@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.
Files changed (202) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +2 -2
  3. package/dist/app/PublicClientApplication.mjs.map +1 -1
  4. package/dist/app/PublicClientNext.d.ts +274 -0
  5. package/dist/app/PublicClientNext.d.ts.map +1 -0
  6. package/dist/app/PublicClientNext.mjs +362 -0
  7. package/dist/app/PublicClientNext.mjs.map +1 -0
  8. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  9. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  10. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  11. package/dist/cache/BrowserCacheManager.d.ts +2 -13
  12. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  13. package/dist/cache/BrowserCacheManager.mjs +7 -64
  14. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  15. package/dist/cache/BrowserStorage.mjs +1 -1
  16. package/dist/cache/CryptoKeyStore.mjs +1 -1
  17. package/dist/cache/DatabaseStorage.mjs +1 -1
  18. package/dist/cache/MemoryStorage.mjs +1 -1
  19. package/dist/cache/TokenCache.mjs +1 -1
  20. package/dist/config/Configuration.d.ts +4 -0
  21. package/dist/config/Configuration.d.ts.map +1 -1
  22. package/dist/config/Configuration.mjs +2 -1
  23. package/dist/config/Configuration.mjs.map +1 -1
  24. package/dist/controllers/ControllerFactory.d.ts +2 -1
  25. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  26. package/dist/controllers/ControllerFactory.mjs +26 -19
  27. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  28. package/dist/controllers/NestedAppAuthController.d.ts +96 -0
  29. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
  30. package/dist/controllers/NestedAppAuthController.mjs +345 -0
  31. package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
  32. package/dist/controllers/StandardController.d.ts.map +1 -1
  33. package/dist/controllers/StandardController.mjs +16 -13
  34. package/dist/controllers/StandardController.mjs.map +1 -1
  35. package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
  36. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
  37. package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
  38. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
  39. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  40. package/dist/crypto/BrowserCrypto.mjs +3 -3
  41. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  42. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  43. package/dist/crypto/CryptoOps.mjs +8 -5
  44. package/dist/crypto/CryptoOps.mjs.map +1 -1
  45. package/dist/crypto/PkceGenerator.mjs +1 -1
  46. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  47. package/dist/encode/Base64Decode.mjs +1 -1
  48. package/dist/encode/Base64Encode.mjs +1 -1
  49. package/dist/error/BrowserAuthError.mjs +1 -1
  50. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  51. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  52. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  53. package/dist/error/NativeAuthError.mjs +1 -1
  54. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  55. package/dist/error/NestedAppAuthError.d.ts +15 -0
  56. package/dist/error/NestedAppAuthError.d.ts.map +1 -0
  57. package/dist/error/NestedAppAuthError.mjs +30 -0
  58. package/dist/error/NestedAppAuthError.mjs.map +1 -0
  59. package/dist/event/EventHandler.mjs +1 -1
  60. package/dist/event/EventMessage.mjs +1 -1
  61. package/dist/event/EventType.mjs +1 -1
  62. package/dist/index.d.ts +3 -5
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.mjs +4 -2
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/interaction_client/BaseInteractionClient.mjs +4 -4
  67. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  68. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  69. package/dist/interaction_client/NativeInteractionClient.mjs +15 -4
  70. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  71. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  72. package/dist/interaction_client/PopupClient.mjs +5 -4
  73. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  74. package/dist/interaction_client/RedirectClient.mjs +7 -7
  75. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  76. package/dist/interaction_client/SilentAuthCodeClient.mjs +4 -4
  77. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  78. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  79. package/dist/interaction_client/SilentCacheClient.mjs +4 -3
  80. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  81. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  82. package/dist/interaction_client/SilentIframeClient.mjs +27 -13
  83. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  84. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  85. package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
  86. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  87. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  88. package/dist/interaction_handler/SilentHandler.d.ts +13 -47
  89. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  90. package/dist/interaction_handler/SilentHandler.mjs +120 -155
  91. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  92. package/dist/naa/AccountInfo.d.ts +13 -0
  93. package/dist/naa/AccountInfo.d.ts.map +1 -0
  94. package/dist/naa/AccountRequests.d.ts +10 -0
  95. package/dist/naa/AccountRequests.d.ts.map +1 -0
  96. package/dist/naa/AuthBridge.d.ts +6 -0
  97. package/dist/naa/AuthBridge.d.ts.map +1 -0
  98. package/dist/naa/BridgeCapabilities.d.ts +4 -0
  99. package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
  100. package/dist/naa/BridgeError.d.ts +10 -0
  101. package/dist/naa/BridgeError.d.ts.map +1 -0
  102. package/dist/naa/BridgeError.mjs +12 -0
  103. package/dist/naa/BridgeError.mjs.map +1 -0
  104. package/dist/naa/BridgeProxy.d.ts +72 -0
  105. package/dist/naa/BridgeProxy.d.ts.map +1 -0
  106. package/dist/naa/BridgeProxy.mjs +154 -0
  107. package/dist/naa/BridgeProxy.mjs.map +1 -0
  108. package/dist/naa/BridgeRequest.d.ts +7 -0
  109. package/dist/naa/BridgeRequest.d.ts.map +1 -0
  110. package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
  111. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
  112. package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
  113. package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
  114. package/dist/naa/BridgeStatusCode.d.ts +11 -0
  115. package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
  116. package/dist/naa/BridgeStatusCode.mjs +20 -0
  117. package/dist/naa/BridgeStatusCode.mjs.map +1 -0
  118. package/dist/naa/IBridgeProxy.d.ts +11 -0
  119. package/dist/naa/IBridgeProxy.d.ts.map +1 -0
  120. package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
  121. package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
  122. package/dist/naa/TokenRequest.d.ts +22 -0
  123. package/dist/naa/TokenRequest.d.ts.map +1 -0
  124. package/dist/naa/TokenResponse.d.ts +17 -0
  125. package/dist/naa/TokenResponse.d.ts.map +1 -0
  126. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
  127. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
  128. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
  129. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
  130. package/dist/navigation/NavigationClient.mjs +1 -1
  131. package/dist/network/FetchClient.mjs +1 -1
  132. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  133. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  134. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
  135. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
  136. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
  137. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  138. package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
  139. package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
  140. package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
  141. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
  142. package/dist/packageMetadata.d.ts +1 -1
  143. package/dist/packageMetadata.mjs +2 -2
  144. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  145. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  146. package/dist/utils/BrowserConstants.mjs +1 -1
  147. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  148. package/dist/utils/BrowserUtils.d.ts +54 -53
  149. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  150. package/dist/utils/BrowserUtils.mjs +114 -102
  151. package/dist/utils/BrowserUtils.mjs.map +1 -1
  152. package/lib/msal-browser.cjs +61 -17728
  153. package/lib/msal-browser.cjs.map +1 -1
  154. package/lib/msal-browser.js +14625 -13223
  155. package/lib/msal-browser.js.map +1 -1
  156. package/lib/msal-browser.min.js +66 -68
  157. package/package.json +2 -2
  158. package/src/app/PublicClientApplication.ts +1 -1
  159. package/src/app/PublicClientNext.ts +442 -0
  160. package/src/cache/BrowserCacheManager.ts +11 -100
  161. package/src/config/Configuration.ts +5 -0
  162. package/src/controllers/ControllerFactory.ts +36 -25
  163. package/src/controllers/NestedAppAuthController.ts +525 -0
  164. package/src/controllers/StandardController.ts +8 -6
  165. package/src/controllers/UnknownOperatingContextController.ts +383 -0
  166. package/src/crypto/BrowserCrypto.ts +2 -2
  167. package/src/crypto/CryptoOps.ts +8 -5
  168. package/src/error/NestedAppAuthError.ts +32 -0
  169. package/src/index.ts +3 -10
  170. package/src/interaction_client/BaseInteractionClient.ts +1 -1
  171. package/src/interaction_client/NativeInteractionClient.ts +19 -3
  172. package/src/interaction_client/PopupClient.ts +2 -1
  173. package/src/interaction_client/RedirectClient.ts +1 -1
  174. package/src/interaction_client/SilentAuthCodeClient.ts +5 -4
  175. package/src/interaction_client/SilentCacheClient.ts +11 -3
  176. package/src/interaction_client/SilentIframeClient.ts +53 -17
  177. package/src/interaction_client/StandardInteractionClient.ts +1 -1
  178. package/src/interaction_handler/SilentHandler.ts +177 -233
  179. package/src/naa/AccountInfo.ts +17 -0
  180. package/src/naa/AccountRequests.ts +16 -0
  181. package/src/naa/AuthBridge.ts +16 -0
  182. package/src/naa/BridgeCapabilities.ts +8 -0
  183. package/src/naa/BridgeError.ts +18 -0
  184. package/src/naa/BridgeProxy.ts +230 -0
  185. package/src/naa/BridgeRequest.ts +12 -0
  186. package/src/naa/BridgeRequestEnvelope.ts +46 -0
  187. package/src/naa/BridgeResponseEnvelope.ts +21 -0
  188. package/src/naa/BridgeStatusCode.ts +15 -0
  189. package/src/naa/IBridgeProxy.ts +25 -0
  190. package/src/naa/InitializeBridgeResponse.ts +12 -0
  191. package/src/naa/TokenRequest.ts +26 -0
  192. package/src/naa/TokenResponse.ts +61 -0
  193. package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
  194. package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
  195. package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
  196. package/src/packageMetadata.ts +1 -1
  197. package/src/utils/BrowserUtils.ts +133 -125
  198. package/dist/utils/BrowserStringUtils.d.ts +0 -22
  199. package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
  200. package/dist/utils/BrowserStringUtils.mjs +0 -144
  201. package/dist/utils/BrowserStringUtils.mjs.map +0 -1
  202. package/src/utils/BrowserStringUtils.ts +0 -143
