@azure/msal-browser 3.28.1 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/app/PublicClientNext.mjs +1 -1
  4. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
  5. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  6. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +8 -8
  7. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  8. package/dist/broker/nativeBroker/NativeResponse.d.ts +1 -1
  9. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  10. package/dist/cache/AccountManager.mjs +1 -1
  11. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  12. package/dist/cache/BrowserCacheManager.d.ts +11 -51
  13. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  14. package/dist/cache/BrowserCacheManager.mjs +42 -291
  15. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  16. package/dist/cache/CacheHelpers.d.ts +16 -0
  17. package/dist/cache/CacheHelpers.d.ts.map +1 -0
  18. package/dist/cache/CacheHelpers.mjs +46 -0
  19. package/dist/cache/CacheHelpers.mjs.map +1 -0
  20. package/dist/cache/CookieStorage.d.ts +3 -0
  21. package/dist/cache/CookieStorage.d.ts.map +1 -1
  22. package/dist/cache/CookieStorage.mjs +12 -1
  23. package/dist/cache/CookieStorage.mjs.map +1 -1
  24. package/dist/cache/DatabaseStorage.mjs +1 -1
  25. package/dist/cache/ITokenCache.d.ts +1 -1
  26. package/dist/cache/ITokenCache.d.ts.map +1 -1
  27. package/dist/cache/IWindowStorage.d.ts +12 -0
  28. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  29. package/dist/cache/LocalStorage.d.ts +38 -1
  30. package/dist/cache/LocalStorage.d.ts.map +1 -1
  31. package/dist/cache/LocalStorage.mjs +183 -2
  32. package/dist/cache/LocalStorage.mjs.map +1 -1
  33. package/dist/cache/MemoryStorage.d.ts +3 -0
  34. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  35. package/dist/cache/MemoryStorage.mjs +10 -1
  36. package/dist/cache/MemoryStorage.mjs.map +1 -1
  37. package/dist/cache/SessionStorage.d.ts +3 -0
  38. package/dist/cache/SessionStorage.d.ts.map +1 -1
  39. package/dist/cache/SessionStorage.mjs +10 -1
  40. package/dist/cache/SessionStorage.mjs.map +1 -1
  41. package/dist/cache/TokenCache.d.ts +1 -1
  42. package/dist/cache/TokenCache.d.ts.map +1 -1
  43. package/dist/cache/TokenCache.mjs +16 -15
  44. package/dist/cache/TokenCache.mjs.map +1 -1
  45. package/dist/config/Configuration.d.ts +2 -2
  46. package/dist/config/Configuration.d.ts.map +1 -1
  47. package/dist/config/Configuration.mjs +5 -5
  48. package/dist/config/Configuration.mjs.map +1 -1
  49. package/dist/controllers/ControllerFactory.mjs +1 -1
  50. package/dist/controllers/NestedAppAuthController.d.ts +4 -3
  51. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  52. package/dist/controllers/NestedAppAuthController.mjs +8 -6
  53. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  54. package/dist/controllers/StandardController.d.ts +2 -2
  55. package/dist/controllers/StandardController.d.ts.map +1 -1
  56. package/dist/controllers/StandardController.mjs +27 -22
  57. package/dist/controllers/StandardController.mjs.map +1 -1
  58. package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
  59. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  60. package/dist/controllers/UnknownOperatingContextController.mjs +3 -3
  61. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  62. package/dist/crypto/BrowserCrypto.d.ts +27 -0
  63. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  64. package/dist/crypto/BrowserCrypto.mjs +83 -3
  65. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  66. package/dist/crypto/CryptoOps.mjs +1 -1
  67. package/dist/crypto/PkceGenerator.mjs +1 -1
  68. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  69. package/dist/encode/Base64Decode.d.ts +5 -0
  70. package/dist/encode/Base64Decode.d.ts.map +1 -1
  71. package/dist/encode/Base64Decode.mjs +2 -2
  72. package/dist/encode/Base64Decode.mjs.map +1 -1
  73. package/dist/encode/Base64Encode.mjs +1 -1
  74. package/dist/error/BrowserAuthError.mjs +1 -1
  75. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  76. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  77. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  78. package/dist/error/NativeAuthError.mjs +1 -1
  79. package/dist/error/NativeAuthError.mjs.map +1 -1
  80. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  81. package/dist/error/NestedAppAuthError.mjs +1 -1
  82. package/dist/event/EventHandler.mjs +1 -1
  83. package/dist/event/EventMessage.mjs +1 -1
  84. package/dist/event/EventType.mjs +1 -1
  85. package/dist/index.d.ts +0 -1
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.mjs +1 -2
  88. package/dist/index.mjs.map +1 -1
  89. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  90. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  91. package/dist/interaction_client/NativeInteractionClient.d.ts +2 -2
  92. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  93. package/dist/interaction_client/NativeInteractionClient.mjs +6 -6
  94. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  95. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  96. package/dist/interaction_client/PopupClient.mjs +4 -4
  97. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  98. package/dist/interaction_client/RedirectClient.mjs +2 -2
  99. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  100. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  101. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  102. package/dist/interaction_client/SilentIframeClient.mjs +2 -2
  103. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  104. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  105. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  106. package/dist/interaction_client/StandardInteractionClient.mjs +1 -8
  107. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  108. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  109. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  110. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  111. package/dist/naa/BridgeError.mjs +1 -1
  112. package/dist/naa/BridgeProxy.mjs +1 -1
  113. package/dist/naa/BridgeStatusCode.mjs +1 -1
  114. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  115. package/dist/navigation/NavigationClient.mjs +1 -1
  116. package/dist/network/FetchClient.mjs +1 -1
  117. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  118. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  119. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  120. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  121. package/dist/packageMetadata.d.ts +1 -1
  122. package/dist/packageMetadata.d.ts.map +1 -1
  123. package/dist/packageMetadata.mjs +2 -2
  124. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  125. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  126. package/dist/request/PopupRequest.d.ts +1 -1
  127. package/dist/request/PopupRequest.d.ts.map +1 -1
  128. package/dist/request/RedirectRequest.d.ts +1 -1
  129. package/dist/request/RedirectRequest.d.ts.map +1 -1
  130. package/dist/request/RequestHelpers.mjs +1 -1
  131. package/dist/request/SsoSilentRequest.d.ts +1 -1
  132. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  133. package/dist/response/ResponseHandler.mjs +1 -1
  134. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  135. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  136. package/dist/utils/BrowserConstants.mjs +1 -1
  137. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  138. package/dist/utils/BrowserUtils.mjs +1 -1
  139. package/lib/msal-browser.cjs +630 -650
  140. package/lib/msal-browser.cjs.map +1 -1
  141. package/lib/msal-browser.js +630 -650
  142. package/lib/msal-browser.js.map +1 -1
  143. package/lib/msal-browser.min.js +65 -66
  144. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
  145. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  146. package/lib/types/broker/nativeBroker/NativeResponse.d.ts +1 -1
  147. package/lib/types/cache/BrowserCacheManager.d.ts +11 -51
  148. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  149. package/lib/types/cache/CacheHelpers.d.ts +16 -0
  150. package/lib/types/cache/CacheHelpers.d.ts.map +1 -0
  151. package/lib/types/cache/CookieStorage.d.ts +3 -0
  152. package/lib/types/cache/CookieStorage.d.ts.map +1 -1
  153. package/lib/types/cache/ITokenCache.d.ts +1 -1
  154. package/lib/types/cache/ITokenCache.d.ts.map +1 -1
  155. package/lib/types/cache/IWindowStorage.d.ts +12 -0
  156. package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
  157. package/lib/types/cache/LocalStorage.d.ts +38 -1
  158. package/lib/types/cache/LocalStorage.d.ts.map +1 -1
  159. package/lib/types/cache/MemoryStorage.d.ts +3 -0
  160. package/lib/types/cache/MemoryStorage.d.ts.map +1 -1
  161. package/lib/types/cache/SessionStorage.d.ts +3 -0
  162. package/lib/types/cache/SessionStorage.d.ts.map +1 -1
  163. package/lib/types/cache/TokenCache.d.ts +1 -1
  164. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  165. package/lib/types/config/Configuration.d.ts +2 -2
  166. package/lib/types/config/Configuration.d.ts.map +1 -1
  167. package/lib/types/controllers/NestedAppAuthController.d.ts +4 -3
  168. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  169. package/lib/types/controllers/StandardController.d.ts +2 -2
  170. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  171. package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
  172. package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  173. package/lib/types/crypto/BrowserCrypto.d.ts +27 -0
  174. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  175. package/lib/types/encode/Base64Decode.d.ts +5 -0
  176. package/lib/types/encode/Base64Decode.d.ts.map +1 -1
  177. package/lib/types/index.d.ts +0 -1
  178. package/lib/types/index.d.ts.map +1 -1
  179. package/lib/types/interaction_client/NativeInteractionClient.d.ts +2 -2
  180. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  181. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  182. package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  183. package/lib/types/packageMetadata.d.ts +1 -1
  184. package/lib/types/packageMetadata.d.ts.map +1 -1
  185. package/lib/types/request/AuthorizationUrlRequest.d.ts +1 -1
  186. package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
  187. package/lib/types/request/PopupRequest.d.ts +1 -1
  188. package/lib/types/request/PopupRequest.d.ts.map +1 -1
  189. package/lib/types/request/RedirectRequest.d.ts +1 -1
  190. package/lib/types/request/RedirectRequest.d.ts.map +1 -1
  191. package/lib/types/request/SsoSilentRequest.d.ts +1 -1
  192. package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
  193. package/package.json +2 -2
  194. package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
  195. package/src/broker/nativeBroker/NativeResponse.ts +1 -1
  196. package/src/cache/BrowserCacheManager.ts +95 -422
  197. package/src/cache/CacheHelpers.ts +52 -0
  198. package/src/cache/CookieStorage.ts +18 -0
  199. package/src/cache/ITokenCache.ts +1 -1
  200. package/src/cache/IWindowStorage.ts +14 -0
  201. package/src/cache/LocalStorage.ts +330 -1
  202. package/src/cache/MemoryStorage.ts +12 -0
  203. package/src/cache/SessionStorage.ts +12 -0
  204. package/src/cache/TokenCache.ts +42 -25
  205. package/src/config/Configuration.ts +6 -6
  206. package/src/controllers/NestedAppAuthController.ts +14 -6
  207. package/src/controllers/StandardController.ts +41 -22
  208. package/src/controllers/UnknownOperatingContextController.ts +6 -5
  209. package/src/crypto/BrowserCrypto.ts +120 -1
  210. package/src/encode/Base64Decode.ts +1 -1
  211. package/src/index.ts +0 -1
  212. package/src/interaction_client/NativeInteractionClient.ts +7 -6
  213. package/src/interaction_client/PopupClient.ts +9 -8
  214. package/src/interaction_client/RedirectClient.ts +1 -1
  215. package/src/interaction_client/SilentIframeClient.ts +1 -1
  216. package/src/interaction_client/StandardInteractionClient.ts +0 -8
  217. package/src/packageMetadata.ts +1 -1
  218. package/src/request/AuthorizationUrlRequest.ts +1 -1
  219. package/src/request/PopupRequest.ts +1 -1
  220. package/src/request/RedirectRequest.ts +1 -1
  221. package/src/request/SsoSilentRequest.ts +1 -1
  222. package/dist/cache/BrowserStorage.d.ts +0 -14
  223. package/dist/cache/BrowserStorage.d.ts.map +0 -1
  224. package/dist/cache/BrowserStorage.mjs +0 -46
  225. package/dist/cache/BrowserStorage.mjs.map +0 -1
  226. package/lib/types/cache/BrowserStorage.d.ts +0 -14
  227. package/lib/types/cache/BrowserStorage.d.ts.map +0 -1
  228. package/src/cache/BrowserStorage.ts +0 -52
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v3.28.1 2025-01-14 */
1
+ /*! @azure/msal-browser v4.0.1 2025-01-15 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -6,7 +6,7 @@
6
6
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.msal = {}));
7
7
  })(this, (function (exports) { 'use strict';
8
8
 
9
- /*! @azure/msal-common v14.16.0 2025-01-14 */
9
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
10
10
  /*
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.
12
12
  * Licensed under the MIT License.
@@ -113,12 +113,6 @@
113
113
  * Persistent cache keys MSAL which stay while user is logged in.
114
114
  */
115
115
  const PersistentCacheKeys = {
116
- ID_TOKEN: "idtoken",
117
- CLIENT_INFO: "client.info",
118
- ADAL_ID_TOKEN: "adal.idtoken",
119
- ERROR: "error",
120
- ERROR_DESC: "error.description",
121
- ACTIVE_ACCOUNT: "active-account",
122
116
  ACTIVE_ACCOUNT_FILTERS: "active-account-filters", // new cache entry for active_account for a more robust version for browser
123
117
  };
124
118
  /**
@@ -316,7 +310,7 @@
316
310
  // Token renewal offset default in seconds
317
311
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
318
312
 
319
- /*! @azure/msal-common v14.16.0 2025-01-14 */
313
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
320
314
  /*
321
315
  * Copyright (c) Microsoft Corporation. All rights reserved.
322
316
  * Licensed under the MIT License.
@@ -333,7 +327,7 @@
333
327
  unexpectedError: unexpectedError
334
328
  });
335
329
 
336
- /*! @azure/msal-common v14.16.0 2025-01-14 */
330
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
337
331
 
338
332
  /*
339
333
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -382,7 +376,7 @@
382
376
  : AuthErrorMessages[code]);
383
377
  }
384
378
 
385
- /*! @azure/msal-common v14.16.0 2025-01-14 */
379
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
386
380
  /*
387
381
  * Copyright (c) Microsoft Corporation. All rights reserved.
388
382
  * Licensed under the MIT License.
@@ -480,7 +474,7 @@
480
474
  userTimeoutReached: userTimeoutReached
481
475
  });
482
476
 
483
- /*! @azure/msal-common v14.16.0 2025-01-14 */
477
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
484
478
 
485
479
  /*
486
480
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -732,7 +726,7 @@
732
726
  return new ClientAuthError(errorCode, additionalMessage);
733
727
  }
734
728
 
735
- /*! @azure/msal-common v14.16.0 2025-01-14 */
729
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
736
730
 
737
731
  /*
738
732
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -771,7 +765,7 @@
771
765
  },
772
766
  };
773
767
 
774
- /*! @azure/msal-common v14.16.0 2025-01-14 */
768
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
775
769
 
