Socket
Socket
Sign inDemoInstall

@azure/msal-browser

Package Overview
Dependencies
Maintainers
3
Versions
117
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.20.0 to 3.21.0

0

dist/app/IPublicClientApplication.d.ts

@@ -0,0 +0,0 @@ import { AccountFilter, AccountInfo, Logger, PerformanceCallbackFunction } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { ITokenCache } from "../cache/ITokenCache";

@@ -0,0 +0,0 @@ import { ITokenCache } from "../cache/ITokenCache";

@@ -0,0 +0,0 @@ import { Logger, AuthenticationScheme, IPerformanceClient } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { NativeExtensionMethod } from "../../utils/BrowserConstants";

@@ -0,0 +0,0 @@ export declare const USER_INTERACTION_REQUIRED = "USER_INTERACTION_REQUIRED";

@@ -0,0 +0,0 @@ import { AccountInfo, AccountFilter, Logger } from "@azure/msal-common";

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

25

dist/cache/BrowserCacheManager.d.ts

@@ -350,2 +350,27 @@ import { CommonAuthorizationCodeRequest, ICrypto, AccountEntity, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, CacheManager, ServerTelemetryEntity, ThrottlingEntity, Logger, AuthorityMetadataEntity, AccountInfo, ValidCredentialType, TokenKeys, CredentialType, CacheRecord, IPerformanceClient, StaticAuthorityOptions, StoreInCache } from "@azure/msal-common";

cleanRequestByInteractionType(interactionType: InteractionType): void;
/**
* Create request retry key to cache retry status
*/
generateRequestRetriedKey(): string;
/**
* Gets the request retry value from the cache
*/
getRequestRetried(): number | null;
/**
* Sets the request retry value to "retried" in the cache
*/
setRequestRetried(): void;
/**
* Removes all request retry values in the cache
*/
removeRequestRetried(): void;
/**
* Caches the redirectRequest in the cache
* @param redirectRequest
*/
cacheRedirectRequest(redirectRequest: RedirectRequest): void;
/**
* Gets redirect request from the cache. Logs an error and returns undefined if nothing is found.
*/
getCachedRedirectRequest(): RedirectRequest | undefined;
cacheCodeRequest(authCodeRequest: CommonAuthorizationCodeRequest): void;

