@azure/msal-browser 2.16.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +240 -0
- package/{changelog.md → CHANGELOG.md} +489 -430
- package/LICENSE +21 -21
- package/README.md +212 -206
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/app/ClientApplication.d.ts +19 -140
- package/dist/app/ClientApplication.d.ts.map +1 -1
- package/dist/app/ClientApplication.js +115 -895
- package/dist/app/ClientApplication.js.map +1 -1
- package/dist/app/IPublicClientApplication.d.ts +6 -0
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.js +13 -1
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +35 -41
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/cache/AsyncMemoryStorage.d.ts +46 -0
- package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -0
- package/dist/cache/AsyncMemoryStorage.js +195 -0
- package/dist/cache/AsyncMemoryStorage.js.map +1 -0
- package/dist/cache/BrowserCacheManager.d.ts +19 -2
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +104 -15
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.d.ts +1 -1
- package/dist/cache/BrowserStorage.d.ts.map +1 -1
- package/dist/cache/BrowserStorage.js +1 -1
- package/dist/cache/BrowserStorage.js.map +1 -1
- package/dist/cache/DatabaseStorage.d.ts +29 -4
- package/dist/cache/DatabaseStorage.d.ts.map +1 -1
- package/dist/cache/DatabaseStorage.js +151 -45
- package/dist/cache/DatabaseStorage.js.map +1 -1
- package/dist/cache/IAsyncMemoryStorage.d.ts +28 -0
- package/dist/cache/IAsyncMemoryStorage.d.ts.map +1 -0
- package/dist/cache/ITokenCache.d.ts +8 -0
- package/dist/cache/ITokenCache.d.ts.map +1 -0
- package/dist/cache/IWindowStorage.d.ts +3 -3
- package/dist/cache/IWindowStorage.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.d.ts +3 -3
- package/dist/cache/MemoryStorage.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.js +1 -1
- package/dist/cache/MemoryStorage.js.map +1 -1
- package/dist/cache/TokenCache.d.ts +48 -0
- package/dist/cache/TokenCache.d.ts.map +1 -0
- package/dist/cache/TokenCache.js +124 -0
- package/dist/cache/TokenCache.js.map +1 -0
- package/dist/config/Configuration.js +1 -1
- package/dist/config/Configuration.js.map +1 -1
- package/dist/crypto/BrowserCrypto.d.ts +3 -1
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.js +3 -2
- package/dist/crypto/BrowserCrypto.js.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +21 -6
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.js +67 -15
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.js +1 -1
- package/dist/crypto/GuidGenerator.js.map +1 -1
- package/dist/crypto/PkceGenerator.js +1 -1
- package/dist/crypto/PkceGenerator.js.map +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +31 -0
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -0
- package/dist/crypto/SignedHttpRequest.js +70 -0
- package/dist/crypto/SignedHttpRequest.js.map +1 -0
- package/dist/encode/Base64Decode.js +1 -1
- package/dist/encode/Base64Decode.js.map +1 -1
- package/dist/encode/Base64Encode.js +1 -1
- package/dist/encode/Base64Encode.js.map +1 -1
- package/dist/error/BrowserAuthError.d.ts +28 -4
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +41 -11
- 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.d.ts +13 -0
- package/dist/event/EventHandler.d.ts.map +1 -1
- package/dist/event/EventHandler.js +66 -1
- package/dist/event/EventHandler.js.map +1 -1
- package/dist/event/EventMessage.d.ts +4 -3
- package/dist/event/EventMessage.d.ts.map +1 -1
- package/dist/event/EventMessage.js +24 -5
- package/dist/event/EventMessage.js.map +1 -1
- package/dist/event/EventType.d.ts +2 -0
- package/dist/event/EventType.d.ts.map +1 -1
- package/dist/event/EventType.js +3 -1
- package/dist/event/EventType.js.map +1 -1
- package/dist/index.cjs.js +4505 -3045
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts +42 -0
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -0
- package/dist/interaction_client/BaseInteractionClient.js +131 -0
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -0
- package/dist/interaction_client/PopupClient.d.ts +37 -0
- package/dist/interaction_client/PopupClient.d.ts.map +1 -0
- package/dist/interaction_client/PopupClient.js +234 -0
- package/dist/interaction_client/PopupClient.js.map +1 -0
- package/dist/interaction_client/RedirectClient.d.ts +42 -0
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -0
- package/dist/interaction_client/RedirectClient.js +301 -0
- package/dist/interaction_client/RedirectClient.js.map +1 -0
- package/dist/interaction_client/SilentCacheClient.d.ts +22 -0
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -0
- package/dist/interaction_client/SilentCacheClient.js +85 -0
- package/dist/interaction_client/SilentCacheClient.js.map +1 -0
- package/dist/interaction_client/SilentIframeClient.d.ts +29 -0
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -0
- package/dist/interaction_client/SilentIframeClient.js +107 -0
- package/dist/interaction_client/SilentIframeClient.js.map +1 -0
- package/dist/interaction_client/SilentRefreshClient.d.ts +20 -0
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -0
- package/dist/interaction_client/SilentRefreshClient.js +76 -0
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -0
- package/dist/interaction_client/StandardInteractionClient.d.ts +66 -0
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -0
- package/dist/interaction_client/StandardInteractionClient.js +249 -0
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -0
- package/dist/interaction_handler/InteractionHandler.js +1 -1
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/PopupHandler.d.ts +2 -0
- package/dist/interaction_handler/PopupHandler.d.ts.map +1 -1
- package/dist/interaction_handler/PopupHandler.js +3 -4
- package/dist/interaction_handler/PopupHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +6 -5
- 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.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/EndSessionPopupRequest.d.ts +3 -0
- package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
- package/dist/request/PopupRequest.d.ts +3 -0
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.d.ts +12 -1
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.js +16 -3
- 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.d.ts +26 -2
- package/dist/utils/PopupUtils.d.ts.map +1 -1
- package/dist/utils/PopupUtils.js +42 -15
- package/dist/utils/PopupUtils.js.map +1 -1
- package/lib/msal-browser.js +4505 -3045
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +42 -42
- package/package.json +8 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserUtils.js","sources":["../../src/utils/BrowserUtils.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"BrowserUtils.js","sources":["../../src/utils/BrowserUtils.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Constants, INetworkModule, UrlString } from \"@azure/msal-common\";\nimport { FetchClient } from \"../network/FetchClient\";\nimport { XhrClient } from \"../network/XhrClient\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { InteractionType, BrowserConstants } from \"./BrowserConstants\";\n\n/**\n * Utility class for browser specific functions\n */\nexport class BrowserUtils {\n\n // #region Window Navigation and URL management\n\n /**\n * Clears hash from window url.\n */\n static clearHash(contentWindow: Window): void {\n // Office.js sets history.replaceState to null\n contentWindow.location.hash = Constants.EMPTY_STRING;\n if (typeof contentWindow.history.replaceState === \"function\") {\n // Full removes \"#\" from url\n contentWindow.history.replaceState(null, Constants.EMPTY_STRING, `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`);\n }\n }\n\n /**\n * Replaces current hash with hash from provided url\n */\n static replaceHash(url: string): void {\n const urlParts = url.split(\"#\");\n urlParts.shift(); // Remove part before the hash\n window.location.hash = urlParts.length > 0 ? urlParts.join(\"#\") : \"\";\n }\n\n /**\n * Returns boolean of whether the current window is in an iframe or not.\n */\n static isInIframe(): boolean {\n return window.parent !== window;\n }\n\n /**\n * Returns boolean of whether or not the current window is a popup opened by msal\n */\n static isInPopup(): boolean {\n return typeof window !== \"undefined\" && !!window.opener && \n window.opener !== window && \n typeof window.name === \"string\" && \n window.name.indexOf(`${BrowserConstants.POPUP_NAME_PREFIX}.`) === 0;\n }\n\n // #endregion\n\n /**\n * Returns current window URL as redirect uri\n */\n static getCurrentUri(): string {\n return window.location.href.split(\"?\")[0].split(\"#\")[0];\n }\n\n /**\n * Gets the homepage url for the current window location.\n */\n static getHomepage(): string {\n const currentUrl = new UrlString(window.location.href);\n const urlComponents = currentUrl.getUrlComponents();\n return `${urlComponents.Protocol}//${urlComponents.HostNameAndPort}/`;\n }\n\n /**\n * Returns best compatible network client object. \n */\n static getBrowserNetworkClient(): INetworkModule {\n if (window.fetch && window.Headers) {\n return new FetchClient();\n } else {\n return new XhrClient();\n }\n }\n\n /**\n * Throws error if we have completed an auth and are \n * attempting another auth request inside an iframe.\n */\n static blockReloadInHiddenIframes(): void {\n const isResponseHash = UrlString.hashContainsKnownProperties(window.location.hash);\n // return an error if called from the hidden iframe created by the msal js silent calls\n if (isResponseHash && BrowserUtils.isInIframe()) {\n throw BrowserAuthError.createBlockReloadInHiddenIframeError();\n }\n }\n\n /**\n * Block redirect operations in iframes unless explicitly allowed\n * @param interactionType Interaction type for the request\n * @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe\n */\n static blockRedirectInIframe(interactionType: InteractionType, allowRedirectInIframe: boolean): void {\n const isIframedApp = BrowserUtils.isInIframe();\n if (interactionType === InteractionType.Redirect && isIframedApp && !allowRedirectInIframe) {\n // If we are not in top frame, we shouldn't redirect. This is also handled by the service.\n throw BrowserAuthError.createRedirectInIframeError(isIframedApp);\n }\n }\n\n /**\n * Block redirectUri loaded in popup from calling AcquireToken APIs\n */\n static blockAcquireTokenInPopups(): void {\n // Popups opened by msal popup APIs are given a name that starts with \"msal.\"\n if (BrowserUtils.isInPopup()) {\n throw BrowserAuthError.createBlockAcquireTokenInPopupsError();\n }\n }\n\n /**\n * Throws error if token requests are made in non-browser environment\n * @param isBrowserEnvironment Flag indicating if environment is a browser.\n */\n static blockNonBrowserEnvironment(isBrowserEnvironment: boolean): void {\n if (!isBrowserEnvironment) {\n throw BrowserAuthError.createNonBrowserEnvironmentError();\n }\n }\n\n /**\n * Returns boolean of whether current browser is an Internet Explorer or Edge browser.\n */\n static detectIEOrEdge(): boolean {\n const ua = window.navigator.userAgent;\n const msie = ua.indexOf(\"MSIE \");\n const msie11 = ua.indexOf(\"Trident/\");\n const msedge = ua.indexOf(\"Edge/\");\n const isIE = msie > 0 || msie11 > 0;\n const isEdge = msedge > 0;\n return isIE || isEdge;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;AAWA;;;;IAGA;KAgIC;;;;;IAzHU,sBAAS,GAAhB,UAAiB,aAAqB;;QAElC,aAAa,CAAC,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC;QACrD,IAAI,OAAO,aAAa,CAAC,OAAO,CAAC,YAAY,KAAK,UAAU,EAAE;;YAE1D,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,YAAY,EAAE,KAAG,aAAa,CAAC,QAAQ,CAAC,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,MAAQ,CAAC,CAAC;SAC1K;KACJ;;;;IAKM,wBAAW,GAAlB,UAAmB,GAAW;QAC1B,IAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG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AAqB,GAA5B,UAA6B,eAAgC,EAAE,qBAA8B;QACzF,IAAM,YAAY,GAAG,YAAY,CAAC,UAAU,EAAE,CAAC;QAC/C,IAAI,eAAe,KAAK,eAAe,CAAC,QAAQ,IAAI,YAAY,IAAI,CAAC,qBAAqB,EAAE;;YAExF,MAAM,gBAAgB,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;SACpE;KACJ;;;;IAKM,sCAAyB,GAAhC;;QAEI,IAAI,YAAY,CAAC,SAAS,EAAE,EAAE;YAC1B,MAAM,gBAAgB,CAAC,oCAAoC,EAAE,CAAC;SACjE;KACJ;;;;;IAMM,uCAA0B,GAAjC,UAAkC,oBAA6B;QAC3D,IAAI,CAAC,oBAAoB,EAAE;YACvB,MAAM,gBAAgB,CAAC,gCAAgC,EAAE,CAAC;SAC7D;KACJ;;;;IAKM,2BAAc,GAArB;QACI,IAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;QACtC,IAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACjC,IAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACtC,IAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnC,IAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;QACpC,IAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC;QAC1B,OAAO,IAAI,IAAI,MAAM,CAAC;KACzB;IACL,mBAAC;AAAD,CAAC;;;;"}
|
package/dist/utils/MathUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MathUtils.js","sources":["../../src/utils/MathUtils.ts"],"sourcesContent":["/*\
|
|
1
|
+
{"version":3,"file":"MathUtils.js","sources":["../../src/utils/MathUtils.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Utility class for math specific functions in browser.\n */\nexport class MathUtils {\n\n /**\n * Decimal to Hex\n *\n * @param num\n */\n static decimalToHex(num: number): string {\n let hex: string = num.toString(16);\n while (hex.length < 2) {\n hex = \"0\" + hex;\n }\n return hex;\n }\n}\n"],"names":[],"mappings":";;AAAA;;;;AAKA;;;;IAGA;KAcC;;;;;;IAPU,sBAAY,GAAnB,UAAoB,GAAW;QAC3B,IAAI,GAAG,GAAW,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACnC,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;SACnB;QACD,OAAO,GAAG,CAAC;KACd;IACL,gBAAC;AAAD,CAAC;;;;"}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { CommonEndSessionRequest, Logger } from "@azure/msal-common";
|
|
2
2
|
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
|
|
3
|
+
import { PopupParams } from "../interaction_handler/PopupHandler";
|
|
3
4
|
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
|
|
5
|
+
/**
|
|
6
|
+
* Popup configurations for setting dimensions and position of popup window
|
|
7
|
+
*/
|
|
8
|
+
export declare type PopupWindowAttributes = {
|
|
9
|
+
popupSize?: PopupSize;
|
|
10
|
+
popupPosition?: PopupPosition;
|
|
11
|
+
};
|
|
12
|
+
export declare type PopupSize = {
|
|
13
|
+
height: number;
|
|
14
|
+
width: number;
|
|
15
|
+
};
|
|
16
|
+
export declare type PopupPosition = {
|
|
17
|
+
top: number;
|
|
18
|
+
left: number;
|
|
19
|
+
};
|
|
4
20
|
export declare class PopupUtils {
|
|
5
21
|
private browserStorage;
|
|
6
22
|
private logger;
|
|
@@ -15,11 +31,19 @@ export declare class PopupUtils {
|
|
|
15
31
|
* @param title
|
|
16
32
|
* @param popUpWidth
|
|
17
33
|
* @param popUpHeight
|
|
34
|
+
* @param popupWindowAttributes
|
|
18
35
|
* @ignore
|
|
19
36
|
* @hidden
|
|
20
37
|
*/
|
|
21
|
-
openPopup(urlNavigate: string,
|
|
22
|
-
|
|
38
|
+
openPopup(urlNavigate: string, popupParams: PopupParams): Window;
|
|
39
|
+
/**
|
|
40
|
+
* Helper function to set popup window dimensions and position
|
|
41
|
+
* @param urlNavigate
|
|
42
|
+
* @param popupName
|
|
43
|
+
* @param popupWindowAttributes
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
static openSizedPopup(urlNavigate: string, popupName: string, popupWindowAttributes: PopupWindowAttributes, logger: Logger): Window | null;
|
|
23
47
|
/**
|
|
24
48
|
* Event callback to unload main window.
|
|
25
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupUtils.d.ts","sourceRoot":"","sources":["../../src/utils/PopupUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAa,MAAM,EAAe,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAG7E,qBAAa,UAAU;IACnB,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAmB;gBAE5B,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM;IAQ5D
|
|
1
|
+
{"version":3,"file":"PopupUtils.d.ts","sourceRoot":"","sources":["../../src/utils/PopupUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAa,MAAM,EAAe,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAG7E;;GAEG;AACH,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-
/*! @azure/msal-browser v2.
|
|
1
|
+
/*! @azure/msal-browser v2.19.0 2021-11-02 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { StringUtils, Constants } from '@azure/msal-common';
|
|
4
4
|
import { BrowserAuthError } from '../error/BrowserAuthError.js';
|
|
5
|
-
import {
|
|
5
|
+
import { BrowserConstants, InteractionType } from './BrowserConstants.js';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -24,22 +24,23 @@ var PopupUtils = /** @class */ (function () {
|
|
|
24
24
|
* @param title
|
|
25
25
|
* @param popUpWidth
|
|
26
26
|
* @param popUpHeight
|
|
27
|
+
* @param popupWindowAttributes
|
|
27
28
|
* @ignore
|
|
28
29
|
* @hidden
|
|
29
30
|
*/
|
|
30
|
-
PopupUtils.prototype.openPopup = function (urlNavigate,
|
|
31
|
+
PopupUtils.prototype.openPopup = function (urlNavigate, popupParams) {
|
|
31
32
|
try {
|
|
32
33
|
var popupWindow = void 0;
|
|
33
34
|
// Popup window passed in, setting url to navigate to
|
|
34
|
-
if (popup) {
|
|
35
|
-
popupWindow = popup;
|
|
35
|
+
if (popupParams.popup) {
|
|
36
|
+
popupWindow = popupParams.popup;
|
|
36
37
|
this.logger.verbosePii("Navigating popup window to: " + urlNavigate);
|
|
37
38
|
popupWindow.location.assign(urlNavigate);
|
|
38
39
|
}
|
|
39
|
-
else if (typeof popup === "undefined") {
|
|
40
|
+
else if (typeof popupParams.popup === "undefined") {
|
|
40
41
|
// Popup will be undefined if it was not passed in
|
|
41
42
|
this.logger.verbosePii("Opening popup window to: " + urlNavigate);
|
|
42
|
-
popupWindow = PopupUtils.openSizedPopup(urlNavigate, popupName);
|
|
43
|
+
popupWindow = PopupUtils.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes, this.logger);
|
|
43
44
|
}
|
|
44
45
|
// Popup will be null if popups are blocked
|
|
45
46
|
if (!popupWindow) {
|
|
@@ -54,11 +55,19 @@ var PopupUtils = /** @class */ (function () {
|
|
|
54
55
|
}
|
|
55
56
|
catch (e) {
|
|
56
57
|
this.logger.error("error opening popup " + e.message);
|
|
57
|
-
this.browserStorage.
|
|
58
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
58
59
|
throw BrowserAuthError.createPopupWindowError(e.toString());
|
|
59
60
|
}
|
|
60
61
|
};
|
|
61
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Helper function to set popup window dimensions and position
|
|
64
|
+
* @param urlNavigate
|
|
65
|
+
* @param popupName
|
|
66
|
+
* @param popupWindowAttributes
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
PopupUtils.openSizedPopup = function (urlNavigate, popupName, popupWindowAttributes, logger) {
|
|
70
|
+
var _a, _b, _c, _d;
|
|
62
71
|
/**
|
|
63
72
|
* adding winLeft and winTop to account for dual monitor
|
|
64
73
|
* using screenLeft and screenTop for IE8 and earlier
|
|
@@ -69,11 +78,29 @@ var PopupUtils = /** @class */ (function () {
|
|
|
69
78
|
* window.innerWidth displays browser window"s height and width excluding toolbars
|
|
70
79
|
* using document.documentElement.clientWidth for IE8 and earlier
|
|
71
80
|
*/
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
|
|
81
|
+
var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
82
|
+
var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
83
|
+
var width = (_a = popupWindowAttributes.popupSize) === null || _a === void 0 ? void 0 : _a.width;
|
|
84
|
+
var height = (_b = popupWindowAttributes.popupSize) === null || _b === void 0 ? void 0 : _b.height;
|
|
85
|
+
var top = (_c = popupWindowAttributes.popupPosition) === null || _c === void 0 ? void 0 : _c.top;
|
|
86
|
+
var left = (_d = popupWindowAttributes.popupPosition) === null || _d === void 0 ? void 0 : _d.left;
|
|
87
|
+
if (!width || width < 0 || width > winWidth) {
|
|
88
|
+
logger.verbose("Default popup window width used. Window width not configured or invalid.");
|
|
89
|
+
width = BrowserConstants.POPUP_WIDTH;
|
|
90
|
+
}
|
|
91
|
+
if (!height || height < 0 || height > winHeight) {
|
|
92
|
+
logger.verbose("Default popup window height used. Window height not configured or invalid.");
|
|
93
|
+
height = BrowserConstants.POPUP_HEIGHT;
|
|
94
|
+
}
|
|
95
|
+
if (!top || top < 0 || top > winHeight) {
|
|
96
|
+
logger.verbose("Default popup window top position used. Window top not configured or invalid.");
|
|
97
|
+
top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);
|
|
98
|
+
}
|
|
99
|
+
if (!left || left < 0 || left > winWidth) {
|
|
100
|
+
logger.verbose("Default popup window left position used. Window left not configured or invalid.");
|
|
101
|
+
left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);
|
|
102
|
+
}
|
|
103
|
+
return window.open(urlNavigate, popupName, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", scrollbars=yes");
|
|
77
104
|
};
|
|
78
105
|
/**
|
|
79
106
|
* Event callback to unload main window.
|
|
@@ -98,7 +125,7 @@ var PopupUtils = /** @class */ (function () {
|
|
|
98
125
|
// Remove window unload function
|
|
99
126
|
window.removeEventListener("beforeunload", this.unloadWindow);
|
|
100
127
|
// Interaction is completed - remove interaction status.
|
|
101
|
-
this.browserStorage.
|
|
128
|
+
this.browserStorage.setInteractionInProgress(false);
|
|
102
129
|
};
|
|
103
130
|
/**
|
|
104
131
|
* Monitors a window until it loads a url with the same origin.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupUtils.js","sources":["../../src/utils/PopupUtils.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { CommonEndSessionRequest, Constants, Logger, StringUtils } from \"@azure/msal-common\";\r\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\r\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\r\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\r\nimport { BrowserConstants, InteractionType, TemporaryCacheKeys } from \"./BrowserConstants\";\r\n\r\nexport class PopupUtils {\r\n private browserStorage: BrowserCacheManager;\r\n private logger: Logger;\r\n private currentWindow: Window|undefined;\r\n\r\n constructor(storageImpl: BrowserCacheManager, logger: Logger) {\r\n this.browserStorage = storageImpl;\r\n this.logger = logger;\r\n\r\n // Properly sets this reference for the unload event.\r\n this.unloadWindow = this.unloadWindow.bind(this);\r\n }\r\n\r\n /**\r\n * @hidden\r\n *\r\n * Configures popup window for login.\r\n *\r\n * @param urlNavigate\r\n * @param title\r\n * @param popUpWidth\r\n * @param popUpHeight\r\n * @ignore\r\n * @hidden\r\n */\r\n openPopup(urlNavigate: string, popupName: string, popup?: Window|null): Window {\r\n try {\r\n let popupWindow;\r\n // Popup window passed in, setting url to navigate to\r\n if (popup) {\r\n popupWindow = popup;\r\n this.logger.verbosePii(`Navigating popup window to: ${urlNavigate}`);\r\n popupWindow.location.assign(urlNavigate);\r\n } else if (typeof popup === \"undefined\") {\r\n // Popup will be undefined if it was not passed in\r\n this.logger.verbosePii(`Opening popup window to: ${urlNavigate}`);\r\n popupWindow = PopupUtils.openSizedPopup(urlNavigate, popupName);\r\n }\r\n\r\n // Popup will be null if popups are blocked\r\n if (!popupWindow) {\r\n throw BrowserAuthError.createEmptyWindowCreatedError();\r\n }\r\n if (popupWindow.focus) {\r\n popupWindow.focus();\r\n }\r\n this.currentWindow = popupWindow;\r\n window.addEventListener(\"beforeunload\", this.unloadWindow);\r\n\r\n return popupWindow;\r\n } catch (e) {\r\n this.logger.error(\"error opening popup \" + e.message);\r\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.INTERACTION_STATUS_KEY));\r\n throw BrowserAuthError.createPopupWindowError(e.toString());\r\n }\r\n }\r\n\r\n static openSizedPopup(urlNavigate: string, popupName: string): Window|null {\r\n /**\r\n * adding winLeft and winTop to account for dual monitor\r\n * using screenLeft and screenTop for IE8 and earlier\r\n */\r\n const winLeft = window.screenLeft ? window.screenLeft : window.screenX;\r\n const winTop = window.screenTop ? window.screenTop : window.screenY;\r\n /**\r\n * window.innerWidth displays browser window\"s height and width excluding toolbars\r\n * using document.documentElement.clientWidth for IE8 and earlier\r\n */\r\n const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\r\n const height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;\r\n const left = Math.max(0, ((width / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);\r\n const top = Math.max(0, ((height / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);\r\n\r\n return window.open(urlNavigate, popupName, `width=${BrowserConstants.POPUP_WIDTH}, height=${BrowserConstants.POPUP_HEIGHT}, top=${top}, left=${left}, scrollbars=yes`);\r\n }\r\n\r\n /**\r\n * Event callback to unload main window.\r\n */\r\n unloadWindow(e: Event): void {\r\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Popup);\r\n if (this.currentWindow) {\r\n this.currentWindow.close();\r\n }\r\n // Guarantees browser unload will happen, so no other errors will be thrown.\r\n e.preventDefault();\r\n }\r\n\r\n /**\r\n * Closes popup, removes any state vars created during popup calls.\r\n * @param popupWindow\r\n */\r\n cleanPopup(popupWindow?: Window): void {\r\n if (popupWindow) {\r\n // Close window.\r\n popupWindow.close();\r\n }\r\n // Remove window unload function\r\n window.removeEventListener(\"beforeunload\", this.unloadWindow);\r\n\r\n // Interaction is completed - remove interaction status.\r\n this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.INTERACTION_STATUS_KEY));\r\n }\r\n\r\n /**\r\n * Monitors a window until it loads a url with the same origin.\r\n * @param popupWindow - window that is being monitored\r\n */\r\n monitorPopupForSameOrigin(popupWindow: Window): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n const intervalId = setInterval(() => {\r\n if (popupWindow.closed) {\r\n // Window is closed\r\n this.cleanPopup();\r\n clearInterval(intervalId);\r\n reject(BrowserAuthError.createUserCancelledError());\r\n return;\r\n }\r\n\r\n let href: string = Constants.EMPTY_STRING;\r\n try {\r\n /*\r\n * Will throw if cross origin,\r\n * which should be caught and ignored\r\n * since we need the interval to keep running while on STS UI.\r\n */\r\n href = popupWindow.location.href;\r\n } catch (e) {}\r\n\r\n // Don't process blank pages or cross domain\r\n if (StringUtils.isEmpty(href) || href === \"about:blank\") {\r\n return;\r\n }\r\n\r\n clearInterval(intervalId);\r\n resolve();\r\n }, BrowserConstants.POLL_INTERVAL_MS);\r\n });\r\n }\r\n\r\n /**\r\n * Generates the name for the popup based on the client id and request\r\n * @param clientId\r\n * @param request\r\n */\r\n static generatePopupName(clientId: string, request: AuthorizationUrlRequest): string {\r\n return `${BrowserConstants.POPUP_NAME_PREFIX}.${clientId}.${request.scopes.join(\"-\")}.${request.authority}.${request.correlationId}`;\r\n }\r\n\r\n /**\r\n * Generates the name for the popup based on the client id and request for logouts\r\n * @param clientId \r\n * @param request \r\n */\r\n static generateLogoutPopupName(clientId: string, request: CommonEndSessionRequest): string {\r\n const homeAccountId = request.account && request.account.homeAccountId;\r\n return `${BrowserConstants.POPUP_NAME_PREFIX}.${clientId}.${homeAccountId}.${request.correlationId}`;\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;AAAA;;;;;IAgBI,oBAAY,WAAgC,EAAE,MAAc;QACxD,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;QAGrB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpD;;;;;;;;;;;;;IAcD,8BAAS,GAAT,UAAU,WAAmB,EAAE,SAAiB,EAAE,KAAmB;QACjE,IAAI;YACA,IAAI,WAAW,SAAA,CAAC;;YAEhB,IAAI,KAAK,EAAE;g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,OAAO,CAAC,aAAe,CAAC;KACxG;IACL,iBAAC;AAAD,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"PopupUtils.js","sources":["../../src/utils/PopupUtils.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { CommonEndSessionRequest, Constants, Logger, StringUtils } from \"@azure/msal-common\";\nimport { BrowserCacheManager } from \"../cache/BrowserCacheManager\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { PopupParams } from \"../interaction_handler/PopupHandler\";\nimport { AuthorizationUrlRequest } from \"../request/AuthorizationUrlRequest\";\nimport { BrowserConstants, InteractionType } from \"./BrowserConstants\";\n\n/**\n * Popup configurations for setting dimensions and position of popup window\n */\nexport type PopupWindowAttributes = {\n popupSize?: PopupSize,\n popupPosition?: PopupPosition\n};\n\nexport type PopupSize = {\n height: number;\n width: number;\n};\n\nexport type PopupPosition = {\n top: number;\n left: number;\n};\n\nexport class PopupUtils {\n private browserStorage: BrowserCacheManager;\n private logger: Logger;\n private currentWindow: Window|undefined;\n\n constructor(storageImpl: BrowserCacheManager, logger: Logger) {\n this.browserStorage = storageImpl;\n this.logger = logger;\n\n // Properly sets this reference for the unload event.\n this.unloadWindow = this.unloadWindow.bind(this);\n }\n\n /**\n * @hidden\n *\n * Configures popup window for login.\n *\n * @param urlNavigate\n * @param title\n * @param popUpWidth\n * @param popUpHeight\n * @param popupWindowAttributes\n * @ignore\n * @hidden\n */\n openPopup(urlNavigate: string, popupParams: PopupParams): Window {\n try {\n let popupWindow;\n // Popup window passed in, setting url to navigate to\n if (popupParams.popup) {\n popupWindow = popupParams.popup;\n this.logger.verbosePii(`Navigating popup window to: ${urlNavigate}`);\n popupWindow.location.assign(urlNavigate);\n } else if (typeof popupParams.popup === \"undefined\") {\n // Popup will be undefined if it was not passed in\n this.logger.verbosePii(`Opening popup window to: ${urlNavigate}`);\n popupWindow = PopupUtils.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes, this.logger);\n }\n\n // Popup will be null if popups are blocked\n if (!popupWindow) {\n throw BrowserAuthError.createEmptyWindowCreatedError();\n }\n if (popupWindow.focus) {\n popupWindow.focus();\n }\n this.currentWindow = popupWindow;\n window.addEventListener(\"beforeunload\", this.unloadWindow);\n\n return popupWindow;\n } catch (e) {\n this.logger.error(\"error opening popup \" + e.message);\n this.browserStorage.setInteractionInProgress(false);\n throw BrowserAuthError.createPopupWindowError(e.toString());\n }\n }\n\n /**\n * Helper function to set popup window dimensions and position\n * @param urlNavigate \n * @param popupName \n * @param popupWindowAttributes \n * @returns \n */\n static openSizedPopup(urlNavigate: string, popupName: string, popupWindowAttributes: PopupWindowAttributes, logger: Logger): Window|null {\n /**\n * adding winLeft and winTop to account for dual monitor\n * using screenLeft and screenTop for IE8 and earlier\n */\n const winLeft = window.screenLeft ? window.screenLeft : window.screenX;\n const winTop = window.screenTop ? window.screenTop : window.screenY;\n /**\n * window.innerWidth displays browser window\"s height and width excluding toolbars\n * using document.documentElement.clientWidth for IE8 and earlier\n */\n const winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\n const winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;\n\n let width = popupWindowAttributes.popupSize?.width;\n let height = popupWindowAttributes.popupSize?.height;\n let top = popupWindowAttributes.popupPosition?.top;\n let left = popupWindowAttributes.popupPosition?.left;\n\n if (!width || width < 0 || width > winWidth) {\n logger.verbose(\"Default popup window width used. Window width not configured or invalid.\");\n width = BrowserConstants.POPUP_WIDTH;\n }\n\n if (!height || height < 0 || height > winHeight) {\n logger.verbose(\"Default popup window height used. Window height not configured or invalid.\");\n height = BrowserConstants.POPUP_HEIGHT;\n }\n\n if (!top || top < 0 || top > winHeight) {\n logger.verbose(\"Default popup window top position used. Window top not configured or invalid.\");\n top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);\n }\n\n if (!left || left < 0 || left > winWidth) {\n logger.verbose(\"Default popup window left position used. Window left not configured or invalid.\");\n left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);\n }\n\n return window.open(urlNavigate, popupName, `width=${width}, height=${height}, top=${top}, left=${left}, scrollbars=yes`);\n }\n\n /**\n * Event callback to unload main window.\n */\n unloadWindow(e: Event): void {\n this.browserStorage.cleanRequestByInteractionType(InteractionType.Popup);\n if (this.currentWindow) {\n this.currentWindow.close();\n }\n // Guarantees browser unload will happen, so no other errors will be thrown.\n e.preventDefault();\n }\n\n /**\n * Closes popup, removes any state vars created during popup calls.\n * @param popupWindow\n */\n cleanPopup(popupWindow?: Window): void {\n if (popupWindow) {\n // Close window.\n popupWindow.close();\n }\n // Remove window unload function\n window.removeEventListener(\"beforeunload\", this.unloadWindow);\n\n // Interaction is completed - remove interaction status.\n this.browserStorage.setInteractionInProgress(false);\n }\n\n /**\n * Monitors a window until it loads a url with the same origin.\n * @param popupWindow - window that is being monitored\n */\n monitorPopupForSameOrigin(popupWindow: Window): Promise<void> {\n return new Promise((resolve, reject) => {\n const intervalId = setInterval(() => {\n if (popupWindow.closed) {\n // Window is closed\n this.cleanPopup();\n clearInterval(intervalId);\n reject(BrowserAuthError.createUserCancelledError());\n return;\n }\n\n let href: string = Constants.EMPTY_STRING;\n try {\n /*\n * Will throw if cross origin,\n * which should be caught and ignored\n * since we need the interval to keep running while on STS UI.\n */\n href = popupWindow.location.href;\n } catch (e) {}\n\n // Don't process blank pages or cross domain\n if (StringUtils.isEmpty(href) || href === \"about:blank\") {\n return;\n }\n\n clearInterval(intervalId);\n resolve();\n }, BrowserConstants.POLL_INTERVAL_MS);\n });\n }\n\n /**\n * Generates the name for the popup based on the client id and request\n * @param clientId\n * @param request\n */\n static generatePopupName(clientId: string, request: AuthorizationUrlRequest): string {\n return `${BrowserConstants.POPUP_NAME_PREFIX}.${clientId}.${request.scopes.join(\"-\")}.${request.authority}.${request.correlationId}`;\n }\n\n /**\n * Generates the name for the popup based on the client id and request for logouts\n * @param clientId \n * @param request \n */\n static generateLogoutPopupName(clientId: string, request: CommonEndSessionRequest): string {\n const homeAccountId = request.account && request.account.homeAccountId;\n return `${BrowserConstants.POPUP_NAME_PREFIX}.${clientId}.${homeAccountId}.${request.correlationId}`;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;;IAmCI,oBAAY,WAAgC,EAAE,MAAc;QACxD,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;QAGrB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpD;;;;;;;;;;;;;;IAeD,8BAAS,GAAT,UAAU,WAAmB,EAAE,WAAwB;QACnD,IAAI;YACA,IAAI,WAAW,SAAA,CAAC;;YAEhB,IAAI,WAAW,CAAC,KAAK,EAAE;gBACnB,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC;gBAChC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,iCAA+B,WAAa,CAAC,CAAC;gBACrE,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;aAC5C;iBAAM,IAAI,OAAO,WAAW,CAAC,KAAK,KAAK,WAAW,EAAE;;gBAEjD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,8BAA4B,WAAa,CAAC,CAAC;gBAClE,WAAW,GAAG,UAAU,CAAC,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,qBAAqB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;aAC/H;;YAGD,IAAI,CAAC,WAAW,EAAE;gBACd,MAAM,gBAAgB,CAAC,6BAA6B,EAAE,CAAC;aAC1D;YACD,IAAI,WAAW,CAAC,KAAK,EAAE;gBACnB,WAAW,CAAC,KAAK,EAAE,CAAC;aACvB;YACD,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC;YACj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