@azure/msal-browser 4.0.0-alpha.0 → 4.0.2

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 (189) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  3. package/dist/app/PublicClientApplication.mjs +4 -2
  4. package/dist/app/PublicClientApplication.mjs.map +1 -1
  5. package/dist/app/PublicClientNext.mjs +1 -1
  6. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
  7. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  8. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +8 -8
  9. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  10. package/dist/broker/nativeBroker/NativeResponse.d.ts +1 -1
  11. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  12. package/dist/cache/AccountManager.mjs +1 -1
  13. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  14. package/dist/cache/BrowserCacheManager.d.ts +10 -15
  15. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  16. package/dist/cache/BrowserCacheManager.mjs +42 -43
  17. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  18. package/dist/cache/CacheHelpers.mjs +1 -1
  19. package/dist/cache/CookieStorage.mjs +1 -1
  20. package/dist/cache/CookieStorage.mjs.map +1 -1
  21. package/dist/cache/DatabaseStorage.mjs +1 -1
  22. package/dist/cache/IWindowStorage.d.ts +2 -2
  23. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  24. package/dist/cache/LocalStorage.d.ts +7 -3
  25. package/dist/cache/LocalStorage.d.ts.map +1 -1
  26. package/dist/cache/LocalStorage.mjs +48 -34
  27. package/dist/cache/LocalStorage.mjs.map +1 -1
  28. package/dist/cache/MemoryStorage.mjs +1 -1
  29. package/dist/cache/SessionStorage.mjs +1 -1
  30. package/dist/cache/TokenCache.d.ts.map +1 -1
  31. package/dist/cache/TokenCache.mjs +15 -14
  32. package/dist/cache/TokenCache.mjs.map +1 -1
  33. package/dist/config/Configuration.d.ts +2 -2
  34. package/dist/config/Configuration.d.ts.map +1 -1
  35. package/dist/config/Configuration.mjs +5 -5
  36. package/dist/config/Configuration.mjs.map +1 -1
  37. package/dist/controllers/ControllerFactory.mjs +1 -1
  38. package/dist/controllers/NestedAppAuthController.d.ts +6 -3
  39. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  40. package/dist/controllers/NestedAppAuthController.mjs +34 -18
  41. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  42. package/dist/controllers/StandardController.d.ts +2 -2
  43. package/dist/controllers/StandardController.d.ts.map +1 -1
  44. package/dist/controllers/StandardController.mjs +27 -23
  45. package/dist/controllers/StandardController.mjs.map +1 -1
  46. package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
  47. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  48. package/dist/controllers/UnknownOperatingContextController.mjs +3 -3
  49. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  50. package/dist/crypto/BrowserCrypto.d.ts +1 -1
  51. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  52. package/dist/crypto/BrowserCrypto.mjs +3 -3
  53. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  54. package/dist/crypto/CryptoOps.d.ts +1 -1
  55. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  56. package/dist/crypto/CryptoOps.mjs +3 -3
  57. package/dist/crypto/CryptoOps.mjs.map +1 -1
  58. package/dist/crypto/PkceGenerator.mjs +1 -1
  59. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  60. package/dist/encode/Base64Decode.mjs +1 -1
  61. package/dist/encode/Base64Encode.mjs +1 -1
  62. package/dist/error/BrowserAuthError.mjs +1 -1
  63. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  64. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  65. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  66. package/dist/error/NativeAuthError.mjs +1 -1
  67. package/dist/error/NativeAuthError.mjs.map +1 -1
  68. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  69. package/dist/error/NestedAppAuthError.mjs +1 -1
  70. package/dist/event/EventHandler.mjs +1 -1
  71. package/dist/event/EventMessage.mjs +1 -1
  72. package/dist/event/EventType.mjs +1 -1
  73. package/dist/index.mjs +1 -1
  74. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  75. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  76. package/dist/interaction_client/NativeInteractionClient.d.ts +2 -3
  77. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  78. package/dist/interaction_client/NativeInteractionClient.mjs +11 -9
  79. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  80. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  81. package/dist/interaction_client/PopupClient.mjs +4 -4
  82. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  83. package/dist/interaction_client/RedirectClient.mjs +2 -2
  84. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  85. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  86. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  87. package/dist/interaction_client/SilentIframeClient.mjs +2 -2
  88. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  89. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  90. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  91. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  92. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  93. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  94. package/dist/naa/BridgeError.mjs +1 -1
  95. package/dist/naa/BridgeProxy.mjs +1 -1
  96. package/dist/naa/BridgeStatusCode.mjs +1 -1
  97. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  98. package/dist/navigation/NavigationClient.mjs +1 -1
  99. package/dist/network/FetchClient.mjs +1 -1
  100. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  101. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  102. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  103. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  104. package/dist/packageMetadata.d.ts +1 -1
  105. package/dist/packageMetadata.d.ts.map +1 -1
  106. package/dist/packageMetadata.mjs +2 -2
  107. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  108. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  109. package/dist/request/PopupRequest.d.ts +1 -1
  110. package/dist/request/PopupRequest.d.ts.map +1 -1
  111. package/dist/request/RedirectRequest.d.ts +1 -1
  112. package/dist/request/RedirectRequest.d.ts.map +1 -1
  113. package/dist/request/RequestHelpers.mjs +1 -1
  114. package/dist/request/SsoSilentRequest.d.ts +1 -1
  115. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  116. package/dist/response/ResponseHandler.mjs +1 -1
  117. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  118. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  119. package/dist/utils/BrowserConstants.mjs +1 -1
  120. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  121. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  122. package/dist/utils/BrowserUtils.mjs +4 -2
  123. package/dist/utils/BrowserUtils.mjs.map +1 -1
  124. package/lib/msal-browser.cjs +298 -249
  125. package/lib/msal-browser.cjs.map +1 -1
  126. package/lib/msal-browser.js +298 -249
  127. package/lib/msal-browser.js.map +1 -1
  128. package/lib/msal-browser.min.js +63 -63
  129. package/lib/types/app/PublicClientApplication.d.ts.map +1 -1
  130. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
  131. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  132. package/lib/types/broker/nativeBroker/NativeResponse.d.ts +1 -1
  133. package/lib/types/cache/BrowserCacheManager.d.ts +10 -15
  134. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  135. package/lib/types/cache/IWindowStorage.d.ts +2 -2
  136. package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
  137. package/lib/types/cache/LocalStorage.d.ts +7 -3
  138. package/lib/types/cache/LocalStorage.d.ts.map +1 -1
  139. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  140. package/lib/types/config/Configuration.d.ts +2 -2
  141. package/lib/types/config/Configuration.d.ts.map +1 -1
  142. package/lib/types/controllers/NestedAppAuthController.d.ts +6 -3
  143. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  144. package/lib/types/controllers/StandardController.d.ts +2 -2
  145. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  146. package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
  147. package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  148. package/lib/types/crypto/BrowserCrypto.d.ts +1 -1
  149. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  150. package/lib/types/crypto/CryptoOps.d.ts +1 -1
  151. package/lib/types/crypto/CryptoOps.d.ts.map +1 -1
  152. package/lib/types/interaction_client/NativeInteractionClient.d.ts +2 -3
  153. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  154. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  155. package/lib/types/packageMetadata.d.ts +1 -1
  156. package/lib/types/packageMetadata.d.ts.map +1 -1
  157. package/lib/types/request/AuthorizationUrlRequest.d.ts +1 -1
  158. package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
  159. package/lib/types/request/PopupRequest.d.ts +1 -1
  160. package/lib/types/request/PopupRequest.d.ts.map +1 -1
  161. package/lib/types/request/RedirectRequest.d.ts +1 -1
  162. package/lib/types/request/RedirectRequest.d.ts.map +1 -1
  163. package/lib/types/request/SsoSilentRequest.d.ts +1 -1
  164. package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
  165. package/lib/types/utils/BrowserUtils.d.ts.map +1 -1
  166. package/package.json +2 -2
  167. package/src/app/PublicClientApplication.ts +6 -1
  168. package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
  169. package/src/broker/nativeBroker/NativeResponse.ts +1 -1
  170. package/src/cache/BrowserCacheManager.ts +88 -57
  171. package/src/cache/IWindowStorage.ts +2 -2
  172. package/src/cache/LocalStorage.ts +142 -43
  173. package/src/cache/TokenCache.ts +28 -11
  174. package/src/config/Configuration.ts +6 -6
  175. package/src/controllers/NestedAppAuthController.ts +51 -23
  176. package/src/controllers/StandardController.ts +41 -24
  177. package/src/controllers/UnknownOperatingContextController.ts +6 -5
  178. package/src/crypto/BrowserCrypto.ts +4 -2
  179. package/src/crypto/CryptoOps.ts +8 -2
  180. package/src/interaction_client/NativeInteractionClient.ts +16 -16
  181. package/src/interaction_client/PopupClient.ts +9 -8
  182. package/src/interaction_client/RedirectClient.ts +1 -1
  183. package/src/interaction_client/SilentIframeClient.ts +1 -1
  184. package/src/packageMetadata.ts +1 -1
  185. package/src/request/AuthorizationUrlRequest.ts +1 -1
  186. package/src/request/PopupRequest.ts +1 -1
  187. package/src/request/RedirectRequest.ts +1 -1
  188. package/src/request/SsoSilentRequest.ts +1 -1
  189. package/src/utils/BrowserUtils.ts +3 -1
@@ -1,8 +1,8 @@
1
- /*! @azure/msal-browser v4.0.0-alpha.0 2024-12-18 */
1
+ /*! @azure/msal-browser v4.0.2 2025-01-22 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
5
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6
6
  /*
7
7
  * Copyright (c) Microsoft Corporation. All rights reserved.
8
8
  * Licensed under the MIT License.
@@ -306,7 +306,7 @@ const JsonWebTokenTypes = {
306
306
  // Token renewal offset default in seconds
307
307
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
308
308
 
309
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
309
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
310
310
  /*
311
311
  * Copyright (c) Microsoft Corporation. All rights reserved.
312
312
  * Licensed under the MIT License.
@@ -323,7 +323,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
323
323
  unexpectedError: unexpectedError
324
324
  });
325
325
 
326
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
326
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
327
327
 
328
328
  /*
329
329
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -372,7 +372,7 @@ function createAuthError(code, additionalMessage) {
372
372
  : AuthErrorMessages[code]);
373
373
  }
374
374
 
375
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
375
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
376
376
  /*
377
377
  * Copyright (c) Microsoft Corporation. All rights reserved.
378
378
  * Licensed under the MIT License.
@@ -470,7 +470,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
470
470
  userTimeoutReached: userTimeoutReached
471
471
  });
472
472
 
473
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
473
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
474
474
 
475
475
  /*
476
476
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -722,7 +722,7 @@ function createClientAuthError(errorCode, additionalMessage) {
722
722
  return new ClientAuthError(errorCode, additionalMessage);
723
723
  }
724
724
 
725
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
725
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
726
726
 
727
727
  /*
728
728
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -761,7 +761,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
761
761
  },
762
762
  };
763
763
 
764
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
764
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
765
765
 
766
766
  /*
767
767
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -952,12 +952,12 @@ class Logger {
952
952
  }
953
953
  }
954
954
 
955
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
955
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
956
956
  /* eslint-disable header/header */