@@ -352,0 +377,0 @@ /**

@@ -0,0 +0,0 @@ import { IWindowStorage } from "./IWindowStorage";

@@ -0,0 +0,0 @@ import { IAsyncStorage } from "./IAsyncStorage";

@@ -0,0 +0,0 @@ export interface IAsyncStorage<T> {

@@ -0,0 +0,0 @@ import { ExternalTokenResponse } from "@azure/msal-common";

@@ -0,0 +0,0 @@ export interface IWindowStorage<T> {

@@ -0,0 +0,0 @@ import { IWindowStorage } from "./IWindowStorage";

@@ -0,0 +0,0 @@ import { ICrypto, Logger, ExternalTokenResponse } from "@azure/msal-common";

@@ -70,6 +70,11 @@ import { SystemOptions, LoggerOptions, INetworkModule, ProtocolMode, OIDCOptions, AzureCloudOptions, ApplicationTelemetry, IPerformanceClient } from "@azure/msal-common";

supportsNestedAppAuth?: boolean;
/**
* Callback that will be passed the url that MSAL will navigate to in redirect flows. Returning false in the callback will stop navigation.
*/
onRedirectNavigate?: (url: string) => boolean | void;
};
/** @internal */
export type InternalAuthOptions = Required<BrowserAuthOptions> & {
export type InternalAuthOptions = Omit<Required<BrowserAuthOptions>, "onRedirectNavigate"> & {
OIDCOptions: Required<OIDCOptions>;
onRedirectNavigate?: (url: string) => boolean | void;
};

@@ -76,0 +81,0 @@ /**

@@ -0,0 +0,0 @@ import { IController } from "./IController";

@@ -0,0 +0,0 @@ import { AccountInfo, Logger, PerformanceCallbackFunction, IPerformanceClient, AccountFilter } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { CommonAuthorizationUrlRequest, CommonSilentFlowRequest, PerformanceCallbackFunction, AccountInfo, Logger, ICrypto, IPerformanceClient, AccountFilter } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { AccountInfo, INetworkModule, Logger, CommonSilentFlowRequest, ICrypto, PerformanceCallbackFunction, IPerformanceClient, BaseAuthRequest, AccountFilter } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { CommonAuthorizationUrlRequest, CommonSilentFlowRequest, PerformanceCallbackFunction, AccountInfo, Logger, ICrypto, IPerformanceClient, AccountFilter } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { IPerformanceClient, Logger } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { ICrypto, IPerformanceClient, Logger, ShrOptions, SignedHttpRequest, SignedHttpRequestParameters } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { IPerformanceClient, Logger, PkceCodes } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { LoggerOptions, SignedHttpRequestParameters } from "@azure/msal-common";

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

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

@@ -54,2 +54,3 @@ import { AuthError } from "@azure/msal-common";

invalid_pop_token_request: string;
failed_to_retry: string;
};

@@ -56,0 +57,0 @@ /**

@@ -47,2 +47,3 @@ export declare const pkceNotCreated = "pkce_not_created";

export declare const invalidPopTokenRequest = "invalid_pop_token_request";
export declare const failedToRetry = "failed_to_retry";
//# sourceMappingURL=BrowserAuthErrorCodes.d.ts.map

@@ -0,0 +0,0 @@ import { AuthError } from "@azure/msal-common";

@@ -0,0 +0,0 @@ export declare const storageNotSupported = "storage_not_supported";

@@ -0,0 +0,0 @@ import { AuthError } from "@azure/msal-common";

export declare const contentError = "ContentError";
export declare const userSwitch = "user_switch";
//# sourceMappingURL=NativeAuthErrorCodes.d.ts.map

@@ -0,0 +0,0 @@ import { AuthError } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { ICrypto, Logger } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { AuthError, AccountInfo } from "@azure/msal-common";

@@ -0,0 +0,0 @@ export declare const EventType: {

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

@@ -0,0 +0,0 @@ import { ICrypto, INetworkModule, Logger, AccountInfo, ServerTelemetryManager, Authority, IPerformanceClient, AzureCloudOptions } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { AuthorizationCodeClient, ClientConfiguration } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { Logger, ICrypto, AccountEntity, ScopeSet, IPerformanceClient, TokenClaims, InProgressPerformanceEvent, ServerTelemetryManager } from "@azure/msal-common";

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

import { CommonEndSessionRequest, IPerformanceClient, Logger, ICrypto } from "@azure/msal-common";
import { CommonAuthorizationCodeRequest, AuthorizationCodeClient, CommonEndSessionRequest, IPerformanceClient, Logger, ICrypto } from "@azure/msal-common";
import { StandardInteractionClient } from "./StandardInteractionClient";

@@ -12,2 +12,3 @@ import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";

import { AuthenticationResult } from "../response/AuthenticationResult";
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
export type PopupParams = {

@@ -33,3 +34,3 @@ popup?: Window | null;

/**
* Helper which obtains an access_token for your API via opening a popup window in the user's browser
* Helper which initializes authorization clients and requests
* @param validRequest

@@ -44,2 +45,14 @@ * @param popupName

/**
* Helper which obtains an access_token for your API via opening a popup window in the user's browser
* @param authClient
* @param authCodeRequest
* @param validRequest
* @param request
* @param popupName
* @param popupWindowAttributes
* @param popup
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
*/
protected acquireTokenPopupAsyncHelper(authClient: AuthorizationCodeClient, authCodeRequest: CommonAuthorizationCodeRequest, validRequest: AuthorizationUrlRequest, request: PopupRequest, popupName: string, popupWindowAttributes: PopupWindowAttributes, popup?: Window | null): Promise<AuthenticationResult>;
/**
*

@@ -46,0 +59,0 @@ * @param validRequest

@@ -0,0 +0,0 @@ import { ServerTelemetryManager, ServerAuthorizationCodeResponse, ICrypto, Logger, IPerformanceClient, InProgressPerformanceEvent } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { ICrypto, Logger, IPerformanceClient } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { StandardInteractionClient } from "./StandardInteractionClient";

@@ -0,0 +0,0 @@ import { ICrypto, Logger, AuthorizationCodeClient, IPerformanceClient } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { StandardInteractionClient } from "./StandardInteractionClient";

@@ -0,0 +0,0 @@ import { ServerTelemetryManager, CommonAuthorizationCodeRequest, AuthorizationCodeClient, ClientConfiguration, CommonEndSessionRequest, AccountInfo, AzureCloudOptions } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { AuthorizationCodePayload, CommonAuthorizationCodeRequest, AuthorizationCodeClient, CcsCredential, Logger, IPerformanceClient, ServerAuthorizationCodeResponse } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { AuthorizationCodeClient, CommonAuthorizationCodeRequest, Logger, IPerformanceClient, CcsCredential, ServerAuthorizationCodeResponse } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { Logger, IPerformanceClient, ServerResponseType } from "@azure/msal-common";

@@ -0,0 +0,0 @@ export type AccountInfo = {

@@ -0,0 +0,0 @@ export type AuthBridgeResponse = string | {

@@ -0,0 +0,0 @@ import { AccountInfo } from "./AccountInfo";

@@ -0,0 +0,0 @@ export interface BridgeCapabilities {

@@ -0,0 +0,0 @@ import { BridgeStatusCode } from "./BridgeStatusCode";

@@ -0,0 +0,0 @@ import { AuthBridge } from "./AuthBridge";

@@ -0,0 +0,0 @@ import { BridgeResponseEnvelope } from "./BridgeResponseEnvelope";

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

@@ -0,0 +0,0 @@ import { BridgeError } from "./BridgeError";

@@ -0,0 +0,0 @@ export declare const BridgeStatusCode: {

@@ -0,0 +0,0 @@ import { AuthResult } from "./AuthResult";

@@ -0,0 +0,0 @@ import { BridgeCapabilities } from "./BridgeCapabilities";

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

@@ -0,0 +0,0 @@ export type TokenRequest = {

@@ -0,0 +0,0 @@ export type TokenResponse = {

@@ -0,0 +0,0 @@ import { NavigationOptions } from "./NavigationOptions";

@@ -0,0 +0,0 @@ import { INavigationClient } from "./INavigationClient";

@@ -0,0 +0,0 @@ import { ApiId } from "../utils/BrowserConstants";

@@ -0,0 +0,0 @@ import { INetworkModule, NetworkRequestOptions, NetworkResponse } from "@azure/msal-common";

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

@@ -0,0 +0,0 @@ import { BaseOperatingContext } from "./BaseOperatingContext";

@@ -0,0 +0,0 @@ import { BaseOperatingContext } from "./BaseOperatingContext";

@@ -0,0 +0,0 @@ import { BaseOperatingContext } from "./BaseOperatingContext";

2

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

@@ -0,0 +0,0 @@ import { CommonAuthorizationCodeRequest } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { CommonAuthorizationUrlRequest } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { AccountInfo } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { CommonEndSessionRequest } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { CommonEndSessionRequest } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { CommonAuthorizationUrlRequest, StringDict } from "@azure/msal-common";

@@ -33,2 +33,7 @@ import { CommonAuthorizationUrlRequest, StringDict } from "@azure/msal-common";

redirectStartPage?: string;
/**
* @deprecated
* onRedirectNavigate is deprecated and will be removed in the next major version.
* Set onRedirectNavigate in Configuration instead.
*/
onRedirectNavigate?: (url: string) => boolean | void;

@@ -35,0 +40,0 @@ tokenBodyParameters?: StringDict;

@@ -0,0 +0,0 @@ import { AccountInfo, BaseAuthRequest, CommonSilentFlowRequest, IPerformanceClient, Logger } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { AccountInfo, CommonSilentFlowRequest, StringDict } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { CommonAuthorizationUrlRequest, StringDict } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { AccountInfo, AuthenticationResult as CommonAuthenticationResult } from "@azure/msal-common";

@@ -0,0 +0,0 @@ import { ICrypto, Logger, ServerAuthorizationCodeResponse } from "@azure/msal-common";

import { InProgressPerformanceEvent, IPerformanceClient, PerformanceClient, PerformanceEvents } from "@azure/msal-common";
import { Configuration } from "../config/Configuration";
/**
* Returns boolean, indicating whether browser supports window.performance.now() function.
*/
export declare function supportsBrowserPerformanceNow(): boolean;
export declare class BrowserPerformanceClient extends PerformanceClient implements IPerformanceClient {

@@ -4,0 +8,0 @@ constructor(configuration: Configuration, intFields?: Set<string>, abbreviations?: Map<string, string>);

@@ -0,0 +0,0 @@ import { IPerformanceMeasurement, SubMeasurement } from "@azure/msal-common";

@@ -81,2 +81,4 @@ import { PopupRequest } from "../request/PopupRequest";

readonly REDIRECT_CONTEXT: "request.redirect.context";
readonly REDIRECT_REQUEST: "request.redirect";
readonly REQUEST_RETRY: "request.retry";
};

@@ -83,0 +85,0 @@ export type TemporaryCacheKeys = (typeof TemporaryCacheKeys)[keyof typeof TemporaryCacheKeys];

@@ -0,0 +0,0 @@ import { InteractionType } from "./BrowserConstants";

@@ -0,0 +0,0 @@ import { invoke, invokeAsync } from "@azure/msal-common";

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

},
"version": "3.20.0",
"version": "3.21.0",
"description": "Microsoft Authentication Library for js",

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