776
770
  /*
777
771
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -962,12 +956,12 @@
962
956
  }
963
957
  }
964
958
 
965
- /*! @azure/msal-common v14.16.0 2025-01-14 */
959
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
966
960
  /* eslint-disable header/header */
967
961
  const name$1 = "@azure/msal-common";
968
- const version$1 = "14.16.0";
962
+ const version$1 = "15.0.1";
969
963
 
970
- /*! @azure/msal-common v14.16.0 2025-01-14 */
964
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
971
965
  /*
972
966
  * Copyright (c) Microsoft Corporation. All rights reserved.
973
967
  * Licensed under the MIT License.
@@ -987,7 +981,7 @@
987
981
  AzureUsGovernment: "https://login.microsoftonline.us",
988
982
  };
989
983
 
990
- /*! @azure/msal-common v14.16.0 2025-01-14 */
984
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
991
985
 
992
986
  /*
993
987
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1048,7 +1042,7 @@
1048
1042
  }
1049
1043
  }
1050
1044
 
1051
- /*! @azure/msal-common v14.16.0 2025-01-14 */
1045
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
1052
1046
  /*
1053
1047
  * Copyright (c) Microsoft Corporation. All rights reserved.
1054
1048
  * Licensed under the MIT License.
@@ -1085,7 +1079,7 @@
1085
1079
  return cachedAtSec > nowSeconds();
1086
1080
  }
1087
1081
 
1088
- /*! @azure/msal-common v14.16.0 2025-01-14 */
1082
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
1089
1083
 
1090
1084
  /*
1091
1085
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1412,7 +1406,7 @@
1412
1406
  return metadata.expiresAt <= nowSeconds();
1413
1407
  }
1414
1408
 
1415
- /*! @azure/msal-common v14.16.0 2025-01-14 */
1409
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
1416
1410
  /*
1417
1411
  * Copyright (c) Microsoft Corporation. All rights reserved.
1418
1412
  * Licensed under the MIT License.
@@ -1437,14 +1431,14 @@
1437
1431
  const missingNonceAuthenticationHeader = "missing_nonce_authentication_header";
1438
1432
  const invalidAuthenticationHeader = "invalid_authentication_header";
1439
1433
  const cannotSetOIDCOptions = "cannot_set_OIDCOptions";
1440
- const cannotAllowNativeBroker = "cannot_allow_native_broker";
1434
+ const cannotAllowPlatformBroker = "cannot_allow_platform_broker";
1441
1435
  const authorityMismatch = "authority_mismatch";
1442
1436
 
1443
1437
  var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1444
1438
  __proto__: null,
1445
1439
  authorityMismatch: authorityMismatch,
1446
1440
  authorityUriInsecure: authorityUriInsecure,
1447
- cannotAllowNativeBroker: cannotAllowNativeBroker,
1441
+ cannotAllowPlatformBroker: cannotAllowPlatformBroker,
1448
1442
  cannotSetOIDCOptions: cannotSetOIDCOptions,
1449
1443
  claimsRequestParsingError: claimsRequestParsingError,
1450
1444
  emptyInputScopesError: emptyInputScopesError,
@@ -1466,7 +1460,7 @@
1466
1460
  urlParseError: urlParseError
1467
1461
  });
1468
1462
 
1469
- /*! @azure/msal-common v14.16.0 2025-01-14 */
1463
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
1470
1464
 
1471
1465
  /*
1472
1466
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1493,7 +1487,7 @@
1493
1487
  [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.",
1494
1488
  [invalidAuthenticationHeader]: "Invalid authentication header provided",
1495
1489
  [cannotSetOIDCOptions]: "Cannot set OIDCOptions parameter. Please change the protocol mode to OIDC or use a non-Microsoft authority.",
1496
- [cannotAllowNativeBroker]: "Cannot set allowNativeBroker parameter to true when not in AAD protocol mode.",
1490
+ [cannotAllowPlatformBroker]: "Cannot set allowPlatformBroker parameter to true when not in AAD protocol mode.",
1497
1491
  [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.",
1498
1492
  };
1499
1493
  /**
@@ -1581,9 +1575,9 @@
1581
1575
  code: cannotSetOIDCOptions,
1582
1576
  desc: ClientConfigurationErrorMessages[cannotSetOIDCOptions],
1583
1577
  },
1584
- cannotAllowNativeBroker: {
1585
- code: cannotAllowNativeBroker,
1586
- desc: ClientConfigurationErrorMessages[cannotAllowNativeBroker],
1578
+ cannotAllowPlatformBroker: {
1579
+ code: cannotAllowPlatformBroker,
1580
+ desc: ClientConfigurationErrorMessages[cannotAllowPlatformBroker],
1587
1581
  },
1588
1582
  authorityMismatch: {
1589
1583
  code: authorityMismatch,
@@ -1604,7 +1598,7 @@
1604
1598
  return new ClientConfigurationError(errorCode);
1605
1599
  }
1606
1600
 
1607
- /*! @azure/msal-common v14.16.0 2025-01-14 */
1601
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
1608
1602
  /*
1609
1603
  * Copyright (c) Microsoft Corporation. All rights reserved.
1610
1604
  * Licensed under the MIT License.
@@ -1701,7 +1695,7 @@
1701
1695
  }
1702
1696
  }
1703
1697
 
1704
- /*! @azure/msal-common v14.16.0 2025-01-14 */
1698
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
1705
1699
 
1706
1700
  /*
1707
1701
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1901,7 +1895,7 @@
1901
1895
  }
1902
1896
  }
1903
1897
 
1904
- /*! @azure/msal-common v14.16.0 2025-01-14 */
1898
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
1905
1899
 
1906
1900
  /*
1907
1901
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1941,7 +1935,7 @@
1941
1935
  };
1942
1936
  }
1943
1937
 
1944
- /*! @azure/msal-common v14.16.0 2025-01-14 */
1938
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
1945
1939
  /*
1946
1940
  * Copyright (c) Microsoft Corporation. All rights reserved.
1947
1941
  * Licensed under the MIT License.
@@ -2020,7 +2014,7 @@
2020
2014
  return updatedAccountInfo;
2021
2015
  }
2022
2016
 
2023
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2017
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2024
2018
  /*
2025
2019
  * Copyright (c) Microsoft Corporation. All rights reserved.
2026
2020
  * Licensed under the MIT License.
@@ -2035,7 +2029,7 @@
2035
2029
  Ciam: 3,
2036
2030
  };
2037
2031
 
2038
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2032
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2039
2033
  /*
2040
2034
  * Copyright (c) Microsoft Corporation. All rights reserved.
2041
2035
  * Licensed under the MIT License.
@@ -2057,7 +2051,7 @@
2057
2051
  return null;
2058
2052
  }
2059
2053
 
2060
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2054
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2061
2055
  /*
2062
2056
  * Copyright (c) Microsoft Corporation. All rights reserved.
2063
2057
  * Licensed under the MIT License.
@@ -2070,7 +2064,7 @@
2070
2064
  OIDC: "OIDC",
2071
2065
  };
2072
2066
 
2073
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2067
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2074
2068
 
2075
2069
  /*
2076
2070
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2313,7 +2307,7 @@
2313
2307
  }
2314
2308
  }
2315
2309
 
2316
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2310
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2317
2311
 
2318
2312
  /*
2319
2313
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2360,7 +2354,7 @@
2360
2354
  return null;
2361
2355
  }
2362
2356
 
2363
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2357
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2364
2358
 
2365
2359
  /*
2366
2360
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2524,7 +2518,7 @@
2524
2518
  }
2525
2519
  }
2526
2520
 
2527
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2521
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2528
2522
 
2529
2523
  /*
2530
2524
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2664,7 +2658,7 @@
2664
2658
  return null;
2665
2659
  }
2666
2660
 
2667
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2661
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2668
2662
  /*
2669
2663
  * Copyright (c) Microsoft Corporation. All rights reserved.
2670
2664
  * Licensed under the MIT License.
@@ -2672,7 +2666,7 @@
2672
2666
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2673
2667
  const cacheUnknownErrorCode = "cache_error_unknown";
2674
2668
 
2675
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2669
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2676
2670
 
2677
2671
  /*
2678
2672
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2699,7 +2693,7 @@
2699
2693
  }
2700
2694
  }
2701
2695
 
2702
- /*! @azure/msal-common v14.16.0 2025-01-14 */
2696
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
2703
2697
 
2704
2698
  /*
2705
2699
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2864,24 +2858,24 @@
2864
2858
  * @param storeInCache {?StoreInCache}
2865
2859
  * @param correlationId {?string} correlation id
2866
2860
  */