957
957
  const name$1 = "@azure/msal-common";
958
- const version$1 = "15.0.0-alpha.0";
958
+ const version$1 = "15.0.2";
959
959
 
960
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
960
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
961
961
  /*
962
962
  * Copyright (c) Microsoft Corporation. All rights reserved.
963
963
  * Licensed under the MIT License.
@@ -977,7 +977,7 @@ const AzureCloudInstance = {
977
977
  AzureUsGovernment: "https://login.microsoftonline.us",
978
978
  };
979
979
 
980
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
980
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
981
981
 
982
982
  /*
983
983
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1038,7 +1038,7 @@ function checkMaxAge(authTime, maxAge) {
1038
1038
  }
1039
1039
  }
1040
1040
 
1041
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1041
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
1042
1042
  /*
1043
1043
  * Copyright (c) Microsoft Corporation. All rights reserved.
1044
1044
  * Licensed under the MIT License.
@@ -1075,7 +1075,7 @@ function wasClockTurnedBack(cachedAt) {
1075
1075
  return cachedAtSec > nowSeconds();
1076
1076
  }
1077
1077
 
1078
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1078
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
1079
1079
 
1080
1080
  /*
1081
1081
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1402,7 +1402,7 @@ function isAuthorityMetadataExpired(metadata) {
1402
1402
  return metadata.expiresAt <= nowSeconds();
1403
1403
  }
1404
1404
 
1405
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1405
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
1406
1406
  /*
1407
1407
  * Copyright (c) Microsoft Corporation. All rights reserved.
1408
1408
  * Licensed under the MIT License.
@@ -1427,14 +1427,14 @@ const missingSshKid = "missing_ssh_kid";
1427
1427
  const missingNonceAuthenticationHeader = "missing_nonce_authentication_header";
1428
1428
  const invalidAuthenticationHeader = "invalid_authentication_header";
1429
1429
  const cannotSetOIDCOptions = "cannot_set_OIDCOptions";
1430
- const cannotAllowNativeBroker = "cannot_allow_native_broker";
1430
+ const cannotAllowPlatformBroker = "cannot_allow_platform_broker";
1431
1431
  const authorityMismatch = "authority_mismatch";
1432
1432
 
1433
1433
  var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1434
1434
  __proto__: null,
1435
1435
  authorityMismatch: authorityMismatch,
1436
1436
  authorityUriInsecure: authorityUriInsecure,
1437
- cannotAllowNativeBroker: cannotAllowNativeBroker,
1437
+ cannotAllowPlatformBroker: cannotAllowPlatformBroker,
1438
1438
  cannotSetOIDCOptions: cannotSetOIDCOptions,
1439
1439
  claimsRequestParsingError: claimsRequestParsingError,
1440
1440
  emptyInputScopesError: emptyInputScopesError,
@@ -1456,7 +1456,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1456
1456
  urlParseError: urlParseError
1457
1457
  });
1458
1458
 
1459
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1459
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
1460
1460
 
1461
1461
  /*
1462
1462
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1483,7 +1483,7 @@ const ClientConfigurationErrorMessages = {
1483
1483
  [missingNonceAuthenticationHeader]: "Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce.",
1484
1484
  [invalidAuthenticationHeader]: "Invalid authentication header provided",
1485
1485
  [cannotSetOIDCOptions]: "Cannot set OIDCOptions parameter. Please change the protocol mode to OIDC or use a non-Microsoft authority.",
1486
- [cannotAllowNativeBroker]: "Cannot set allowNativeBroker parameter to true when not in AAD protocol mode.",
1486
+ [cannotAllowPlatformBroker]: "Cannot set allowPlatformBroker parameter to true when not in AAD protocol mode.",
1487
1487
  [authorityMismatch]: "Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority.",
1488
1488
  };
1489
1489
  /**
@@ -1571,9 +1571,9 @@ const ClientConfigurationErrorMessage = {
1571
1571
  code: cannotSetOIDCOptions,
1572
1572
  desc: ClientConfigurationErrorMessages[cannotSetOIDCOptions],
1573
1573
  },
1574
- cannotAllowNativeBroker: {
1575
- code: cannotAllowNativeBroker,
1576
- desc: ClientConfigurationErrorMessages[cannotAllowNativeBroker],
1574
+ cannotAllowPlatformBroker: {
1575
+ code: cannotAllowPlatformBroker,
1576
+ desc: ClientConfigurationErrorMessages[cannotAllowPlatformBroker],
1577
1577
  },
1578
1578
  authorityMismatch: {
1579
1579
  code: authorityMismatch,
@@ -1594,7 +1594,7 @@ function createClientConfigurationError(errorCode) {
1594
1594
  return new ClientConfigurationError(errorCode);
1595
1595
  }
1596
1596
 
1597
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1597
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
1598
1598
  /*
1599
1599
  * Copyright (c) Microsoft Corporation. All rights reserved.
1600
1600
  * Licensed under the MIT License.
@@ -1691,7 +1691,7 @@ class StringUtils {
1691
1691
  }
1692
1692
  }
1693
1693
 
1694
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1694
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
1695
1695
 
1696
1696
  /*
1697
1697
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1711,8 +1711,10 @@ class ScopeSet {
1711
1711
  const filteredInput = scopeArr
1712
1712
  ? StringUtils.removeEmptyStringsFromArray(scopeArr)
1713
1713
  : [];
1714
- // Validate and filter scopes (validate function throws if validation fails)
1715
- this.validateInputScopes(filteredInput);
1714
+ // Check if scopes array has at least one member
1715
+ if (!filteredInput || !filteredInput.length) {
1716
+ throw createClientConfigurationError(emptyInputScopesError);
1717
+ }
1716
1718
  this.scopes = new Set(); // Iterator in constructor not supported by IE11
1717
1719
  filteredInput.forEach((scope) => this.scopes.add(scope));
1718
1720
  }
@@ -1742,17 +1744,6 @@ class ScopeSet {
1742
1744
  }
1743
1745
  return scopeSet;
1744
1746
  }
1745
- /**
1746
- * Used to validate the scopes input parameter requested by the developer.
1747
- * @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.
1748
- * @param {boolean} scopesRequired - Boolean indicating whether the scopes array is required or not
1749
- */
1750
- validateInputScopes(inputScopes) {
1751
- // Check if scopes are required but not given or is an empty array
1752
- if (!inputScopes || inputScopes.length < 1) {
1753
- throw createClientConfigurationError(emptyInputScopesError);
1754
- }
1755
- }
1756
1747
  /**
1757
1748
  * Check if a given scope is present in this set of scopes.
1758
1749
  * @param scope
@@ -1891,7 +1882,7 @@ class ScopeSet {
1891
1882
  }
1892
1883
  }
1893
1884
 
1894
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1885
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
1895
1886
 
1896
1887
  /*
1897
1888
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1931,7 +1922,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
1931
1922
  };
1932
1923
  }
1933
1924
 
1934
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1925
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
1935
1926
  /*
1936
1927
  * Copyright (c) Microsoft Corporation. All rights reserved.
1937
1928
  * Licensed under the MIT License.
@@ -2010,7 +2001,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
2010
2001
  return updatedAccountInfo;
2011
2002
  }
2012
2003
 
2013
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2004
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2014
2005
  /*
2015
2006
  * Copyright (c) Microsoft Corporation. All rights reserved.
2016
2007
  * Licensed under the MIT License.
@@ -2025,7 +2016,7 @@ const AuthorityType = {
2025
2016
  Ciam: 3,
2026
2017
  };
2027
2018
 
2028
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2019
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2029
2020
  /*
2030
2021
  * Copyright (c) Microsoft Corporation. All rights reserved.
2031
2022
  * Licensed under the MIT License.
@@ -2047,7 +2038,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2047
2038
  return null;
2048
2039
  }
2049
2040
 
2050
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2041
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2051
2042
  /*
2052
2043
  * Copyright (c) Microsoft Corporation. All rights reserved.
2053
2044
  * Licensed under the MIT License.
@@ -2060,7 +2051,7 @@ const ProtocolMode = {
2060
2051
  OIDC: "OIDC",
2061
2052
  };
2062
2053
 
2063
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2054
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2064
2055
 
2065
2056
  /*
2066
2057
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2303,7 +2294,7 @@ class AccountEntity {
2303
2294
  }
2304
2295
  }
2305
2296
 
2306
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2297
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2307
2298
 
2308
2299
  /*
2309
2300
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2350,7 +2341,7 @@ function getDeserializedResponse(responseString) {
2350
2341
  return null;
2351
2342
  }
2352
2343
 
2353
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2344
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2354
2345
 
2355
2346
  /*
2356
2347
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2514,7 +2505,7 @@ class UrlString {
2514
2505
  }
2515
2506
  }
2516
2507
 
2517
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2508
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2518
2509
 
2519
2510
  /*
2520
2511
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2654,7 +2645,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2654
2645
  return null;
2655
2646
  }
2656
2647
 
2657
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2648
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2658
2649
  /*
2659
2650
  * Copyright (c) Microsoft Corporation. All rights reserved.
2660
2651
  * Licensed under the MIT License.
@@ -2662,7 +2653,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2662
2653
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2663
2654
  const cacheUnknownErrorCode = "cache_error_unknown";
2664
2655
 
2665
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2656
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2666
2657
 
2667
2658
  /*
2668
2659
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2689,7 +2680,7 @@ class CacheError extends Error {
2689
2680
  }
2690
2681
  }
2691
2682
 
2692
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2683
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
2693
2684
 
2694
2685
  /*
2695
2686
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2854,24 +2845,24 @@ class CacheManager {
2854
2845
  * @param storeInCache {?StoreInCache}
2855
2846
  * @param correlationId {?string} correlation id
2856
2847
  */