"dependencies": {
"@azure/msal-common": "14.14.0"
"@azure/msal-common": "14.14.1"
}
}

@@ -102,7 +102,15 @@ /*

supportsNestedAppAuth?: boolean;
/**
* Callback that will be passed the url that MSAL will navigate to in redirect flows. Returning false in the callback will stop navigation.
*/
onRedirectNavigate?: (url: string) => boolean | void;
};
/** @internal */
export type InternalAuthOptions = Required<BrowserAuthOptions> & {
export type InternalAuthOptions = Omit<
Required<BrowserAuthOptions>,
"onRedirectNavigate"
> & {
OIDCOptions: Required<OIDCOptions>;
onRedirectNavigate?: (url: string) => boolean | void;
};

@@ -109,0 +117,0 @@

@@ -95,2 +95,4 @@ /*

"Invalid PoP token request. The request should not have both a popKid value and signPopToken set to true.",
[BrowserAuthErrorCodes.failedToRetry]:
"Unable to retry failed auth code redemption due to usage of the onRedirectNavigate request parameter. Please set onRedirectNavigate on the PublicClientApplication configuration instead or call loginRedirect again.",
};

@@ -97,0 +99,0 @@

@@ -59,1 +59,2 @@ /*

export const invalidPopTokenRequest = "invalid_pop_token_request";
export const failedToRetry = "failed_to_retry";

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

invoke,
ServerError,
} from "@azure/msal-common";

@@ -51,2 +52,3 @@ import { StandardInteractionClient } from "./StandardInteractionClient";

import * as ResponseHandler from "../response/ResponseHandler";
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";

@@ -187,3 +189,3 @@ export type PopupParams = {

/**
* Helper which obtains an access_token for your API via opening a popup window in the user's browser
* Helper which initializes authorization clients and requests
* @param validRequest

@@ -217,15 +219,16 @@ * @param popupName

let authClient: AuthorizationCodeClient | undefined;
try {
// Create auth code request and generate PKCE params
const authCodeRequest: CommonAuthorizationCodeRequest =
await invokeAsync(
this.initializeAuthorizationCodeRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
this.logger,
this.performanceClient,
this.correlationId
)(validRequest);
const authCodeRequest = await invokeAsync(
this.initializeAuthorizationCodeRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
this.logger,
this.performanceClient,
this.correlationId
)(validRequest);
// Initialize the client
const authClient: AuthorizationCodeClient = await invokeAsync(
authClient = await invokeAsync(
this.createAuthCodeClient.bind(this),

@@ -243,56 +246,54 @@ PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,

const isNativeBroker = NativeMessageHandler.isNativeAvailable(
this.config,
return await invokeAsync(
this.acquireTokenPopupAsyncHelper.bind(this),
PerformanceEvents.PopupClientTokenHelper,
this.logger,
this.nativeMessageHandler,
request.authenticationScheme
this.performanceClient,
this.correlationId
)(
authClient,
authCodeRequest,
validRequest,
request,
popupName,
popupWindowAttributes,
popup
);
// Start measurement for server calls with native brokering enabled
let fetchNativeAccountIdMeasurement;
if (isNativeBroker) {
fetchNativeAccountIdMeasurement =
this.performanceClient.startMeasurement(
PerformanceEvents.FetchAccountIdWithNativeBroker,
request.correlationId
);
} catch (e) {
if (popup) {
// Close the synchronous popup if an error is thrown before the window unload event is registered
popup.close();
}
// Create acquire token url.
const navigateUrl = await authClient.getAuthCodeUrl({
...validRequest,
nativeBroker: isNativeBroker,
});
if (e instanceof AuthError) {
(e as AuthError).setCorrelationId(this.correlationId);
serverTelemetryManager.cacheFailedRequest(e);
}
// Create popup interaction handler.
const interactionHandler = new InteractionHandler(
authClient,
this.browserStorage,
authCodeRequest,
this.logger,
this.performanceClient
);
if (
!authClient ||
!(e instanceof ServerError) ||
e.errorCode !== BrowserConstants.INVALID_GRANT_ERROR
) {
throw e;
}
// Show the UI once the url has been created. Get the window handle for the popup.
const popupParameters: PopupParams = {
popup,
popupName,
popupWindowAttributes,
};
const popupWindow: Window = this.initiateAuthRequest(
navigateUrl,
popupParameters
this.performanceClient.addFields(
{
retryError: e.errorCode,
},
this.correlationId
);
this.eventHandler.emitEvent(
EventType.POPUP_OPENED,
InteractionType.Popup,
{ popupWindow },
null
);
// Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
const responseString = await this.monitorPopupForHash(popupWindow);
const retryAuthCodeRequest = await invokeAsync(
this.initializeAuthorizationCodeRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
this.logger,
this.performanceClient,
this.correlationId
)(validRequest);
const serverParams = invoke(
ResponseHandler.deserializeResponse,
PerformanceEvents.DeserializeResponse,
return await invokeAsync(
this.acquireTokenPopupAsyncHelper.bind(this),
PerformanceEvents.PopupClientTokenHelper,
this.logger,

@@ -302,74 +303,158 @@ this.performanceClient,

)(
responseString,
this.config.auth.OIDCOptions.serverResponseType,
this.logger
authClient,
retryAuthCodeRequest,
validRequest,
request,
popupName,
popupWindowAttributes,
popup
);
// Remove throttle if it exists
ThrottlingUtils.removeThrottle(
this.browserStorage,
this.config.auth.clientId,
authCodeRequest
);
}
}
if (serverParams.accountId) {
this.logger.verbose(
"Account id found in hash, calling WAM for token"
/**
* Helper which obtains an access_token for your API via opening a popup window in the user's browser
* @param authClient
* @param authCodeRequest
* @param validRequest
* @param request
* @param popupName
* @param popupWindowAttributes
* @param popup
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
*/
protected async acquireTokenPopupAsyncHelper(
authClient: AuthorizationCodeClient,
authCodeRequest: CommonAuthorizationCodeRequest,
validRequest: AuthorizationUrlRequest,
request: PopupRequest,
popupName: string,
popupWindowAttributes: PopupWindowAttributes,
popup?: Window | null
): Promise<AuthenticationResult> {
const correlationId = validRequest.correlationId;
this.performanceClient.addQueueMeasurement(
PerformanceEvents.PopupClientTokenHelper,
correlationId
);
const isNativeBroker = NativeMessageHandler.isNativeAvailable(
this.config,
this.logger,
this.nativeMessageHandler,
request.authenticationScheme
);
// Start measurement for server calls with native brokering enabled
let fetchNativeAccountIdMeasurement;
if (isNativeBroker) {
fetchNativeAccountIdMeasurement =
this.performanceClient.startMeasurement(
PerformanceEvents.FetchAccountIdWithNativeBroker,
request.correlationId
);
// end measurement for server call with native brokering enabled
if (fetchNativeAccountIdMeasurement) {
fetchNativeAccountIdMeasurement.end({
success: true,
isNativeBroker: true,
});
}
}
if (!this.nativeMessageHandler) {
throw createBrowserAuthError(
BrowserAuthErrorCodes.nativeConnectionNotEstablished
);
}
const nativeInteractionClient = new NativeInteractionClient(
this.config,
this.browserStorage,
this.browserCrypto,
this.logger,
this.eventHandler,
this.navigationClient,
ApiId.acquireTokenPopup,
this.performanceClient,
this.nativeMessageHandler,
serverParams.accountId,
this.nativeStorage,
validRequest.correlationId
);
const { userRequestState } = ProtocolUtils.parseRequestState(
this.browserCrypto,
validRequest.state
);
return await nativeInteractionClient.acquireToken({
...validRequest,
state: userRequestState,
prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
// Create acquire token url.
const navigateUrl = await authClient.getAuthCodeUrl({
...validRequest,
nativeBroker: isNativeBroker,
});
// Create popup interaction handler.
const interactionHandler = new InteractionHandler(
authClient,
this.browserStorage,
authCodeRequest,
this.logger,
this.performanceClient
);
// Show the UI once the url has been created. Get the window handle for the popup.
const popupParameters: PopupParams = {
popup,
popupName,
popupWindowAttributes,
};
const popupWindow: Window = this.initiateAuthRequest(
navigateUrl,
popupParameters
);
this.eventHandler.emitEvent(
EventType.POPUP_OPENED,
InteractionType.Popup,
{ popupWindow },
null
);
// Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
const responseString = await this.monitorPopupForHash(popupWindow);
const serverParams = invoke(
ResponseHandler.deserializeResponse,
PerformanceEvents.DeserializeResponse,
this.logger,
this.performanceClient,
this.correlationId
)(
responseString,
this.config.auth.OIDCOptions.serverResponseType,
this.logger
);
// Remove throttle if it exists
ThrottlingUtils.removeThrottle(
this.browserStorage,
this.config.auth.clientId,
authCodeRequest
);
if (serverParams.accountId) {
this.logger.verbose(
"Account id found in hash, calling WAM for token"
);
// end measurement for server call with native brokering enabled
if (fetchNativeAccountIdMeasurement) {
fetchNativeAccountIdMeasurement.end({
success: true,
isNativeBroker: true,
});
}
// Handle response from hash string.
const result = await interactionHandler.handleCodeResponse(
serverParams,
validRequest
if (!this.nativeMessageHandler) {
throw createBrowserAuthError(
BrowserAuthErrorCodes.nativeConnectionNotEstablished
);
}
const nativeInteractionClient = new NativeInteractionClient(
this.config,
this.browserStorage,
this.browserCrypto,
this.logger,
this.eventHandler,
this.navigationClient,
ApiId.acquireTokenPopup,
this.performanceClient,
this.nativeMessageHandler,
serverParams.accountId,
this.nativeStorage,
validRequest.correlationId
);
const { userRequestState } = ProtocolUtils.parseRequestState(
this.browserCrypto,
validRequest.state
);
return nativeInteractionClient.acquireToken({
...validRequest,
state: userRequestState,
prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
});
}
return result;
} catch (e) {
if (popup) {
// Close the synchronous popup if an error is thrown before the window unload event is registered
popup.close();
}
// Handle response from hash string.
const result = await interactionHandler.handleCodeResponse(
serverParams,
validRequest
);
if (e instanceof AuthError) {
(e as AuthError).setCorrelationId(this.correlationId);
serverTelemetryManager.cacheFailedRequest(e);
}
throw e;
}
return result;
}

@@ -376,0 +461,0 @@

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

InProgressPerformanceEvent,
ServerError,
} from "@azure/msal-common";

@@ -30,2 +31,3 @@ import { StandardInteractionClient } from "./StandardInteractionClient";

ApiId,
BrowserConstants,
InteractionType,

@@ -88,2 +90,10 @@ TemporaryCacheKeys,

async acquireToken(request: RedirectRequest): Promise<void> {
if (request.onRedirectNavigate) {
this.logger.warning(
"Unable to cache redirect request, onRedirectNavigate request option has been deprecated. Please set onRedirectNavigate on PublicClientApplication config instead."
);
} else {
this.browserStorage.cacheRedirectRequest(request);
}
const validRequest = await invokeAsync(

@@ -180,3 +190,5 @@ this.initializeAuthorizationRequest.bind(this),

redirectStartPage: redirectStartPage,
onRedirectNavigate: request.onRedirectNavigate,
onRedirectNavigate:
request.onRedirectNavigate ||
this.config.auth.onRedirectNavigate,
});

@@ -208,2 +220,3 @@ } catch (e) {

);
try {

@@ -339,6 +352,53 @@ if (!this.browserStorage.isInteractionInProgress(true)) {

}
if (
e instanceof ServerError &&
e.errorCode === BrowserConstants.INVALID_GRANT_ERROR
) {
this.performanceClient.addFields(
{
retryError: e.errorCode,
},
this.correlationId
);
const requestRetried = this.browserStorage.getRequestRetried();
if (requestRetried) {
this.logger.error(
"Retried request already detected. Throwing error."
);
this.browserStorage.removeRequestRetried();
throw e;
}
const redirectRequest =
this.browserStorage.getCachedRedirectRequest();
if (!redirectRequest) {
this.logger.error(
"Unable to retry. Please retry with redirect request"
);
this.browserStorage.setRequestRetried();
throw createBrowserAuthError(
BrowserAuthErrorCodes.failedToRetry
);
}
this.browserStorage.setRequestRetried();
await this.acquireToken(redirectRequest);
return null;
}
this.browserStorage.removeTemporaryItem(
this.browserStorage.generateCacheKey(
TemporaryCacheKeys.REDIRECT_REQUEST
)
);
this.browserStorage.removeRequestRetried();
throw e;
} finally {
this.browserStorage.cleanRequestByInteractionType(
InteractionType.Redirect
);
throw e;
}

@@ -345,0 +405,0 @@ }

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

