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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) 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.mjs +1 -1
  5. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  6. package/dist/cache/AccountManager.mjs +1 -1
  7. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  8. package/dist/cache/BrowserCacheManager.d.ts +9 -85
  9. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  10. package/dist/cache/BrowserCacheManager.mjs +55 -398
  11. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  12. package/dist/cache/CacheHelpers.d.ts +16 -0
  13. package/dist/cache/CacheHelpers.d.ts.map +1 -0
  14. package/dist/cache/CacheHelpers.mjs +46 -0
  15. package/dist/cache/CacheHelpers.mjs.map +1 -0
  16. package/dist/cache/CookieStorage.d.ts +17 -0
  17. package/dist/cache/CookieStorage.d.ts.map +1 -0
  18. package/dist/cache/CookieStorage.mjs +73 -0
  19. package/dist/cache/CookieStorage.mjs.map +1 -0
  20. package/dist/cache/DatabaseStorage.mjs +1 -1
  21. package/dist/cache/ITokenCache.d.ts +1 -1
  22. package/dist/cache/ITokenCache.d.ts.map +1 -1
  23. package/dist/cache/IWindowStorage.d.ts +12 -0
  24. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  25. package/dist/cache/LocalStorage.d.ts +43 -0
  26. package/dist/cache/LocalStorage.d.ts.map +1 -0
  27. package/dist/cache/LocalStorage.mjs +201 -0
  28. package/dist/cache/LocalStorage.mjs.map +1 -0
  29. package/dist/cache/MemoryStorage.d.ts +3 -0
  30. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  31. package/dist/cache/MemoryStorage.mjs +10 -1
  32. package/dist/cache/MemoryStorage.mjs.map +1 -1
  33. package/dist/cache/SessionStorage.d.ts +13 -0
  34. package/dist/cache/SessionStorage.d.ts.map +1 -0
  35. package/dist/cache/SessionStorage.mjs +43 -0
  36. package/dist/cache/SessionStorage.mjs.map +1 -0
  37. package/dist/cache/TokenCache.d.ts +1 -1
  38. package/dist/cache/TokenCache.d.ts.map +1 -1
  39. package/dist/cache/TokenCache.mjs +15 -15
  40. package/dist/cache/TokenCache.mjs.map +1 -1
  41. package/dist/config/Configuration.mjs +1 -1
  42. package/dist/controllers/ControllerFactory.mjs +1 -1
  43. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  44. package/dist/controllers/NestedAppAuthController.mjs +4 -4
  45. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  46. package/dist/controllers/StandardController.d.ts.map +1 -1
  47. package/dist/controllers/StandardController.mjs +3 -2
  48. package/dist/controllers/StandardController.mjs.map +1 -1
  49. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  50. package/dist/crypto/BrowserCrypto.d.ts +27 -0
  51. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  52. package/dist/crypto/BrowserCrypto.mjs +83 -3
  53. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  54. package/dist/crypto/CryptoOps.mjs +1 -1
  55. package/dist/crypto/PkceGenerator.mjs +1 -1
  56. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  57. package/dist/encode/Base64Decode.d.ts +5 -0
  58. package/dist/encode/Base64Decode.d.ts.map +1 -1
  59. package/dist/encode/Base64Decode.mjs +2 -2
  60. package/dist/encode/Base64Decode.mjs.map +1 -1
  61. package/dist/encode/Base64Encode.mjs +1 -1
  62. package/dist/error/BrowserAuthError.mjs +1 -1
  63. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  64. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  65. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  66. package/dist/error/NativeAuthError.mjs +1 -1
  67. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  68. package/dist/error/NestedAppAuthError.mjs +1 -1
  69. package/dist/event/EventHandler.mjs +1 -1
  70. package/dist/event/EventMessage.mjs +1 -1
  71. package/dist/event/EventType.mjs +1 -1
  72. package/dist/index.d.ts +3 -1
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.mjs +3 -2
  75. package/dist/index.mjs.map +1 -1
  76. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  77. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  78. package/dist/interaction_client/NativeInteractionClient.d.ts +1 -1
  79. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  80. package/dist/interaction_client/NativeInteractionClient.mjs +4 -4
  81. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  82. package/dist/interaction_client/PopupClient.mjs +1 -1
  83. package/dist/interaction_client/RedirectClient.mjs +1 -1
  84. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  85. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  86. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  87. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  88. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  89. package/dist/interaction_client/StandardInteractionClient.mjs +5 -8
  90. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  91. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  92. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  93. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  94. package/dist/naa/BridgeError.mjs +1 -1
  95. package/dist/naa/BridgeProxy.mjs +1 -1
  96. package/dist/naa/BridgeStatusCode.mjs +1 -1
  97. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  98. package/dist/navigation/NavigationClient.mjs +1 -1
  99. package/dist/network/FetchClient.mjs +1 -1
  100. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  101. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  102. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  103. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  104. package/dist/packageMetadata.d.ts +1 -1
  105. package/dist/packageMetadata.d.ts.map +1 -1
  106. package/dist/packageMetadata.mjs +2 -2
  107. package/dist/request/RequestHelpers.mjs +1 -1
  108. package/dist/response/ResponseHandler.mjs +1 -1
  109. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  110. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  111. package/dist/utils/BrowserConstants.mjs +1 -1
  112. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  113. package/dist/utils/BrowserUtils.mjs +1 -1
  114. package/lib/msal-browser.cjs +587 -622
  115. package/lib/msal-browser.cjs.map +1 -1
  116. package/lib/msal-browser.js +587 -622
  117. package/lib/msal-browser.js.map +1 -1
  118. package/lib/msal-browser.min.js +65 -66
  119. package/lib/types/cache/BrowserCacheManager.d.ts +9 -85
  120. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  121. package/lib/types/cache/CacheHelpers.d.ts +16 -0
  122. package/lib/types/cache/CacheHelpers.d.ts.map +1 -0
  123. package/lib/types/cache/CookieStorage.d.ts +17 -0
  124. package/lib/types/cache/CookieStorage.d.ts.map +1 -0
  125. package/lib/types/cache/ITokenCache.d.ts +1 -1
  126. package/lib/types/cache/ITokenCache.d.ts.map +1 -1
  127. package/lib/types/cache/IWindowStorage.d.ts +12 -0
  128. package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
  129. package/lib/types/cache/LocalStorage.d.ts +43 -0
  130. package/lib/types/cache/LocalStorage.d.ts.map +1 -0
  131. package/lib/types/cache/MemoryStorage.d.ts +3 -0
  132. package/lib/types/cache/MemoryStorage.d.ts.map +1 -1
  133. package/lib/types/cache/SessionStorage.d.ts +13 -0
  134. package/lib/types/cache/SessionStorage.d.ts.map +1 -0
  135. package/lib/types/cache/TokenCache.d.ts +1 -1
  136. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  137. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  138. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  139. package/lib/types/crypto/BrowserCrypto.d.ts +27 -0
  140. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  141. package/lib/types/encode/Base64Decode.d.ts +5 -0
  142. package/lib/types/encode/Base64Decode.d.ts.map +1 -1
  143. package/lib/types/index.d.ts +3 -1
  144. package/lib/types/index.d.ts.map +1 -1
  145. package/lib/types/interaction_client/NativeInteractionClient.d.ts +1 -1
  146. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  147. package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  148. package/lib/types/packageMetadata.d.ts +1 -1
  149. package/lib/types/packageMetadata.d.ts.map +1 -1
  150. package/package.json +2 -2
  151. package/src/cache/BrowserCacheManager.ts +85 -552
  152. package/src/cache/CacheHelpers.ts +52 -0
  153. package/src/cache/CookieStorage.ts +98 -0
  154. package/src/cache/ITokenCache.ts +1 -1
  155. package/src/cache/IWindowStorage.ts +14 -0
  156. package/src/cache/LocalStorage.ts +270 -0
  157. package/src/cache/MemoryStorage.ts +12 -0
  158. package/src/cache/SessionStorage.ts +52 -0
  159. package/src/cache/TokenCache.ts +19 -19
  160. package/src/controllers/NestedAppAuthController.ts +3 -3
  161. package/src/controllers/StandardController.ts +3 -1
  162. package/src/crypto/BrowserCrypto.ts +120 -1
  163. package/src/encode/Base64Decode.ts +1 -1
  164. package/src/index.ts +3 -1
  165. package/src/interaction_client/NativeInteractionClient.ts +3 -3
  166. package/src/interaction_client/StandardInteractionClient.ts +5 -8
  167. package/src/packageMetadata.ts +1 -1
  168. package/dist/cache/BrowserStorage.d.ts +0 -12
  169. package/dist/cache/BrowserStorage.d.ts.map +0 -1
  170. package/dist/cache/BrowserStorage.mjs +0 -41
  171. package/dist/cache/BrowserStorage.mjs.map +0 -1
  172. package/lib/types/cache/BrowserStorage.d.ts +0 -12
  173. package/lib/types/cache/BrowserStorage.d.ts.map +0 -1
  174. package/src/cache/BrowserStorage.ts +0 -52
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v3.27.0 2024-11-05 */
1
+ /*! @azure/msal-browser v4.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
9
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
313
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
330
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
379
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
477
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
729
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
768
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
959
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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.0-alpha.0";
969
963
 
970
- /*! @azure/msal-common v14.16.0 2024-11-05 */
964
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
984
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
1045
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
1082
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
1409
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1416
1410
  /*
1417
1411
  * Copyright (c) Microsoft Corporation. All rights reserved.
1418
1412
  * Licensed under the MIT License.
@@ -1466,7 +1460,7 @@
1466
1460
  urlParseError: urlParseError
1467
1461
  });
1468
1462
 
1469
- /*! @azure/msal-common v14.16.0 2024-11-05 */
1463
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
1470
1464
 
1471
1465
  /*
1472
1466
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1604,7 +1598,7 @@
1604
1598
  return new ClientConfigurationError(errorCode);
1605
1599
  }
1606
1600
 
1607
- /*! @azure/msal-common v14.16.0 2024-11-05 */
1601
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
1698
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
1898
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
1938
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2017
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2032
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2054
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2067
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2310
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2357
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2521
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2661
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2669
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
2696
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
2703
2697
 
