Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure/msal-browser

Package Overview
Dependencies
Maintainers
3
Versions
122
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.3.0 to 3.4.0

10

dist/controllers/ControllerFactory.d.ts
import { IController } from "./IController";
import { Logger } from "@azure/msal-common";
import { Configuration } from "../config/Configuration";
export declare class ControllerFactory {
protected config: Configuration;
protected logger: Logger;
constructor(config: Configuration);
createV3Controller(): Promise<IController>;
createController(): Promise<IController | null>;
}
export declare function createV3Controller(config: Configuration): Promise<IController>;
export declare function createController(config: Configuration): Promise<IController | null>;
//# sourceMappingURL=ControllerFactory.d.ts.map

3

dist/controllers/IController.d.ts

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

import { AccountInfo, Logger, PerformanceCallbackFunction, IPerformanceClient, CommonSilentFlowRequest, AccountFilter } from "@azure/msal-common";
import { AccountInfo, Logger, PerformanceCallbackFunction, IPerformanceClient, AccountFilter } from "@azure/msal-common";
import { RedirectRequest } from "../request/RedirectRequest";

@@ -24,3 +24,2 @@ import { PopupRequest } from "../request/PopupRequest";

acquireTokenNative(request: PopupRequest | SilentRequest | SsoSilentRequest, apiId: ApiId, accountId?: string): Promise<AuthenticationResult>;
acquireTokenByRefreshToken(commonRequest: CommonSilentFlowRequest, silentRequest: SilentRequest): Promise<AuthenticationResult>;
addEventCallback(callback: EventCallbackFunction): string | null;

@@ -27,0 +26,0 @@ removeEventCallback(callbackId: string): void;

import { AccountInfo, INetworkModule, Logger, CommonSilentFlowRequest, ICrypto, PerformanceCallbackFunction, IPerformanceClient, BaseAuthRequest, AccountFilter } from "@azure/msal-common";
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
import { BrowserConfiguration } from "../config/Configuration";
import { InteractionType, ApiId, WrapperSKU } from "../utils/BrowserConstants";
import { InteractionType, ApiId, WrapperSKU, CacheLookupPolicy } from "../utils/BrowserConstants";
import { RedirectRequest } from "../request/RedirectRequest";

@@ -144,10 +144,10 @@ import { PopupRequest } from "../request/PopupRequest";

*/
protected acquireTokenFromCache(silentCacheClient: SilentCacheClient, commonRequest: CommonSilentFlowRequest, silentRequest: SilentRequest): Promise<AuthenticationResult>;
protected acquireTokenFromCache(silentCacheClient: SilentCacheClient, commonRequest: CommonSilentFlowRequest, cacheLookupPolicy: CacheLookupPolicy): Promise<AuthenticationResult>;
/**
* Attempt to acquire an access token via a refresh token
* @param commonRequest CommonSilentFlowRequest
* @param silentRequest SilentRequest
* @param cacheLookupPolicy CacheLookupPolicy
* @returns A promise that, when resolved, returns the access token
*/
acquireTokenByRefreshToken(commonRequest: CommonSilentFlowRequest, silentRequest: SilentRequest): Promise<AuthenticationResult>;
acquireTokenByRefreshToken(commonRequest: CommonSilentFlowRequest, cacheLookupPolicy: CacheLookupPolicy): Promise<AuthenticationResult>;
/**

@@ -154,0 +154,0 @@ * Attempt to acquire an access token via an iframe

@@ -10,6 +10,5 @@ import { CommonEndSessionRequest, IPerformanceClient, Logger, ICrypto } from "@azure/msal-common";

import { BrowserConfiguration } from "../config/Configuration";
import { InteractionParams } from "../interaction_handler/InteractionHandler";
import { PopupWindowAttributes } from "../request/PopupWindowAttributes";
import { AuthenticationResult } from "../response/AuthenticationResult";
export type PopupParams = InteractionParams & {
export type PopupParams = {
popup?: Window | null;

@@ -16,0 +15,0 @@ popupName: string;

@@ -1,5 +0,5 @@

import { AuthorizationCodePayload, CommonAuthorizationCodeRequest, AuthorizationCodeClient, Authority, INetworkModule, CcsCredential, Logger, IPerformanceClient } from "@azure/msal-common";
import { AuthorizationCodePayload, CommonAuthorizationCodeRequest, AuthorizationCodeClient, CcsCredential, Logger, IPerformanceClient } from "@azure/msal-common";
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
import { AuthenticationResult } from "../response/AuthenticationResult";
export type InteractionParams = {};
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
/**

@@ -19,3 +19,3 @@ * Abstract class which defines operations for a browser interaction handling class.

*/
handleCodeResponseFromHash(locationHash: string, state: string, authority: Authority, networkModule: INetworkModule): Promise<AuthenticationResult>;
handleCodeResponseFromHash(locationHash: string, request: AuthorizationUrlRequest): Promise<AuthenticationResult>;
/**

@@ -29,15 +29,8 @@ * Process auth code response from AAD

*/
handleCodeResponseFromServer(authCodeResponse: AuthorizationCodePayload, state: string, authority: Authority, networkModule: INetworkModule, validateNonce?: boolean): Promise<AuthenticationResult>;
handleCodeResponseFromServer(authCodeResponse: AuthorizationCodePayload, request: AuthorizationUrlRequest, validateNonce?: boolean): Promise<AuthenticationResult>;
/**
* Updates authority based on cloudInstanceHostname
* @param cloudInstanceHostname
* @param authority
* @param networkModule
* Build ccs creds if available
*/
protected updateTokenEndpointAuthority(cloudInstanceHostname: string, authority: Authority, networkModule: INetworkModule): Promise<void>;
/**
* Looks up ccs creds in the cache
*/
protected checkCcsCredentials(): CcsCredential | null;
protected createCcsCredentials(request: AuthorizationUrlRequest): CcsCredential | null;
}
//# sourceMappingURL=InteractionHandler.d.ts.map