2867
- async saveCacheRecord(cacheRecord, storeInCache, correlationId) {
2861
+ async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
2868
2862
  if (!cacheRecord) {
2869
2863
  throw createClientAuthError(invalidCacheRecord);
2870
2864
  }
2871
2865
  try {
2872
2866
  if (!!cacheRecord.account) {
2873
- this.setAccount(cacheRecord.account);
2867
+ await this.setAccount(cacheRecord.account, correlationId);
2874
2868
  }
2875
2869
  if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
2876
- this.setIdTokenCredential(cacheRecord.idToken);
2870
+ await this.setIdTokenCredential(cacheRecord.idToken, correlationId);
2877
2871
  }
2878
2872
  if (!!cacheRecord.accessToken &&
2879
2873
  storeInCache?.accessToken !== false) {
2880
- await this.saveAccessToken(cacheRecord.accessToken);
2874
+ await this.saveAccessToken(cacheRecord.accessToken, correlationId);
2881
2875
  }
2882
2876
  if (!!cacheRecord.refreshToken &&
2883
2877
  storeInCache?.refreshToken !== false) {
2884
- this.setRefreshTokenCredential(cacheRecord.refreshToken);
2878
+ await this.setRefreshTokenCredential(cacheRecord.refreshToken, correlationId);
2885
2879
  }
2886
2880
  if (!!cacheRecord.appMetadata) {
2887
2881
  this.setAppMetadata(cacheRecord.appMetadata);
@@ -2911,7 +2905,7 @@
2911
2905
  * saves access token credential
2912
2906
  * @param credential
2913
2907
  */
2914
- async saveAccessToken(credential) {
2908
+ async saveAccessToken(credential, correlationId) {
2915
2909
  const accessTokenFilter = {
2916
2910
  clientId: credential.clientId,
2917
2911
  credentialType: credential.credentialType,
@@ -2938,7 +2932,7 @@
2938
2932
  }
2939
2933
  });
2940
2934
  await Promise.all(removedAccessTokens);
2941
- this.setAccessTokenCredential(credential);
2935
+ await this.setAccessTokenCredential(credential, correlationId);
2942
2936
  }
2943
2937
  /**
2944
2938
  * Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
@@ -3224,61 +3218,6 @@
3224
3218
  });
3225
3219
  await Promise.all(removedCredentials);
3226
3220
  }
3227
- /**
3228
- * Migrates a single-tenant account and all it's associated alternate cross-tenant account objects in the
3229
- * cache into a condensed multi-tenant account object with tenant profiles.
3230
- * @param accountKey
3231
- * @param accountEntity
3232
- * @param logger
3233
- * @returns
3234
- */
3235
- updateOutdatedCachedAccount(accountKey, accountEntity, logger) {
3236
- // Only update if account entity is defined and has no tenantProfiles object (is outdated)
3237
- if (accountEntity && accountEntity.isSingleTenant()) {
3238
- this.commonLogger?.verbose("updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity");
3239
- // Get keys of all accounts belonging to user
3240
- const matchingAccountKeys = this.getAccountKeys().filter((key) => {
3241
- return key.startsWith(accountEntity.homeAccountId);
3242
- });
3243
- // Get all account entities belonging to user
3244
- const accountsToMerge = [];
3245
- matchingAccountKeys.forEach((key) => {
3246
- const account = this.getCachedAccountEntity(key);
3247
- if (account) {
3248
- accountsToMerge.push(account);
3249
- }
3250
- });
3251
- // Set base account to home account if available, any account if not
3252
- const baseAccount = accountsToMerge.find((account) => {
3253
- return tenantIdMatchesHomeTenant(account.realm, account.homeAccountId);
3254
- }) || accountsToMerge[0];
3255
- // Populate tenant profiles built from each account entity belonging to the user
3256
- baseAccount.tenantProfiles = accountsToMerge.map((account) => {
3257
- return {
3258
- tenantId: account.realm,
3259
- localAccountId: account.localAccountId,
3260
- name: account.name,
3261
- isHomeTenant: tenantIdMatchesHomeTenant(account.realm, account.homeAccountId),
3262
- };
3263
- });
3264
- const updatedAccount = CacheManager.toObject(new AccountEntity(), {
3265
- ...baseAccount,
3266
- });
3267
- const newAccountKey = updatedAccount.generateAccountKey();
3268
- // Clear cache of legacy account objects that have been collpsed into tenant profiles
3269
- matchingAccountKeys.forEach((key) => {
3270
- if (key !== newAccountKey) {
3271
- this.removeOutdatedAccount(accountKey);
3272
- }
3273
- });
3274
- // Cache updated account object
3275
- this.setAccount(updatedAccount);
3276
- logger?.verbose("Updated an outdated account entity in the cache");
3277
- return updatedAccount;
3278
- }
3279
- // No update is necessary
3280
- return accountEntity;
3281
- }
3282
3221
  /**
3283
3222
  * returns a boolean if the given credential is removed
3284
3223
  * @param credential
@@ -3874,28 +3813,25 @@
3874
3813
  }
3875
3814
  /** @internal */
3876
3815
  class DefaultStorageClass extends CacheManager {
3877
- setAccount() {
3816
+ async setAccount() {
3878
3817
  throw createClientAuthError(methodNotImplemented);
3879
3818
  }
3880
3819
  getAccount() {
3881
3820
  throw createClientAuthError(methodNotImplemented);
3882
3821
  }
3883
- getCachedAccountEntity() {
3884
- throw createClientAuthError(methodNotImplemented);
3885
- }
3886
- setIdTokenCredential() {
3822
+ async setIdTokenCredential() {
3887
3823
  throw createClientAuthError(methodNotImplemented);
3888
3824
  }
3889
3825
  getIdTokenCredential() {
3890
3826
  throw createClientAuthError(methodNotImplemented);
3891
3827
  }
3892
- setAccessTokenCredential() {
3828
+ async setAccessTokenCredential() {
3893
3829
  throw createClientAuthError(methodNotImplemented);
3894
3830
  }
3895
3831
  getAccessTokenCredential() {
3896
3832
  throw createClientAuthError(methodNotImplemented);
3897
3833
  }
3898
- setRefreshTokenCredential() {
3834
+ async setRefreshTokenCredential() {
3899
3835
  throw createClientAuthError(methodNotImplemented);
3900
3836
  }
3901
3837
  getRefreshTokenCredential() {
@@ -3940,15 +3876,9 @@
3940
3876
  getTokenKeys() {
3941
3877
  throw createClientAuthError(methodNotImplemented);
3942
3878
  }
3943
- updateCredentialCacheKey() {
3944
- throw createClientAuthError(methodNotImplemented);
3945
- }
3946
- removeOutdatedAccount() {
3947
- throw createClientAuthError(methodNotImplemented);
3948
- }
3949
3879
  }
3950
3880
 
3951
- /*! @azure/msal-common v14.16.0 2025-01-14 */
3881
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
3952
3882
 
3953
3883
  /*
3954
3884
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4047,7 +3977,7 @@
4047
3977
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4048
3978
  }
4049
3979
 
4050
- /*! @azure/msal-common v14.16.0 2025-01-14 */
3980
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
4051
3981
  /*
4052
3982
  * Copyright (c) Microsoft Corporation. All rights reserved.
4053
3983
  * Licensed under the MIT License.
@@ -4057,7 +3987,7 @@
4057
3987
  UPN: "UPN",
4058
3988
  };
4059
3989
 
4060
- /*! @azure/msal-common v14.16.0 2025-01-14 */
3990
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
4061
3991
  /*
4062
3992
  * Copyright (c) Microsoft Corporation. All rights reserved.
4063
3993
  * Licensed under the MIT License.
@@ -4107,7 +4037,7 @@
4107
4037
  const BROKER_CLIENT_ID = "brk_client_id";
4108
4038
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4109
4039
 
4110
- /*! @azure/msal-common v14.16.0 2025-01-14 */
4040
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
4111
4041
 
4112
4042
  /*
4113
4043
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4174,7 +4104,7 @@
4174
4104
  }
4175
4105
  }
4176
4106
 
4177
- /*! @azure/msal-common v14.16.0 2025-01-14 */
4107
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
4178
4108
 
4179
4109
  /*
4180
4110
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4582,7 +4512,7 @@
4582
4512
  }
4583
4513
  }
4584
4514
 
4585
- /*! @azure/msal-common v14.16.0 2025-01-14 */
4515
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
4586
4516
  /*
4587
4517
  * Copyright (c) Microsoft Corporation. All rights reserved.
4588
4518
  * Licensed under the MIT License.
@@ -4594,7 +4524,7 @@
4594
4524
  response.hasOwnProperty("jwks_uri"));
4595
4525
  }
4596
4526
 
4597
- /*! @azure/msal-common v14.16.0 2025-01-14 */
4527
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
4598
4528
  /*
4599
4529
  * Copyright (c) Microsoft Corporation. All rights reserved.
4600
4530
  * Licensed under the MIT License.
@@ -4604,7 +4534,7 @@
4604
4534
  response.hasOwnProperty("metadata"));
4605
4535
  }
4606
4536
 
4607
- /*! @azure/msal-common v14.16.0 2025-01-14 */
4537
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
4608
4538
  /*
4609
4539
  * Copyright (c) Microsoft Corporation. All rights reserved.
4610
4540
  * Licensed under the MIT License.
@@ -4614,7 +4544,7 @@
4614
4544
  response.hasOwnProperty("error_description"));
4615
4545
  }
4616
4546
 
4617
- /*! @azure/msal-common v14.16.0 2025-01-14 */
4547
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
4618
4548
  /*
4619
4549
  * Copyright (c) Microsoft Corporation. All rights reserved.
4620
4550
  * Licensed under the MIT License.
@@ -4772,6 +4702,7 @@
4772
4702
  */
4773
4703
  InitializeSilentRequest: "initializeSilentRequest",
4774
4704
  InitializeClientApplication: "initializeClientApplication",
4705
+ InitializeCache: "initializeCache",
4775
4706
  /**
4776
4707
  * Helper function in SilentIframeClient class (msal-browser).
4777
4708
  */
@@ -4849,6 +4780,8 @@
4849
4780
  */
4850
4781
  ClearTokensAndKeysWithClaims: "clearTokensAndKeysWithClaims",
4851
4782
  CacheManagerGetRefreshToken: "cacheManagerGetRefreshToken",
4783
+ ImportExistingCache: "importExistingCache",
4784
+ SetUserData: "setUserData",
4852
4785
  /**
4853
4786
  * Crypto Operations
4854
4787
  */
@@ -4857,6 +4790,12 @@
4857
4790
  GenerateCodeChallengeFromVerifier: "generateCodeChallengeFromVerifier",
4858
4791
  Sha256Digest: "sha256Digest",
4859
4792
  GetRandomValues: "getRandomValues",
4793
+ GenerateHKDF: "generateHKDF",
4794
+ GenerateBaseKey: "generateBaseKey",
4795
+ Base64Decode: "base64Decode",
4796
+ UrlEncodeArr: "urlEncodeArr",
4797
+ Encrypt: "encrypt",
4798
+ Decrypt: "decrypt",
4860
4799
  };
4861
4800
  const PerformanceEventAbbreviations = new Map([
4862
4801
  [PerformanceEvents.AcquireTokenByCode, "ATByCode"],
@@ -4941,6 +4880,9 @@
4941
4880
  PerformanceEvents.InitializeClientApplication,
4942
4881
  "InitClientApplication",
4943
4882
  ],
4883
+ [PerformanceEvents.InitializeCache, "InitCache"],
4884
+ [PerformanceEvents.ImportExistingCache, "importCache"],
4885
+ [PerformanceEvents.SetUserData, "setUserData"],
4944
4886
  [PerformanceEvents.SilentIframeClientTokenHelper, "SIClientTHelper"],
4945
4887
  [
4946
4888
  PerformanceEvents.SilentHandlerInitiateAuthRequest,
@@ -5074,6 +5016,12 @@
5074
5016
  ],
5075
5017
  [PerformanceEvents.Sha256Digest, "Sha256Digest"],
5076
5018
  [PerformanceEvents.GetRandomValues, "GetRandomValues"],
5019
+ [PerformanceEvents.GenerateHKDF, "genHKDF"],
5020
+ [PerformanceEvents.GenerateBaseKey, "genBaseKey"],
5021
+ [PerformanceEvents.Base64Decode, "b64Decode"],
5022
+ [PerformanceEvents.UrlEncodeArr, "urlEncArr"],
5023
+ [PerformanceEvents.Encrypt, "encrypt"],
5024
+ [PerformanceEvents.Decrypt, "decrypt"],
5077
5025
  ]);
5078
5026
  /**
5079
5027
  * State of the performance event.
@@ -5099,9 +5047,11 @@
5099
5047
  "multiMatchedAT",
5100
5048
  "multiMatchedID",
5101
5049
  "multiMatchedRT",
5050
+ "unencryptedCacheCount",
5051
+ "encryptedCacheExpiredCount",
5102
5052
  ]);
5103
5053
 
5104
- /*! @azure/msal-common v14.16.0 2025-01-14 */
5054
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
5105
5055
  /*
5106
5056
  * Copyright (c) Microsoft Corporation. All rights reserved.
5107
5057
  * Licensed under the MIT License.
@@ -5197,7 +5147,7 @@
5197
5147
  };
5198
5148
  };
5199
5149
 
5200
- /*! @azure/msal-common v14.16.0 2025-01-14 */
5150
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
5201
5151
 
5202
5152
  /*
5203
5153
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5306,7 +5256,7 @@
5306
5256
  },
5307
5257
  };
5308
5258
 
5309
- /*! @azure/msal-common v14.16.0 2025-01-14 */
5259
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
5310
5260
 
5311
5261
  /*
5312
5262
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6145,7 +6095,7 @@
6145
6095
  };
6146
6096
  }
6147
6097
 
6148
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6098
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6149
6099
 
6150
6100
  /*
6151
6101
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6176,7 +6126,7 @@
6176
6126
  }
6177
6127
  }
6178
6128
 
6179
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6129
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6180
6130
 
6181
6131
  /*
6182
6132
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6195,7 +6145,7 @@
6195
6145
  }
6196
6146
  }
6197
6147
 
6198
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6148
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6199
6149
 
6200
6150
  /*
6201
6151
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6293,7 +6243,7 @@
6293
6243
  }
6294
6244
  }
6295
6245
 
6296
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6246
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6297
6247
 
6298
6248
  /*
6299
6249
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6323,7 +6273,7 @@
6323
6273
  return new NetworkError(error, httpStatus, responseHeaders);
6324
6274
  }
6325
6275
 
6326
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6276
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6327
6277
 
6328
6278
  /*
6329
6279
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6473,7 +6423,7 @@
6473
6423
  }
6474
6424
  }
6475
6425
 
6476
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6426
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6477
6427
  /*
6478
6428
  * Copyright (c) Microsoft Corporation. All rights reserved.
6479
6429
  * Licensed under the MIT License.
@@ -6499,7 +6449,7 @@
6499
6449
  refreshTokenExpired: refreshTokenExpired
6500
6450
  });
6501
6451
 
6502
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6452
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6503
6453
 
6504
6454
  /*
6505
6455
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6587,7 +6537,7 @@
6587
6537
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6588
6538
  }
6589
6539
 
6590
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6540
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6591
6541
 
6592
6542
  /*
6593
6543
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6659,7 +6609,7 @@
6659
6609
  }
6660
6610
  }
6661
6611
 
6662
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6612
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6663
6613
 
6664
6614
  /*
6665
6615
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6743,7 +6693,7 @@
6743
6693
  }
6744
6694
  }
6745
6695
 
6746
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6696
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6747
6697
  /*
6748
6698
  * Copyright (c) Microsoft Corporation. All rights reserved.
6749
6699
  * Licensed under the MIT License.
@@ -6770,7 +6720,7 @@
6770
6720
  }
6771
6721
  }
6772
6722
 
6773
- /*! @azure/msal-common v14.16.0 2025-01-14 */
6723
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
6774
6724
 
6775
6725
  /*
6776
6726
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6930,13 +6880,13 @@
6930
6880
  !forceCacheRefreshTokenResponse &&
6931
6881
  cacheRecord.account) {
6932
6882
  const key = cacheRecord.account.generateAccountKey();
6933
- const account = this.cacheStorage.getAccount(key, this.logger);
6883
+ const account = this.cacheStorage.getAccount(key);
6934
6884
  if (!account) {
6935
6885
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
6936
6886
  return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
6937
6887
  }
6938
6888
  }
6939
- await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache, request.correlationId);
6889
+ await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, request.storeInCache);
6940
6890
  }
6941
6891
  finally {
6942
6892
  if (this.persistencePlugin &&
@@ -7122,7 +7072,7 @@
7122
7072
  });
7123
7073
  let cachedAccount = null;
7124
7074
  if (baseAccountKey) {
7125
- cachedAccount = cacheStorage.getAccount(baseAccountKey, logger);
7075
+ cachedAccount = cacheStorage.getAccount(baseAccountKey);
7126
7076
  }
7127
7077
  const baseAccount = cachedAccount ||
7128
7078
  AccountEntity.createAccount({
@@ -7147,7 +7097,7 @@
7147
7097
  return baseAccount;
7148
7098
  }
7149
7099
 
7150
- /*! @azure/msal-common v14.16.0 2025-01-14 */
7100
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
7151
7101
  /*
7152
7102
  * Copyright (c) Microsoft Corporation. All rights reserved.
7153
7103
  * Licensed under the MIT License.
@@ -7165,7 +7115,7 @@
7165
7115
  }
7166
7116
  }
7167
7117
 
7168
- /*! @azure/msal-common v14.16.0 2025-01-14 */
7118
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
7169
7119
 
7170
7120
  /*
7171
7121
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7539,7 +7489,7 @@
7539
7489
  });
7540
7490
  }
7541
7491
  this.addExtraQueryParams(request, parameterBuilder);
7542
- if (request.nativeBroker) {
7492
+ if (request.platformBroker) {
7543
7493
  // signal ests that this is a WAM call
7544
7494
  parameterBuilder.addNativeBroker();
7545
7495
  // pass the req_cnf for POP
@@ -7607,7 +7557,7 @@
7607
7557
  }
7608
7558
  }
7609
7559
 
7610
- /*! @azure/msal-common v14.16.0 2025-01-14 */
7560
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
7611
7561
 
7612
7562
  /*
7613
7563
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7827,7 +7777,7 @@
7827
7777
  }
7828
7778
  }
7829
7779
 
7830
- /*! @azure/msal-common v14.16.0 2025-01-14 */
7780
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
7831
7781
 
7832
7782
  /*
7833
7783
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7963,7 +7913,7 @@
7963
7913
  }
7964
7914
  }
7965
7915
 
7966
- /*! @azure/msal-common v14.16.0 2025-01-14 */
7916
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
7967
7917
 
7968
7918
  /*
7969
7919
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7978,7 +7928,7 @@
7978
7928
  },
7979
7929
  };
7980
7930
 
7981
- /*! @azure/msal-common v14.16.0 2025-01-14 */
7931
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
7982
7932
 
7983
7933
  /*
7984
7934
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8036,7 +7986,7 @@
8036
7986
  }
8037
7987
  }
8038
7988
 
8039
- /*! @azure/msal-common v14.16.0 2025-01-14 */
7989
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
8040
7990
 
8041
7991
  /*
8042
7992
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8299,7 +8249,7 @@
8299
8249
  }
8300
8250
  }
8301
8251
 
8302
- /*! @azure/msal-common v14.16.0 2025-01-14 */
8252
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
8303
8253
  /*
8304
8254
  * Copyright (c) Microsoft Corporation. All rights reserved.
8305
8255
  * Licensed under the MIT License.
@@ -8307,7 +8257,7 @@
8307
8257
  const missingKidError = "missing_kid_error";
8308
8258
  const missingAlgError = "missing_alg_error";
8309
8259
 
8310
- /*! @azure/msal-common v14.16.0 2025-01-14 */
8260
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
8311
8261
 
8312
8262
  /*
8313
8263
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8332,7 +8282,7 @@
8332
8282
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
8333
8283
  }
8334
8284
 
8335
- /*! @azure/msal-common v14.16.0 2025-01-14 */
8285
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
8336
8286
 
8337
8287
  /*
8338
8288
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8372,7 +8322,7 @@
8372
8322
  }
8373
8323
  }
8374
8324
 
8375
- /*! @azure/msal-common v14.16.0 2025-01-14 */
8325
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
8376
8326
 
8377
8327
  /*
8378
8328
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8451,7 +8401,7 @@
8451
8401
  }
8452
8402
  }
8453
8403
 
8454
- /*! @azure/msal-common v14.16.0 2025-01-14 */
8404
+ /*! @azure/msal-common v15.0.1 2025-01-15 */
8455
8405
 
8456
8406
  /*
8457
8407
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9688,6 +9638,43 @@
9688
9638
  return btoa(binString);
9689
9639
  }
9690
9640
 
9641
+ /*
9642
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9643
+ * Licensed under the MIT License.
9644
+ */
9645
+ /**
9646
+ * Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
9647
+ * https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
9648
+ */
9649
+ /**
9650
+ * Returns a URL-safe plaintext decoded string from b64 encoded input.
9651
+ * @param input
9652
+ */
9653
+ function base64Decode(input) {
9654
+ return new TextDecoder().decode(base64DecToArr(input));
9655
+ }
9656
+ /**
9657
+ * Decodes base64 into Uint8Array
9658
+ * @param base64String
9659
+ */
9660
+ function base64DecToArr(base64String) {
9661
+ let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
9662
+ switch (encodedString.length % 4) {
9663
+ case 0:
9664
+ break;
9665
+ case 2:
9666
+ encodedString += "==";
9667
+ break;
9668
+ case 3:
9669
+ encodedString += "=";
9670
+ break;
9671
+ default:
9672
+ throw createBrowserAuthError(invalidBase64String);
9673
+ }
9674
+ const binString = atob(encodedString);
9675
+ return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
9676
+ }
9677
+
9691
9678
  /*
9692
9679
  * Copyright (c) Microsoft Corporation. All rights reserved.
9693
9680
  * Licensed under the MIT License.
@@ -9699,8 +9686,10 @@
9699
9686
  /**
9700
9687
  * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
9701
9688
  */
9702
- // RSA KeyGen Algorithm
9689
+ // Algorithms
9703
9690
  const PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
9691
+ const AES_GCM = "AES-GCM";
9692
+ const HKDF = "HKDF";
9704
9693
  // SHA-256 hashing algorithm
9705
9694
  const S256_HASH_ALG = "SHA-256";
9706
9695
  // MOD length for PoP tokens
@@ -9711,6 +9700,13 @@
9711
9700
  const UUID_CHARS = "0123456789abcdef";
9712
9701
  // Array to store UINT32 random value
9713
9702
  const UINT32_ARR = new Uint32Array(1);
9703
+ // Key Format
9704
+ const RAW = "raw";
9705
+ // Key Usages
9706
+ const ENCRYPT = "encrypt";
9707
+ const DECRYPT = "decrypt";
9708
+ const DERIVE_KEY = "deriveKey";
9709
+ // Suberror
9714
9710
  const SUBTLE_SUBERROR = "crypto_subtle_undefined";
9715
9711
  const keygenAlgorithmOptions = {
9716
9712
  name: PKCS1_V15_KEYGEN_ALG,
@@ -9833,6 +9829,76 @@
9833
9829
  async function sign(key, data) {
9834
9830
  return window.crypto.subtle.sign(keygenAlgorithmOptions, key, data);
9835
9831
  }
9832
+ /**
9833
+ * Generates symmetric base encryption key. This may be stored as all encryption/decryption keys will be derived from this one.
9834
+ */
9835
+ async function generateBaseKey() {
9836
+ const key = await window.crypto.subtle.generateKey({
9837
+ name: AES_GCM,
9838
+ length: 256,
9839
+ }, true, [ENCRYPT, DECRYPT]);
9840
+ return window.crypto.subtle.exportKey(RAW, key);
9841
+ }
9842
+ /**
9843
+ * Returns the raw key to be passed into the key derivation function
9844
+ * @param baseKey
9845
+ * @returns
9846
+ */
9847
+ async function generateHKDF(baseKey) {
9848
+ return window.crypto.subtle.importKey(RAW, baseKey, HKDF, false, [
9849
+ DERIVE_KEY,
9850
+ ]);
9851
+ }
9852
+ /**
9853
+ * Given a base key and a nonce generates a derived key to be used in encryption and decryption.
9854
+ * Note: every time we encrypt a new key is derived
9855
+ * @param baseKey
9856
+ * @param nonce
9857
+ * @returns
9858
+ */
9859
+ async function deriveKey(baseKey, nonce, context) {
9860
+ return window.crypto.subtle.deriveKey({
9861
+ name: HKDF,
9862
+ salt: nonce,
9863
+ hash: S256_HASH_ALG,
9864
+ info: new TextEncoder().encode(context),
9865
+ }, baseKey, { name: AES_GCM, length: 256 }, false, [ENCRYPT, DECRYPT]);
9866
+ }
9867
+ /**
9868
+ * Encrypt the given data given a base key. Returns encrypted data and a nonce that must be provided during decryption
9869
+ * @param key
9870
+ * @param rawData
9871
+ */
9872
+ async function encrypt(baseKey, rawData, context) {
9873
+ const encodedData = new TextEncoder().encode(rawData);
9874
+ // The nonce must never be reused with a given key.
9875
+ const nonce = window.crypto.getRandomValues(new Uint8Array(16));
9876
+ const derivedKey = await deriveKey(baseKey, nonce, context);
9877
+ const encryptedData = await window.crypto.subtle.encrypt({
9878
+ name: AES_GCM,
9879
+ iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
9880
+ }, derivedKey, encodedData);
9881
+ return {
9882
+ data: urlEncodeArr(new Uint8Array(encryptedData)),
9883
+ nonce: urlEncodeArr(nonce),
9884
+ };
9885
+ }
9886
+ /**
9887
+ * Decrypt data with the given key and nonce
9888
+ * @param key
9889
+ * @param nonce
9890
+ * @param encryptedData
9891
+ * @returns
9892
+ */
9893
+ async function decrypt(baseKey, nonce, context, encryptedData) {
9894
+ const encodedData = base64DecToArr(encryptedData);
9895
+ const derivedKey = await deriveKey(baseKey, base64DecToArr(nonce), context);
9896
+ const decryptedData = await window.crypto.subtle.decrypt({
9897
+ name: AES_GCM,
9898
+ iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
9899
+ }, derivedKey, encodedData);
9900
+ return new TextDecoder().decode(decryptedData);
9901
+ }
9836
9902
  /**
9837
9903
  * Returns the SHA-256 hash of an input string
9838
9904
  * @param plainText
@@ -10325,7 +10391,7 @@
10325
10391
  redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
10326
10392
  asyncPopups: false,
10327
10393
  allowRedirectInIframe: false,
10328
- allowNativeBroker: false,
10394
+ allowPlatformBroker: false,
10329
10395
  nativeBrokerHandshakeTimeout: userInputSystem?.nativeBrokerHandshakeTimeout ||
10330
10396
  DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
10331
10397
  pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS,
@@ -10348,11 +10414,11 @@
10348
10414
  const logger = new Logger(providedSystemOptions.loggerOptions);
10349
10415
  logger.warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions)));
10350
10416
  }
10351
- // Throw an error if user has set allowNativeBroker to true without being in AAD protocol mode
10417
+ // Throw an error if user has set allowPlatformBroker to true without being in AAD protocol mode
10352
10418
  if (userInputAuth?.protocolMode &&
10353
10419
  userInputAuth.protocolMode !== ProtocolMode.AAD &&
10354
- providedSystemOptions?.allowNativeBroker) {
10355
- throw createClientConfigurationError(cannotAllowNativeBroker);
10420
+ providedSystemOptions?.allowPlatformBroker) {
10421
+ throw createClientConfigurationError(cannotAllowPlatformBroker);
10356
10422
  }
10357
10423
  const overlayedConfig = {
10358
10424
  auth: {
@@ -10372,7 +10438,7 @@
10372
10438
 
10373
10439
  /* eslint-disable header/header */
10374
10440
  const name = "@azure/msal-browser";
10375
- const version = "3.28.1";
10441
+ const version = "4.0.1";
10376
10442
 
10377
10443
  /*
10378
10444
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10748,43 +10814,6 @@
10748
10814
  */
10749
10815
  StandardOperatingContext.ID = "StandardOperatingContext";
10750
10816
 
10751
- /*
10752
- * Copyright (c) Microsoft Corporation. All rights reserved.
10753
- * Licensed under the MIT License.
10754
- */
10755
- /**
10756
- * Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
10757
- * https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
10758
- */
10759
- /**
10760
- * Returns a URL-safe plaintext decoded string from b64 encoded input.
10761
- * @param input
10762
- */
10763
- function base64Decode(input) {
10764
- return new TextDecoder().decode(base64DecToArr(input));
10765
- }
10766
- /**
10767
- * Decodes base64 into Uint8Array
10768
- * @param base64String
10769
- */
10770
- function base64DecToArr(base64String) {
10771
- let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
10772
- switch (encodedString.length % 4) {
10773
- case 0:
10774
- break;
10775
- case 2:
10776
- encodedString += "==";
10777
- break;
10778
- case 3:
10779
- encodedString += "=";
10780
- break;
10781
- default:
10782
- throw createBrowserAuthError(invalidBase64String);
10783
- }
10784
- const binString = atob(encodedString);
10785
- return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
10786
- }
10787
-
10788
10817
  /*
10789
10818
  * Copyright (c) Microsoft Corporation. All rights reserved.
10790
10819
  * Licensed under the MIT License.
@@ -10994,12 +11023,21 @@
10994
11023
  constructor() {
10995
11024
  this.cache = new Map();
10996
11025
  }
11026
+ async initialize() {
11027
+ // Memory storage does not require initialization
11028
+ }
10997
11029
  getItem(key) {
10998
11030
  return this.cache.get(key) || null;
10999
11031
  }
11032
+ getUserData(key) {
11033
+ return this.getItem(key);
11034
+ }
11000
11035
  setItem(key, value) {
11001
11036
  this.cache.set(key, value);
11002
11037
  }
11038
+ async setUserData(key, value) {
11039
+ this.setItem(key, value);
11040
+ }
11003
11041
  removeItem(key) {
11004
11042
  this.cache.delete(key);
11005
11043
  }
@@ -11331,19 +11369,189 @@
11331
11369
  * Copyright (c) Microsoft Corporation. All rights reserved.
11332
11370
  * Licensed under the MIT License.
11333
11371
  */
11372
+ // Cookie life calculation (hours * minutes * seconds * ms)
11373
+ const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11374
+ class CookieStorage {
11375
+ initialize() {
11376
+ return Promise.resolve();
11377
+ }
11378
+ getItem(key) {
11379
+ const name = `${encodeURIComponent(key)}`;
11380
+ const cookieList = document.cookie.split(";");
11381
+ for (let i = 0; i < cookieList.length; i++) {
11382
+ const cookie = cookieList[i];
11383
+ const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
11384
+ const value = rest.join("=");
11385
+ if (key === name) {
11386
+ return value;
11387
+ }
11388
+ }
11389
+ return "";
11390
+ }
11391
+ getUserData() {
11392
+ throw createClientAuthError(methodNotImplemented);
11393
+ }
11394
+ setItem(key, value, cookieLifeDays, secure = true) {
11395
+ let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
11396
+ if (cookieLifeDays) {
11397
+ const expireTime = getCookieExpirationTime(cookieLifeDays);
11398
+ cookieStr += `expires=${expireTime};`;
11399
+ }
11400
+ if (secure) {
11401
+ cookieStr += "Secure;";
11402
+ }
11403
+ document.cookie = cookieStr;
11404
+ }
11405
+ async setUserData() {
11406
+ return Promise.reject(createClientAuthError(methodNotImplemented));
11407
+ }
11408
+ removeItem(key) {
11409
+ // Setting expiration to -1 removes it
11410
+ this.setItem(key, "", -1);
11411
+ }
11412
+ getKeys() {
11413
+ const cookieList = document.cookie.split(";");
11414
+ const keys = [];
11415
+ cookieList.forEach((cookie) => {
11416
+ const cookieParts = decodeURIComponent(cookie).trim().split("=");
11417
+ keys.push(cookieParts[0]);
11418
+ });
11419
+ return keys;
11420
+ }
11421
+ containsKey(key) {
11422
+ return this.getKeys().includes(key);
11423
+ }
11424
+ }
11425
+ /**
11426
+ * Get cookie expiration time
11427
+ * @param cookieLifeDays
11428
+ */
11429
+ function getCookieExpirationTime(cookieLifeDays) {
11430
+ const today = new Date();
11431
+ const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
11432
+ return expr.toUTCString();
11433
+ }
11434
+
11435
+ /*
11436
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11437
+ * Licensed under the MIT License.
11438
+ */
11439
+ /**
11440
+ * Returns a list of cache keys for all known accounts
11441
+ * @param storage
11442
+ * @returns
11443
+ */
11444
+ function getAccountKeys(storage) {
11445
+ const accountKeys = storage.getItem(StaticCacheKeys.ACCOUNT_KEYS);
11446
+ if (accountKeys) {
11447
+ return JSON.parse(accountKeys);
11448
+ }
11449
+ return [];
11450
+ }
11451
+ /**
11452
+ * Returns a list of cache keys for all known tokens
11453
+ * @param clientId
11454
+ * @param storage
11455
+ * @returns
11456
+ */
11457
+ function getTokenKeys(clientId, storage) {
11458
+ const item = storage.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${clientId}`);
11459
+ if (item) {
11460
+ const tokenKeys = JSON.parse(item);
11461
+ if (tokenKeys &&
11462
+ tokenKeys.hasOwnProperty("idToken") &&
11463
+ tokenKeys.hasOwnProperty("accessToken") &&
11464
+ tokenKeys.hasOwnProperty("refreshToken")) {
11465
+ return tokenKeys;
11466
+ }
11467
+ }
11468
+ return {
11469
+ idToken: [],
11470
+ accessToken: [],
11471
+ refreshToken: [],
11472
+ };
11473
+ }
11474
+
11475
+ /*
11476
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11477
+ * Licensed under the MIT License.
11478
+ */
11479
+ const ENCRYPTION_KEY = "msal.cache.encryption";
11334
11480
  class LocalStorage {
11335
- constructor() {
11481
+ constructor(clientId, logger, performanceClient) {
11336
11482
  if (!window.localStorage) {
11337
11483
  throw createBrowserConfigurationAuthError(storageNotSupported);
11338
11484
  }
11485
+ this.memoryStorage = new MemoryStorage();
11486
+ this.initialized = false;
11487
+ this.clientId = clientId;
11488
+ this.logger = logger;
11489
+ this.performanceClient = performanceClient;
11490
+ }
11491
+ async initialize(correlationId) {
11492
+ this.initialized = true;
11493
+ const cookies = new CookieStorage();
11494
+ const cookieString = cookies.getItem(ENCRYPTION_KEY);
11495
+ let parsedCookie = { key: "", id: "" };
11496
+ if (cookieString) {
11497
+ try {
11498
+ parsedCookie = JSON.parse(cookieString);
11499
+ }
11500
+ catch (e) { }
11501
+ }
11502
+ if (parsedCookie.key && parsedCookie.id) {
11503
+ // Encryption key already exists, import
11504
+ const baseKey = invoke(base64DecToArr, PerformanceEvents.Base64Decode, this.logger, this.performanceClient, correlationId)(parsedCookie.key);
11505
+ this.encryptionCookie = {
11506
+ id: parsedCookie.id,
11507
+ key: await invokeAsync(generateHKDF, PerformanceEvents.GenerateHKDF, this.logger, this.performanceClient, correlationId)(baseKey),
11508
+ };
11509
+ await invokeAsync(this.importExistingCache.bind(this), PerformanceEvents.ImportExistingCache, this.logger, this.performanceClient, correlationId)(correlationId);
11510
+ }
11511
+ else {
11512
+ // Encryption key doesn't exist or is invalid, generate a new one and clear existing cache
11513
+ this.clear();
11514
+ const id = createNewGuid();
11515
+ const baseKey = await invokeAsync(generateBaseKey, PerformanceEvents.GenerateBaseKey, this.logger, this.performanceClient, correlationId)();
11516
+ const keyStr = invoke(urlEncodeArr, PerformanceEvents.UrlEncodeArr, this.logger, this.performanceClient, correlationId)(new Uint8Array(baseKey));
11517
+ this.encryptionCookie = {
11518
+ id: id,
11519
+ key: await invokeAsync(generateHKDF, PerformanceEvents.GenerateHKDF, this.logger, this.performanceClient, correlationId)(baseKey),
11520
+ };
11521
+ const cookieData = {
11522
+ id: id,
11523
+ key: keyStr,
11524
+ };
11525
+ cookies.setItem(ENCRYPTION_KEY, JSON.stringify(cookieData));
11526
+ }
11339
11527
  }
11340
11528
  getItem(key) {
11341
11529
  return window.localStorage.getItem(key);
11342
11530
  }
11531
+ getUserData(key) {
11532
+ if (!this.initialized) {
11533
+ throw createBrowserAuthError(uninitializedPublicClientApplication);
11534
+ }
11535
+ return this.memoryStorage.getItem(key);
11536
+ }
11343
11537
  setItem(key, value) {
11344
11538
  window.localStorage.setItem(key, value);
11345
11539
  }
11540
+ async setUserData(key, value, correlationId) {
11541
+ if (!this.initialized || !this.encryptionCookie) {
11542
+ throw createBrowserAuthError(uninitializedPublicClientApplication);
11543
+ }
11544
+ const { data, nonce } = await invokeAsync(encrypt, PerformanceEvents.Encrypt, this.logger, this.performanceClient, correlationId)(this.encryptionCookie.key, value, this.getContext(key));
11545
+ const encryptedData = {
11546
+ id: this.encryptionCookie.id,
11547
+ nonce: nonce,
11548
+ data: data,
11549
+ };
11550
+ this.memoryStorage.setItem(key, value);
11551
+ this.setItem(key, JSON.stringify(encryptedData));
11552
+ }
11346
11553
  removeItem(key) {
11554
+ this.memoryStorage.removeItem(key);
11347
11555
  window.localStorage.removeItem(key);
11348
11556
  }
11349
11557
  getKeys() {
@@ -11352,6 +11560,114 @@
11352
11560
  containsKey(key) {
11353
11561
  return window.localStorage.hasOwnProperty(key);
11354
11562
  }
11563
+ /**
11564
+ * Removes all known MSAL keys from the cache
11565
+ */
11566
+ clear() {
11567
+ // Removes all remaining MSAL cache items
11568
+ this.memoryStorage.clear();
11569
+ const accountKeys = getAccountKeys(this);
11570
+ accountKeys.forEach((key) => this.removeItem(key));
11571
+ const tokenKeys = getTokenKeys(this.clientId, this);
11572
+ tokenKeys.idToken.forEach((key) => this.removeItem(key));
11573
+ tokenKeys.accessToken.forEach((key) => this.removeItem(key));
11574
+ tokenKeys.refreshToken.forEach((key) => this.removeItem(key));
11575
+ // Clean up anything left
11576
+ this.getKeys().forEach((cacheKey) => {
11577
+ if (cacheKey.startsWith(Constants.CACHE_PREFIX) ||
11578
+ cacheKey.indexOf(this.clientId) !== -1) {
11579
+ this.removeItem(cacheKey);
11580
+ }
11581
+ });
11582
+ }
11583
+ /**
11584
+ * Helper to decrypt all known MSAL keys in localStorage and save them to inMemory storage
11585
+ * @returns
11586
+ */
11587
+ async importExistingCache(correlationId) {
11588
+ if (!this.encryptionCookie) {
11589
+ return;
11590
+ }
11591
+ let accountKeys = getAccountKeys(this);
11592
+ accountKeys = await this.importArray(accountKeys, correlationId);
11593
+ // Write valid account keys back to map
11594
+ this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11595
+ const tokenKeys = getTokenKeys(this.clientId, this);
11596
+ tokenKeys.idToken = await this.importArray(tokenKeys.idToken, correlationId);
11597
+ tokenKeys.accessToken = await this.importArray(tokenKeys.accessToken, correlationId);
11598
+ tokenKeys.refreshToken = await this.importArray(tokenKeys.refreshToken, correlationId);
11599
+ // Write valid token keys back to map
11600
+ this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11601
+ }
11602
+ /**
11603
+ * Helper to decrypt and save cache entries
11604
+ * @param key
11605
+ * @returns
11606
+ */
11607
+ async getItemFromEncryptedCache(key, correlationId) {
11608
+ if (!this.encryptionCookie) {
11609
+ return null;
11610
+ }
11611
+ const rawCache = this.getItem(key);
11612
+ if (!rawCache) {
11613
+ return null;
11614
+ }
11615
+ let encObj;
11616
+ try {
11617
+ encObj = JSON.parse(rawCache);
11618
+ }
11619
+ catch (e) {
11620
+ // Not a valid encrypted object, remove
11621
+ return null;
11622
+ }
11623
+ if (!encObj.id || !encObj.nonce || !encObj.data) {
11624
+ // Data is not encrypted, likely from old version of MSAL. It must be removed because we don't know how old it is.
11625
+ this.performanceClient.incrementFields({ unencryptedCacheCount: 1 }, correlationId);
11626
+ return null;
11627
+ }
11628
+ if (encObj.id !== this.encryptionCookie.id) {
11629
+ // Data was encrypted with a different key. It must be removed because it is from a previous session.
11630
+ this.performanceClient.incrementFields({ encryptedCacheExpiredCount: 1 }, correlationId);
11631
+ return null;
11632
+ }
11633
+ return invokeAsync(decrypt, PerformanceEvents.Decrypt, this.logger, this.performanceClient, correlationId)(this.encryptionCookie.key, encObj.nonce, this.getContext(key), encObj.data);
11634
+ }
11635
+ /**
11636
+ * Helper to decrypt and save an array of cache keys
11637
+ * @param arr
11638
+ * @returns Array of keys successfully imported
11639
+ */
11640
+ async importArray(arr, correlationId) {
11641
+ const importedArr = [];
11642
+ const promiseArr = [];
11643
+ arr.forEach((key) => {
11644
+ const promise = this.getItemFromEncryptedCache(key, correlationId).then((value) => {
11645
+ if (value) {
11646
+ this.memoryStorage.setItem(key, value);
11647
+ importedArr.push(key);
11648
+ }
11649
+ else {
11650
+ // If value is empty, unencrypted or expired remove
11651
+ this.removeItem(key);
11652
+ }
11653
+ });
11654
+ promiseArr.push(promise);
11655
+ });
11656
+ await Promise.all(promiseArr);
11657
+ return importedArr;
11658
+ }
11659
+ /**
11660
+ * Gets encryption context for a given cache entry. This is clientId for app specific entries, empty string for shared entries
11661
+ * @param key
11662
+ * @returns
11663
+ */
11664
+ getContext(key) {
11665
+ let context = "";
11666
+ if (key.includes(this.clientId)) {
11667
+ context = this.clientId; // Used to bind encryption key to this appId
11668
+ }
11669
+ return context;
11670
+ }
11355
11671
  }
11356
11672
 
11357
11673
  /*
@@ -11364,12 +11680,21 @@
11364
11680
  throw createBrowserConfigurationAuthError(storageNotSupported);
11365
11681
  }
11366
11682
  }
11683
+ async initialize() {
11684
+ // Session storage does not require initialization
11685
+ }
11367
11686
  getItem(key) {
11368
11687
  return window.sessionStorage.getItem(key);
11369
11688
  }
11689
+ getUserData(key) {
11690
+ return this.getItem(key);
11691
+ }
11370
11692
  setItem(key, value) {
11371
11693
  window.sessionStorage.setItem(key, value);
11372
11694
  }
11695
+ async setUserData(key, value) {
11696
+ this.setItem(key, value);
11697
+ }
11373
11698
  removeItem(key) {
11374
11699
  window.sessionStorage.removeItem(key);
11375
11700
  }
@@ -11403,64 +11728,6 @@
11403
11728
  }
11404
11729
  }
11405
11730
 
11406
- /*
11407
- * Copyright (c) Microsoft Corporation. All rights reserved.
11408
- * Licensed under the MIT License.
11409
- */
11410
- // Cookie life calculation (hours * minutes * seconds * ms)
11411
- const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11412
- class CookieStorage {
11413
- getItem(key) {
11414
- const name = `${encodeURIComponent(key)}`;
11415
- const cookieList = document.cookie.split(";");
11416
- for (let i = 0; i < cookieList.length; i++) {
11417
- const cookie = cookieList[i];
11418
- const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
11419
- const value = rest.join("=");
11420
- if (key === name) {
11421
- return value;
11422
- }
11423
- }
11424
- return "";
11425
- }
11426
- setItem(key, value, cookieLifeDays, secure = true) {
11427
- let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
11428
- if (cookieLifeDays) {
11429
- const expireTime = getCookieExpirationTime(cookieLifeDays);
11430
- cookieStr += `expires=${expireTime};`;
11431
- }
11432
- if (secure) {
11433
- cookieStr += "Secure;";
11434
- }
11435
- document.cookie = cookieStr;
11436
- }
11437
- removeItem(key) {
11438
- // Setting expiration to -1 removes it
11439
- this.setItem(key, "", -1);
11440
- }
11441
- getKeys() {
11442
- const cookieList = document.cookie.split(";");
11443
- const keys = [];
11444
- cookieList.forEach((cookie) => {
11445
- const cookieParts = decodeURIComponent(cookie).trim().split("=");
11446
- keys.push(cookieParts[0]);
11447
- });
11448
- return keys;
11449
- }
11450
- containsKey(key) {
11451
- return this.getKeys().includes(key);
11452
- }
11453
- }
11454
- /**
11455
- * Get cookie expiration time
11456
- * @param cookieLifeDays
11457
- */
11458
- function getCookieExpirationTime(cookieLifeDays) {
11459
- const today = new Date();
11460
- const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
11461
- return expr.toUTCString();
11462
- }
11463
-
11464
11731
  /*
11465
11732
  * Copyright (c) Microsoft Corporation. All rights reserved.
11466
11733
  * Licensed under the MIT License.
@@ -11471,7 +11738,7 @@
11471
11738
  * parameters such as state and nonce, generally.
11472
11739
  */
11473
11740
  class BrowserCacheManager extends CacheManager {
11474
- constructor(clientId, cacheConfig, cryptoImpl, logger, staticAuthorityOptions, performanceClient) {
11741
+ constructor(clientId, cacheConfig, cryptoImpl, logger, performanceClient, staticAuthorityOptions) {
11475
11742
  super(clientId, cryptoImpl, logger, staticAuthorityOptions);
11476
11743
  this.cacheConfig = cacheConfig;
11477
11744
  this.logger = logger;
@@ -11479,13 +11746,11 @@
11479
11746
  this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);
11480
11747
  this.temporaryCacheStorage = this.setupBrowserStorage(this.cacheConfig.temporaryCacheLocation);
11481
11748
  this.cookieStorage = new CookieStorage();
11482
- // Migrate cache entries from older versions of MSAL.
11483
- if (cacheConfig.cacheMigrationEnabled) {
11484
- this.migrateCacheEntries();
11485
- this.createKeyMaps();
11486
- }
11487
11749
  this.performanceClient = performanceClient;
11488
11750
  }
11751
+ async initialize(correlationId) {
11752
+ await this.browserStorage.initialize(correlationId);
11753
+ }
11489
11754
  /**
11490
11755
  * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
11491
11756
  * @param cacheLocation
@@ -11494,7 +11759,7 @@
11494
11759
  try {
11495
11760
  switch (cacheLocation) {
11496
11761
  case BrowserCacheLocation.LocalStorage:
11497
- return new LocalStorage();
11762
+ return new LocalStorage(this.clientId, this.logger, this.performanceClient);
11498
11763
  case BrowserCacheLocation.SessionStorage:
11499
11764
  return new SessionStorage();
11500
11765
  case BrowserCacheLocation.MemoryStorage:
@@ -11508,123 +11773,6 @@
11508
11773
  this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
11509
11774
  return new MemoryStorage();
11510
11775
  }
11511
- /**
11512
- * Migrate all old cache entries to new schema. No rollback supported.
11513
- * @param storeAuthStateInCookie
11514
- */
11515
- migrateCacheEntries() {
11516
- const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
11517
- const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
11518
- const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
11519
- const errorDescKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR_DESC}`;
11520
- const idTokenValue = this.browserStorage.getItem(idTokenKey);
11521
- const clientInfoValue = this.browserStorage.getItem(clientInfoKey);
11522
- const errorValue = this.browserStorage.getItem(errorKey);
11523
- const errorDescValue = this.browserStorage.getItem(errorDescKey);
11524
- const values = [
11525
- idTokenValue,
11526
- clientInfoValue,
11527
- errorValue,
11528
- errorDescValue,
11529
- ];
11530
- const keysToMigrate = [
11531
- PersistentCacheKeys.ID_TOKEN,
11532
- PersistentCacheKeys.CLIENT_INFO,
11533
- PersistentCacheKeys.ERROR,
11534
- PersistentCacheKeys.ERROR_DESC,
11535
- ];
11536
- keysToMigrate.forEach((cacheKey, index) => {
11537
- const value = values[index];
11538
- if (value) {
11539
- this.setTemporaryCache(cacheKey, value, true);
11540
- }
11541
- });
11542
- }
11543
- /**
11544
- * Searches all cache entries for MSAL accounts and creates the account key map
11545
- * This is used to migrate users from older versions of MSAL which did not create the map.
11546
- * @returns
11547
- */
11548
- createKeyMaps() {
11549
- this.logger.trace("BrowserCacheManager - createKeyMaps called.");
11550
- const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
11551
- const tokenKeys = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
11552
- if (accountKeys && tokenKeys) {
11553
- this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
11554
- // Key maps already exist, no need to iterate through cache
11555
- return;
11556
- }
11557
- const allKeys = this.browserStorage.getKeys();
11558
- allKeys.forEach((key) => {
11559
- if (this.isCredentialKey(key)) {
11560
- // Get item, parse, validate and write key to map
11561
- const value = this.getItem(key);
11562
- if (value) {
11563
- const credObj = this.validateAndParseJson(value);
11564
- if (credObj && credObj.hasOwnProperty("credentialType")) {
11565
- switch (credObj["credentialType"]) {
11566
- case CredentialType.ID_TOKEN:
11567
- if (isIdTokenEntity(credObj)) {
11568
- this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
11569
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`);
11570
- const idTokenEntity = credObj;
11571
- const newKey = this.updateCredentialCacheKey(key, idTokenEntity);
11572
- this.addTokenKey(newKey, CredentialType.ID_TOKEN);
11573
- return;
11574
- }
11575
- else {
11576
- this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
11577
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed idToken validation on key: ${key}`);
11578
- }
11579
- break;
11580
- case CredentialType.ACCESS_TOKEN:
11581
- case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
11582
- if (isAccessTokenEntity(credObj)) {
11583
- this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
11584
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`);
11585
- const accessTokenEntity = credObj;
11586
- const newKey = this.updateCredentialCacheKey(key, accessTokenEntity);
11587
- this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
11588
- return;
11589
- }
11590
- else {
11591
- this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
11592
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed accessToken validation on key: ${key}`);
11593
- }
11594
- break;
11595
- case CredentialType.REFRESH_TOKEN:
11596
- if (isRefreshTokenEntity(credObj)) {
11597
- this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
11598
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`);
11599
- const refreshTokenEntity = credObj;
11600
- const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity);
11601
- this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
11602
- return;
11603
- }
11604
- else {
11605
- this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
11606
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: ${key}`);
11607
- }
11608
- break;
11609
- // If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
11610
- }
11611
- }
11612
- }
11613
- }
11614
- if (this.isAccountKey(key)) {
11615
- const value = this.getItem(key);
11616
- if (value) {
11617
- const accountObj = this.validateAndParseJson(value);
11618
- if (accountObj &&
11619
- AccountEntity.isAccountEntity(accountObj)) {
11620
- this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
11621
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`);
11622
- this.addAccountKeyToMap(key);
11623
- }
11624
- }
11625
- }
11626
- });
11627
- }
11628
11776
  /**
11629
11777
  * Parses passed value as JSON object, JSON.parse() will throw an error.
11630
11778
  * @param input
@@ -11646,38 +11794,15 @@
11646
11794
  return null;
11647
11795
  }
11648
11796
  }
11649
- /**
11650
- * fetches the entry from the browser storage based off the key
11651
- * @param key
11652
- */
11653
- getItem(key) {
11654
- return this.browserStorage.getItem(key);
11655
- }
11656
- /**
11657
- * sets the entry in the browser storage
11658
- * @param key
11659
- * @param value
11660
- */
11661
- setItem(key, value) {
11662
- this.browserStorage.setItem(key, value);
11663
- }
11664
- /**
11665
- * fetch the account entity from the platform cache
11666
- * @param accountKey
11667
- */
11668
- getAccount(accountKey, logger) {
11669
- this.logger.trace("BrowserCacheManager.getAccount called");
11670
- const accountEntity = this.getCachedAccountEntity(accountKey);
11671
- return this.updateOutdatedCachedAccount(accountKey, accountEntity, logger);
11672
- }
11673
11797
  /**
11674
11798
  * Reads account from cache, deserializes it into an account entity and returns it.
11675
11799
  * If account is not found from the key, returns null and removes key from map.
11676
11800
  * @param accountKey
11677
11801
  * @returns
11678
11802
  */
11679
- getCachedAccountEntity(accountKey) {
11680
- const serializedAccount = this.getItem(accountKey);
11803
+ getAccount(accountKey) {
11804
+ this.logger.trace("BrowserCacheManager.getAccount called");
11805
+ const serializedAccount = this.browserStorage.getUserData(accountKey);
11681
11806
  if (!serializedAccount) {
11682
11807
  this.removeAccountKeyFromMap(accountKey);
11683
11808
  return null;
@@ -11693,10 +11818,10 @@
11693
11818
  * set account entity in the platform cache
11694
11819
  * @param account
11695
11820
  */
11696
- setAccount(account) {
11821
+ async setAccount(account, correlationId) {
11697
11822
  this.logger.trace("BrowserCacheManager.setAccount called");
11698
11823
  const key = account.generateAccountKey();
11699
- this.setItem(key, JSON.stringify(account));
11824
+ await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(key, JSON.stringify(account), correlationId);
11700
11825
  this.addAccountKeyToMap(key);
11701
11826
  }
11702
11827
  /**
@@ -11704,13 +11829,7 @@
11704
11829
  * @returns
11705
11830
  */
11706
11831
  getAccountKeys() {
11707
- this.logger.trace("BrowserCacheManager.getAccountKeys called");
11708
- const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
11709
- if (accountKeys) {
11710
- return JSON.parse(accountKeys);
11711
- }
11712
- this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
11713
- return [];
11832
+ return getAccountKeys(this.browserStorage);
11714
11833
  }
11715
11834
  /**
11716
11835
  * Add a new account to the key map
@@ -11723,7 +11842,7 @@
11723
11842
  if (accountKeys.indexOf(key) === -1) {
11724
11843
  // Only add key if it does not already exist in the map
11725
11844
  accountKeys.push(key);
11726
- this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11845
+ this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11727
11846
  this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
11728
11847
  }
11729
11848
  else {
@@ -11741,7 +11860,7 @@
11741
11860
  const removalIndex = accountKeys.indexOf(key);
11742
11861
  if (removalIndex > -1) {
11743
11862
  accountKeys.splice(removalIndex, 1);
11744
- this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11863
+ this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11745
11864
  this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
11746
11865
  }
11747
11866
  else {
@@ -11756,14 +11875,6 @@
11756
11875
  void super.removeAccount(key);
11757
11876
  this.removeAccountKeyFromMap(key);
11758
11877
  }
11759
- /**
11760
- * Remove account entity from the platform cache if it's outdated
11761
- * @param accountKey
11762
- */
11763
- removeOutdatedAccount(accountKey) {
11764
- this.removeItem(accountKey);
11765
- this.removeAccountKeyFromMap(accountKey);
11766
- }
11767
11878
  /**
11768
11879
  * Removes given idToken from the cache and from the key map
11769
11880
  * @param key
@@ -11793,28 +11904,7 @@
11793
11904
  * @returns
11794
11905
  */
11795
11906
  getTokenKeys() {
11796
- this.logger.trace("BrowserCacheManager.getTokenKeys called");
11797
- const item = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
11798
- if (item) {
11799
- const tokenKeys = this.validateAndParseJson(item);
11800
- if (tokenKeys &&
11801
- tokenKeys.hasOwnProperty("idToken") &&
11802
- tokenKeys.hasOwnProperty("accessToken") &&
11803
- tokenKeys.hasOwnProperty("refreshToken")) {
11804
- return tokenKeys;
11805
- }
11806
- else {
11807
- this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
11808
- }
11809
- }
11810
- else {
11811
- this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
11812
- }
11813
- return {
11814
- idToken: [],
11815
- accessToken: [],
11816
- refreshToken: [],
11817
- };
11907
+ return getTokenKeys(this.clientId, this.browserStorage);
11818
11908
  }
11819
11909
  /**
11820
11910
  * Adds the given key to the token key map
@@ -11847,7 +11937,7 @@
11847
11937
  this.logger.error(`BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
11848
11938
  throw createClientAuthError(unexpectedCredentialType);
11849
11939
  }
11850
- this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11940
+ this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11851
11941
  }
11852
11942
  /**
11853
11943
  * Removes the given key from the token key map
@@ -11895,14 +11985,14 @@
11895
11985
  this.logger.error(`BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
11896
11986
  throw createClientAuthError(unexpectedCredentialType);
11897
11987
  }
11898
- this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11988
+ this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11899
11989
  }
11900
11990
  /**
11901
11991
  * generates idToken entity from a string
11902
11992
  * @param idTokenKey
11903
11993
  */
11904
11994
  getIdTokenCredential(idTokenKey) {
11905
- const value = this.getItem(idTokenKey);
11995
+ const value = this.browserStorage.getUserData(idTokenKey);
11906
11996
  if (!value) {
11907
11997
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
11908
11998
  this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
@@ -11921,10 +12011,10 @@
11921
12011
  * set IdToken credential to the platform cache
11922
12012
  * @param idToken
11923
12013
  */
11924
- setIdTokenCredential(idToken) {
12014
+ async setIdTokenCredential(idToken, correlationId) {
11925
12015
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
11926
12016
  const idTokenKey = generateCredentialKey(idToken);
11927
- this.setItem(idTokenKey, JSON.stringify(idToken));
12017
+ await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(idTokenKey, JSON.stringify(idToken), correlationId);
11928
12018
  this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
11929
12019
  }
11930
12020
  /**
@@ -11932,7 +12022,7 @@
11932
12022
  * @param key
11933
12023
  */
11934
12024
  getAccessTokenCredential(accessTokenKey) {
11935
- const value = this.getItem(accessTokenKey);
12025
+ const value = this.browserStorage.getUserData(accessTokenKey);
11936
12026
  if (!value) {
11937
12027
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
11938
12028
  this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
@@ -11952,10 +12042,10 @@
11952
12042
  * set accessToken credential to the platform cache
11953
12043
  * @param accessToken
11954
12044
  */
11955
- setAccessTokenCredential(accessToken) {
12045
+ async setAccessTokenCredential(accessToken, correlationId) {
11956
12046
  this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
11957
12047
  const accessTokenKey = generateCredentialKey(accessToken);
11958
- this.setItem(accessTokenKey, JSON.stringify(accessToken));
12048
+ await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(accessTokenKey, JSON.stringify(accessToken), correlationId);
11959
12049
  this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
11960
12050
  }
11961
12051
  /**
@@ -11963,7 +12053,7 @@
11963
12053
  * @param refreshTokenKey
11964
12054
  */
11965
12055
  getRefreshTokenCredential(refreshTokenKey) {
11966
- const value = this.getItem(refreshTokenKey);
12056
+ const value = this.browserStorage.getUserData(refreshTokenKey);
11967
12057
  if (!value) {
11968
12058
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
11969
12059
  this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
@@ -11983,10 +12073,10 @@
11983
12073
  * set refreshToken credential to the platform cache
11984
12074
  * @param refreshToken
11985
12075
  */
11986
- setRefreshTokenCredential(refreshToken) {
12076
+ async setRefreshTokenCredential(refreshToken, correlationId) {
11987
12077
  this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
11988
12078
  const refreshTokenKey = generateCredentialKey(refreshToken);
11989
- this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
12079
+ await invokeAsync(this.browserStorage.setUserData.bind(this.browserStorage), PerformanceEvents.SetUserData, this.logger, this.performanceClient)(refreshTokenKey, JSON.stringify(refreshToken), correlationId);
11990
12080
  this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
11991
12081
  }
11992
12082
  /**
@@ -11994,7 +12084,7 @@
11994
12084
  * @param appMetadataKey
11995
12085
  */
11996
12086
  getAppMetadata(appMetadataKey) {
11997
- const value = this.getItem(appMetadataKey);
12087
+ const value = this.browserStorage.getItem(appMetadataKey);
11998
12088
  if (!value) {
11999
12089
  this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit");
12000
12090
  return null;
@@ -12015,14 +12105,14 @@
12015
12105
  setAppMetadata(appMetadata) {
12016
12106
  this.logger.trace("BrowserCacheManager.setAppMetadata called");
12017
12107
  const appMetadataKey = generateAppMetadataKey(appMetadata);
12018
- this.setItem(appMetadataKey, JSON.stringify(appMetadata));
12108
+ this.browserStorage.setItem(appMetadataKey, JSON.stringify(appMetadata));
12019
12109
  }
12020
12110
  /**
12021
12111
  * fetch server telemetry entity from the platform cache
12022
12112
  * @param serverTelemetryKey
12023
12113
  */
12024
12114
  getServerTelemetry(serverTelemetryKey) {
12025
- const value = this.getItem(serverTelemetryKey);
12115
+ const value = this.browserStorage.getItem(serverTelemetryKey);
12026
12116
  if (!value) {
12027
12117
  this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit");
12028
12118
  return null;
@@ -12043,7 +12133,7 @@
12043
12133
  */
12044
12134
  setServerTelemetry(serverTelemetryKey, serverTelemetry) {
12045
12135
  this.logger.trace("BrowserCacheManager.setServerTelemetry called");
12046
- this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
12136
+ this.browserStorage.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
12047
12137
  }
12048
12138
  /**
12049
12139
  *
@@ -12103,25 +12193,9 @@
12103
12193
  */
12104
12194
  getActiveAccount() {
12105
12195
  const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
12106
- const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
12196
+ const activeAccountValueFilters = this.browserStorage.getItem(activeAccountKeyFilters);
12107
12197
  if (!activeAccountValueFilters) {
12108
- // if new active account cache type isn't found, it's an old version, so look for that instead
12109
- this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema");
12110
- const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
12111
- const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
12112
- if (!activeAccountValueLocal) {
12113
- this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
12114
- return null;
12115
- }
12116
- const activeAccount = this.getAccountInfoFilteredBy({
12117
- localAccountId: activeAccountValueLocal,
12118
- });
12119
- if (activeAccount) {
12120
- this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
12121
- this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
12122
- this.setActiveAccount(activeAccount);
12123
- return activeAccount;
12124
- }
12198
+ this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters found");
12125
12199
  return null;
12126
12200
  }
12127
12201
  const activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
@@ -12142,7 +12216,6 @@
12142
12216
  */
12143
12217
  setActiveAccount(account) {
12144
12218
  const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
12145
- const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
12146
12219
  if (account) {
12147
12220
  this.logger.verbose("setActiveAccount: Active account set");
12148
12221
  const activeAccountValue = {
@@ -12151,12 +12224,10 @@
12151
12224
  tenantId: account.tenantId,
12152
12225
  };
12153
12226
  this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
12154
- this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
12155
12227
  }
12156
12228
  else {
12157
12229
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
12158
12230
  this.browserStorage.removeItem(activeAccountKey);
12159
- this.browserStorage.removeItem(activeAccountKeyLocal);
12160
12231
  }
12161
12232
  }
12162
12233
  /**
@@ -12164,7 +12235,7 @@
12164
12235
  * @param throttlingCacheKey
12165
12236
  */
12166
12237
  getThrottlingCache(throttlingCacheKey) {
12167
- const value = this.getItem(throttlingCacheKey);
12238
+ const value = this.browserStorage.getItem(throttlingCacheKey);
12168
12239
  if (!value) {
12169
12240
  this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit");
12170
12241
  return null;
@@ -12185,7 +12256,7 @@
12185
12256
  */
12186
12257
  setThrottlingCache(throttlingCacheKey, throttlingCache) {
12187
12258
  this.logger.trace("BrowserCacheManager.setThrottlingCache called");
12188
- this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
12259
+ this.browserStorage.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
12189
12260
  }
12190
12261
  /**
12191
12262
  * Gets cache item with given key.
@@ -12313,8 +12384,7 @@
12313
12384
  generateCacheKey(key) {
12314
12385
  const generatedKey = this.validateAndParseJson(key);
12315
12386
  if (!generatedKey) {
12316
- if (StringUtils.startsWith(key, Constants.CACHE_PREFIX) ||
12317
- StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)) {
12387
+ if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)) {
12318
12388
  return key;
12319
12389
  }
12320
12390
  return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;
@@ -12540,59 +12610,6 @@
12540
12610
  this.removeTemporaryItem(key);
12541
12611
  }
12542
12612
  }
12543
- /**
12544
- * Returns username retrieved from ADAL or MSAL v1 idToken
12545
- * @deprecated
12546
- */
12547
- getLegacyLoginHint() {
12548
- // Only check for adal/msal token if no SSO params are being used
12549
- const adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
12550
- if (adalIdTokenString) {
12551
- this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
12552
- this.logger.verbose("Cached ADAL id token retrieved.");
12553
- }
12554
- // Check for cached MSAL v1 id token
12555
- const msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
12556
- if (msalIdTokenString) {
12557
- this.browserStorage.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
12558
- this.logger.verbose("Cached MSAL.js v1 id token retrieved");
12559
- }
12560
- const cachedIdTokenString = msalIdTokenString || adalIdTokenString;
12561
- if (cachedIdTokenString) {
12562
- const idTokenClaims = extractTokenClaims(cachedIdTokenString, base64Decode);
12563
- if (idTokenClaims.preferred_username) {
12564
- this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
12565
- return idTokenClaims.preferred_username;
12566
- }
12567
- else if (idTokenClaims.upn) {
12568
- this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
12569
- return idTokenClaims.upn;
12570
- }
12571
- else {
12572
- this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO.");
12573
- }
12574
- }
12575
- return null;
12576
- }
12577
- /**
12578
- * Updates a credential's cache key if the current cache key is outdated
12579
- */
12580
- updateCredentialCacheKey(currentCacheKey, credential) {
12581
- const updatedCacheKey = generateCredentialKey(credential);
12582
- if (currentCacheKey !== updatedCacheKey) {
12583
- const cacheItem = this.getItem(currentCacheKey);
12584
- if (cacheItem) {
12585
- this.browserStorage.removeItem(currentCacheKey);
12586
- this.setItem(updatedCacheKey, cacheItem);
12587
- this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
12588
- return updatedCacheKey;
12589
- }
12590
- else {
12591
- this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`);
12592
- }
12593
- }
12594
- return currentCacheKey;
12595
- }
12596
12613
  /**
12597
12614
  * Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
12598
12615
  * @param result
@@ -12618,7 +12635,7 @@
12618
12635
  idToken: idTokenEntity,
12619
12636
  accessToken: accessTokenEntity,
12620
12637
  };
12621
- return this.saveCacheRecord(cacheRecord);
12638
+ return this.saveCacheRecord(cacheRecord, result.correlationId);
12622
12639
  }
12623
12640
  /**
12624
12641
  * saves a cache record
@@ -12626,9 +12643,9 @@
12626
12643
  * @param storeInCache {?StoreInCache}
12627
12644
  * @param correlationId {?string} correlation id
12628
12645
  */
12629
- async saveCacheRecord(cacheRecord, storeInCache, correlationId) {
12646
+ async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
12630
12647
  try {
12631
- await super.saveCacheRecord(cacheRecord, storeInCache, correlationId);
12648
+ await super.saveCacheRecord(cacheRecord, correlationId, storeInCache);
12632
12649
  }
12633
12650
  catch (e) {
12634
12651
  if (e instanceof CacheError &&
@@ -12648,7 +12665,7 @@
12648
12665
  }
12649
12666
  }
12650
12667
  }
12651
- const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger) => {
12668
+ const DEFAULT_BROWSER_CACHE_MANAGER = (clientId, logger, performanceClient) => {
12652
12669
  const cacheOptions = {
12653
12670
  cacheLocation: BrowserCacheLocation.MemoryStorage,
12654
12671
  temporaryCacheLocation: BrowserCacheLocation.MemoryStorage,
@@ -12657,7 +12674,7 @@
12657
12674
  cacheMigrationEnabled: false,
12658
12675
  claimsBasedCachingEnabled: false,
12659
12676
  };
12660
- return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger);
12677
+ return new BrowserCacheManager(clientId, cacheOptions, DEFAULT_CRYPTO_IMPLEMENTATION, logger, performanceClient);
12661
12678
  };
12662
12679
 
12663
12680
  /*
@@ -13319,13 +13336,6 @@
13319
13336
  this.logger.verbosePii(`Setting validated request account: ${account.homeAccountId}`, this.correlationId);
13320
13337
  validatedRequest.account = account;
13321
13338
  }
13322
- // Check for ADAL/MSAL v1 SSO
13323
- if (!validatedRequest.loginHint && !account) {
13324
- const legacyLoginHint = this.browserStorage.getLegacyLoginHint();
13325
- if (legacyLoginHint) {
13326
- validatedRequest.loginHint = legacyLoginHint;
13327
- }
13328
- }
13329
13339
  return validatedRequest;
13330
13340
  }
13331
13341
  }
@@ -13729,8 +13739,8 @@
13729
13739
  // generate authenticationResult
13730
13740
  const result = await this.generateAuthenticationResult(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
13731
13741
  // cache accounts and tokens in the appropriate storage
13732
- this.cacheAccount(baseAccount);
13733
- this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
13742
+ await this.cacheAccount(baseAccount);
13743
+ await this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
13734
13744
  return result;
13735
13745
  }
13736
13746
  /**
@@ -13854,9 +13864,9 @@
13854
13864
  * cache the account entity in browser storage
13855
13865
  * @param accountEntity
13856
13866
  */
13857
- cacheAccount(accountEntity) {
13867
+ async cacheAccount(accountEntity) {
13858
13868
  // Store the account info and hence `nativeAccountId` in browser cache
13859
- this.browserStorage.setAccount(accountEntity);
13869
+ await this.browserStorage.setAccount(accountEntity, this.correlationId);
13860
13870
  // Remove any existing cached tokens for this account in browser storage
13861
13871
  this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
13862
13872
  this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
@@ -13887,7 +13897,7 @@
13887
13897
  idToken: cachedIdToken,
13888
13898
  accessToken: cachedAccessToken,
13889
13899
  };
13890
- void this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.storeInCache);
13900
+ return this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, this.correlationId, request.storeInCache);
13891
13901
  }
13892
13902
  addTelemetryFromNativeResponse(response) {
13893
13903
  const mats = this.getMATSFromResponse(response);
@@ -14322,15 +14332,15 @@
14322
14332
  * @param nativeExtensionProvider
14323
14333
  * @param authenticationScheme
14324
14334
  */
14325
- static isNativeAvailable(config, logger, nativeExtensionProvider, authenticationScheme) {
14326
- logger.trace("isNativeAvailable called");
14327
- if (!config.system.allowNativeBroker) {
14328
- logger.trace("isNativeAvailable: allowNativeBroker is not enabled, returning false");
14335
+ static isPlatformBrokerAvailable(config, logger, nativeExtensionProvider, authenticationScheme) {
14336
+ logger.trace("isPlatformBrokerAvailable called");
14337
+ if (!config.system.allowPlatformBroker) {
14338
+ logger.trace("isPlatformBrokerAvailable: allowPlatformBroker is not enabled, returning false");
14329
14339
  // Developer disabled WAM
14330
14340
  return false;
14331
14341
  }
14332
14342
  if (!nativeExtensionProvider) {
14333
- logger.trace("isNativeAvailable: WAM extension provider is not initialized, returning false");
14343
+ logger.trace("isPlatformBrokerAvailable: Platform extension provider is not initialized, returning false");
14334
14344
  // Extension is not available
14335
14345
  return false;
14336
14346
  }
@@ -14338,10 +14348,10 @@
14338
14348
  switch (authenticationScheme) {
14339
14349
  case AuthenticationScheme.BEARER:
14340
14350
  case AuthenticationScheme.POP:
14341
- logger.trace("isNativeAvailable: authenticationScheme is supported, returning true");
14351
+ logger.trace("isPlatformBrokerAvailable: authenticationScheme is supported, returning true");
14342
14352
  return true;
14343
14353
  default:
14344
- logger.trace("isNativeAvailable: authenticationScheme is not supported, returning false");
14354
+ logger.trace("isPlatformBrokerAvailable: authenticationScheme is not supported, returning false");
14345
14355
  return false;
14346
14356
  }
14347
14357
  }
@@ -14578,17 +14588,17 @@
14578
14588
  requestExtraQueryParameters: validRequest.extraQueryParameters,
14579
14589
  account: validRequest.account,
14580
14590
  });
14581
- const isNativeBroker = NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme);
14591
+ const isPlatformBroker = NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme);
14582
14592
  // Start measurement for server calls with native brokering enabled
14583
14593
  let fetchNativeAccountIdMeasurement;
14584
- if (isNativeBroker) {
14594
+ if (isPlatformBroker) {
14585
14595
  fetchNativeAccountIdMeasurement =
14586
14596
  this.performanceClient.startMeasurement(PerformanceEvents.FetchAccountIdWithNativeBroker, request.correlationId);
14587
14597
  }
14588
14598
  // Create acquire token url.
14589
14599
  const navigateUrl = await authClient.getAuthCodeUrl({
14590
14600
  ...validRequest,
14591
- nativeBroker: isNativeBroker,
14601
+ platformBroker: isPlatformBroker,
14592
14602
  });
14593
14603
  // Create popup interaction handler.
14594
14604
  const interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
@@ -15105,7 +15115,7 @@
15105
15115
  // Create acquire token url.
15106
15116
  const navigateUrl = await authClient.getAuthCodeUrl({
15107
15117
  ...validRequest,
15108
- nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme),
15118
+ platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme),
15109
15119
  });
15110
15120
  const redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);
15111
15121
  this.logger.verbosePii(`Redirect start page: ${redirectStartPage}`);
@@ -15619,7 +15629,7 @@
15619
15629
  // Create authorize request url
15620
15630
  const navigateUrl = await invokeAsync(authClient.getAuthCodeUrl.bind(authClient), PerformanceEvents.GetAuthCodeUrl, this.logger, this.performanceClient, correlationId)({
15621
15631
  ...silentRequest,
15622
- nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme),
15632
+ platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme),
15623
15633
  });
15624
15634
  // Create silent handler
15625
15635
  const interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
@@ -15734,10 +15744,11 @@
15734
15744
  * @param options
15735
15745
  * @returns `AuthenticationResult` for the response that was loaded.
15736
15746
  */
15737
- loadExternalTokens(request, response, options) {
15747
+ async loadExternalTokens(request, response, options) {
15738
15748
  if (!this.isBrowserEnvironment) {
15739
15749
  throw createBrowserAuthError(nonBrowserEnvironment);
15740
15750
  }
15751
+ const correlationId = request.correlationId || createNewGuid();
15741
15752
  const idTokenClaims = response.id_token
15742
15753
  ? extractTokenClaims(response.id_token, base64Decode)
15743
15754
  : undefined;
@@ -15751,10 +15762,10 @@
15751
15762
  const authority = request.authority
15752
15763
  ? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
15753
15764
  : undefined;
15754
- const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
15755
- const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
15756
- const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
15757
- const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
15765
+ const cacheRecordAccount = await this.loadAccount(request, options.clientInfo || response.client_info || "", correlationId, idTokenClaims, authority);
15766
+ const idToken = await this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, correlationId);
15767
+ const accessToken = await this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options, correlationId);
15768
+ const refreshToken = await this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, correlationId);
15758
15769
  return this.generateAuthenticationResult(request, {
15759
15770
  account: cacheRecordAccount,
15760
15771
  idToken,
@@ -15771,11 +15782,11 @@
15771
15782
  * @param requestHomeAccountId
15772
15783
  * @returns `AccountEntity`
15773
15784
  */
15774
- loadAccount(request, clientInfo, idTokenClaims, authority) {
15785
+ async loadAccount(request, clientInfo, correlationId, idTokenClaims, authority) {
15775
15786
  this.logger.verbose("TokenCache - loading account");
15776
15787
  if (request.account) {
15777
15788
  const accountEntity = AccountEntity.createFromAccountInfo(request.account);
15778
- this.storage.setAccount(accountEntity);
15789
+ await this.storage.setAccount(accountEntity, correlationId);
15779
15790
  return accountEntity;
15780
15791
  }
15781
15792
  else if (!authority || (!clientInfo && !idTokenClaims)) {
@@ -15787,7 +15798,7 @@
15787
15798
  const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
15788
15799
  undefined, // nativeAccountId
15789
15800
  this.logger);
15790
- this.storage.setAccount(cachedAccount);
15801
+ await this.storage.setAccount(cachedAccount, correlationId);
15791
15802
  return cachedAccount;
15792
15803
  }
15793
15804
  /**
@@ -15798,14 +15809,14 @@
15798
15809
  * @param tenantId
15799
15810
  * @returns `IdTokenEntity`
15800
15811
  */
15801
- loadIdToken(response, homeAccountId, environment, tenantId) {
15812
+ async loadIdToken(response, homeAccountId, environment, tenantId, correlationId) {
15802
15813
  if (!response.id_token) {
15803
15814
  this.logger.verbose("TokenCache - no id token found in response");
15804
15815
  return null;
15805
15816
  }
15806
15817
  this.logger.verbose("TokenCache - loading id token");
15807
15818
  const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
15808
- this.storage.setIdTokenCredential(idTokenEntity);
15819
+ await this.storage.setIdTokenCredential(idTokenEntity, correlationId);
15809
15820
  return idTokenEntity;
15810
15821
  }
15811
15822
  /**
@@ -15817,7 +15828,7 @@
15817
15828
  * @param tenantId
15818
15829
  * @returns `AccessTokenEntity`
15819
15830
  */
15820
- loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
15831
+ async loadAccessToken(request, response, homeAccountId, environment, tenantId, options, correlationId) {
15821
15832
  if (!response.access_token) {
15822
15833
  this.logger.verbose("TokenCache - no access token found in response");
15823
15834
  return null;
@@ -15841,7 +15852,7 @@
15841
15852
  (response.ext_expires_in || response.expires_in) +
15842
15853
  new Date().getTime() / 1000;
15843
15854
  const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
15844
- this.storage.setAccessTokenCredential(accessTokenEntity);
15855
+ await this.storage.setAccessTokenCredential(accessTokenEntity, correlationId);
15845
15856
  return accessTokenEntity;
15846
15857
  }
15847
15858
  /**
@@ -15852,7 +15863,7 @@
15852
15863
  * @param environment
15853
15864
  * @returns `RefreshTokenEntity`
15854
15865
  */
15855
- loadRefreshToken(response, homeAccountId, environment) {
15866
+ async loadRefreshToken(response, homeAccountId, environment, correlationId) {
15856
15867
  if (!response.refresh_token) {
15857
15868
  this.logger.verbose("TokenCache - no refresh token found in response");
15858
15869
  return null;
@@ -15860,7 +15871,7 @@
15860
15871
  this.logger.verbose("TokenCache - loading refresh token");
15861
15872
  const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
15862
15873
  response.refresh_token_expires_in);
15863
- this.storage.setRefreshTokenCredential(refreshTokenEntity);
15874
+ await this.storage.setRefreshTokenCredential(refreshTokenEntity, correlationId);
15864
15875
  return refreshTokenEntity;
15865
15876
  }
15866
15877
  /**
@@ -16056,8 +16067,8 @@
16056
16067
  this.eventHandler = new EventHandler(this.logger);
16057
16068
  // Initialize the browser storage class.
16058
16069
  this.browserStorage = this.isBrowserEnvironment
16059
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, buildStaticAuthorityOptions(this.config.auth), this.performanceClient)
16060
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
16070
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, buildStaticAuthorityOptions(this.config.auth))
16071
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
16061
16072
  // initialize in memory storage for native flows
16062
16073
  const nativeCacheOptions = {
16063
16074
  cacheLocation: BrowserCacheLocation.MemoryStorage,
@@ -16067,7 +16078,7 @@
16067
16078
  cacheMigrationEnabled: false,
16068
16079
  claimsBasedCachingEnabled: false,
16069
16080
  };
16070
- this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger, undefined, this.performanceClient);
16081
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger, this.performanceClient);
16071
16082
  // Initialize the token cache
16072
16083
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
16073
16084
  this.activeSilentTokenRequests = new Map();
@@ -16110,10 +16121,11 @@
16110
16121
  return;
16111
16122
  }
16112
16123
  const initCorrelationId = request?.correlationId || this.getRequestCorrelationId();
16113
- const allowNativeBroker = this.config.system.allowNativeBroker;
16124
+ const allowPlatformBroker = this.config.system.allowPlatformBroker;
16114
16125
  const initMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.InitializeClientApplication, initCorrelationId);
16115
16126
  this.eventHandler.emitEvent(EventType.INITIALIZE_START);
16116
- if (allowNativeBroker) {
16127
+ await invokeAsync(this.browserStorage.initialize.bind(this.browserStorage), PerformanceEvents.InitializeCache, this.logger, this.performanceClient, initCorrelationId)(initCorrelationId);
16128
+ if (allowPlatformBroker) {
16117
16129
  try {
16118
16130
  this.nativeExtensionProvider =
16119
16131
  await NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient);
@@ -16128,7 +16140,10 @@
16128
16140
  }
16129
16141
  this.initialized = true;
16130
16142
  this.eventHandler.emitEvent(EventType.INITIALIZE_END);
16131
- initMeasurement.end({ allowNativeBroker, success: true });
16143
+ initMeasurement.end({
16144
+ allowPlatformBroker: allowPlatformBroker,
16145
+ success: true,
16146
+ });
16132
16147
  }
16133
16148
  // #region Redirect Flow
16134
16149
  /**
@@ -16172,7 +16187,7 @@
16172
16187
  const loggedInAccounts = this.getAllAccounts();
16173
16188
  const request = this.browserStorage.getCachedNativeRequest();
16174
16189
  const useNative = request &&
16175
- NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
16190
+ NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider) &&
16176
16191
  this.nativeExtensionProvider &&
16177
16192
  !hash;
16178
16193
  const correlationId = useNative
@@ -16301,7 +16316,8 @@
16301
16316
  this.eventHandler.emitEvent(EventType.LOGIN_START, exports.InteractionType.Redirect, request);
16302
16317
  }
16303
16318
  let result;
16304
- if (this.nativeExtensionProvider && this.canUseNative(request)) {
16319
+ if (this.nativeExtensionProvider &&
16320
+ this.canUsePlatformBroker(request)) {
16305
16321
  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);
16306
16322
  result = nativeClient
16307
16323
  .acquireTokenRedirect(request, atrMeasurement)
@@ -16372,7 +16388,7 @@
16372
16388
  this.eventHandler.emitEvent(EventType.LOGIN_START, exports.InteractionType.Popup, request);
16373
16389
  }
16374
16390
  let result;
16375
- if (this.canUseNative(request)) {
16391
+ if (this.canUsePlatformBroker(request)) {
16376
16392
  result = this.acquireTokenNative({
16377
16393
  ...request,
16378
16394
  correlationId,
@@ -16489,7 +16505,7 @@
16489
16505
  this.logger.verbose("ssoSilent called", correlationId);
16490
16506
  this.eventHandler.emitEvent(EventType.SSO_SILENT_START, exports.InteractionType.Silent, validRequest);
16491
16507
  let result;
16492
- if (this.canUseNative(validRequest)) {
16508
+ if (this.canUsePlatformBroker(validRequest)) {
16493
16509
  result = this.acquireTokenNative(validRequest, ApiId.ssoSilent).catch((e) => {
16494
16510
  // If native token acquisition fails for availability reasons fallback to standard flow
16495
16511
  if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
@@ -16587,7 +16603,7 @@
16587
16603
  return await response;
16588
16604
  }
16589
16605
  else if (request.nativeAccountId) {
16590
- if (this.canUseNative(request, request.nativeAccountId)) {
16606
+ if (this.canUsePlatformBroker(request, request.nativeAccountId)) {
16591
16607
  const result = await this.acquireTokenNative({
16592
16608
  ...request,
16593
16609
  correlationId,
@@ -16834,7 +16850,7 @@
16834
16850
  this.logger.verbose("hydrateCache called");
16835
16851
  // Account gets saved to browser storage regardless of native or not
16836
16852
  const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
16837
- this.browserStorage.setAccount(accountEntity);
16853
+ await this.browserStorage.setAccount(accountEntity, result.correlationId);
16838
16854
  if (result.fromNativeBroker) {
16839
16855
  this.logger.verbose("Response was from native broker, storing in-memory");
16840
16856
  // Tokens from native broker are stored in-memory
@@ -16858,13 +16874,13 @@
16858
16874
  return nativeClient.acquireToken(request);
16859
16875
  }
16860
16876
  /**
16861
- * Returns boolean indicating if this request can use the native broker
16877
+ * Returns boolean indicating if this request can use the platform broker
16862
16878
  * @param request
16863
16879
  */
16864
- canUseNative(request, accountId) {
16865
- this.logger.trace("canUseNative called");
16866
- if (!NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme)) {
16867
- this.logger.trace("canUseNative: isNativeAvailable returned false, returning false");
16880
+ canUsePlatformBroker(request, accountId) {
16881
+ this.logger.trace("canUsePlatformBroker called");
16882
+ if (!NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme)) {
16883
+ this.logger.trace("canUsePlatformBroker: isPlatformBrokerAvailable returned false, returning false");
16868
16884
  return false;
16869
16885
  }
16870
16886
  if (request.prompt) {
@@ -16872,15 +16888,15 @@
16872
16888
  case PromptValue.NONE:
16873
16889
  case PromptValue.CONSENT:
16874
16890
  case PromptValue.LOGIN:
16875
- this.logger.trace("canUseNative: prompt is compatible with native flow");
16891
+ this.logger.trace("canUsePlatformBroker: prompt is compatible with platform broker flow");
16876
16892
  break;
16877
16893
  default:
16878
- this.logger.trace(`canUseNative: prompt = ${request.prompt} is not compatible with native flow, returning false`);
16894
+ this.logger.trace(`canUsePlatformBroker: prompt = ${request.prompt} is not compatible with platform broker flow, returning false`);
16879
16895
  return false;
16880
16896
  }
16881
16897
  }
16882
16898
  if (!accountId && !this.getNativeAccountId(request)) {
16883
- this.logger.trace("canUseNative: nativeAccountId is not available, returning false");
16899
+ this.logger.trace("canUsePlatformBroker: nativeAccountId is not available, returning false");
16884
16900
  return false;
16885
16901
  }
16886
16902
  return true;
@@ -17321,7 +17337,7 @@
17321
17337
  * @returns
17322
17338
  */
17323
17339
  async acquireTokenSilentNoIframe(silentRequest, cacheLookupPolicy) {
17324
- if (NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, silentRequest.authenticationScheme) &&
17340
+ if (NativeMessageHandler.isPlatformBrokerAvailable(this.config, this.logger, this.nativeExtensionProvider, silentRequest.authenticationScheme) &&
17325
17341
  silentRequest.account.nativeAccountId) {
17326
17342
  this.logger.verbose("acquireTokenSilent - attempting to acquire token from native platform");
17327
17343
  return this.acquireTokenNative(silentRequest, ApiId.acquireTokenSilent_silentFlow).catch(async (e) => {
@@ -17611,8 +17627,8 @@
17611
17627
  : DEFAULT_CRYPTO_IMPLEMENTATION;
17612
17628
  // Initialize the browser storage class.
17613
17629
  this.browserStorage = this.operatingContext.isBrowserEnvironment()
17614
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, buildStaticAuthorityOptions(this.config.auth))
17615
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
17630
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, buildStaticAuthorityOptions(this.config.auth))
17631
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
17616
17632
  this.eventHandler = new EventHandler(this.logger);
17617
17633
  this.nestedAppAuthAdapter = new NestedAppAuthAdapter(this.config.auth.clientId, this.config.auth.clientCapabilities, this.browserCrypto, this.logger);
17618
17634
  // Set the active account if available
@@ -17635,8 +17651,9 @@
17635
17651
  * Specific implementation of initialize function for NestedAppAuthController
17636
17652
  * @returns
17637
17653
  */
17638
- initialize() {
17639
- // do nothing not required by this controller
17654
+ async initialize(request) {
17655
+ const initCorrelationId = request?.correlationId || createNewGuid();
17656
+ await this.browserStorage.initialize(initCorrelationId);
17640
17657
  return Promise.resolve();
17641
17658
  }
17642
17659
  /**
@@ -18062,7 +18079,7 @@
18062
18079
  async hydrateCache(result, request) {
18063
18080
  this.logger.verbose("hydrateCache called");
18064
18081
  const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
18065
- this.browserStorage.setAccount(accountEntity);
18082
+ await this.browserStorage.setAccount(accountEntity, result.correlationId);
18066
18083
  return this.browserStorage.hydrateCache(result, request);
18067
18084
  }
18068
18085
  }
@@ -18494,8 +18511,8 @@
18494
18511
  : DEFAULT_CRYPTO_IMPLEMENTATION;
18495
18512
  // Initialize the browser storage class.
18496
18513
  this.browserStorage = this.isBrowserEnvironment
18497
- ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, undefined, this.performanceClient)
18498
- : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
18514
+ ? new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger, this.performanceClient, undefined)
18515
+ : DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger, this.performanceClient);
18499
18516
  }
18500
18517
  getBrowserStorage() {
18501
18518
  return this.browserStorage;
@@ -19220,42 +19237,6 @@
19220
19237
  },
19221
19238
  };
19222
19239
 
19223
- /*
19224
- * Copyright (c) Microsoft Corporation. All rights reserved.
19225
- * Licensed under the MIT License.
19226
- */
19227
- /**
19228
- * @deprecated This class will be removed in a future major version
19229
- */
19230
- class BrowserStorage {
19231
- constructor(cacheLocation) {
19232
- if (cacheLocation === BrowserCacheLocation.LocalStorage) {
19233
- this.windowStorage = new LocalStorage();
19234
- }
19235
- else if (cacheLocation === BrowserCacheLocation.SessionStorage) {
19236
- this.windowStorage = new SessionStorage();
19237
- }
19238
- else {
19239
- throw createBrowserConfigurationAuthError(storageNotSupported);
19240
- }
19241
- }
19242
- getItem(key) {
19243
- return this.windowStorage.getItem(key);
19244
- }
19245
- setItem(key, value) {
19246
- this.windowStorage.setItem(key, value);
19247
- }
19248
- removeItem(key) {
19249
- this.windowStorage.removeItem(key);
19250
- }
19251
- getKeys() {
19252
- return Object.keys(this.windowStorage);
19253
- }
19254
- containsKey(key) {
19255
- return this.windowStorage.hasOwnProperty(key);
19256
- }
19257
- }
19258
-
19259
19240
  /*
19260
19241
  * Copyright (c) Microsoft Corporation. All rights reserved.
19261
19242
  * Licensed under the MIT License.
@@ -19643,7 +19624,6 @@
19643
19624
  exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
19644
19625
  exports.BrowserPerformanceClient = BrowserPerformanceClient;
19645
19626
  exports.BrowserPerformanceMeasurement = BrowserPerformanceMeasurement;
19646
- exports.BrowserStorage = BrowserStorage;
19647
19627
  exports.BrowserUtils = BrowserUtils;
19648
19628
  exports.CacheLookupPolicy = CacheLookupPolicy;
19649
19629
  exports.ClientAuthError = ClientAuthError;