invoke,
ServerError,
} from "@azure/msal-common";

@@ -30,4 +31,8 @@ import { StandardInteractionClient } from "./StandardInteractionClient";

} from "../error/BrowserAuthError";
import { InteractionType, ApiId } from "../utils/BrowserConstants";
import {
InteractionType,
ApiId,
BrowserConstants,
} from "../utils/BrowserConstants";
import {
initiateAuthRequest,

@@ -128,5 +133,7 @@ monitorIframeForHash,

let authClient: AuthorizationCodeClient | undefined;
try {
// Initialize the client
const authClient: AuthorizationCodeClient = await invokeAsync(
authClient = await invokeAsync(
this.createAuthCodeClient.bind(this),

@@ -156,3 +163,34 @@ PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,

}
throw e;
if (
!authClient ||
!(e instanceof ServerError) ||
e.errorCode !== BrowserConstants.INVALID_GRANT_ERROR
) {
throw e;
}
this.performanceClient.addFields(
{
retryError: e.errorCode,
},
this.correlationId
);
const retrySilentRequest: AuthorizationUrlRequest =
await invokeAsync(
this.initializeAuthorizationRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
this.logger,
this.performanceClient,
request.correlationId
)(inputRequest, InteractionType.Silent);
return await invokeAsync(
this.silentTokenHelper.bind(this),
PerformanceEvents.SilentIframeClientTokenHelper,
this.logger,
this.performanceClient,
this.correlationId
)(authClient, retrySilentRequest);
}

@@ -159,0 +197,0 @@ }

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

this.browserStorage.cleanRequestByState(state);
this.browserStorage.removeRequestRetried();
return tokenResponse;

@@ -227,0 +228,0 @@ }

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