@@ -1,7 +0,6 @@

import { AuthorizationCodeClient, CommonAuthorizationCodeRequest, ICrypto, Authority, INetworkModule, Logger, IPerformanceClient } from "@azure/msal-common";
import { AuthorizationCodeClient, CommonAuthorizationCodeRequest, Logger, IPerformanceClient, CcsCredential } from "@azure/msal-common";
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
import { InteractionHandler, InteractionParams } from "./InteractionHandler";
import { INavigationClient } from "../navigation/INavigationClient";
import { AuthenticationResult } from "../response/AuthenticationResult";
export type RedirectParams = InteractionParams & {
export type RedirectParams = {
navigationClient: INavigationClient;

@@ -12,5 +11,9 @@ redirectTimeout: number;

};
export declare class RedirectHandler extends InteractionHandler {
private browserCrypto;
constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, logger: Logger, browserCrypto: ICrypto, performanceClient: IPerformanceClient);
export declare class RedirectHandler {
authModule: AuthorizationCodeClient;
browserStorage: BrowserCacheManager;
authCodeRequest: CommonAuthorizationCodeRequest;
logger: Logger;
performanceClient: IPerformanceClient;
constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, logger: Logger, performanceClient: IPerformanceClient);
/**

@@ -25,4 +28,8 @@ * Redirects window to given URL.

*/
handleCodeResponseFromHash(locationHash: string, state: string, authority: Authority, networkModule: INetworkModule): Promise<AuthenticationResult>;
handleCodeResponseFromHash(locationHash: string, state: string): Promise<AuthenticationResult>;
/**
* Looks up ccs creds in the cache
*/
protected checkCcsCredentials(): CcsCredential | null;
}
//# sourceMappingURL=RedirectHandler.d.ts.map
export declare const name = "@azure/msal-browser";
export declare const version = "3.3.0";
export declare const version = "3.4.0";
//# sourceMappingURL=packageMetadata.d.ts.map

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

},
"version": "3.3.0",
"version": "3.4.0",
"description": "Microsoft Authentication Library for js",

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

"dependencies": {
"@azure/msal-common": "14.2.0"
"@azure/msal-common": "14.3.0"
}
}

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

import { SsoSilentRequest } from "../request/SsoSilentRequest";
import { ControllerFactory } from "../controllers/ControllerFactory";
import * as ControllerFactory from "../controllers/ControllerFactory";
import { StandardController } from "../controllers/StandardController";

