@azure/msal-browser 2.19.0 → 2.19.1
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/LICENSE +21 -21
- package/README.md +212 -212
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.js +1 -1
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.js +1 -1
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.js +1 -1
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/cache/AsyncMemoryStorage.js +1 -1
- package/dist/cache/AsyncMemoryStorage.js.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +5 -1
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +20 -1
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/BrowserStorage.js.map +1 -1
- package/dist/cache/DatabaseStorage.js +1 -1
- package/dist/cache/DatabaseStorage.js.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/MemoryStorage.js.map +1 -1
- package/dist/cache/TokenCache.js +1 -1
- package/dist/cache/TokenCache.js.map +1 -1
- package/dist/config/Configuration.js +1 -1
- package/dist/config/Configuration.js.map +1 -1
- package/dist/crypto/BrowserCrypto.js +1 -1
- package/dist/crypto/BrowserCrypto.js.map +1 -1
- package/dist/crypto/CryptoOps.js +1 -1
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/GuidGenerator.js.map +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/PkceGenerator.js.map +1 -1
- package/dist/crypto/SignedHttpRequest.js +1 -1
- package/dist/crypto/SignedHttpRequest.js.map +1 -1
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Decode.js.map +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/encode/Base64Encode.js.map +1 -1
- package/dist/error/BrowserAuthError.js +1 -1
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +1 -1
- package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
- package/dist/event/EventHandler.js +1 -1
- package/dist/event/EventHandler.js.map +1 -1
- package/dist/event/EventMessage.js +1 -1
- package/dist/event/EventMessage.js.map +1 -1
- package/dist/event/EventType.js +1 -1
- package/dist/event/EventType.js.map +1 -1
- package/dist/index.cjs.js +2003 -1959
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.js +1 -1
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.js +1 -1
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +1 -1
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +1 -1
- package/dist/interaction_client/SilentIframeClient.js.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +1 -1
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +1 -1
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +1 -1
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/PopupHandler.js +1 -1
- package/dist/interaction_handler/PopupHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +1 -1
- package/dist/interaction_handler/RedirectHandler.js.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +1 -1
- package/dist/interaction_handler/SilentHandler.js.map +1 -1
- package/dist/navigation/NavigationClient.js +1 -1
- package/dist/navigation/NavigationClient.js.map +1 -1
- package/dist/network/FetchClient.js +1 -1
- package/dist/network/FetchClient.js.map +1 -1
- package/dist/network/XhrClient.js +1 -1
- package/dist/network/XhrClient.js.map +1 -1
- package/dist/packageMetadata.js +1 -1
- package/dist/packageMetadata.js.map +1 -1
- package/dist/utils/BrowserConstants.js +1 -1
- package/dist/utils/BrowserConstants.js.map +1 -1
- package/dist/utils/BrowserProtocolUtils.js +1 -1
- package/dist/utils/BrowserProtocolUtils.js.map +1 -1
- package/dist/utils/BrowserStringUtils.js +1 -1
- package/dist/utils/BrowserStringUtils.js.map +1 -1
- package/dist/utils/BrowserUtils.js +1 -1
- package/dist/utils/BrowserUtils.js.map +1 -1
- package/dist/utils/MathUtils.js +1 -1
- package/dist/utils/MathUtils.js.map +1 -1
- package/dist/utils/PopupUtils.js +1 -1
- package/dist/utils/PopupUtils.js.map +1 -1
- package/lib/msal-browser.js +2003 -1959
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +22 -22
- package/package.json +95 -95
- package/CHANGELOG.json +0 -1613
- package/CHANGELOG.md +0 -510
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.19.
|
|
1
|
+
/*! @azure/msal-browser v2.19.1 2022-08-03 */
|
|
2
2
|
'use strict';
|
|
3
3
|
export { PublicClientApplication } from './app/PublicClientApplication.js';
|
|
4
4
|
export { ApiId, BrowserCacheLocation, InteractionStatus, InteractionType, WrapperSKU } from './utils/BrowserConstants.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.19.
|
|
1
|
+
/*! @azure/msal-browser v2.19.1 2022-08-03 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __awaiter, __generator, __spread, __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { AccountEntity, AuthenticationScheme, ClientConfigurationError, UrlString, ServerTelemetryManager } from '@azure/msal-common';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInteractionClient.js","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICrypto, INetworkModule, Logger, AuthenticationResult, AccountInfo, AccountEntity, BaseAuthRequest, AuthenticationScheme, UrlString, ServerTelemetryManager, ServerTelemetryRequest, ClientConfigurationError } from \"@azure/msal-common\";\nimport { BrowserConfiguration } from \"../config/Configuration\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { EventHandler } from \"../event/EventHandler\";\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\nimport { PopupRequest } from \"../request/PopupRequest\";\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\nimport { version } from \"../packageMetadata\";\nimport { BrowserConstants } from \"../utils/BrowserConstants\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\n\nexport abstract class BaseInteractionClient {\n\n protected config: BrowserConfiguration;\n protected browserStorage: BrowserCacheManager;\n protected browserCrypto: ICrypto;\n protected networkClient: INetworkModule;\n protected logger: Logger;\n protected eventHandler: EventHandler;\n protected correlationId: string;\n\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, correlationId?: string) {\n this.config = config;\n this.browserStorage = storageImpl;\n this.browserCrypto = browserCrypto;\n this.networkClient = this.config.system.networkClient;\n this.eventHandler = eventHandler;\n this.correlationId = correlationId || this.browserCrypto.createNewGuid();\n this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);\n }\n\n abstract acquireToken(request: RedirectRequest|PopupRequest|SsoSilentRequest): Promise<AuthenticationResult|void>;\n\n abstract logout(request: EndSessionRequest): Promise<void>;\n\n protected async clearCacheOnLogout(account?: AccountInfo| null): Promise<void> {\n if (account) {\n if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {\n this.logger.verbose(\"Setting active account to null\");\n this.browserStorage.setActiveAccount(null);\n }\n // Clear given account.\n try {\n await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));\n this.logger.verbose(\"Cleared cache items belonging to the account provided in the logout request.\");\n } catch (error) {\n this.logger.error(\"Account provided in logout request was not found. Local cache unchanged.\");\n }\n } else {\n try {\n // Clear all accounts and tokens\n await this.browserStorage.clear();\n // Clear any stray keys from IndexedDB\n await this.browserCrypto.clearKeystore();\n this.logger.verbose(\"No account provided in logout request, clearing all cache items.\");\n } catch(e) {\n this.logger.error(\"Attempted to clear all MSAL cache items and failed. Local cache unchanged.\");\n }\n }\n }\n\n /**\n * Initializer function for all request APIs\n * @param request\n */\n protected initializeBaseRequest(request: Partial<BaseAuthRequest>): BaseAuthRequest {\n this.logger.verbose(\"Initializing BaseAuthRequest\");\n const authority = request.authority || this.config.auth.authority;\n\n const scopes = [...((request && request.scopes) || [])];\n\n // Set authenticationScheme to BEARER if not explicitly set in the request\n if (!request.authenticationScheme) {\n request.authenticationScheme = AuthenticationScheme.BEARER;\n this.logger.verbose(\"Authentication Scheme wasn't explicitly set in request, defaulting to \\\"Bearer\\\" request\");\n } else {\n if (request.authenticationScheme === AuthenticationScheme.SSH) {\n if (!request.sshJwk) {\n throw ClientConfigurationError.createMissingSshJwkError();\n }\n if(!request.sshKid) {\n throw ClientConfigurationError.createMissingSshKidError();\n }\n }\n this.logger.verbose(`Authentication Scheme set to \"${request.authenticationScheme}\" as configured in Auth request`);\n }\n\n const validatedRequest: BaseAuthRequest = {\n ...request,\n correlationId: this.correlationId,\n authority,\n scopes\n };\n\n return validatedRequest;\n }\n\n /**\n *\n * Use to get the redirect uri configured in MSAL or null.\n * @param requestRedirectUri\n * @returns Redirect URL\n *\n */\n protected getRedirectUri(requestRedirectUri?: string): string {\n this.logger.verbose(\"getRedirectUri called\");\n const redirectUri = requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();\n return UrlString.getAbsoluteUrl(redirectUri, BrowserUtils.getCurrentUri());\n }\n\n /**\n *\n * @param apiId\n * @param correlationId\n * @param forceRefresh\n */\n protected initializeServerTelemetryManager(apiId: number, forceRefresh?: boolean): ServerTelemetryManager {\n this.logger.verbose(\"initializeServerTelemetryManager called\");\n const telemetryPayload: ServerTelemetryRequest = {\n clientId: this.config.auth.clientId,\n correlationId: this.correlationId,\n apiId: apiId,\n forceRefresh: forceRefresh || false,\n wrapperSKU: this.browserStorage.getWrapperMetadata()[0],\n wrapperVer: this.browserStorage.getWrapperMetadata()[1]\n };\n\n return new ServerTelemetryManager(telemetryPayload, this.browserStorage);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IA2BI,+BAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,aAAsB;QAClK,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;KACtF;IAMe,kDAAkB,GAAlC,UAAmC,OAA2B;;;;;6BACtD,OAAO,EAAP,wBAAO;wBACP,IAAI,aAAa,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,EAAE,KAAK,CAAC,EAAE;4BAC1F,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC;4BACtD,IAAI,CAAC,cAAc,C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AC5E;IACL,4BAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"BaseInteractionClient.js","sources":["../../src/interaction_client/BaseInteractionClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ICrypto, INetworkModule, Logger, AuthenticationResult, AccountInfo, AccountEntity, BaseAuthRequest, AuthenticationScheme, UrlString, ServerTelemetryManager, ServerTelemetryRequest, ClientConfigurationError } from \"@azure/msal-common\";\r\nimport { BrowserConfiguration } from \"../config/Configuration\";\r\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\r\nimport { EventHandler } from \"../event/EventHandler\";\r\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\r\nimport { RedirectRequest } from \"../request/RedirectRequest\";\r\nimport { PopupRequest } from \"../request/PopupRequest\";\r\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\r\nimport { version } from \"../packageMetadata\";\r\nimport { BrowserConstants } from \"../utils/BrowserConstants\";\r\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\r\n\r\nexport abstract class BaseInteractionClient {\r\n\r\n protected config: BrowserConfiguration;\r\n protected browserStorage: BrowserCacheManager;\r\n protected browserCrypto: ICrypto;\r\n protected networkClient: INetworkModule;\r\n protected logger: Logger;\r\n protected eventHandler: EventHandler;\r\n protected correlationId: string;\r\n\r\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, correlationId?: string) {\r\n this.config = config;\r\n this.browserStorage = storageImpl;\r\n this.browserCrypto = browserCrypto;\r\n this.networkClient = this.config.system.networkClient;\r\n this.eventHandler = eventHandler;\r\n this.correlationId = correlationId || this.browserCrypto.createNewGuid();\r\n this.logger = logger.clone(BrowserConstants.MSAL_SKU, version, this.correlationId);\r\n }\r\n\r\n abstract acquireToken(request: RedirectRequest|PopupRequest|SsoSilentRequest): Promise<AuthenticationResult|void>;\r\n\r\n abstract logout(request: EndSessionRequest): Promise<void>;\r\n\r\n protected async clearCacheOnLogout(account?: AccountInfo| null): Promise<void> {\r\n if (account) {\r\n if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {\r\n this.logger.verbose(\"Setting active account to null\");\r\n this.browserStorage.setActiveAccount(null);\r\n }\r\n // Clear given account.\r\n try {\r\n await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));\r\n this.logger.verbose(\"Cleared cache items belonging to the account provided in the logout request.\");\r\n } catch (error) {\r\n this.logger.error(\"Account provided in logout request was not found. Local cache unchanged.\");\r\n }\r\n } else {\r\n try {\r\n // Clear all accounts and tokens\r\n await this.browserStorage.clear();\r\n // Clear any stray keys from IndexedDB\r\n await this.browserCrypto.clearKeystore();\r\n this.logger.verbose(\"No account provided in logout request, clearing all cache items.\");\r\n } catch(e) {\r\n this.logger.error(\"Attempted to clear all MSAL cache items and failed. Local cache unchanged.\");\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Initializer function for all request APIs\r\n * @param request\r\n */\r\n protected initializeBaseRequest(request: Partial<BaseAuthRequest>): BaseAuthRequest {\r\n this.logger.verbose(\"Initializing BaseAuthRequest\");\r\n const authority = request.authority || this.config.auth.authority;\r\n\r\n const scopes = [...((request && request.scopes) || [])];\r\n\r\n // Set authenticationScheme to BEARER if not explicitly set in the request\r\n if (!request.authenticationScheme) {\r\n request.authenticationScheme = AuthenticationScheme.BEARER;\r\n this.logger.verbose(\"Authentication Scheme wasn't explicitly set in request, defaulting to \\\"Bearer\\\" request\");\r\n } else {\r\n if (request.authenticationScheme === AuthenticationScheme.SSH) {\r\n if (!request.sshJwk) {\r\n throw ClientConfigurationError.createMissingSshJwkError();\r\n }\r\n if(!request.sshKid) {\r\n throw ClientConfigurationError.createMissingSshKidError();\r\n }\r\n }\r\n this.logger.verbose(`Authentication Scheme set to \"${request.authenticationScheme}\" as configured in Auth request`);\r\n }\r\n\r\n const validatedRequest: BaseAuthRequest = {\r\n ...request,\r\n correlationId: this.correlationId,\r\n authority,\r\n scopes\r\n };\r\n\r\n return validatedRequest;\r\n }\r\n\r\n /**\r\n *\r\n * Use to get the redirect uri configured in MSAL or null.\r\n * @param requestRedirectUri\r\n * @returns Redirect URL\r\n *\r\n */\r\n protected getRedirectUri(requestRedirectUri?: string): string {\r\n this.logger.verbose(\"getRedirectUri called\");\r\n const redirectUri = requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();\r\n return UrlString.getAbsoluteUrl(redirectUri, BrowserUtils.getCurrentUri());\r\n }\r\n\r\n /**\r\n *\r\n * @param apiId\r\n * @param correlationId\r\n * @param forceRefresh\r\n */\r\n protected initializeServerTelemetryManager(apiId: number, forceRefresh?: boolean): ServerTelemetryManager {\r\n this.logger.verbose(\"initializeServerTelemetryManager called\");\r\n const telemetryPayload: ServerTelemetryRequest = {\r\n clientId: this.config.auth.clientId,\r\n correlationId: this.correlationId,\r\n apiId: apiId,\r\n forceRefresh: forceRefresh || false,\r\n wrapperSKU: this.browserStorage.getWrapperMetadata()[0],\r\n wrapperVer: this.browserStorage.getWrapperMetadata()[1]\r\n };\r\n\r\n return new ServerTelemetryManager(telemetryPayload, this.browserStorage);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IA2BI,+BAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,aAAsB;QAClK,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC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B;YAC7C,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ;YACnC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,YAAY,IAAI,KAAK;YACnC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;YACvD,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;SAC1D,CAAC;QAEF,OAAO,IAAI,sBAAsB,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;KAC5E;IACL,4BAAC;AAAD,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupClient.js","sources":["../../src/interaction_client/PopupClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthenticationResult, CommonAuthorizationCodeRequest, AuthorizationCodeClient, ThrottlingUtils, CommonEndSessionRequest, UrlString, AuthError } from \"@azure/msal-common\";\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { PopupWindowAttributes, PopupUtils } from \"../utils/PopupUtils\";\nimport { EventType } from \"../event/EventType\";\nimport { InteractionType, ApiId } from \"../utils/BrowserConstants\";\nimport { PopupHandler, PopupParams } from \"../interaction_handler/PopupHandler\";\nimport { EndSessionPopupRequest } from \"../request/EndSessionPopupRequest\";\nimport { NavigationOptions } from \"../navigation/NavigationOptions\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { PopupRequest } from \"../request/PopupRequest\";\n\nexport class PopupClient extends StandardInteractionClient {\n /**\n * Acquires tokens by opening a popup window to the /authorize endpoint of the authority\n * @param request \n */\n acquireToken(request: PopupRequest): Promise<AuthenticationResult> {\n try {\n const validRequest = this.preflightInteractiveRequest(request, InteractionType.Popup);\n const popupName = PopupUtils.generatePopupName(this.config.auth.clientId, validRequest);\n const popupWindowAttributes = request.popupWindowAttributes || {};\n\n // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.\n if (this.config.system.asyncPopups) {\n this.logger.verbose(\"asyncPopups set to true, acquiring token\");\n // Passes on popup position and dimensions if in request\n return this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes);\n } else {\n // asyncPopups flag is set to false. Opens popup before acquiring token.\n this.logger.verbose(\"asyncPopup set to false, opening popup before acquiring token\");\n const popup = PopupUtils.openSizedPopup(\"about:blank\", popupName, popupWindowAttributes, this.logger);\n return this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes, popup);\n }\n } catch (e) {\n return Promise.reject(e);\n }\n }\n\n /**\n * Clears local cache for the current user then opens a popup window prompting the user to sign-out of the server\n * @param logoutRequest \n */\n logout(logoutRequest?: EndSessionPopupRequest): Promise<void> {\n try {\n this.logger.verbose(\"logoutPopup called\");\n const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);\n\n const popupName = PopupUtils.generateLogoutPopupName(this.config.auth.clientId, validLogoutRequest);\n const authority = logoutRequest && logoutRequest.authority;\n const mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;\n const popupWindowAttributes = logoutRequest?.popupWindowAttributes || {};\n\n // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.\n if (this.config.system.asyncPopups) {\n this.logger.verbose(\"asyncPopups set to true\");\n // Passes on popup position and dimensions if in request\n return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, undefined, mainWindowRedirectUri);\n } else {\n // asyncPopups flag is set to false. Opens popup before logging out.\n this.logger.verbose(\"asyncPopup set to false, opening popup\");\n const popup = PopupUtils.openSizedPopup(\"about:blank\", popupName, popupWindowAttributes, this.logger);\n return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, popup, mainWindowRedirectUri);\n }\n } catch (e) {\n // Since this function is synchronous we need to reject\n return Promise.reject(e);\n }\n }\n\n /**\n * Helper which obtains an access_token for your API via opening a popup window in the user's browser\n * @param validRequest\n * @param popupName\n * @param popup\n * @param popupWindowAttributes\n *\n * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.\n */\n private async acquireTokenPopupAsync(validRequest: AuthorizationUrlRequest, popupName: string, popupWindowAttributes: PopupWindowAttributes, popup?: Window|null): Promise<AuthenticationResult> {\n this.logger.verbose(\"acquireTokenPopupAsync called\");\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenPopup);\n\n try {\n // Create auth code request and generate PKCE params\n const authCodeRequest: CommonAuthorizationCodeRequest = await this.initializeAuthorizationCodeRequest(validRequest);\n\n // Initialize the client\n const authClient: AuthorizationCodeClient = await this.createAuthCodeClient(serverTelemetryManager, validRequest.authority);\n this.logger.verbose(\"Auth code client created\");\n\n // Create acquire token url.\n const navigateUrl = await authClient.getAuthCodeUrl(validRequest);\n\n // Create popup interaction handler.\n const interactionHandler = new PopupHandler(authClient, this.browserStorage, authCodeRequest, this.logger);\n\n // Show the UI once the url has been created. Get the window handle for the popup.\n const popupParameters: PopupParams = {\n popup,\n popupName,\n popupWindowAttributes\n };\n const popupWindow: Window = interactionHandler.initiateAuthRequest(navigateUrl, popupParameters);\n this.eventHandler.emitEvent(EventType.POPUP_OPENED, InteractionType.Popup, {popupWindow}, null);\n\n // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.\n const hash = await interactionHandler.monitorPopupForHash(popupWindow);\n const state = this.validateAndExtractStateFromHash(hash, InteractionType.Popup, validRequest.correlationId);\n\n // Remove throttle if it exists\n ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest);\n\n // Handle response from hash string.\n const result = await interactionHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient);\n\n return result;\n } catch (e) { \n if (popup) {\n // Close the synchronous popup if an error is thrown before the window unload event is registered\n popup.close();\n }\n\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n\n serverTelemetryManager.cacheFailedRequest(e);\n this.browserStorage.cleanRequestByState(validRequest.state);\n throw e;\n }\n }\n\n /**\n * \n * @param validRequest \n * @param popupName \n * @param requestAuthority\n * @param popup \n * @param mainWindowRedirectUri \n * @param popupWindowAttributes \n */\n private async logoutPopupAsync(validRequest: CommonEndSessionRequest, popupName: string, popupWindowAttributes: PopupWindowAttributes, requestAuthority?: string, popup?: Window|null, mainWindowRedirectUri?: string): Promise<void> {\n this.logger.verbose(\"logoutPopupAsync called\");\n this.eventHandler.emitEvent(EventType.LOGOUT_START, InteractionType.Popup, validRequest);\n\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.logoutPopup);\n \n try {\n // Clear cache on logout\n await this.clearCacheOnLogout(validRequest.account);\n\n this.browserStorage.setInteractionInProgress(true);\n // Initialize the client\n const authClient = await this.createAuthCodeClient(serverTelemetryManager, requestAuthority);\n this.logger.verbose(\"Auth code client created\");\n\n // Create logout string and navigate user window to logout.\n const logoutUri: string = authClient.getLogoutUri(validRequest);\n\n this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, InteractionType.Popup, validRequest);\n\n const popupUtils = new PopupUtils(this.browserStorage, this.logger);\n // Open the popup window to requestUrl.\n const popupWindow = popupUtils.openPopup(logoutUri, {popupName, popupWindowAttributes, popup});\n this.eventHandler.emitEvent(EventType.POPUP_OPENED, InteractionType.Popup, {popupWindow}, null);\n\n try {\n // Don't care if this throws an error (User Cancelled)\n await popupUtils.monitorPopupForSameOrigin(popupWindow);\n this.logger.verbose(\"Popup successfully redirected to postLogoutRedirectUri\");\n } catch (e) {\n this.logger.verbose(`Error occurred while monitoring popup for same origin. Session on server may remain active. Error: ${e}`);\n }\n\n popupUtils.cleanPopup(popupWindow);\n\n if (mainWindowRedirectUri) {\n const navigationOptions: NavigationOptions = {\n apiId: ApiId.logoutPopup,\n timeout: this.config.system.redirectNavigationTimeout,\n noHistory: false\n };\n const absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, BrowserUtils.getCurrentUri());\n\n this.logger.verbose(\"Redirecting main window to url specified in the request\");\n this.logger.verbosePii(`Redirecing main window to: ${absoluteUrl}`);\n this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);\n } else {\n this.logger.verbose(\"No main window navigation requested\");\n }\n\n } catch (e) {\n if (popup) {\n // Close the synchronous popup if an error is thrown before the window unload event is registered\n popup.close();\n }\n\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n \n this.browserStorage.setInteractionInProgress(false);\n this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, InteractionType.Popup, null, e);\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Popup);\n serverTelemetryManager.cacheFailedRequest(e);\n throw e;\n }\n\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Popup);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;IAiBiC,+BAAyB;IAA1D;;KAuMC;;;;;IAlMG,kCAAY,GAAZ,UAAa,OAAqB;QAC9B,IAAI;YACA,IAAM,YAAY,GAAG,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;YACtF,IAAM,SAAS,GAAG,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACxF,IAAM,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,IAAI,EAAE,CAAC;;YAGlE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;gBAChC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,0CAA0C,CAAC,CAAC;;gBAEhE,OAAO,IAAI,CAAC,sBAAsB,CAAC,YAAY,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAC;aACtF;iBAAM;;gBAEH,IAAI,CAAC,MAAM,CAAC,OAA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,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;;;;;KAC5E;IACL,kBAAC;AAAD,CAvMA,CAAiC,yBAAyB;;;;"}
|
|
1
|
+
{"version":3,"file":"PopupClient.js","sources":["../../src/interaction_client/PopupClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthenticationResult, CommonAuthorizationCodeRequest, AuthorizationCodeClient, ThrottlingUtils, CommonEndSessionRequest, UrlString, AuthError } from \"@azure/msal-common\";\r\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\r\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\r\nimport { PopupWindowAttributes, PopupUtils } from \"../utils/PopupUtils\";\r\nimport { EventType } from \"../event/EventType\";\r\nimport { InteractionType, ApiId } from \"../utils/BrowserConstants\";\r\nimport { PopupHandler, PopupParams } from \"../interaction_handler/PopupHandler\";\r\nimport { EndSessionPopupRequest } from \"../request/EndSessionPopupRequest\";\r\nimport { NavigationOptions } from \"../navigation/NavigationOptions\";\r\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\r\nimport { PopupRequest } from \"../request/PopupRequest\";\r\n\r\nexport class PopupClient extends StandardInteractionClient {\r\n /**\r\n * Acquires tokens by opening a popup window to the /authorize endpoint of the authority\r\n * @param request \r\n */\r\n acquireToken(request: PopupRequest): Promise<AuthenticationResult> {\r\n try {\r\n const validRequest = this.preflightInteractiveRequest(request, InteractionType.Popup);\r\n const popupName = PopupUtils.generatePopupName(this.config.auth.clientId, validRequest);\r\n const popupWindowAttributes = request.popupWindowAttributes || {};\r\n\r\n // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.\r\n if (this.config.system.asyncPopups) {\r\n this.logger.verbose(\"asyncPopups set to true, acquiring token\");\r\n // Passes on popup position and dimensions if in request\r\n return this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes);\r\n } else {\r\n // asyncPopups flag is set to false. Opens popup before acquiring token.\r\n this.logger.verbose(\"asyncPopup set to false, opening popup before acquiring token\");\r\n const popup = PopupUtils.openSizedPopup(\"about:blank\", popupName, popupWindowAttributes, this.logger);\r\n return this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes, popup);\r\n }\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n }\r\n\r\n /**\r\n * Clears local cache for the current user then opens a popup window prompting the user to sign-out of the server\r\n * @param logoutRequest \r\n */\r\n logout(logoutRequest?: EndSessionPopupRequest): Promise<void> {\r\n try {\r\n this.logger.verbose(\"logoutPopup called\");\r\n const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);\r\n\r\n const popupName = PopupUtils.generateLogoutPopupName(this.config.auth.clientId, validLogoutRequest);\r\n const authority = logoutRequest && logoutRequest.authority;\r\n const mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;\r\n const popupWindowAttributes = logoutRequest?.popupWindowAttributes || {};\r\n\r\n // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.\r\n if (this.config.system.asyncPopups) {\r\n this.logger.verbose(\"asyncPopups set to true\");\r\n // Passes on popup position and dimensions if in request\r\n return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, undefined, mainWindowRedirectUri);\r\n } else {\r\n // asyncPopups flag is set to false. Opens popup before logging out.\r\n this.logger.verbose(\"asyncPopup set to false, opening popup\");\r\n const popup = PopupUtils.openSizedPopup(\"about:blank\", popupName, popupWindowAttributes, this.logger);\r\n return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, popup, mainWindowRedirectUri);\r\n }\r\n } catch (e) {\r\n // Since this function is synchronous we need to reject\r\n return Promise.reject(e);\r\n }\r\n }\r\n\r\n /**\r\n * Helper which obtains an access_token for your API via opening a popup window in the user's browser\r\n * @param validRequest\r\n * @param popupName\r\n * @param popup\r\n * @param popupWindowAttributes\r\n *\r\n * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.\r\n */\r\n private async acquireTokenPopupAsync(validRequest: AuthorizationUrlRequest, popupName: string, popupWindowAttributes: PopupWindowAttributes, popup?: Window|null): Promise<AuthenticationResult> {\r\n this.logger.verbose(\"acquireTokenPopupAsync called\");\r\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenPopup);\r\n\r\n try {\r\n // Create auth code request and generate PKCE params\r\n const authCodeRequest: CommonAuthorizationCodeRequest = await this.initializeAuthorizationCodeRequest(validRequest);\r\n\r\n // Initialize the client\r\n const authClient: AuthorizationCodeClient = await this.createAuthCodeClient(serverTelemetryManager, validRequest.authority);\r\n this.logger.verbose(\"Auth code client created\");\r\n\r\n // Create acquire token url.\r\n const navigateUrl = await authClient.getAuthCodeUrl(validRequest);\r\n\r\n // Create popup interaction handler.\r\n const interactionHandler = new PopupHandler(authClient, this.browserStorage, authCodeRequest, this.logger);\r\n\r\n // Show the UI once the url has been created. Get the window handle for the popup.\r\n const popupParameters: PopupParams = {\r\n popup,\r\n popupName,\r\n popupWindowAttributes\r\n };\r\n const popupWindow: Window = interactionHandler.initiateAuthRequest(navigateUrl, popupParameters);\r\n this.eventHandler.emitEvent(EventType.POPUP_OPENED, InteractionType.Popup, {popupWindow}, null);\r\n\r\n // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.\r\n const hash = await interactionHandler.monitorPopupForHash(popupWindow);\r\n const state = this.validateAndExtractStateFromHash(hash, InteractionType.Popup, validRequest.correlationId);\r\n\r\n // Remove throttle if it exists\r\n ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest);\r\n\r\n // Handle response from hash string.\r\n const result = await interactionHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient);\r\n\r\n return result;\r\n } catch (e) { \r\n if (popup) {\r\n // Close the synchronous popup if an error is thrown before the window unload event is registered\r\n popup.close();\r\n }\r\n\r\n if (e instanceof AuthError) {\r\n e.setCorrelationId(this.correlationId);\r\n }\r\n\r\n serverTelemetryManager.cacheFailedRequest(e);\r\n this.browserStorage.cleanRequestByState(validRequest.state);\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * \r\n * @param validRequest \r\n * @param popupName \r\n * @param requestAuthority\r\n * @param popup \r\n * @param mainWindowRedirectUri \r\n * @param popupWindowAttributes \r\n */\r\n private async logoutPopupAsync(validRequest: CommonEndSessionRequest, popupName: string, popupWindowAttributes: PopupWindowAttributes, requestAuthority?: string, popup?: Window|null, mainWindowRedirectUri?: string): Promise<void> {\r\n this.logger.verbose(\"logoutPopupAsync called\");\r\n this.eventHandler.emitEvent(EventType.LOGOUT_START, InteractionType.Popup, validRequest);\r\n\r\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.logoutPopup);\r\n \r\n try {\r\n // Clear cache on logout\r\n await this.clearCacheOnLogout(validRequest.account);\r\n\r\n this.browserStorage.setInteractionInProgress(true);\r\n // Initialize the client\r\n const authClient = await this.createAuthCodeClient(serverTelemetryManager, requestAuthority);\r\n this.logger.verbose(\"Auth code client created\");\r\n\r\n // Create logout string and navigate user window to logout.\r\n const logoutUri: string = authClient.getLogoutUri(validRequest);\r\n\r\n this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, InteractionType.Popup, validRequest);\r\n\r\n const popupUtils = new PopupUtils(this.browserStorage, this.logger);\r\n // Open the popup window to requestUrl.\r\n const popupWindow = popupUtils.openPopup(logoutUri, {popupName, popupWindowAttributes, popup});\r\n this.eventHandler.emitEvent(EventType.POPUP_OPENED, InteractionType.Popup, {popupWindow}, null);\r\n\r\n try {\r\n // Don't care if this throws an error (User Cancelled)\r\n await popupUtils.monitorPopupForSameOrigin(popupWindow);\r\n this.logger.verbose(\"Popup successfully redirected to postLogoutRedirectUri\");\r\n } catch (e) {\r\n this.logger.verbose(`Error occurred while monitoring popup for same origin. Session on server may remain active. Error: ${e}`);\r\n }\r\n\r\n popupUtils.cleanPopup(popupWindow);\r\n\r\n if (mainWindowRedirectUri) {\r\n const navigationOptions: NavigationOptions = {\r\n apiId: ApiId.logoutPopup,\r\n timeout: this.config.system.redirectNavigationTimeout,\r\n noHistory: false\r\n };\r\n const absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, BrowserUtils.getCurrentUri());\r\n\r\n this.logger.verbose(\"Redirecting main window to url specified in the request\");\r\n this.logger.verbosePii(`Redirecing main window to: ${absoluteUrl}`);\r\n this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);\r\n } else {\r\n this.logger.verbose(\"No main window navigation requested\");\r\n }\r\n\r\n } catch (e) {\r\n if (popup) {\r\n // Close the synchronous popup if an error is thrown before the window unload event is registered\r\n popup.close();\r\n }\r\n\r\n if (e instanceof AuthError) {\r\n e.setCorrelationId(this.correlationId);\r\n }\r\n \r\n this.browserStorage.setInteractionInProgress(false);\r\n this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, InteractionType.Popup, null, e);\r\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Popup);\r\n serverTelemetryManager.cacheFailedRequest(e);\r\n throw e;\r\n }\r\n\r\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Popup);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;IAiBiC,+BAAyB;IAA1D;;KAuMC;;;;;IAlMG,kCAAY,GAAZ,UAAa,OAAqB;QAC9B,IAAI;YACA,IAAM,YAAY,GAAG,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;YACtF,IAAM,SAAS,GAAG,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACxF,IAAM,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,IAAI,EAAE,CAAC;;YAGlE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;gBAChC,IAAI,CAAC,MAAM,CAAC,OAAO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e,CAAC,KAAK,CAAC,CAAC;wBACzE,sBAAsB,CAAC,kBAAkB,CAAC,GAAC,CAAC,CAAC;wBAC7C,MAAM,GAAC,CAAC;;wBAGZ,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;;;;;KAC5E;IACL,kBAAC;AAAD,CAvMA,CAAiC,yBAAyB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedirectClient.js","sources":["../../src/interaction_client/RedirectClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthenticationResult, CommonAuthorizationCodeRequest, AuthorizationCodeClient, UrlString, AuthError, ServerTelemetryManager } from \"@azure/msal-common\";\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\nimport { ApiId, InteractionType, TemporaryCacheKeys } from \"../utils/BrowserConstants\";\nimport { RedirectHandler } from \"../interaction_handler/RedirectHandler\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\nimport { EventType } from \"../event/EventType\";\nimport { NavigationOptions } from \"../navigation/NavigationOptions\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\n\nexport class RedirectClient extends StandardInteractionClient { \n /**\n * Redirects the page to the /authorize endpoint of the IDP\n * @param request \n */\n async acquireToken(request: RedirectRequest): Promise<void> {\n const validRequest: AuthorizationUrlRequest = this.preflightInteractiveRequest(request, InteractionType.Redirect);\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenRedirect);\n\n try {\n // Create auth code request and generate PKCE params\n const authCodeRequest: CommonAuthorizationCodeRequest = await this.initializeAuthorizationCodeRequest(validRequest);\n\n // Initialize the client\n const authClient: AuthorizationCodeClient = await this.createAuthCodeClient(serverTelemetryManager, validRequest.authority);\n this.logger.verbose(\"Auth code client created\");\n\n // Create redirect interaction handler.\n const interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);\n\n // Create acquire token url.\n const navigateUrl = await authClient.getAuthCodeUrl(validRequest);\n\n const redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);\n this.logger.verbosePii(`Redirect start page: ${redirectStartPage}`);\n\n // Show the UI once the url has been created. Response will come back in the hash, which will be handled in the handleRedirectCallback function.\n return await interactionHandler.initiateAuthRequest(navigateUrl, {\n navigationClient: this.navigationClient,\n redirectTimeout: this.config.system.redirectNavigationTimeout,\n redirectStartPage: redirectStartPage,\n onRedirectNavigate: request.onRedirectNavigate\n });\n } catch (e) {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n this.browserStorage.cleanRequestByState(validRequest.state);\n throw e;\n }\n }\n\n /**\n * Checks if navigateToLoginRequestUrl is set, and:\n * - if true, performs logic to cache and navigate\n * - if false, handles hash string and parses response\n * @param hash\n */\n async handleRedirectPromise(hash?: string): Promise<AuthenticationResult | null> {\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.handleRedirectPromise);\n try {\n if (!this.browserStorage.isInteractionInProgress(true)) {\n this.logger.info(\"handleRedirectPromise called but there is no interaction in progress, returning null.\");\n return null;\n }\n\n const responseHash = this.getRedirectResponseHash(hash || window.location.hash);\n if (!responseHash) {\n // Not a recognized server response hash or hash not associated with a redirect request\n this.logger.info(\"handleRedirectPromise did not detect a response hash as a result of a redirect. Cleaning temporary cache.\");\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\n return null;\n }\n\n let state: string;\n try {\n state = this.validateAndExtractStateFromHash(responseHash, InteractionType.Redirect);\n BrowserUtils.clearHash(window);\n this.logger.verbose(\"State extracted from hash\");\n } catch (e) {\n this.logger.info(`handleRedirectPromise was unable to extract state due to: ${e}`);\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\n return null;\n }\n\n // If navigateToLoginRequestUrl is true, get the url where the redirect request was initiated\n const loginRequestUrl = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, true) || \"\";\n const loginRequestUrlNormalized = UrlString.removeHashFromUrl(loginRequestUrl);\n const currentUrlNormalized = UrlString.removeHashFromUrl(window.location.href);\n\n if (loginRequestUrlNormalized === currentUrlNormalized && this.config.auth.navigateToLoginRequestUrl) {\n // We are on the page we need to navigate to - handle hash\n this.logger.verbose(\"Current page is loginRequestUrl, handling hash\");\n const handleHashResult = await this.handleHash(responseHash, state, serverTelemetryManager);\n\n if (loginRequestUrl.indexOf(\"#\") > -1) {\n // Replace current hash with non-msal hash, if present\n BrowserUtils.replaceHash(loginRequestUrl);\n }\n\n return handleHashResult;\n } else if (!this.config.auth.navigateToLoginRequestUrl) {\n this.logger.verbose(\"NavigateToLoginRequestUrl set to false, handling hash\");\n return this.handleHash(responseHash, state, serverTelemetryManager);\n } else if (!BrowserUtils.isInIframe() || this.config.system.allowRedirectInIframe) {\n /*\n * Returned from authority using redirect - need to perform navigation before processing response\n * Cache the hash to be retrieved after the next redirect\n */\n this.browserStorage.setTemporaryCache(TemporaryCacheKeys.URL_HASH, responseHash, true);\n const navigationOptions: NavigationOptions = {\n apiId: ApiId.handleRedirectPromise,\n timeout: this.config.system.redirectNavigationTimeout,\n noHistory: true\n };\n\n /**\n * Default behavior is to redirect to the start page and not process the hash now. \n * The start page is expected to also call handleRedirectPromise which will process the hash in one of the checks above.\n */ \n let processHashOnRedirect: boolean = true;\n if (!loginRequestUrl || loginRequestUrl === \"null\") {\n // Redirect to home page if login request url is null (real null or the string null)\n const homepage = BrowserUtils.getHomepage();\n // Cache the homepage under ORIGIN_URI to ensure cached hash is processed on homepage\n this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, homepage, true);\n this.logger.warning(\"Unable to get valid login request url from cache, redirecting to home page\");\n processHashOnRedirect = await this.navigationClient.navigateInternal(homepage, navigationOptions);\n } else {\n // Navigate to page that initiated the redirect request\n this.logger.verbose(`Navigating to loginRequestUrl: ${loginRequestUrl}`);\n processHashOnRedirect = await this.navigationClient.navigateInternal(loginRequestUrl, navigationOptions);\n }\n\n // If navigateInternal implementation returns false, handle the hash now\n if (!processHashOnRedirect) {\n return this.handleHash(responseHash, state, serverTelemetryManager);\n }\n }\n\n return null;\n } catch (e) {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\n throw e;\n }\n }\n\n /**\n * Gets the response hash for a redirect request\n * Returns null if interactionType in the state value is not \"redirect\" or the hash does not contain known properties\n * @param hash\n */\n private getRedirectResponseHash(hash: string): string | null {\n this.logger.verbose(\"getRedirectResponseHash called\");\n // Get current location hash from window or cache.\n const isResponseHash: boolean = UrlString.hashContainsKnownProperties(hash);\n const cachedHash = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.URL_HASH, true);\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH));\n\n if (isResponseHash) {\n this.logger.verbose(\"Hash contains known properties, returning response hash\");\n return hash;\n }\n\n this.logger.verbose(\"Hash does not contain known properties, returning cached hash\");\n return cachedHash;\n }\n\n /**\n * Checks if hash exists and handles in window.\n * @param hash\n * @param state\n */\n private async handleHash(hash: string, state: string, serverTelemetryManager: ServerTelemetryManager): Promise<AuthenticationResult> {\n const cachedRequest = this.browserStorage.getCachedRequest(state, this.browserCrypto);\n this.logger.verbose(\"handleHash called, retrieved cached request\");\n\n // Hash contains known properties - handle and return in callback\n const currentAuthority = this.browserStorage.getCachedAuthority(state);\n if (!currentAuthority) {\n throw BrowserAuthError.createNoCachedAuthorityError();\n }\n\n const authClient = await this.createAuthCodeClient(serverTelemetryManager, currentAuthority);\n this.logger.verbose(\"Auth code client created\");\n const interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);\n return await interactionHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient, this.config.auth.clientId);\n }\n\n /**\n * Use to log out the current user, and redirect the user to the postLogoutRedirectUri.\n * Default behaviour is to redirect the user to `window.location.href`.\n * @param logoutRequest\n */\n async logout(logoutRequest?: EndSessionRequest): Promise<void> {\n this.logger.verbose(\"logoutRedirect called\");\n const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.logout);\n\n try {\n this.eventHandler.emitEvent(EventType.LOGOUT_START, InteractionType.Redirect, logoutRequest);\n \n // Clear cache on logout\n await this.clearCacheOnLogout(validLogoutRequest.account);\n \n const navigationOptions: NavigationOptions = {\n apiId: ApiId.logout,\n timeout: this.config.system.redirectNavigationTimeout,\n noHistory: false\n };\n const authClient = await this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority);\n this.logger.verbose(\"Auth code client created\");\n\n // Create logout string and navigate user window to logout.\n const logoutUri: string = authClient.getLogoutUri(validLogoutRequest);\n \n this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, InteractionType.Redirect, validLogoutRequest);\n // Check if onRedirectNavigate is implemented, and invoke it if so\n if (logoutRequest && typeof logoutRequest.onRedirectNavigate === \"function\") {\n const navigate = logoutRequest.onRedirectNavigate(logoutUri);\n\n if (navigate !== false) {\n this.logger.verbose(\"Logout onRedirectNavigate did not return false, navigating\");\n await this.navigationClient.navigateExternal(logoutUri, navigationOptions);\n return;\n } else {\n this.logger.verbose(\"Logout onRedirectNavigate returned false, stopping navigation\");\n }\n } else {\n await this.navigationClient.navigateExternal(logoutUri, navigationOptions);\n return;\n }\n } catch(e) {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, InteractionType.Redirect, null, e);\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Redirect);\n throw e;\n }\n\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Redirect);\n }\n\n /**\n * Use to get the redirectStartPage either from request or use current window\n * @param requestStartPage\n */\n protected getRedirectStartPage(requestStartPage?: string): string {\n const redirectStartPage = requestStartPage || window.location.href;\n return UrlString.getAbsoluteUrl(redirectStartPage, BrowserUtils.getCurrentUri());\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;IAiBoC,kCAAyB;IAA7D;;KAwPC;;;;;IAnPS,qCAAY,GAAlB,UAAmB,OAAwB;;;;;;wBACjC,YAAY,GAA4B,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;wBAC5G,sBAAsB,GAAG,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;;;;wBAIrC,qBAAM,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC,EAAA;;wBAA7G,eAAe,GAAmC,SAA2D;wBAGvE,qBAAM,IAAI,CAAC,oBAAoB,CAAC,sBAAsB,EAAE,YAAY,CAAC,SAAS,CAAC,EAAA;;wBAArH,UAAU,GAA4B,SAA+E;wBAC3H,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;wBAG1C,kBAAkB,GAAG,IAAI,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;wBAG9G,qBAAM,UAAU,CAAC,cAAc,CAAC,YAAY,CAAC,EAAA;;wBAA3D,WAAW,GAAG,SAA6C;wBAE3D,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;wBAC/E,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,0BAAwB,iBAAmB,CAAC,CAAC;wBAG7D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AAE,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAC,CAAC,CAAC;wBACzF,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;wBAC5E,MAAM,GAAC,CAAC;;wBAGZ,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;;;;;KAC/E;;;;;IAMS,6CAAoB,GAA9B,UAA+B,gBAAyB;QACpD,IAAM,iBAAiB,GAAG,gBAAgB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACnE,OAAO,SAAS,CAAC,cAAc,CAAC,iBAAiB,EAAE,YAAY,CAAC,aAAa,EAAE,CAAC,CAAC;KACpF;IACL,qBAAC;AAAD,CAxPA,CAAoC,yBAAyB;;;;"}
|
|
1
|
+
{"version":3,"file":"RedirectClient.js","sources":["../../src/interaction_client/RedirectClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthenticationResult, CommonAuthorizationCodeRequest, AuthorizationCodeClient, UrlString, AuthError, ServerTelemetryManager } from \"@azure/msal-common\";\r\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\r\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\r\nimport { ApiId, InteractionType, TemporaryCacheKeys } from \"../utils/BrowserConstants\";\r\nimport { RedirectHandler } from \"../interaction_handler/RedirectHandler\";\r\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\r\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\r\nimport { EventType } from \"../event/EventType\";\r\nimport { NavigationOptions } from \"../navigation/NavigationOptions\";\r\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\r\nimport { RedirectRequest } from \"../request/RedirectRequest\";\r\n\r\nexport class RedirectClient extends StandardInteractionClient { \r\n /**\r\n * Redirects the page to the /authorize endpoint of the IDP\r\n * @param request \r\n */\r\n async acquireToken(request: RedirectRequest): Promise<void> {\r\n const validRequest: AuthorizationUrlRequest = this.preflightInteractiveRequest(request, InteractionType.Redirect);\r\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenRedirect);\r\n\r\n try {\r\n // Create auth code request and generate PKCE params\r\n const authCodeRequest: CommonAuthorizationCodeRequest = await this.initializeAuthorizationCodeRequest(validRequest);\r\n\r\n // Initialize the client\r\n const authClient: AuthorizationCodeClient = await this.createAuthCodeClient(serverTelemetryManager, validRequest.authority);\r\n this.logger.verbose(\"Auth code client created\");\r\n\r\n // Create redirect interaction handler.\r\n const interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);\r\n\r\n // Create acquire token url.\r\n const navigateUrl = await authClient.getAuthCodeUrl(validRequest);\r\n\r\n const redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);\r\n this.logger.verbosePii(`Redirect start page: ${redirectStartPage}`);\r\n\r\n // Show the UI once the url has been created. Response will come back in the hash, which will be handled in the handleRedirectCallback function.\r\n return await interactionHandler.initiateAuthRequest(navigateUrl, {\r\n navigationClient: this.navigationClient,\r\n redirectTimeout: this.config.system.redirectNavigationTimeout,\r\n redirectStartPage: redirectStartPage,\r\n onRedirectNavigate: request.onRedirectNavigate\r\n });\r\n } catch (e) {\r\n if (e instanceof AuthError) {\r\n e.setCorrelationId(this.correlationId);\r\n }\r\n serverTelemetryManager.cacheFailedRequest(e);\r\n this.browserStorage.cleanRequestByState(validRequest.state);\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Checks if navigateToLoginRequestUrl is set, and:\r\n * - if true, performs logic to cache and navigate\r\n * - if false, handles hash string and parses response\r\n * @param hash\r\n */\r\n async handleRedirectPromise(hash?: string): Promise<AuthenticationResult | null> {\r\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.handleRedirectPromise);\r\n try {\r\n if (!this.browserStorage.isInteractionInProgress(true)) {\r\n this.logger.info(\"handleRedirectPromise called but there is no interaction in progress, returning null.\");\r\n return null;\r\n }\r\n\r\n const responseHash = this.getRedirectResponseHash(hash || window.location.hash);\r\n if (!responseHash) {\r\n // Not a recognized server response hash or hash not associated with a redirect request\r\n this.logger.info(\"handleRedirectPromise did not detect a response hash as a result of a redirect. Cleaning temporary cache.\");\r\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\r\n return null;\r\n }\r\n\r\n let state: string;\r\n try {\r\n state = this.validateAndExtractStateFromHash(responseHash, InteractionType.Redirect);\r\n BrowserUtils.clearHash(window);\r\n this.logger.verbose(\"State extracted from hash\");\r\n } catch (e) {\r\n this.logger.info(`handleRedirectPromise was unable to extract state due to: ${e}`);\r\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\r\n return null;\r\n }\r\n\r\n // If navigateToLoginRequestUrl is true, get the url where the redirect request was initiated\r\n const loginRequestUrl = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, true) || \"\";\r\n const loginRequestUrlNormalized = UrlString.removeHashFromUrl(loginRequestUrl);\r\n const currentUrlNormalized = UrlString.removeHashFromUrl(window.location.href);\r\n\r\n if (loginRequestUrlNormalized === currentUrlNormalized && this.config.auth.navigateToLoginRequestUrl) {\r\n // We are on the page we need to navigate to - handle hash\r\n this.logger.verbose(\"Current page is loginRequestUrl, handling hash\");\r\n const handleHashResult = await this.handleHash(responseHash, state, serverTelemetryManager);\r\n\r\n if (loginRequestUrl.indexOf(\"#\") > -1) {\r\n // Replace current hash with non-msal hash, if present\r\n BrowserUtils.replaceHash(loginRequestUrl);\r\n }\r\n\r\n return handleHashResult;\r\n } else if (!this.config.auth.navigateToLoginRequestUrl) {\r\n this.logger.verbose(\"NavigateToLoginRequestUrl set to false, handling hash\");\r\n return this.handleHash(responseHash, state, serverTelemetryManager);\r\n } else if (!BrowserUtils.isInIframe() || this.config.system.allowRedirectInIframe) {\r\n /*\r\n * Returned from authority using redirect - need to perform navigation before processing response\r\n * Cache the hash to be retrieved after the next redirect\r\n */\r\n this.browserStorage.setTemporaryCache(TemporaryCacheKeys.URL_HASH, responseHash, true);\r\n const navigationOptions: NavigationOptions = {\r\n apiId: ApiId.handleRedirectPromise,\r\n timeout: this.config.system.redirectNavigationTimeout,\r\n noHistory: true\r\n };\r\n\r\n /**\r\n * Default behavior is to redirect to the start page and not process the hash now. \r\n * The start page is expected to also call handleRedirectPromise which will process the hash in one of the checks above.\r\n */ \r\n let processHashOnRedirect: boolean = true;\r\n if (!loginRequestUrl || loginRequestUrl === \"null\") {\r\n // Redirect to home page if login request url is null (real null or the string null)\r\n const homepage = BrowserUtils.getHomepage();\r\n // Cache the homepage under ORIGIN_URI to ensure cached hash is processed on homepage\r\n this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, homepage, true);\r\n this.logger.warning(\"Unable to get valid login request url from cache, redirecting to home page\");\r\n processHashOnRedirect = await this.navigationClient.navigateInternal(homepage, navigationOptions);\r\n } else {\r\n // Navigate to page that initiated the redirect request\r\n this.logger.verbose(`Navigating to loginRequestUrl: ${loginRequestUrl}`);\r\n processHashOnRedirect = await this.navigationClient.navigateInternal(loginRequestUrl, navigationOptions);\r\n }\r\n\r\n // If navigateInternal implementation returns false, handle the hash now\r\n if (!processHashOnRedirect) {\r\n return this.handleHash(responseHash, state, serverTelemetryManager);\r\n }\r\n }\r\n\r\n return null;\r\n } catch (e) {\r\n if (e instanceof AuthError) {\r\n e.setCorrelationId(this.correlationId);\r\n }\r\n serverTelemetryManager.cacheFailedRequest(e);\r\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Redirect);\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the response hash for a redirect request\r\n * Returns null if interactionType in the state value is not \"redirect\" or the hash does not contain known properties\r\n * @param hash\r\n */\r\n private getRedirectResponseHash(hash: string): string | null {\r\n this.logger.verbose(\"getRedirectResponseHash called\");\r\n // Get current location hash from window or cache.\r\n const isResponseHash: boolean = UrlString.hashContainsKnownProperties(hash);\r\n const cachedHash = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.URL_HASH, true);\r\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH));\r\n\r\n if (isResponseHash) {\r\n this.logger.verbose(\"Hash contains known properties, returning response hash\");\r\n return hash;\r\n }\r\n\r\n this.logger.verbose(\"Hash does not contain known properties, returning cached hash\");\r\n return cachedHash;\r\n }\r\n\r\n /**\r\n * Checks if hash exists and handles in window.\r\n * @param hash\r\n * @param state\r\n */\r\n private async handleHash(hash: string, state: string, serverTelemetryManager: ServerTelemetryManager): Promise<AuthenticationResult> {\r\n const cachedRequest = this.browserStorage.getCachedRequest(state, this.browserCrypto);\r\n this.logger.verbose(\"handleHash called, retrieved cached request\");\r\n\r\n // Hash contains known properties - handle and return in callback\r\n const currentAuthority = this.browserStorage.getCachedAuthority(state);\r\n if (!currentAuthority) {\r\n throw BrowserAuthError.createNoCachedAuthorityError();\r\n }\r\n\r\n const authClient = await this.createAuthCodeClient(serverTelemetryManager, currentAuthority);\r\n this.logger.verbose(\"Auth code client created\");\r\n const interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);\r\n return await interactionHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient, this.config.auth.clientId);\r\n }\r\n\r\n /**\r\n * Use to log out the current user, and redirect the user to the postLogoutRedirectUri.\r\n * Default behaviour is to redirect the user to `window.location.href`.\r\n * @param logoutRequest\r\n */\r\n async logout(logoutRequest?: EndSessionRequest): Promise<void> {\r\n this.logger.verbose(\"logoutRedirect called\");\r\n const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);\r\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.logout);\r\n\r\n try {\r\n this.eventHandler.emitEvent(EventType.LOGOUT_START, InteractionType.Redirect, logoutRequest);\r\n \r\n // Clear cache on logout\r\n await this.clearCacheOnLogout(validLogoutRequest.account);\r\n \r\n const navigationOptions: NavigationOptions = {\r\n apiId: ApiId.logout,\r\n timeout: this.config.system.redirectNavigationTimeout,\r\n noHistory: false\r\n };\r\n const authClient = await this.createAuthCodeClient(serverTelemetryManager, logoutRequest && logoutRequest.authority);\r\n this.logger.verbose(\"Auth code client created\");\r\n\r\n // Create logout string and navigate user window to logout.\r\n const logoutUri: string = authClient.getLogoutUri(validLogoutRequest);\r\n \r\n this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, InteractionType.Redirect, validLogoutRequest);\r\n // Check if onRedirectNavigate is implemented, and invoke it if so\r\n if (logoutRequest && typeof logoutRequest.onRedirectNavigate === \"function\") {\r\n const navigate = logoutRequest.onRedirectNavigate(logoutUri);\r\n\r\n if (navigate !== false) {\r\n this.logger.verbose(\"Logout onRedirectNavigate did not return false, navigating\");\r\n await this.navigationClient.navigateExternal(logoutUri, navigationOptions);\r\n return;\r\n } else {\r\n this.logger.verbose(\"Logout onRedirectNavigate returned false, stopping navigation\");\r\n }\r\n } else {\r\n await this.navigationClient.navigateExternal(logoutUri, navigationOptions);\r\n return;\r\n }\r\n } catch(e) {\r\n if (e instanceof AuthError) {\r\n e.setCorrelationId(this.correlationId);\r\n }\r\n serverTelemetryManager.cacheFailedRequest(e);\r\n this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, InteractionType.Redirect, null, e);\r\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Redirect);\r\n throw e;\r\n }\r\n\r\n this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Redirect);\r\n }\r\n\r\n /**\r\n * Use to get the redirectStartPage either from request or use current window\r\n * @param requestStartPage\r\n */\r\n protected getRedirectStartPage(requestStartPage?: string): string {\r\n const redirectStartPage = requestStartPage || window.location.href;\r\n return UrlString.getAbsoluteUrl(redirectStartPage, BrowserUtils.getCurrentUri());\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;IAiBoC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9B,UAA+B,gBAAyB;QACpD,IAAM,iBAAiB,GAAG,gBAAgB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACnE,OAAO,SAAS,CAAC,cAAc,CAAC,iBAAiB,EAAE,YAAY,CAAC,aAAa,EAAE,CAAC,CAAC;KACpF;IACL,qBAAC;AAAD,CAxPA,CAAoC,yBAAyB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.19.
|
|
1
|
+
/*! @azure/msal-browser v2.19.1 2022-08-03 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { StandardInteractionClient } from './StandardInteractionClient.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentCacheClient.js","sources":["../../src/interaction_client/SilentCacheClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { CommonSilentFlowRequest, AuthenticationResult, SilentFlowClient, ServerTelemetryManager, AccountInfo } from \"@azure/msal-common\";\nimport { SilentRequest } from \"../request/SilentRequest\";\nimport { EventType } from \"../event/EventType\";\nimport { InteractionType, ApiId } from \"../utils/BrowserConstants\";\nimport { BrowserAuthError, BrowserAuthErrorMessage } from \"../error/BrowserAuthError\";\n\nexport class SilentCacheClient extends StandardInteractionClient {\n /**\n * Returns unexpired tokens from the cache, if available\n * @param silentRequest \n */\n async acquireToken(silentRequest: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n // Telemetry manager only used to increment cacheHits here\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);\n const silentAuthClient = await this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority);\n this.logger.verbose(\"Silent auth client created\");\n \n try {\n const cachedToken = await silentAuthClient.acquireCachedToken(silentRequest);\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, cachedToken);\n return cachedToken;\n } catch (error) {\n if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {\n this.logger.verbose(\"Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.\");\n }\n throw error;\n }\n }\n \n /**\n * Currently Unsupported\n */\n logout(): Promise<void> {\n // Synchronous so we must reject\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\n }\n\n /**\n * Creates an Silent Flow Client with the given authority, or the default authority.\n * @param serverTelemetryManager\n * @param authorityUrl\n */\n protected async createSilentFlowClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<SilentFlowClient> {\n // Create auth module.\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl);\n return new SilentFlowClient(clientConfig);\n }\n\n initializeSilentRequest(request: SilentRequest, account: AccountInfo): CommonSilentFlowRequest {\n return {\n ...request,\n ...this.initializeBaseRequest(request),\n account: account,\n forceRefresh: request.forceRefresh || false\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;IAYuC,qCAAyB;IAAhE;;KAkDC;;;;;IA7CS,wCAAY,GAAlB,UAAmB,aAAsC;;;;;;wBAE/C,sBAAsB,GAAG,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;wBACjF,qBAAM,IAAI,CAAC,sBAAsB,CAAC,sBAAsB,EAAE,aAAa,CAAC,SAAS,CAAC,EAAA;;wBAArG,gBAAgB,GAAG,SAAkF;wBAC3G,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;;;;wBAG1B,qBAAM,gBAAgB,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAA;;wBAAtE,WAAW,GAAG,SAAwD;wBAC5E,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,qBAAqB,EAAE,eAAe,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;wBAClG,sBAAO,WAAW,EAAC;;;wBAEnB,IAAI,OAAK,YAAY,gBAAgB,IAAI,OAAK,CAAC,SAAS,KAAK,uBAAuB,CAAC,2BAA2B,CAAC,IAAI,EAAE;4BACnH,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sHAAsH,CAAC,CAAC;yBAC/I;wBACD,MAAM,OAAK,CAAC;;;;;KAEnB;;;;IAKD,kCAAM,GAAN;;QAEI,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,kCAAkC,EAAE,CAAC,CAAC;KAChF;;;;;;IAOe,kDAAsB,GAAtC,UAAuC,sBAA8C,EAAE,YAAqB;;;;;4BAEnF,qBAAM,IAAI,CAAC,sBAAsB,CAAC,sBAAsB,EAAE,YAAY,CAAC,EAAA;;wBAAtF,YAAY,GAAG,SAAuE;wBAC5F,sBAAO,IAAI,gBAAgB,CAAC,YAAY,CAAC,EAAC;;;;KAC7C;IAED,mDAAuB,GAAvB,UAAwB,OAAsB,EAAE,OAAoB;QAChE,sCACO,OAAO,GACP,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,KACtC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK,IAC7C;KACL;IACL,wBAAC;AAAD,CAlDA,CAAuC,yBAAyB;;;;"}
|
|
1
|
+
{"version":3,"file":"SilentCacheClient.js","sources":["../../src/interaction_client/SilentCacheClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\r\nimport { CommonSilentFlowRequest, AuthenticationResult, SilentFlowClient, ServerTelemetryManager, AccountInfo } from \"@azure/msal-common\";\r\nimport { SilentRequest } from \"../request/SilentRequest\";\r\nimport { EventType } from \"../event/EventType\";\r\nimport { InteractionType, ApiId } from \"../utils/BrowserConstants\";\r\nimport { BrowserAuthError, BrowserAuthErrorMessage } from \"../error/BrowserAuthError\";\r\n\r\nexport class SilentCacheClient extends StandardInteractionClient {\r\n /**\r\n * Returns unexpired tokens from the cache, if available\r\n * @param silentRequest \r\n */\r\n async acquireToken(silentRequest: CommonSilentFlowRequest): Promise<AuthenticationResult> {\r\n // Telemetry manager only used to increment cacheHits here\r\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);\r\n const silentAuthClient = await this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority);\r\n this.logger.verbose(\"Silent auth client created\");\r\n \r\n try {\r\n const cachedToken = await silentAuthClient.acquireCachedToken(silentRequest);\r\n this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Silent, cachedToken);\r\n return cachedToken;\r\n } catch (error) {\r\n if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {\r\n this.logger.verbose(\"Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.\");\r\n }\r\n throw error;\r\n }\r\n }\r\n \r\n /**\r\n * Currently Unsupported\r\n */\r\n logout(): Promise<void> {\r\n // Synchronous so we must reject\r\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\r\n }\r\n\r\n /**\r\n * Creates an Silent Flow Client with the given authority, or the default authority.\r\n * @param serverTelemetryManager\r\n * @param authorityUrl\r\n */\r\n protected async createSilentFlowClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<SilentFlowClient> {\r\n // Create auth module.\r\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl);\r\n return new SilentFlowClient(clientConfig);\r\n }\r\n\r\n initializeSilentRequest(request: SilentRequest, account: AccountInfo): CommonSilentFlowRequest {\r\n return {\r\n ...request,\r\n ...this.initializeBaseRequest(request),\r\n account: account,\r\n forceRefresh: request.forceRefresh || false\r\n };\r\n }\r\n}\r\n"],"names":[],"mapp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AC,qBAAqB,CAAC,OAAO,CAAC,KACtC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK,IAC7C;KACL;IACL,wBAAC;AAAD,CAlDA,CAAuC,yBAAyB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.19.
|
|
1
|
+
/*! @azure/msal-browser v2.19.1 2022-08-03 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { AuthError, StringUtils, PromptValue } from '@azure/msal-common';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentIframeClient.js","sources":["../../src/interaction_client/SilentIframeClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AuthenticationResult, ICrypto, Logger, StringUtils, PromptValue, CommonAuthorizationCodeRequest, AuthorizationCodeClient, AuthError } from \"@azure/msal-common\";\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\nimport { BrowserConfiguration } from \"../config/Configuration\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { EventHandler } from \"../event/EventHandler\";\nimport { INavigationClient } from \"../navigation/INavigationClient\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { InteractionType, ApiId } from \"../utils/BrowserConstants\";\nimport { SilentHandler } from \"../interaction_handler/SilentHandler\";\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\n\nexport class SilentIframeClient extends StandardInteractionClient {\n private apiId: ApiId;\n\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, apiId: ApiId, correlationId?: string) {\n super(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId);\n this.apiId = apiId;\n }\n \n /**\n * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none\n * @param request \n */\n async acquireToken(request: SsoSilentRequest): Promise<AuthenticationResult> {\n this.logger.verbose(\"acquireTokenByIframe called\");\n // Check that we have some SSO data\n if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {\n this.logger.warning(\"No user hint provided. The authorization server may need more information to complete this request.\");\n }\n\n // Check that prompt is set to none, throw error if it is set to anything else.\n if (request.prompt && request.prompt !== PromptValue.NONE) {\n throw BrowserAuthError.createSilentPromptValueError(request.prompt);\n }\n\n // Create silent request\n const silentRequest: AuthorizationUrlRequest = this.initializeAuthorizationRequest({\n ...request,\n prompt: PromptValue.NONE\n }, InteractionType.Silent);\n\n const serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);\n\n try {\n // Create auth code request and generate PKCE params\n const authCodeRequest: CommonAuthorizationCodeRequest = await this.initializeAuthorizationCodeRequest(silentRequest);\n\n // Initialize the client\n const authClient: AuthorizationCodeClient = await this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority);\n this.logger.verbose(\"Auth code client created\");\n\n // Create authorize request url\n const navigateUrl = await authClient.getAuthCodeUrl(silentRequest);\n\n return await this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger);\n } catch (e) {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n this.browserStorage.cleanRequestByState(silentRequest.state);\n throw e;\n }\n }\n\n /**\n * Currently Unsupported\n */\n logout(): Promise<void> {\n // Synchronous so we must reject\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\n }\n\n /**\n * Helper which acquires an authorization code silently using a hidden iframe from given url\n * using the scopes requested as part of the id, and exchanges the code for a set of OAuth tokens.\n * @param navigateUrl\n * @param userRequestScopes\n */\n private async silentTokenHelper(navigateUrl: string, authCodeRequest: CommonAuthorizationCodeRequest, authClient: AuthorizationCodeClient, browserRequestLogger: Logger): Promise<AuthenticationResult> {\n // Create silent handler\n const silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, browserRequestLogger, this.config.system.navigateFrameWait);\n // Get the frame handle for the silent request\n const msalFrame = await silentHandler.initiateAuthRequest(navigateUrl);\n // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.\n const hash = await silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout);\n const state = this.validateAndExtractStateFromHash(hash, InteractionType.Silent, authCodeRequest.correlationId);\n\n // Handle response from hash string\n return silentHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;IAiBwC,sCAAyB;IAG7D,4BAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,gBAAmC,EAAE,KAAY,EAAE,aAAsB;QAAzN,YACI,kBAAM,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,CAAC,SAEnG;QADG,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;;KACtB;;;;;IAMK,yCAAY,GAAlB,UAAmB,OAAyB;;;;;;wBACxC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;;wBAEnD,IAAI,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE;4BACnJ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,qGAAqG,CAAC,CAAC;yBAC9H;;wBAGD,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,KA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C,WAAmB,EAAE,eAA+C,EAAE,UAAmC,EAAE,oBAA4B;;;;;;wBAE7J,aAAa,GAAG,IAAI,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE,eAAe,EAAE,oBAAoB,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;wBAEpI,qBAAM,aAAa,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAA;;wBAAhE,SAAS,GAAG,SAAoD;wBAEzD,qBAAM,aAAa,CAAC,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAA;;wBAAhG,IAAI,GAAG,SAAyF;wBAChG,KAAK,GAAG,IAAI,CAAC,+BAA+B,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;;wBAGhH,sBAAO,aAAa,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,EAAC;;;;KAClG;IACL,yBAAC;AAAD,CAhFA,CAAwC,yBAAyB;;;;"}
|
|
1
|
+
{"version":3,"file":"SilentIframeClient.js","sources":["../../src/interaction_client/SilentIframeClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthenticationResult, ICrypto, Logger, StringUtils, PromptValue, CommonAuthorizationCodeRequest, AuthorizationCodeClient, AuthError } from \"@azure/msal-common\";\r\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\r\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\r\nimport { BrowserConfiguration } from \"../config/Configuration\";\r\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\r\nimport { EventHandler } from \"../event/EventHandler\";\r\nimport { INavigationClient } from \"../navigation/INavigationClient\";\r\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\r\nimport { InteractionType, ApiId } from \"../utils/BrowserConstants\";\r\nimport { SilentHandler } from \"../interaction_handler/SilentHandler\";\r\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\r\n\r\nexport class SilentIframeClient extends StandardInteractionClient {\r\n private apiId: ApiId;\r\n\r\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, apiId: ApiId, correlationId?: string) {\r\n super(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId);\r\n this.apiId = apiId;\r\n }\r\n \r\n /**\r\n * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none\r\n * @param request \r\n */\r\n async acquireToken(request: SsoSilentRequest): Promise<AuthenticationResult> {\r\n this.logger.verbose(\"acquireTokenByIframe called\");\r\n // Check that we have some SSO data\r\n if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {\r\n this.logger.warning(\"No user hint provided. The authorization server may need more information to complete this request.\");\r\n }\r\n\r\n // Check that prompt is set to none, throw error if it is set to anything else.\r\n if (request.prompt && request.prompt !== PromptValue.NONE) {\r\n throw BrowserAuthError.createSilentPromptValueError(request.prompt);\r\n }\r\n\r\n // Create silent request\r\n const silentRequest: AuthorizationUrlRequest = this.initializeAuthorizationRequest({\r\n ...request,\r\n prompt: PromptValue.NONE\r\n }, InteractionType.Silent);\r\n\r\n const serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);\r\n\r\n try {\r\n // Create auth code request and generate PKCE params\r\n const authCodeRequest: CommonAuthorizationCodeRequest = await this.initializeAuthorizationCodeRequest(silentRequest);\r\n\r\n // Initialize the client\r\n const authClient: AuthorizationCodeClient = await this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority);\r\n this.logger.verbose(\"Auth code client created\");\r\n\r\n // Create authorize request url\r\n const navigateUrl = await authClient.getAuthCodeUrl(silentRequest);\r\n\r\n return await this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger);\r\n } catch (e) {\r\n if (e instanceof AuthError) {\r\n e.setCorrelationId(this.correlationId);\r\n }\r\n serverTelemetryManager.cacheFailedRequest(e);\r\n this.browserStorage.cleanRequestByState(silentRequest.state);\r\n throw e;\r\n }\r\n }\r\n\r\n /**\r\n * Currently Unsupported\r\n */\r\n logout(): Promise<void> {\r\n // Synchronous so we must reject\r\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\r\n }\r\n\r\n /**\r\n * Helper which acquires an authorization code silently using a hidden iframe from given url\r\n * using the scopes requested as part of the id, and exchanges the code for a set of OAuth tokens.\r\n * @param navigateUrl\r\n * @param userRequestScopes\r\n */\r\n private async silentTokenHelper(navigateUrl: string, authCodeRequest: CommonAuthorizationCodeRequest, authClient: AuthorizationCodeClient, browserRequestLogger: Logger): Promise<AuthenticationResult> {\r\n // Create silent handler\r\n const silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, browserRequestLogger, this.config.system.navigateFrameWait);\r\n // Get the frame handle for the silent request\r\n const msalFrame = await silentHandler.initiateAuthRequest(navigateUrl);\r\n // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.\r\n const hash = await silentHandler.monitorIframeForHash(msalFrame, this.config.system.iframeHashTimeout);\r\n const state = this.validateAndExtractStateFromHash(hash, InteractionType.Silent, authCodeRequest.correlationId);\r\n\r\n // Handle response from hash string\r\n return silentHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;IAiBwC,sCAAyB;IAG7D,4BAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,gBAAmC,EAAE,KAAY,EAAE,aAAsB;QAAzN,YACI,kBAAM,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,E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;;;KAClG;IACL,yBAAC;AAAD,CAhFA,CAAwC,yBAAyB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.19.
|
|
1
|
+
/*! @azure/msal-browser v2.19.1 2022-08-03 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { StandardInteractionClient } from './StandardInteractionClient.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentRefreshClient.js","sources":["../../src/interaction_client/SilentRefreshClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { CommonSilentFlowRequest, AuthenticationResult, ServerTelemetryManager, RefreshTokenClient, AuthError } from \"@azure/msal-common\";\nimport { ApiId } from \"../utils/BrowserConstants\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\n\nexport class SilentRefreshClient extends StandardInteractionClient {\n /**\n * Exchanges the refresh token for new tokens\n * @param request \n */\n async acquireToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\n const silentRequest: CommonSilentFlowRequest = {\n ...request,\n ...this.initializeBaseRequest(request)\n };\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);\n const refreshTokenClient = await this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority);\n this.logger.verbose(\"Refresh token client created\");\n \n // Send request to renew token. Auth module will throw errors if token cannot be renewed.\n return refreshTokenClient.acquireTokenByRefreshToken(silentRequest).catch(e => {\n if (e instanceof AuthError) {\n e.setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n throw e;\n });\n }\n\n /**\n * Currently Unsupported\n */\n logout(): Promise<void> {\n // Synchronous so we must reject\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\n }\n\n /**\n * Creates a Refresh Client with the given authority, or the default authority.\n * @param serverTelemetryManager\n * @param authorityUrl\n */\n protected async createRefreshTokenClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<RefreshTokenClient> {\n // Create auth module.\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl);\n return new RefreshTokenClient(clientConfig);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IAUyC,uCAAyB;IAAlE;;KA0CC;;;;;IArCS,0CAAY,GAAlB,UAAmB,OAAgC;;;;;;;wBACzC,aAAa,yBACZ,OAAO,GACP,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CACzC,CAAC;wBACI,sBAAsB,GAAG,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;wBAC/E,qBAAM,IAAI,CAAC,wBAAwB,CAAC,sBAAsB,EAAE,aAAa,CAAC,SAAS,CAAC,EAAA;;wBAAzG,kBAAkB,GAAG,SAAoF;wBAC/G,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;;wBAGpD,sBAAO,kBAAkB,CAAC,0BAA0B,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,UAAA,CAAC;gCACvE,IAAI,CAAC,YAAY,SAAS,EAAE;oCACxB,CAAC,CAAC,gBAAgB,CAAC,KAAI,CAAC,aAAa,CAAC,CAAC;iCAC1C;gCACD,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;gCAC7C,MAAM,CAAC,CAAC;6BACX,CAAC,EAAC;;;;KACN;;;;IAKD,oCAAM,GAAN;;QAEI,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,kCAAkC,EAAE,CAAC,CAAC;KAChF;;;;;;IAOe,sDAAwB,GAAxC,UAAyC,sBAA8C,EAAE,YAAqB;;;;;4BAErF,qBAAM,IAAI,CAAC,sBAAsB,CAAC,sBAAsB,EAAE,YAAY,CAAC,EAAA;;wBAAtF,YAAY,GAAG,SAAuE;wBAC5F,sBAAO,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAC;;;;KAC/C;IACL,0BAAC;AAAD,CA1CA,CAAyC,yBAAyB;;;;"}
|
|
1
|
+
{"version":3,"file":"SilentRefreshClient.js","sources":["../../src/interaction_client/SilentRefreshClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\r\nimport { CommonSilentFlowRequest, AuthenticationResult, ServerTelemetryManager, RefreshTokenClient, AuthError } from \"@azure/msal-common\";\r\nimport { ApiId } from \"../utils/BrowserConstants\";\r\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\r\n\r\nexport class SilentRefreshClient extends StandardInteractionClient {\r\n /**\r\n * Exchanges the refresh token for new tokens\r\n * @param request \r\n */\r\n async acquireToken(request: CommonSilentFlowRequest): Promise<AuthenticationResult> {\r\n const silentRequest: CommonSilentFlowRequest = {\r\n ...request,\r\n ...this.initializeBaseRequest(request)\r\n };\r\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);\r\n const refreshTokenClient = await this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority);\r\n this.logger.verbose(\"Refresh token client created\");\r\n \r\n // Send request to renew token. Auth module will throw errors if token cannot be renewed.\r\n return refreshTokenClient.acquireTokenByRefreshToken(silentRequest).catch(e => {\r\n if (e instanceof AuthError) {\r\n e.setCorrelationId(this.correlationId);\r\n }\r\n serverTelemetryManager.cacheFailedRequest(e);\r\n throw e;\r\n });\r\n }\r\n\r\n /**\r\n * Currently Unsupported\r\n */\r\n logout(): Promise<void> {\r\n // Synchronous so we must reject\r\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\r\n }\r\n\r\n /**\r\n * Creates a Refresh Client with the given authority, or the default authority.\r\n * @param serverTelemetryManager\r\n * @param authorityUrl\r\n */\r\n protected async createRefreshTokenClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<RefreshTokenClient> {\r\n // Create auth module.\r\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl);\r\n return new RefreshTokenClient(clientConfig);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IAUyC,uCAAyB;IAAlE;;KA0CC;;;;;IArCS,0CAAY,GAAlB,UAAmB,OAAgC;;;;;;;wBACzC,aAAa,yBACZ,OAAO,GACP,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,CACzC,CAAC;wBACI,sBAAsB,GAAG,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;wBAC/E,qBAAM,IAAI,CAAC,wBAAwB,CAAC,sBAAsB,EAAE,aAAa,CAAC,SAAS,CAAC,EAAA;;wBAAzG,kBAAkB,GAAG,SAAoF;wBAC/G,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;;wBAGpD,sBAAO,kBAAkB,CAAC,0BAA0B,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,UAAA,CAAC;gCACvE,IAAI,CAAC,YAAY,SAAS,EAAE;oCACxB,CAAC,CAAC,gBAAgB,CAAC,KAAI,CAAC,aAAa,CAAC,CAAC;iCAC1C;gCACD,sBAAsB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;gCAC7C,MAAM,CAAC,CAAC;6BACX,CAAC,EAAC;;;;KACN;;;;IAKD,oCAAM,GAAN;;QAEI,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,kCAAkC,EAAE,CAAC,CAAC;KAChF;;;;;;IAOe,sDAAwB,GAAxC,UAAyC,sBAA8C,EAAE,YAAqB;;;;;4BAErF,qBAAM,IAAI,CAAC,sBAAsB,CAAC,sBAAsB,EAAE,YAAY,CAAC,EAAA;;wBAAtF,YAAY,GAAG,SAAuE;wBAC5F,sBAAO,IAAI,kBAAkB,CAAC,YAAY,CAAC,EAAC;;;;KAC/C;IACL,0BAAC;AAAD,CA1CA,CAAyC,yBAAyB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-browser v2.19.
|
|
1
|
+
/*! @azure/msal-browser v2.19.1 2022-08-03 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
|
|
4
4
|
import { Constants, UrlString, AuthorizationCodeClient, AuthorityFactory, ProtocolUtils, ResponseMode, StringUtils } from '@azure/msal-common';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StandardInteractionClient.js","sources":["../../src/interaction_client/StandardInteractionClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICrypto, Logger, ServerTelemetryManager, CommonAuthorizationCodeRequest, Constants, AuthorizationCodeClient, ClientConfiguration, AuthorityOptions, Authority, AuthorityFactory, ServerAuthorizationCodeResponse, UrlString, CommonEndSessionRequest, ProtocolUtils, ResponseMode, StringUtils } from \"@azure/msal-common\";\nimport { BaseInteractionClient } from \"./BaseInteractionClient\";\nimport { BrowserConfiguration } from \"../config/Configuration\";\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { EventHandler } from \"../event/EventHandler\";\nimport { BrowserConstants, InteractionType } from \"../utils/BrowserConstants\";\nimport { version } from \"../packageMetadata\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { BrowserProtocolUtils, BrowserStateObject } from \"../utils/BrowserProtocolUtils\";\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\nimport { INavigationClient } from \"../navigation/INavigationClient\";\nimport { RedirectRequest } from \"../request/RedirectRequest\";\nimport { PopupRequest } from \"../request/PopupRequest\";\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\n\n/**\n * Defines the class structure and helper functions used by the \"standard\", non-brokered auth flows (popup, redirect, silent (RT), silent (iframe))\n */\nexport abstract class StandardInteractionClient extends BaseInteractionClient {\n protected navigationClient: INavigationClient;\n\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, correlationId?: string) {\n super(config, storageImpl, browserCrypto, logger, eventHandler, correlationId);\n this.navigationClient = navigationClient;\n }\n \n /**\n * Generates an auth code request tied to the url request.\n * @param request\n */\n protected async initializeAuthorizationCodeRequest(request: AuthorizationUrlRequest): Promise<CommonAuthorizationCodeRequest> {\n this.logger.verbose(\"initializeAuthorizationRequest called\", request.correlationId);\n const generatedPkceParams = await this.browserCrypto.generatePkceCodes();\n\n const authCodeRequest: CommonAuthorizationCodeRequest = {\n ...request,\n redirectUri: request.redirectUri,\n code: \"\",\n codeVerifier: generatedPkceParams.verifier\n };\n\n request.codeChallenge = generatedPkceParams.challenge;\n request.codeChallengeMethod = Constants.S256_CODE_CHALLENGE_METHOD;\n\n return authCodeRequest;\n }\n\n /**\n * Initializer for the logout request.\n * @param logoutRequest\n */\n protected initializeLogoutRequest(logoutRequest?: EndSessionRequest): CommonEndSessionRequest {\n this.logger.verbose(\"initializeLogoutRequest called\", logoutRequest?.correlationId);\n\n // Check if interaction is in progress. Throw error if true.\n if (this.browserStorage.isInteractionInProgress()) {\n throw BrowserAuthError.createInteractionInProgressError();\n }\n\n const validLogoutRequest: CommonEndSessionRequest = {\n correlationId: this.browserCrypto.createNewGuid(),\n ...logoutRequest\n };\n\n /*\n * Only set redirect uri if logout request isn't provided or the set uri isn't null.\n * Otherwise, use passed uri, config, or current page.\n */\n if (!logoutRequest || logoutRequest.postLogoutRedirectUri !== null) {\n if (logoutRequest && logoutRequest.postLogoutRedirectUri) {\n this.logger.verbose(\"Setting postLogoutRedirectUri to uri set on logout request\", validLogoutRequest.correlationId);\n validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(logoutRequest.postLogoutRedirectUri, BrowserUtils.getCurrentUri());\n } else if (this.config.auth.postLogoutRedirectUri === null) {\n this.logger.verbose(\"postLogoutRedirectUri configured as null and no uri set on request, not passing post logout redirect\", validLogoutRequest.correlationId);\n } else if (this.config.auth.postLogoutRedirectUri) {\n this.logger.verbose(\"Setting postLogoutRedirectUri to configured uri\", validLogoutRequest.correlationId);\n validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(this.config.auth.postLogoutRedirectUri, BrowserUtils.getCurrentUri());\n } else {\n this.logger.verbose(\"Setting postLogoutRedirectUri to current page\", validLogoutRequest.correlationId);\n validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(BrowserUtils.getCurrentUri(), BrowserUtils.getCurrentUri());\n }\n } else {\n this.logger.verbose(\"postLogoutRedirectUri passed as null, not setting post logout redirect uri\", validLogoutRequest.correlationId);\n }\n\n return validLogoutRequest;\n }\n\n /**\n * Creates an Authorization Code Client with the given authority, or the default authority.\n * @param serverTelemetryManager\n * @param authorityUrl\n */\n protected async createAuthCodeClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<AuthorizationCodeClient> {\n // Create auth module.\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl);\n return new AuthorizationCodeClient(clientConfig);\n }\n\n /**\n * Creates a Client Configuration object with the given request authority, or the default authority.\n * @param serverTelemetryManager\n * @param requestAuthority\n * @param requestCorrelationId\n */\n protected async getClientConfiguration(serverTelemetryManager: ServerTelemetryManager, requestAuthority?: string): Promise<ClientConfiguration> {\n this.logger.verbose(\"getClientConfiguration called\");\n const discoveredAuthority = await this.getDiscoveredAuthority(requestAuthority);\n\n return {\n authOptions: {\n clientId: this.config.auth.clientId,\n authority: discoveredAuthority,\n clientCapabilities: this.config.auth.clientCapabilities\n },\n systemOptions: {\n tokenRenewalOffsetSeconds: this.config.system.tokenRenewalOffsetSeconds,\n preventCorsPreflight: true\n },\n loggerOptions: {\n loggerCallback: this.config.system.loggerOptions.loggerCallback,\n piiLoggingEnabled: this.config.system.loggerOptions.piiLoggingEnabled,\n logLevel: this.config.system.loggerOptions.logLevel,\n correlationId: this.correlationId\n },\n cryptoInterface: this.browserCrypto,\n networkInterface: this.networkClient,\n storageInterface: this.browserStorage,\n serverTelemetryManager: serverTelemetryManager,\n libraryInfo: {\n sku: BrowserConstants.MSAL_SKU,\n version: version,\n cpu: \"\",\n os: \"\"\n }\n };\n }\n\n /**\n * @param hash\n * @param interactionType\n */\n protected validateAndExtractStateFromHash(hash: string, interactionType: InteractionType, requestCorrelationId?: string): string {\n this.logger.verbose(\"validateAndExtractStateFromHash called\", requestCorrelationId);\n // Deserialize hash fragment response parameters.\n const serverParams: ServerAuthorizationCodeResponse = UrlString.getDeserializedHash(hash);\n if (!serverParams.state) {\n throw BrowserAuthError.createHashDoesNotContainStateError();\n }\n\n const platformStateObj = BrowserProtocolUtils.extractBrowserRequestState(this.browserCrypto, serverParams.state);\n if (!platformStateObj) {\n throw BrowserAuthError.createUnableToParseStateError();\n }\n\n if (platformStateObj.interactionType !== interactionType) {\n throw BrowserAuthError.createStateInteractionTypeMismatchError();\n }\n\n this.logger.verbose(\"Returning state from hash\", requestCorrelationId);\n return serverParams.state;\n }\n\n /**\n * Used to get a discovered version of the default authority.\n * @param requestAuthority\n * @param requestCorrelationId\n */\n protected async getDiscoveredAuthority(requestAuthority?: string): Promise<Authority> {\n this.logger.verbose(\"getDiscoveredAuthority called\");\n const authorityOptions: AuthorityOptions = {\n protocolMode: this.config.auth.protocolMode,\n knownAuthorities: this.config.auth.knownAuthorities,\n cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,\n authorityMetadata: this.config.auth.authorityMetadata\n };\n\n if (requestAuthority) {\n this.logger.verbose(\"Creating discovered authority with request authority\");\n return await AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions);\n }\n\n this.logger.verbose(\"Creating discovered authority with configured authority\");\n return await AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions);\n }\n\n /**\n * Helper to validate app environment before making a request.\n * @param request\n * @param interactionType\n */\n protected preflightInteractiveRequest(request: RedirectRequest|PopupRequest, interactionType: InteractionType): AuthorizationUrlRequest {\n this.logger.verbose(\"preflightInteractiveRequest called, validating app environment\", request?.correlationId);\n // block the reload if it occurred inside a hidden iframe\n BrowserUtils.blockReloadInHiddenIframes();\n \n // Check if interaction is in progress. Throw error if true.\n if (this.browserStorage.isInteractionInProgress(false)) {\n throw BrowserAuthError.createInteractionInProgressError();\n }\n \n return this.initializeAuthorizationRequest(request, interactionType);\n }\n\n /**\n * Helper to initialize required request parameters for interactive APIs and ssoSilent()\n * @param request\n * @param interactionType\n */\n protected initializeAuthorizationRequest(request: RedirectRequest|PopupRequest|SsoSilentRequest, interactionType: InteractionType): AuthorizationUrlRequest {\n this.logger.verbose(\"initializeAuthorizationRequest called\");\n const redirectUri = this.getRedirectUri(request.redirectUri);\n const browserState: BrowserStateObject = {\n interactionType: interactionType\n };\n\n const state = ProtocolUtils.setRequestState(\n this.browserCrypto,\n (request && request.state) || \"\",\n browserState\n );\n\n const validatedRequest: AuthorizationUrlRequest = {\n ...this.initializeBaseRequest(request),\n redirectUri: redirectUri,\n state: state,\n nonce: request.nonce || this.browserCrypto.createNewGuid(),\n responseMode: ResponseMode.FRAGMENT\n };\n\n const account = request.account || this.browserStorage.getActiveAccount();\n if (account) {\n this.logger.verbose(\"Setting validated request account\");\n this.logger.verbosePii(`Setting validated request account: ${account}`);\n validatedRequest.account = account;\n }\n\n // Check for ADAL/MSAL v1 SSO\n if (StringUtils.isEmpty(validatedRequest.loginHint) && !account) {\n const legacyLoginHint = this.browserStorage.getLegacyLoginHint();\n if (legacyLoginHint) {\n validatedRequest.loginHint = legacyLoginHint;\n }\n }\n\n this.browserStorage.updateCacheEntries(validatedRequest.state, validatedRequest.nonce, validatedRequest.authority, validatedRequest.loginHint || \"\", validatedRequest.account || null);\n\n return validatedRequest;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;AAsBA;;;;IAGwD,6CAAqB;IAGzE,mCAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,gBAAmC,EAAE,aAAsB;QAA3M,YACI,kBAAM,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,SAEjF;QADG,KAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;;KAC5C;;;;;IAMe,sEAAkC,GAAlD,UAAmD,OAAgC;;;;;;wBAC/E,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,uCAAuC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;wBACxD,qBAAM,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,EAAA;;wBAAlE,mBAAmB,GAAG,SAA4C;wBAElE,eAAe,yBACd,OAAO,KACV,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,IAAI,EAAE,EAAE,EACR,YAAY,EAAE,mBAAmB,CAAC,QAAQ,GAC7C,CAAC;wBAEF,OAAO,CAAC,aAAa,GAAG,mBAAmB,CAAC,SAAS,CAAC;wBACtD,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,0BAA0B,CAAC;wBAEnE,sBAAO,eAAe,EAAC;;;;KAC1B;;;;;IAMS,2DAAuB,GAAjC,UAAkC,aAAiC;QAC/D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,gCAAgC,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,aAAa,CAAC,CAAC;;QAGpF,IAAI,IAAI,CAAC,cAAc,CAAC,uBAAuB,EAAE,EAAE;YAC/C,MAAM,gBAAgB,CAAC,gCAAgC,EAAE,CAAC;SAC7D;QAED,IAAM,kBAAkB,cACpB,aAAa,EAAE,IAAI,C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,gCAAC;AAAD,CAvOA,CAAwD,qBAAqB;;;;"}
|
|
1
|
+
{"version":3,"file":"StandardInteractionClient.js","sources":["../../src/interaction_client/StandardInteractionClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ICrypto, Logger, ServerTelemetryManager, CommonAuthorizationCodeRequest, Constants, AuthorizationCodeClient, ClientConfiguration, AuthorityOptions, Authority, AuthorityFactory, ServerAuthorizationCodeResponse, UrlString, CommonEndSessionRequest, ProtocolUtils, ResponseMode, StringUtils } from \"@azure/msal-common\";\r\nimport { BaseInteractionClient } from \"./BaseInteractionClient\";\r\nimport { BrowserConfiguration } from \"../config/Configuration\";\r\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\r\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\r\nimport { EventHandler } from \"../event/EventHandler\";\r\nimport { BrowserConstants, InteractionType } from \"../utils/BrowserConstants\";\r\nimport { version } from \"../packageMetadata\";\r\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\r\nimport { BrowserProtocolUtils, BrowserStateObject } from \"../utils/BrowserProtocolUtils\";\r\nimport { EndSessionRequest } from \"../request/EndSessionRequest\";\r\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\r\nimport { INavigationClient } from \"../navigation/INavigationClient\";\r\nimport { RedirectRequest } from \"../request/RedirectRequest\";\r\nimport { PopupRequest } from \"../request/PopupRequest\";\r\nimport { SsoSilentRequest } from \"../request/SsoSilentRequest\";\r\n\r\n/**\r\n * Defines the class structure and helper functions used by the \"standard\", non-brokered auth flows (popup, redirect, silent (RT), silent (iframe))\r\n */\r\nexport abstract class StandardInteractionClient extends BaseInteractionClient {\r\n protected navigationClient: INavigationClient;\r\n\r\n constructor(config: BrowserConfiguration, storageImpl: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, correlationId?: string) {\r\n super(config, storageImpl, browserCrypto, logger, eventHandler, correlationId);\r\n this.navigationClient = navigationClient;\r\n }\r\n \r\n /**\r\n * Generates an auth code request tied to the url request.\r\n * @param request\r\n */\r\n protected async initializeAuthorizationCodeRequest(request: AuthorizationUrlRequest): Promise<CommonAuthorizationCodeRequest> {\r\n this.logger.verbose(\"initializeAuthorizationRequest called\", request.correlationId);\r\n const generatedPkceParams = await this.browserCrypto.generatePkceCodes();\r\n\r\n const authCodeRequest: CommonAuthorizationCodeRequest = {\r\n ...request,\r\n redirectUri: request.redirectUri,\r\n code: \"\",\r\n codeVerifier: generatedPkceParams.verifier\r\n };\r\n\r\n request.codeChallenge = generatedPkceParams.challenge;\r\n request.codeChallengeMethod = Constants.S256_CODE_CHALLENGE_METHOD;\r\n\r\n return authCodeRequest;\r\n }\r\n\r\n /**\r\n * Initializer for the logout request.\r\n * @param logoutRequest\r\n */\r\n protected initializeLogoutRequest(logoutRequest?: EndSessionRequest): CommonEndSessionRequest {\r\n this.logger.verbose(\"initializeLogoutRequest called\", logoutRequest?.correlationId);\r\n\r\n // Check if interaction is in progress. Throw error if true.\r\n if (this.browserStorage.isInteractionInProgress()) {\r\n throw BrowserAuthError.createInteractionInProgressError();\r\n }\r\n\r\n const validLogoutRequest: CommonEndSessionRequest = {\r\n correlationId: this.browserCrypto.createNewGuid(),\r\n ...logoutRequest\r\n };\r\n\r\n /*\r\n * Only set redirect uri if logout request isn't provided or the set uri isn't null.\r\n * Otherwise, use passed uri, config, or current page.\r\n */\r\n if (!logoutRequest || logoutRequest.postLogoutRedirectUri !== null) {\r\n if (logoutRequest && logoutRequest.postLogoutRedirectUri) {\r\n this.logger.verbose(\"Setting postLogoutRedirectUri to uri set on logout request\", validLogoutRequest.correlationId);\r\n validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(logoutRequest.postLogoutRedirectUri, BrowserUtils.getCurrentUri());\r\n } else if (this.config.auth.postLogoutRedirectUri === null) {\r\n this.logger.verbose(\"postLogoutRedirectUri configured as null and no uri set on request, not passing post logout redirect\", validLogoutRequest.correlationId);\r\n } else if (this.config.auth.postLogoutRedirectUri) {\r\n this.logger.verbose(\"Setting postLogoutRedirectUri to configured uri\", validLogoutRequest.correlationId);\r\n validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(this.config.auth.postLogoutRedirectUri, BrowserUtils.getCurrentUri());\r\n } else {\r\n this.logger.verbose(\"Setting postLogoutRedirectUri to current page\", validLogoutRequest.correlationId);\r\n validLogoutRequest.postLogoutRedirectUri = UrlString.getAbsoluteUrl(BrowserUtils.getCurrentUri(), BrowserUtils.getCurrentUri());\r\n }\r\n } else {\r\n this.logger.verbose(\"postLogoutRedirectUri passed as null, not setting post logout redirect uri\", validLogoutRequest.correlationId);\r\n }\r\n\r\n return validLogoutRequest;\r\n }\r\n\r\n /**\r\n * Creates an Authorization Code Client with the given authority, or the default authority.\r\n * @param serverTelemetryManager\r\n * @param authorityUrl\r\n */\r\n protected async createAuthCodeClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string): Promise<AuthorizationCodeClient> {\r\n // Create auth module.\r\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl);\r\n return new AuthorizationCodeClient(clientConfig);\r\n }\r\n\r\n /**\r\n * Creates a Client Configuration object with the given request authority, or the default authority.\r\n * @param serverTelemetryManager\r\n * @param requestAuthority\r\n * @param requestCorrelationId\r\n */\r\n protected async getClientConfiguration(serverTelemetryManager: ServerTelemetryManager, requestAuthority?: string): Promise<ClientConfiguration> {\r\n this.logger.verbose(\"getClientConfiguration called\");\r\n const discoveredAuthority = await this.getDiscoveredAuthority(requestAuthority);\r\n\r\n return {\r\n authOptions: {\r\n clientId: this.config.auth.clientId,\r\n authority: discoveredAuthority,\r\n clientCapabilities: this.config.auth.clientCapabilities\r\n },\r\n systemOptions: {\r\n tokenRenewalOffsetSeconds: this.config.system.tokenRenewalOffsetSeconds,\r\n preventCorsPreflight: true\r\n },\r\n loggerOptions: {\r\n loggerCallback: this.config.system.loggerOptions.loggerCallback,\r\n piiLoggingEnabled: this.config.system.loggerOptions.piiLoggingEnabled,\r\n logLevel: this.config.system.loggerOptions.logLevel,\r\n correlationId: this.correlationId\r\n },\r\n cryptoInterface: this.browserCrypto,\r\n networkInterface: this.networkClient,\r\n storageInterface: this.browserStorage,\r\n serverTelemetryManager: serverTelemetryManager,\r\n libraryInfo: {\r\n sku: BrowserConstants.MSAL_SKU,\r\n version: version,\r\n cpu: \"\",\r\n os: \"\"\r\n }\r\n };\r\n }\r\n\r\n /**\r\n * @param hash\r\n * @param interactionType\r\n */\r\n protected validateAndExtractStateFromHash(hash: string, interactionType: InteractionType, requestCorrelationId?: string): string {\r\n this.logger.verbose(\"validateAndExtractStateFromHash called\", requestCorrelationId);\r\n // Deserialize hash fragment response parameters.\r\n const serverParams: ServerAuthorizationCodeResponse = UrlString.getDeserializedHash(hash);\r\n if (!serverParams.state) {\r\n throw BrowserAuthError.createHashDoesNotContainStateError();\r\n }\r\n\r\n const platformStateObj = BrowserProtocolUtils.extractBrowserRequestState(this.browserCrypto, serverParams.state);\r\n if (!platformStateObj) {\r\n throw BrowserAuthError.createUnableToParseStateError();\r\n }\r\n\r\n if (platformStateObj.interactionType !== interactionType) {\r\n throw BrowserAuthError.createStateInteractionTypeMismatchError();\r\n }\r\n\r\n this.logger.verbose(\"Returning state from hash\", requestCorrelationId);\r\n return serverParams.state;\r\n }\r\n\r\n /**\r\n * Used to get a discovered version of the default authority.\r\n * @param requestAuthority\r\n * @param requestCorrelationId\r\n */\r\n protected async getDiscoveredAuthority(requestAuthority?: string): Promise<Authority> {\r\n this.logger.verbose(\"getDiscoveredAuthority called\");\r\n const authorityOptions: AuthorityOptions = {\r\n protocolMode: this.config.auth.protocolMode,\r\n knownAuthorities: this.config.auth.knownAuthorities,\r\n cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,\r\n authorityMetadata: this.config.auth.authorityMetadata\r\n };\r\n\r\n if (requestAuthority) {\r\n this.logger.verbose(\"Creating discovered authority with request authority\");\r\n return await AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions);\r\n }\r\n\r\n this.logger.verbose(\"Creating discovered authority with configured authority\");\r\n return await AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions);\r\n }\r\n\r\n /**\r\n * Helper to validate app environment before making a request.\r\n * @param request\r\n * @param interactionType\r\n */\r\n protected preflightInteractiveRequest(request: RedirectRequest|PopupRequest, interactionType: InteractionType): AuthorizationUrlRequest {\r\n this.logger.verbose(\"preflightInteractiveRequest called, validating app environment\", request?.correlationId);\r\n // block the reload if it occurred inside a hidden iframe\r\n BrowserUtils.blockReloadInHiddenIframes();\r\n \r\n // Check if interaction is in progress. Throw error if true.\r\n if (this.browserStorage.isInteractionInProgress(false)) {\r\n throw BrowserAuthError.createInteractionInProgressError();\r\n }\r\n \r\n return this.initializeAuthorizationRequest(request, interactionType);\r\n }\r\n\r\n /**\r\n * Helper to initialize required request parameters for interactive APIs and ssoSilent()\r\n * @param request\r\n * @param interactionType\r\n */\r\n protected initializeAuthorizationRequest(request: RedirectRequest|PopupRequest|SsoSilentRequest, interactionType: InteractionType): AuthorizationUrlRequest {\r\n this.logger.verbose(\"initializeAuthorizationRequest called\");\r\n const redirectUri = this.getRedirectUri(request.redirectUri);\r\n const browserState: BrowserStateObject = {\r\n interactionType: interactionType\r\n };\r\n\r\n const state = ProtocolUtils.setRequestState(\r\n this.browserCrypto,\r\n (request && request.state) || \"\",\r\n browserState\r\n );\r\n\r\n const validatedRequest: AuthorizationUrlRequest = {\r\n ...this.initializeBaseRequest(request),\r\n redirectUri: redirectUri,\r\n state: state,\r\n nonce: request.nonce || this.browserCrypto.createNewGuid(),\r\n responseMode: ResponseMode.FRAGMENT\r\n };\r\n\r\n const account = request.account || this.browserStorage.getActiveAccount();\r\n if (account) {\r\n this.logger.verbose(\"Setting validated request account\");\r\n this.logger.verbosePii(`Setting validated request account: ${account}`);\r\n validatedRequest.account = account;\r\n }\r\n\r\n // Check for ADAL/MSAL v1 SSO\r\n if (StringUtils.isEmpty(validatedRequest.loginHint) && !account) {\r\n const legacyLoginHint = this.browserStorage.getLegacyLoginHint();\r\n if (legacyLoginHint) {\r\n validatedRequest.loginHint = legacyLoginHint;\r\n }\r\n }\r\n\r\n this.browserStorage.updateCacheEntries(validatedRequest.state, validatedRequest.nonce, validatedRequest.authority, validatedRequest.loginHint || \"\", validatedRequest.account || null);\r\n\r\n return validatedRequest;\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;AAsBA;;;;IAGwD,6CAAqB;IAGzE,mCAAY,MAA4B,EAAE,WAAgC,EAAE,aAAsB,EAAE,MAAc,EAAE,YAA0B,EAAE,gBAAmC,EAAE,aAAsB;QAA3M,YACI,kBAAM,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,SAEjF;QADG,KAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;;KAC5C;;;;;IAMe,sEAAkC,GAAlD,UAAmD,OAAgC;;;;;;wBAC/E,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,uCAAuC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;wBACxD,qBAAM,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,EAAA;;wBAAlE,mBAAmB,GAAG,SAA4C;wBAElE,eAAe,yBACd,OAAO,KACV,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,IAAI,EAAE,EAAE,EACR,YAAY,EAAE,mBAAmB,CAAC,QAAQ,GAC7C,CAAC;wBAEF,OAAO,CAAC,aAAa,GAAG,mBAAmB,CAAC,SAAS,CAAC;wBACtD,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,0BAA0B,CAAC;wBAEnE,sBAAO,eAAe,EAAC;;;;KAC1B;;;;;IAMS,2DAAuB,GAAjC,UAAkC,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AAS,GAAG,eAAe,CAAC;aAChD;SACJ;QAED,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,EAAE,EAAE,gBAAgB,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;QAEvL,OAAO,gBAAgB,CAAC;KAC3B;IACL,gCAAC;AAAD,CAvOA,CAAwD,qBAAqB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionHandler.js","sources":["../../src/interaction_handler/InteractionHandler.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StringUtils, CommonAuthorizationCodeRequest, AuthenticationResult, AuthorizationCodeClient, AuthorityFactory, Authority, INetworkModule, ClientAuthError, CcsCredential, Logger } from \"@azure/msal-common\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { TemporaryCacheKeys } from \"../utils/BrowserConstants\";\n\nexport type InteractionParams = {};\n\n/**\n * Abstract class which defines operations for a browser interaction handling class.\n */\nexport abstract class InteractionHandler {\n\n protected authModule: AuthorizationCodeClient;\n protected browserStorage: BrowserCacheManager;\n protected authCodeRequest: CommonAuthorizationCodeRequest;\n protected browserRequestLogger: Logger;\n\n constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, browserRequestLogger: Logger) {\n this.authModule = authCodeModule;\n this.browserStorage = storageImpl;\n this.authCodeRequest = authCodeRequest;\n this.browserRequestLogger = browserRequestLogger;\n }\n\n /**\n * Function to enable user interaction.\n * @param requestUrl\n */\n abstract initiateAuthRequest(requestUrl: string, params: InteractionParams): Window | Promise<HTMLIFrameElement> | Promise<void>;\n\n /**\n * Function to handle response parameters from hash.\n * @param locationHash\n */\n async handleCodeResponse(locationHash: string, state: string, authority: Authority, networkModule: INetworkModule): Promise<AuthenticationResult> {\n this.browserRequestLogger.verbose(\"InteractionHandler.handleCodeResponse called\");\n // Check that location hash isn't empty.\n if (StringUtils.isEmpty(locationHash)) {\n throw BrowserAuthError.createEmptyHashError(locationHash);\n }\n\n // Handle code response.\n const stateKey = this.browserStorage.generateStateKey(state);\n const requestState = this.browserStorage.getTemporaryCache(stateKey);\n if (!requestState) {\n throw ClientAuthError.createStateNotFoundError(\"Cached State\");\n }\n const authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);\n\n // Get cached items\n const nonceKey = this.browserStorage.generateNonceKey(requestState);\n const cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);\n\n // Assign code to request\n this.authCodeRequest.code = authCodeResponse.code;\n\n // Check for new cloud instance\n if (authCodeResponse.cloud_instance_host_name) {\n await this.updateTokenEndpointAuthority(authCodeResponse.cloud_instance_host_name, authority, networkModule);\n }\n\n authCodeResponse.nonce = cachedNonce || undefined;\n authCodeResponse.state = requestState;\n\n // Add CCS parameters if available\n if (authCodeResponse.client_info) {\n this.authCodeRequest.clientInfo = authCodeResponse.client_info;\n } else {\n const cachedCcsCred = this.checkCcsCredentials();\n if (cachedCcsCred) {\n this.authCodeRequest.ccsCredential = cachedCcsCred;\n }\n }\n\n // Acquire token with retrieved code.\n const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse);\n this.browserStorage.cleanRequestByState(state);\n return tokenResponse;\n }\n\n /**\n * Updates authority based on cloudInstanceHostname\n * @param cloudInstanceHostname \n * @param authority \n * @param networkModule \n */\n protected async updateTokenEndpointAuthority(cloudInstanceHostname: string, authority: Authority, networkModule: INetworkModule): Promise<void> {\n const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${authority.tenant}/`;\n const cloudInstanceAuthority = await AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options);\n this.authModule.updateAuthority(cloudInstanceAuthority);\n }\n\n /**\n * Looks up ccs creds in the cache\n */\n protected checkCcsCredentials(): CcsCredential | null {\n // Look up ccs credential in temp cache\n const cachedCcsCred = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, true);\n if (cachedCcsCred) {\n try {\n return JSON.parse(cachedCcsCred) as CcsCredential;\n } catch (e) {\n this.authModule.logger.error(\"Cache credential could not be parsed\");\n this.authModule.logger.errorPii(`Cache credential could not be parsed: ${cachedCcsCred}`);\n }\n }\n return null;\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;;;;AAYA;;;;IAUI,4BAAY,cAAuC,EAAE,WAAgC,EAAE,eAA+C,EAAE,oBAA4B;QAChK,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;QAClC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;KACpD;;;;;IAYK,+CAAkB,GAAxB,UAAyB,YAAoB,EAAE,KAAa,EAAE,SAAoB,EAAE,aAA6B;;;;;;wBAC7G,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;;wBAElF,IAAI,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;4BACnC,MAAM,gBAAgB,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;yBAC7D;wBAGK,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;wBACvD,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;wBACrE,IAAI,CAAC,YAAY,EAAE;4BACf,MAAM,eAAe,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC;yBAClE;wBACK,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,YAAY,EAAE,YAAY,CAAC,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AI,CAAC,cAAc,EAAE,SAAS,CAAC,OAAO,CAAC,EAAA;;wBAA1J,sBAAsB,GAAG,SAAiI;wBAChK,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC;;;;;KAC3D;;;;IAKS,gDAAmB,GAA7B;;QAEI,IAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QACrG,IAAI,aAAa,EAAE;YACf,IAAI;gBACA,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAkB,CAAC;aACrD;YAAC,OAAO,CAAC,EAAE;gBACR,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;gBACrE,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,2CAAyC,aAAe,CAAC,CAAC;aAC7F;SACJ;QACD,OAAO,IAAI,CAAC;KACf;IACL,yBAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"InteractionHandler.js","sources":["../../src/interaction_handler/InteractionHandler.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { StringUtils, CommonAuthorizationCodeRequest, AuthenticationResult, AuthorizationCodeClient, AuthorityFactory, Authority, INetworkModule, ClientAuthError, CcsCredential, Logger } from \"@azure/msal-common\";\r\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\r\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\r\nimport { TemporaryCacheKeys } from \"../utils/BrowserConstants\";\r\n\r\nexport type InteractionParams = {};\r\n\r\n/**\r\n * Abstract class which defines operations for a browser interaction handling class.\r\n */\r\nexport abstract class InteractionHandler {\r\n\r\n protected authModule: AuthorizationCodeClient;\r\n protected browserStorage: BrowserCacheManager;\r\n protected authCodeRequest: CommonAuthorizationCodeRequest;\r\n protected browserRequestLogger: Logger;\r\n\r\n constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, browserRequestLogger: Logger) {\r\n this.authModule = authCodeModule;\r\n this.browserStorage = storageImpl;\r\n this.authCodeRequest = authCodeRequest;\r\n this.browserRequestLogger = browserRequestLogger;\r\n }\r\n\r\n /**\r\n * Function to enable user interaction.\r\n * @param requestUrl\r\n */\r\n abstract initiateAuthRequest(requestUrl: string, params: InteractionParams): Window | Promise<HTMLIFrameElement> | Promise<void>;\r\n\r\n /**\r\n * Function to handle response parameters from hash.\r\n * @param locationHash\r\n */\r\n async handleCodeResponse(locationHash: string, state: string, authority: Authority, networkModule: INetworkModule): Promise<AuthenticationResult> {\r\n this.browserRequestLogger.verbose(\"InteractionHandler.handleCodeResponse called\");\r\n // Check that location hash isn't empty.\r\n if (StringUtils.isEmpty(locationHash)) {\r\n throw BrowserAuthError.createEmptyHashError(locationHash);\r\n }\r\n\r\n // Handle code response.\r\n const stateKey = this.browserStorage.generateStateKey(state);\r\n const requestState = this.browserStorage.getTemporaryCache(stateKey);\r\n if (!requestState) {\r\n throw ClientAuthError.createStateNotFoundError(\"Cached State\");\r\n }\r\n const authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);\r\n\r\n // Get cached items\r\n const nonceKey = this.browserStorage.generateNonceKey(requestState);\r\n const cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);\r\n\r\n // Assign code to request\r\n this.authCodeRequest.code = authCodeResponse.code;\r\n\r\n // Check for new cloud instance\r\n if (authCodeResponse.cloud_instance_host_name) {\r\n await this.updateTokenEndpointAuthority(authCodeResponse.cloud_instance_host_name, authority, networkModule);\r\n }\r\n\r\n authCodeResponse.nonce = cachedNonce || undefined;\r\n authCodeResponse.state = requestState;\r\n\r\n // Add CCS parameters if available\r\n if (authCodeResponse.client_info) {\r\n this.authCodeRequest.clientInfo = authCodeResponse.client_info;\r\n } else {\r\n const cachedCcsCred = this.checkCcsCredentials();\r\n if (cachedCcsCred) {\r\n this.authCodeRequest.ccsCredential = cachedCcsCred;\r\n }\r\n }\r\n\r\n // Acquire token with retrieved code.\r\n const tokenResponse = await this.authModule.acquireToken(this.authCodeRequest, authCodeResponse);\r\n this.browserStorage.cleanRequestByState(state);\r\n return tokenResponse;\r\n }\r\n\r\n /**\r\n * Updates authority based on cloudInstanceHostname\r\n * @param cloudInstanceHostname \r\n * @param authority \r\n * @param networkModule \r\n */\r\n protected async updateTokenEndpointAuthority(cloudInstanceHostname: string, authority: Authority, networkModule: INetworkModule): Promise<void> {\r\n const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${authority.tenant}/`;\r\n const cloudInstanceAuthority = await AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options);\r\n this.authModule.updateAuthority(cloudInstanceAuthority);\r\n }\r\n\r\n /**\r\n * Looks up ccs creds in the cache\r\n */\r\n protected checkCcsCredentials(): CcsCredential | null {\r\n // Look up ccs credential in temp cache\r\n const cachedCcsCred = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, true);\r\n if (cachedCcsCred) {\r\n try {\r\n return JSON.parse(cachedCcsCred) as CcsCredential;\r\n } catch (e) {\r\n this.authModule.logger.error(\"Cache credential could not be parsed\");\r\n this.authModule.logger.errorPii(`Cache credential could not be parsed: ${cachedCcsCred}`);\r\n }\r\n }\r\n return null;\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;AAAA;;;;AAYA;;;;IAUI,4BAAY,cAAuC,EAAE,WAAgC,EAAE,eAA+C,EAAE,oBAA4B;QAChK,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;QAClC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;KACpD;;;;;IAYK,+CAAkB,GAAxB,UAAyB,YAAo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
|
|
|
1
|
-
{"version":3,"file":"PopupHandler.js","sources":["../../src/interaction_handler/PopupHandler.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { UrlString, StringUtils, CommonAuthorizationCodeRequest, AuthorizationCodeClient, Logger } from \"@azure/msal-common\";\nimport { InteractionHandler, InteractionParams } from \"./InteractionHandler\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { PopupWindowAttributes, PopupUtils } from \"../utils/PopupUtils\";\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\n\nexport type PopupParams = InteractionParams & {\n popup?: Window|null;\n popupName: string;\n popupWindowAttributes: PopupWindowAttributes\n};\n\n/**\n * This class implements the interaction handler base class for browsers. It is written specifically for handling\n * popup window scenarios. It includes functions for monitoring the popup window for a hash.\n */\nexport class PopupHandler extends InteractionHandler {\n private popupUtils: PopupUtils;\n\n constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, browserRequestLogger: Logger) {\n super(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger);\n\n // Properly sets this reference for the unload event.\n this.popupUtils = new PopupUtils(storageImpl, browserRequestLogger);\n }\n\n /**\n * Opens a popup window with given request Url.\n * @param requestUrl\n */\n initiateAuthRequest(requestUrl: string, params: PopupParams): Window {\n // Check that request url is not empty.\n if (!StringUtils.isEmpty(requestUrl)) {\n // Set interaction status in the library.\n this.browserStorage.setInteractionInProgress(true);\n this.browserRequestLogger.infoPii(`Navigate to: ${requestUrl}`);\n // Open the popup window to requestUrl.\n return this.popupUtils.openPopup(requestUrl, params);\n } else {\n // Throw error if request URL is empty.\n this.browserRequestLogger.error(\"Navigate url is empty\");\n throw BrowserAuthError.createEmptyNavigationUriError();\n }\n }\n\n /**\n * Monitors a window until it loads a url with a known hash, or hits a specified timeout.\n * @param popupWindow - window that is being monitored\n * @param timeout - milliseconds until timeout\n */\n monitorPopupForHash(popupWindow: Window): Promise<string> {\n return this.popupUtils.monitorPopupForSameOrigin(popupWindow).then(() => {\n const contentHash = popupWindow.location.hash;\n BrowserUtils.clearHash(popupWindow);\n this.popupUtils.cleanPopup(popupWindow);\n\n if (!contentHash) {\n throw BrowserAuthError.createEmptyHashError(popupWindow.location.href);\n }\n\n if (UrlString.hashContainsKnownProperties(contentHash)) {\n return contentHash;\n } else {\n throw BrowserAuthError.createHashDoesNotContainKnownPropertiesError();\n }\n }\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;AAkBA;;;;;IAIkC,gCAAkB;IAGhD,sBAAY,cAAuC,EAAE,WAAgC,EAAE,eAA+C,EAAE,oBAA4B;QAApK,YACI,kBAAM,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,CAAC,SAI5E;;QADG,KAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;;KACvE;;;;;IAMD,0CAAmB,GAAnB,UAAoB,UAAkB,EAAE,MAAmB;;QAEvD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;;YAElC,IAAI,CAAC,cAAc,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;YACnD,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,kBAAgB,UAAY,CAAC,CAAC;;YAEhE,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;SACxD;aAAM;;YAEH,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACzD,MAAM,gBAAgB,CAAC,6BAA6B,EAAE,CAAC;SAC1D;KACJ;;;;;;IAOD,0CAAmB,GAAnB,UAAoB,WAAmB;QAAvC,iBAiBC;QAhBG,OAAO,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YAC/D,IAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC9C,YAAY,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YACpC,KAAI,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YAExC,IAAI,CAAC,WAAW,EAAE;gBACd,MAAM,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC1E;YAED,IAAI,SAAS,CAAC,2BAA2B,CAAC,WAAW,CAAC,EAAE;gBACpD,OAAO,WAAW,CAAC;aACtB;iBAAM;gBACH,MAAM,gBAAgB,CAAC,4CAA4C,EAAE,CAAC;aACzE;SACJ,CACA,CAAC;KACL;IACL,mBAAC;AAAD,CApDA,CAAkC,kBAAkB;;;;"}
|
|
1
|
+
{"version":3,"file":"PopupHandler.js","sources":["../../src/interaction_handler/PopupHandler.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { UrlString, StringUtils, CommonAuthorizationCodeRequest, AuthorizationCodeClient, Logger } from \"@azure/msal-common\";\r\nimport { InteractionHandler, InteractionParams } from \"./InteractionHandler\";\r\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\r\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\r\nimport { PopupWindowAttributes, PopupUtils } from \"../utils/PopupUtils\";\r\nimport { BrowserUtils } from \"../utils/BrowserUtils\";\r\n\r\nexport type PopupParams = InteractionParams & {\r\n popup?: Window|null;\r\n popupName: string;\r\n popupWindowAttributes: PopupWindowAttributes\r\n};\r\n\r\n/**\r\n * This class implements the interaction handler base class for browsers. It is written specifically for handling\r\n * popup window scenarios. It includes functions for monitoring the popup window for a hash.\r\n */\r\nexport class PopupHandler extends InteractionHandler {\r\n private popupUtils: PopupUtils;\r\n\r\n constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, browserRequestLogger: Logger) {\r\n super(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger);\r\n\r\n // Properly sets this reference for the unload event.\r\n this.popupUtils = new PopupUtils(storageImpl, browserRequestLogger);\r\n }\r\n\r\n /**\r\n * Opens a popup window with given request Url.\r\n * @param requestUrl\r\n */\r\n initiateAuthRequest(requestUrl: string, params: PopupParams): Window {\r\n // Check that request url is not empty.\r\n if (!StringUtils.isEmpty(requestUrl)) {\r\n // Set interaction status in the library.\r\n this.browserStorage.setInteractionInProgress(true);\r\n this.browserRequestLogger.infoPii(`Navigate to: ${requestUrl}`);\r\n // Open the popup window to requestUrl.\r\n return this.popupUtils.openPopup(requestUrl, params);\r\n } else {\r\n // Throw error if request URL is empty.\r\n this.browserRequestLogger.error(\"Navigate url is empty\");\r\n throw BrowserAuthError.createEmptyNavigationUriError();\r\n }\r\n }\r\n\r\n /**\r\n * Monitors a window until it loads a url with a known hash, or hits a specified timeout.\r\n * @param popupWindow - window that is being monitored\r\n * @param timeout - milliseconds until timeout\r\n */\r\n monitorPopupForHash(popupWindow: Window): Promise<string> {\r\n return this.popupUtils.monitorPopupForSameOrigin(popupWindow).then(() => {\r\n const contentHash = popupWindow.location.hash;\r\n BrowserUtils.clearHash(popupWindow);\r\n this.popupUtils.cleanPopup(popupWindow);\r\n\r\n if (!contentHash) {\r\n throw BrowserAuthError.createEmptyHashError(popupWindow.location.href);\r\n }\r\n\r\n if (UrlString.hashContainsKnownProperties(contentHash)) {\r\n return contentHash;\r\n } else {\r\n throw BrowserAuthError.createHashDoesNotContainKnownPropertiesError();\r\n }\r\n }\r\n );\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;AAkBA;;;;;IAIkC,gCAAkB;IAGhD,sBAAY,cAAuC,EAAE,WAAgC,EAAE,eAA+C,EAAE,oBAA4B;QAApK,YACI,kBAAM,cAAc,EAAE,WAAW,EAAE,eAAe,EAA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