@@ -1,56 +1,57 @@
1
1
  import { InteractionType } from "./BrowserConstants";
2
2
  /**
3
- * Utility class for browser specific functions
4
- */
5
- export declare class BrowserUtils {
6
- /**
7
- * Clears hash from window url.
8
- */
9
- static clearHash(contentWindow: Window): void;
10
- /**
11
- * Replaces current hash with hash from provided url
12
- */
13
- static replaceHash(url: string): void;
14
- /**
15
- * Returns boolean of whether the current window is in an iframe or not.
16
- */
17
- static isInIframe(): boolean;
18
- /**
19
- * Returns boolean of whether or not the current window is a popup opened by msal
20
- */
21
- static isInPopup(): boolean;
22
- /**
23
- * Returns current window URL as redirect uri
24
- */
25
- static getCurrentUri(): string;
26
- /**
27
- * Gets the homepage url for the current window location.
28
- */
29
- static getHomepage(): string;
30
- /**
31
- * Throws error if we have completed an auth and are
32
- * attempting another auth request inside an iframe.
33
- */
34
- static blockReloadInHiddenIframes(): void;
35
- /**
36
- * Block redirect operations in iframes unless explicitly allowed
37
- * @param interactionType Interaction type for the request
38
- * @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
39
- */
40
- static blockRedirectInIframe(interactionType: InteractionType, allowRedirectInIframe: boolean): void;
41
- /**
42
- * Block redirectUri loaded in popup from calling AcquireToken APIs
43
- */
44
- static blockAcquireTokenInPopups(): void;
45
- /**
46
- * Throws error if token requests are made in non-browser environment
47
- * @param isBrowserEnvironment Flag indicating if environment is a browser.
48
- */
49
- static blockNonBrowserEnvironment(isBrowserEnvironment: boolean): void;
50
- /**
51
- * Throws error if initialize hasn't been called
52
- * @param initialized
53
- */
54
- static blockAPICallsBeforeInitialize(initialized: boolean): void;
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,qBAAa,YAAY;IAGrB;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAa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,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.2.0 2023-10-05 */
1
+ /*! @azure/msal-browser v3.3.0 2023-10-20 */
2
2
  'use strict';
3
- import { Constants, UrlString } from '@azure/msal-common';
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
- * Utility class for browser specific functions
13
+ * Clears hash from window url.
14
14
  */
15
- class BrowserUtils {
16
- // #region Window Navigation and URL management
17
- /**
18
- * Clears hash from window url.
19
- */
20
- static clearHash(contentWindow) {
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
- * Returns boolean of whether or not the current window is a popup opened by msal
45
- */
46
- static isInPopup() {
47
- return (typeof window !== "undefined" &&
48
- !!window.opener &&
49
- window.opener !== window &&
50
- typeof window.name === "string" &&
51
- window.name.indexOf(`${BrowserConstants.POPUP_NAME_PREFIX}.`) === 0);
52
- }
53
- // #endregion
54
- /**
55
- * Returns current window URL as redirect uri
56
- */
57
- static getCurrentUri() {
58
- return window.location.href.split("?")[0].split("#")[0];
59
- }
60
- /**
61
- * Gets the homepage url for the current window location.
62
- */
63
- static getHomepage() {
64
- const currentUrl = new UrlString(window.location.href);
65
- const urlComponents = currentUrl.getUrlComponents();
66
- return `${urlComponents.Protocol}//${urlComponents.HostNameAndPort}/`;
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
- * Throws error if we have completed an auth and are
70
- * attempting another auth request inside an iframe.
71
- */
72
- static blockReloadInHiddenIframes() {
73
- const isResponseHash = UrlString.hashContainsKnownProperties(window.location.hash);
74
- // return an error if called from the hidden iframe created by the msal js silent calls
75
- if (isResponseHash && BrowserUtils.isInIframe()) {
76
- throw createBrowserAuthError(blockIframeReload);
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
- * Block redirect operations in iframes unless explicitly allowed
81
- * @param interactionType Interaction type for the request
82
- * @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
83
- */
84
- static blockRedirectInIframe(interactionType, allowRedirectInIframe) {
85
- const isIframedApp = BrowserUtils.isInIframe();
86
- if (interactionType === InteractionType.Redirect &&
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
- * Block redirectUri loaded in popup from calling AcquireToken APIs
95
- */
96
- static blockAcquireTokenInPopups() {
97
- // Popups opened by msal popup APIs are given a name that starts with "msal."
98
- if (BrowserUtils.isInPopup()) {
99
- throw createBrowserAuthError(blockNestedPopups);
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
- * Throws error if token requests are made in non-browser environment
104
- * @param isBrowserEnvironment Flag indicating if environment is a browser.
105
- */
106
- static blockNonBrowserEnvironment(isBrowserEnvironment) {
107
- if (!isBrowserEnvironment) {
108
- throw createBrowserAuthError(nonBrowserEnvironment);
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
- * Throws error if initialize hasn't been called
113
- * @param initialized
114
- */
115
- static blockAPICallsBeforeInitialize(initialized) {
116
- if (!initialized) {
117
- throw createBrowserAuthError(uninitializedPublicClientApplication);
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 { BrowserUtils };
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;AAMI;AACH;AAaA;;AAEG;AACH;AAOA;;AAEG,IAAA,OAAA,SAAA,CAAA,aAAA,EAAA;;AAKH,QAAA,aAAA,CAAA,QAAA,CAAA,IAAA,GAAA,SAAA,CAAA,YAAA,CAAA;;AAEG;YACa,aAAW,CAAA,OAAA,CAAA,YAAA,CAAA,IAAA,EAAA,SAAA,CAAA,YAAA,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;AAY3B,SAAA;;AAEG;;AAKH;;AAEG,QAAA,MAAA,QAAA,GAAA,GAAA,CAAA,KAAA,CAAA,GAAA,CAAA,CAAA;QACG,QAAY,CAAA,KAAA,EAAA,CAAA;AAMlB,QAAA,MAAA,CAAA,QA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