import * as BrowserCrypto from "../crypto/BrowserCrypto";
import { supportsBrowserPerformanceNow } from "../telemetry/BrowserPerformanceClient";

@@ -85,3 +86,5 @@ declare global {

requestId: BrowserCrypto.createNewGuid(),
sendTime: Date.now(),
sendTime: supportsBrowserPerformanceNow()
? window.performance.now()
: Date.now(),
};

@@ -162,3 +165,5 @@ const request: BridgeRequest = {

requestId: BrowserCrypto.createNewGuid(),
sendTime: Date.now(),
sendTime: supportsBrowserPerformanceNow()
? window.performance.now()
: Date.now(),
...requestParams,

@@ -165,0 +170,0 @@ };

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

@@ -49,4 +49,9 @@ /*

redirectStartPage?: string;
/**
* @deprecated
* onRedirectNavigate is deprecated and will be removed in the next major version.
* Set onRedirectNavigate in Configuration instead.
*/
onRedirectNavigate?: (url: string) => boolean | void;
tokenBodyParameters?: StringDict;
};

@@ -45,3 +45,3 @@ /*

*/
function supportsBrowserPerformanceNow(): boolean {
export function supportsBrowserPerformanceNow(): boolean {
return (

@@ -48,0 +48,0 @@ typeof window !== "undefined" &&

@@ -96,2 +96,4 @@ /*

REDIRECT_CONTEXT: "request.redirect.context",
REDIRECT_REQUEST: "request.redirect",
REQUEST_RETRY: "request.retry",
} as const;

@@ -98,0 +100,0 @@ export type TemporaryCacheKeys =

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