2704
2698
  /*
2705
2699
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2870,10 +2864,10 @@
2870
2864
  }
2871
2865
  try {
2872
2866
  if (!!cacheRecord.account) {
2873
- this.setAccount(cacheRecord.account);
2867
+ await this.setAccount(cacheRecord.account);
2874
2868
  }
2875
2869
  if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
2876
- this.setIdTokenCredential(cacheRecord.idToken);
2870
+ await this.setIdTokenCredential(cacheRecord.idToken);
2877
2871
  }
2878
2872
  if (!!cacheRecord.accessToken &&
2879
2873
  storeInCache?.accessToken !== false) {
@@ -2881,7 +2875,7 @@
2881
2875
  }
2882
2876
  if (!!cacheRecord.refreshToken &&
2883
2877
  storeInCache?.refreshToken !== false) {
2884
- this.setRefreshTokenCredential(cacheRecord.refreshToken);
2878
+ await this.setRefreshTokenCredential(cacheRecord.refreshToken);
2885
2879
  }
2886
2880
  if (!!cacheRecord.appMetadata) {
2887
2881
  this.setAppMetadata(cacheRecord.appMetadata);
@@ -2938,7 +2932,7 @@
2938
2932
  }
2939
2933
  });
2940
2934
  await Promise.all(removedAccessTokens);
2941
- this.setAccessTokenCredential(credential);
2935
+ await this.setAccessTokenCredential(credential);
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 2024-11-05 */
3881
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
3980
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
3990
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
4040
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
4107
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
4515
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
4527
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
4537
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
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 2024-11-05 */
4547
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
4618
4548
  /*
4619
4549
  * Copyright (c) Microsoft Corporation. All rights reserved.
4620
4550
  * Licensed under the MIT License.
@@ -5101,7 +5031,7 @@
5101
5031
  "multiMatchedRT",
5102
5032
  ]);
5103
5033
 
5104
- /*! @azure/msal-common v14.16.0 2024-11-05 */
5034
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
5105
5035
  /*
5106
5036
  * Copyright (c) Microsoft Corporation. All rights reserved.
5107
5037
  * Licensed under the MIT License.
@@ -5197,7 +5127,7 @@
5197
5127
  };
5198
5128
  };
5199
5129
 
5200
- /*! @azure/msal-common v14.16.0 2024-11-05 */
5130
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
5201
5131
 
5202
5132
  /*
5203
5133
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5306,7 +5236,7 @@
5306
5236
  },
5307
5237
  };
5308
5238
 
5309
- /*! @azure/msal-common v14.16.0 2024-11-05 */
5239
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
5310
5240
 
5311
5241
  /*
5312
5242
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6145,7 +6075,7 @@
6145
6075
  };
6146
6076
  }
6147
6077
 
6148
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6078
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6149
6079
 
6150
6080
  /*
6151
6081
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6176,7 +6106,7 @@
6176
6106
  }
6177
6107
  }
6178
6108
 
6179
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6109
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6180
6110
 
6181
6111
  /*
6182
6112
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6195,7 +6125,7 @@
6195
6125
  }
6196
6126
  }
6197
6127
 
6198
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6128
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6199
6129
 
6200
6130
  /*
6201
6131
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6293,7 +6223,7 @@
6293
6223
  }
6294
6224
  }
6295
6225
 
6296
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6226
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6297
6227
 
6298
6228
  /*
6299
6229
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6323,7 +6253,7 @@
6323
6253
  return new NetworkError(error, httpStatus, responseHeaders);
6324
6254
  }
6325
6255
 
6326
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6256
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6327
6257
 
6328
6258
  /*
6329
6259
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6473,7 +6403,7 @@
6473
6403
  }
6474
6404
  }
6475
6405
 
6476
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6406
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6477
6407
  /*
6478
6408
  * Copyright (c) Microsoft Corporation. All rights reserved.
6479
6409
  * Licensed under the MIT License.
@@ -6499,7 +6429,7 @@
6499
6429
  refreshTokenExpired: refreshTokenExpired
6500
6430
  });
6501
6431
 
6502
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6432
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6503
6433
 
6504
6434
  /*
6505
6435
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6587,7 +6517,7 @@
6587
6517
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6588
6518
  }
6589
6519
 
6590
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6520
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6591
6521
 
6592
6522
  /*
6593
6523
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6659,7 +6589,7 @@
6659
6589
  }
6660
6590
  }
6661
6591
 
6662
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6592
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6663
6593
 
6664
6594
  /*
6665
6595
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6743,7 +6673,7 @@
6743
6673
  }
6744
6674
  }
6745
6675
 
6746
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6676
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6747
6677
  /*
6748
6678
  * Copyright (c) Microsoft Corporation. All rights reserved.
6749
6679
  * Licensed under the MIT License.
@@ -6770,7 +6700,7 @@
6770
6700
  }
6771
6701
  }
6772
6702
 
6773
- /*! @azure/msal-common v14.16.0 2024-11-05 */
6703
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
6774
6704
 
6775
6705
  /*
6776
6706
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6930,7 +6860,7 @@
6930
6860
  !forceCacheRefreshTokenResponse &&
6931
6861
  cacheRecord.account) {
6932
6862
  const key = cacheRecord.account.generateAccountKey();
6933
- const account = this.cacheStorage.getAccount(key, this.logger);
6863
+ const account = this.cacheStorage.getAccount(key);
6934
6864
  if (!account) {
6935
6865
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
6936
6866
  return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
@@ -7122,7 +7052,7 @@
7122
7052
  });
7123
7053
  let cachedAccount = null;
7124
7054
  if (baseAccountKey) {
7125
- cachedAccount = cacheStorage.getAccount(baseAccountKey, logger);
7055
+ cachedAccount = cacheStorage.getAccount(baseAccountKey);
7126
7056
  }
7127
7057
  const baseAccount = cachedAccount ||
7128
7058
  AccountEntity.createAccount({
@@ -7147,7 +7077,7 @@
7147
7077
  return baseAccount;
7148
7078
  }
7149
7079
 
7150
- /*! @azure/msal-common v14.16.0 2024-11-05 */
7080
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7151
7081
  /*
7152
7082
  * Copyright (c) Microsoft Corporation. All rights reserved.
7153
7083
  * Licensed under the MIT License.
@@ -7165,7 +7095,7 @@
7165
7095
  }
7166
7096
  }
7167
7097
 
7168
- /*! @azure/msal-common v14.16.0 2024-11-05 */
7098
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7169
7099
 
7170
7100
  /*
7171
7101
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7607,7 +7537,7 @@
7607
7537
  }
7608
7538
  }
7609
7539
 
7610
- /*! @azure/msal-common v14.16.0 2024-11-05 */
7540
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7611
7541
 
7612
7542
  /*
7613
7543
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7827,7 +7757,7 @@
7827
7757
  }
7828
7758
  }
7829
7759
 
7830
- /*! @azure/msal-common v14.16.0 2024-11-05 */
7760
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7831
7761
 
7832
7762
  /*
7833
7763
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7963,7 +7893,7 @@
7963
7893
  }
7964
7894
  }
7965
7895
 
7966
- /*! @azure/msal-common v14.16.0 2024-11-05 */
7896
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7967
7897
 
7968
7898
  /*
7969
7899
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7978,7 +7908,7 @@
7978
7908
  },
7979
7909
  };
7980
7910
 
7981
- /*! @azure/msal-common v14.16.0 2024-11-05 */
7911
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
7982
7912
 
7983
7913
  /*
7984
7914
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8036,7 +7966,7 @@
8036
7966
  }
8037
7967
  }
8038
7968
 
8039
- /*! @azure/msal-common v14.16.0 2024-11-05 */
7969
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8040
7970
 
8041
7971
  /*
8042
7972
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8299,7 +8229,7 @@
8299
8229
  }
8300
8230
  }
8301
8231
 
8302
- /*! @azure/msal-common v14.16.0 2024-11-05 */
8232
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8303
8233
  /*
8304
8234
  * Copyright (c) Microsoft Corporation. All rights reserved.
8305
8235
  * Licensed under the MIT License.
@@ -8307,7 +8237,7 @@
8307
8237
  const missingKidError = "missing_kid_error";
8308
8238
  const missingAlgError = "missing_alg_error";
8309
8239
 
8310
- /*! @azure/msal-common v14.16.0 2024-11-05 */
8240
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8311
8241
 
8312
8242
  /*
8313
8243
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8332,7 +8262,7 @@
8332
8262
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
8333
8263
  }
8334
8264
 
8335
- /*! @azure/msal-common v14.16.0 2024-11-05 */
8265
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8336
8266
 
8337
8267
  /*
8338
8268
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8372,7 +8302,7 @@
8372
8302
  }
8373
8303
  }
8374
8304
 
8375
- /*! @azure/msal-common v14.16.0 2024-11-05 */
8305
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8376
8306
 
8377
8307
  /*
8378
8308
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8451,7 +8381,7 @@
8451
8381
  }
8452
8382
  }
8453
8383
 
8454
- /*! @azure/msal-common v14.16.0 2024-11-05 */
8384
+ /*! @azure/msal-common v15.0.0-alpha.0 2024-12-18 */
8455
8385
 
