@azure/msal-browser 3.2.0 → 3.3.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/dist/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.mjs +2 -2
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.d.ts +274 -0
- package/dist/app/PublicClientNext.d.ts.map +1 -0
- package/dist/app/PublicClientNext.mjs +362 -0
- package/dist/app/PublicClientNext.mjs.map +1 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +2 -13
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +7 -64
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/CryptoKeyStore.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/config/Configuration.d.ts +4 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +2 -1
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.d.ts +2 -1
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +26 -19
- package/dist/controllers/ControllerFactory.mjs.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +96 -0
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
- package/dist/controllers/NestedAppAuthController.mjs +345 -0
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +16 -13
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
- package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
- package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +3 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +8 -5
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.d.ts +15 -0
- package/dist/error/NestedAppAuthError.d.ts.map +1 -0
- package/dist/error/NestedAppAuthError.mjs +30 -0
- package/dist/error/NestedAppAuthError.mjs.map +1 -0
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +4 -4
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +15 -4
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +5 -4
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +7 -7
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +4 -4
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +4 -3
- package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +27 -13
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +13 -47
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +120 -155
- package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
- package/dist/naa/AccountInfo.d.ts +13 -0
- package/dist/naa/AccountInfo.d.ts.map +1 -0
- package/dist/naa/AccountRequests.d.ts +10 -0
- package/dist/naa/AccountRequests.d.ts.map +1 -0
- package/dist/naa/AuthBridge.d.ts +6 -0
- package/dist/naa/AuthBridge.d.ts.map +1 -0
- package/dist/naa/BridgeCapabilities.d.ts +4 -0
- package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
- package/dist/naa/BridgeError.d.ts +10 -0
- package/dist/naa/BridgeError.d.ts.map +1 -0
- package/dist/naa/BridgeError.mjs +12 -0
- package/dist/naa/BridgeError.mjs.map +1 -0
- package/dist/naa/BridgeProxy.d.ts +72 -0
- package/dist/naa/BridgeProxy.d.ts.map +1 -0
- package/dist/naa/BridgeProxy.mjs +154 -0
- package/dist/naa/BridgeProxy.mjs.map +1 -0
- package/dist/naa/BridgeRequest.d.ts +7 -0
- package/dist/naa/BridgeRequest.d.ts.map +1 -0
- package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
- package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
- package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
- package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
- package/dist/naa/BridgeStatusCode.d.ts +11 -0
- package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
- package/dist/naa/BridgeStatusCode.mjs +20 -0
- package/dist/naa/BridgeStatusCode.mjs.map +1 -0
- package/dist/naa/IBridgeProxy.d.ts +11 -0
- package/dist/naa/IBridgeProxy.d.ts.map +1 -0
- package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
- package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
- package/dist/naa/TokenRequest.d.ts +22 -0
- package/dist/naa/TokenRequest.d.ts.map +1 -0
- package/dist/naa/TokenResponse.d.ts +17 -0
- package/dist/naa/TokenResponse.d.ts.map +1 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
- package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
- package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.d.ts +54 -53
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +114 -102
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +61 -17728
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +14625 -13223
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +66 -68
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +1 -1
- package/src/app/PublicClientNext.ts +442 -0
- package/src/cache/BrowserCacheManager.ts +11 -100
- package/src/config/Configuration.ts +5 -0
- package/src/controllers/ControllerFactory.ts +36 -25
- package/src/controllers/NestedAppAuthController.ts +525 -0
- package/src/controllers/StandardController.ts +8 -6
- package/src/controllers/UnknownOperatingContextController.ts +383 -0
- package/src/crypto/BrowserCrypto.ts +2 -2
- package/src/crypto/CryptoOps.ts +8 -5
- package/src/error/NestedAppAuthError.ts +32 -0
- package/src/index.ts +3 -10
- package/src/interaction_client/BaseInteractionClient.ts +1 -1
- package/src/interaction_client/NativeInteractionClient.ts +19 -3
- package/src/interaction_client/PopupClient.ts +2 -1
- package/src/interaction_client/RedirectClient.ts +1 -1
- package/src/interaction_client/SilentAuthCodeClient.ts +5 -4
- package/src/interaction_client/SilentCacheClient.ts +11 -3
- package/src/interaction_client/SilentIframeClient.ts +53 -17
- package/src/interaction_client/StandardInteractionClient.ts +1 -1
- package/src/interaction_handler/SilentHandler.ts +177 -233
- package/src/naa/AccountInfo.ts +17 -0
- package/src/naa/AccountRequests.ts +16 -0
- package/src/naa/AuthBridge.ts +16 -0
- package/src/naa/BridgeCapabilities.ts +8 -0
- package/src/naa/BridgeError.ts +18 -0
- package/src/naa/BridgeProxy.ts +230 -0
- package/src/naa/BridgeRequest.ts +12 -0
- package/src/naa/BridgeRequestEnvelope.ts +46 -0
- package/src/naa/BridgeResponseEnvelope.ts +21 -0
- package/src/naa/BridgeStatusCode.ts +15 -0
- package/src/naa/IBridgeProxy.ts +25 -0
- package/src/naa/InitializeBridgeResponse.ts +12 -0
- package/src/naa/TokenRequest.ts +26 -0
- package/src/naa/TokenResponse.ts +61 -0
- package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
- package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
- package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
- package/src/packageMetadata.ts +1 -1
- package/src/utils/BrowserUtils.ts +133 -125
- package/dist/utils/BrowserStringUtils.d.ts +0 -22
- package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
- package/dist/utils/BrowserStringUtils.mjs +0 -144
- package/dist/utils/BrowserStringUtils.mjs.map +0 -1
- package/src/utils/BrowserStringUtils.ts +0 -143
|
@@ -1,56 +1,57 @@
|
|
|
1
1
|
import { InteractionType } from "./BrowserConstants";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
3
|
+
* Clears hash from window url.
|
|
4
|
+
*/
|
|
5
|
+
export declare function clearHash(contentWindow: Window): void;
|
|
6
|
+
/**
|
|
7
|
+
* Replaces current hash with hash from provided url
|
|
8
|
+
*/
|
|
9
|
+
export declare function replaceHash(url: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Returns boolean of whether the current window is in an iframe or not.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isInIframe(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Returns boolean of whether or not the current window is a popup opened by msal
|
|
16
|
+
*/
|
|
17
|
+
export declare function isInPopup(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Returns current window URL as redirect uri
|
|
20
|
+
*/
|
|
21
|
+
export declare function getCurrentUri(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the homepage url for the current window location.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getHomepage(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Throws error if we have completed an auth and are
|
|
28
|
+
* attempting another auth request inside an iframe.
|
|
29
|
+
*/
|
|
30
|
+
export declare function blockReloadInHiddenIframes(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Block redirect operations in iframes unless explicitly allowed
|
|
33
|
+
* @param interactionType Interaction type for the request
|
|
34
|
+
* @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
|
|
35
|
+
*/
|
|
36
|
+
export declare function blockRedirectInIframe(interactionType: InteractionType, allowRedirectInIframe: boolean): void;
|
|
37
|
+
/**
|
|
38
|
+
* Block redirectUri loaded in popup from calling AcquireToken APIs
|
|
39
|
+
*/
|
|
40
|
+
export declare function blockAcquireTokenInPopups(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Throws error if token requests are made in non-browser environment
|
|
43
|
+
* @param isBrowserEnvironment Flag indicating if environment is a browser.
|
|
44
|
+
*/
|
|
45
|
+
export declare function blockNonBrowserEnvironment(isBrowserEnvironment: boolean): void;
|
|
46
|
+
/**
|
|
47
|
+
* Throws error if initialize hasn't been called
|
|
48
|
+
* @param initialized
|
|
49
|
+
*/
|
|
50
|
+
export declare function blockAPICallsBeforeInitialize(initialized: boolean): void;
|
|
51
|
+
/**
|
|
52
|
+
* Adds a preconnect link element to the header which begins DNS resolution and SSL connection in anticipation of the /token request
|
|
53
|
+
* @param loginDomain Authority domain, including https protocol e.g. https://login.microsoftonline.com
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
export declare function preconnect(authority: string): void;
|
|
56
57
|
//# sourceMappingURL=BrowserUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserUtils.d.ts","sourceRoot":"","sources":["../../src/utils/BrowserUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAoB,MAAM,oBAAoB,CAAC;AAEvE;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"BrowserUtils.d.ts","sourceRoot":"","sources":["../../src/utils/BrowserUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAoB,MAAM,oBAAoB,CAAC;AAEvE;;GAEG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAWrD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI7C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAQnC;AAID;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAIpC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAQjD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACjC,eAAe,EAAE,eAAe,EAChC,qBAAqB,EAAE,OAAO,GAC/B,IAAI,CAUN;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAKhD;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACtC,oBAAoB,EAAE,OAAO,GAC9B,IAAI,CAMN;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAMxE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAalD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.
|
|
1
|
+
/*! @azure/msal-browser v3.3.0 2023-10-20 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import {
|
|
3
|
+
import { UrlString } from '@azure/msal-common';
|
|
4
4
|
import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
|
|
5
5
|
import { BrowserConstants, InteractionType } from './BrowserConstants.mjs';
|
|
6
6
|
import { blockIframeReload, redirectInIframe, blockNestedPopups, nonBrowserEnvironment, uninitializedPublicClientApplication } from '../error/BrowserAuthErrorCodes.mjs';
|
|
@@ -10,114 +10,126 @@ import { blockIframeReload, redirectInIframe, blockNestedPopups, nonBrowserEnvir
|
|
|
10
10
|
* Licensed under the MIT License.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Clears hash from window url.
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Office.js sets history.replaceState to null
|
|
22
|
-
contentWindow.location.hash = Constants.EMPTY_STRING;
|
|
23
|
-
if (typeof contentWindow.history.replaceState === "function") {
|
|
24
|
-
// Full removes "#" from url
|
|
25
|
-
contentWindow.history.replaceState(null, Constants.EMPTY_STRING, `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Replaces current hash with hash from provided url
|
|
30
|
-
*/
|
|
31
|
-
static replaceHash(url) {
|
|
32
|
-
const urlParts = url.split("#");
|
|
33
|
-
urlParts.shift(); // Remove part before the hash
|
|
34
|
-
window.location.hash =
|
|
35
|
-
urlParts.length > 0 ? urlParts.join("#") : Constants.EMPTY_STRING;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Returns boolean of whether the current window is in an iframe or not.
|
|
39
|
-
*/
|
|
40
|
-
static isInIframe() {
|
|
41
|
-
return window.parent !== window;
|
|
15
|
+
function clearHash(contentWindow) {
|
|
16
|
+
// Office.js sets history.replaceState to null
|
|
17
|
+
contentWindow.location.hash = "";
|
|
18
|
+
if (typeof contentWindow.history.replaceState === "function") {
|
|
19
|
+
// Full removes "#" from url
|
|
20
|
+
contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`);
|
|
42
21
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Replaces current hash with hash from provided url
|
|
25
|
+
*/
|
|
26
|
+
function replaceHash(url) {
|
|
27
|
+
const urlParts = url.split("#");
|
|
28
|
+
urlParts.shift(); // Remove part before the hash
|
|
29
|
+
window.location.hash = urlParts.length > 0 ? urlParts.join("#") : "";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns boolean of whether the current window is in an iframe or not.
|
|
33
|
+
*/
|
|
34
|
+
function isInIframe() {
|
|
35
|
+
return window.parent !== window;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns boolean of whether or not the current window is a popup opened by msal
|
|
39
|
+
*/
|
|
40
|
+
function isInPopup() {
|
|
41
|
+
return (typeof window !== "undefined" &&
|
|
42
|
+
!!window.opener &&
|
|
43
|
+
window.opener !== window &&
|
|
44
|
+
typeof window.name === "string" &&
|
|
45
|
+
window.name.indexOf(`${BrowserConstants.POPUP_NAME_PREFIX}.`) === 0);
|
|
46
|
+
}
|
|
47
|
+
// #endregion
|
|
48
|
+
/**
|
|
49
|
+
* Returns current window URL as redirect uri
|
|
50
|
+
*/
|
|
51
|
+
function getCurrentUri() {
|
|
52
|
+
return window.location.href.split("?")[0].split("#")[0];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the homepage url for the current window location.
|
|
56
|
+
*/
|
|
57
|
+
function getHomepage() {
|
|
58
|
+
const currentUrl = new UrlString(window.location.href);
|
|
59
|
+
const urlComponents = currentUrl.getUrlComponents();
|
|
60
|
+
return `${urlComponents.Protocol}//${urlComponents.HostNameAndPort}/`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Throws error if we have completed an auth and are
|
|
64
|
+
* attempting another auth request inside an iframe.
|
|
65
|
+
*/
|
|
66
|
+
function blockReloadInHiddenIframes() {
|
|
67
|
+
const isResponseHash = UrlString.hashContainsKnownProperties(window.location.hash);
|
|
68
|
+
// return an error if called from the hidden iframe created by the msal js silent calls
|
|
69
|
+
if (isResponseHash && isInIframe()) {
|
|
70
|
+
throw createBrowserAuthError(blockIframeReload);
|
|
67
71
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Block redirect operations in iframes unless explicitly allowed
|
|
75
|
+
* @param interactionType Interaction type for the request
|
|
76
|
+
* @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
|
|
77
|
+
*/
|
|
78
|
+
function blockRedirectInIframe(interactionType, allowRedirectInIframe) {
|
|
79
|
+
const isIframedApp = isInIframe();
|
|
80
|
+
if (interactionType === InteractionType.Redirect &&
|
|
81
|
+
isIframedApp &&
|
|
82
|
+
!allowRedirectInIframe) {
|
|
83
|
+
// If we are not in top frame, we shouldn't redirect. This is also handled by the service.
|
|
84
|
+
throw createBrowserAuthError(redirectInIframe);
|
|
78
85
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
isIframedApp &&
|
|
88
|
-
!allowRedirectInIframe) {
|
|
89
|
-
// If we are not in top frame, we shouldn't redirect. This is also handled by the service.
|
|
90
|
-
throw createBrowserAuthError(redirectInIframe);
|
|
91
|
-
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Block redirectUri loaded in popup from calling AcquireToken APIs
|
|
89
|
+
*/
|
|
90
|
+
function blockAcquireTokenInPopups() {
|
|
91
|
+
// Popups opened by msal popup APIs are given a name that starts with "msal."
|
|
92
|
+
if (isInPopup()) {
|
|
93
|
+
throw createBrowserAuthError(blockNestedPopups);
|
|
92
94
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Throws error if token requests are made in non-browser environment
|
|
98
|
+
* @param isBrowserEnvironment Flag indicating if environment is a browser.
|
|
99
|
+
*/
|
|
100
|
+
function blockNonBrowserEnvironment(isBrowserEnvironment) {
|
|
101
|
+
if (!isBrowserEnvironment) {
|
|
102
|
+
throw createBrowserAuthError(nonBrowserEnvironment);
|
|
101
103
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Throws error if initialize hasn't been called
|
|
107
|
+
* @param initialized
|
|
108
|
+
*/
|
|
109
|
+
function blockAPICallsBeforeInitialize(initialized) {
|
|
110
|
+
if (!initialized) {
|
|
111
|
+
throw createBrowserAuthError(uninitializedPublicClientApplication);
|
|
110
112
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Adds a preconnect link element to the header which begins DNS resolution and SSL connection in anticipation of the /token request
|
|
116
|
+
* @param loginDomain Authority domain, including https protocol e.g. https://login.microsoftonline.com
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
function preconnect(authority) {
|
|
120
|
+
const link = document.createElement("link");
|
|
121
|
+
link.rel = "preconnect";
|
|
122
|
+
link.href = new URL(authority).origin;
|
|
123
|
+
link.crossOrigin = "anonymous";
|
|
124
|
+
document.head.appendChild(link);
|
|
125
|
+
// The browser will close connection if not used within a few seconds, remove element from the header after 10s
|
|
126
|
+
window.setTimeout(() => {
|
|
127
|
+
try {
|
|
128
|
+
document.head.removeChild(link);
|
|
118
129
|
}
|
|
119
|
-
|
|
130
|
+
catch { }
|
|
131
|
+
}, 10000); // 10s Timeout
|
|
120
132
|
}
|
|
121
133
|
|
|
122
|
-
export {
|
|
134
|
+
export { blockAPICallsBeforeInitialize, blockAcquireTokenInPopups, blockNonBrowserEnvironment, blockRedirectInIframe, blockReloadInHiddenIframes, clearHash, getCurrentUri, getHomepage, isInIframe, isInPopup, preconnect, replaceHash };
|
|
123
135
|
//# sourceMappingURL=BrowserUtils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserUtils.mjs","sources":["../../src/utils/BrowserUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAUA;AAEA;;AAEG;
|
|
1
|
+
{"version":3,"file":"BrowserUtils.mjs","sources":["../../src/utils/BrowserUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAUA;AAEA;;AAEG;AAgBA;AACH;AAMA;;AAEG;AACH,IAAgB,aAAA,CAAA,QAAA,CAAA,IAAA,GAAU,EAAI,CAAA;AAI9B,IAAA,IAAA,OAAA,aAAA,CAAA,OAAA,CAAA,YAAA,KAAA,UAAA,EAAA;;AAEG,QAAA,aAAA,CAAA,OAAA,CAAA,YAAA,CAAA,IAAA,EAAA,EAAA,EAAA,CAAA,EAAA,aAAA,CAAA,QAAA,CAAA,MAAA,CAAA,EAAA,aAAA,CAAA,QAAA,CAAA,QAAA,CAAA,EAAA,aAAA,CAAA,QAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA;AACH,KAAgB;AAYhB,CAAA;;AAEG;AACH;AAIA,SAAA,WAAA,CAAA,GAAA,EAAA;;AAEG,IAAA,QAAA,CAAA,KAAA,EAAA,CAAA;AACH,IAAgB,MAAA,CAAA,QAAA,CAAA,IAAA,GAAA,QAAW,CAAI,MAAA,GAAM,CAIpC,GAAA,QAAA,CAAA,IAAA,CAAA,GAAA,CAAA,GAAA,EAAA,CAAA;AAED,CAAA;;;AAGG;AACa,SAAA,UAAA,GAAA;AAUhB,IAAA,OAAA,MAAA,CAAA,MAAA,KAAA,MAAA,CAAA;;;;AAIG;AACa,SAAA,SAAA,GAAA;AAehB,IAAA,QAAA,OAAA,MAAA,KAAA,WAAA;;AAEG,QAAA,MAAA,CAAA,MAAA,KAAA,MAAA;AACH,QAAgB,OAAA,MAAA,CAAA,IAAA,KAAA,QAAA;AAOhB,QAAA,MAAA,CAAA,IAAA,CAAA,OAAA,CAAA,CAAA,EAAA,gBAAA,CAAA,iBAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,EAAA;;;AAGG;AACH;AAUA;;;AAGG,CAAA;AACH;AAQA;;;;AAIG,IAAA,MAAA,aAAA,GAAA,UAAA,CAAA,gBAAA,EAAA,CAAA;AACH,IAAA,OAAA,CAAA,EAAA,sBAA2B,CAAA,EAAA,EAAA,aAAiB,CAAG,eAa9C,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|