2857
- async saveCacheRecord(cacheRecord, storeInCache, correlationId) {
2848
+ async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
2858
2849
  if (!cacheRecord) {
2859
2850
  throw createClientAuthError(invalidCacheRecord);
2860
2851
  }
2861
2852
  try {
2862
2853
  if (!!cacheRecord.account) {
2863
- await this.setAccount(cacheRecord.account);
2854
+ await this.setAccount(cacheRecord.account, correlationId);
2864
2855
  }
2865
2856
  if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
2866
- await this.setIdTokenCredential(cacheRecord.idToken);
2857
+ await this.setIdTokenCredential(cacheRecord.idToken, correlationId);
2867
2858
  }
2868
2859
  if (!!cacheRecord.accessToken &&
2869
2860
  storeInCache?.accessToken !== false) {
2870
- await this.saveAccessToken(cacheRecord.accessToken);
2861
+ await this.saveAccessToken(cacheRecord.accessToken, correlationId);
2871
2862
  }
2872
2863
  if (!!cacheRecord.refreshToken &&
2873
2864
  storeInCache?.refreshToken !== false) {
2874
- await this.setRefreshTokenCredential(cacheRecord.refreshToken);
2865
+ await this.setRefreshTokenCredential(cacheRecord.refreshToken, correlationId);
2875
2866
  }
2876
2867
  if (!!cacheRecord.appMetadata) {
2877
2868
  this.setAppMetadata(cacheRecord.appMetadata);
@@ -2901,7 +2892,7 @@ class CacheManager {
2901
2892
  * saves access token credential
2902
2893
  * @param credential
2903
2894
  */
2904
- async saveAccessToken(credential) {
2895
+ async saveAccessToken(credential, correlationId) {
2905
2896
  const accessTokenFilter = {
2906
2897
  clientId: credential.clientId,
2907
2898
  credentialType: credential.credentialType,
@@ -2928,7 +2919,7 @@ class CacheManager {
2928
2919
  }
2929
2920
  });
2930
2921
  await Promise.all(removedAccessTokens);
2931
- await this.setAccessTokenCredential(credential);
2922
+ await this.setAccessTokenCredential(credential, correlationId);
2932
2923
  }
2933
2924
  /**
2934
2925
  * Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
@@ -3874,7 +3865,7 @@ class DefaultStorageClass extends CacheManager {
3874
3865
  }
3875
3866
  }
3876
3867
 
3877
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
3868
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
3878
3869
 
3879
3870
  /*
3880
3871
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3973,7 +3964,7 @@ function isOidcProtocolMode(config) {
3973
3964
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
3974
3965
  }
3975
3966
 
3976
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
3967
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
3977
3968
  /*
3978
3969
  * Copyright (c) Microsoft Corporation. All rights reserved.
3979
3970
  * Licensed under the MIT License.
@@ -3983,7 +3974,7 @@ const CcsCredentialType = {
3983
3974
  UPN: "UPN",
3984
3975
  };
3985
3976
 
3986
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
3977
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
3987
3978
  /*
3988
3979
  * Copyright (c) Microsoft Corporation. All rights reserved.
3989
3980
  * Licensed under the MIT License.
@@ -4033,7 +4024,7 @@ const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
4033
4024
  const BROKER_CLIENT_ID = "brk_client_id";
4034
4025
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4035
4026
 
4036
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
4027
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
4037
4028
 
4038
4029
  /*
4039
4030
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4100,7 +4091,7 @@ class RequestValidator {
4100
4091
  }
4101
4092
  }
4102
4093
 
4103
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
4094
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
4104
4095
 
4105
4096
  /*
4106
4097
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4508,7 +4499,7 @@ class RequestParameterBuilder {
4508
4499
  }
4509
4500
  }
4510
4501
 
4511
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
4502
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
4512
4503
  /*
4513
4504
  * Copyright (c) Microsoft Corporation. All rights reserved.
4514
4505
  * Licensed under the MIT License.
@@ -4520,7 +4511,7 @@ function isOpenIdConfigResponse(response) {
4520
4511
  response.hasOwnProperty("jwks_uri"));
4521
4512
  }
4522
4513
 
4523
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
4514
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
4524
4515
  /*
4525
4516
  * Copyright (c) Microsoft Corporation. All rights reserved.
4526
4517
  * Licensed under the MIT License.
@@ -4530,7 +4521,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4530
4521
  response.hasOwnProperty("metadata"));
4531
4522
  }
4532
4523
 
4533
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
4524
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
4534
4525
  /*
4535
4526
  * Copyright (c) Microsoft Corporation. All rights reserved.
4536
4527
  * Licensed under the MIT License.
@@ -4540,7 +4531,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4540
4531
  response.hasOwnProperty("error_description"));
4541
4532
  }
4542
4533
 
4543
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
4534
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
4544
4535
  /*
4545
4536
  * Copyright (c) Microsoft Corporation. All rights reserved.
4546
4537
  * Licensed under the MIT License.
@@ -4698,6 +4689,7 @@ const PerformanceEvents = {
4698
4689
  */
4699
4690
  InitializeSilentRequest: "initializeSilentRequest",
4700
4691
  InitializeClientApplication: "initializeClientApplication",
4692
+ InitializeCache: "initializeCache",
4701
4693
  /**
4702
4694
  * Helper function in SilentIframeClient class (msal-browser).
4703
4695
  */
@@ -4775,6 +4767,8 @@ const PerformanceEvents = {
4775
4767
  */
4776
4768
  ClearTokensAndKeysWithClaims: "clearTokensAndKeysWithClaims",
4777
4769
  CacheManagerGetRefreshToken: "cacheManagerGetRefreshToken",
4770
+ ImportExistingCache: "importExistingCache",
4771
+ SetUserData: "setUserData",
4778
4772
  /**
4779
4773
  * Crypto Operations
4780
4774
  */
@@ -4783,6 +4777,12 @@ const PerformanceEvents = {
4783
4777
  GenerateCodeChallengeFromVerifier: "generateCodeChallengeFromVerifier",
4784
4778
  Sha256Digest: "sha256Digest",
4785
4779
  GetRandomValues: "getRandomValues",
4780
+ GenerateHKDF: "generateHKDF",
4781
+ GenerateBaseKey: "generateBaseKey",
4782
+ Base64Decode: "base64Decode",
4783
+ UrlEncodeArr: "urlEncodeArr",
4784
+ Encrypt: "encrypt",
4785
+ Decrypt: "decrypt",
4786
4786
  };
4787
4787
  const PerformanceEventAbbreviations = new Map([
4788
4788
  [PerformanceEvents.AcquireTokenByCode, "ATByCode"],
@@ -4867,6 +4867,9 @@ const PerformanceEventAbbreviations = new Map([
4867
4867
  PerformanceEvents.InitializeClientApplication,
4868
4868
  "InitClientApplication",
4869
4869
  ],
4870
+ [PerformanceEvents.InitializeCache, "InitCache"],
4871
+ [PerformanceEvents.ImportExistingCache, "importCache"],
4872
+ [PerformanceEvents.SetUserData, "setUserData"],
4870
4873
  [PerformanceEvents.SilentIframeClientTokenHelper, "SIClientTHelper"],
4871
4874
  [
4872
4875
  PerformanceEvents.SilentHandlerInitiateAuthRequest,
@@ -5000,6 +5003,12 @@ const PerformanceEventAbbreviations = new Map([
5000
5003
  ],
5001
5004
  [PerformanceEvents.Sha256Digest, "Sha256Digest"],
5002
5005
  [PerformanceEvents.GetRandomValues, "GetRandomValues"],
5006
+ [PerformanceEvents.GenerateHKDF, "genHKDF"],
5007
+ [PerformanceEvents.GenerateBaseKey, "genBaseKey"],
5008
+ [PerformanceEvents.Base64Decode, "b64Decode"],
5009
+ [PerformanceEvents.UrlEncodeArr, "urlEncArr"],
5010
+ [PerformanceEvents.Encrypt, "encrypt"],
5011
+ [PerformanceEvents.Decrypt, "decrypt"],
5003
5012
  ]);
5004
5013
  /**
5005
5014
  * State of the performance event.
@@ -5025,9 +5034,11 @@ const IntFields = new Set([
5025
5034
  "multiMatchedAT",
5026
5035
  "multiMatchedID",
5027
5036
  "multiMatchedRT",
5037
+ "unencryptedCacheCount",
5038
+ "encryptedCacheExpiredCount",
5028
5039
  ]);
5029
5040
 
5030
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
5041
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
5031
5042
  /*
5032
5043
  * Copyright (c) Microsoft Corporation. All rights reserved.
5033
5044
  * Licensed under the MIT License.
@@ -5123,7 +5134,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
5123
5134
  };
5124
5135
  };
5125
5136
 
5126
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
5137
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
5127
5138
 
5128
5139
  /*
5129
5140
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5232,7 +5243,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5232
5243
  },
5233
5244
  };
5234
5245
 
5235
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
5246
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
5236
5247
 
5237
5248
  /*
5238
5249
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6071,7 +6082,7 @@ function buildStaticAuthorityOptions(authOptions) {
6071
6082
  };
6072
6083
  }
6073
6084
 
6074
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6085
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6075
6086
 
6076
6087
  /*
6077
6088
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6102,7 +6113,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
6102
6113
  }
6103
6114
  }
6104
6115
 
6105
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6116
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6106
6117
 
6107
6118
  /*
6108
6119
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6121,7 +6132,7 @@ class ServerError extends AuthError {
6121
6132
  }
6122
6133
  }
6123
6134
 
6124
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6135
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6125
6136
 
6126
6137
  /*
6127
6138
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6219,7 +6230,7 @@ class ThrottlingUtils {
6219
6230
  }
6220
6231
  }
6221
6232
 
6222
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6233
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6223
6234
 
6224
6235
  /*
6225
6236
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6249,7 +6260,7 @@ function createNetworkError(error, httpStatus, responseHeaders) {
6249
6260
  return new NetworkError(error, httpStatus, responseHeaders);
6250
6261
  }
6251
6262
 
6252
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6263
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6253
6264
 
6254
6265
  /*
6255
6266
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6399,7 +6410,7 @@ class BaseClient {
6399
6410
  }
6400
6411
  }
6401
6412
 
6402
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6413
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6403
6414
  /*
6404
6415
  * Copyright (c) Microsoft Corporation. All rights reserved.
6405
6416
  * Licensed under the MIT License.
@@ -6425,7 +6436,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6425
6436
  refreshTokenExpired: refreshTokenExpired
6426
6437
  });
6427
6438
 
6428
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6439
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6429
6440
 
6430
6441
  /*
6431
6442
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6513,7 +6524,7 @@ function createInteractionRequiredAuthError(errorCode) {
6513
6524
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6514
6525
  }
6515
6526
 
6516
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6527
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6517
6528
 
6518
6529
  /*
6519
6530
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6585,7 +6596,7 @@ class ProtocolUtils {
6585
6596
  }
6586
6597
  }
6587
6598
 
6588
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6599
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6589
6600
 
6590
6601
  /*
6591
6602
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6669,7 +6680,7 @@ class PopTokenGenerator {
6669
6680
  }
6670
6681
  }
6671
6682
 
6672
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6683
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6673
6684
  /*
6674
6685
  * Copyright (c) Microsoft Corporation. All rights reserved.
6675
6686
  * Licensed under the MIT License.
@@ -6696,7 +6707,7 @@ class PopTokenGenerator {
6696
6707
  }
6697
6708
  }
6698
6709
 
6699
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6710
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
6700
6711
 
6701
6712
  /*
6702
6713
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6862,7 +6873,7 @@ class ResponseHandler {
6862
6873
  return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
6863
6874
  }
6864
6875
  }
6865
- await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache, request.correlationId);
6876
+ await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, request.storeInCache);
6866
6877
  }
6867
6878
  finally {
6868
6879
  if (this.persistencePlugin &&
@@ -7073,7 +7084,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
7073
7084
  return baseAccount;
7074
7085
  }
7075
7086
 
7076
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7087
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
7077
7088
  /*
7078
7089
  * Copyright (c) Microsoft Corporation. All rights reserved.
7079
7090
  * Licensed under the MIT License.
@@ -7091,7 +7102,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
7091
7102
  }
7092
7103
  }
7093
7104
 
7094
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7105
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
7095
7106
 
7096
7107
  /*
7097
7108
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7465,7 +7476,7 @@ class AuthorizationCodeClient extends BaseClient {
7465
7476
  });
7466
7477
  }
7467
7478
  this.addExtraQueryParams(request, parameterBuilder);
7468
- if (request.nativeBroker) {
7479
+ if (request.platformBroker) {
7469
7480
  // signal ests that this is a WAM call
7470
7481
  parameterBuilder.addNativeBroker();
7471
7482
  // pass the req_cnf for POP
@@ -7533,7 +7544,7 @@ class AuthorizationCodeClient extends BaseClient {
7533
7544
  }
7534
7545
  }
7535
7546
 
7536
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7547
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
7537
7548
 
7538
7549
  /*
7539
7550
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7753,7 +7764,7 @@ class RefreshTokenClient extends BaseClient {
7753
7764
  }
7754
7765
  }
7755
7766
 
7756
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7767
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
7757
7768
 
7758
7769
  /*
7759
7770
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7889,7 +7900,7 @@ class SilentFlowClient extends BaseClient {
7889
7900
  }
7890
7901
  }
7891
7902
 
7892
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7903
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
7893
7904
 
7894
7905
  /*
7895
7906
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7904,7 +7915,7 @@ const StubbedNetworkModule = {
7904
7915
  },
7905
7916
  };
7906
7917
 
7907
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7918
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
7908
7919
 
7909
7920
  /*
7910
7921
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7962,7 +7973,7 @@ class AuthenticationHeaderParser {
7962
7973
  }
7963
7974
  }
7964
7975
 
7965
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7976
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
7966
7977
 
7967
7978
  /*
7968
7979
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8225,7 +8236,7 @@ class ServerTelemetryManager {
8225
8236
  }
8226
8237
  }
8227
8238
 
8228
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8239
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
8229
8240
  /*
8230
8241
  * Copyright (c) Microsoft Corporation. All rights reserved.
8231
8242
  * Licensed under the MIT License.
@@ -8233,7 +8244,7 @@ class ServerTelemetryManager {
8233
8244
  const missingKidError = "missing_kid_error";
8234
8245
  const missingAlgError = "missing_alg_error";
8235
8246
 
8236
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8247
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
8237
8248
 
8238
8249
  /*
8239
8250
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8258,7 +8269,7 @@ function createJoseHeaderError(code) {
8258
8269
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
8259
8270
  }
8260
8271
 
8261
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8272
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
8262
8273
 
8263
8274
  /*
8264
8275
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8298,7 +8309,7 @@ class JoseHeader {
8298
8309
  }
8299
8310
  }
8300
8311
 
8301
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8312
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
8302
8313
 
8303
8314
  /*
8304
8315
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8377,7 +8388,7 @@ class StubPerformanceClient {
8377
8388
  }
8378
8389
  }
8379
8390
 
8380
- /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8391
+ /*! @azure/msal-common v15.0.2 2025-01-22 */
8381
8392
 
8382
8393
  /*
8383
8394
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9693,14 +9704,14 @@ const keygenAlgorithmOptions = {
9693
9704
  /**
9694
9705
  * Check whether browser crypto is available.
9695
9706
  */
9696
- function validateCryptoAvailable() {
9707
+ function validateCryptoAvailable(skipValidateSubtleCrypto) {
9697
9708
  if (!window) {
9698
9709
  throw createBrowserAuthError(nonBrowserEnvironment);
9699
9710
  }
9700
9711
  if (!window.crypto) {
9701
9712
  throw createBrowserAuthError(cryptoNonExistent);
9702
9713
  }
9703
- if (!window.crypto.subtle) {
9714
+ if (!skipValidateSubtleCrypto && !window.crypto.subtle) {
9704
9715
  throw createBrowserAuthError(cryptoNonExistent, SUBTLE_SUBERROR);
9705
9716
  }
9706
9717
  }
@@ -9985,7 +9996,9 @@ function isInPopup() {
9985
9996
  * Returns current window URL as redirect uri
9986
9997
  */
9987
9998
  function getCurrentUri() {
9988
- return window.location.href.split("?")[0].split("#")[0];
9999
+ return typeof window !== "undefined" && window.location
10000
+ ? window.location.href.split("?")[0].split("#")[0]
10001
+ : "";
9989
10002
  }
9990
10003
  /**
9991
10004
  * Gets the homepage url for the current window location.
@@ -10365,7 +10378,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
10365
10378
  redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
10366
10379
  asyncPopups: false,
10367
10380
  allowRedirectInIframe: false,
10368
- allowNativeBroker: false,
10381
+ allowPlatformBroker: false,
10369
10382
  nativeBrokerHandshakeTimeout: userInputSystem?.nativeBrokerHandshakeTimeout ||
10370
10383
  DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
10371
10384
  pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,
@@ -10388,11 +10401,11 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
10388
10401
  const logger = new Logger(providedSystemOptions.loggerOptions);
10389
10402
  logger.warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions)));
10390
10403
  }
10391
- // Throw an error if user has set allowNativeBroker to true without being in AAD protocol mode
10404
+ // Throw an error if user has set allowPlatformBroker to true without being in AAD protocol mode
10392
10405
  if (userInputAuth?.protocolMode &&
10393
10406
  userInputAuth.protocolMode !== ProtocolMode.AAD &&
10394
- providedSystemOptions?.allowNativeBroker) {
10395
- throw createClientConfigurationError(cannotAllowNativeBroker);
10407
+ providedSystemOptions?.allowPlatformBroker) {
10408
+ throw createClientConfigurationError(cannotAllowPlatformBroker);
10396
10409
  }
10397
10410
  const overlayedConfig = {
10398
10411
  auth: {
@@ -10412,7 +10425,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
10412
10425
 
10413
10426
  /* eslint-disable header/header */
10414
10427
  const name = "@azure/msal-browser";
10415
- const version = "4.0.0-alpha.0";
10428
+ const version = "4.0.2";
10416
10429
 
10417
10430
  /*
10418
10431
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11171,10 +11184,10 @@ class AsyncMemoryStorage {
11171
11184
  * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
11172
11185
  */
11173
11186
  class CryptoOps {
11174
- constructor(logger, performanceClient) {
11187
+ constructor(logger, performanceClient, skipValidateSubtleCrypto) {
11175
11188
  this.logger = logger;
11176
11189
  // Browser crypto needs to be validated first before any other classes can be set.
11177
- validateCryptoAvailable();
11190
+ validateCryptoAvailable(skipValidateSubtleCrypto ?? false);
11178
11191
  this.cache = new AsyncMemoryStorage(this.logger);
11179
11192
  this.performanceClient = performanceClient;
11180
11193
  }
@@ -11452,15 +11465,17 @@ function getTokenKeys(clientId, storage) {
11452
11465
  */
11453
11466
  const ENCRYPTION_KEY = "msal.cache.encryption";
11454
11467
  class LocalStorage {
11455
- constructor(clientId) {
11468
+ constructor(clientId, logger, performanceClient) {
11456
11469
  if (!window.localStorage) {
11457
11470
  throw createBrowserConfigurationAuthError(storageNotSupported);
11458
11471
  }
11459
11472
  this.memoryStorage = new MemoryStorage();
11460
11473
  this.initialized = false;
11461
11474
  this.clientId = clientId;
11475
+ this.logger = logger;
11476
+ this.performanceClient = performanceClient;
11462
11477
  }
11463
- async initialize() {
11478
+ async initialize(correlationId) {
11464
11479
  this.initialized = true;
11465
11480
  const cookies = new CookieStorage();
11466
11481
  const cookieString = cookies.getItem(ENCRYPTION_KEY);
@@ -11469,27 +11484,26 @@ class LocalStorage {
11469
11484
  try {
11470
11485
  parsedCookie = JSON.parse(cookieString);
11471
11486
  }
11472
- catch (e) {
11473
- // TODO: Log telemetry but don't throw
11474
- }
11487
+ catch (e) { }
11475
11488
  }
11476
11489
  if (parsedCookie.key && parsedCookie.id) {
11477
11490
  // Encryption key already exists, import
11491
+ const baseKey = invoke(base64DecToArr, PerformanceEvents.Base64Decode, this.logger, this.performanceClient, correlationId)(parsedCookie.key);
11478
11492
  this.encryptionCookie = {
11479
11493
  id: parsedCookie.id,
11480
- key: await generateHKDF(base64DecToArr(parsedCookie.key)),
11494
+ key: await invokeAsync(generateHKDF, PerformanceEvents.GenerateHKDF, this.logger, this.performanceClient, correlationId)(baseKey),
11481
11495
  };
11482
- await this.importExistingCache();
11496
+ await invokeAsync(this.importExistingCache.bind(this), PerformanceEvents.ImportExistingCache, this.logger, this.performanceClient, correlationId)(correlationId);
11483
11497
  }
11484
11498
  else {
11485
11499
  // Encryption key doesn't exist or is invalid, generate a new one and clear existing cache
11486
11500
  this.clear();
11487
11501
  const id = createNewGuid();
11488
- const baseKey = await generateBaseKey();
11489
- const keyStr = urlEncodeArr(new Uint8Array(baseKey));
11502
+ const baseKey = await invokeAsync(generateBaseKey, PerformanceEvents.GenerateBaseKey, this.logger, this.performanceClient, correlationId)();
11503
+ const keyStr = invoke(urlEncodeArr, PerformanceEvents.UrlEncodeArr, this.logger, this.performanceClient, correlationId)(new Uint8Array(baseKey));
11490
11504
  this.encryptionCookie = {
11491
11505
  id: id,
11492
- key: await generateHKDF(baseKey),
11506
+ key: await invokeAsync(generateHKDF, PerformanceEvents.GenerateHKDF, this.logger, this.performanceClient, correlationId)(baseKey),
11493
11507
  };
11494
11508
  const cookieData = {
11495
11509
  id: id,
@@ -11510,11 +11524,11 @@ class LocalStorage {
11510
11524
  setItem(key, value) {
11511
11525
  window.localStorage.setItem(key, value);
11512
11526
  }
11513
- async setUserData(key, value) {
11527
+ async setUserData(key, value, correlationId) {
11514
11528
  if (!this.initialized || !this.encryptionCookie) {
11515
11529
  throw createBrowserAuthError(uninitializedPublicClientApplication);
11516
11530
  }
11517
- const { data, nonce } = await encrypt(this.encryptionCookie.key, value, this.getContext(key));
11531
+ const { data, nonce } = await invokeAsync(encrypt, PerformanceEvents.Encrypt, this.logger, this.performanceClient, correlationId)(this.encryptionCookie.key, value, this.getContext(key));
11518
11532
  const encryptedData = {
11519
11533
  id: this.encryptionCookie.id,
11520
11534
  nonce: nonce,
@@ -11557,25 +11571,27 @@ class LocalStorage {
11557
11571
  * Helper to decrypt all known MSAL keys in localStorage and save them to inMemory storage
11558
11572
  * @returns
11559
11573
  */
11560
- async importExistingCache() {
11574
+ async importExistingCache(correlationId) {
11561
11575
  if (!this.encryptionCookie) {
11562
11576
  return;
11563
11577
  }
11564
- const accountKeys = getAccountKeys(this);
11565
- await this.importArray(accountKeys);
11578
+ let accountKeys = getAccountKeys(this);
11579
+ accountKeys = await this.importArray(accountKeys, correlationId);
11580
+ // Write valid account keys back to map
11581
+ this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11566
11582
  const tokenKeys = getTokenKeys(this.clientId, this);
11567
- await Promise.all([
11568
- this.importArray(tokenKeys.idToken),
11569
- this.importArray(tokenKeys.accessToken),
11570
- this.importArray(tokenKeys.refreshToken),
11571
- ]);
11583
+ tokenKeys.idToken = await this.importArray(tokenKeys.idToken, correlationId);
11584
+ tokenKeys.accessToken = await this.importArray(tokenKeys.accessToken, correlationId);
11585
+ tokenKeys.refreshToken = await this.importArray(tokenKeys.refreshToken, correlationId);
11586
+ // Write valid token keys back to map
11587
+ this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11572
11588
  }
11573
11589
  /**
11574
11590
  * Helper to decrypt and save cache entries
11575
11591
  * @param key
11576
11592
  * @returns
11577
11593
  */
11578
- async getItemFromEncryptedCache(key) {
11594
+ async getItemFromEncryptedCache(key, correlationId) {
11579
11595
  if (!this.encryptionCookie) {
11580
11596
  return null;
11581
11597
  }
@@ -11586,36 +11602,46 @@ class LocalStorage {
11586
11602
  let encObj;
11587
11603
  try {
11588
11604
  encObj = JSON.parse(rawCache);
11589
- if (!encObj.id || !encObj.nonce || !encObj.data) {
11590
- throw "Not encrypted!"; // TODO: Typed error
11591
- }
11592
- if (encObj.id !== this.encryptionCookie.id) {
11593
- throw "Old item!"; // TODO: Typed error
11594
- }
11595
11605
  }
11596
11606
  catch (e) {
11597
11607
  // Not a valid encrypted object, remove
11598
- this.removeItem(key);
11599
- // TODO: Log to telemetry
11600
11608
  return null;
11601
11609
  }
11602
- return decrypt(this.encryptionCookie.key, encObj.nonce, this.getContext(key), encObj.data);
11610
+ if (!encObj.id || !encObj.nonce || !encObj.data) {
11611
+ // Data is not encrypted, likely from old version of MSAL. It must be removed because we don't know how old it is.
11612
+ this.performanceClient.incrementFields({ unencryptedCacheCount: 1 }, correlationId);
11613
+ return null;
11614
+ }
11615
+ if (encObj.id !== this.encryptionCookie.id) {
11616
+ // Data was encrypted with a different key. It must be removed because it is from a previous session.
11617
+ this.performanceClient.incrementFields({ encryptedCacheExpiredCount: 1 }, correlationId);
11618
+ return null;
11619
+ }
11620
+ return invokeAsync(decrypt, PerformanceEvents.Decrypt, this.logger, this.performanceClient, correlationId)(this.encryptionCookie.key, encObj.nonce, this.getContext(key), encObj.data);
11603
11621
  }
11604
11622
  /**
11605
11623
  * Helper to decrypt and save an array of cache keys
11606
11624
  * @param arr
11625
+ * @returns Array of keys successfully imported
11607
11626
  */
11608
- async importArray(arr) {
11627
+ async importArray(arr, correlationId) {
11628
+ const importedArr = [];
11609
11629
  const promiseArr = [];
11610
11630
  arr.forEach((key) => {
11611
- const promise = this.getItemFromEncryptedCache(key).then((value) => {
11631
+ const promise = this.getItemFromEncryptedCache(key, correlationId).then((value) => {
11612
11632
  if (value) {
11613
11633
  this.memoryStorage.setItem(key, value);
11634
+ importedArr.push(key);
11635
+ }
11636
+ else {
11637
+ // If value is empty, unencrypted or expired remove
11638
+ this.removeItem(key);
11614
11639
  }
11615
11640
  });
11616
11641
  promiseArr.push(promise);
11617
11642
  });
11618
11643
  await Promise.all(promiseArr);
11644
+ return importedArr;
11619
11645
  }
11620
11646
  /**
11621
11647
  * Gets encryption context for a given cache entry. This is clientId for app specific entries, empty string for shared entries
@@ -11699,40 +11725,18 @@ function extractBrowserRequestState(browserCrypto, state) {
11699
11725
  * parameters such as state and nonce, generally.
11700
11726
  */
11701
11727
  class BrowserCacheManager extends CacheManager {
11702
- constructor(clientId, cacheConfig, cryptoImpl, logger, staticAuthorityOptions, performanceClient) {
11728
+ constructor(clientId, cacheConfig, cryptoImpl, logger, performanceClient, staticAuthorityOptions) {
11703
11729
  super(clientId, cryptoImpl, logger, staticAuthorityOptions);
11704
11730
  this.cacheConfig = cacheConfig;
11705
11731
  this.logger = logger;
11706
11732
  this.internalStorage = new MemoryStorage();
11707
- this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);
11708
- this.temporaryCacheStorage = this.setupBrowserStorage(this.cacheConfig.temporaryCacheLocation);
11733
+ this.browserStorage = getStorageImplementation(clientId, cacheConfig.cacheLocation, logger, performanceClient);
11734
+ this.temporaryCacheStorage = getStorageImplementation(clientId, cacheConfig.temporaryCacheLocation, logger, performanceClient);
11709
11735
  this.cookieStorage = new CookieStorage();
11710
11736
  this.performanceClient = performanceClient;
11711
11737
  }
11712
- async initialize() {
11713
- await this.browserStorage.initialize();
11714
- }
11715
- /**
11716
- * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
11717
- * @param cacheLocation
11718
- */
11719
- setupBrowserStorage(cacheLocation) {
11720
- try {
11721
- switch (cacheLocation) {
11722
- case BrowserCacheLocation.LocalStorage:
11723
- return new LocalStorage(this.clientId);
11724
- case BrowserCacheLocation.SessionStorage:
11725
- return new SessionStorage();
11726
- case BrowserCacheLocation.MemoryStorage:
11727
- default:
11728
- break;
11729
- }
11730
- }
11731
- catch (e) {
11732
- this.logger.error(e);
11733
- }
11734
- this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
11735
- return new MemoryStorage();
11738
+ async initialize(correlationId) {
11739
+ await this.browserStorage.initialize(correlationId);
11736
11740
  }
11737
11741
  /**
11738
11742
  * Parses passed value as JSON object, JSON.parse() will throw an error.
@@ -11779,10 +11783,10 @@ class BrowserCacheManager extends CacheManager {
11779
11783
  * set account entity in the platform cache
11780
11784
  * @param account
11781
11785
  */
11782
- async setAccount(account) {
11786
+ async setAccount(account, correlationId) {
11783
11787
  this.logger.trace("BrowserCacheManager.setAccount called");
11784
11788
  const key = account.generateAccountKey();
11785
- await this.browserStorage.setUserData(key, JSON.stringify(account));
11789
+ await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(key, JSON.stringify(account), correlationId);
11786
11790
  this.addAccountKeyToMap(key);
11787
11791
  }
11788
11792
  /**
@@ -11972,10 +11976,10 @@ class BrowserCacheManager extends CacheManager {
11972
11976
  * set IdToken credential to the platform cache
11973
11977
  * @param idToken
11974
11978
  */
11975
- async setIdTokenCredential(idToken) {
11979
+ async setIdTokenCredential(idToken, correlationId) {
11976
11980
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
11977
11981
  const idTokenKey = generateCredentialKey(idToken);
11978
- await this.browserStorage.setUserData(idTokenKey, JSON.stringify(idToken));
11982
+ await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(idTokenKey, JSON.stringify(idToken), correlationId);
11979
11983
  this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
11980
11984
  }
11981
11985
  /**
@@ -12003,10 +12007,10 @@ class BrowserCacheManager extends CacheManager {
12003
12007
  * set accessToken credential to the platform cache
12004
12008
  * @param accessToken
12005
12009
  */
12006
- async setAccessTokenCredential(accessToken) {
12010
+ async setAccessTokenCredential(accessToken, correlationId) {
12007
12011
  this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
12008
12012
  const accessTokenKey = generateCredentialKey(accessToken);
12009
- await this.browserStorage.setUserData(accessTokenKey, JSON.stringify(accessToken));
12013
+ await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(accessTokenKey, JSON.stringify(accessToken), correlationId);
12010
12014
  this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
12011
12015
  }
12012
12016
  /**
@@ -12034,10 +12038,10 @@ class BrowserCacheManager extends CacheManager {
12034
12038
  * set refreshToken credential to the platform cache
12035
12039
  * @param refreshToken
12036
12040
  */
12037
- async setRefreshTokenCredential(refreshToken) {
12041
+ async setRefreshTokenCredential(refreshToken, correlationId) {
12038
12042
  this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
12039
12043
  const refreshTokenKey = generateCredentialKey(refreshToken);
12040
- await this.browserStorage.setUserData(refreshTokenKey, JSON.stringify(refreshToken));
12044
+ await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(refreshTokenKey, JSON.stringify(refreshToken), correlationId);
12041
12045
  this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
12042
12046
  }
12043
12047
  /**
@@ -12596,7 +12600,7 @@ class BrowserCacheManager extends CacheManager {
12596
12600
  idToken: idTokenEntity,
12597
12601
  accessToken: accessTokenEntity,
12598
12602
  };
12599
- return this.saveCacheRecord(cacheRecord);
12603
+ return this.saveCacheRecord(cacheRecord, result.correlationId);
12600
12604
  }
12601
12605
  /**
12602
12606
  * saves a cache record
@@ -12604,9 +12608,9 @@ class BrowserCacheManager extends CacheManager {
12604
12608
  * @param storeInCache {?StoreInCache}
12605
12609
  * @param correlationId {?string} correlation id
12606
12610
  */
12607
- async saveCacheRecord(cacheRecord, storeInCache, correlationId) {
12611
+ async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
12608
12612
  try {
12609
- await super.saveCacheRecord(cacheRecord, storeInCache, correlationId);
12613
+ await super.saveCacheRecord(cacheRecord, correlationId, storeInCache);
12610
12614
  }
12611
12615
  catch (e) {
12612
12616
  if (e instanceof CacheError &&
@@ -12626,7 +12630,28 @@ class BrowserCacheManager extends CacheManager {
12626
12630
  }
12627
12631
  }
12628
12632
  }
12629
- const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
12633
+ /**
12634
+ * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
12635
+ * @param cacheLocation
12636
+ */
12637
+ function getStorageImplementation(clientId, cacheLocation, logger, performanceClient) {
12638
+ try {
12639
+ switch (cacheLocation) {
12640
+ case BrowserCacheLocation.LocalStorage:
12641
+ return new LocalStorage(clientId, logger, performanceClient);
12642
+ case BrowserCacheLocation.SessionStorage:
12643
+ return new SessionStorage();
12644
+ case BrowserCacheLocation.MemoryStorage:
12645
+ default:
12646
+ break;
12647
+ }
12648
+ }
12649
+ catch (e) {
12650
+ logger.error(e);
12651
+ }
12652
+ return new MemoryStorage();
12653
+ }
12654
+ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger, performanceClient) => {
12630
12655
  const cacheOptions = {
12631
12656
  cacheLocation: BrowserCacheLocation.MemoryStorage,
12632
12657
  temporaryCacheLocation: BrowserCacheLocation.MemoryStorage,
@@ -12635,7 +12660,7 @@ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
12635
12660
  cacheMigrationEnabled: false,
12636
12661
  claimsBasedCachingEnabled: false,
12637
12662
  };
12638
- return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
12663
+ return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger, performanceClient);
12639
12664
  };
12640
12665
 
12641
12666
  /*
@@ -13441,7 +13466,6 @@ class NativeInteractionClient extends BaseInteractionClient {
13441
13466
  this.nativeMessageHandler = provider;
13442
13467
  this.nativeStorageManager = nativeStorageImpl;
13443
13468
  this.silentCacheClient = new SilentCacheClient(config, this.nativeStorageManager, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
13444
- this.serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
13445
13469
  const extensionName = this.nativeMessageHandler.getExtensionId() ===
13446
13470
  NativeConstants.PREFERRED_EXTENSION_ID
13447
13471
  ? "chrome"
@@ -13476,6 +13500,7 @@ class NativeInteractionClient extends BaseInteractionClient {
13476
13500
  // start the perf measurement
13477
13501
  const nativeATMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
13478
13502
  const reqTimestamp = nowSeconds();
13503
+ const serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
13479
13504
  try {
13480
13505
  // initialize native request
13481
13506
  const nativeRequest = await this.initializeNativeRequest(request);
@@ -13508,7 +13533,7 @@ class NativeInteractionClient extends BaseInteractionClient {
13508
13533
  isNativeBroker: true,
13509
13534
  requestId: result.requestId,
13510
13535
  });
13511
- this.serverTelemetryManager.clearNativeBrokerErrorCode();
13536
+ serverTelemetryManager.clearNativeBrokerErrorCode();
13512
13537
  return result;
13513
13538
  })
13514
13539
  .catch((error) => {
@@ -13523,7 +13548,7 @@ class NativeInteractionClient extends BaseInteractionClient {
13523
13548
  }
13524
13549
  catch (e) {
13525
13550
  if (e instanceof NativeAuthError) {
13526
- this.serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
13551
+ serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
13527
13552
  }
13528
13553
  throw e;
13529
13554
  }
@@ -13600,7 +13625,8 @@ class NativeInteractionClient extends BaseInteractionClient {
13600
13625
  catch (e) {
13601
13626
  // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
13602
13627
  if (e instanceof NativeAuthError) {
13603
- this.serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
13628
+ const serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
13629
+ serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
13604
13630
  if (isFatalNativeAuthError(e)) {
13605
13631
  throw e;
13606
13632
  }
@@ -13655,7 +13681,8 @@ class NativeInteractionClient extends BaseInteractionClient {
13655
13681
  const result = this.handleNativeResponse(response, request, reqTimestamp);
13656
13682
  this.browserStorage.setInteractionInProgress(false);
13657
13683
  const res = await result;
13658
- this.serverTelemetryManager.clearNativeBrokerErrorCode();
13684
+ const serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
13685
+ serverTelemetryManager.clearNativeBrokerErrorCode();
13659
13686
  return res;
13660
13687
  }
13661
13688
  catch (e) {
@@ -13701,7 +13728,7 @@ class NativeInteractionClient extends BaseInteractionClient {
13701
13728
  const result = await this.generateAuthenticationResult(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
13702
13729
  // cache accounts and tokens in the appropriate storage
13703
13730
  await this.cacheAccount(baseAccount);
13704
- this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
13731
+ await this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
13705
13732
  return result;
13706
13733
  }
13707
13734
  /**
@@ -13827,7 +13854,7 @@ class NativeInteractionClient extends BaseInteractionClient {
13827
13854
  */
13828
13855
  async cacheAccount(accountEntity) {
13829
13856
  // Store the account info and hence `nativeAccountId` in browser cache
13830
- await this.browserStorage.setAccount(accountEntity);
13857
+ await this.browserStorage.setAccount(accountEntity, this.correlationId);
13831
13858
  // Remove any existing cached tokens for this account in browser storage
13832
13859
  this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
13833
13860
  this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
@@ -13858,7 +13885,7 @@ class NativeInteractionClient extends BaseInteractionClient {
13858
13885
  idToken: cachedIdToken,
13859
13886
  accessToken: cachedAccessToken,
13860
13887
  };
13861
- void this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.storeInCache);
13888
+ return this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, this.correlationId, request.storeInCache);
13862
13889
  }
13863
13890
  addTelemetryFromNativeResponse(response) {
13864
13891
  const mats = this.getMATSFromResponse(response);
@@ -14293,15 +14320,15 @@ class NativeMessageHandler {
14293
14320
  * @param nativeExtensionProvider
14294
14321
  * @param authenticationScheme
14295
14322
  */
14296
- static isNativeAvailable(config, logger, nativeExtensionProvider, authenticationScheme) {
14297
- logger.trace("isNativeAvailable called");
14298
- if (!config.system.allowNativeBroker) {
14299
- logger.trace("isNativeAvailable: allowNativeBroker is not enabled, returning false");
14323
+ static isPlatformBrokerAvailable(config, logger, nativeExtensionProvider, authenticationScheme) {
14324
+ logger.trace("isPlatformBrokerAvailable called");
14325
+ if (!config.system.allowPlatformBroker) {
14326
+ logger.trace("isPlatformBrokerAvailable: allowPlatformBroker is not enabled, returning false");
14300
14327
  // Developer disabled WAM
14301
14328
  return false;
14302
14329
  }
14303
14330
  if (!nativeExtensionProvider) {
14304
- logger.trace("isNativeAvailable: WAM extension provider is not initialized, returning false");
14331
+ logger.trace("isPlatformBrokerAvailable: Platform extension provider is not initialized, returning false");
14305
14332
  // Extension is not available
14306
14333
  return false;
14307
14334
  }
@@ -14309,10 +14336,10 @@ class NativeMessageHandler {
14309
14336
  switch (authenticationScheme) {
14310
14337
  case AuthenticationScheme.BEARER:
14311
14338
  case AuthenticationScheme.POP:
14312
- logger.trace("isNativeAvailable: authenticationScheme is supported, returning true");
14339
+ logger.trace("isPlatformBrokerAvailable: authenticationScheme is supported, returning true");
14313
14340
  return true;
14314
14341
  default:
14315
- logger.trace("isNativeAvailable: authenticationScheme is not supported, returning false");
14342
+ logger.trace("isPlatformBrokerAvailable: authenticationScheme is not supported, returning false");
14316
14343
  return false;
14317
14344
  }
14318
14345
  }
@@ -14549,17 +14576,17 @@ class PopupClient extends StandardInteractionClient {
14549
14576
  requestExtraQueryParameters: validRequest.extraQueryParameters,
14550
14577
  account: validRequest.account,
14551
14578
  });
14552
- const isNativeBroker = NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme);
14579
+ const isPlatformBroker = NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme);
14553
14580
  // Start measurement for server calls with native brokering enabled
14554
14581
  let fetchNativeAccountIdMeasurement;
14555
- if (isNativeBroker) {
14582
+ if (isPlatformBroker) {
14556
14583
  fetchNativeAccountIdMeasurement =
14557
14584
  this.performanceClient.startMeasurement(PerformanceEvents.FetchAccountIdWithNativeBroker, request.correlationId);
14558
14585
  }
14559
14586
  // Create acquire token url.
14560
14587
  const navigateUrl = await authClient.getAuthCodeUrl({
14561
14588
  ...validRequest,
14562
- nativeBroker: isNativeBroker,
14589
+ platformBroker: isPlatformBroker,
14563
14590
  });
14564
14591
  // Create popup interaction handler.
14565
14592
  const interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
@@ -15076,7 +15103,7 @@ class RedirectClient extends StandardInteractionClient {
15076
15103
  // Create acquire token url.
15077
15104
  const navigateUrl = await authClient.getAuthCodeUrl({
15078
15105
  ...validRequest,
15079
- nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme),
15106
+ platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme),
15080
15107
  });
15081
15108
  const redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);
15082
15109
  this.logger.verbosePii(`Redirect start page: ${redirectStartPage}`);
@@ -15590,7 +15617,7 @@ class SilentIframeClient extends StandardInteractionClient {
15590
15617
  // Create authorize request url
15591
15618
  const navigateUrl = await invokeAsync(authClient.getAuthCodeUrl.bind(authClient), PerformanceEvents.GetAuthCodeUrl, this.logger, this.performanceClient, correlationId)({
15592
15619
  ...silentRequest,
15593
- nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme),
15620
+ platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme),
15594
15621
  });
15595
15622
  // Create silent handler
15596
15623
  const interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
@@ -15709,6 +15736,7 @@ class TokenCache {
15709
15736
  if (!this.isBrowserEnvironment) {
15710
15737
  throw createBrowserAuthError(nonBrowserEnvironment);
15711
15738
  }
15739
+ const correlationId = request.correlationId || createNewGuid();
15712
15740
  const idTokenClaims = response.id_token
15713
15741
  ? extractTokenClaims(response.id_token, base64Decode)
15714
15742
  : undefined;
@@ -15722,10 +15750,10 @@ class TokenCache {
15722
15750
  const authority = request.authority
15723
15751
  ? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
15724
15752
  : undefined;
15725
- const cacheRecordAccount = await this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
15726
- const idToken = await this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
15727
- const accessToken = await this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
15728
- const refreshToken = await this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
15753
+ const cacheRecordAccount = await this.loadAccount(request, options.clientInfo || response.client_info || "", correlationId, idTokenClaims, authority);
15754
+ const idToken = await this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, correlationId);
15755
+ const accessToken = await this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options, correlationId);
15756
+ const refreshToken = await this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, correlationId);
15729
15757
  return this.generateAuthenticationResult(request, {
15730
15758
  account: cacheRecordAccount,
15731
15759
  idToken,
@@ -15742,11 +15770,11 @@ class TokenCache {
15742
15770
  * @param requestHomeAccountId
15743
15771
  * @returns `AccountEntity`
15744
15772
  */
15745
- async loadAccount(request, clientInfo, idTokenClaims, authority) {
15773
+ async loadAccount(request, clientInfo, correlationId, idTokenClaims, authority) {
15746
15774
  this.logger.verbose("TokenCache - loading account");
15747
15775
  if (request.account) {
15748
15776
  const accountEntity = AccountEntity.createFromAccountInfo(request.account);
15749
- await this.storage.setAccount(accountEntity);
15777
+ await this.storage.setAccount(accountEntity, correlationId);
15750
15778
  return accountEntity;
15751
15779
  }
15752
15780
  else if (!authority || (!clientInfo && !idTokenClaims)) {
@@ -15758,7 +15786,7 @@ class TokenCache {
15758
15786
  const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
15759
15787
  undefined, // nativeAccountId
15760
15788
  this.logger);
15761
- await this.storage.setAccount(cachedAccount);
15789
+ await this.storage.setAccount(cachedAccount, correlationId);
15762
15790
  return cachedAccount;
15763
15791
  }
15764
15792
  /**
@@ -15769,14 +15797,14 @@ class TokenCache {
15769
15797
  * @param tenantId
15770
15798
  * @returns `IdTokenEntity`
15771
15799
  */
15772
- async loadIdToken(response, homeAccountId, environment, tenantId) {
15800
+ async loadIdToken(response, homeAccountId, environment, tenantId, correlationId) {
15773
15801
  if (!response.id_token) {
15774
15802
  this.logger.verbose("TokenCache - no id token found in response");
15775
15803
  return null;
15776
15804
  }
15777
15805
  this.logger.verbose("TokenCache - loading id token");
15778
15806
  const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
15779
- await this.storage.setIdTokenCredential(idTokenEntity);
15807
+ await this.storage.setIdTokenCredential(idTokenEntity, correlationId);
15780
15808
  return idTokenEntity;
15781
15809
  }
15782
15810
  /**
@@ -15788,7 +15816,7 @@ class TokenCache {
15788
15816
  * @param tenantId
15789
15817
  * @returns `AccessTokenEntity`
15790
15818
  */
15791
- async loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
15819
+ async loadAccessToken(request, response, homeAccountId, environment, tenantId, options, correlationId) {
15792
15820
  if (!response.access_token) {
15793
15821
  this.logger.verbose("TokenCache - no access token found in response");
15794
15822
  return null;
@@ -15812,7 +15840,7 @@ class TokenCache {
15812
15840
  (response.ext_expires_in || response.expires_in) +
15813
15841
  new Date().getTime() / 1000;
15814
15842
  const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
15815
- await this.storage.setAccessTokenCredential(accessTokenEntity);
15843
+ await this.storage.setAccessTokenCredential(accessTokenEntity, correlationId);
15816
15844
  return accessTokenEntity;
15817
15845
  }
15818
15846
  /**
@@ -15823,7 +15851,7 @@ class TokenCache {
15823
15851
  * @param environment
15824
15852
  * @returns `RefreshTokenEntity`
15825
15853
  */
15826
- async loadRefreshToken(response, homeAccountId, environment) {
15854
+ async loadRefreshToken(response, homeAccountId, environment, correlationId) {
15827
15855
  if (!response.refresh_token) {
15828
15856
  this.logger.verbose("TokenCache - no refresh token found in response");
15829
15857
  return null;
@@ -15831,7 +15859,7 @@ class TokenCache {
15831
15859
  this.logger.verbose("TokenCache - loading refresh token");
15832
15860
  const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
15833
15861
  response.refresh_token_expires_in);
15834
- await this.storage.setRefreshTokenCredential(refreshTokenEntity);
15862
+ await this.storage.setRefreshTokenCredential(refreshTokenEntity, correlationId);
15835
15863
  return refreshTokenEntity;
15836
15864
  }
15837
15865
  /**
@@ -16027,8 +16055,8 @@ class StandardController {
16027
16055
  this.eventHandler = new EventHandler(this.logger);
16028
16056
  // Initialize the browser storage class.
16029
16057
  this.browserStorage = this.isBrowserEnvironment
16030
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, buildStaticAuthorityOptions(this.config.auth), this.performanceClient)
16031
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
16058
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, buildStaticAuthorityOptions(this.config.auth))
16059
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
16032
16060
  // initialize in memory storage for native flows
16033
16061
  const nativeCacheOptions = {
16034
16062
  cacheLocation: BrowserCacheLocation.MemoryStorage,
@@ -16038,7 +16066,7 @@ class StandardController {
16038
16066
  cacheMigrationEnabled: false,
16039
16067
  claimsBasedCachingEnabled: false,
16040
16068
  };
16041
- this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger, undefined, this.performanceClient);
16069
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger, this.performanceClient);
16042
16070
  // Initialize the token cache
16043
16071
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
16044
16072
  this.activeSilentTokenRequests = new Map();
@@ -16080,12 +16108,12 @@ class StandardController {
16080
16108
  this.eventHandler.emitEvent(EventType.INITIALIZE_END);
16081
16109
  return;
16082
16110
  }
16083
- await this.browserStorage.initialize();
16084
16111
  const initCorrelationId = request?.correlationId || this.getRequestCorrelationId();
16085
- const allowNativeBroker = this.config.system.allowNativeBroker;
16112
+ const allowPlatformBroker = this.config.system.allowPlatformBroker;
16086
16113
  const initMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.InitializeClientApplication, initCorrelationId);
16087
16114
  this.eventHandler.emitEvent(EventType.INITIALIZE_START);
16088
- if (allowNativeBroker) {
16115
+ await invokeAsync(this.browserStorage.initialize.bind(this.browserStorage), PerformanceEvents.InitializeCache, this.logger, this.performanceClient, initCorrelationId)(initCorrelationId);
16116
+ if (allowPlatformBroker) {
16089
16117
  try {
16090
16118
  this.nativeExtensionProvider =
16091
16119
  await NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient);
@@ -16100,7 +16128,10 @@ class StandardController {
16100
16128
  }
16101
16129
  this.initialized = true;
16102
16130
  this.eventHandler.emitEvent(EventType.INITIALIZE_END);
16103
- initMeasurement.end({ allowNativeBroker, success: true });
16131
+ initMeasurement.end({
16132
+ allowPlatformBroker: allowPlatformBroker,
16133
+ success: true,
16134
+ });
16104
16135
  }
16105
16136
  // #region Redirect Flow
16106
16137
  /**
@@ -16144,7 +16175,7 @@ class StandardController {
16144
16175
  const loggedInAccounts = this.getAllAccounts();
16145
16176
  const request = this.browserStorage.getCachedNativeRequest();
16146
16177
  const useNative = request &&
16147
- NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
16178
+ NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
16148
16179
  this.nativeExtensionProvider &&
16149
16180
  !hash;
16150
16181
  const correlationId = useNative
@@ -16273,7 +16304,8 @@ class StandardController {
16273
16304
  this.eventHandler.emitEvent(EventType.LOGIN_START, exports.InteractionType.Redirect, request);
16274
16305
  }
16275
16306
  let result;
16276
- if (this.nativeExtensionProvider && this.canUseNative(request)) {
16307
+ if (this.nativeExtensionProvider &&
16308
+ this.canUsePlatformBroker(request)) {
16277
16309
  const nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.acquireTokenRedirect, this.performanceClient, this.nativeExtensionProvider, this.getNativeAccountId(request), this.nativeInternalStorage, correlationId);
16278
16310
  result = nativeClient
16279
16311
  .acquireTokenRedirect(request, atrMeasurement)
@@ -16344,7 +16376,7 @@ class StandardController {
16344
16376
  this.eventHandler.emitEvent(EventType.LOGIN_START, exports.InteractionType.Popup, request);
16345
16377
  }
16346
16378
  let result;
16347
- if (this.canUseNative(request)) {
16379
+ if (this.canUsePlatformBroker(request)) {
16348
16380
  result = this.acquireTokenNative({
16349
16381
  ...request,
16350
16382
  correlationId,
@@ -16461,7 +16493,7 @@ class StandardController {
16461
16493
  this.logger.verbose("ssoSilent called", correlationId);
16462
16494
  this.eventHandler.emitEvent(EventType.SSO_SILENT_START, exports.InteractionType.Silent, validRequest);
16463
16495
  let result;
16464
- if (this.canUseNative(validRequest)) {
16496
+ if (this.canUsePlatformBroker(validRequest)) {
16465
16497
  result = this.acquireTokenNative(validRequest, ApiId.ssoSilent).catch((e) => {
16466
16498
  // If native token acquisition fails for availability reasons fallback to standard flow
16467
16499
  if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
@@ -16559,7 +16591,7 @@ class StandardController {
16559
16591
  return await response;
16560
16592
  }
16561
16593
  else if (request.nativeAccountId) {
16562
- if (this.canUseNative(request, request.nativeAccountId)) {
16594
+ if (this.canUsePlatformBroker(request, request.nativeAccountId)) {
16563
16595
  const result = await this.acquireTokenNative({
16564
16596
  ...request,
16565
16597
  correlationId,
@@ -16806,7 +16838,7 @@ class StandardController {
16806
16838
  this.logger.verbose("hydrateCache called");
16807
16839
  // Account gets saved to browser storage regardless of native or not
16808
16840
  const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
16809
- await this.browserStorage.setAccount(accountEntity);
16841
+ await this.browserStorage.setAccount(accountEntity, result.correlationId);
16810
16842
  if (result.fromNativeBroker) {
16811
16843
  this.logger.verbose("Response was from native broker, storing in-memory");
16812
16844
  // Tokens from native broker are stored in-memory
@@ -16830,13 +16862,13 @@ class StandardController {
16830
16862
  return nativeClient.acquireToken(request);
16831
16863
  }
16832
16864
  /**
16833
- * Returns boolean indicating if this request can use the native broker
16865
+ * Returns boolean indicating if this request can use the platform broker
16834
16866
  * @param request
16835
16867
  */
16836
- canUseNative(request, accountId) {
16837
- this.logger.trace("canUseNative called");
16838
- if (!NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme)) {
16839
- this.logger.trace("canUseNative: isNativeAvailable returned false, returning false");
16868
+ canUsePlatformBroker(request, accountId) {
16869
+ this.logger.trace("canUsePlatformBroker called");
16870
+ if (!NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme)) {
16871
+ this.logger.trace("canUsePlatformBroker: isPlatformBrokerAvailable returned false, returning false");
16840
16872
  return false;
16841
16873
  }
16842
16874
  if (request.prompt) {
@@ -16844,15 +16876,15 @@ class StandardController {
16844
16876
  case PromptValue.NONE:
16845
16877
  case PromptValue.CONSENT:
16846
16878
  case PromptValue.LOGIN:
16847
- this.logger.trace("canUseNative: prompt is compatible with native flow");
16879
+ this.logger.trace("canUsePlatformBroker: prompt is compatible with platform broker flow");
16848
16880
  break;
16849
16881
  default:
16850
- this.logger.trace(`canUseNative: prompt = ${request.prompt} is not compatible with native flow, returning false`);
16882
+ this.logger.trace(`canUsePlatformBroker: prompt = ${request.prompt} is not compatible with platform broker flow, returning false`);
16851
16883
  return false;
16852
16884
  }
16853
16885
  }
16854
16886
  if (!accountId && !this.getNativeAccountId(request)) {
16855
- this.logger.trace("canUseNative: nativeAccountId is not available, returning false");
16887
+ this.logger.trace("canUsePlatformBroker: nativeAccountId is not available, returning false");
16856
16888
  return false;
16857
16889
  }
16858
16890
  return true;
@@ -17293,7 +17325,7 @@ class StandardController {
17293
17325
  * @returns
17294
17326
  */
17295
17327
  async acquireTokenSilentNoIframe(silentRequest, cacheLookupPolicy) {
17296
- if (NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, silentRequest.authenticationScheme) &&
17328
+ if (NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider, silentRequest.authenticationScheme) &&
17297
17329
  silentRequest.account.nativeAccountId) {
17298
17330
  this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
17299
17331
  return this.acquireTokenNative(silentRequest, ApiId.acquireTokenSilent_silentFlow).catch(async (e) => {
@@ -17579,20 +17611,17 @@ class NestedAppAuthController {
17579
17611
  this.performanceClient = this.config.telemetry.client;
17580
17612
  // Initialize the crypto class.
17581
17613
  this.browserCrypto = operatingContext.isBrowserEnvironment()
17582
- ? new CryptoOps(this.logger, this.performanceClient)
17614
+ ? new CryptoOps(this.logger, this.performanceClient, true)
17583
17615
  : DEFAULT_CRYPTO_IMPLEMENTATION;
17584
17616
  // Initialize the browser storage class.
17585
17617
  this.browserStorage = this.operatingContext.isBrowserEnvironment()
17586
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, buildStaticAuthorityOptions(this.config.auth))
17587
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
17618
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, buildStaticAuthorityOptions(this.config.auth))
17619
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
17588
17620
  this.eventHandler = new EventHandler(this.logger);
17589
17621
  this.nestedAppAuthAdapter = new NestedAppAuthAdapter(this.config.auth.clientId, this.config.auth.clientCapabilities, this.browserCrypto, this.logger);
17590
17622
  // Set the active account if available
17591
17623
  const accountContext = this.bridgeProxy.getAccountContext();
17592
- if (accountContext) {
17593
- const cachedAccount = getAccount(accountContext, this.logger, this.browserStorage);
17594
- setActiveAccount(cachedAccount, this.browserStorage);
17595
- }
17624
+ this.currentAccountContext = accountContext ? accountContext : null;
17596
17625
  }
17597
17626
  /**
17598
17627
  * Factory function to create a new instance of NestedAppAuthController
@@ -17607,8 +17636,9 @@ class NestedAppAuthController {
17607
17636
  * Specific implementation of initialize function for NestedAppAuthController
17608
17637
  * @returns
17609
17638
  */
17610
- async initialize() {
17611
- await this.browserStorage.initialize();
17639
+ async initialize(request) {
17640
+ const initCorrelationId = request?.correlationId || createNewGuid();
17641
+ await this.browserStorage.initialize(initCorrelationId);
17612
17642
  return Promise.resolve();
17613
17643
  }
17614
17644
  /**
@@ -17644,7 +17674,12 @@ class NestedAppAuthController {
17644
17674
  };
17645
17675
  // cache the tokens in the response
17646
17676
  await this.hydrateCache(result, request);
17647
- this.browserStorage.setActiveAccount(result.account);
17677
+ // cache the account context in memory after successful token fetch
17678
+ this.currentAccountContext = {
17679
+ homeAccountId: result.account.homeAccountId,
17680
+ environment: result.account.environment,
17681
+ tenantId: result.account.tenantId,
17682
+ };
17648
17683
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
17649
17684
  atPopupMeasurement.add({
17650
17685
  accessTokenSize: result.accessToken.length,
@@ -17694,7 +17729,12 @@ class NestedAppAuthController {
17694
17729
  const result = this.nestedAppAuthAdapter.fromNaaTokenResponse(naaRequest, response, reqTimestamp);
17695
17730
  // cache the tokens in the response
17696
17731
  await this.hydrateCache(result, request);
17697
- this.browserStorage.setActiveAccount(result.account);
17732
+ // cache the account context in memory after successful token fetch
17733
+ this.currentAccountContext = {
17734
+ homeAccountId: result.account.homeAccountId,
17735
+ environment: result.account.environment,
17736
+ tenantId: result.account.tenantId,
17737
+ };
17698
17738
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, result);
17699
17739
  ssoSilentMeasurement?.add({
17700
17740
  accessTokenSize: result.accessToken.length,
@@ -17730,8 +17770,16 @@ class NestedAppAuthController {
17730
17770
  this.logger.verbose("Claims are present in the request, skipping cache lookup");
17731
17771
  return null;
17732
17772
  }
17773
+ // if the request has forceRefresh, we cannot look up in the cache
17774
+ if (request.forceRefresh) {
17775
+ this.logger.verbose("forceRefresh is set to true, skipping cache lookup");
17776
+ return null;
17777
+ }
17733
17778
  // respect cache lookup policy
17734
17779
  let result = null;
17780
+ if (!request.cacheLookupPolicy) {
17781
+ request.cacheLookupPolicy = CacheLookupPolicy.Default;
17782
+ }
17735
17783
  switch (request.cacheLookupPolicy) {
17736
17784
  case CacheLookupPolicy.Default:
17737
17785
  case CacheLookupPolicy.AccessToken:
@@ -17765,12 +17813,11 @@ class NestedAppAuthController {
17765
17813
  * @returns
17766
17814
  */
17767
17815
  async acquireTokenFromCacheInternal(request) {
17768
- const accountContext = this.bridgeProxy.getAccountContext();
17816
+ // always prioritize the account context from the bridge
17817
+ const accountContext = this.bridgeProxy.getAccountContext() || this.currentAccountContext;
17769
17818
  let currentAccount = null;
17770
17819
  if (accountContext) {
17771
- const hubAccount = getAccount(accountContext, this.logger, this.browserStorage);
17772
- // always prioritize for hub account context, the reqirement of `request.account` will be removed soon
17773
- currentAccount = hubAccount || request.account;
17820
+ currentAccount = getAccount(accountContext, this.logger, this.browserStorage);
17774
17821
  }
17775
17822
  // fall back to brokering if no cached account is found
17776
17823
  if (!currentAccount) {
@@ -18034,7 +18081,7 @@ class NestedAppAuthController {
18034
18081
  async hydrateCache(result, request) {
18035
18082
  this.logger.verbose("hydrateCache called");
18036
18083
  const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
18037
- await this.browserStorage.setAccount(accountEntity);
18084
+ await this.browserStorage.setAccount(accountEntity, result.correlationId);
18038
18085
  return this.browserStorage.hydrateCache(result, request);
18039
18086
  }
18040
18087
  }
@@ -18414,7 +18461,9 @@ async function createNestablePublicClientApplication(configuration) {
18414
18461
  await nestedAppAuth.initialize();
18415
18462
  if (nestedAppAuth.isAvailable()) {
18416
18463
  const controller = new NestedAppAuthController(nestedAppAuth);
18417
- return new PublicClientApplication(configuration, controller);
18464
+ const nestablePCA = new PublicClientApplication(configuration, controller);
18465
+ await nestablePCA.initialize();
18466
+ return nestablePCA;
18418
18467
  }
18419
18468
  return createStandardPublicClientApplication(configuration);
18420
18469
  }
@@ -18466,8 +18515,8 @@ class UnknownOperatingContextController {
18466
18515
  : DEFAULT_CRYPTO_IMPLEMENTATION;
18467
18516
  // Initialize the browser storage class.
18468
18517
  this.browserStorage = this.isBrowserEnvironment
18469
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, undefined, this.performanceClient)
18470
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
18518
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, undefined)
18519
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
18471
18520
  }
18472
18521
  getBrowserStorage() {
18473
18522
  return this.browserStorage;