@@ -42,4 +42,5 @@ import { BrowserConfiguration, Configuration } from "../config/Configuration";

): Promise<IPublicClientApplication> {
const factory = new ControllerFactory(configuration);
const controller = await factory.createV3Controller();
const controller = await ControllerFactory.createV3Controller(
configuration
);
const pca = new PublicClientApplication(configuration, controller);

@@ -46,0 +47,0 @@

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

import { SsoSilentRequest } from "../request/SsoSilentRequest";
import { ControllerFactory } from "../controllers/ControllerFactory";
import * as ControllerFactory from "../controllers/ControllerFactory";
import { BrowserConfiguration, Configuration } from "../config/Configuration";

@@ -51,4 +51,5 @@ import { EventCallbackFunction } from "../event/EventMessage";

): Promise<IPublicClientApplication> {
const factory = new ControllerFactory(configuration);
const controller = await factory.createController();
const controller = await ControllerFactory.createController(
configuration
);
let pca;

@@ -105,4 +106,5 @@ if (controller !== null) {

if (this.controller instanceof UnknownOperatingContextController) {
const factory = new ControllerFactory(this.configuration);
const result = await factory.createController();
const result = await ControllerFactory.createController(
this.configuration
);
if (result !== null) {

@@ -109,0 +111,0 @@ this.controller = result;

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

TokenClaims,
CacheHelpers,
} from "@azure/msal-common";

@@ -298,3 +299,3 @@ import { BrowserConfiguration } from "../config/Configuration";

): IdTokenEntity {
const idTokenEntity = IdTokenEntity.createIdTokenEntity(
const idTokenEntity = CacheHelpers.createIdTokenEntity(
homeAccountId,

@@ -360,3 +361,3 @@ environment,

const accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(
const accessTokenEntity = CacheHelpers.createAccessTokenEntity(
homeAccountId,

@@ -370,3 +371,3 @@ environment,

extendedExpiresOn,
this.cryptoObj
base64Decode
);

@@ -406,3 +407,3 @@

const refreshTokenEntity = RefreshTokenEntity.createRefreshTokenEntity(
const refreshTokenEntity = CacheHelpers.createRefreshTokenEntity(
homeAccountId,

@@ -409,0 +410,0 @@ environment,

@@ -9,59 +9,40 @@ /*

import { IController } from "./IController";
import { Logger } from "@azure/msal-common";
import { Configuration } from "../config/Configuration";
import { version, name } from "../packageMetadata";
export class ControllerFactory {
protected config: Configuration;
protected logger: Logger;
export async function createV3Controller(
config: Configuration
): Promise<IController> {
const standard = new StandardOperatingContext(config);
constructor(config: Configuration) {
this.config = config;
const loggerOptions = {
loggerCallback: undefined,
piiLoggingEnabled: false,
logLevel: undefined,
correlationId: undefined,
};
this.logger = new Logger(loggerOptions, name, version);
}
await standard.initialize();
async createV3Controller(): Promise<IController> {
const standard = new StandardOperatingContext(this.config);
const controller = await import("./StandardController");
return await controller.StandardController.createController(standard);
}
await standard.initialize();
export async function createController(
config: Configuration
): Promise<IController | null> {
const standard = new StandardOperatingContext(config);
const teamsApp = new TeamsAppOperatingContext(config);
const operatingContexts = [standard.initialize(), teamsApp.initialize()];
await Promise.all(operatingContexts);
if (
teamsApp.isAvailable() &&
teamsApp.getConfig().auth.supportsNestedAppAuth
) {
const controller = await import("./NestedAppAuthController");
return await controller.NestedAppAuthController.createController(
teamsApp
);
} else if (standard.isAvailable()) {
const controller = await import("./StandardController");
return await controller.StandardController.createController(standard);
} else {
// Since neither of the actual operating contexts are available keep the UnknownOperatingContextController
return null;
}
async createController(): Promise<IController | null> {
const standard = new StandardOperatingContext(this.config);
const teamsApp = new TeamsAppOperatingContext(this.config);
const operatingContexts = [
standard.initialize(),
teamsApp.initialize(),
];
await Promise.all(operatingContexts);
if (
teamsApp.isAvailable() &&
teamsApp.getConfig().auth.supportsNestedAppAuth
) {
const controller = await import("./NestedAppAuthController");
return await controller.NestedAppAuthController.createController(
teamsApp
);
} else if (standard.isAvailable()) {
const controller = await import("./StandardController");
return await controller.StandardController.createController(
standard
);
} else {
// Since neither of the actual operating contexts are available keep the UnknownOperatingContextController
return null;
}
}
}

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

IPerformanceClient,
CommonSilentFlowRequest,
AccountFilter,

@@ -52,7 +51,2 @@ } from "@azure/msal-common";

acquireTokenByRefreshToken(
commonRequest: CommonSilentFlowRequest,
silentRequest: SilentRequest
): Promise<AuthenticationResult>;
addEventCallback(callback: EventCallbackFunction): string | null;

@@ -59,0 +53,0 @@

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

AuthErrorCodes,
CacheHelpers,
} from "@azure/msal-common";

@@ -660,3 +661,3 @@ import { BaseInteractionClient } from "./BaseInteractionClient";

const cachedIdToken: IdTokenEntity | null =
IdTokenEntity.createIdTokenEntity(
CacheHelpers.createIdTokenEntity(
homeAccountIdentifier,

@@ -680,3 +681,3 @@ request.authority,

const cachedAccessToken: AccessTokenEntity | null =
AccessTokenEntity.createAccessTokenEntity(
CacheHelpers.createAccessTokenEntity(
homeAccountIdentifier,

@@ -690,3 +691,3 @@ request.authority,

0,
this.browserCrypto
base64Decode
);

@@ -693,0 +694,0 @@

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

ServerResponseType,
invokeAsync,
} from "@azure/msal-common";

@@ -46,6 +47,3 @@ import { StandardInteractionClient } from "./StandardInteractionClient";

import { BrowserConfiguration } from "../config/Configuration";
import {
InteractionHandler,
InteractionParams,
} from "../interaction_handler/InteractionHandler";
import { InteractionHandler } from "../interaction_handler/InteractionHandler";
import { PopupWindowAttributes } from "../request/PopupWindowAttributes";

@@ -55,3 +53,3 @@ import { EventError } from "../event/EventMessage";

export type PopupParams = InteractionParams & {
export type PopupParams = {
popup?: Window | null;

@@ -209,40 +207,35 @@ popupName: string;

this.performanceClient.setPreQueueTime(
const validRequest = await invokeAsync(
this.initializeAuthorizationRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
request.correlationId
);
const validRequest = await this.initializeAuthorizationRequest(
request,
InteractionType.Popup
);
this.logger,
this.performanceClient,
this.correlationId
)(request, InteractionType.Popup);
BrowserUtils.preconnect(validRequest.authority);
this.browserStorage.updateCacheEntries(
validRequest.state,
validRequest.nonce,
validRequest.authority,
validRequest.loginHint || Constants.EMPTY_STRING,
validRequest.account || null
);
try {
// Create auth code request and generate PKCE params
this.performanceClient.setPreQueueTime(
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
request.correlationId
);
const authCodeRequest: CommonAuthorizationCodeRequest =
await this.initializeAuthorizationCodeRequest(validRequest);
await invokeAsync(
this.initializeAuthorizationCodeRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
this.logger,
this.performanceClient,
this.correlationId
)(validRequest);
// Initialize the client
this.performanceClient.setPreQueueTime(
const authClient: AuthorizationCodeClient = await invokeAsync(
this.createAuthCodeClient.bind(this),
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
request.correlationId
this.logger,
this.performanceClient,
this.correlationId
)(
serverTelemetryManager,
validRequest.authority,
validRequest.azureCloudOptions
);
const authClient: AuthorizationCodeClient =
await this.createAuthCodeClient(
serverTelemetryManager,
validRequest.authority,
validRequest.azureCloudOptions
);
this.logger.verbose("Auth code client created");

@@ -302,7 +295,2 @@ const isNativeBroker = NativeMessageHandler.isNativeAvailable(

UrlString.getDeserializedHash(hash);
const state = this.validateAndExtractStateFromHash(
serverParams,
InteractionType.Popup,
validRequest.correlationId
);
// Remove throttle if it exists

@@ -348,13 +336,9 @@ ThrottlingUtils.removeThrottle(

this.browserCrypto,
state
validRequest.state
);
return nativeInteractionClient
.acquireToken({
...validRequest,
state: userRequestState,
prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
})
.finally(() => {
this.browserStorage.cleanRequestByState(state);
});
return nativeInteractionClient.acquireToken({
...validRequest,
state: userRequestState,
prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
});
}

@@ -365,5 +349,3 @@

hash,
state,
authClient.authority,
this.networkClient
validRequest
);

@@ -382,3 +364,2 @@

}
this.browserStorage.cleanRequestByState(validRequest.state);
throw e;

@@ -421,11 +402,9 @@ }

// Initialize the client
this.performanceClient.setPreQueueTime(
const authClient = await invokeAsync(
this.createAuthCodeClient.bind(this),
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
validRequest.correlationId
);
const authClient = await this.createAuthCodeClient(
serverTelemetryManager,
requestAuthority
);
this.logger.verbose("Auth code client created");
this.logger,
this.performanceClient,
this.correlationId
)(serverTelemetryManager, requestAuthority);

@@ -432,0 +411,0 @@ try {

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

ProtocolMode,
invokeAsync,
} from "@azure/msal-common";

@@ -82,10 +83,10 @@ import { StandardInteractionClient } from "./StandardInteractionClient";

async acquireToken(request: RedirectRequest): Promise<void> {
this.performanceClient.setPreQueueTime(
const validRequest = await invokeAsync(
this.initializeAuthorizationRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
request.correlationId
);
const validRequest = await this.initializeAuthorizationRequest(
request,
InteractionType.Redirect
);
this.logger,
this.performanceClient,
this.correlationId
)(request, InteractionType.Redirect);
this.browserStorage.updateCacheEntries(

@@ -95,3 +96,3 @@ validRequest.state,

validRequest.authority,
validRequest.loginHint || Constants.EMPTY_STRING,
validRequest.loginHint || "",
validRequest.account || null

@@ -119,21 +120,23 @@ );

// Create auth code request and generate PKCE params
this.performanceClient.setPreQueueTime(
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
request.correlationId
);
const authCodeRequest: CommonAuthorizationCodeRequest =
await this.initializeAuthorizationCodeRequest(validRequest);
await invokeAsync(
this.initializeAuthorizationCodeRequest.bind(this),
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
this.logger,
this.performanceClient,
this.correlationId
)(validRequest);
// Initialize the client
this.performanceClient.setPreQueueTime(
const authClient: AuthorizationCodeClient = await invokeAsync(
this.createAuthCodeClient.bind(this),
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
request.correlationId
this.logger,
this.performanceClient,
this.correlationId
)(
serverTelemetryManager,
validRequest.authority,
validRequest.azureCloudOptions
);
const authClient: AuthorizationCodeClient =
await this.createAuthCodeClient(
serverTelemetryManager,
validRequest.authority,
validRequest.azureCloudOptions
);
this.logger.verbose("Auth code client created");

@@ -146,3 +149,2 @@ // Create redirect interaction handler.

this.logger,
this.browserCrypto,
this.performanceClient

@@ -452,11 +454,11 @@ );

}
this.performanceClient.setPreQueueTime(
const authClient = await invokeAsync(
this.createAuthCodeClient.bind(this),
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
cachedRequest.correlationId
);
const authClient = await this.createAuthCodeClient(
serverTelemetryManager,
currentAuthority
);
this.logger.verbose("Auth code client created");
this.logger,
this.performanceClient,
this.correlationId
)(serverTelemetryManager, currentAuthority);
ThrottlingUtils.removeThrottle(

@@ -472,11 +474,5 @@ this.browserStorage,

this.logger,
this.browserCrypto,
this.performanceClient
);
return await interactionHandler.handleCodeResponseFromHash(
hash,
state,
authClient.authority,
this.networkClient
);
return await interactionHandler.handleCodeResponseFromHash(hash, state);
}

@@ -511,11 +507,10 @@

};
this.performanceClient.setPreQueueTime(
const authClient = await invokeAsync(
this.createAuthCodeClient.bind(this),
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
validLogoutRequest.correlationId
);
const authClient = await this.createAuthCodeClient(
serverTelemetryManager,
logoutRequest && logoutRequest.authority
);
this.logger.verbose("Auth code client created");
this.logger,
this.performanceClient,
this.correlationId
)(serverTelemetryManager, logoutRequest && logoutRequest.authority);

@@ -522,0 +517,0 @@ if (authClient.authority.protocolMode === ProtocolMode.OIDC) {

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

AuthError,
Constants,
IPerformanceClient,

@@ -85,9 +84,2 @@ PerformanceEvents,

)(request, InteractionType.Silent);
this.browserStorage.updateCacheEntries(
silentRequest.state,
silentRequest.nonce,
silentRequest.authority,
silentRequest.loginHint || Constants.EMPTY_STRING,
silentRequest.account || null
);

@@ -142,5 +134,3 @@ const serverTelemetryManager = this.initializeServerTelemetryManager(

},
silentRequest.state,
authClient.authority,
this.networkClient,
silentRequest,
false

@@ -153,3 +143,2 @@ );

}
this.browserStorage.cleanRequestByState(silentRequest.state);
throw e;

@@ -156,0 +145,0 @@ }

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

AuthError,
Constants,
UrlString,

@@ -124,9 +123,2 @@ ServerAuthorizationCodeResponse,

BrowserUtils.preconnect(silentRequest.authority);
this.browserStorage.updateCacheEntries(
silentRequest.state,
silentRequest.nonce,
silentRequest.authority,
silentRequest.loginHint || Constants.EMPTY_STRING,
silentRequest.account || null
);

@@ -163,3 +155,2 @@ const serverTelemetryManager = this.initializeServerTelemetryManager(

}
this.browserStorage.cleanRequestByState(silentRequest.state);
throw e;

@@ -279,7 +270,2 @@ }

UrlString.getDeserializedHash(hash);
const state = this.validateAndExtractStateFromHash(
serverParams,
InteractionType.Silent,
correlationId
);

@@ -311,3 +297,3 @@ if (serverParams.accountId) {

this.browserCrypto,
state
silentRequest.state
);

@@ -326,4 +312,2 @@ return invokeAsync(

prompt: silentRequest.prompt || PromptValue.NONE,
}).finally(() => {
this.browserStorage.cleanRequestByState(state);
});

@@ -341,4 +325,4 @@ }

correlationId
)(hash, state, authClient.authority, this.networkClient);
)(hash, silentRequest);
}
}

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

);
this.logger.verbose("Refresh token client created");
// Send request to renew token. Auth module will throw errors if token cannot be renewed.

@@ -67,20 +66,7 @@ return invokeAsync(

request.correlationId
)(silentRequest)
.then((result) => result as AuthenticationResult)
.then((result: AuthenticationResult) => {
this.performanceClient.addFields(
{
fromCache: result.fromCache,
requestId: result.requestId,
},
request.correlationId
);
return result;
})
.catch((e: AuthError) => {
(e as AuthError).setCorrelationId(this.correlationId);
serverTelemetryManager.cacheFailedRequest(e);
throw e;
});
)(silentRequest).catch((e: AuthError) => {
(e as AuthError).setCorrelationId(this.correlationId);
serverTelemetryManager.cacheFailedRequest(e);
throw e;
}) as Promise<AuthenticationResult>;
}

@@ -87,0 +73,0 @@

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

AuthorizationCodeClient,
AuthorityFactory,
Authority,
INetworkModule,
CcsCredential,

@@ -20,4 +17,3 @@ Logger,

invokeAsync,
createClientAuthError,
ClientAuthErrorCodes,
CcsCredentialType,
} from "@azure/msal-common";

@@ -30,7 +26,5 @@

} from "../error/BrowserAuthError";
import { TemporaryCacheKeys } from "../utils/BrowserConstants";
import { AuthenticationResult } from "../response/AuthenticationResult";
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
export type InteractionParams = {};
/**

@@ -66,9 +60,7 @@ * Abstract class which defines operations for a browser interaction handling class.

locationHash: string,
state: string,
authority: Authority,
networkModule: INetworkModule
request: AuthorizationUrlRequest
): Promise<AuthenticationResult> {
this.performanceClient.addQueueMeasurement(
PerformanceEvents.HandleCodeResponseFromHash,
this.authCodeRequest.correlationId
request.correlationId
);

@@ -80,12 +72,2 @@ // Check that location hash isn't empty.

// Handle code response.
const stateKey = this.browserStorage.generateStateKey(state);
const requestState = this.browserStorage.getTemporaryCache(stateKey);
if (!requestState) {
throw createClientAuthError(
ClientAuthErrorCodes.stateNotFound,
"Cached State"
);
}
let authCodeResponse;

@@ -95,3 +77,3 @@ try {

locationHash,
requestState
request.state
);

@@ -117,4 +99,4 @@ } catch (e) {

this.performanceClient,
this.authCodeRequest.correlationId
)(authCodeResponse, state, authority, networkModule);
request.correlationId
)(authCodeResponse, request);
}

@@ -132,5 +114,3 @@

authCodeResponse: AuthorizationCodePayload,
state: string,
authority: Authority,
networkModule: INetworkModule,
request: AuthorizationUrlRequest,
validateNonce: boolean = true

@@ -140,3 +120,3 @@ ): Promise<AuthenticationResult> {

PerformanceEvents.HandleCodeResponseFromServer,
this.authCodeRequest.correlationId
request.correlationId
);

@@ -147,16 +127,2 @@ this.logger.trace(

// Handle code response.
const stateKey = this.browserStorage.generateStateKey(state);
const requestState = this.browserStorage.getTemporaryCache(stateKey);
if (!requestState) {
throw createClientAuthError(
ClientAuthErrorCodes.stateNotFound,
"Cached State"
);
}
// Get cached items
const nonceKey = this.browserStorage.generateNonceKey(requestState);
const cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);
// Assign code to request

@@ -168,12 +134,8 @@ this.authCodeRequest.code = authCodeResponse.code;

await invokeAsync(
this.updateTokenEndpointAuthority.bind(this),
this.authModule.updateAuthority.bind(this.authModule),
PerformanceEvents.UpdateTokenEndpointAuthority,
this.logger,
this.performanceClient,
this.authCodeRequest.correlationId
)(
authCodeResponse.cloud_instance_host_name,
authority,
networkModule
);
request.correlationId
)(authCodeResponse.cloud_instance_host_name, request.correlationId);
}

@@ -183,6 +145,7 @@

if (validateNonce) {
authCodeResponse.nonce = cachedNonce || undefined;
// TODO: Assigning "response nonce" to "request nonce" is confusing. Refactor the function doing validation to accept request nonce directly
authCodeResponse.nonce = request.nonce || undefined;
}
authCodeResponse.state = requestState;
authCodeResponse.state = request.state;

@@ -193,5 +156,5 @@ // Add CCS parameters if available

} else {
const cachedCcsCred = this.checkCcsCredentials();
if (cachedCcsCred) {
this.authCodeRequest.ccsCredential = cachedCcsCred;
const ccsCred = this.createCcsCredentials(request);
if (ccsCred) {
this.authCodeRequest.ccsCredential = ccsCred;
}

@@ -206,5 +169,4 @@ }

this.performanceClient,
this.authCodeRequest.correlationId
request.correlationId
)(this.authCodeRequest, authCodeResponse)) as AuthenticationResult;
this.browserStorage.cleanRequestByState(state);
return tokenResponse;

@@ -214,53 +176,21 @@ }

/**
* Updates authority based on cloudInstanceHostname
* @param cloudInstanceHostname
* @param authority
* @param networkModule
* Build ccs creds if available
*/
protected async updateTokenEndpointAuthority(
cloudInstanceHostname: string,
authority: Authority,
networkModule: INetworkModule
): Promise<void> {
this.performanceClient.addQueueMeasurement(
PerformanceEvents.UpdateTokenEndpointAuthority,
this.authCodeRequest.correlationId
);
const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${authority.tenant}/`;
const cloudInstanceAuthority =
await AuthorityFactory.createDiscoveredInstance(
cloudInstanceAuthorityUri,
networkModule,
this.browserStorage,
authority.options,
this.logger,
this.performanceClient,
this.authCodeRequest.correlationId
);
this.authModule.updateAuthority(cloudInstanceAuthority);
}
protected createCcsCredentials(
request: AuthorizationUrlRequest
): CcsCredential | null {
if (request.account) {
return {
credential: request.account.homeAccountId,
type: CcsCredentialType.HOME_ACCOUNT_ID,
};
} else if (request.loginHint) {
return {
credential: request.loginHint,
type: CcsCredentialType.UPN,
};
}
/**
* Looks up ccs creds in the cache
*/
protected checkCcsCredentials(): CcsCredential | null {
// Look up ccs credential in temp cache
const cachedCcsCred = this.browserStorage.getTemporaryCache(
TemporaryCacheKeys.CCS_CREDENTIAL,
true
);
if (cachedCcsCred) {
try {
return JSON.parse(cachedCcsCred) as CcsCredential;
} catch (e) {
this.authModule.logger.error(
"Cache credential could not be parsed"
);
this.authModule.logger.errorPii(
`Cache credential could not be parsed: ${cachedCcsCred}`
);
}
}
return null;
}
}

@@ -9,5 +9,2 @@ /*

CommonAuthorizationCodeRequest,
ICrypto,
Authority,
INetworkModule,
Logger,

@@ -18,2 +15,5 @@ ServerError,

ClientAuthErrorCodes,
CcsCredential,
invokeAsync,
PerformanceEvents,
} from "@azure/msal-common";

@@ -26,3 +26,2 @@ import {

import { BrowserCacheManager } from "../cache/BrowserCacheManager";
import { InteractionHandler, InteractionParams } from "./InteractionHandler";
import { INavigationClient } from "../navigation/INavigationClient";

@@ -32,3 +31,3 @@ import { NavigationOptions } from "../navigation/NavigationOptions";

export type RedirectParams = InteractionParams & {
export type RedirectParams = {
navigationClient: INavigationClient;

@@ -40,4 +39,8 @@ redirectTimeout: number;

export class RedirectHandler extends InteractionHandler {
private browserCrypto: ICrypto;
export class RedirectHandler {
authModule: AuthorizationCodeClient;
browserStorage: BrowserCacheManager;
authCodeRequest: CommonAuthorizationCodeRequest;
logger: Logger;
performanceClient: IPerformanceClient;

@@ -49,13 +52,9 @@ constructor(

logger: Logger,
browserCrypto: ICrypto,
performanceClient: IPerformanceClient
) {
super(
authCodeModule,
storageImpl,
authCodeRequest,
logger,
performanceClient
);
this.browserCrypto = browserCrypto;
this.authModule = authCodeModule;
this.browserStorage = storageImpl;
this.authCodeRequest = authCodeRequest;
this.logger = logger;
this.performanceClient = performanceClient;
}

@@ -153,5 +152,3 @@

locationHash: string,
state: string,
authority: Authority,
networkModule: INetworkModule
state: string
): Promise<AuthenticationResult> {

@@ -207,6 +204,11 @@ this.logger.verbose("RedirectHandler.handleCodeResponse called");

if (authCodeResponse.cloud_instance_host_name) {
await this.updateTokenEndpointAuthority(
await invokeAsync(
this.authModule.updateAuthority.bind(this.authModule),
PerformanceEvents.UpdateTokenEndpointAuthority,
this.logger,
this.performanceClient,
this.authCodeRequest.correlationId
)(
authCodeResponse.cloud_instance_host_name,
authority,
networkModule
this.authCodeRequest.correlationId
);

@@ -237,2 +239,26 @@ }

}
/**
* Looks up ccs creds in the cache
*/
protected checkCcsCredentials(): CcsCredential | null {
// Look up ccs credential in temp cache
const cachedCcsCred = this.browserStorage.getTemporaryCache(
TemporaryCacheKeys.CCS_CREDENTIAL,
true
);
if (cachedCcsCred) {
try {
return JSON.parse(cachedCcsCred) as CcsCredential;
} catch (e) {
this.authModule.logger.error(
"Cache credential could not be parsed"
);
this.authModule.logger.errorPii(
`Cache credential could not be parsed: ${cachedCcsCred}`
);
}
}
return null;
}
}
/* eslint-disable header/header */
export const name = "@azure/msal-browser";
export const version = "3.3.0";
export const version = "3.4.0";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff 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