8456
8386
  /*
8457
8387
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9688,6 +9618,43 @@
9688
9618
  return btoa(binString);
9689
9619
  }
9690
9620
 
9621
+ /*
9622
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9623
+ * Licensed under the MIT License.
9624
+ */
9625
+ /**
9626
+ * Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
9627
+ * https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
9628
+ */
9629
+ /**
9630
+ * Returns a URL-safe plaintext decoded string from b64 encoded input.
9631
+ * @param input
9632
+ */
9633
+ function base64Decode(input) {
9634
+ return new TextDecoder().decode(base64DecToArr(input));
9635
+ }
9636
+ /**
9637
+ * Decodes base64 into Uint8Array
9638
+ * @param base64String
9639
+ */
9640
+ function base64DecToArr(base64String) {
9641
+ let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
9642
+ switch (encodedString.length % 4) {
9643
+ case 0:
9644
+ break;
9645
+ case 2:
9646
+ encodedString += "==";
9647
+ break;
9648
+ case 3:
9649
+ encodedString += "=";
9650
+ break;
9651
+ default:
9652
+ throw createBrowserAuthError(invalidBase64String);
9653
+ }
9654
+ const binString = atob(encodedString);
9655
+ return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
9656
+ }
9657
+
9691
9658
  /*
9692
9659
  * Copyright (c) Microsoft Corporation. All rights reserved.
9693
9660
  * Licensed under the MIT License.
@@ -9699,8 +9666,10 @@
9699
9666
  /**
9700
9667
  * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
9701
9668
  */
9702
- // RSA KeyGen Algorithm
9669
+ // Algorithms
9703
9670
  const PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
9671
+ const AES_GCM = "AES-GCM";
9672
+ const HKDF = "HKDF";
9704
9673
  // SHA-256 hashing algorithm
9705
9674
  const S256_HASH_ALG = "SHA-256";
9706
9675
  // MOD length for PoP tokens
@@ -9711,6 +9680,13 @@
9711
9680
  const UUID_CHARS = "0123456789abcdef";
9712
9681
  // Array to store UINT32 random value
9713
9682
  const UINT32_ARR = new Uint32Array(1);
9683
+ // Key Format
9684
+ const RAW = "raw";
9685
+ // Key Usages
9686
+ const ENCRYPT = "encrypt";
9687
+ const DECRYPT = "decrypt";
9688
+ const DERIVE_KEY = "deriveKey";
9689
+ // Suberror
9714
9690
  const SUBTLE_SUBERROR = "crypto_subtle_undefined";
