@azure/msal-browser 2.32.2 → 2.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.d.ts +3 -0
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +75 -26
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.js +1 -1
- package/dist/app/PublicClientApplication.d.ts +2 -0
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +37 -15
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +10 -7
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.js +18 -8
- package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/BrowserCacheManager.js +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/CryptoKeyStore.js +1 -1
- package/dist/cache/DatabaseStorage.js +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/TokenCache.js +1 -1
- package/dist/config/Configuration.js +1 -1
- package/dist/crypto/BrowserCrypto.js +1 -1
- package/dist/crypto/CryptoOps.js +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/ModernBrowserCrypto.js +1 -1
- package/dist/crypto/MsBrowserCrypto.js +1 -1
- package/dist/crypto/MsrBrowserCrypto.js +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/SignedHttpRequest.js +1 -1
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/error/BrowserAuthError.d.ts +8 -0
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +11 -1
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/error/NativeAuthError.js +1 -1
- package/dist/event/EventHandler.js +1 -1
- package/dist/event/EventMessage.js +1 -1
- package/dist/event/EventType.js +1 -1
- package/dist/index.cjs.js +1683 -979
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +3 -2
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts +66 -3
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.js +174 -68
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.js +9 -2
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.js +13 -5
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +7 -3
- package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +7 -2
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +21 -4
- package/dist/interaction_client/SilentIframeClient.js.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +9 -3
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +16 -5
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts +3 -2
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +12 -4
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +2 -2
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +3 -3
- package/dist/interaction_handler/RedirectHandler.js.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +2 -2
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +13 -15
- package/dist/interaction_handler/SilentHandler.js.map +1 -1
- package/dist/internals.d.ts +5 -0
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +4 -1
- package/dist/internals.js.map +1 -1
- package/dist/navigation/NavigationClient.js +1 -1
- package/dist/network/FetchClient.js +1 -1
- package/dist/network/XhrClient.js +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/EndSessionPopupRequest.d.ts +1 -1
- package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
- package/dist/request/EndSessionRequest.d.ts +1 -1
- package/dist/request/EndSessionRequest.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +20 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +80 -3
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +14 -5
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +36 -4
- package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
- package/dist/utils/BrowserConstants.js +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.js +1 -1
- package/dist/utils/BrowserUtils.js +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/lib/msal-browser.js +1683 -979
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +43 -44
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicClientApplication.js","sources":["../../src/app/PublicClientApplication.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccountInfo, AuthenticationResult, Constants, RequestThumbprint, AuthError, PerformanceEvents, ServerError, InteractionRequiredAuthError } from \"@azure/msal-common\";\nimport { Configuration } from \"../config/Configuration\";\nimport { DEFAULT_REQUEST, InteractionType, ApiId, CacheLookupPolicy, BrowserConstants } from \"../utils/BrowserConstants\";\nimport { IPublicClientApplication } from \"./IPublicClientApplication\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\nimport { PopupRequest } from \"../request/PopupRequest\";\nimport { ClientApplication } from \"./ClientApplication\";\nimport { SilentRequest } from \"../request/SilentRequest\";\nimport { EventType } from \"../event/EventType\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { NativeAuthError } from \"../error/NativeAuthError\";\nimport { NativeMessageHandler } from \"../broker/nativeBroker/NativeMessageHandler\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\n\n/**\n * The PublicClientApplication class is the object exposed by the library to perform authentication and authorization functions in Single Page Applications\n * to obtain JWT tokens as described in the OAuth 2.0 Authorization Code Flow with PKCE specification.\n */\nexport class PublicClientApplication extends ClientApplication implements IPublicClientApplication {\n\n // Active requests\n private activeSilentTokenRequests: Map<string, Promise<AuthenticationResult>>;\n\n /**\n * @constructor\n * Constructor for the PublicClientApplication used to instantiate the PublicClientApplication object\n *\n * Important attributes in the Configuration object for auth are:\n * - clientID: the application ID of your application. You can obtain one by registering your application with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview\n * - authority: the authority URL for your application.\n * - redirect_uri: the uri of your application registered in the portal.\n *\n * In Azure AD, authority is a URL indicating the Azure active directory that MSAL uses to obtain tokens.\n * It is of the form https://login.microsoftonline.com/{Enter_the_Tenant_Info_Here}\n * If your application supports Accounts in one organizational directory, replace \"Enter_the_Tenant_Info_Here\" value with the Tenant Id or Tenant name (for example, contoso.microsoft.com).\n * If your application supports Accounts in any organizational directory, replace \"Enter_the_Tenant_Info_Here\" value with organizations.\n * If your application supports Accounts in any organizational directory and personal Microsoft accounts, replace \"Enter_the_Tenant_Info_Here\" value with common.\n * To restrict support to Personal Microsoft accounts only, replace \"Enter_the_Tenant_Info_Here\" value with consumers.\n *\n * In Azure B2C, authority is of the form https://{instance}/tfp/{tenant}/{policyName}/\n * Full B2C functionality will be available in this library in future versions.\n *\n * @param configuration object for the MSAL PublicClientApplication instance\n */\n constructor(configuration: Configuration) {\n super(configuration);\n\n this.activeSilentTokenRequests = new Map();\n }\n\n /**\n * Use when initiating the login process by redirecting the user's browser to the authorization endpoint. This function redirects the page, so\n * any code that follows this function will not execute.\n *\n * IMPORTANT: It is NOT recommended to have code that is dependent on the resolution of the Promise. This function will navigate away from the current\n * browser window. It currently returns a Promise in order to reflect the asynchronous nature of the code running in this function.\n *\n * @param request\n */\n async loginRedirect(request?: RedirectRequest): Promise<void> {\n const correlationId: string = this.getRequestCorrelationId(request);\n this.logger.verbose(\"loginRedirect called\", correlationId);\n return this.acquireTokenRedirect({\n correlationId,\n ...(request || DEFAULT_REQUEST)\n });\n }\n\n /**\n * Use when initiating the login process via opening a popup window in the user's browser\n *\n * @param request\n *\n * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.\n */\n loginPopup(request?: PopupRequest): Promise<AuthenticationResult> {\n const correlationId: string = this.getRequestCorrelationId(request);\n this.logger.verbose(\"loginPopup called\", correlationId);\n return this.acquireTokenPopup({\n correlationId,\n ...(request || DEFAULT_REQUEST)\n });\n }\n\n /**\n * Silently acquire an access token for a given set of scopes. Returns currently processing promise if parallel requests are made.\n *\n * @param {@link (SilentRequest:type)}\n * @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse} object\n */\n async acquireTokenSilent(request: SilentRequest): Promise<AuthenticationResult> {\n const correlationId = this.getRequestCorrelationId(request);\n const atsMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilent, correlationId);\n atsMeasurement.addStaticFields({\n cacheLookupPolicy: request.cacheLookupPolicy\n });\n \n this.preflightBrowserEnvironmentCheck(InteractionType.Silent);\n this.logger.verbose(\"acquireTokenSilent called\", correlationId);\n\n const account = request.account || this.getActiveAccount();\n if (!account) {\n throw BrowserAuthError.createNoAccountError();\n }\n\n const thumbprint: RequestThumbprint = {\n clientId: this.config.auth.clientId,\n authority: request.authority || Constants.EMPTY_STRING,\n scopes: request.scopes,\n homeAccountIdentifier: account.homeAccountId,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n const silentRequestKey = JSON.stringify(thumbprint);\n\n const cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);\n if (typeof cachedResponse === \"undefined\") {\n this.logger.verbose(\"acquireTokenSilent called for the first time, storing active request\", correlationId);\n\n const response = this.acquireTokenSilentAsync({\n ...request,\n correlationId\n }, account)\n .then((result) => {\n this.activeSilentTokenRequests.delete(silentRequestKey);\n atsMeasurement.addStaticFields({\n accessTokenSize: result.accessToken.length,\n idTokenSize: result.idToken.length\n });\n atsMeasurement.endMeasurement({\n success: true,\n fromCache: result.fromCache,\n isNativeBroker: result.fromNativeBroker,\n cacheLookupPolicy: request.cacheLookupPolicy,\n requestId: result.requestId,\n });\n atsMeasurement.flushMeasurement();\n return result;\n })\n .catch((error: AuthError) => {\n this.activeSilentTokenRequests.delete(silentRequestKey);\n atsMeasurement.endMeasurement({\n errorCode: error.errorCode,\n subErrorCode: error.subError,\n success: false\n });\n atsMeasurement.flushMeasurement();\n throw error;\n });\n this.activeSilentTokenRequests.set(silentRequestKey, response);\n return response;\n } else {\n this.logger.verbose(\"acquireTokenSilent has been called previously, returning the result from the first call\", correlationId);\n atsMeasurement.endMeasurement({\n success: true\n });\n // Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics\n atsMeasurement.discardMeasurement();\n return cachedResponse;\n }\n }\n\n /**\n * Silently acquire an access token for a given set of scopes. Will use cached token if available, otherwise will attempt to acquire a new token from the network via refresh token.\n * @param {@link (SilentRequest:type)}\n * @param {@link (AccountInfo:type)}\n * @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse} \n */\n protected async acquireTokenSilentAsync(request: SilentRequest, account: AccountInfo): Promise<AuthenticationResult>{\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, InteractionType.Silent, request);\n const atsAsyncMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);\n\n let result: Promise<AuthenticationResult>;\n if (NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) && account.nativeAccountId) {\n this.logger.verbose(\"acquireTokenSilent - attempting to acquire token from native platform\");\n const silentRequest: SilentRequest = {\n ...request,\n account\n };\n result = this.acquireTokenNative(silentRequest, ApiId.acquireTokenSilent_silentFlow).catch(async (e: AuthError) => {\n // If native token acquisition fails for availability reasons fallback to web flow\n if (e instanceof NativeAuthError && e.isFatal()) {\n this.logger.verbose(\"acquireTokenSilent - native platform unavailable, falling back to web flow\");\n this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt \n\n // Cache will not contain tokens, given that previous WAM requests succeeded. Skip cache and RT renewal and go straight to iframe renewal\n const silentIframeClient = this.createSilentIframeClient(request.correlationId);\n return silentIframeClient.acquireToken(request);\n }\n throw e;\n });\n } else {\n this.logger.verbose(\"acquireTokenSilent - attempting to acquire token from web flow\");\n\n const silentCacheClient = this.createSilentCacheClient(request.correlationId);\n const silentRequest = await silentCacheClient.initializeSilentRequest(request, account);\n \n const requestWithCLP = {\n ...request,\n // set the request's CacheLookupPolicy to Default if it was not optionally passed in\n cacheLookupPolicy: request.cacheLookupPolicy || CacheLookupPolicy.Default\n };\n\n result = this.acquireTokenFromCache(silentCacheClient, silentRequest, requestWithCLP).catch((cacheError: AuthError) => {\n if (requestWithCLP.cacheLookupPolicy === CacheLookupPolicy.AccessToken) {\n throw cacheError;\n }\n\n // block the reload if it occurred inside a hidden iframe\n BrowserUtils.blockReloadInHiddenIframes();\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_NETWORK_START, InteractionType.Silent, silentRequest);\n\n return this.acquireTokenByRefreshToken(silentRequest, requestWithCLP).catch((refreshTokenError: AuthError) => {\n const isServerError = refreshTokenError instanceof ServerError;\n const isInteractionRequiredError = refreshTokenError instanceof InteractionRequiredAuthError;\n const isInvalidGrantError = (refreshTokenError.errorCode === BrowserConstants.INVALID_GRANT_ERROR);\n\n if ((!isServerError ||\n !isInvalidGrantError ||\n isInteractionRequiredError ||\n requestWithCLP.cacheLookupPolicy === CacheLookupPolicy.AccessTokenAndRefreshToken ||\n requestWithCLP.cacheLookupPolicy === CacheLookupPolicy.RefreshToken)\n && (requestWithCLP.cacheLookupPolicy !== CacheLookupPolicy.Skip)\n ) {\n throw refreshTokenError;\n }\n \n this.logger.verbose(\"Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.\", request.correlationId);\n return this.acquireTokenBySilentIframe(silentRequest);\n });\n });\n }\n\n return result.then((response) => {\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, response);\n atsAsyncMeasurement.endMeasurement({\n success: true,\n fromCache: response.fromCache,\n isNativeBroker: response.fromNativeBroker,\n requestId: response.requestId\n });\n return response;\n }).catch((tokenRenewalError: AuthError) => {\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Silent, null, tokenRenewalError);\n atsAsyncMeasurement.endMeasurement({\n errorCode: tokenRenewalError.errorCode,\n subErrorCode: tokenRenewalError.subError,\n success: false\n });\n throw tokenRenewalError;\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;AAmBA;;;;;IAI6C,2CAAiB;;;;;;;;;;;;;;;;;;;;;;IA0B1D,iCAAY,aAA4B;QAAxC,YACI,kBAAM,aAAa,CAAC,SAGvB;QADG,KAAI,CAAC,yBAAyB,GAAG,IAAI,GAAG,EAAE,CAAC;;KAC9C;;;;;;;;;;IAWK,+CAAa,GAAnB,UAAoB,OAAyB;;;;gBACnC,aAAa,GAAW,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;gBACpE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;gBAC3D,sBAAO,IAAI,CAAC,oBAAoB,YAC5B,aAAa,eAAA,KACT,OAAO,IAAI,eAAe,GAChC,EAAC;;;KACN;;;;;;;;IASD,4CAAU,GAAV,UAAW,OAAsB;QAC7B,IAAM,aAAa,GAAW,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC,iBAAiB,YACzB,aAAa,eAAA,KACT,OAAO,IAAI,eAAe,GAChC,CAAC;KACN;;;;;;;IAQK,oDAAkB,GAAxB,UAAyB,OAAsB;;;;;gBACrC,aAAa,GAAG,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;gBACtD,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,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KAAI,CAAC,MAAM,CAAC,OAAO,CAAC,wGAAwG,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;gCACrJ,OAAO,KAAI,CAAC,0BAA0B,CAAC,eAAa,CAAC,CAAC;6BACzD,CAAC,CAAC;yBACN,CAAC,CAAC;;4BAGP,sBAAO,MAAM,CAAC,IAAI,CAAC,UAAC,QAAQ;4BACxB,KAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,qBAAqB,EAAE,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;4BAC/F,mBAAmB,CAAC,cAAc,CAAC;gCAC/B,OAAO,EAAE,IAAI;gCACb,SAAS,EAAE,QAAQ,CAAC,SAAS;gCAC7B,cAAc,EAAE,QAAQ,CAAC,gBAAgB;gCACzC,SAAS,EAAE,QAAQ,CAAC,SAAS;6BAChC,CAAC,CAAC;4BACH,OAAO,QAAQ,CAAC;yBACnB,CAAC,CAAC,KAAK,CAAC,UAAC,iBAA4B;4BAClC,KAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,qBAAqB,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;4BAC9G,mBAAmB,CAAC,cAAc,CAAC;gCAC/B,SAAS,EAAE,iBAAiB,CAAC,SAAS;gCACtC,YAAY,EAAE,iBAAiB,CAAC,QAAQ;gCACxC,OAAO,EAAE,KAAK;6BACjB,CAAC,CAAC;4BACH,MAAM,iBAAiB,CAAC;yBAC3B,CAAC,EAAC;;;;KACN;IACL,8BAAC;AAAD,CA9OA,CAA6C,iBAAiB;;;;"}
|
|
1
|
+
{"version":3,"file":"PublicClientApplication.js","sources":["../../src/app/PublicClientApplication.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AccountInfo, AuthenticationResult, Constants, RequestThumbprint, AuthError, PerformanceEvents, ServerError, InteractionRequiredAuthError, InProgressPerformanceEvent } from \"@azure/msal-common\";\nimport { Configuration } from \"../config/Configuration\";\nimport { DEFAULT_REQUEST, InteractionType, ApiId, CacheLookupPolicy, BrowserConstants } from \"../utils/BrowserConstants\";\nimport { IPublicClientApplication } from \"./IPublicClientApplication\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\nimport { PopupRequest } from \"../request/PopupRequest\";\nimport { ClientApplication } from \"./ClientApplication\";\nimport { SilentRequest } from \"../request/SilentRequest\";\nimport { EventType } from \"../event/EventType\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { NativeAuthError } from \"../error/NativeAuthError\";\nimport { NativeMessageHandler } from \"../broker/nativeBroker/NativeMessageHandler\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\n\n/**\n * The PublicClientApplication class is the object exposed by the library to perform authentication and authorization functions in Single Page Applications\n * to obtain JWT tokens as described in the OAuth 2.0 Authorization Code Flow with PKCE specification.\n */\nexport class PublicClientApplication extends ClientApplication implements IPublicClientApplication {\n\n // Active requests\n private activeSilentTokenRequests: Map<string, Promise<AuthenticationResult>>;\n private astsAsyncMeasurement?: InProgressPerformanceEvent = undefined;\n\n /**\n * @constructor\n * Constructor for the PublicClientApplication used to instantiate the PublicClientApplication object\n *\n * Important attributes in the Configuration object for auth are:\n * - clientID: the application ID of your application. You can obtain one by registering your application with our Application registration portal : https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview\n * - authority: the authority URL for your application.\n * - redirect_uri: the uri of your application registered in the portal.\n *\n * In Azure AD, authority is a URL indicating the Azure active directory that MSAL uses to obtain tokens.\n * It is of the form https://login.microsoftonline.com/{Enter_the_Tenant_Info_Here}\n * If your application supports Accounts in one organizational directory, replace \"Enter_the_Tenant_Info_Here\" value with the Tenant Id or Tenant name (for example, contoso.microsoft.com).\n * If your application supports Accounts in any organizational directory, replace \"Enter_the_Tenant_Info_Here\" value with organizations.\n * If your application supports Accounts in any organizational directory and personal Microsoft accounts, replace \"Enter_the_Tenant_Info_Here\" value with common.\n * To restrict support to Personal Microsoft accounts only, replace \"Enter_the_Tenant_Info_Here\" value with consumers.\n *\n * In Azure B2C, authority is of the form https://{instance}/tfp/{tenant}/{policyName}/\n * Full B2C functionality will be available in this library in future versions.\n *\n * @param configuration object for the MSAL PublicClientApplication instance\n */\n constructor(configuration: Configuration) {\n super(configuration);\n\n this.activeSilentTokenRequests = new Map();\n // Register listener functions\n this.trackPageVisibility = this.trackPageVisibility.bind(this);\n }\n\n /**\n * Use when initiating the login process by redirecting the user's browser to the authorization endpoint. This function redirects the page, so\n * any code that follows this function will not execute.\n *\n * IMPORTANT: It is NOT recommended to have code that is dependent on the resolution of the Promise. This function will navigate away from the current\n * browser window. It currently returns a Promise in order to reflect the asynchronous nature of the code running in this function.\n *\n * @param request\n */\n async loginRedirect(request?: RedirectRequest): Promise<void> {\n const correlationId: string = this.getRequestCorrelationId(request);\n this.logger.verbose(\"loginRedirect called\", correlationId);\n return this.acquireTokenRedirect({\n correlationId,\n ...(request || DEFAULT_REQUEST)\n });\n }\n\n /**\n * Use when initiating the login process via opening a popup window in the user's browser\n *\n * @param request\n *\n * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.\n */\n loginPopup(request?: PopupRequest): Promise<AuthenticationResult> {\n const correlationId: string = this.getRequestCorrelationId(request);\n this.logger.verbose(\"loginPopup called\", correlationId);\n return this.acquireTokenPopup({\n correlationId,\n ...(request || DEFAULT_REQUEST)\n });\n }\n\n /**\n * Silently acquire an access token for a given set of scopes. Returns currently processing promise if parallel requests are made.\n *\n * @param {@link (SilentRequest:type)}\n * @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse} object\n */\n async acquireTokenSilent(request: SilentRequest): Promise<AuthenticationResult> {\n const correlationId = this.getRequestCorrelationId(request);\n const atsMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilent, correlationId);\n atsMeasurement.addStaticFields({\n cacheLookupPolicy: request.cacheLookupPolicy\n });\n\n this.preflightBrowserEnvironmentCheck(InteractionType.Silent);\n this.logger.verbose(\"acquireTokenSilent called\", correlationId);\n\n const account = request.account || this.getActiveAccount();\n if (!account) {\n throw BrowserAuthError.createNoAccountError();\n }\n\n const thumbprint: RequestThumbprint = {\n clientId: this.config.auth.clientId,\n authority: request.authority || Constants.EMPTY_STRING,\n scopes: request.scopes,\n homeAccountIdentifier: account.homeAccountId,\n claims: request.claims,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshKid: request.sshKid\n };\n const silentRequestKey = JSON.stringify(thumbprint);\n\n const cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);\n if (typeof cachedResponse === \"undefined\") {\n this.logger.verbose(\"acquireTokenSilent called for the first time, storing active request\", correlationId);\n\n this.performanceClient.setPreQueueTime(PerformanceEvents.AcquireTokenSilentAsync, correlationId);\n const response = this.acquireTokenSilentAsync({\n ...request,\n correlationId\n }, account)\n .then((result) => {\n this.activeSilentTokenRequests.delete(silentRequestKey);\n atsMeasurement.addStaticFields({\n accessTokenSize: result.accessToken.length,\n idTokenSize: result.idToken.length\n });\n atsMeasurement.endMeasurement({\n success: true,\n fromCache: result.fromCache,\n isNativeBroker: result.fromNativeBroker,\n cacheLookupPolicy: request.cacheLookupPolicy,\n requestId: result.requestId,\n });\n return result;\n })\n .catch((error: AuthError) => {\n this.activeSilentTokenRequests.delete(silentRequestKey);\n atsMeasurement.endMeasurement({\n errorCode: error.errorCode,\n subErrorCode: error.subError,\n success: false\n });\n throw error;\n });\n this.activeSilentTokenRequests.set(silentRequestKey, response);\n return response;\n } else {\n this.logger.verbose(\"acquireTokenSilent has been called previously, returning the result from the first call\", correlationId);\n // Discard measurements for memoized calls, as they are usually only a couple of ms and will artificially deflate metrics\n atsMeasurement.discardMeasurement();\n return cachedResponse;\n }\n }\n\n private trackPageVisibility():void {\n if (!this.astsAsyncMeasurement) {\n return;\n }\n this.logger.info(\"Perf: Visibility change detected\");\n this.astsAsyncMeasurement.increment({\n visibilityChangeCount: 1,\n });\n }\n\n /**\n * Silently acquire an access token for a given set of scopes. Will use cached token if available, otherwise will attempt to acquire a new token from the network via refresh token.\n * @param {@link (SilentRequest:type)}\n * @param {@link (AccountInfo:type)}\n * @returns {Promise.<AuthenticationResult>} - a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the {@link AuthResponse}\n */\n protected async acquireTokenSilentAsync(request: SilentRequest, account: AccountInfo): Promise<AuthenticationResult>{\n this.performanceClient.addQueueMeasurement(PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);\n\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, InteractionType.Silent, request);\n this.astsAsyncMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);\n this.astsAsyncMeasurement?.increment({\n visibilityChangeCount: 0\n });\n document.addEventListener(\"visibilitychange\",this.trackPageVisibility);\n let result: Promise<AuthenticationResult>;\n if (NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) && account.nativeAccountId) {\n this.logger.verbose(\"acquireTokenSilent - attempting to acquire token from native platform\");\n const silentRequest: SilentRequest = {\n ...request,\n account\n };\n result = this.acquireTokenNative(silentRequest, ApiId.acquireTokenSilent_silentFlow).catch(async (e: AuthError) => {\n // If native token acquisition fails for availability reasons fallback to web flow\n if (e instanceof NativeAuthError && e.isFatal()) {\n this.logger.verbose(\"acquireTokenSilent - native platform unavailable, falling back to web flow\");\n this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt\n\n // Cache will not contain tokens, given that previous WAM requests succeeded. Skip cache and RT renewal and go straight to iframe renewal\n const silentIframeClient = this.createSilentIframeClient(request.correlationId);\n return silentIframeClient.acquireToken(request);\n }\n throw e;\n });\n } else {\n this.logger.verbose(\"acquireTokenSilent - attempting to acquire token from web flow\");\n\n const silentCacheClient = this.createSilentCacheClient(request.correlationId);\n\n this.performanceClient.setPreQueueTime(PerformanceEvents.InitializeSilentRequest, request.correlationId);\n const silentRequest = await silentCacheClient.initializeSilentRequest(request, account);\n\n const requestWithCLP = {\n ...request,\n // set the request's CacheLookupPolicy to Default if it was not optionally passed in\n cacheLookupPolicy: request.cacheLookupPolicy || CacheLookupPolicy.Default\n };\n\n this.performanceClient.setPreQueueTime(PerformanceEvents.AcquireTokenFromCache, silentRequest.correlationId);\n result = this.acquireTokenFromCache(silentCacheClient, silentRequest, requestWithCLP).catch((cacheError: AuthError) => {\n if (requestWithCLP.cacheLookupPolicy === CacheLookupPolicy.AccessToken) {\n throw cacheError;\n }\n\n // block the reload if it occurred inside a hidden iframe\n BrowserUtils.blockReloadInHiddenIframes();\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_NETWORK_START, InteractionType.Silent, silentRequest);\n\n this.performanceClient.setPreQueueTime(PerformanceEvents.AcquireTokenByRefreshToken, silentRequest.correlationId);\n return this.acquireTokenByRefreshToken(silentRequest, requestWithCLP).catch((refreshTokenError: AuthError) => {\n const isServerError = refreshTokenError instanceof ServerError;\n const isInteractionRequiredError = refreshTokenError instanceof InteractionRequiredAuthError;\n const isInvalidGrantError = (refreshTokenError.errorCode === BrowserConstants.INVALID_GRANT_ERROR);\n\n if ((!isServerError ||\n !isInvalidGrantError ||\n isInteractionRequiredError ||\n requestWithCLP.cacheLookupPolicy === CacheLookupPolicy.AccessTokenAndRefreshToken ||\n requestWithCLP.cacheLookupPolicy === CacheLookupPolicy.RefreshToken)\n && (requestWithCLP.cacheLookupPolicy !== CacheLookupPolicy.Skip)\n ) {\n throw refreshTokenError;\n }\n\n this.logger.verbose(\"Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.\", request.correlationId);\n this.performanceClient.setPreQueueTime(PerformanceEvents.AcquireTokenBySilentIframe, silentRequest.correlationId);\n return this.acquireTokenBySilentIframe(silentRequest);\n });\n });\n }\n\n return result.then((response) => {\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, response);\n this.astsAsyncMeasurement?.endMeasurement({\n success: true,\n fromCache: response.fromCache,\n isNativeBroker: response.fromNativeBroker,\n requestId: response.requestId\n });\n return response;\n }).catch((tokenRenewalError: AuthError) => {\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Silent, null, tokenRenewalError);\n this.astsAsyncMeasurement?.endMeasurement({\n errorCode: tokenRenewalError.errorCode,\n subErrorCode: tokenRenewalError.subError,\n success: false\n });\n throw tokenRenewalError;\n }).finally(() => {\n document.removeEventListener(\"visibilitychange\",this.trackPageVisibility);\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;AAmBA;;;;;IAI6C,2CAAiB;;;;;;;;;;;;;;;;;;;;;;IA2B1D,iCAAY,aAA4B;QAAxC,YACI,kBAAM,aAAa,CAAC,SAKvB;QA7BO,0BAAoB,GAAgC,SAAS,CAAC;QA0BlE,KAAI,CAAC,yBAAyB,GAAG,IAAI,GAAG,EAAE,CAAC;;QAE3C,KAAI,CAAC,mBAAmB,GAAG,KAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;;KAClE;;;;;;;;;;IAWK,+CAAa,GAAnB,UAAoB,OAAyB;;;;gBACnC,aAAa,GAAW,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;gBACpE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,aAAa,CAAC,CAAC;gBAC3D,sBAAO,IAAI,CAAC,oBAAoB,YAC5B,aAAa,eAAA,KACT,OAAO,IAAI,eAAe,GAChC,EAAC;;;KACN;;;;;;;;IASD,4CAAU,GAAV,UAAW,OAAsB;QAC7B,IAAM,aAAa,GAAW,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,MAAM,CAAC,OAA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
|
|
2
2
|
import { NativeExtensionRequestBody } from "./NativeRequest";
|
|
3
3
|
import { BrowserConfiguration } from "../../config/Configuration";
|
|
4
4
|
export declare class NativeMessageHandler {
|
|
5
5
|
private extensionId;
|
|
6
6
|
private extensionVersion;
|
|
7
7
|
private logger;
|
|
8
|
-
private handshakeTimeoutMs;
|
|
8
|
+
private readonly handshakeTimeoutMs;
|
|
9
9
|
private responseId;
|
|
10
10
|
private timeoutId;
|
|
11
11
|
private resolvers;
|
|
12
12
|
private handshakeResolvers;
|
|
13
13
|
private messageChannel;
|
|
14
|
-
private windowListener;
|
|
15
|
-
|
|
14
|
+
private readonly windowListener;
|
|
15
|
+
private readonly performanceClient;
|
|
16
|
+
private readonly handshakeEvent;
|
|
17
|
+
constructor(logger: Logger, handshakeTimeoutMs: number, performanceClient: IPerformanceClient, extensionId?: string);
|
|
16
18
|
/**
|
|
17
19
|
* Sends a given message to the extension and resolves with the extension response
|
|
18
20
|
* @param body
|
|
@@ -20,10 +22,11 @@ export declare class NativeMessageHandler {
|
|
|
20
22
|
sendMessage(body: NativeExtensionRequestBody): Promise<object>;
|
|
21
23
|
/**
|
|
22
24
|
* Returns an instance of the MessageHandler that has successfully established a connection with an extension
|
|
23
|
-
* @param logger
|
|
24
|
-
* @param handshakeTimeoutMs
|
|
25
|
+
* @param {Logger} logger
|
|
26
|
+
* @param {number} handshakeTimeoutMs
|
|
27
|
+
* @param {IPerformanceClient} performanceClient
|
|
25
28
|
*/
|
|
26
|
-
static createProvider(logger: Logger, handshakeTimeoutMs: number): Promise<NativeMessageHandler>;
|
|
29
|
+
static createProvider(logger: Logger, handshakeTimeoutMs: number, performanceClient: IPerformanceClient): Promise<NativeMessageHandler>;
|
|
27
30
|
/**
|
|
28
31
|
* Send handshake request helper.
|
|
29
32
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeMessageHandler.d.ts","sourceRoot":"","sources":["../../../src/broker/nativeBroker/NativeMessageHandler.ts"],"names":[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;;;OAGG;IACH,cAAc,IAAI,MAAM,GAAG,SAAS;IAIpC;;;OAGG;IACH,mBAAmB,IAAI,MAAM,GAAG,SAAS;IAIzC;;;;;;OAMG;IACH,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,CAAC,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,OAAO;CA4B/K"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.34.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __awaiter, __generator } from '../../_virtual/_tslib.js';
|
|
4
4
|
import { NativeConstants, NativeExtensionMethod } from '../../utils/BrowserConstants.js';
|
|
5
|
-
import { AuthError, AuthenticationScheme } from '@azure/msal-common';
|
|
5
|
+
import { AuthError, AuthenticationScheme, PerformanceEvents } from '@azure/msal-common';
|
|
6
6
|
import { NativeAuthError } from '../../error/NativeAuthError.js';
|
|
7
7
|
import { BrowserAuthError } from '../../error/BrowserAuthError.js';
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ import { BrowserAuthError } from '../../error/BrowserAuthError.js';
|
|
|
11
11
|
* Licensed under the MIT License.
|
|
12
12
|
*/
|
|
13
13
|
var NativeMessageHandler = /** @class */ (function () {
|
|
14
|
-
function NativeMessageHandler(logger, handshakeTimeoutMs, extensionId) {
|
|
14
|
+
function NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, extensionId) {
|
|
15
15
|
this.logger = logger;
|
|
16
16
|
this.handshakeTimeoutMs = handshakeTimeoutMs;
|
|
17
17
|
this.extensionId = extensionId;
|
|
@@ -20,6 +20,8 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
20
20
|
this.responseId = 0;
|
|
21
21
|
this.messageChannel = new MessageChannel();
|
|
22
22
|
this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound
|
|
23
|
+
this.performanceClient = performanceClient;
|
|
24
|
+
this.handshakeEvent = performanceClient.startMeasurement(PerformanceEvents.NativeMessageHandlerHandshake);
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Sends a given message to the extension and resolves with the extension response
|
|
@@ -48,10 +50,11 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
48
50
|
};
|
|
49
51
|
/**
|
|
50
52
|
* Returns an instance of the MessageHandler that has successfully established a connection with an extension
|
|
51
|
-
* @param logger
|
|
52
|
-
* @param handshakeTimeoutMs
|
|
53
|
+
* @param {Logger} logger
|
|
54
|
+
* @param {number} handshakeTimeoutMs
|
|
55
|
+
* @param {IPerformanceClient} performanceClient
|
|
53
56
|
*/
|
|
54
|
-
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs) {
|
|
57
|
+
NativeMessageHandler.createProvider = function (logger, handshakeTimeoutMs, performanceClient) {
|
|
55
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
56
59
|
var preferredProvider, backupProvider;
|
|
57
60
|
return __generator(this, function (_a) {
|
|
@@ -61,14 +64,14 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
61
64
|
_a.label = 1;
|
|
62
65
|
case 1:
|
|
63
66
|
_a.trys.push([1, 3, , 5]);
|
|
64
|
-
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
67
|
+
preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, NativeConstants.PREFERRED_EXTENSION_ID);
|
|
65
68
|
return [4 /*yield*/, preferredProvider.sendHandshakeRequest()];
|
|
66
69
|
case 2:
|
|
67
70
|
_a.sent();
|
|
68
71
|
return [2 /*return*/, preferredProvider];
|
|
69
72
|
case 3:
|
|
70
73
|
_a.sent();
|
|
71
|
-
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs);
|
|
74
|
+
backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient);
|
|
72
75
|
return [4 /*yield*/, backupProvider.sendHandshakeRequest()];
|
|
73
76
|
case 4:
|
|
74
77
|
_a.sent();
|
|
@@ -97,6 +100,10 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
97
100
|
method: NativeExtensionMethod.HandshakeRequest
|
|
98
101
|
}
|
|
99
102
|
};
|
|
103
|
+
this.handshakeEvent.addStaticFields({
|
|
104
|
+
extensionId: this.extensionId,
|
|
105
|
+
extensionHandshakeTimeoutMs: this.handshakeTimeoutMs
|
|
106
|
+
});
|
|
100
107
|
this.messageChannel.port1.onmessage = function (event) {
|
|
101
108
|
_this.onChannelMessage(event);
|
|
102
109
|
};
|
|
@@ -111,6 +118,7 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
111
118
|
window.removeEventListener("message", _this.windowListener, false);
|
|
112
119
|
_this.messageChannel.port1.close();
|
|
113
120
|
_this.messageChannel.port2.close();
|
|
121
|
+
_this.handshakeEvent.endMeasurement({ extensionHandshakeTimedOut: true, success: false });
|
|
114
122
|
reject(BrowserAuthError.createNativeHandshakeTimeoutError());
|
|
115
123
|
_this.handshakeResolvers.delete(req.responseId);
|
|
116
124
|
}, _this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here
|
|
@@ -144,6 +152,7 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
144
152
|
window.removeEventListener("message", this.windowListener, false);
|
|
145
153
|
var handshakeResolver = this.handshakeResolvers.get(request.responseId);
|
|
146
154
|
if (handshakeResolver) {
|
|
155
|
+
this.handshakeEvent.endMeasurement({ success: false, extensionInstalled: false });
|
|
147
156
|
handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());
|
|
148
157
|
}
|
|
149
158
|
}
|
|
@@ -191,6 +200,7 @@ var NativeMessageHandler = /** @class */ (function () {
|
|
|
191
200
|
this.extensionId = request.extensionId;
|
|
192
201
|
this.extensionVersion = request.body.version;
|
|
193
202
|
this.logger.verbose("NativeMessageHandler - Received HandshakeResponse from extension: " + this.extensionId);
|
|
203
|
+
this.handshakeEvent.endMeasurement({ extensionInstalled: true, success: true });
|
|
194
204
|
handshakeResolver.resolve();
|
|
195
205
|
this.handshakeResolvers.delete(request.responseId);
|
|
196
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeMessageHandler.js","sources":["../../../src/broker/nativeBroker/NativeMessageHandler.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { NativeConstants, NativeExtensionMethod } from \"../../utils/BrowserConstants\";\nimport { Logger, AuthError, AuthenticationScheme } from \"@azure/msal-common\";\nimport { NativeExtensionRequest, NativeExtensionRequestBody } from \"./NativeRequest\";\nimport { NativeAuthError } from \"../../error/NativeAuthError\";\nimport { BrowserAuthError } from \"../../error/BrowserAuthError\";\nimport { BrowserConfiguration } from \"../../config/Configuration\";\n\ntype ResponseResolvers<T> = {\n resolve: (value:T|PromiseLike<T>) => void;\n reject: (value:AuthError|Error|PromiseLike<Error>|PromiseLike<AuthError>) => void;\n};\n\nexport class NativeMessageHandler {\n private extensionId: string | undefined;\n private extensionVersion: string | undefined;\n private logger: Logger;\n private handshakeTimeoutMs: number;\n private responseId: number;\n private timeoutId: number | undefined;\n private resolvers: Map<number, ResponseResolvers<object>>;\n private handshakeResolvers: Map<number, ResponseResolvers<void>>;\n private messageChannel: MessageChannel;\n private windowListener: (event: MessageEvent) => void;\n\n constructor(logger: Logger, handshakeTimeoutMs: number, extensionId?: string) {\n this.logger = logger;\n this.handshakeTimeoutMs = handshakeTimeoutMs;\n this.extensionId = extensionId;\n this.resolvers = new Map(); // Used for non-handshake messages\n this.handshakeResolvers = new Map(); // Used for handshake messages\n this.responseId = 0;\n this.messageChannel = new MessageChannel();\n this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound\n }\n\n /**\n * Sends a given message to the extension and resolves with the extension response\n * @param body \n */\n async sendMessage(body: NativeExtensionRequestBody): Promise<object> {\n this.logger.trace(\"NativeMessageHandler - sendMessage called.\");\n const req: NativeExtensionRequest = {\n channel: NativeConstants.CHANNEL_ID,\n extensionId: this.extensionId,\n responseId: this.responseId++,\n body: body\n };\n\n this.logger.trace(\"NativeMessageHandler - Sending request to browser extension\");\n this.logger.tracePii(`NativeMessageHandler - Sending request to browser extension: ${JSON.stringify(req)}`);\n this.messageChannel.port1.postMessage(req);\n\n return new Promise((resolve, reject) => {\n this.resolvers.set(req.responseId, {resolve, reject});\n });\n }\n\n /**\n * Returns an instance of the MessageHandler that has successfully established a connection with an extension\n * @param logger \n * @param handshakeTimeoutMs\n */\n static async createProvider(logger: Logger, handshakeTimeoutMs: number): Promise<NativeMessageHandler> {\n logger.trace(\"NativeMessageHandler - createProvider called.\");\n try {\n const preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, NativeConstants.PREFERRED_EXTENSION_ID);\n await preferredProvider.sendHandshakeRequest();\n return preferredProvider;\n } catch (e) {\n // If preferred extension fails for whatever reason, fallback to using any installed extension\n const backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs);\n await backupProvider.sendHandshakeRequest();\n return backupProvider;\n }\n }\n\n /**\n * Send handshake request helper.\n */\n private async sendHandshakeRequest(): Promise<void> {\n this.logger.trace(\"NativeMessageHandler - sendHandshakeRequest called.\");\n // Register this event listener before sending handshake\n window.addEventListener(\"message\", this.windowListener, false); // false is important, because content script message processing should work first\n\n const req: NativeExtensionRequest = {\n channel: NativeConstants.CHANNEL_ID,\n extensionId: this.extensionId,\n responseId: this.responseId++,\n\n body: {\n method: NativeExtensionMethod.HandshakeRequest\n }\n };\n\n this.messageChannel.port1.onmessage = (event) => {\n this.onChannelMessage(event);\n };\n\n window.postMessage(req, window.origin, [this.messageChannel.port2]);\n\n return new Promise((resolve, reject) => {\n this.handshakeResolvers.set(req.responseId, {resolve, reject});\n this.timeoutId = window.setTimeout(() => {\n /*\n * Throw an error if neither HandshakeResponse nor original Handshake request are received in a reasonable timeframe.\n * This typically suggests an event handler stopped propagation of the Handshake request but did not respond to it on the MessageChannel port\n */\n window.removeEventListener(\"message\", this.windowListener, false);\n this.messageChannel.port1.close();\n this.messageChannel.port2.close();\n reject(BrowserAuthError.createNativeHandshakeTimeoutError());\n this.handshakeResolvers.delete(req.responseId);\n }, this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here\n });\n }\n\n /**\n * Invoked when a message is posted to the window. If a handshake request is received it means the extension is not installed.\n * @param event \n */\n private onWindowMessage(event: MessageEvent): void {\n this.logger.trace(\"NativeMessageHandler - onWindowMessage called\");\n // We only accept messages from ourselves\n if (event.source !== window) {\n return;\n }\n\n const request = event.data;\n\n if (!request.channel || request.channel !== NativeConstants.CHANNEL_ID) {\n return;\n }\n\n if (request.extensionId && request.extensionId !== this.extensionId) {\n return;\n }\n\n if (request.body.method === NativeExtensionMethod.HandshakeRequest) {\n // If we receive this message back it means no extension intercepted the request, meaning no extension supporting handshake protocol is installed\n this.logger.verbose(request.extensionId ? `Extension with id: ${request.extensionId} not installed` : \"No extension installed\");\n clearTimeout(this.timeoutId);\n this.messageChannel.port1.close();\n this.messageChannel.port2.close();\n window.removeEventListener(\"message\", this.windowListener, false);\n const handshakeResolver = this.handshakeResolvers.get(request.responseId);\n if (handshakeResolver) {\n handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());\n }\n }\n }\n\n /**\n * Invoked when a message is received from the extension on the MessageChannel port\n * @param event \n */\n private onChannelMessage(event: MessageEvent): void {\n this.logger.trace(\"NativeMessageHandler - onChannelMessage called.\");\n const request = event.data;\n \n const resolver = this.resolvers.get(request.responseId);\n const handshakeResolver = this.handshakeResolvers.get(request.responseId);\n\n try {\n const method = request.body.method;\n \n if (method === NativeExtensionMethod.Response) {\n if (!resolver) {\n return;\n }\n const response = request.body.response;\n this.logger.trace(\"NativeMessageHandler - Received response from browser extension\");\n this.logger.tracePii(`NativeMessageHandler - Received response from browser extension: ${JSON.stringify(response)}`);\n if (response.status !== \"Success\") {\n resolver.reject(NativeAuthError.createError(response.code, response.description, response.ext));\n } else if (response.result) {\n if (response.result[\"code\"] && response.result[\"description\"]) {\n resolver.reject(NativeAuthError.createError(response.result[\"code\"], response.result[\"description\"], response.result[\"ext\"]));\n } else {\n resolver.resolve(response.result);\n }\n } else {\n throw AuthError.createUnexpectedError(\"Event does not contain result.\");\n }\n this.resolvers.delete(request.responseId);\n } else if (method === NativeExtensionMethod.HandshakeResponse) {\n if (!handshakeResolver) {\n return;\n }\n clearTimeout(this.timeoutId); // Clear setTimeout\n window.removeEventListener(\"message\", this.windowListener, false); // Remove 'No extension' listener\n this.extensionId = request.extensionId;\n this.extensionVersion = request.body.version;\n this.logger.verbose(`NativeMessageHandler - Received HandshakeResponse from extension: ${this.extensionId}`);\n\n handshakeResolver.resolve();\n this.handshakeResolvers.delete(request.responseId);\n } \n // Do nothing if method is not Response or HandshakeResponse\n } catch (err) {\n this.logger.error(\"Error parsing response from WAM Extension\");\n this.logger.errorPii(`Error parsing response from WAM Extension: ${err.toString()}`);\n this.logger.errorPii(`Unable to parse ${event}`);\n\n if (resolver) {\n resolver.reject(err as AuthError);\n } else if (handshakeResolver) {\n handshakeResolver.reject(err as AuthError);\n }\n }\n }\n\n /**\n * Returns the Id for the browser extension this handler is communicating with\n * @returns \n */\n getExtensionId(): string | undefined {\n return this.extensionId;\n }\n\n /**\n * Returns the version for the browser extension this handler is communicating with\n * @returns \n */\n getExtensionVersion(): string | undefined {\n return this.extensionVersion;\n }\n \n /**\n * Returns boolean indicating whether or not the request should attempt to use native broker\n * @param logger\n * @param config\n * @param nativeExtensionProvider\n * @param authenticationScheme \n */\n static isNativeAvailable(config: BrowserConfiguration, logger: Logger, nativeExtensionProvider?: NativeMessageHandler, authenticationScheme?: AuthenticationScheme): boolean {\n logger.trace(\"isNativeAvailable called\");\n if (!config.system.allowNativeBroker) {\n logger.trace(\"isNativeAvailable: allowNativeBroker is not enabled, returning false\");\n // Developer disabled WAM\n return false;\n }\n\n if (!nativeExtensionProvider) {\n logger.trace(\"isNativeAvailable: WAM extension provider is not initialized, returning false\");\n // Extension is not available\n return false;\n }\n\n if (authenticationScheme) {\n switch(authenticationScheme) {\n case AuthenticationScheme.BEARER:\n case AuthenticationScheme.POP:\n logger.trace(\"isNativeAvailable: authenticationScheme is supported, returning true\");\n return true;\n default:\n logger.trace(\"isNativeAvailable: authenticationScheme is not supported, returning false\");\n return false;\n }\n }\n\n return true;\n }\n} \n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IA6BI,8BAAY,MAAc,EAAE,kBAA0B,EAAE,WAAoB;QACxE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,IAAI,GAAG,EAAE,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACzD;;;;;IAMK,0CAAW,GAAjB,UAAkB,IAAgC;;;;;gBAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;gBAC1D,GAAG,GAA2B;oBAChC,OAAO,EAAE,eAAe,CAAC,UAAU;oBACnC,WAAW,EAAE,IAAI,CAAC,WAAW;oBAC7B,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE;oBAC7B,IAAI,EAAE,IAAI;iBACb,CAAC;gBAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;gBACjF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kEAAgE,IAAI,C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C,sEAAsE,CAAC,CAAC;;YAErF,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,CAAC,uBAAuB,EAAE;YAC1B,MAAM,CAAC,KAAK,CAAC,+EAA+E,CAAC,CAAC;;YAE9F,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,oBAAoB,EAAE;YACtB,QAAO,oBAAoB;gBACvB,KAAK,oBAAoB,CAAC,MAAM,CAAC;gBACjC,KAAK,oBAAoB,CAAC,GAAG;oBACzB,MAAM,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAC;oBACrF,OAAO,IAAI,CAAC;gBAChB;oBACI,MAAM,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;oBAC1F,OAAO,KAAK,CAAC;aACpB;SACJ;QAED,OAAO,IAAI,CAAC;KACf;IACL,2BAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"NativeMessageHandler.js","sources":["../../../src/broker/nativeBroker/NativeMessageHandler.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { NativeConstants, NativeExtensionMethod } from \"../../utils/BrowserConstants\";\nimport {\n Logger,\n AuthError,\n AuthenticationScheme,\n InProgressPerformanceEvent,\n PerformanceEvents,\n IPerformanceClient\n} from \"@azure/msal-common\";\nimport { NativeExtensionRequest, NativeExtensionRequestBody } from \"./NativeRequest\";\nimport { NativeAuthError } from \"../../error/NativeAuthError\";\nimport { BrowserAuthError } from \"../../error/BrowserAuthError\";\nimport { BrowserConfiguration } from \"../../config/Configuration\";\n\ntype ResponseResolvers<T> = {\n resolve: (value:T|PromiseLike<T>) => void;\n reject: (value:AuthError|Error|PromiseLike<Error>|PromiseLike<AuthError>) => void;\n};\n\nexport class NativeMessageHandler {\n private extensionId: string | undefined;\n private extensionVersion: string | undefined;\n private logger: Logger;\n private readonly handshakeTimeoutMs: number;\n private responseId: number;\n private timeoutId: number | undefined;\n private resolvers: Map<number, ResponseResolvers<object>>;\n private handshakeResolvers: Map<number, ResponseResolvers<void>>;\n private messageChannel: MessageChannel;\n private readonly windowListener: (event: MessageEvent) => void;\n private readonly performanceClient: IPerformanceClient;\n private readonly handshakeEvent: InProgressPerformanceEvent;\n\n constructor(logger: Logger, handshakeTimeoutMs: number, performanceClient: IPerformanceClient, extensionId?: string) {\n this.logger = logger;\n this.handshakeTimeoutMs = handshakeTimeoutMs;\n this.extensionId = extensionId;\n this.resolvers = new Map(); // Used for non-handshake messages\n this.handshakeResolvers = new Map(); // Used for handshake messages\n this.responseId = 0;\n this.messageChannel = new MessageChannel();\n this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound\n this.performanceClient = performanceClient;\n this.handshakeEvent = performanceClient.startMeasurement(PerformanceEvents.NativeMessageHandlerHandshake);\n }\n\n /**\n * Sends a given message to the extension and resolves with the extension response\n * @param body\n */\n async sendMessage(body: NativeExtensionRequestBody): Promise<object> {\n this.logger.trace(\"NativeMessageHandler - sendMessage called.\");\n const req: NativeExtensionRequest = {\n channel: NativeConstants.CHANNEL_ID,\n extensionId: this.extensionId,\n responseId: this.responseId++,\n body: body\n };\n\n this.logger.trace(\"NativeMessageHandler - Sending request to browser extension\");\n this.logger.tracePii(`NativeMessageHandler - Sending request to browser extension: ${JSON.stringify(req)}`);\n this.messageChannel.port1.postMessage(req);\n\n return new Promise((resolve, reject) => {\n this.resolvers.set(req.responseId, {resolve, reject});\n });\n }\n\n /**\n * Returns an instance of the MessageHandler that has successfully established a connection with an extension\n * @param {Logger} logger\n * @param {number} handshakeTimeoutMs\n * @param {IPerformanceClient} performanceClient\n */\n static async createProvider(logger: Logger, handshakeTimeoutMs: number, performanceClient: IPerformanceClient): Promise<NativeMessageHandler> {\n logger.trace(\"NativeMessageHandler - createProvider called.\");\n try {\n const preferredProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient, NativeConstants.PREFERRED_EXTENSION_ID);\n await preferredProvider.sendHandshakeRequest();\n return preferredProvider;\n } catch (e) {\n // If preferred extension fails for whatever reason, fallback to using any installed extension\n const backupProvider = new NativeMessageHandler(logger, handshakeTimeoutMs, performanceClient);\n await backupProvider.sendHandshakeRequest();\n return backupProvider;\n }\n }\n\n /**\n * Send handshake request helper.\n */\n private async sendHandshakeRequest(): Promise<void> {\n this.logger.trace(\"NativeMessageHandler - sendHandshakeRequest called.\");\n // Register this event listener before sending handshake\n window.addEventListener(\"message\", this.windowListener, false); // false is important, because content script message processing should work first\n\n const req: NativeExtensionRequest = {\n channel: NativeConstants.CHANNEL_ID,\n extensionId: this.extensionId,\n responseId: this.responseId++,\n body: {\n method: NativeExtensionMethod.HandshakeRequest\n }\n };\n this.handshakeEvent.addStaticFields({\n extensionId: this.extensionId,\n extensionHandshakeTimeoutMs: this.handshakeTimeoutMs\n });\n\n this.messageChannel.port1.onmessage = (event) => {\n this.onChannelMessage(event);\n };\n\n window.postMessage(req, window.origin, [this.messageChannel.port2]);\n\n return new Promise((resolve, reject) => {\n this.handshakeResolvers.set(req.responseId, {resolve, reject});\n this.timeoutId = window.setTimeout(() => {\n /*\n * Throw an error if neither HandshakeResponse nor original Handshake request are received in a reasonable timeframe.\n * This typically suggests an event handler stopped propagation of the Handshake request but did not respond to it on the MessageChannel port\n */\n window.removeEventListener(\"message\", this.windowListener, false);\n this.messageChannel.port1.close();\n this.messageChannel.port2.close();\n this.handshakeEvent.endMeasurement({extensionHandshakeTimedOut: true, success: false});\n reject(BrowserAuthError.createNativeHandshakeTimeoutError());\n this.handshakeResolvers.delete(req.responseId);\n }, this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here\n });\n }\n\n /**\n * Invoked when a message is posted to the window. If a handshake request is received it means the extension is not installed.\n * @param event\n */\n private onWindowMessage(event: MessageEvent): void {\n this.logger.trace(\"NativeMessageHandler - onWindowMessage called\");\n // We only accept messages from ourselves\n if (event.source !== window) {\n return;\n }\n\n const request = event.data;\n\n if (!request.channel || request.channel !== NativeConstants.CHANNEL_ID) {\n return;\n }\n\n if (request.extensionId && request.extensionId !== this.extensionId) {\n return;\n }\n\n if (request.body.method === NativeExtensionMethod.HandshakeRequest) {\n // If we receive this message back it means no extension intercepted the request, meaning no extension supporting handshake protocol is installed\n this.logger.verbose(request.extensionId ? `Extension with id: ${request.extensionId} not installed` : \"No extension installed\");\n clearTimeout(this.timeoutId);\n this.messageChannel.port1.close();\n this.messageChannel.port2.close();\n window.removeEventListener(\"message\", this.windowListener, false);\n const handshakeResolver = this.handshakeResolvers.get(request.responseId);\n if (handshakeResolver) {\n this.handshakeEvent.endMeasurement({success: false, extensionInstalled: false});\n handshakeResolver.reject(BrowserAuthError.createNativeExtensionNotInstalledError());\n }\n }\n }\n\n /**\n * Invoked when a message is received from the extension on the MessageChannel port\n * @param event\n */\n private onChannelMessage(event: MessageEvent): void {\n this.logger.trace(\"NativeMessageHandler - onChannelMessage called.\");\n const request = event.data;\n\n const resolver = this.resolvers.get(request.responseId);\n const handshakeResolver = this.handshakeResolvers.get(request.responseId);\n\n try {\n const method = request.body.method;\n\n if (method === NativeExtensionMethod.Response) {\n if (!resolver) {\n return;\n }\n const response = request.body.response;\n this.logger.trace(\"NativeMessageHandler - Received response from browser extension\");\n this.logger.tracePii(`NativeMessageHandler - Received response from browser extension: ${JSON.stringify(response)}`);\n if (response.status !== \"Success\") {\n resolver.reject(NativeAuthError.createError(response.code, response.description, response.ext));\n } else if (response.result) {\n if (response.result[\"code\"] && response.result[\"description\"]) {\n resolver.reject(NativeAuthError.createError(response.result[\"code\"], response.result[\"description\"], response.result[\"ext\"]));\n } else {\n resolver.resolve(response.result);\n }\n } else {\n throw AuthError.createUnexpectedError(\"Event does not contain result.\");\n }\n this.resolvers.delete(request.responseId);\n } else if (method === NativeExtensionMethod.HandshakeResponse) {\n if (!handshakeResolver) {\n return;\n }\n clearTimeout(this.timeoutId); // Clear setTimeout\n window.removeEventListener(\"message\", this.windowListener, false); // Remove 'No extension' listener\n this.extensionId = request.extensionId;\n this.extensionVersion = request.body.version;\n this.logger.verbose(`NativeMessageHandler - Received HandshakeResponse from extension: ${this.extensionId}`);\n this.handshakeEvent.endMeasurement({extensionInstalled: true, success: true});\n\n handshakeResolver.resolve();\n this.handshakeResolvers.delete(request.responseId);\n }\n // Do nothing if method is not Response or HandshakeResponse\n } catch (err) {\n this.logger.error(\"Error parsing response from WAM Extension\");\n this.logger.errorPii(`Error parsing response from WAM Extension: ${err.toString()}`);\n this.logger.errorPii(`Unable to parse ${event}`);\n\n if (resolver) {\n resolver.reject(err as AuthError);\n } else if (handshakeResolver) {\n handshakeResolver.reject(err as AuthError);\n }\n }\n }\n\n /**\n * Returns the Id for the browser extension this handler is communicating with\n * @returns\n */\n getExtensionId(): string | undefined {\n return this.extensionId;\n }\n\n /**\n * Returns the version for the browser extension this handler is communicating with\n * @returns\n */\n getExtensionVersion(): string | undefined {\n return this.extensionVersion;\n }\n\n /**\n * Returns boolean indicating whether or not the request should attempt to use native broker\n * @param logger\n * @param config\n * @param nativeExtensionProvider\n * @param authenticationScheme\n */\n static isNativeAvailable(config: BrowserConfiguration, logger: Logger, nativeExtensionProvider?: NativeMessageHandler, authenticationScheme?: AuthenticationScheme): boolean {\n logger.trace(\"isNativeAvailable called\");\n if (!config.system.allowNativeBroker) {\n logger.trace(\"isNativeAvailable: allowNativeBroker is not enabled, returning false\");\n // Developer disabled WAM\n return false;\n }\n\n if (!nativeExtensionProvider) {\n logger.trace(\"isNativeAvailable: WAM extension provider is not initialized, returning false\");\n // Extension is not available\n return false;\n }\n\n if (authenticationScheme) {\n switch(authenticationScheme) {\n case AuthenticationScheme.BEARER:\n case AuthenticationScheme.POP:\n logger.trace(\"isNativeAvailable: authenticationScheme is supported, returning true\");\n return true;\n default:\n logger.trace(\"isNativeAvailable: authenticationScheme is not supported, returning false\");\n return false;\n }\n }\n\n return true;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IAsCI,8BAAY,MAAc,EAAE,kBAA0B,EAAE,iBAAqC,EAAE,WAAoB;QAC/G,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AmB,GAAnB;QACI,OAAO,IAAI,CAAC,gBAAgB,CAAC;KAChC;;;;;;;;IASM,sCAAiB,GAAxB,UAAyB,MAA4B,EAAE,MAAc,EAAE,uBAA8C,EAAE,oBAA2C;QAC9J,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE;YAClC,MAAM,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAC;;YAErF,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,CAAC,uBAAuB,EAAE;YAC1B,MAAM,CAAC,KAAK,CAAC,+EAA+E,CAAC,CAAC;;YAE9F,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,oBAAoB,EAAE;YACtB,QAAO,oBAAoB;gBACvB,KAAK,oBAAoB,CAAC,MAAM,CAAC;gBACjC,KAAK,oBAAoB,CAAC,GAAG;oBACzB,MAAM,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAC;oBACrF,OAAO,IAAI,CAAC;gBAChB;oBACI,MAAM,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;oBAC1F,OAAO,KAAK,CAAC;aACpB;SACJ;QAED,OAAO,IAAI,CAAC;KACf;IACL,2BAAC;AAAD,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.34.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __spread, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
4
|
import { AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, Constants, PersistentCacheKeys, ClientAuthError, ThrottlingEntity, StringUtils, ProtocolUtils, CcsCredentialType, IdToken, DEFAULT_CRYPTO_IMPLEMENTATION } from '@azure/msal-common';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.34.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { BrowserConfigurationAuthError } from '../error/BrowserConfigurationAuthError.js';
|
|
4
4
|
import { BrowserCacheLocation } from '../utils/BrowserConstants.js';
|
package/dist/cache/TokenCache.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.34.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { AuthToken, CacheRecord, Authority, AccountEntity, IdTokenEntity, ScopeSet, AccessTokenEntity, RefreshTokenEntity, Constants } from '@azure/msal-common';
|
|
4
4
|
import { BrowserAuthError } from '../error/BrowserAuthError.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.34.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { DEFAULT_SYSTEM_OPTIONS, StubbedNetworkModule, Constants, ProtocolMode, AzureCloudInstance, LogLevel } from '@azure/msal-common';
|
package/dist/crypto/CryptoOps.js
CHANGED
|
@@ -151,6 +151,10 @@ export declare const BrowserAuthErrorMessage: {
|
|
|
151
151
|
code: string;
|
|
152
152
|
desc: string;
|
|
153
153
|
};
|
|
154
|
+
spaCodeAndNativeAccountPresent: {
|
|
155
|
+
code: string;
|
|
156
|
+
desc: string;
|
|
157
|
+
};
|
|
154
158
|
databaseUnavailable: {
|
|
155
159
|
code: string;
|
|
156
160
|
desc: string;
|
|
@@ -341,6 +345,10 @@ export declare class BrowserAuthError extends AuthError {
|
|
|
341
345
|
* Create an error when an authorization code or native account ID is required but not provided
|
|
342
346
|
*/
|
|
343
347
|
static createAuthCodeOrNativeAccountIdRequiredError(): BrowserAuthError;
|
|
348
|
+
/**
|
|
349
|
+
* Create an error when both authorization code and native account ID are provided
|
|
350
|
+
*/
|
|
351
|
+
static createSpaCodeAndNativeAccountIdPresentError(): BrowserAuthError;
|
|
344
352
|
/**
|
|
345
353
|
* Create an error when IndexedDB is unavailable
|
|
346
354
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserAuthError.d.ts","sourceRoot":"","sources":["../../src/error/BrowserAuthError.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAe,MAAM,oBAAoB,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"BrowserAuthError.d.ts","sourceRoot":"","sources":["../../src/error/BrowserAuthError.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAe,MAAM,oBAAoB,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqLnC,CAAC;AAEF;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBAE/B,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;IAOpD;;;OAGG;IACH,MAAM,CAAC,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB;IAKvE;;;OAGG;IACH,MAAM,CAAC,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB;IAKzE;;;OAGG;IACH,MAAM,CAAC,mCAAmC,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB;IAK5E;;OAEG;IACH,MAAM,CAAC,6BAA6B,IAAI,gBAAgB;IAIxD;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAC,SAAS,EAAE,MA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1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.34.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends } from '../_virtual/_tslib.js';
|
|
4
4
|
import { StringUtils, AuthError } from '@azure/msal-common';
|
|
@@ -159,6 +159,10 @@ var BrowserAuthErrorMessage = {
|
|
|
159
159
|
code: "auth_code_or_nativeAccountId_required",
|
|
160
160
|
desc: "An authorization code or nativeAccountId must be provided to this flow."
|
|
161
161
|
},
|
|
162
|
+
spaCodeAndNativeAccountPresent: {
|
|
163
|
+
code: "spa_code_and_nativeAccountId_present",
|
|
164
|
+
desc: "Request cannot contain both spa code and native account id."
|
|
165
|
+
},
|
|
162
166
|
databaseUnavailable: {
|
|
163
167
|
code: "database_unavailable",
|
|
164
168
|
desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
|
|
@@ -431,6 +435,12 @@ var BrowserAuthError = /** @class */ (function (_super) {
|
|
|
431
435
|
BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError = function () {
|
|
432
436
|
return new BrowserAuthError(BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.code, BrowserAuthErrorMessage.authCodeOrNativeAccountRequired.desc);
|
|
433
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Create an error when both authorization code and native account ID are provided
|
|
440
|
+
*/
|
|
441
|
+
BrowserAuthError.createSpaCodeAndNativeAccountIdPresentError = function () {
|
|
442
|
+
return new BrowserAuthError(BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.code, BrowserAuthErrorMessage.spaCodeAndNativeAccountPresent.desc);
|
|
443
|
+
};
|
|
434
444
|
/**
|
|
435
445
|
* Create an error when IndexedDB is unavailable
|
|
436
446
|
*/
|