@azure/msal-browser 2.16.1 → 2.20.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/CHANGELOG.json +283 -0
- package/{changelog.md → CHANGELOG.md} +73 -1
- package/README.md +12 -4
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.d.ts +35 -137
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +178 -883
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.d.ts +8 -0
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.js +16 -1
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +35 -41
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/cache/AsyncMemoryStorage.d.ts +46 -0
- package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -0
- package/dist/cache/AsyncMemoryStorage.js +195 -0
- package/dist/cache/AsyncMemoryStorage.js.map +1 -0
- package/dist/cache/BrowserCacheManager.d.ts +19 -2
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +104 -15
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.d.ts +1 -1
- package/dist/cache/BrowserStorage.d.ts.map +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/BrowserStorage.js.map +1 -1
- package/dist/cache/DatabaseStorage.d.ts +29 -4
- package/dist/cache/DatabaseStorage.d.ts.map +1 -1
- package/dist/cache/DatabaseStorage.js +151 -45
- package/dist/cache/DatabaseStorage.js.map +1 -1
- package/dist/cache/IAsyncMemoryStorage.d.ts +28 -0
- package/dist/cache/IAsyncMemoryStorage.d.ts.map +1 -0
- package/dist/cache/ITokenCache.d.ts +8 -0
- package/dist/cache/ITokenCache.d.ts.map +1 -0
- package/dist/cache/IWindowStorage.d.ts +3 -3
- package/dist/cache/IWindowStorage.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.d.ts +3 -3
- package/dist/cache/MemoryStorage.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/MemoryStorage.js.map +1 -1
- package/dist/cache/TokenCache.d.ts +48 -0
- package/dist/cache/TokenCache.d.ts.map +1 -0
- package/dist/cache/TokenCache.js +124 -0
- package/dist/cache/TokenCache.js.map +1 -0
- package/dist/config/Configuration.js +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +3 -1
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.js +3 -2
- package/dist/crypto/BrowserCrypto.js.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +21 -6
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.js +67 -15
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +31 -0
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -0
- package/dist/crypto/SignedHttpRequest.js +70 -0
- package/dist/crypto/SignedHttpRequest.js.map +1 -0
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/error/BrowserAuthError.d.ts +36 -4
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +51 -11
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/event/EventHandler.d.ts +13 -0
- package/dist/event/EventHandler.d.ts.map +1 -1
- package/dist/event/EventHandler.js +66 -1
- package/dist/event/EventHandler.js.map +1 -1
- package/dist/event/EventMessage.d.ts +4 -3
- package/dist/event/EventMessage.d.ts.map +1 -1
- package/dist/event/EventMessage.js +24 -5
- package/dist/event/EventMessage.js.map +1 -1
- package/dist/event/EventType.d.ts +5 -0
- package/dist/event/EventType.d.ts.map +1 -1
- package/dist/event/EventType.js +6 -1
- package/dist/event/EventType.js.map +1 -1
- package/dist/index.cjs.js +4678 -2996
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts +42 -0
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -0
- package/dist/interaction_client/BaseInteractionClient.js +131 -0
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -0
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts +5 -0
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts.map +1 -0
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +21 -0
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js.map +1 -0
- package/dist/interaction_client/PopupClient.d.ts +37 -0
- package/dist/interaction_client/PopupClient.d.ts.map +1 -0
- package/dist/interaction_client/PopupClient.js +234 -0
- package/dist/interaction_client/PopupClient.js.map +1 -0
- package/dist/interaction_client/RedirectClient.d.ts +42 -0
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -0
- package/dist/interaction_client/RedirectClient.js +301 -0
- package/dist/interaction_client/RedirectClient.js.map +1 -0
- package/dist/interaction_client/SilentAuthCodeClient.d.ts +22 -0
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -0
- package/dist/interaction_client/SilentAuthCodeClient.js +80 -0
- package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -0
- package/dist/interaction_client/SilentCacheClient.d.ts +22 -0
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -0
- package/dist/interaction_client/SilentCacheClient.js +85 -0
- package/dist/interaction_client/SilentCacheClient.js.map +1 -0
- package/dist/interaction_client/SilentIframeClient.d.ts +29 -0
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -0
- package/dist/interaction_client/SilentIframeClient.js +107 -0
- package/dist/interaction_client/SilentIframeClient.js.map +1 -0
- package/dist/interaction_client/SilentRefreshClient.d.ts +20 -0
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -0
- package/dist/interaction_client/SilentRefreshClient.js +76 -0
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -0
- package/dist/interaction_client/StandardInteractionClient.d.ts +66 -0
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -0
- package/dist/interaction_client/StandardInteractionClient.js +249 -0
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -0
- package/dist/interaction_handler/InteractionHandler.d.ts +11 -2
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +36 -10
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/PopupHandler.d.ts +2 -0
- package/dist/interaction_handler/PopupHandler.d.ts.map +1 -1
- package/dist/interaction_handler/PopupHandler.js +3 -4
- package/dist/interaction_handler/PopupHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +7 -6
- package/dist/interaction_handler/RedirectHandler.js.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +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/AuthorizationCodeRequest.d.ts +8 -0
- package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -0
- package/dist/request/EndSessionPopupRequest.d.ts +3 -0
- package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
- package/dist/request/PopupRequest.d.ts +3 -0
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.d.ts +13 -1
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.js +17 -3
- package/dist/utils/BrowserConstants.js.map +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/dist/utils/PopupUtils.d.ts +26 -2
- package/dist/utils/PopupUtils.d.ts.map +1 -1
- package/dist/utils/PopupUtils.js +42 -15
- package/dist/utils/PopupUtils.js.map +1 -1
- package/lib/msal-browser.js +4678 -2996
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +32 -32
- package/package.json +9 -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, CommonSilentFlowRequest, RequestThumbprint } from \"@azure/msal-common\";\nimport { Configuration } from \"../config/Configuration\";\nimport { DEFAULT_REQUEST, ApiId, InteractionType } 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 { version, name } from \"../packageMetadata\";\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 this.logger.verbose(\"loginRedirect called\");\n return this.acquireTokenRedirect(request || DEFAULT_REQUEST);\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 this.logger.verbose(\"loginPopup called\");\n return this.acquireTokenPopup(request || DEFAULT_REQUEST);\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 this.preflightBrowserEnvironmentCheck(InteractionType.Silent);\n this.logger.verbose(\"acquireTokenSilent called\", request.correlationId);\n const account = request.account || this.getActiveAccount();\n if (!account) {\n throw BrowserAuthError.createNoAccountError();\n }\n const thumbprint: RequestThumbprint = {\n clientId: this.config.auth.clientId,\n authority: request.authority || \"\",\n scopes: request.scopes,\n homeAccountIdentifier: account.homeAccountId\n };\n const silentRequestKey = JSON.stringify(thumbprint);\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\", request.correlationId);\n const response = this.acquireTokenSilentAsync(request, account)\n .then((result) => {\n this.activeSilentTokenRequests.delete(silentRequestKey);\n return result;\n })\n .catch((error) => {\n this.activeSilentTokenRequests.delete(silentRequestKey);\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\", request.correlationId);\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 private async acquireTokenSilentAsync(request: SilentRequest, account: AccountInfo): Promise<AuthenticationResult>{\n const silentRequest: CommonSilentFlowRequest = {\n ...request,\n ...this.initializeBaseRequest(request),\n account: account,\n forceRefresh: request.forceRefresh || false\n };\n const browserRequestLogger = this.logger.clone(name, version, silentRequest.correlationId);\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, InteractionType.Silent, request);\n try {\n // Telemetry manager only used to increment cacheHits here\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow, silentRequest.correlationId);\n const silentAuthClient = await this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.correlationId);\n browserRequestLogger.verbose(\"Silent auth client created\");\n const cachedToken = await silentAuthClient.acquireCachedToken(silentRequest);\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, cachedToken);\n return cachedToken;\n } catch (e) {\n try {\n const tokenRenewalResult = await this.acquireTokenByRefreshToken(silentRequest);\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, tokenRenewalResult);\n return tokenRenewalResult;\n } catch (tokenRenewalError) {\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Silent, null, tokenRenewalError);\n throw tokenRenewalError;\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;AAiBA;;;;;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;;;gBACzC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;gBAC5C,sBAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,IAAI,eAAe,CAAC,EAAC;;;KAChE;;;;;;;;IASD,4CAAU,GAAV,UAAW,OAAsB;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,C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,MAAM,EAAE,WAAW,CAAC,CAAC;wBAClG,sBAAO,WAAW,EAAC;;;;;;wBAGY,qBAAM,IAAI,CAAC,0BAA0B,CAAC,aAAa,CAAC,EAAA;;wBAAzE,kBAAkB,GAAG,SAAoD;wBAC/E,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,qBAAqB,EAAE,eAAe,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;wBACzG,sBAAO,kBAAkB,EAAC;;;wBAE1B,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,qBAAqB,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,mBAAiB,CAAC,CAAC;wBAC9G,MAAM,mBAAiB,CAAC;;;;;;KAGnC;IACL,8BAAC;AAAD,CApIA,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, RequestThumbprint } from \"@azure/msal-common\";\nimport { Configuration } from \"../config/Configuration\";\nimport { DEFAULT_REQUEST, InteractionType } 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 { SilentCacheClient } from \"../interaction_client/SilentCacheClient\";\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 this.logger.verbose(\"loginRedirect called\");\n return this.acquireTokenRedirect(request || DEFAULT_REQUEST);\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 this.logger.verbose(\"loginPopup called\");\n return this.acquireTokenPopup(request || DEFAULT_REQUEST);\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 this.preflightBrowserEnvironmentCheck(InteractionType.Silent);\n this.logger.verbose(\"acquireTokenSilent called\", request.correlationId);\n const account = request.account || this.getActiveAccount();\n if (!account) {\n throw BrowserAuthError.createNoAccountError();\n }\n const thumbprint: RequestThumbprint = {\n clientId: this.config.auth.clientId,\n authority: request.authority || \"\",\n scopes: request.scopes,\n homeAccountIdentifier: account.homeAccountId,\n authenticationScheme: request.authenticationScheme,\n resourceRequestMethod: request.resourceRequestMethod,\n resourceRequestUri: request.resourceRequestUri,\n shrClaims: request.shrClaims,\n sshJwk: request.sshJwk,\n sshKid: request.sshKid\n };\n const silentRequestKey = JSON.stringify(thumbprint);\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\", request.correlationId);\n const response = this.acquireTokenSilentAsync(request, account)\n .then((result) => {\n this.activeSilentTokenRequests.delete(silentRequestKey);\n return result;\n })\n .catch((error) => {\n this.activeSilentTokenRequests.delete(silentRequestKey);\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\", request.correlationId);\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 private async acquireTokenSilentAsync(request: SilentRequest, account: AccountInfo): Promise<AuthenticationResult>{\n const silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);\n const silentRequest = silentCacheClient.initializeSilentRequest(request, account);\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, InteractionType.Silent, request);\n\n return silentCacheClient.acquireToken(silentRequest).catch(async () => {\n try {\n const tokenRenewalResult = await this.acquireTokenByRefreshToken(silentRequest);\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, tokenRenewalResult);\n return tokenRenewalResult;\n } catch (tokenRenewalError) {\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Silent, null, tokenRenewalError);\n throw tokenRenewalError;\n }\n });\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;AAiBA;;;;;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;;;gBACzC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;gBAC5C,sBAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,IAAI,eAAe,CAAC,EAAC;;;KAChE;;;;;;;;IASD,4CAAU,GAAV,UAAW,OAAsB;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,IAAI,eAAe,CAAC,CAAC;KAC7D;;;;;;;IAQK,oDAAkB,GAAxB,UAAyB,OAAsB;;;;;gBAC3C,IAAI,CAAC,gCAAgC,CAAC,eAAe,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AE,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,mBAAiB,CAAC,CAAC;oCAC9G,MAAM,mBAAiB,CAAC;;;;yBAE/B,CAAC,EAAC;;;KACN;IACL,8BAAC;AAAD,CA9HA,CAA6C,iBAAiB;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Logger } from "@azure/msal-common";
|
|
2
|
+
import { IAsyncStorage } from "./IAsyncMemoryStorage";
|
|
3
|
+
/**
|
|
4
|
+
* This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper,
|
|
5
|
+
* backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AsyncMemoryStorage<T> implements IAsyncStorage<T> {
|
|
8
|
+
private inMemoryCache;
|
|
9
|
+
private indexedDBCache;
|
|
10
|
+
private logger;
|
|
11
|
+
constructor(logger: Logger);
|
|
12
|
+
private handleDatabaseAccessError;
|
|
13
|
+
/**
|
|
14
|
+
* Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
|
|
15
|
+
* storage object if item isn't found in-memory.
|
|
16
|
+
* @param key
|
|
17
|
+
*/
|
|
18
|
+
getItem(key: string): Promise<T | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Sets the item in the in-memory cache and then tries to set it in the asynchronous
|
|
21
|
+
* storage object with the given key.
|
|
22
|
+
* @param key
|
|
23
|
+
* @param value
|
|
24
|
+
*/
|
|
25
|
+
setItem(key: string, value: T): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.
|
|
28
|
+
* @param key
|
|
29
|
+
*/
|
|
30
|
+
removeItem(key: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Get all the keys from the in-memory cache as an iterable array of strings. If no keys are found, query the keys in the
|
|
33
|
+
* asynchronous storage object.
|
|
34
|
+
*/
|
|
35
|
+
getKeys(): Promise<string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns true or false if the given key is present in the cache.
|
|
38
|
+
* @param key
|
|
39
|
+
*/
|
|
40
|
+
containsKey(key: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Clears in-memory Map and tries to delete the IndexedDB database.
|
|
43
|
+
*/
|
|
44
|
+
clear(): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=AsyncMemoryStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncMemoryStorage.d.ts","sourceRoot":"","sources":["../../src/cache/AsyncMemoryStorage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD;;;GAGG;AACH,qBAAa,kBAAkB,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAM1B,OAAO,CAAC,yBAAyB;IAKjC;;;;OAIG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAa7C;;;;;OAKG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASnD;;;OAGG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5C;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAalC;;;OAGG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAahD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ/B"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/*! @azure/msal-browser v2.20.0 2021-12-07 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { BrowserAuthError, BrowserAuthErrorMessage } from '../error/BrowserAuthError.js';
|
|
5
|
+
import { DatabaseStorage } from './DatabaseStorage.js';
|
|
6
|
+
import { MemoryStorage } from './MemoryStorage.js';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10
|
+
* Licensed under the MIT License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper,
|
|
14
|
+
* backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
|
|
15
|
+
*/
|
|
16
|
+
var AsyncMemoryStorage = /** @class */ (function () {
|
|
17
|
+
function AsyncMemoryStorage(logger) {
|
|
18
|
+
this.inMemoryCache = new MemoryStorage();
|
|
19
|
+
this.indexedDBCache = new DatabaseStorage();
|
|
20
|
+
this.logger = logger;
|
|
21
|
+
}
|
|
22
|
+
AsyncMemoryStorage.prototype.handleDatabaseAccessError = function (error) {
|
|
23
|
+
if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {
|
|
24
|
+
this.logger.error("Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.");
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
|
|
29
|
+
* storage object if item isn't found in-memory.
|
|
30
|
+
* @param key
|
|
31
|
+
*/
|
|
32
|
+
AsyncMemoryStorage.prototype.getItem = function (key) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
34
|
+
var item, e_1;
|
|
35
|
+
return __generator(this, function (_a) {
|
|
36
|
+
switch (_a.label) {
|
|
37
|
+
case 0:
|
|
38
|
+
item = this.inMemoryCache.getItem(key);
|
|
39
|
+
if (!!item) return [3 /*break*/, 4];
|
|
40
|
+
_a.label = 1;
|
|
41
|
+
case 1:
|
|
42
|
+
_a.trys.push([1, 3, , 4]);
|
|
43
|
+
this.logger.verbose("Queried item not found in in-memory cache, now querying persistent storage.");
|
|
44
|
+
return [4 /*yield*/, this.indexedDBCache.getItem(key)];
|
|
45
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
46
|
+
case 3:
|
|
47
|
+
e_1 = _a.sent();
|
|
48
|
+
this.handleDatabaseAccessError(e_1);
|
|
49
|
+
return [3 /*break*/, 4];
|
|
50
|
+
case 4: return [2 /*return*/, item];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Sets the item in the in-memory cache and then tries to set it in the asynchronous
|
|
57
|
+
* storage object with the given key.
|
|
58
|
+
* @param key
|
|
59
|
+
* @param value
|
|
60
|
+
*/
|
|
61
|
+
AsyncMemoryStorage.prototype.setItem = function (key, value) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var e_2;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
this.inMemoryCache.setItem(key, value);
|
|
68
|
+
_a.label = 1;
|
|
69
|
+
case 1:
|
|
70
|
+
_a.trys.push([1, 3, , 4]);
|
|
71
|
+
return [4 /*yield*/, this.indexedDBCache.setItem(key, value)];
|
|
72
|
+
case 2:
|
|
73
|
+
_a.sent();
|
|
74
|
+
return [3 /*break*/, 4];
|
|
75
|
+
case 3:
|
|
76
|
+
e_2 = _a.sent();
|
|
77
|
+
this.handleDatabaseAccessError(e_2);
|
|
78
|
+
return [3 /*break*/, 4];
|
|
79
|
+
case 4: return [2 /*return*/];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.
|
|
86
|
+
* @param key
|
|
87
|
+
*/
|
|
88
|
+
AsyncMemoryStorage.prototype.removeItem = function (key) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var e_3;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
this.inMemoryCache.removeItem(key);
|
|
95
|
+
_a.label = 1;
|
|
96
|
+
case 1:
|
|
97
|
+
_a.trys.push([1, 3, , 4]);
|
|
98
|
+
return [4 /*yield*/, this.indexedDBCache.removeItem(key)];
|
|
99
|
+
case 2:
|
|
100
|
+
_a.sent();
|
|
101
|
+
return [3 /*break*/, 4];
|
|
102
|
+
case 3:
|
|
103
|
+
e_3 = _a.sent();
|
|
104
|
+
this.handleDatabaseAccessError(e_3);
|
|
105
|
+
return [3 /*break*/, 4];
|
|
106
|
+
case 4: return [2 /*return*/];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Get all the keys from the in-memory cache as an iterable array of strings. If no keys are found, query the keys in the
|
|
113
|
+
* asynchronous storage object.
|
|
114
|
+
*/
|
|
115
|
+
AsyncMemoryStorage.prototype.getKeys = function () {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
+
var cacheKeys, e_4;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
cacheKeys = this.inMemoryCache.getKeys();
|
|
122
|
+
if (!(cacheKeys.length === 0)) return [3 /*break*/, 4];
|
|
123
|
+
_a.label = 1;
|
|
124
|
+
case 1:
|
|
125
|
+
_a.trys.push([1, 3, , 4]);
|
|
126
|
+
this.logger.verbose("In-memory cache is empty, now querying persistent storage.");
|
|
127
|
+
return [4 /*yield*/, this.indexedDBCache.getKeys()];
|
|
128
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
129
|
+
case 3:
|
|
130
|
+
e_4 = _a.sent();
|
|
131
|
+
this.handleDatabaseAccessError(e_4);
|
|
132
|
+
return [3 /*break*/, 4];
|
|
133
|
+
case 4: return [2 /*return*/, cacheKeys];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Returns true or false if the given key is present in the cache.
|
|
140
|
+
* @param key
|
|
141
|
+
*/
|
|
142
|
+
AsyncMemoryStorage.prototype.containsKey = function (key) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
var containsKey, e_5;
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0:
|
|
148
|
+
containsKey = this.inMemoryCache.containsKey(key);
|
|
149
|
+
if (!!containsKey) return [3 /*break*/, 4];
|
|
150
|
+
_a.label = 1;
|
|
151
|
+
case 1:
|
|
152
|
+
_a.trys.push([1, 3, , 4]);
|
|
153
|
+
this.logger.verbose("Key not found in in-memory cache, now querying persistent storage.");
|
|
154
|
+
return [4 /*yield*/, this.indexedDBCache.containsKey(key)];
|
|
155
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
156
|
+
case 3:
|
|
157
|
+
e_5 = _a.sent();
|
|
158
|
+
this.handleDatabaseAccessError(e_5);
|
|
159
|
+
return [3 /*break*/, 4];
|
|
160
|
+
case 4: return [2 /*return*/, containsKey];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Clears in-memory Map and tries to delete the IndexedDB database.
|
|
167
|
+
*/
|
|
168
|
+
AsyncMemoryStorage.prototype.clear = function () {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
var e_6;
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
switch (_a.label) {
|
|
173
|
+
case 0:
|
|
174
|
+
this.inMemoryCache.clear();
|
|
175
|
+
_a.label = 1;
|
|
176
|
+
case 1:
|
|
177
|
+
_a.trys.push([1, 3, , 4]);
|
|
178
|
+
return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
|
|
179
|
+
case 2:
|
|
180
|
+
_a.sent();
|
|
181
|
+
return [3 /*break*/, 4];
|
|
182
|
+
case 3:
|
|
183
|
+
e_6 = _a.sent();
|
|
184
|
+
this.handleDatabaseAccessError(e_6);
|
|
185
|
+
return [3 /*break*/, 4];
|
|
186
|
+
case 4: return [2 /*return*/];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
return AsyncMemoryStorage;
|
|
192
|
+
}());
|
|
193
|
+
|
|
194
|
+
export { AsyncMemoryStorage };
|
|
195
|
+
//# sourceMappingURL=AsyncMemoryStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncMemoryStorage.js","sources":["../../src/cache/AsyncMemoryStorage.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Logger } from \"@azure/msal-common\";\nimport { BrowserAuthError, BrowserAuthErrorMessage } from \"../error/BrowserAuthError\";\nimport { DatabaseStorage } from \"./DatabaseStorage\";\nimport { IAsyncStorage } from \"./IAsyncMemoryStorage\";\nimport { MemoryStorage } from \"./MemoryStorage\";\n\n/**\n * This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper,\n * backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.\n */\nexport class AsyncMemoryStorage<T> implements IAsyncStorage<T> {\n private inMemoryCache: MemoryStorage<T>;\n private indexedDBCache: DatabaseStorage<T>;\n private logger: Logger;\n\n constructor(logger: Logger) {\n this.inMemoryCache = new MemoryStorage<T>();\n this.indexedDBCache = new DatabaseStorage<T>();\n this.logger = logger;\n }\n\n private handleDatabaseAccessError(error: unknown): void {\n if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {\n this.logger.error(\"Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.\");\n }\n }\n /**\n * Get the item matching the given key. Tries in-memory cache first, then in the asynchronous\n * storage object if item isn't found in-memory.\n * @param key \n */\n async getItem(key: string): Promise<T | null> {\n const item = this.inMemoryCache.getItem(key);\n if(!item) {\n try {\n this.logger.verbose(\"Queried item not found in in-memory cache, now querying persistent storage.\");\n return await this.indexedDBCache.getItem(key);\n } catch (e) {\n this.handleDatabaseAccessError(e);\n }\n }\n return item;\n }\n\n /**\n * Sets the item in the in-memory cache and then tries to set it in the asynchronous\n * storage object with the given key.\n * @param key \n * @param value \n */\n async setItem(key: string, value: T): Promise<void> {\n this.inMemoryCache.setItem(key, value);\n try {\n await this.indexedDBCache.setItem(key, value);\n } catch (e) {\n this.handleDatabaseAccessError(e);\n }\n }\n\n /**\n * Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.\n * @param key \n */\n async removeItem(key: string): Promise<void> {\n this.inMemoryCache.removeItem(key);\n try {\n await this.indexedDBCache.removeItem(key);\n } catch (e) {\n this.handleDatabaseAccessError(e);\n }\n }\n\n /**\n * Get all the keys from the in-memory cache as an iterable array of strings. If no keys are found, query the keys in the \n * asynchronous storage object.\n */\n async getKeys(): Promise<string[]> {\n const cacheKeys = this.inMemoryCache.getKeys();\n if (cacheKeys.length === 0) {\n try {\n this.logger.verbose(\"In-memory cache is empty, now querying persistent storage.\");\n return await this.indexedDBCache.getKeys();\n } catch (e) {\n this.handleDatabaseAccessError(e);\n }\n }\n return cacheKeys;\n }\n\n /**\n * Returns true or false if the given key is present in the cache.\n * @param key \n */\n async containsKey(key: string): Promise<boolean> {\n const containsKey = this.inMemoryCache.containsKey(key);\n if(!containsKey) {\n try {\n this.logger.verbose(\"Key not found in in-memory cache, now querying persistent storage.\");\n return await this.indexedDBCache.containsKey(key);\n } catch (e) {\n this.handleDatabaseAccessError(e);\n }\n }\n return containsKey;\n }\n\n /**\n * Clears in-memory Map and tries to delete the IndexedDB database.\n */\n async clear(): Promise<void> {\n this.inMemoryCache.clear();\n try {\n await this.indexedDBCache.deleteDatabase();\n } catch (e) {\n this.handleDatabaseAccessError(e);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;AAWA;;;;;IASI,4BAAY,MAAc;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,EAAK,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,IAAI,eAAe,EAAK,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;KACxB;IAEO,sDAAyB,GAAjC,UAAkC,KAAc;QAC5C,IAAI,KAAK,YAAY,gBAAgB,IAAI,KAAK,CAAC,SAAS,KAAK,uBAAuB,CAAC,mBAAmB,CAAC,IAAI,EAAE;YAC3G,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6IAA6I,CAAC,CAAC;SACpK;KACJ;;;;;;IAMK,oCAAO,GAAb,UAAc,GAAW;;;;;;wBACf,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;6BAC1C,CAAC,IAAI,EAAL,wBAAK;;;;wBAEA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,6EAA6E,CAAC,CAAC;wBAC5F,qBAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,EAAA;4BAA7C,sBAAO,SAAsC,EAAC;;;wBAE9C,IAAI,CAAC,yBAAyB,CAAC,GAAC,CAAC,CAAC;;4BAG1C,sBAAO,IAAI,EAAC;;;;KACf;;;;;;;IAQK,oCAAO,GAAb,UAAc,GAAW,EAAE,KAAQ;;;;;;wBAC/B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;;;;wBAEnC,qBAAM,IAAI,CAAC,cAA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kCAAK,GAAX;;;;;;wBACI,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;;;;wBAEvB,qBAAM,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,EAAA;;wBAA1C,SAA0C,CAAC;;;;wBAE3C,IAAI,CAAC,yBAAyB,CAAC,GAAC,CAAC,CAAC;;;;;;KAEzC;IACL,yBAAC;AAAD,CAAC;;;;"}
|
|
@@ -122,6 +122,16 @@ export declare class BrowserCacheManager extends CacheManager {
|
|
|
122
122
|
*
|
|
123
123
|
*/
|
|
124
124
|
getAuthorityMetadataKeys(): Array<string>;
|
|
125
|
+
/**
|
|
126
|
+
* Sets wrapper metadata in memory
|
|
127
|
+
* @param wrapperSKU
|
|
128
|
+
* @param wrapperVersion
|
|
129
|
+
*/
|
|
130
|
+
setWrapperMetadata(wrapperSKU: string, wrapperVersion: string): void;
|
|
131
|
+
/**
|
|
132
|
+
* Returns wrapper metadata from in-memory storage
|
|
133
|
+
*/
|
|
134
|
+
getWrapperMetadata(): [string, string];
|
|
125
135
|
/**
|
|
126
136
|
*
|
|
127
137
|
* @param entity
|
|
@@ -182,9 +192,9 @@ export declare class BrowserCacheManager extends CacheManager {
|
|
|
182
192
|
*/
|
|
183
193
|
getKeys(): string[];
|
|
184
194
|
/**
|
|
185
|
-
* Clears all cache entries created by MSAL
|
|
195
|
+
* Clears all cache entries created by MSAL.
|
|
186
196
|
*/
|
|
187
|
-
clear(): void
|
|
197
|
+
clear(): Promise<void>;
|
|
188
198
|
/**
|
|
189
199
|
* Add value to cookies
|
|
190
200
|
* @param cookieName
|
|
@@ -271,6 +281,13 @@ export declare class BrowserCacheManager extends CacheManager {
|
|
|
271
281
|
* Gets the token exchange parameters from the cache. Throws an error if nothing is found.
|
|
272
282
|
*/
|
|
273
283
|
getCachedRequest(state: string, browserCrypto: ICrypto): CommonAuthorizationCodeRequest;
|
|
284
|
+
isInteractionInProgress(matchClientId?: boolean): boolean;
|
|
285
|
+
getInteractionInProgress(): string | null;
|
|
286
|
+
setInteractionInProgress(inProgress: boolean): void;
|
|
287
|
+
/**
|
|
288
|
+
* Returns username retrieved from ADAL or MSAL v1 idToken
|
|
289
|
+
*/
|
|
290
|
+
getLegacyLoginHint(): string | null;
|
|
274
291
|
}
|
|
275
292
|
export declare const DEFAULT_BROWSER_CACHE_MANAGER: (clientId: string, logger: Logger) => BrowserCacheManager;
|
|
276
293
|
//# sourceMappingURL=BrowserCacheManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserCacheManager.d.ts","sourceRoot":"","sources":["../../src/cache/BrowserCacheManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAA+C,8BAA8B,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAiB,MAAM,EAAE,uBAAuB,EAAiC,WAAW,
|
|
1
|
+
{"version":3,"file":"BrowserCacheManager.d.ts","sourceRoot":"","sources":["../../src/cache/BrowserCacheManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAA+C,8BAA8B,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAiB,MAAM,EAAE,uBAAuB,EAAiC,WAAW,EAA6C,MAAM,oBAAoB,CAAC;AAChZ,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAwB,eAAe,EAAyC,MAAM,2BAA2B,CAAC;AAMzH;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;IAGjD,OAAO,CAAC,WAAW,CAAyB;IAE5C,OAAO,CAAC,cAAc,CAAyB;IAE/C,OAAO,CAAC,eAAe,CAAwB;IAE/C,OAAO,CAAC,qBAAqB,CAAyB;IAEtD,OAAO,CAAC,MAAM,CAAS;IAGvB,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M,GAAG,IAAI;IAyBtC;;;OAGG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAY9C;;;;OAIG;IACH,6BAA6B,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;IAwBrE,gBAAgB,CAAC,eAAe,EAAE,8BAA8B,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI;IAO/F;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,GAAG,8BAA8B;IA2BvF,uBAAuB,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO;IAUzD,wBAAwB,IAAI,MAAM,GAAG,IAAI;IAKzC,wBAAwB,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI;IAYnD;;OAEG;IACH,kBAAkB,IAAI,MAAM,GAAG,IAAI;CAiCtC;AAED,eAAO,MAAM,6BAA6B,aAAc,MAAM,UAAU,MAAM,KAAG,mBAOhF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.20.0 2021-12-07 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { __extends, __spread } from '../_virtual/_tslib.js';
|
|
4
|
-
import { DEFAULT_CRYPTO_IMPLEMENTATION, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, PersistentCacheKeys, ThrottlingEntity, Constants, StringUtils, ProtocolUtils, CcsCredentialType } from '@azure/msal-common';
|
|
3
|
+
import { __extends, __spread, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
4
|
+
import { DEFAULT_CRYPTO_IMPLEMENTATION, AccountEntity, CacheManager, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, ServerTelemetryEntity, AuthorityMetadataEntity, PersistentCacheKeys, ThrottlingEntity, Constants, StringUtils, ProtocolUtils, CcsCredentialType, IdToken } from '@azure/msal-common';
|
|
5
5
|
import { BrowserAuthError } from '../error/BrowserAuthError.js';
|
|
6
|
-
import { BrowserCacheLocation, TemporaryCacheKeys } from '../utils/BrowserConstants.js';
|
|
6
|
+
import { BrowserCacheLocation, InMemoryCacheKeys, TemporaryCacheKeys } from '../utils/BrowserConstants.js';
|
|
7
7
|
import { BrowserStorage } from './BrowserStorage.js';
|
|
8
8
|
import { MemoryStorage } from './MemoryStorage.js';
|
|
9
9
|
import { BrowserProtocolUtils } from '../utils/BrowserProtocolUtils.js';
|
|
@@ -322,6 +322,23 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
322
322
|
return _this.isAuthorityMetadata(key);
|
|
323
323
|
});
|
|
324
324
|
};
|
|
325
|
+
/**
|
|
326
|
+
* Sets wrapper metadata in memory
|
|
327
|
+
* @param wrapperSKU
|
|
328
|
+
* @param wrapperVersion
|
|
329
|
+
*/
|
|
330
|
+
BrowserCacheManager.prototype.setWrapperMetadata = function (wrapperSKU, wrapperVersion) {
|
|
331
|
+
this.internalStorage.setItem(InMemoryCacheKeys.WRAPPER_SKU, wrapperSKU);
|
|
332
|
+
this.internalStorage.setItem(InMemoryCacheKeys.WRAPPER_VER, wrapperVersion);
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Returns wrapper metadata from in-memory storage
|
|
336
|
+
*/
|
|
337
|
+
BrowserCacheManager.prototype.getWrapperMetadata = function () {
|
|
338
|
+
var sku = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_SKU) || "";
|
|
339
|
+
var version = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_VER) || "";
|
|
340
|
+
return [sku, version];
|
|
341
|
+
};
|
|
325
342
|
/**
|
|
326
343
|
*
|
|
327
344
|
* @param entity
|
|
@@ -481,19 +498,32 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
481
498
|
return __spread(this.browserStorage.getKeys(), this.temporaryCacheStorage.getKeys());
|
|
482
499
|
};
|
|
483
500
|
/**
|
|
484
|
-
* Clears all cache entries created by MSAL
|
|
501
|
+
* Clears all cache entries created by MSAL.
|
|
485
502
|
*/
|
|
486
503
|
BrowserCacheManager.prototype.clear = function () {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
504
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
505
|
+
var _this = this;
|
|
506
|
+
return __generator(this, function (_a) {
|
|
507
|
+
switch (_a.label) {
|
|
508
|
+
case 0:
|
|
509
|
+
// Removes all accounts and their credentials
|
|
510
|
+
return [4 /*yield*/, this.removeAllAccounts()];
|
|
511
|
+
case 1:
|
|
512
|
+
// Removes all accounts and their credentials
|
|
513
|
+
_a.sent();
|
|
514
|
+
this.removeAppMetadata();
|
|
515
|
+
// Removes all remaining MSAL cache items
|
|
516
|
+
this.getKeys().forEach(function (cacheKey) {
|
|
517
|
+
// Check if key contains msal prefix; For now, we are clearing all the cache items created by MSAL.js
|
|
518
|
+
if ((_this.browserStorage.containsKey(cacheKey) || _this.temporaryCacheStorage.containsKey(cacheKey)) && ((cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1) || (cacheKey.indexOf(_this.clientId) !== -1))) {
|
|
519
|
+
_this.removeItem(cacheKey);
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
this.internalStorage.clear();
|
|
523
|
+
return [2 /*return*/];
|
|
524
|
+
}
|
|
525
|
+
});
|
|
495
526
|
});
|
|
496
|
-
this.internalStorage.clear();
|
|
497
527
|
};
|
|
498
528
|
/**
|
|
499
529
|
* Add value to cookies
|
|
@@ -683,8 +713,9 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
683
713
|
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
|
|
684
714
|
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));
|
|
685
715
|
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));
|
|
686
|
-
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.
|
|
716
|
+
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID));
|
|
687
717
|
this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL));
|
|
718
|
+
this.setInteractionInProgress(false);
|
|
688
719
|
};
|
|
689
720
|
/**
|
|
690
721
|
* Removes temporary cache for the provided state
|
|
@@ -760,6 +791,64 @@ var BrowserCacheManager = /** @class */ (function (_super) {
|
|
|
760
791
|
}
|
|
761
792
|
return parsedRequest;
|
|
762
793
|
};
|
|
794
|
+
BrowserCacheManager.prototype.isInteractionInProgress = function (matchClientId) {
|
|
795
|
+
var clientId = this.getInteractionInProgress();
|
|
796
|
+
if (matchClientId) {
|
|
797
|
+
return clientId === this.clientId;
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
return !!clientId;
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
BrowserCacheManager.prototype.getInteractionInProgress = function () {
|
|
804
|
+
var key = Constants.CACHE_PREFIX + "." + TemporaryCacheKeys.INTERACTION_STATUS_KEY;
|
|
805
|
+
return this.getTemporaryCache(key, false);
|
|
806
|
+
};
|
|
807
|
+
BrowserCacheManager.prototype.setInteractionInProgress = function (inProgress) {
|
|
808
|
+
var clientId = this.getInteractionInProgress();
|
|
809
|
+
// Ensure we don't overwrite interaction in progress for a different clientId
|
|
810
|
+
var key = Constants.CACHE_PREFIX + "." + TemporaryCacheKeys.INTERACTION_STATUS_KEY;
|
|
811
|
+
if (inProgress && !clientId) {
|
|
812
|
+
// No interaction is in progress
|
|
813
|
+
this.setTemporaryCache(key, this.clientId, false);
|
|
814
|
+
}
|
|
815
|
+
else if (!inProgress && clientId === this.clientId) {
|
|
816
|
+
this.removeItem(key);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
/**
|
|
820
|
+
* Returns username retrieved from ADAL or MSAL v1 idToken
|
|
821
|
+
*/
|
|
822
|
+
BrowserCacheManager.prototype.getLegacyLoginHint = function () {
|
|
823
|
+
// Only check for adal/msal token if no SSO params are being used
|
|
824
|
+
var adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
825
|
+
if (adalIdTokenString) {
|
|
826
|
+
this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
|
|
827
|
+
this.logger.verbose("Cached ADAL id token retrieved.");
|
|
828
|
+
}
|
|
829
|
+
// Check for cached MSAL v1 id token
|
|
830
|
+
var msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
|
|
831
|
+
if (msalIdTokenString) {
|
|
832
|
+
this.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
|
|
833
|
+
this.logger.verbose("Cached MSAL.js v1 id token retrieved");
|
|
834
|
+
}
|
|
835
|
+
var cachedIdTokenString = msalIdTokenString || adalIdTokenString;
|
|
836
|
+
if (cachedIdTokenString) {
|
|
837
|
+
var cachedIdToken = new IdToken(cachedIdTokenString, this.cryptoImpl);
|
|
838
|
+
if (cachedIdToken.claims && cachedIdToken.claims.preferred_username) {
|
|
839
|
+
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
|
|
840
|
+
return cachedIdToken.claims.preferred_username;
|
|
841
|
+
}
|
|
842
|
+
else if (cachedIdToken.claims && cachedIdToken.claims.upn) {
|
|
843
|
+
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
|
|
844
|
+
return cachedIdToken.claims.upn;
|
|
845
|
+
}
|
|
846
|
+
else {
|
|
847
|
+
this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO.");
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return null;
|
|
851
|
+
};
|
|
763
852
|
return BrowserCacheManager;
|
|
764
853
|
}(CacheManager));
|
|
765
854
|
var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
|