9715
9691
  const keygenAlgorithmOptions = {
9716
9692
  name: PKCS1_V15_KEYGEN_ALG,
@@ -9833,6 +9809,76 @@
9833
9809
  async function sign(key, data) {
9834
9810
  return window.crypto.subtle.sign(keygenAlgorithmOptions, key, data);
9835
9811
  }
9812
+ /**
9813
+ * Generates symmetric base encryption key. This may be stored as all encryption/decryption keys will be derived from this one.
9814
+ */
9815
+ async function generateBaseKey() {
9816
+ const key = await window.crypto.subtle.generateKey({
9817
+ name: AES_GCM,
9818
+ length: 256,
9819
+ }, true, [ENCRYPT, DECRYPT]);
9820
+ return window.crypto.subtle.exportKey(RAW, key);
9821
+ }
9822
+ /**
9823
+ * Returns the raw key to be passed into the key derivation function
9824
+ * @param baseKey
9825
+ * @returns
9826
+ */
9827
+ async function generateHKDF(baseKey) {
9828
+ return window.crypto.subtle.importKey(RAW, baseKey, HKDF, false, [
9829
+ DERIVE_KEY,
9830
+ ]);
9831
+ }
9832
+ /**
9833
+ * Given a base key and a nonce generates a derived key to be used in encryption and decryption.
9834
+ * Note: every time we encrypt a new key is derived
9835
+ * @param baseKey
9836
+ * @param nonce
9837
+ * @returns
9838
+ */
9839
+ async function deriveKey(baseKey, nonce, context) {
9840
+ return window.crypto.subtle.deriveKey({
9841
+ name: HKDF,
9842
+ salt: nonce,
9843
+ hash: S256_HASH_ALG,
9844
+ info: new TextEncoder().encode(context),
9845
+ }, baseKey, { name: AES_GCM, length: 256 }, false, [ENCRYPT, DECRYPT]);
9846
+ }
9847
+ /**
9848
+ * Encrypt the given data given a base key. Returns encrypted data and a nonce that must be provided during decryption
9849
+ * @param key
9850
+ * @param rawData
9851
+ */
9852
+ async function encrypt(baseKey, rawData, context) {
9853
+ const encodedData = new TextEncoder().encode(rawData);
9854
+ // The nonce must never be reused with a given key.
9855
+ const nonce = window.crypto.getRandomValues(new Uint8Array(16));
9856
+ const derivedKey = await deriveKey(baseKey, nonce, context);
9857
+ const encryptedData = await window.crypto.subtle.encrypt({
9858
+ name: AES_GCM,
9859
+ iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
9860
+ }, derivedKey, encodedData);
9861
+ return {
9862
+ data: urlEncodeArr(new Uint8Array(encryptedData)),
9863
+ nonce: urlEncodeArr(nonce),
9864
+ };
9865
+ }
9866
+ /**
9867
+ * Decrypt data with the given key and nonce
9868
+ * @param key
9869
+ * @param nonce
9870
+ * @param encryptedData
9871
+ * @returns
9872
+ */
9873
+ async function decrypt(baseKey, nonce, context, encryptedData) {
9874
+ const encodedData = base64DecToArr(encryptedData);
9875
+ const derivedKey = await deriveKey(baseKey, base64DecToArr(nonce), context);
9876
+ const decryptedData = await window.crypto.subtle.decrypt({
9877
+ name: AES_GCM,
9878
+ iv: new Uint8Array(12), // New key is derived for every encrypt so we don't need a new nonce
9879
+ }, derivedKey, encodedData);
9880
+ return new TextDecoder().decode(decryptedData);
9881
+ }
9836
9882
  /**
9837
9883
  * Returns the SHA-256 hash of an input string
9838
9884
  * @param plainText
@@ -10370,7 +10416,7 @@
10370
10416
 
10371
10417
  /* eslint-disable header/header */
10372
10418
  const name = "@azure/msal-browser";
10373
- const version = "3.27.0";
10419
+ const version = "4.0.0-alpha.0";
10374
10420
 
10375
10421
  /*
10376
10422
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10746,43 +10792,6 @@
10746
10792
  */
10747
10793
  StandardOperatingContext.ID = "StandardOperatingContext";
10748
10794
 
10749
- /*
10750
- * Copyright (c) Microsoft Corporation. All rights reserved.
10751
- * Licensed under the MIT License.
10752
- */
10753
- /**
10754
- * Class which exposes APIs to decode base64 strings to plaintext. See here for implementation details:
10755
- * https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
10756
- */
10757
- /**
10758
- * Returns a URL-safe plaintext decoded string from b64 encoded input.
10759
- * @param input
10760
- */
10761
- function base64Decode(input) {
10762
- return new TextDecoder().decode(base64DecToArr(input));
10763
- }
10764
- /**
10765
- * Decodes base64 into Uint8Array
10766
- * @param base64String
10767
- */
10768
- function base64DecToArr(base64String) {
10769
- let encodedString = base64String.replace(/-/g, "+").replace(/_/g, "/");
10770
- switch (encodedString.length % 4) {
10771
- case 0:
10772
- break;
10773
- case 2:
10774
- encodedString += "==";
10775
- break;
10776
- case 3:
10777
- encodedString += "=";
10778
- break;
10779
- default:
10780
- throw createBrowserAuthError(invalidBase64String);
10781
- }
10782
- const binString = atob(encodedString);
10783
- return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
10784
- }
10785
-
10786
10795
  /*
10787
10796
  * Copyright (c) Microsoft Corporation. All rights reserved.
10788
10797
  * Licensed under the MIT License.
@@ -10992,12 +11001,21 @@
10992
11001
  constructor() {
10993
11002
  this.cache = new Map();
10994
11003
  }
11004
+ async initialize() {
11005
+ // Memory storage does not require initialization
11006
+ }
10995
11007
  getItem(key) {
10996
11008
  return this.cache.get(key) || null;
10997
11009
  }
11010
+ getUserData(key) {
11011
+ return this.getItem(key);
11012
+ }
10998
11013
  setItem(key, value) {
10999
11014
  this.cache.set(key, value);
11000
11015
  }
11016
+ async setUserData(key, value) {
11017
+ this.setItem(key, value);
11018
+ }
11001
11019
  removeItem(key) {
11002
11020
  this.cache.delete(key);
11003
11021
  }
@@ -11329,32 +11347,327 @@
11329
11347
  * Copyright (c) Microsoft Corporation. All rights reserved.
11330
11348
  * Licensed under the MIT License.
11331
11349
  */
11332
- class BrowserStorage {
11333
- constructor(cacheLocation) {
11334
- this.validateWindowStorage(cacheLocation);
11335
- this.windowStorage = window[cacheLocation];
11350
+ // Cookie life calculation (hours * minutes * seconds * ms)
11351
+ const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11352
+ class CookieStorage {
11353
+ initialize() {
11354
+ return Promise.resolve();
11355
+ }
11356
+ getItem(key) {
11357
+ const name = `${encodeURIComponent(key)}`;
11358
+ const cookieList = document.cookie.split(";");
11359
+ for (let i = 0; i < cookieList.length; i++) {
11360
+ const cookie = cookieList[i];
11361
+ const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
11362
+ const value = rest.join("=");
11363
+ if (key === name) {
11364
+ return value;
11365
+ }
11366
+ }
11367
+ return "";
11368
+ }
11369
+ getUserData() {
11370
+ throw createClientAuthError(methodNotImplemented);
11371
+ }
11372
+ setItem(key, value, cookieLifeDays, secure = true) {
11373
+ let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
11374
+ if (cookieLifeDays) {
11375
+ const expireTime = getCookieExpirationTime(cookieLifeDays);
11376
+ cookieStr += `expires=${expireTime};`;
11377
+ }
11378
+ if (secure) {
11379
+ cookieStr += "Secure;";
11380
+ }
11381
+ document.cookie = cookieStr;
11382
+ }
11383
+ async setUserData() {
11384
+ return Promise.reject(createClientAuthError(methodNotImplemented));
11385
+ }
11386
+ removeItem(key) {
11387
+ // Setting expiration to -1 removes it
11388
+ this.setItem(key, "", -1);
11389
+ }
11390
+ getKeys() {
11391
+ const cookieList = document.cookie.split(";");
11392
+ const keys = [];
11393
+ cookieList.forEach((cookie) => {
11394
+ const cookieParts = decodeURIComponent(cookie).trim().split("=");
11395
+ keys.push(cookieParts[0]);
11396
+ });
11397
+ return keys;
11398
+ }
11399
+ containsKey(key) {
11400
+ return this.getKeys().includes(key);
11401
+ }
11402
+ }
11403
+ /**
11404
+ * Get cookie expiration time
11405
+ * @param cookieLifeDays
11406
+ */
11407
+ function getCookieExpirationTime(cookieLifeDays) {
11408
+ const today = new Date();
11409
+ const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
11410
+ return expr.toUTCString();
11411
+ }
11412
+
11413
+ /*
11414
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11415
+ * Licensed under the MIT License.
11416
+ */
11417
+ /**
11418
+ * Returns a list of cache keys for all known accounts
11419
+ * @param storage
11420
+ * @returns
11421
+ */
11422
+ function getAccountKeys(storage) {
11423
+ const accountKeys = storage.getItem(StaticCacheKeys.ACCOUNT_KEYS);
11424
+ if (accountKeys) {
11425
+ return JSON.parse(accountKeys);
11426
+ }
11427
+ return [];
11428
+ }
11429
+ /**
11430
+ * Returns a list of cache keys for all known tokens
11431
+ * @param clientId
11432
+ * @param storage
11433
+ * @returns
11434
+ */
11435
+ function getTokenKeys(clientId, storage) {
11436
+ const item = storage.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${clientId}`);
11437
+ if (item) {
11438
+ const tokenKeys = JSON.parse(item);
11439
+ if (tokenKeys &&
11440
+ tokenKeys.hasOwnProperty("idToken") &&
11441
+ tokenKeys.hasOwnProperty("accessToken") &&
11442
+ tokenKeys.hasOwnProperty("refreshToken")) {
11443
+ return tokenKeys;
11444
+ }
11445
+ }
11446
+ return {
11447
+ idToken: [],
11448
+ accessToken: [],
11449
+ refreshToken: [],
11450
+ };
11451
+ }
11452
+
11453
+ /*
11454
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11455
+ * Licensed under the MIT License.
11456
+ */
11457
+ const ENCRYPTION_KEY = "msal.cache.encryption";
11458
+ class LocalStorage {
11459
+ constructor(clientId) {
11460
+ if (!window.localStorage) {
11461
+ throw createBrowserConfigurationAuthError(storageNotSupported);
11462
+ }
11463
+ this.memoryStorage = new MemoryStorage();
11464
+ this.initialized = false;
11465
+ this.clientId = clientId;
11466
+ }
11467
+ async initialize() {
11468
+ this.initialized = true;
11469
+ const cookies = new CookieStorage();
11470
+ const cookieString = cookies.getItem(ENCRYPTION_KEY);
11471
+ let parsedCookie = { key: "", id: "" };
11472
+ if (cookieString) {
11473
+ try {
11474
+ parsedCookie = JSON.parse(cookieString);
11475
+ }
11476
+ catch (e) {
11477
+ // TODO: Log telemetry but don't throw
11478
+ }
11479
+ }
11480
+ if (parsedCookie.key && parsedCookie.id) {
11481
+ // Encryption key already exists, import
11482
+ this.encryptionCookie = {
11483
+ id: parsedCookie.id,
11484
+ key: await generateHKDF(base64DecToArr(parsedCookie.key)),
11485
+ };
11486
+ await this.importExistingCache();
11487
+ }
11488
+ else {
11489
+ // Encryption key doesn't exist or is invalid, generate a new one and clear existing cache
11490
+ this.clear();
11491
+ const id = createNewGuid();
11492
+ const baseKey = await generateBaseKey();
11493
+ const keyStr = urlEncodeArr(new Uint8Array(baseKey));
11494
+ this.encryptionCookie = {
11495
+ id: id,
11496
+ key: await generateHKDF(baseKey),
11497
+ };
11498
+ const cookieData = {
11499
+ id: id,
11500
+ key: keyStr,
11501
+ };
11502
+ cookies.setItem(ENCRYPTION_KEY, JSON.stringify(cookieData));
11503
+ }
11504
+ }
11505
+ getItem(key) {
11506
+ return window.localStorage.getItem(key);
11507
+ }
11508
+ getUserData(key) {
11509
+ if (!this.initialized) {
11510
+ throw createBrowserAuthError(uninitializedPublicClientApplication);
11511
+ }
11512
+ return this.memoryStorage.getItem(key);
11513
+ }
11514
+ setItem(key, value) {
11515
+ window.localStorage.setItem(key, value);
11516
+ }
11517
+ async setUserData(key, value) {
11518
+ if (!this.initialized || !this.encryptionCookie) {
11519
+ throw createBrowserAuthError(uninitializedPublicClientApplication);
11520
+ }
11521
+ const { data, nonce } = await encrypt(this.encryptionCookie.key, value, this.getContext(key));
11522
+ const encryptedData = {
11523
+ id: this.encryptionCookie.id,
11524
+ nonce: nonce,
11525
+ data: data,
11526
+ };
11527
+ this.memoryStorage.setItem(key, value);
11528
+ this.setItem(key, JSON.stringify(encryptedData));
11529
+ }
11530
+ removeItem(key) {
11531
+ this.memoryStorage.removeItem(key);
11532
+ window.localStorage.removeItem(key);
11533
+ }
11534
+ getKeys() {
11535
+ return Object.keys(window.localStorage);
11536
+ }
11537
+ containsKey(key) {
11538
+ return window.localStorage.hasOwnProperty(key);
11539
+ }
11540
+ /**
11541
+ * Removes all known MSAL keys from the cache
11542
+ */
11543
+ clear() {
11544
+ // Removes all remaining MSAL cache items
11545
+ this.memoryStorage.clear();
11546
+ const accountKeys = getAccountKeys(this);
11547
+ accountKeys.forEach((key) => this.removeItem(key));
11548
+ const tokenKeys = getTokenKeys(this.clientId, this);
11549
+ tokenKeys.idToken.forEach((key) => this.removeItem(key));
11550
+ tokenKeys.accessToken.forEach((key) => this.removeItem(key));
11551
+ tokenKeys.refreshToken.forEach((key) => this.removeItem(key));
11552
+ // Clean up anything left
11553
+ this.getKeys().forEach((cacheKey) => {
11554
+ if (cacheKey.startsWith(Constants.CACHE_PREFIX) ||
11555
+ cacheKey.indexOf(this.clientId) !== -1) {
11556
+ this.removeItem(cacheKey);
11557
+ }
11558
+ });
11559
+ }
11560
+ /**
11561
+ * Helper to decrypt all known MSAL keys in localStorage and save them to inMemory storage
11562
+ * @returns
11563
+ */
11564
+ async importExistingCache() {
11565
+ if (!this.encryptionCookie) {
11566
+ return;
11567
+ }
11568
+ const accountKeys = getAccountKeys(this);
11569
+ await this.importArray(accountKeys);
11570
+ const tokenKeys = getTokenKeys(this.clientId, this);
11571
+ await Promise.all([
11572
+ this.importArray(tokenKeys.idToken),
11573
+ this.importArray(tokenKeys.accessToken),
11574
+ this.importArray(tokenKeys.refreshToken),
11575
+ ]);
11576
+ }
11577
+ /**
11578
+ * Helper to decrypt and save cache entries
11579
+ * @param key
11580
+ * @returns
11581
+ */
11582
+ async getItemFromEncryptedCache(key) {
11583
+ if (!this.encryptionCookie) {
11584
+ return null;
11585
+ }
11586
+ const rawCache = this.getItem(key);
11587
+ if (!rawCache) {
11588
+ return null;
11589
+ }
11590
+ let encObj;
11591
+ try {
11592
+ encObj = JSON.parse(rawCache);
11593
+ if (!encObj.id || !encObj.nonce || !encObj.data) {
11594
+ throw "Not encrypted!"; // TODO: Typed error
11595
+ }
11596
+ if (encObj.id !== this.encryptionCookie.id) {
11597
+ throw "Old item!"; // TODO: Typed error
11598
+ }
11599
+ }
11600
+ catch (e) {
11601
+ // Not a valid encrypted object, remove
11602
+ this.removeItem(key);
11603
+ // TODO: Log to telemetry
11604
+ return null;
11605
+ }
11606
+ return decrypt(this.encryptionCookie.key, encObj.nonce, this.getContext(key), encObj.data);
11607
+ }
11608
+ /**
11609
+ * Helper to decrypt and save an array of cache keys
11610
+ * @param arr
11611
+ */
11612
+ async importArray(arr) {
11613
+ const promiseArr = [];
11614
+ arr.forEach((key) => {
11615
+ const promise = this.getItemFromEncryptedCache(key).then((value) => {
11616
+ if (value) {
11617
+ this.memoryStorage.setItem(key, value);
11618
+ }
11619
+ });
11620
+ promiseArr.push(promise);
11621
+ });
11622
+ await Promise.all(promiseArr);
11623
+ }
11624
+ /**
11625
+ * Gets encryption context for a given cache entry. This is clientId for app specific entries, empty string for shared entries
11626
+ * @param key
11627
+ * @returns
11628
+ */
11629
+ getContext(key) {
11630
+ let context = "";
11631
+ if (key.includes(this.clientId)) {
11632
+ context = this.clientId; // Used to bind encryption key to this appId
11633
+ }
11634
+ return context;
11336
11635
  }
11337
- validateWindowStorage(cacheLocation) {
11338
- if ((cacheLocation !== BrowserCacheLocation.LocalStorage &&
11339
- cacheLocation !== BrowserCacheLocation.SessionStorage) ||
11340
- !window[cacheLocation]) {
11636
+ }
11637
+
11638
+ /*
11639
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11640
+ * Licensed under the MIT License.
11641
+ */
11642
+ class SessionStorage {
11643
+ constructor() {
11644
+ if (!window.sessionStorage) {
11341
11645
  throw createBrowserConfigurationAuthError(storageNotSupported);
11342
11646
  }
11343
11647
  }
11648
+ async initialize() {
11649
+ // Session storage does not require initialization
11650
+ }
11344
11651
  getItem(key) {
11345
- return this.windowStorage.getItem(key);
11652
+ return window.sessionStorage.getItem(key);
11653
+ }
11654
+ getUserData(key) {
11655
+ return this.getItem(key);
11346
11656
  }
11347
11657
  setItem(key, value) {
11348
- this.windowStorage.setItem(key, value);
11658
+ window.sessionStorage.setItem(key, value);
11659
+ }
11660
+ async setUserData(key, value) {
11661
+ this.setItem(key, value);
11349
11662
  }
11350
11663
  removeItem(key) {
11351
- this.windowStorage.removeItem(key);
11664
+ window.sessionStorage.removeItem(key);
11352
11665
  }
11353
11666
  getKeys() {
11354
- return Object.keys(this.windowStorage);
11667
+ return Object.keys(window.sessionStorage);
11355
11668
  }
11356
11669
  containsKey(key) {
11357
- return this.windowStorage.hasOwnProperty(key);
11670
+ return window.sessionStorage.hasOwnProperty(key);
11358
11671
  }
11359
11672
  }
11360
11673
 
@@ -11392,180 +11705,39 @@
11392
11705
  class BrowserCacheManager extends CacheManager {
11393
11706
  constructor(clientId, cacheConfig, cryptoImpl, logger, staticAuthorityOptions, performanceClient) {
11394
11707
  super(clientId, cryptoImpl, logger, staticAuthorityOptions);
11395
- // Cookie life calculation (hours * minutes * seconds * ms)
11396
- this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11397
11708
  this.cacheConfig = cacheConfig;
11398
11709
  this.logger = logger;
11399
11710
  this.internalStorage = new MemoryStorage();
11400
11711
  this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);
11401
- this.temporaryCacheStorage = this.setupTemporaryCacheStorage(this.cacheConfig.temporaryCacheLocation, this.cacheConfig.cacheLocation);
11402
- // Migrate cache entries from older versions of MSAL.
11403
- if (cacheConfig.cacheMigrationEnabled) {
11404
- this.migrateCacheEntries();
11405
- this.createKeyMaps();
11406
- }
11712
+ this.temporaryCacheStorage = this.setupBrowserStorage(this.cacheConfig.temporaryCacheLocation);
11713
+ this.cookieStorage = new CookieStorage();
11407
11714
  this.performanceClient = performanceClient;
11408
11715
  }
11716
+ async initialize() {
11717
+ await this.browserStorage.initialize();
11718
+ }
11409
11719
  /**
11410
11720
  * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
11411
11721
  * @param cacheLocation
11412
11722
  */
11413
11723
  setupBrowserStorage(cacheLocation) {
11414
- switch (cacheLocation) {
11415
- case BrowserCacheLocation.LocalStorage:
11416
- case BrowserCacheLocation.SessionStorage:
11417
- try {
11418
- return new BrowserStorage(cacheLocation);
11419
- }
11420
- catch (e) {
11421
- this.logger.verbose(e);
11724
+ try {
11725
+ switch (cacheLocation) {
11726
+ case BrowserCacheLocation.LocalStorage:
11727
+ return new LocalStorage(this.clientId);
11728
+ case BrowserCacheLocation.SessionStorage:
11729
+ return new SessionStorage();
11730
+ case BrowserCacheLocation.MemoryStorage:
11731
+ default:
11422
11732
  break;
11423
- }
11424
- case BrowserCacheLocation.MemoryStorage:
11733
+ }
11734
+ }
11735
+ catch (e) {
11736
+ this.logger.error(e);
11425
11737
  }
11426
11738
  this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
11427
11739
  return new MemoryStorage();
11428
11740
  }
11429
- /**
11430
- * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured temporaryCacheLocation.
11431
- * @param temporaryCacheLocation
11432
- * @param cacheLocation
11433
- */
11434
- setupTemporaryCacheStorage(temporaryCacheLocation, cacheLocation) {
11435
- switch (cacheLocation) {
11436
- case BrowserCacheLocation.LocalStorage:
11437
- case BrowserCacheLocation.SessionStorage:
11438
- try {
11439
- // Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
11440
- return new BrowserStorage(temporaryCacheLocation ||
11441
- BrowserCacheLocation.SessionStorage);
11442
- }
11443
- catch (e) {
11444
- this.logger.verbose(e);
11445
- return this.internalStorage;
11446
- }
11447
- case BrowserCacheLocation.MemoryStorage:
11448
- default:
11449
- return this.internalStorage;
11450
- }
11451
- }
11452
- /**
11453
- * Migrate all old cache entries to new schema. No rollback supported.
11454
- * @param storeAuthStateInCookie
11455
- */
11456
- migrateCacheEntries() {
11457
- const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
11458
- const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
11459
- const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
11460
- const errorDescKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR_DESC}`;
11461
- const idTokenValue = this.browserStorage.getItem(idTokenKey);
11462
- const clientInfoValue = this.browserStorage.getItem(clientInfoKey);
11463
- const errorValue = this.browserStorage.getItem(errorKey);
11464
- const errorDescValue = this.browserStorage.getItem(errorDescKey);
11465
- const values = [
11466
- idTokenValue,
11467
- clientInfoValue,
11468
- errorValue,
11469
- errorDescValue,
11470
- ];
11471
- const keysToMigrate = [
11472
- PersistentCacheKeys.ID_TOKEN,
11473
- PersistentCacheKeys.CLIENT_INFO,
11474
- PersistentCacheKeys.ERROR,
11475
- PersistentCacheKeys.ERROR_DESC,
11476
- ];
11477
- keysToMigrate.forEach((cacheKey, index) => {
11478
- const value = values[index];
11479
- if (value) {
11480
- this.setTemporaryCache(cacheKey, value, true);
11481
- }
11482
- });
11483
- }
11484
- /**
11485
- * Searches all cache entries for MSAL accounts and creates the account key map
11486
- * This is used to migrate users from older versions of MSAL which did not create the map.
11487
- * @returns
11488
- */
11489
- createKeyMaps() {
11490
- this.logger.trace("BrowserCacheManager - createKeyMaps called.");
11491
- const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
11492
- const tokenKeys = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
11493
- if (accountKeys && tokenKeys) {
11494
- this.logger.verbose("BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.");
11495
- // Key maps already exist, no need to iterate through cache
11496
- return;
11497
- }
11498
- const allKeys = this.browserStorage.getKeys();
11499
- allKeys.forEach((key) => {
11500
- if (this.isCredentialKey(key)) {
11501
- // Get item, parse, validate and write key to map
11502
- const value = this.getItem(key);
11503
- if (value) {
11504
- const credObj = this.validateAndParseJson(value);
11505
- if (credObj && credObj.hasOwnProperty("credentialType")) {
11506
- switch (credObj["credentialType"]) {
11507
- case CredentialType.ID_TOKEN:
11508
- if (isIdTokenEntity(credObj)) {
11509
- this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
11510
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`);
11511
- const idTokenEntity = credObj;
11512
- const newKey = this.updateCredentialCacheKey(key, idTokenEntity);
11513
- this.addTokenKey(newKey, CredentialType.ID_TOKEN);
11514
- return;
11515
- }
11516
- else {
11517
- this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping.");
11518
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed idToken validation on key: ${key}`);
11519
- }
11520
- break;
11521
- case CredentialType.ACCESS_TOKEN:
11522
- case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
11523
- if (isAccessTokenEntity(credObj)) {
11524
- this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
11525
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`);
11526
- const accessTokenEntity = credObj;
11527
- const newKey = this.updateCredentialCacheKey(key, accessTokenEntity);
11528
- this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
11529
- return;
11530
- }
11531
- else {
11532
- this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping.");
11533
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed accessToken validation on key: ${key}`);
11534
- }
11535
- break;
11536
- case CredentialType.REFRESH_TOKEN:
11537
- if (isRefreshTokenEntity(credObj)) {
11538
- this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
11539
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`);
11540
- const refreshTokenEntity = credObj;
11541
- const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity);
11542
- this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
11543
- return;
11544
- }
11545
- else {
11546
- this.logger.trace("BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping.");
11547
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: ${key}`);
11548
- }
11549
- break;
11550
- // If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
11551
- }
11552
- }
11553
- }
11554
- }
11555
- if (this.isAccountKey(key)) {
11556
- const value = this.getItem(key);
11557
- if (value) {
11558
- const accountObj = this.validateAndParseJson(value);
11559
- if (accountObj &&
11560
- AccountEntity.isAccountEntity(accountObj)) {
11561
- this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
11562
- this.logger.tracePii(`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`);
11563
- this.addAccountKeyToMap(key);
11564
- }
11565
- }
11566
- }
11567
- });
11568
- }
11569
11741
  /**
11570
11742
  * Parses passed value as JSON object, JSON.parse() will throw an error.
11571
11743
  * @param input
@@ -11587,38 +11759,15 @@
11587
11759
  return null;
11588
11760
  }
11589
11761
  }
11590
- /**
11591
- * fetches the entry from the browser storage based off the key
11592
- * @param key
11593
- */
11594
- getItem(key) {
11595
- return this.browserStorage.getItem(key);
11596
- }
11597
- /**
11598
- * sets the entry in the browser storage
11599
- * @param key
11600
- * @param value
11601
- */
11602
- setItem(key, value) {
11603
- this.browserStorage.setItem(key, value);
11604
- }
11605
- /**
11606
- * fetch the account entity from the platform cache
11607
- * @param accountKey
11608
- */
11609
- getAccount(accountKey, logger) {
11610
- this.logger.trace("BrowserCacheManager.getAccount called");
11611
- const accountEntity = this.getCachedAccountEntity(accountKey);
11612
- return this.updateOutdatedCachedAccount(accountKey, accountEntity, logger);
11613
- }
11614
11762
  /**
11615
11763
  * Reads account from cache, deserializes it into an account entity and returns it.
11616
11764
  * If account is not found from the key, returns null and removes key from map.
11617
11765
  * @param accountKey
11618
11766
  * @returns
11619
11767
  */
