Socket
Socket
Sign inDemoInstall

@azure/msal-browser

Package Overview
Dependencies
Maintainers
3
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/msal-browser - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

dist/naa/AuthResult.d.ts

26

dist/naa/BridgeProxy.d.ts
import { AccountInfo } from "./AccountInfo";
import { AccountByHomeIdRequest, AccountByLocalIdRequest, AccountByUsernameRequest } from "./AccountRequests";
import { AuthBridge } from "./AuthBridge";
import { AuthResult } from "./AuthResult";
import { BridgeCapabilities } from "./BridgeCapabilities";
import { BridgeRequest } from "./BridgeRequest";
import { IBridgeProxy } from "./IBridgeProxy";
import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
import { InitContext } from "./InitContext";
import { TokenRequest } from "./TokenRequest";
import { TokenResponse } from "./TokenResponse";
declare global {

@@ -20,3 +20,3 @@ interface Window {

export declare class BridgeProxy implements IBridgeProxy {
static bridgeRequests: any[];
static bridgeRequests: BridgeRequest[];
static crypto: Crypto;

@@ -32,3 +32,3 @@ sdkName: string;

*/
protected static initializeNestedAppAuthBridge(): Promise<InitializeBridgeResponse>;
protected static initializeNestedAppAuthBridge(): Promise<InitContext>;
static getRandomId(): string;

@@ -38,17 +38,12 @@ /**

* @param request A token request
* @returns a promise that resolves to a token response or rejects with a BridgeError
* @returns a promise that resolves to an auth result or rejects with a BridgeError
*/
getTokenInteractive(request: TokenRequest): Promise<TokenResponse>;
getTokenInteractive(request: TokenRequest): Promise<AuthResult>;
/**
* getTokenSilent Attempts to get a token silently from the bridge
* @param request A token request
* @returns a promise that resolves to a token response or rejects with a BridgeError
* @returns a promise that resolves to an auth result or rejects with a BridgeError
*/
getTokenSilent(request: TokenRequest): Promise<TokenResponse>;
/**
* getAccountInfo - Gets account information from the bridge
*
* @param request A request for account information
*/
getAccountInfo(request: AccountByHomeIdRequest | AccountByLocalIdRequest | AccountByUsernameRequest): Promise<AccountInfo>;
getTokenSilent(request: TokenRequest): Promise<AuthResult>;
private getToken;
getActiveAccount(): Promise<AccountInfo>;

@@ -62,2 +57,3 @@ getHostCapabilities(): BridgeCapabilities | null;

private sendRequest;
private static validateBridgeResultOrThrow;
/**

@@ -64,0 +60,0 @@ * Private constructor for BridgeProxy

@@ -1,7 +0,8 @@

export type BridgeRequest<TResponse> = {
import { BridgeResponseEnvelope } from "./BridgeResponseEnvelope";
export type BridgeRequest = {
requestId: string;
method: string;
resolve: (value: TResponse | PromiseLike<TResponse>) => void;
resolve: (value: BridgeResponseEnvelope | PromiseLike<BridgeResponseEnvelope>) => void;
reject: (reason?: any) => void;
};
//# sourceMappingURL=BridgeRequest.d.ts.map
import { TokenRequest } from "./TokenRequest";
import { AccountByHomeIdRequest, AccountByLocalIdRequest, AccountByUsernameRequest } from "./AccountRequests";
export type BridgeMethods = "GetToken" | "GetActiveAccount" | "GetAllAccounts" | "GetAccountByHomeId" | "GetAccountByLocalId" | "GetAccountByUsername" | "GetInitContext" | "GetTokenPopup";
export type BridgeMethods = "GetToken" | "GetActiveAccount" | "GetAllAccounts" | "GetInitContext" | "GetTokenPopup";
export type BridgeRequestEnvelope = {

@@ -11,5 +10,5 @@ messageType: "NestedAppAuthRequest";

requestId: string;
body?: TokenRequest | AccountByHomeIdRequest | AccountByLocalIdRequest | AccountByUsernameRequest;
tokenParams?: TokenRequest;
};
export declare function isBridgeRequestEnvelope(obj: unknown): obj is BridgeRequestEnvelope;
//# sourceMappingURL=BridgeRequestEnvelope.d.ts.map
import { BridgeError } from "./BridgeError";
import { TokenResponse } from "./TokenResponse";
import { AccountInfo } from "./AccountInfo";
import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
import { InitContext } from "./InitContext";
export type BridgeResponseEnvelope = {

@@ -9,4 +9,7 @@ messageType: "NestedAppAuthResponse";

success: boolean;
body: TokenResponse | BridgeError | AccountInfo | AccountInfo[] | InitializeBridgeResponse;
token?: TokenResponse;
error?: BridgeError;
account?: AccountInfo;
initContext?: InitContext;
};
//# sourceMappingURL=BridgeResponseEnvelope.d.ts.map

@@ -1,11 +0,12 @@

export declare enum BridgeStatusCode {
USER_INTERACTION_REQUIRED = "USER_INTERACTION_REQUIRED",
USER_CANCEL = "USER_CANCEL",
NO_NETWORK = "NO_NETWORK",
TRANSIENT_ERROR = "TRANSIENT_ERROR",
PERSISTENT_ERROR = "PERSISTENT_ERROR",
DISABLED = "DISABLED",
ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE",
NESTED_APP_AUTH_UNAVAILABLE = "NESTED_APP_AUTH_UNAVAILABLE"
}
export declare const BridgeStatusCode: {
readonly UserInteractionRequired: "USER_INTERACTION_REQUIRED";
readonly UserCancel: "USER_CANCEL";
readonly NoNetwork: "NO_NETWORK";
readonly TransientError: "TRANSIENT_ERROR";
readonly PersistentError: "PERSISTENT_ERROR";
readonly Disabled: "DISABLED";
readonly AccountUnavailable: "ACCOUNT_UNAVAILABLE";
readonly NestedAppAuthUnavailable: "NESTED_APP_AUTH_UNAVAILABLE";
};
export type BridgeStatusCode = (typeof BridgeStatusCode)[keyof typeof BridgeStatusCode];
//# sourceMappingURL=BridgeStatusCode.d.ts.map
import { AccountInfo } from "./AccountInfo";
import { AccountByHomeIdRequest, AccountByLocalIdRequest, AccountByUsernameRequest } from "./AccountRequests";
import { AuthResult } from "./AuthResult";
import { BridgeCapabilities } from "./BridgeCapabilities";
import { TokenRequest } from "./TokenRequest";
import { TokenResponse } from "./TokenResponse";
export interface IBridgeProxy {
getTokenInteractive(request: TokenRequest): Promise<TokenResponse>;
getTokenSilent(request: TokenRequest): Promise<TokenResponse>;
getAccountInfo(request: AccountByHomeIdRequest | AccountByLocalIdRequest | AccountByUsernameRequest): Promise<AccountInfo>;
getTokenInteractive(request: TokenRequest): Promise<AuthResult>;
getTokenSilent(request: TokenRequest): Promise<AuthResult>;
getActiveAccount(): Promise<AccountInfo>;

@@ -11,0 +9,0 @@ getHostCapabilities(): BridgeCapabilities | null;

@@ -5,5 +5,5 @@ import { TokenRequest } from "../TokenRequest";

import { PopupRequest } from "../../request/PopupRequest";
import { TokenResponse } from "../TokenResponse";
import { AccountInfo as MsalAccountInfo, AuthError, ClientAuthError, ClientConfigurationError, InteractionRequiredAuthError, ServerError, ICrypto, Logger, TokenClaims } from "@azure/msal-common";
import { AuthenticationResult } from "../../response/AuthenticationResult";
import { AuthResult } from "../AuthResult";
export declare class NestedAppAuthAdapter {

@@ -16,3 +16,3 @@ protected crypto: ICrypto;

toNaaTokenRequest(request: PopupRequest | RedirectRequest): TokenRequest;
fromNaaTokenResponse(request: TokenRequest, response: TokenResponse, reqTimestamp: number): AuthenticationResult;
fromNaaTokenResponse(request: TokenRequest, response: AuthResult, reqTimestamp: number): AuthenticationResult;
fromNaaAccountInfo(fromAccount: NaaAccountInfo, idTokenClaims?: TokenClaims): MsalAccountInfo;

@@ -19,0 +19,0 @@ /**

export type TokenRequest = {
userObjectId?: string;
platformBrokerId?: string;
clientId: string;

@@ -7,3 +7,2 @@ authority?: string;

correlationId: string;
nonce?: string;
claims?: string;

@@ -10,0 +9,0 @@ state?: string;

@@ -1,9 +0,7 @@

import { AccountInfo } from "./AccountInfo";
export type TokenResponse = {
access_token: string;
account: AccountInfo;
expires_in: number;
id_token: string;
properties: TokenResponseProperties | null;
scope: string;
scope?: string;
shr?: string;

@@ -10,0 +8,0 @@ extendedLifetimeToken?: boolean;

@@ -1,2 +0,2 @@

import { Logger } from "@azure/msal-common";
import { Logger, LogLevel } from "@azure/msal-common";
import { BrowserConfiguration, Configuration } from "../config/Configuration";

@@ -15,2 +15,3 @@ /**

protected browserEnvironment: boolean;
protected static loggerCallback(level: LogLevel, message: string): void;
constructor(config: Configuration);

@@ -17,0 +18,0 @@ /**

export declare const name = "@azure/msal-browser";
export declare const version = "3.6.0";
export declare const version = "3.7.0";
//# sourceMappingURL=packageMetadata.d.ts.map

@@ -1,10 +0,8 @@

import { PerformanceEvents, IPerformanceClient, PerformanceClient, IPerformanceMeasurement, InProgressPerformanceEvent } from "@azure/msal-common";
import { InProgressPerformanceEvent, IPerformanceClient, PerformanceClient, PerformanceEvents } from "@azure/msal-common";
import { Configuration } from "../config/Configuration";
export declare class BrowserPerformanceClient extends PerformanceClient implements IPerformanceClient {
constructor(configuration: Configuration, intFields?: Set<string>);
startPerformanceMeasurement(measureName: string, correlationId: string): IPerformanceMeasurement;
generateId(): string;
private getPageVisibility;
private deleteIncompleteSubMeasurements;
supportsBrowserPerformanceNow(): boolean;
/**

@@ -11,0 +9,0 @@ * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.

@@ -177,2 +177,6 @@ import { PopupRequest } from "../request/PopupRequest";

export type CacheLookupPolicy = (typeof CacheLookupPolicy)[keyof typeof CacheLookupPolicy];
export declare const iFrameRenewalPolicies: CacheLookupPolicy[];
export declare const LOG_LEVEL_CACHE_KEY = "msal.browser.log.level";
export declare const LOG_PII_CACHE_KEY = "msal.browser.log.pii";
export declare const BROWSER_PERF_ENABLED_KEY = "msal.browser.performance.enabled";
//# sourceMappingURL=BrowserConstants.d.ts.map

@@ -13,3 +13,3 @@ {

},
"version": "3.6.0",
"version": "3.7.0",
"description": "Microsoft Authentication Library for js",

@@ -105,4 +105,4 @@ "keywords": [

"dependencies": {
"@azure/msal-common": "14.5.0"
"@azure/msal-common": "14.6.0"
}
}

@@ -273,5 +273,6 @@ /*

clientInfo,
authority.hostnameAndPort,
claimsTenantId,
undefined,
undefined,
undefined, // authCodePayload
undefined, // nativeAccountId
this.logger

@@ -278,0 +279,0 @@ );

@@ -433,4 +433,5 @@ /*

response.client_info,
undefined, // environment
idTokenClaims.tid,
undefined,
undefined, // auth code payload
response.account.id,

@@ -437,0 +438,0 @@ this.logger

@@ -47,2 +47,10 @@ /*

};
if (request.redirectUri) {
// Make sure any passed redirectUri is converted to an absolute URL - redirectUri is not a required parameter for refresh token redemption so only include if explicitly provided
silentRequest.redirectUri = this.getRedirectUri(
request.redirectUri
);
}
const serverTelemetryManager = this.initializeServerTelemetryManager(

@@ -49,0 +57,0 @@ ApiId.acquireTokenSilent_silentFlow

@@ -7,16 +7,13 @@ /*

import { AccountInfo } from "./AccountInfo";
import {
AccountByHomeIdRequest,
AccountByLocalIdRequest,
AccountByUsernameRequest,
} from "./AccountRequests";
import { AuthBridge, AuthBridgeResponse } from "./AuthBridge";
import { AuthResult } from "./AuthResult";
import { BridgeCapabilities } from "./BridgeCapabilities";
import { BridgeError } from "./BridgeError";
import { BridgeRequest } from "./BridgeRequest";
import { BridgeRequestEnvelope, BridgeMethods } from "./BridgeRequestEnvelope";
import { BridgeResponseEnvelope } from "./BridgeResponseEnvelope";
import { BridgeStatusCode } from "./BridgeStatusCode";
import { IBridgeProxy } from "./IBridgeProxy";
import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
import { InitContext } from "./InitContext";
import { TokenRequest } from "./TokenRequest";
import { TokenResponse } from "./TokenResponse";

@@ -35,4 +32,3 @@ declare global {

export class BridgeProxy implements IBridgeProxy {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static bridgeRequests: any[] = [];
static bridgeRequests: BridgeRequest[] = [];
static crypto: Crypto;

@@ -49,3 +45,3 @@ sdkName: string;

*/
protected static async initializeNestedAppAuthBridge(): Promise<InitializeBridgeResponse> {
protected static async initializeNestedAppAuthBridge(): Promise<InitContext> {
if (window === undefined) {

@@ -81,5 +77,5 @@ throw new Error("window is undefined");

if (responseEnvelope.success) {
request.resolve(responseEnvelope.body);
request.resolve(responseEnvelope);
} else {
request.reject(responseEnvelope.body);
request.reject(responseEnvelope.error);
}

@@ -90,3 +86,3 @@ }

const promise = new Promise<InitializeBridgeResponse>(
const bridgeResponse = await new Promise<BridgeResponseEnvelope>(
(resolve, reject) => {

@@ -98,3 +94,3 @@ const message: BridgeRequestEnvelope = {

};
const request: BridgeRequest<InitializeBridgeResponse> = {
const request: BridgeRequest = {
requestId: message.requestId,

@@ -112,3 +108,5 @@ method: message.method,

return await promise;
return BridgeProxy.validateBridgeResultOrThrow(
bridgeResponse.initContext
);
} catch (error) {

@@ -127,6 +125,6 @@ window.console.log(error);

* @param request A token request
* @returns a promise that resolves to a token response or rejects with a BridgeError
* @returns a promise that resolves to an auth result or rejects with a BridgeError
*/
public getTokenInteractive(request: TokenRequest): Promise<TokenResponse> {
return this.sendRequest<TokenResponse>("GetTokenPopup", request);
public getTokenInteractive(request: TokenRequest): Promise<AuthResult> {
return this.getToken("GetTokenPopup", request);
}

@@ -137,38 +135,24 @@

* @param request A token request
* @returns a promise that resolves to a token response or rejects with a BridgeError
* @returns a promise that resolves to an auth result or rejects with a BridgeError
*/
public getTokenSilent(request: TokenRequest): Promise<TokenResponse> {
return this.sendRequest<TokenResponse>("GetToken", request);
public getTokenSilent(request: TokenRequest): Promise<AuthResult> {
return this.getToken("GetToken", request);
}
/**
* getAccountInfo - Gets account information from the bridge
*
* @param request A request for account information
*/
public getAccountInfo(
request:
| AccountByHomeIdRequest
| AccountByLocalIdRequest
| AccountByUsernameRequest
): Promise<AccountInfo> {
let method: BridgeMethods = "GetAccountByHomeId";
if ((request as AccountByHomeIdRequest).homeAccountId !== undefined) {
method = "GetAccountByHomeId";
}
if ((request as AccountByLocalIdRequest).localAccountId !== undefined) {
method = "GetAccountByLocalId";
}
if ((request as AccountByUsernameRequest).username !== undefined) {
method = "GetAccountByUsername";
}
return this.sendRequest<AccountInfo>(method, request);
private async getToken(
requestType: BridgeMethods,
request: TokenRequest
): Promise<AuthResult> {
const result = await this.sendRequest(requestType, {
tokenParams: request,
});
return {
token: BridgeProxy.validateBridgeResultOrThrow(result.token),
account: BridgeProxy.validateBridgeResultOrThrow(result.account),
};
}
public getActiveAccount(): Promise<AccountInfo> {
return this.sendRequest<AccountInfo>("GetActiveAccount", undefined);
public async getActiveAccount(): Promise<AccountInfo> {
const result = await this.sendRequest("GetActiveAccount");
return BridgeProxy.validateBridgeResultOrThrow(result.account);
}

@@ -185,11 +169,6 @@

*/
private sendRequest<TResponse>(
private sendRequest(
method: BridgeMethods,
request:
| TokenRequest
| AccountByHomeIdRequest
| AccountByLocalIdRequest
| AccountByUsernameRequest
| undefined
): Promise<TResponse> {
requestParams?: Partial<BridgeRequestEnvelope>
): Promise<BridgeResponseEnvelope> {
const message: BridgeRequestEnvelope = {

@@ -199,15 +178,17 @@ messageType: "NestedAppAuthRequest",

requestId: BridgeProxy.getRandomId(),
body: request,
...requestParams,
};
const promise = new Promise<TResponse>((resolve, reject) => {
const request: BridgeRequest<TResponse> = {
requestId: message.requestId,
method: message.method,
resolve: resolve,
reject: reject,
};
BridgeProxy.bridgeRequests.push(request);
window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
});
const promise = new Promise<BridgeResponseEnvelope>(
(resolve, reject) => {
const request: BridgeRequest = {
requestId: message.requestId,
method: message.method,
resolve: resolve,
reject: reject,
};
BridgeProxy.bridgeRequests.push(request);
window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
}
);

@@ -217,2 +198,12 @@ return promise;

private static validateBridgeResultOrThrow<T>(input: T | undefined): T {
if (input === undefined) {
const bridgeError: BridgeError = {
status: BridgeStatusCode.NestedAppAuthUnavailable,
};
throw bridgeError;
}
return input;
}
/**

@@ -219,0 +210,0 @@ * Private constructor for BridgeProxy

@@ -6,8 +6,12 @@ /*

export type BridgeRequest<TResponse> = {
import { BridgeResponseEnvelope } from "./BridgeResponseEnvelope";
export type BridgeRequest = {
requestId: string;
method: string;
resolve: (value: TResponse | PromiseLike<TResponse>) => void;
resolve: (
value: BridgeResponseEnvelope | PromiseLike<BridgeResponseEnvelope>
) => void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
reject: (reason?: any) => void;
};

@@ -7,7 +7,2 @@ /*

import { TokenRequest } from "./TokenRequest";
import {
AccountByHomeIdRequest,
AccountByLocalIdRequest,
AccountByUsernameRequest,
} from "./AccountRequests";

@@ -18,5 +13,2 @@ export type BridgeMethods =

| "GetAllAccounts"
| "GetAccountByHomeId"
| "GetAccountByLocalId"
| "GetAccountByUsername"
| "GetInitContext"

@@ -32,7 +24,3 @@ | "GetTokenPopup";

requestId: string;
body?:
| TokenRequest
| AccountByHomeIdRequest
| AccountByLocalIdRequest
| AccountByUsernameRequest;
tokenParams?: TokenRequest;
};

@@ -39,0 +27,0 @@

@@ -9,3 +9,3 @@ /*

import { AccountInfo } from "./AccountInfo";
import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
import { InitContext } from "./InitContext";

@@ -16,8 +16,6 @@ export type BridgeResponseEnvelope = {

success: boolean; // false if body is error
body:
| TokenResponse
| BridgeError
| AccountInfo
| AccountInfo[]
| InitializeBridgeResponse;
token?: TokenResponse;
error?: BridgeError;
account?: AccountInfo;
initContext?: InitContext;
};

@@ -6,11 +6,13 @@ /*

export enum BridgeStatusCode {
USER_INTERACTION_REQUIRED = "USER_INTERACTION_REQUIRED",
USER_CANCEL = "USER_CANCEL",
NO_NETWORK = "NO_NETWORK",
TRANSIENT_ERROR = "TRANSIENT_ERROR",
PERSISTENT_ERROR = "PERSISTENT_ERROR",
DISABLED = "DISABLED",
ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE",
NESTED_APP_AUTH_UNAVAILABLE = "NESTED_APP_AUTH_UNAVAILABLE", // NAA is unavailable in the current context, can retry with standard browser based auth
}
export const BridgeStatusCode = {
UserInteractionRequired: "USER_INTERACTION_REQUIRED",
UserCancel: "USER_CANCEL",
NoNetwork: "NO_NETWORK",
TransientError: "TRANSIENT_ERROR",
PersistentError: "PERSISTENT_ERROR",
Disabled: "DISABLED",
AccountUnavailable: "ACCOUNT_UNAVAILABLE",
NestedAppAuthUnavailable: "NESTED_APP_AUTH_UNAVAILABLE", // NAA is unavailable in the current context, can retry with standard browser based auth
} as const;
export type BridgeStatusCode =
(typeof BridgeStatusCode)[keyof typeof BridgeStatusCode];

@@ -7,22 +7,11 @@ /*

import { AccountInfo } from "./AccountInfo";
import {
AccountByHomeIdRequest,
AccountByLocalIdRequest,
AccountByUsernameRequest,
} from "./AccountRequests";
import { AuthResult } from "./AuthResult";
import { BridgeCapabilities } from "./BridgeCapabilities";
import { TokenRequest } from "./TokenRequest";
import { TokenResponse } from "./TokenResponse";
export interface IBridgeProxy {
getTokenInteractive(request: TokenRequest): Promise<TokenResponse>;
getTokenSilent(request: TokenRequest): Promise<TokenResponse>;
getAccountInfo(
request:
| AccountByHomeIdRequest
| AccountByLocalIdRequest
| AccountByUsernameRequest
): Promise<AccountInfo>;
getTokenInteractive(request: TokenRequest): Promise<AuthResult>;
getTokenSilent(request: TokenRequest): Promise<AuthResult>;
getActiveAccount(): Promise<AccountInfo>;
getHostCapabilities(): BridgeCapabilities | null;
}

@@ -10,3 +10,2 @@ /*

import { PopupRequest } from "../../request/PopupRequest";
import { TokenResponse } from "../TokenResponse";
import {

@@ -33,2 +32,3 @@ AccountInfo as MsalAccountInfo,

import {} from "../../error/BrowserAuthErrorCodes";
import { AuthResult } from "../AuthResult";

@@ -71,3 +71,3 @@ export class NestedAppAuthAdapter {

const tokenRequest: TokenRequest = {
userObjectId: request.account?.homeAccountId,
platformBrokerId: request.account?.homeAccountId,
clientId: this.clientId,

@@ -80,3 +80,2 @@ authority: request.authority,

: this.crypto.createNewGuid(),
nonce: request.nonce,
claims: !StringUtils.isEmptyObj(claims) ? claims : undefined,

@@ -94,6 +93,6 @@ state: request.state,

request: TokenRequest,
response: TokenResponse,
response: AuthResult,
reqTimestamp: number
): AuthenticationResult {
if (!response.id_token || !response.access_token) {
if (!response.token.id_token || !response.token.access_token) {
throw createClientAuthError(ClientAuthErrorCodes.nullOrEmptyToken);

@@ -103,6 +102,6 @@ }

const expiresOn = new Date(
(reqTimestamp + (response.expires_in || 0)) * 1000
(reqTimestamp + (response.token.expires_in || 0)) * 1000
);
const idTokenClaims = AuthToken.extractTokenClaims(
response.id_token,
response.token.id_token,
this.crypto.base64Decode

@@ -114,12 +113,13 @@ );

);
const scopes = response.token.scope || request.scope;
const authenticationResult: AuthenticationResult = {
authority: response.authority || account.environment,
authority: response.token.authority || account.environment,
uniqueId: account.localAccountId,
tenantId: account.tenantId,
scopes: response.scope.split(" "),
scopes: scopes.split(" "),
account,
idToken: response.id_token !== undefined ? response.id_token : "",
idToken: response.token.id_token,
idTokenClaims,
accessToken: response.access_token,
accessToken: response.token.access_token,
fromCache: true,

@@ -214,19 +214,19 @@ expiresOn: expiresOn,

switch (error.status) {
case BridgeStatusCode.USER_CANCEL:
case BridgeStatusCode.UserCancel:
return new ClientAuthError(
ClientAuthErrorCodes.userCanceled
);
case BridgeStatusCode.NO_NETWORK:
case BridgeStatusCode.NoNetwork:
return new ClientAuthError(
ClientAuthErrorCodes.noNetworkConnectivity
);
case BridgeStatusCode.ACCOUNT_UNAVAILABLE:
case BridgeStatusCode.AccountUnavailable:
return new ClientAuthError(
ClientAuthErrorCodes.noAccountFound
);
case BridgeStatusCode.DISABLED:
case BridgeStatusCode.Disabled:
return new ClientAuthError(
ClientAuthErrorCodes.nestedAppAuthBridgeDisabled
);
case BridgeStatusCode.NESTED_APP_AUTH_UNAVAILABLE:
case BridgeStatusCode.NestedAppAuthUnavailable:
return new ClientAuthError(

@@ -237,6 +237,6 @@ error.code ||

);
case BridgeStatusCode.TRANSIENT_ERROR:
case BridgeStatusCode.PERSISTENT_ERROR:
case BridgeStatusCode.TransientError:
case BridgeStatusCode.PersistentError:
return new ServerError(error.code, error.description);
case BridgeStatusCode.USER_INTERACTION_REQUIRED:
case BridgeStatusCode.UserInteractionRequired:
return new InteractionRequiredAuthError(

@@ -243,0 +243,0 @@ error.code,

@@ -7,3 +7,3 @@ /*

export type TokenRequest = {
userObjectId?: string; // Account identifier used by OneAuth
platformBrokerId?: string; // Account identifier used by OneAuth
clientId: string;

@@ -13,3 +13,2 @@ authority?: string;

correlationId: string;
nonce?: string;
claims?: string;

@@ -16,0 +15,0 @@ state?: string;

@@ -6,11 +6,8 @@ /*

import { AccountInfo } from "./AccountInfo";
export type TokenResponse = {
access_token: string;
account: AccountInfo;
expires_in: number;
id_token: string;
properties: TokenResponseProperties | null;
scope: string;
scope?: string;
shr?: string; // token binding enabled at native layer it is the access token, not the signing keys

@@ -17,0 +14,0 @@ extendedLifetimeToken?: boolean;

@@ -6,3 +6,3 @@ /*

import { Logger } from "@azure/msal-common";
import { Logger, LogLevel } from "@azure/msal-common";
import {

@@ -14,2 +14,7 @@ BrowserConfiguration,

import { version, name } from "../packageMetadata";
import {
BrowserCacheLocation,
LOG_LEVEL_CACHE_KEY,
LOG_PII_CACHE_KEY,
} from "../utils/BrowserConstants";

@@ -29,2 +34,27 @@ /**

protected static loggerCallback(level: LogLevel, message: string): void {
switch (level) {
case LogLevel.Error:
// eslint-disable-next-line no-console
console.error(message);
return;
case LogLevel.Info:
// eslint-disable-next-line no-console
console.info(message);
return;
case LogLevel.Verbose:
// eslint-disable-next-line no-console
console.debug(message);
return;
case LogLevel.Warning:
// eslint-disable-next-line no-console
console.warn(message);
return;
default:
// eslint-disable-next-line no-console
console.log(message);
return;
}
}
constructor(config: Configuration) {

@@ -37,9 +67,36 @@ /*

this.browserEnvironment = typeof window !== "undefined";
this.config = buildConfiguration(config, this.browserEnvironment);
this.config = buildConfiguration(config, this.browserEnvironment);
this.logger = new Logger(
this.config.system.loggerOptions,
name,
version
);
let sessionStorage: Storage | undefined;
try {
sessionStorage = window[BrowserCacheLocation.SessionStorage];
// Mute errors if it's a non-browser environment or cookies are blocked.
} catch (e) {}
const logLevelKey = sessionStorage?.getItem(LOG_LEVEL_CACHE_KEY);
const piiLoggingKey = sessionStorage
?.getItem(LOG_PII_CACHE_KEY)
?.toLowerCase();
const piiLoggingEnabled =
piiLoggingKey === "true"
? true
: piiLoggingKey === "false"
? false
: undefined;
const loggerOptions = { ...this.config.system.loggerOptions };
const logLevel =
logLevelKey && Object.keys(LogLevel).includes(logLevelKey)
? LogLevel[logLevelKey]
: undefined;
if (logLevel) {
loggerOptions.loggerCallback = BaseOperatingContext.loggerCallback;
loggerOptions.logLevel = logLevel;
}
if (piiLoggingEnabled !== undefined) {
loggerOptions.piiLoggingEnabled = piiLoggingEnabled;
}
this.logger = new Logger(loggerOptions, name, version);
this.available = false;

@@ -46,0 +103,0 @@ }

/* eslint-disable header/header */
export const name = "@azure/msal-browser";
export const version = "3.6.0";
export const version = "3.7.0";

@@ -7,17 +7,62 @@ /*

import {
Constants,
InProgressPerformanceEvent,
IPerformanceClient,
Logger,
PerformanceClient,
PerformanceEvent,
PerformanceEvents,
IPerformanceClient,
PerformanceClient,
IPerformanceMeasurement,
InProgressPerformanceEvent,
PreQueueEvent,
SubMeasurement,
PreQueueEvent,
Constants,
} from "@azure/msal-common";
import { BrowserPerformanceMeasurement } from "./BrowserPerformanceMeasurement";
import { Configuration } from "../config/Configuration";
import { name, version } from "../packageMetadata";
import {
BROWSER_PERF_ENABLED_KEY,
BrowserCacheLocation,
} from "../utils/BrowserConstants";
/**
* Returns browser performance measurement module if session flag is enabled. Returns undefined otherwise.
*/
function getPerfMeasurementModule() {
let sessionStorage: Storage | undefined;
try {
sessionStorage = window[BrowserCacheLocation.SessionStorage];
const perfEnabled = sessionStorage?.getItem(BROWSER_PERF_ENABLED_KEY);
if (Number(perfEnabled) === 1) {
return import("./BrowserPerformanceMeasurement");
}
// Mute errors if it's a non-browser environment or cookies are blocked.
} catch (e) {}
return undefined;
}
/**
* Returns boolean, indicating whether browser supports window.performance.now() function.
*/
function supportsBrowserPerformanceNow(): boolean {
return (
typeof window !== "undefined" &&
typeof window.performance !== "undefined" &&
typeof window.performance.now === "function"
);
}
/**
* Returns event duration in milliseconds using window performance API if available. Returns undefined otherwise.
* @param startTime {DOMHighResTimeStamp | undefined}
* @returns {number | undefined}
*/
function getPerfDurationMs(
startTime: DOMHighResTimeStamp | undefined
): number | undefined {
if (!startTime || !supportsBrowserPerformanceNow()) {
return undefined;
}
return Math.round(window.performance.now() - startTime);
}
export class BrowserPerformanceClient

@@ -46,9 +91,2 @@ extends PerformanceClient

startPerformanceMeasurement(
measureName: string,
correlationId: string
): IPerformanceMeasurement {
return new BrowserPerformanceMeasurement(measureName, correlationId);
}
generateId(): string {

@@ -65,30 +103,25 @@ return window.crypto.randomUUID();

): void {
const rootEvent = this.eventsByCorrelationId.get(
inProgressEvent.event.correlationId
);
const isRootEvent =
rootEvent && rootEvent.eventId === inProgressEvent.event.eventId;
const incompleteMeasurements: SubMeasurement[] = [];
if (isRootEvent && rootEvent?.incompleteSubMeasurements) {
rootEvent.incompleteSubMeasurements.forEach((subMeasurement) => {
incompleteMeasurements.push({ ...subMeasurement });
});
}
// Clean up remaining marks for incomplete sub-measurements
if (incompleteMeasurements.length > 0) {
BrowserPerformanceMeasurement.flushMeasurements(
void getPerfMeasurementModule()?.then((module) => {
const rootEvent = this.eventsByCorrelationId.get(
inProgressEvent.event.correlationId
);
const isRootEvent =
rootEvent &&
rootEvent.eventId === inProgressEvent.event.eventId;
const incompleteMeasurements: SubMeasurement[] = [];
if (isRootEvent && rootEvent?.incompleteSubMeasurements) {
rootEvent.incompleteSubMeasurements.forEach(
(subMeasurement: SubMeasurement) => {
incompleteMeasurements.push({ ...subMeasurement });
}
);
}
// Clean up remaining marks for incomplete sub-measurements
module.BrowserPerformanceMeasurement.flushMeasurements(
inProgressEvent.event.correlationId,
incompleteMeasurements
);
}
});
}
supportsBrowserPerformanceNow(): boolean {
return (
typeof window !== "undefined" &&
typeof window.performance !== "undefined" &&
typeof window.performance.now === "function"
);
}
/**

@@ -108,3 +141,2 @@ * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.

const startPageVisibility = this.getPageVisibility();
const inProgressEvent = super.startMeasurement(

@@ -114,3 +146,18 @@ measureName,

);
const startTime: number | undefined = supportsBrowserPerformanceNow()
? window.performance.now()
: undefined;
const browserMeasurement = getPerfMeasurementModule()?.then(
(module) => {
return new module.BrowserPerformanceMeasurement(
measureName,
inProgressEvent.event.correlationId
);
}
);
void browserMeasurement?.then((measurement) =>
measurement.startMeasurement()
);
return {

@@ -122,6 +169,10 @@ ...inProgressEvent,

const res = inProgressEvent.end({
...event,
startPageVisibility,
endPageVisibility: this.getPageVisibility(),
...event,
durationMs: getPerfDurationMs(startTime),
});
void browserMeasurement?.then((measurement) =>
measurement.endMeasurement()
);
this.deleteIncompleteSubMeasurements(inProgressEvent);

@@ -133,4 +184,6 @@

inProgressEvent.discard();
void browserMeasurement?.then((measurement) =>
measurement.flushMeasurement()
);
this.deleteIncompleteSubMeasurements(inProgressEvent);
inProgressEvent.measurement.flushMeasurement();
},

@@ -150,3 +203,3 @@ };

): void {
if (!this.supportsBrowserPerformanceNow()) {
if (!supportsBrowserPerformanceNow()) {
this.logger.trace(

@@ -204,3 +257,3 @@ `BrowserPerformanceClient: window performance API not available, unable to set telemetry queue time for ${eventName}`

): void {
if (!this.supportsBrowserPerformanceNow()) {
if (!supportsBrowserPerformanceNow()) {
this.logger.trace(

@@ -207,0 +260,0 @@ `BrowserPerformanceClient: window performance API not available, unable to add queue measurement for ${eventName}`

@@ -242,1 +242,12 @@ /*

(typeof CacheLookupPolicy)[keyof typeof CacheLookupPolicy];
export const iFrameRenewalPolicies: CacheLookupPolicy[] = [
CacheLookupPolicy.Default,
CacheLookupPolicy.Skip,
CacheLookupPolicy.RefreshTokenAndNetwork,
];
export const LOG_LEVEL_CACHE_KEY = "msal.browser.log.level";
export const LOG_PII_CACHE_KEY = "msal.browser.log.pii";
export const BROWSER_PERF_ENABLED_KEY = "msal.browser.performance.enabled";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc