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.21.0 to 3.22.0

25

dist/cache/BrowserCacheManager.d.ts

@@ -350,27 +350,2 @@ 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;

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

1

dist/error/BrowserAuthError.d.ts

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

invalid_pop_token_request: string;
failed_to_retry: string;
};

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

@@ -47,3 +47,2 @@ 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

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

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

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

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

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

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

@@ -45,14 +44,2 @@ * @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>;
/**
*

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

2

dist/packageMetadata.d.ts
export declare const name = "@azure/msal-browser";
export declare const version = "3.21.0";
export declare const version = "3.22.0";
//# sourceMappingURL=packageMetadata.d.ts.map
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 {

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

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

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

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

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

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

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

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

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

"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.",
};

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

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

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

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

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

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

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

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

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

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

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

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

return await invokeAsync(
this.acquireTokenPopupAsyncHelper.bind(this),
PerformanceEvents.PopupClientTokenHelper,
const isNativeBroker = NativeMessageHandler.isNativeAvailable(
this.config,
this.logger,
this.performanceClient,
this.correlationId
)(
authClient,
authCodeRequest,
validRequest,
request,
popupName,
popupWindowAttributes,
popup
this.nativeMessageHandler,
request.authenticationScheme
);
} catch (e) {
if (popup) {
// Close the synchronous popup if an error is thrown before the window unload event is registered
popup.close();
// Start measurement for server calls with native brokering enabled
let fetchNativeAccountIdMeasurement;
if (isNativeBroker) {
fetchNativeAccountIdMeasurement =
this.performanceClient.startMeasurement(
PerformanceEvents.FetchAccountIdWithNativeBroker,
request.correlationId
);
}
if (e instanceof AuthError) {
(e as AuthError).setCorrelationId(this.correlationId);
serverTelemetryManager.cacheFailedRequest(e);
}
// Create acquire token url.
const navigateUrl = await authClient.getAuthCodeUrl({
...validRequest,
nativeBroker: isNativeBroker,
});
if (
!authClient ||
!(e instanceof ServerError) ||
e.errorCode !== BrowserConstants.INVALID_GRANT_ERROR
) {
throw e;
}
// Create popup interaction handler.
const interactionHandler = new InteractionHandler(
authClient,
this.browserStorage,
authCodeRequest,
this.logger,
this.performanceClient
);
this.performanceClient.addFields(
{
retryError: e.errorCode,
},
this.correlationId
// 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
);
const retryAuthCodeRequest = await invokeAsync(
this.initializeAuthorizationCodeRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
this.logger,
this.performanceClient,
this.correlationId
)(validRequest);
// 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);
return await invokeAsync(
this.acquireTokenPopupAsyncHelper.bind(this),
PerformanceEvents.PopupClientTokenHelper,
const serverParams = invoke(
ResponseHandler.deserializeResponse,
PerformanceEvents.DeserializeResponse,
this.logger,

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

)(
authClient,
retryAuthCodeRequest,
validRequest,
request,
popupName,
popupWindowAttributes,
popup
responseString,
this.config.auth.OIDCOptions.serverResponseType,
this.logger
);
}
}
// Remove throttle if it exists
ThrottlingUtils.removeThrottle(
this.browserStorage,
this.config.auth.clientId,
authCodeRequest
);
/**
* 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
);
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,
});
}
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
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,
});
// Handle response from hash string.
const result = await interactionHandler.handleCodeResponse(
serverParams,
validRequest
);
// Create popup interaction handler.
const interactionHandler = new InteractionHandler(
authClient,
this.browserStorage,
authCodeRequest,
this.logger,
this.performanceClient
);
return result;
} catch (e) {
if (popup) {
// Close the synchronous popup if an error is thrown before the window unload event is registered
popup.close();
}
// 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,
});
if (e instanceof AuthError) {
(e as AuthError).setCorrelationId(this.correlationId);
serverTelemetryManager.cacheFailedRequest(e);
}
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
});
throw e;
}
// Handle response from hash string.
const result = await interactionHandler.handleCodeResponse(
serverParams,
validRequest
);
return result;
}

@@ -461,0 +377,0 @@

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

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

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

ApiId,
BrowserConstants,
InteractionType,

@@ -90,10 +88,2 @@ 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(

@@ -350,53 +340,6 @@ this.initializeAuthorizationRequest.bind(this),

}
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;
}

@@ -403,0 +346,0 @@ }

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

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

@@ -164,3 +163,3 @@ import { StandardInteractionClient } from "./StandardInteractionClient";

!authClient ||
!(e instanceof ServerError) ||
!(e instanceof AuthError) ||
e.errorCode !== BrowserConstants.INVALID_GRANT_ERROR

@@ -167,0 +166,0 @@ ) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -100,0 +98,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 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

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