11620
- getCachedAccountEntity(accountKey) {
11621
- const serializedAccount = this.getItem(accountKey);
11768
+ getAccount(accountKey) {
11769
+ this.logger.trace("BrowserCacheManager.getAccount called");
11770
+ const serializedAccount = this.browserStorage.getUserData(accountKey);
11622
11771
  if (!serializedAccount) {
11623
11772
  this.removeAccountKeyFromMap(accountKey);
11624
11773
  return null;
@@ -11634,10 +11783,10 @@
11634
11783
  * set account entity in the platform cache
11635
11784
  * @param account
11636
11785
  */
11637
- setAccount(account) {
11786
+ async setAccount(account) {
11638
11787
  this.logger.trace("BrowserCacheManager.setAccount called");
11639
11788
  const key = account.generateAccountKey();
11640
- this.setItem(key, JSON.stringify(account));
11789
+ await this.browserStorage.setUserData(key, JSON.stringify(account));
11641
11790
  this.addAccountKeyToMap(key);
11642
11791
  }
11643
11792
  /**
@@ -11645,13 +11794,7 @@
11645
11794
  * @returns
11646
11795
  */
11647
11796
  getAccountKeys() {
11648
- this.logger.trace("BrowserCacheManager.getAccountKeys called");
11649
- const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
11650
- if (accountKeys) {
11651
- return JSON.parse(accountKeys);
11652
- }
11653
- this.logger.verbose("BrowserCacheManager.getAccountKeys - No account keys found");
11654
- return [];
11797
+ return getAccountKeys(this.browserStorage);
11655
11798
  }
11656
11799
  /**
11657
11800
  * Add a new account to the key map
@@ -11664,7 +11807,7 @@
11664
11807
  if (accountKeys.indexOf(key) === -1) {
11665
11808
  // Only add key if it does not already exist in the map
11666
11809
  accountKeys.push(key);
11667
- this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11810
+ this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11668
11811
  this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
11669
11812
  }
11670
11813
  else {
@@ -11682,7 +11825,7 @@
11682
11825
  const removalIndex = accountKeys.indexOf(key);
11683
11826
  if (removalIndex > -1) {
11684
11827
  accountKeys.splice(removalIndex, 1);
11685
- this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11828
+ this.browserStorage.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11686
11829
  this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
11687
11830
  }
11688
11831
  else {
@@ -11697,14 +11840,6 @@
11697
11840
  void super.removeAccount(key);
11698
11841
  this.removeAccountKeyFromMap(key);
11699
11842
  }
11700
- /**
11701
- * Remove account entity from the platform cache if it's outdated
11702
- * @param accountKey
11703
- */
11704
- removeOutdatedAccount(accountKey) {
11705
- this.removeItem(accountKey);
11706
- this.removeAccountKeyFromMap(accountKey);
11707
- }
11708
11843
  /**
11709
11844
  * Removes given idToken from the cache and from the key map
11710
11845
  * @param key
@@ -11734,28 +11869,7 @@
11734
11869
  * @returns
11735
11870
  */
11736
11871
  getTokenKeys() {
11737
- this.logger.trace("BrowserCacheManager.getTokenKeys called");
11738
- const item = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
11739
- if (item) {
11740
- const tokenKeys = this.validateAndParseJson(item);
11741
- if (tokenKeys &&
11742
- tokenKeys.hasOwnProperty("idToken") &&
11743
- tokenKeys.hasOwnProperty("accessToken") &&
11744
- tokenKeys.hasOwnProperty("refreshToken")) {
11745
- return tokenKeys;
11746
- }
11747
- else {
11748
- this.logger.error("BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map.");
11749
- }
11750
- }
11751
- else {
11752
- this.logger.verbose("BrowserCacheManager.getTokenKeys - No token keys found");
11753
- }
11754
- return {
11755
- idToken: [],
11756
- accessToken: [],
11757
- refreshToken: [],
11758
- };
11872
+ return getTokenKeys(this.clientId, this.browserStorage);
11759
11873
  }
11760
11874
  /**
11761
11875
  * Adds the given key to the token key map
@@ -11788,7 +11902,7 @@
11788
11902
  this.logger.error(`BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
11789
11903
  throw createClientAuthError(unexpectedCredentialType);
11790
11904
  }
11791
- this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11905
+ this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11792
11906
  }
11793
11907
  /**
11794
11908
  * Removes the given key from the token key map
@@ -11836,14 +11950,14 @@
11836
11950
  this.logger.error(`BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
11837
11951
  throw createClientAuthError(unexpectedCredentialType);
11838
11952
  }
11839
- this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11953
+ this.browserStorage.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11840
11954
  }
11841
11955
  /**
11842
11956
  * generates idToken entity from a string
11843
11957
  * @param idTokenKey
11844
11958
  */
11845
11959
  getIdTokenCredential(idTokenKey) {
11846
- const value = this.getItem(idTokenKey);
11960
+ const value = this.browserStorage.getUserData(idTokenKey);
11847
11961
  if (!value) {
11848
11962
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
11849
11963
  this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
@@ -11862,10 +11976,10 @@
11862
11976
  * set IdToken credential to the platform cache
11863
11977
  * @param idToken
11864
11978
  */
11865
- setIdTokenCredential(idToken) {
11979
+ async setIdTokenCredential(idToken) {
11866
11980
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
11867
11981
  const idTokenKey = generateCredentialKey(idToken);
11868
- this.setItem(idTokenKey, JSON.stringify(idToken));
11982
+ await this.browserStorage.setUserData(idTokenKey, JSON.stringify(idToken));
11869
11983
  this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
11870
11984
  }
11871
11985
  /**
@@ -11873,7 +11987,7 @@
11873
11987
  * @param key
11874
11988
  */
11875
11989
  getAccessTokenCredential(accessTokenKey) {
11876
- const value = this.getItem(accessTokenKey);
11990
+ const value = this.browserStorage.getUserData(accessTokenKey);
11877
11991
  if (!value) {
11878
11992
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
11879
11993
  this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
@@ -11893,10 +12007,10 @@
11893
12007
  * set accessToken credential to the platform cache
11894
12008
  * @param accessToken
11895
12009
  */
11896
- setAccessTokenCredential(accessToken) {
12010
+ async setAccessTokenCredential(accessToken) {
11897
12011
  this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
11898
12012
  const accessTokenKey = generateCredentialKey(accessToken);
11899
- this.setItem(accessTokenKey, JSON.stringify(accessToken));
12013
+ await this.browserStorage.setUserData(accessTokenKey, JSON.stringify(accessToken));
11900
12014
  this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
11901
12015
  }
11902
12016
  /**
@@ -11904,7 +12018,7 @@
11904
12018
  * @param refreshTokenKey
11905
12019
  */
11906
12020
  getRefreshTokenCredential(refreshTokenKey) {
11907
- const value = this.getItem(refreshTokenKey);
12021
+ const value = this.browserStorage.getUserData(refreshTokenKey);
11908
12022
  if (!value) {
11909
12023
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
11910
12024
  this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
@@ -11924,10 +12038,10 @@
11924
12038
  * set refreshToken credential to the platform cache
11925
12039
  * @param refreshToken
11926
12040
  */
11927
- setRefreshTokenCredential(refreshToken) {
12041
+ async setRefreshTokenCredential(refreshToken) {
11928
12042
  this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
11929
12043
  const refreshTokenKey = generateCredentialKey(refreshToken);
11930
- this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
12044
+ await this.browserStorage.setUserData(refreshTokenKey, JSON.stringify(refreshToken));
11931
12045
  this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
11932
12046
  }
11933
12047
  /**
@@ -11935,7 +12049,7 @@
11935
12049
  * @param appMetadataKey
11936
12050
  */
11937
12051
  getAppMetadata(appMetadataKey) {
11938
- const value = this.getItem(appMetadataKey);
12052
+ const value = this.browserStorage.getItem(appMetadataKey);
11939
12053
  if (!value) {
11940
12054
  this.logger.trace("BrowserCacheManager.getAppMetadata: called, no cache hit");
11941
12055
  return null;
@@ -11956,14 +12070,14 @@
11956
12070
  setAppMetadata(appMetadata) {
11957
12071
  this.logger.trace("BrowserCacheManager.setAppMetadata called");
11958
12072
  const appMetadataKey = generateAppMetadataKey(appMetadata);
11959
- this.setItem(appMetadataKey, JSON.stringify(appMetadata));
12073
+ this.browserStorage.setItem(appMetadataKey, JSON.stringify(appMetadata));
11960
12074
  }
11961
12075
  /**
11962
12076
  * fetch server telemetry entity from the platform cache
11963
12077
  * @param serverTelemetryKey
11964
12078
  */
11965
12079
  getServerTelemetry(serverTelemetryKey) {
11966
- const value = this.getItem(serverTelemetryKey);
12080
+ const value = this.browserStorage.getItem(serverTelemetryKey);
11967
12081
  if (!value) {
11968
12082
  this.logger.trace("BrowserCacheManager.getServerTelemetry: called, no cache hit");
11969
12083
  return null;
@@ -11984,7 +12098,7 @@
11984
12098
  */
11985
12099
  setServerTelemetry(serverTelemetryKey, serverTelemetry) {
11986
12100
  this.logger.trace("BrowserCacheManager.setServerTelemetry called");
11987
- this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
12101
+ this.browserStorage.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
11988
12102
  }
11989
12103
  /**
11990
12104
  *
@@ -12044,25 +12158,9 @@
12044
12158
  */
12045
12159
  getActiveAccount() {
12046
12160
  const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
12047
- const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
12161
+ const activeAccountValueFilters = this.browserStorage.getItem(activeAccountKeyFilters);
12048
12162
  if (!activeAccountValueFilters) {
12049
- // if new active account cache type isn't found, it's an old version, so look for that instead
12050
- this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema");
12051
- const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
12052
- const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
12053
- if (!activeAccountValueLocal) {
12054
- this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
12055
- return null;
12056
- }
12057
- const activeAccount = this.getAccountInfoFilteredBy({
12058
- localAccountId: activeAccountValueLocal,
12059
- });
12060
- if (activeAccount) {
12061
- this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
12062
- this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
12063
- this.setActiveAccount(activeAccount);
12064
- return activeAccount;
12065
- }
12163
+ this.logger.trace("BrowserCacheManager.getActiveAccount: No active account filters found");
12066
12164
  return null;
12067
12165
  }
12068
12166
  const activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
@@ -12083,7 +12181,6 @@
12083
12181
  */
12084
12182
  setActiveAccount(account) {
12085
12183
  const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
12086
- const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
12087
12184
  if (account) {
12088
12185
  this.logger.verbose("setActiveAccount: Active account set");
12089
12186
  const activeAccountValue = {
@@ -12092,12 +12189,10 @@
12092
12189
  tenantId: account.tenantId,
12093
12190
  };
12094
12191
  this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
12095
- this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
12096
12192
  }
12097
12193
  else {
12098
12194
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
12099
12195
  this.browserStorage.removeItem(activeAccountKey);
12100
- this.browserStorage.removeItem(activeAccountKeyLocal);
12101
12196
  }
12102
12197
  }
12103
12198
  /**
@@ -12105,7 +12200,7 @@
12105
12200
  * @param throttlingCacheKey
12106
12201
  */
12107
12202
  getThrottlingCache(throttlingCacheKey) {
12108
- const value = this.getItem(throttlingCacheKey);
12203
+ const value = this.browserStorage.getItem(throttlingCacheKey);
12109
12204
  if (!value) {
12110
12205
  this.logger.trace("BrowserCacheManager.getThrottlingCache: called, no cache hit");
12111
12206
  return null;
@@ -12126,7 +12221,7 @@
12126
12221
  */
12127
12222
  setThrottlingCache(throttlingCacheKey, throttlingCache) {
12128
12223
  this.logger.trace("BrowserCacheManager.setThrottlingCache called");
12129
- this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
12224
+ this.browserStorage.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
12130
12225
  }
12131
12226
  /**
12132
12227
  * Gets cache item with given key.
@@ -12136,7 +12231,7 @@
12136
12231
  getTemporaryCache(cacheKey, generateKey) {
12137
12232
  const key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;
12138
12233
  if (this.cacheConfig.storeAuthStateInCookie) {
12139
- const itemCookie = this.getItemCookie(key);
12234
+ const itemCookie = this.cookieStorage.getItem(key);
12140
12235
  if (itemCookie) {
12141
12236
  this.logger.trace("BrowserCacheManager.getTemporaryCache: storeAuthStateInCookies set to true, retrieving from cookies");
12142
12237
  return itemCookie;
@@ -12171,7 +12266,7 @@
12171
12266
  this.temporaryCacheStorage.setItem(key, value);
12172
12267
  if (this.cacheConfig.storeAuthStateInCookie) {
12173
12268
  this.logger.trace("BrowserCacheManager.setTemporaryCache: storeAuthStateInCookie set to true, setting item cookie");
12174
- this.setItemCookie(key, value);
12269
+ this.cookieStorage.setItem(key, value, undefined, this.cacheConfig.secureCookies);
12175
12270
  }
12176
12271
  }
12177
12272
  /**
@@ -12190,7 +12285,7 @@
12190
12285
  this.temporaryCacheStorage.removeItem(key);
12191
12286
  if (this.cacheConfig.storeAuthStateInCookie) {
12192
12287
  this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
12193
- this.clearItemCookie(key);
12288
+ this.cookieStorage.removeItem(key);
12194
12289
  }
12195
12290
  }
12196
12291
  /**
@@ -12246,79 +12341,6 @@
12246
12341
  this.logger.warning(`${removedAccessTokens.length} access tokens with claims in the cache keys have been removed from the cache.`);
12247
12342
  }
12248
12343
  }
12249
- /**
12250
- * Add value to cookies
12251
- * @param cookieName
12252
- * @param cookieValue
12253
- * @param expires
12254
- * @deprecated
12255
- */
12256
- setItemCookie(cookieName, cookieValue, expires) {
12257
- let cookieStr = `${encodeURIComponent(cookieName)}=${encodeURIComponent(cookieValue)};path=/;SameSite=Lax;`;
12258
- if (expires) {
12259
- const expireTime = this.getCookieExpirationTime(expires);
12260
- cookieStr += `expires=${expireTime};`;
12261
- }
12262
- if (this.cacheConfig.secureCookies) {
12263
- cookieStr += "Secure;";
12264
- }
12265
- document.cookie = cookieStr;
12266
- }
12267
- /**
12268
- * Get one item by key from cookies
12269
- * @param cookieName
12270
- * @deprecated
12271
- */
12272
- getItemCookie(cookieName) {
12273
- const name = `${encodeURIComponent(cookieName)}=`;
12274
- const cookieList = document.cookie.split(";");
12275
- for (let i = 0; i < cookieList.length; i++) {
12276
- let cookie = cookieList[i];
12277
- while (cookie.charAt(0) === " ") {
12278
- cookie = cookie.substring(1);
12279
- }
12280
- if (cookie.indexOf(name) === 0) {
12281
- return decodeURIComponent(cookie.substring(name.length, cookie.length));
12282
- }
12283
- }
12284
- return Constants.EMPTY_STRING;
12285
- }
12286
- /**
12287
- * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
12288
- * @deprecated
12289
- */
12290
- clearMsalCookies() {
12291
- const cookiePrefix = `${Constants.CACHE_PREFIX}.${this.clientId}`;
12292
- const cookieList = document.cookie.split(";");
12293
- cookieList.forEach((cookie) => {
12294
- while (cookie.charAt(0) === " ") {
12295
- // eslint-disable-next-line no-param-reassign
12296
- cookie = cookie.substring(1);
12297
- }
12298
- if (cookie.indexOf(cookiePrefix) === 0) {
12299
- const cookieKey = cookie.split("=")[0];
12300
- this.clearItemCookie(cookieKey);
12301
- }
12302
- });
12303
- }
12304
- /**
12305
- * Clear an item in the cookies by key
12306
- * @param cookieName
12307
- * @deprecated
12308
- */
12309
- clearItemCookie(cookieName) {
12310
- this.setItemCookie(cookieName, Constants.EMPTY_STRING, -1);
12311
- }
12312
- /**
12313
- * Get cookie expiration time
12314
- * @param cookieLifeDays
12315
- * @deprecated
12316
- */
12317
- getCookieExpirationTime(cookieLifeDays) {
12318
- const today = new Date();
12319
- const expr = new Date(today.getTime() + cookieLifeDays * this.COOKIE_LIFE_MULTIPLIER);
12320
- return expr.toUTCString();
12321
- }
12322
12344
  /**
12323
12345
  * Prepend msal.<client-id> to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)
12324
12346
  * @param key
@@ -12327,8 +12349,7 @@
12327
12349
  generateCacheKey(key) {
12328
12350
  const generatedKey = this.validateAndParseJson(key);
12329
12351
  if (!generatedKey) {
12330
- if (StringUtils.startsWith(key, Constants.CACHE_PREFIX) ||
12331
- StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)) {
12352
+ if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)) {
12332
12353
  return key;
12333
12354
  }
12334
12355
  return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;
@@ -12442,7 +12463,6 @@
12442
12463
  this.logger.infoPii(`BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: ${cachedState}`);
12443
12464
  this.resetRequestCache(cachedState || Constants.EMPTY_STRING);
12444
12465
  }
12445
- this.clearMsalCookies();
12446
12466
  }
12447
12467
  /**
12448
12468
  * Looks in temporary cache for any state values with the provided interactionType and removes all temporary cache items for that state
@@ -12470,7 +12490,6 @@
12470
12490
  this.resetRequestCache(stateValue);
12471
12491
  }
12472
12492
  });
12473
- this.clearMsalCookies();
12474
12493
  this.setInteractionInProgress(false);
12475
12494
  }
12476
12495
  cacheCodeRequest(authCodeRequest) {
@@ -12556,59 +12575,6 @@
12556
12575
  this.removeTemporaryItem(key);
12557
12576
  }
12558
12577
  }
12559
- /**
12560
- * Returns username retrieved from ADAL or MSAL v1 idToken
12561
- * @deprecated
12562
- */
12563
- getLegacyLoginHint() {
12564
- // Only check for adal/msal token if no SSO params are being used
12565
- const adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
12566
- if (adalIdTokenString) {
12567
- this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
12568
- this.logger.verbose("Cached ADAL id token retrieved.");
12569
- }
12570
- // Check for cached MSAL v1 id token
12571
- const msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
12572
- if (msalIdTokenString) {
12573
- this.browserStorage.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
12574
- this.logger.verbose("Cached MSAL.js v1 id token retrieved");
12575
- }
12576
- const cachedIdTokenString = msalIdTokenString || adalIdTokenString;
12577
- if (cachedIdTokenString) {
12578
- const idTokenClaims = extractTokenClaims(cachedIdTokenString, base64Decode);
12579
- if (idTokenClaims.preferred_username) {
12580
- this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
12581
- return idTokenClaims.preferred_username;
12582
- }
12583
- else if (idTokenClaims.upn) {
12584
- this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
12585
- return idTokenClaims.upn;
12586
- }
12587
- else {
12588
- 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.");
12589
- }
12590
- }
12591
- return null;
12592
- }
12593
- /**
12594
- * Updates a credential's cache key if the current cache key is outdated
12595
- */
12596
- updateCredentialCacheKey(currentCacheKey, credential) {
12597
- const updatedCacheKey = generateCredentialKey(credential);
12598
- if (currentCacheKey !== updatedCacheKey) {
12599
- const cacheItem = this.getItem(currentCacheKey);
12600
- if (cacheItem) {
12601
- this.browserStorage.removeItem(currentCacheKey);
12602
- this.setItem(updatedCacheKey, cacheItem);
12603
- this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
12604
- return updatedCacheKey;
12605
- }
12606
- else {
12607
- this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`);
12608
- }
12609
- }
12610
- return currentCacheKey;
12611
- }
12612
12578
  /**
12613
12579
  * Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
12614
12580
  * @param result
@@ -13325,19 +13291,16 @@
13325
13291
  responseMode: this.config.auth.OIDCOptions
13326
13292
  .serverResponseType,
13327
13293
  };
13294
+ // Skip active account lookup if either login hint or session id is set
13295
+ if (request.loginHint || request.sid) {
13296
+ return validatedRequest;
13297
+ }
13328
13298
  const account = request.account || this.browserStorage.getActiveAccount();
13329
13299
  if (account) {
13330
13300
  this.logger.verbose("Setting validated request account", this.correlationId);
13331
13301
  this.logger.verbosePii(`Setting validated request account: ${account.homeAccountId}`, this.correlationId);
13332
13302
  validatedRequest.account = account;
13333
13303
  }
13334
- // Check for ADAL/MSAL v1 SSO
13335
- if (!validatedRequest.loginHint && !account) {
13336
- const legacyLoginHint = this.browserStorage.getLegacyLoginHint();
13337
- if (legacyLoginHint) {
13338
- validatedRequest.loginHint = legacyLoginHint;
13339
- }
13340
- }
13341
13304
  return validatedRequest;
13342
13305
  }
13343
13306
  }
@@ -13741,7 +13704,7 @@
13741
13704
  // generate authenticationResult
13742
13705
  const result = await this.generateAuthenticationResult(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
13743
13706
  // cache accounts and tokens in the appropriate storage
13744
- this.cacheAccount(baseAccount);
13707
+ await this.cacheAccount(baseAccount);
13745
13708
  this.cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, response.access_token, result.tenantId, reqTimestamp);
13746
13709
  return result;
13747
13710
  }
@@ -13866,9 +13829,9 @@
13866
13829
  * cache the account entity in browser storage
13867
13830
  * @param accountEntity
13868
13831
  */
13869
- cacheAccount(accountEntity) {
13832
+ async cacheAccount(accountEntity) {
13870
13833
  // Store the account info and hence `nativeAccountId` in browser cache
13871
- this.browserStorage.setAccount(accountEntity);
13834
+ await this.browserStorage.setAccount(accountEntity);
13872
13835
  // Remove any existing cached tokens for this account in browser storage
13873
13836
  this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
13874
13837
  this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
@@ -15746,7 +15709,7 @@
15746
15709
  * @param options
15747
15710
  * @returns `AuthenticationResult` for the response that was loaded.
15748
15711
  */
15749
- loadExternalTokens(request, response, options) {
15712
+ async loadExternalTokens(request, response, options) {
15750
15713
  if (!this.isBrowserEnvironment) {
15751
15714
  throw createBrowserAuthError(nonBrowserEnvironment);
15752
15715
  }
@@ -15763,10 +15726,10 @@
15763
15726
  const authority = request.authority
15764
15727
  ? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
15765
15728
  : undefined;
15766
- const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
15767
- const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
15768
- const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
15769
- const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
15729
+ const cacheRecordAccount = await this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
15730
+ const idToken = await this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
15731
+ const accessToken = await this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
15732
+ const refreshToken = await this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
15770
15733
  return this.generateAuthenticationResult(request, {
15771
15734
  account: cacheRecordAccount,
15772
15735
  idToken,
@@ -15783,11 +15746,11 @@
15783
15746
  * @param requestHomeAccountId
15784
15747
  * @returns `AccountEntity`
15785
15748
  */
15786
- loadAccount(request, clientInfo, idTokenClaims, authority) {
15749
+ async loadAccount(request, clientInfo, idTokenClaims, authority) {
15787
15750
  this.logger.verbose("TokenCache - loading account");
15788
15751
  if (request.account) {
15789
15752
  const accountEntity = AccountEntity.createFromAccountInfo(request.account);
15790
- this.storage.setAccount(accountEntity);
15753
+ await this.storage.setAccount(accountEntity);
15791
15754
  return accountEntity;
15792
15755
  }
15793
15756
  else if (!authority || (!clientInfo && !idTokenClaims)) {
@@ -15799,7 +15762,7 @@
15799
15762
  const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
15800
15763
  undefined, // nativeAccountId
15801
15764
  this.logger);
15802
- this.storage.setAccount(cachedAccount);
15765
+ await this.storage.setAccount(cachedAccount);
15803
15766
  return cachedAccount;
15804
15767
  }
15805
15768
  /**
@@ -15810,14 +15773,14 @@
15810
15773
  * @param tenantId
15811
15774
  * @returns `IdTokenEntity`
15812
15775
  */
15813
- loadIdToken(response, homeAccountId, environment, tenantId) {
15776
+ async loadIdToken(response, homeAccountId, environment, tenantId) {
15814
15777
  if (!response.id_token) {
15815
15778
  this.logger.verbose("TokenCache - no id token found in response");
15816
15779
  return null;
15817
15780
  }
15818
15781
  this.logger.verbose("TokenCache - loading id token");
15819
15782
  const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
15820
- this.storage.setIdTokenCredential(idTokenEntity);
15783
+ await this.storage.setIdTokenCredential(idTokenEntity);
15821
15784
  return idTokenEntity;
15822
15785
  }
15823
15786
  /**
@@ -15829,7 +15792,7 @@
15829
15792
  * @param tenantId
15830
15793
  * @returns `AccessTokenEntity`
15831
15794
  */
15832
- loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
15795
+ async loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
15833
15796
  if (!response.access_token) {
15834
15797
  this.logger.verbose("TokenCache - no access token found in response");
15835
15798
  return null;
@@ -15853,7 +15816,7 @@
15853
15816
  (response.ext_expires_in || response.expires_in) +
15854
15817
  new Date().getTime() / 1000;
15855
15818
  const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
15856
- this.storage.setAccessTokenCredential(accessTokenEntity);
15819
+ await this.storage.setAccessTokenCredential(accessTokenEntity);
15857
15820
  return accessTokenEntity;
15858
15821
  }
15859
15822
  /**
@@ -15864,7 +15827,7 @@
15864
15827
  * @param environment
15865
15828
  * @returns `RefreshTokenEntity`
15866
15829
  */
15867
- loadRefreshToken(response, homeAccountId, environment) {
15830
+ async loadRefreshToken(response, homeAccountId, environment) {
15868
15831
  if (!response.refresh_token) {
15869
15832
  this.logger.verbose("TokenCache - no refresh token found in response");
15870
15833
  return null;
@@ -15872,7 +15835,7 @@
15872
15835
  this.logger.verbose("TokenCache - loading refresh token");
15873
15836
  const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
15874
15837
  response.refresh_token_expires_in);
15875
- this.storage.setRefreshTokenCredential(refreshTokenEntity);
15838
+ await this.storage.setRefreshTokenCredential(refreshTokenEntity);
15876
15839
  return refreshTokenEntity;
15877
15840
  }
15878
15841
  /**
@@ -16121,6 +16084,7 @@
16121
16084
  this.eventHandler.emitEvent(EventType.INITIALIZE_END);
16122
16085
  return;
16123
16086
  }
16087
+ await this.browserStorage.initialize();
16124
16088
  const initCorrelationId = request?.correlationId || this.getRequestCorrelationId();
16125
16089
  const allowNativeBroker = this.config.system.allowNativeBroker;
16126
16090
  const initMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.InitializeClientApplication, initCorrelationId);
@@ -16846,7 +16810,7 @@
16846
16810
  this.logger.verbose("hydrateCache called");
16847
16811
  // Account gets saved to browser storage regardless of native or not
16848
16812
  const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
16849
- this.browserStorage.setAccount(accountEntity);
16813
+ await this.browserStorage.setAccount(accountEntity);
16850
16814
  if (result.fromNativeBroker) {
16851
16815
  this.logger.verbose("Response was from native broker, storing in-memory");
16852
16816
  // Tokens from native broker are stored in-memory
@@ -17647,8 +17611,8 @@
17647
17611
  * Specific implementation of initialize function for NestedAppAuthController
17648
17612
  * @returns
17649
17613
  */
17650
- initialize() {
17651
- // do nothing not required by this controller
17614
+ async initialize() {
17615
+ await this.browserStorage.initialize();
17652
17616
  return Promise.resolve();
17653
17617
  }
17654
17618
  /**
@@ -18074,7 +18038,7 @@
18074
18038
  async hydrateCache(result, request) {
18075
18039
  this.logger.verbose("hydrateCache called");
18076
18040
  const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
18077
- this.browserStorage.setAccount(accountEntity);
18041
+ await this.browserStorage.setAccount(accountEntity);
18078
18042
  return this.browserStorage.hydrateCache(result, request);
18079
18043
  }
18080
18044
  }
@@ -19619,7 +19583,6 @@
19619
19583
  exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
19620
19584
  exports.BrowserPerformanceClient = BrowserPerformanceClient;
19621
19585
  exports.BrowserPerformanceMeasurement = BrowserPerformanceMeasurement;
19622
- exports.BrowserStorage = BrowserStorage;
19623
19586
  exports.BrowserUtils = BrowserUtils;
19624
19587
  exports.CacheLookupPolicy = CacheLookupPolicy;
19625
19588
  exports.ClientAuthError = ClientAuthError;
@@ -19637,6 +19600,7 @@
19637
19600
  exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
19638
19601
  exports.InteractionStatus = InteractionStatus;
19639
19602
  exports.JsonWebTokenTypes = JsonWebTokenTypes;
19603
+ exports.LocalStorage = LocalStorage;
19640
19604
  exports.Logger = Logger;
19641
19605
  exports.MemoryStorage = MemoryStorage;
19642
19606
  exports.NavigationClient = NavigationClient;
@@ -19648,6 +19612,7 @@
19648
19612
  exports.PublicClientNext = PublicClientNext;
19649
19613
  exports.ServerError = ServerError;
19650
19614
  exports.ServerResponseType = ServerResponseType;
19615
+ exports.SessionStorage = SessionStorage;
19651
19616
  exports.SignedHttpRequest = SignedHttpRequest;
19652
19617
  exports.StringUtils = StringUtils;
19653
19618
  exports.StubPerformanceClient = StubPerformanceClient;