@azure/msal-browser
Advanced tools
Comparing version 3.19.1 to 3.20.0
@@ -1,2 +0,2 @@ | ||
import { Logger, ICrypto, AccountEntity, ScopeSet, IPerformanceClient, TokenClaims, InProgressPerformanceEvent } from "@azure/msal-common"; | ||
import { Logger, ICrypto, AccountEntity, ScopeSet, IPerformanceClient, TokenClaims, InProgressPerformanceEvent, ServerTelemetryManager } from "@azure/msal-common"; | ||
import { BaseInteractionClient } from "./BaseInteractionClient"; | ||
@@ -23,4 +23,12 @@ import { BrowserConfiguration } from "../config/Configuration"; | ||
protected nativeStorageManager: BrowserCacheManager; | ||
protected skus: string; | ||
protected serverTelemetryManager: ServerTelemetryManager; | ||
constructor(config: BrowserConfiguration, browserStorage: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, apiId: ApiId, performanceClient: IPerformanceClient, provider: NativeMessageHandler, accountId: string, nativeStorageImpl: BrowserCacheManager, correlationId?: string); | ||
/** | ||
* Adds SKUs to request extra query parameters | ||
* @param request {NativeTokenRequest} | ||
* @private | ||
*/ | ||
private addRequestSKUs; | ||
/** | ||
* Acquire token from native platform via browser extension | ||
@@ -27,0 +35,0 @@ * @param request |
export declare const name = "@azure/msal-browser"; | ||
export declare const version = "3.19.1"; | ||
export declare const version = "3.20.0"; | ||
//# sourceMappingURL=packageMetadata.d.ts.map |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"version": "3.19.1", | ||
"version": "3.20.0", | ||
"description": "Microsoft Authentication Library for js", | ||
@@ -108,4 +108,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@azure/msal-common": "14.13.1" | ||
"@azure/msal-common": "14.14.0" | ||
} | ||
} |
@@ -39,2 +39,3 @@ /* | ||
InProgressPerformanceEvent, | ||
ServerTelemetryManager, | ||
} from "@azure/msal-common"; | ||
@@ -54,2 +55,3 @@ import { BaseInteractionClient } from "./BaseInteractionClient"; | ||
NativeConstants, | ||
BrowserConstants, | ||
} from "../utils/BrowserConstants"; | ||
@@ -77,2 +79,3 @@ import { | ||
import { base64Decode } from "../encode/Base64Decode"; | ||
import { version } from "../packageMetadata"; | ||
@@ -90,2 +93,4 @@ const BrokerServerParamKeys = { | ||
protected nativeStorageManager: BrowserCacheManager; | ||
protected skus: string; | ||
protected serverTelemetryManager: ServerTelemetryManager; | ||
@@ -132,5 +137,34 @@ constructor( | ||
); | ||
this.serverTelemetryManager = this.initializeServerTelemetryManager( | ||
this.apiId | ||
); | ||
const extensionName = | ||
this.nativeMessageHandler.getExtensionId() === | ||
NativeConstants.PREFERRED_EXTENSION_ID | ||
? "chrome" | ||
: this.nativeMessageHandler.getExtensionId()?.length | ||
? "unknown" | ||
: undefined; | ||
this.skus = ServerTelemetryManager.makeExtraSkuString({ | ||
libraryName: BrowserConstants.MSAL_SKU, | ||
libraryVersion: version, | ||
extensionName: extensionName, | ||
extensionVersion: this.nativeMessageHandler.getExtensionVersion(), | ||
}); | ||
} | ||
/** | ||
* Adds SKUs to request extra query parameters | ||
* @param request {NativeTokenRequest} | ||
* @private | ||
*/ | ||
private addRequestSKUs(request: NativeTokenRequest) { | ||
request.extraParameters = { | ||
...request.extraParameters, | ||
[AADServerParamKeys.X_CLIENT_EXTRA_SKU]: this.skus, | ||
}; | ||
} | ||
/** | ||
* Acquire token from native platform via browser extension | ||
@@ -155,60 +189,69 @@ * @param request | ||
// initialize native request | ||
const nativeRequest = await this.initializeNativeRequest(request); | ||
// check if the tokens can be retrieved from internal cache | ||
try { | ||
const result = await this.acquireTokensFromCache( | ||
this.accountId, | ||
nativeRequest | ||
); | ||
nativeATMeasurement.end({ | ||
success: true, | ||
isNativeBroker: false, // Should be true only when the result is coming directly from the broker | ||
fromCache: true, | ||
}); | ||
return result; | ||
} catch (e) { | ||
// continue with a native call for any and all errors | ||
this.logger.info( | ||
"MSAL internal Cache does not contain tokens, proceed to make a native call" | ||
); | ||
} | ||
// initialize native request | ||
const nativeRequest = await this.initializeNativeRequest(request); | ||
const { ...nativeTokenRequest } = nativeRequest; | ||
// fall back to native calls | ||
const messageBody: NativeExtensionRequestBody = { | ||
method: NativeExtensionMethod.GetToken, | ||
request: nativeTokenRequest, | ||
}; | ||
const response: object = await this.nativeMessageHandler.sendMessage( | ||
messageBody | ||
); | ||
const validatedResponse: NativeResponse = | ||
this.validateNativeResponse(response); | ||
return this.handleNativeResponse( | ||
validatedResponse, | ||
nativeRequest, | ||
reqTimestamp | ||
) | ||
.then((result: AuthenticationResult) => { | ||
// check if the tokens can be retrieved from internal cache | ||
try { | ||
const result = await this.acquireTokensFromCache( | ||
this.accountId, | ||
nativeRequest | ||
); | ||
nativeATMeasurement.end({ | ||
success: true, | ||
isNativeBroker: true, | ||
requestId: result.requestId, | ||
isNativeBroker: false, // Should be true only when the result is coming directly from the broker | ||
fromCache: true, | ||
}); | ||
return result; | ||
}) | ||
.catch((error: AuthError) => { | ||
nativeATMeasurement.end({ | ||
success: false, | ||
errorCode: error.errorCode, | ||
subErrorCode: error.subError, | ||
isNativeBroker: true, | ||
} catch (e) { | ||
// continue with a native call for any and all errors | ||
this.logger.info( | ||
"MSAL internal Cache does not contain tokens, proceed to make a native call" | ||
); | ||
} | ||
const { ...nativeTokenRequest } = nativeRequest; | ||
// fall back to native calls | ||
const messageBody: NativeExtensionRequestBody = { | ||
method: NativeExtensionMethod.GetToken, | ||
request: nativeTokenRequest, | ||
}; | ||
const response: object = | ||
await this.nativeMessageHandler.sendMessage(messageBody); | ||
const validatedResponse: NativeResponse = | ||
this.validateNativeResponse(response); | ||
return await this.handleNativeResponse( | ||
validatedResponse, | ||
nativeRequest, | ||
reqTimestamp | ||
) | ||
.then((result: AuthenticationResult) => { | ||
nativeATMeasurement.end({ | ||
success: true, | ||
isNativeBroker: true, | ||
requestId: result.requestId, | ||
}); | ||
this.serverTelemetryManager.clearNativeBrokerErrorCode(); | ||
return result; | ||
}) | ||
.catch((error: AuthError) => { | ||
nativeATMeasurement.end({ | ||
success: false, | ||
errorCode: error.errorCode, | ||
subErrorCode: error.subError, | ||
isNativeBroker: true, | ||
}); | ||
throw error; | ||
}); | ||
throw error; | ||
}); | ||
} catch (e) { | ||
if (e instanceof NativeAuthError) { | ||
this.serverTelemetryManager.setNativeBrokerErrorCode( | ||
e.errorCode | ||
); | ||
} | ||
throw e; | ||
} | ||
} | ||
@@ -316,4 +359,9 @@ | ||
// Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise | ||
if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) { | ||
throw e; | ||
if (e instanceof NativeAuthError) { | ||
this.serverTelemetryManager.setNativeBrokerErrorCode( | ||
e.errorCode | ||
); | ||
if (isFatalNativeAuthError(e)) { | ||
throw e; | ||
} | ||
} | ||
@@ -409,3 +457,5 @@ } | ||
this.browserStorage.setInteractionInProgress(false); | ||
return await result; | ||
const res = await result; | ||
this.serverTelemetryManager.clearNativeBrokerErrorCode(); | ||
return res; | ||
} catch (e) { | ||
@@ -991,2 +1041,3 @@ this.browserStorage.setInteractionInProgress(false); | ||
} | ||
this.addRequestSKUs(validatedRequest); | ||
@@ -993,0 +1044,0 @@ return validatedRequest; |
/* eslint-disable header/header */ | ||
export const name = "@azure/msal-browser"; | ||
export const version = "3.19.1"; | ||
export const version = "3.20.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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5628555
71854
+ Added@azure/msal-common@14.14.0(transitive)
- Removed@azure/msal-common@14.13.1(transitive)
Updated@azure/msal-common@14.14.0