@azure/msal-browser 3.28.0 → 3.30.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 (143) 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.d.ts +7 -7
  7. package/dist/cache/AccountManager.d.ts.map +1 -1
  8. package/dist/cache/AccountManager.mjs +17 -15
  9. package/dist/cache/AccountManager.mjs.map +1 -1
  10. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  11. package/dist/cache/BrowserCacheManager.d.ts +35 -27
  12. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  13. package/dist/cache/BrowserCacheManager.mjs +187 -91
  14. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  15. package/dist/cache/BrowserStorage.mjs +1 -1
  16. package/dist/cache/CookieStorage.mjs +1 -1
  17. package/dist/cache/DatabaseStorage.mjs +1 -1
  18. package/dist/cache/LocalStorage.mjs +1 -1
  19. package/dist/cache/MemoryStorage.mjs +1 -1
  20. package/dist/cache/SessionStorage.mjs +1 -1
  21. package/dist/cache/TokenCache.d.ts.map +1 -1
  22. package/dist/cache/TokenCache.mjs +16 -15
  23. package/dist/cache/TokenCache.mjs.map +1 -1
  24. package/dist/config/Configuration.mjs +1 -1
  25. package/dist/controllers/ControllerFactory.mjs +1 -1
  26. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  27. package/dist/controllers/NestedAppAuthController.mjs +29 -19
  28. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  29. package/dist/controllers/StandardController.d.ts.map +1 -1
  30. package/dist/controllers/StandardController.mjs +16 -9
  31. package/dist/controllers/StandardController.mjs.map +1 -1
  32. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  33. package/dist/crypto/BrowserCrypto.d.ts +1 -1
  34. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  35. package/dist/crypto/BrowserCrypto.mjs +3 -3
  36. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  37. package/dist/crypto/CryptoOps.d.ts +1 -1
  38. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  39. package/dist/crypto/CryptoOps.mjs +3 -3
  40. package/dist/crypto/CryptoOps.mjs.map +1 -1
  41. package/dist/crypto/PkceGenerator.mjs +1 -1
  42. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  43. package/dist/encode/Base64Decode.mjs +1 -1
  44. package/dist/encode/Base64Encode.mjs +1 -1
  45. package/dist/error/BrowserAuthError.mjs +1 -1
  46. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  47. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  48. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  49. package/dist/error/NativeAuthError.mjs +1 -1
  50. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  51. package/dist/error/NestedAppAuthError.mjs +1 -1
  52. package/dist/event/EventHandler.mjs +1 -1
  53. package/dist/event/EventMessage.mjs +1 -1
  54. package/dist/event/EventType.mjs +1 -1
  55. package/dist/index.mjs +1 -1
  56. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  57. package/dist/interaction_client/BaseInteractionClient.mjs +5 -5
  58. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  59. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  60. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  61. package/dist/interaction_client/NativeInteractionClient.mjs +9 -7
  62. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  63. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  64. package/dist/interaction_client/PopupClient.mjs +2 -2
  65. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  66. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  67. package/dist/interaction_client/RedirectClient.mjs +2 -2
  68. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  69. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  70. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  71. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  72. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  73. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  74. package/dist/interaction_client/StandardInteractionClient.mjs +3 -2
  75. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  76. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  77. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  78. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  79. package/dist/naa/BridgeError.mjs +1 -1
  80. package/dist/naa/BridgeProxy.mjs +1 -1
  81. package/dist/naa/BridgeStatusCode.mjs +1 -1
  82. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  83. package/dist/navigation/NavigationClient.mjs +1 -1
  84. package/dist/network/FetchClient.mjs +1 -1
  85. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  86. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  87. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  88. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  89. package/dist/packageMetadata.d.ts +1 -1
  90. package/dist/packageMetadata.mjs +2 -2
  91. package/dist/request/RequestHelpers.mjs +1 -1
  92. package/dist/response/ResponseHandler.mjs +1 -1
  93. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  94. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  95. package/dist/utils/BrowserConstants.d.ts +1 -0
  96. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  97. package/dist/utils/BrowserConstants.mjs +2 -1
  98. package/dist/utils/BrowserConstants.mjs.map +1 -1
  99. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  100. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  101. package/dist/utils/BrowserUtils.mjs +4 -2
  102. package/dist/utils/BrowserUtils.mjs.map +1 -1
  103. package/lib/msal-browser.cjs +472 -349
  104. package/lib/msal-browser.cjs.map +1 -1
  105. package/lib/msal-browser.js +472 -349
  106. package/lib/msal-browser.js.map +1 -1
  107. package/lib/msal-browser.min.js +65 -66
  108. package/lib/types/cache/AccountManager.d.ts +7 -7
  109. package/lib/types/cache/AccountManager.d.ts.map +1 -1
  110. package/lib/types/cache/BrowserCacheManager.d.ts +35 -27
  111. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  112. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  113. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  114. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  115. package/lib/types/crypto/BrowserCrypto.d.ts +1 -1
  116. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  117. package/lib/types/crypto/CryptoOps.d.ts +1 -1
  118. package/lib/types/crypto/CryptoOps.d.ts.map +1 -1
  119. package/lib/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  120. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  121. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  122. package/lib/types/interaction_client/RedirectClient.d.ts.map +1 -1
  123. package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  124. package/lib/types/packageMetadata.d.ts +1 -1
  125. package/lib/types/utils/BrowserConstants.d.ts +1 -0
  126. package/lib/types/utils/BrowserConstants.d.ts.map +1 -1
  127. package/lib/types/utils/BrowserUtils.d.ts.map +1 -1
  128. package/package.json +3 -3
  129. package/src/cache/AccountManager.ts +40 -20
  130. package/src/cache/BrowserCacheManager.ts +332 -109
  131. package/src/cache/TokenCache.ts +25 -11
  132. package/src/controllers/NestedAppAuthController.ts +52 -19
  133. package/src/controllers/StandardController.ts +26 -7
  134. package/src/crypto/BrowserCrypto.ts +4 -2
  135. package/src/crypto/CryptoOps.ts +8 -2
  136. package/src/interaction_client/BaseInteractionClient.ts +5 -4
  137. package/src/interaction_client/NativeInteractionClient.ts +22 -12
  138. package/src/interaction_client/PopupClient.ts +2 -1
  139. package/src/interaction_client/RedirectClient.ts +2 -1
  140. package/src/interaction_client/StandardInteractionClient.ts +2 -1
  141. package/src/packageMetadata.ts +1 -1
  142. package/src/utils/BrowserConstants.ts +1 -0
  143. package/src/utils/BrowserUtils.ts +3 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v3.28.0 2024-12-12 */
1
+ /*! @azure/msal-browser v3.30.0 2025-08-05 */
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-12-12 */
9
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
10
10
  /*
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.
12
12
  * Licensed under the MIT License.
@@ -316,7 +316,7 @@
316
316
  // Token renewal offset default in seconds
317
317
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
318
318
 
319
- /*! @azure/msal-common v14.16.0 2024-12-12 */
319
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
320
320
  /*
321
321
  * Copyright (c) Microsoft Corporation. All rights reserved.
322
322
  * Licensed under the MIT License.
@@ -333,7 +333,7 @@
333
333
  unexpectedError: unexpectedError
334
334
  });
335
335
 
336
- /*! @azure/msal-common v14.16.0 2024-12-12 */
336
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
337
337
 
338
338
  /*
339
339
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -382,7 +382,7 @@
382
382
  : AuthErrorMessages[code]);
383
383
  }
384
384
 
385
- /*! @azure/msal-common v14.16.0 2024-12-12 */
385
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
386
386
  /*
387
387
  * Copyright (c) Microsoft Corporation. All rights reserved.
388
388
  * Licensed under the MIT License.
@@ -480,7 +480,7 @@
480
480
  userTimeoutReached: userTimeoutReached
481
481
  });
482
482
 
483
- /*! @azure/msal-common v14.16.0 2024-12-12 */
483
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
484
484
 
485
485
  /*
486
486
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -732,7 +732,7 @@
732
732
  return new ClientAuthError(errorCode, additionalMessage);
733
733
  }
734
734
 
735
- /*! @azure/msal-common v14.16.0 2024-12-12 */
735
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
736
736
 
737
737
  /*
738
738
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -771,7 +771,7 @@
771
771
  },
772
772
  };
773
773
 
774
- /*! @azure/msal-common v14.16.0 2024-12-12 */
774
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
775
775
 
776
776
  /*
777
777
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -962,12 +962,12 @@
962
962
  }
963
963
  }
964
964
 
965
- /*! @azure/msal-common v14.16.0 2024-12-12 */
965
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
966
966
  /* eslint-disable header/header */
967
967
  const name$1 = "@azure/msal-common";
968
- const version$1 = "14.16.0";
968
+ const version$1 = "14.16.1";
969
969
 
970
- /*! @azure/msal-common v14.16.0 2024-12-12 */
970
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
971
971
  /*
972
972
  * Copyright (c) Microsoft Corporation. All rights reserved.
973
973
  * Licensed under the MIT License.
@@ -987,7 +987,7 @@
987
987
  AzureUsGovernment: "https://login.microsoftonline.us",
988
988
  };
989
989
 
990
- /*! @azure/msal-common v14.16.0 2024-12-12 */
990
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
991
991
 
992
992
  /*
993
993
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1048,7 +1048,7 @@
1048
1048
  }
1049
1049
  }
1050
1050
 
1051
- /*! @azure/msal-common v14.16.0 2024-12-12 */
1051
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
1052
1052
  /*
1053
1053
  * Copyright (c) Microsoft Corporation. All rights reserved.
1054
1054
  * Licensed under the MIT License.
@@ -1085,7 +1085,7 @@
1085
1085
  return cachedAtSec > nowSeconds();
1086
1086
  }
1087
1087
 
1088
- /*! @azure/msal-common v14.16.0 2024-12-12 */
1088
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
1089
1089
 
1090
1090
  /*
1091
1091
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1412,7 +1412,7 @@
1412
1412
  return metadata.expiresAt <= nowSeconds();
1413
1413
  }
1414
1414
 
1415
- /*! @azure/msal-common v14.16.0 2024-12-12 */
1415
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
1416
1416
  /*
1417
1417
  * Copyright (c) Microsoft Corporation. All rights reserved.
1418
1418
  * Licensed under the MIT License.
@@ -1466,7 +1466,7 @@
1466
1466
  urlParseError: urlParseError
1467
1467
  });
1468
1468
 
1469
- /*! @azure/msal-common v14.16.0 2024-12-12 */
1469
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
1470
1470
 
1471
1471
  /*
1472
1472
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1604,7 +1604,7 @@
1604
1604
  return new ClientConfigurationError(errorCode);
1605
1605
  }
1606
1606
 
1607
- /*! @azure/msal-common v14.16.0 2024-12-12 */
1607
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
1608
1608
  /*
1609
1609
  * Copyright (c) Microsoft Corporation. All rights reserved.
1610
1610
  * Licensed under the MIT License.
@@ -1701,7 +1701,7 @@
1701
1701
  }
1702
1702
  }
1703
1703
 
1704
- /*! @azure/msal-common v14.16.0 2024-12-12 */
1704
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
1705
1705
 
1706
1706
  /*
1707
1707
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1901,7 +1901,7 @@
1901
1901
  }
1902
1902
  }
1903
1903
 
1904
- /*! @azure/msal-common v14.16.0 2024-12-12 */
1904
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
1905
1905
 
1906
1906
  /*
1907
1907
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1941,7 +1941,7 @@
1941
1941
  };
1942
1942
  }
1943
1943
 
1944
- /*! @azure/msal-common v14.16.0 2024-12-12 */
1944
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
1945
1945
  /*
1946
1946
  * Copyright (c) Microsoft Corporation. All rights reserved.
1947
1947
  * Licensed under the MIT License.
@@ -2020,7 +2020,7 @@
2020
2020
  return updatedAccountInfo;
2021
2021
  }
2022
2022
 
2023
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2023
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2024
2024
  /*
2025
2025
  * Copyright (c) Microsoft Corporation. All rights reserved.
2026
2026
  * Licensed under the MIT License.
@@ -2035,7 +2035,7 @@
2035
2035
  Ciam: 3,
2036
2036
  };
2037
2037
 
2038
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2038
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2039
2039
  /*
2040
2040
  * Copyright (c) Microsoft Corporation. All rights reserved.
2041
2041
  * Licensed under the MIT License.
@@ -2057,7 +2057,7 @@
2057
2057
  return null;
2058
2058
  }
2059
2059
 
2060
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2060
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2061
2061
  /*
2062
2062
  * Copyright (c) Microsoft Corporation. All rights reserved.
2063
2063
  * Licensed under the MIT License.
@@ -2070,7 +2070,7 @@
2070
2070
  OIDC: "OIDC",
2071
2071
  };
2072
2072
 
2073
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2073
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2074
2074
 
2075
2075
  /*
2076
2076
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2313,7 +2313,7 @@
2313
2313
  }
2314
2314
  }
2315
2315
 
2316
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2316
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2317
2317
 
2318
2318
  /*
2319
2319
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2360,7 +2360,7 @@
2360
2360
  return null;
2361
2361
  }
2362
2362
 
2363
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2363
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2364
2364
 
2365
2365
  /*
2366
2366
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2524,7 +2524,7 @@
2524
2524
  }
2525
2525
  }
2526
2526
 
2527
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2527
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2528
2528
 
2529
2529
  /*
2530
2530
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2664,23 +2664,23 @@
2664
2664
  return null;
2665
2665
  }
2666
2666
 
2667
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2667
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2668
2668
  /*
2669
2669
  * Copyright (c) Microsoft Corporation. All rights reserved.
2670
2670
  * Licensed under the MIT License.
2671
2671
  */
2672
- const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2673
- const cacheUnknownErrorCode = "cache_error_unknown";
2672
+ const cacheQuotaExceeded = "cache_quota_exceeded";
2673
+ const cacheErrorUnknown = "cache_error_unknown";
2674
2674
 
2675
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2675
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2676
2676
 
2677
2677
  /*
2678
2678
  * Copyright (c) Microsoft Corporation. All rights reserved.
2679
2679
  * Licensed under the MIT License.
2680
2680
  */
2681
2681
  const CacheErrorMessages = {
2682
- [cacheQuotaExceededErrorCode]: "Exceeded cache storage capacity.",
2683
- [cacheUnknownErrorCode]: "Unexpected error occurred when using cache storage.",
2682
+ [cacheQuotaExceeded]: "Exceeded cache storage capacity.",
2683
+ [cacheErrorUnknown]: "Unexpected error occurred when using cache storage.",
2684
2684
  };
2685
2685
  /**
2686
2686
  * Error thrown when there is an error with the cache
@@ -2690,16 +2690,34 @@
2690
2690
  const message = errorMessage ||
2691
2691
  (CacheErrorMessages[errorCode]
2692
2692
  ? CacheErrorMessages[errorCode]
2693
- : CacheErrorMessages[cacheUnknownErrorCode]);
2693
+ : CacheErrorMessages[cacheErrorUnknown]);
2694
2694
  super(`${errorCode}: ${message}`);
2695
2695
  Object.setPrototypeOf(this, CacheError.prototype);
2696
2696
  this.name = "CacheError";
2697
2697
  this.errorCode = errorCode;
2698
2698
  this.errorMessage = message;
2699
2699
  }
2700
+ }
2701
+ /**
2702
+ * Helper function to wrap browser errors in a CacheError object
2703
+ * @param e
2704
+ * @returns
2705
+ */
2706
+ function createCacheError(e) {
2707
+ if (!(e instanceof Error)) {
2708
+ return new CacheError(cacheErrorUnknown);
2709
+ }
2710
+ if (e.name === "QuotaExceededError" ||
2711
+ e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
2712
+ e.message.includes("exceeded the quota")) {
2713
+ return new CacheError(cacheQuotaExceeded);
2714
+ }
2715
+ else {
2716
+ return new CacheError(e.name, e.message);
2717
+ }
2700
2718
  }
2701
2719
 
2702
- /*! @azure/msal-common v14.16.0 2024-12-12 */
2720
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
2703
2721
 
2704
2722
  /*
2705
2723
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2721,14 +2739,14 @@
2721
2739
  * @param accountFilter - (Optional) filter to narrow down the accounts returned
2722
2740
  * @returns Array of AccountInfo objects in cache
2723
2741
  */
2724
- getAllAccounts(accountFilter) {
2725
- return this.buildTenantProfiles(this.getAccountsFilteredBy(accountFilter || {}), accountFilter);
2742
+ getAllAccounts(correlationId, accountFilter) {
2743
+ return this.buildTenantProfiles(this.getAccountsFilteredBy(accountFilter || {}, correlationId), correlationId, accountFilter);
2726
2744
  }
2727
2745
  /**
2728
2746
  * Gets first tenanted AccountInfo object found based on provided filters
2729
2747
  */
2730
- getAccountInfoFilteredBy(accountFilter) {
2731
- const allAccounts = this.getAllAccounts(accountFilter);
2748
+ getAccountInfoFilteredBy(accountFilter, correlationId) {
2749
+ const allAccounts = this.getAllAccounts(correlationId, accountFilter);
2732
2750
  if (allAccounts.length > 1) {
2733
2751
  // If one or more accounts are found, prioritize accounts that have an ID token
2734
2752
  const sortedAccounts = allAccounts.sort((account) => {
@@ -2749,8 +2767,8 @@
2749
2767
  * @param accountFilter
2750
2768
  * @returns
2751
2769
  */
2752
- getBaseAccountInfo(accountFilter) {
2753
- const accountEntities = this.getAccountsFilteredBy(accountFilter);
2770
+ getBaseAccountInfo(accountFilter, correlationId) {
2771
+ const accountEntities = this.getAccountsFilteredBy(accountFilter, correlationId);
2754
2772
  if (accountEntities.length > 0) {
2755
2773
  return accountEntities[0].getAccountInfo();
2756
2774
  }
@@ -2765,12 +2783,12 @@
2765
2783
  * @param accountFilter
2766
2784
  * @returns Array of AccountInfo objects that match account and tenant profile filters
2767
2785
  */
2768
- buildTenantProfiles(cachedAccounts, accountFilter) {
2786
+ buildTenantProfiles(cachedAccounts, correlationId, accountFilter) {
2769
2787
  return cachedAccounts.flatMap((accountEntity) => {
2770
- return this.getTenantProfilesFromAccountEntity(accountEntity, accountFilter?.tenantId, accountFilter);
2788
+ return this.getTenantProfilesFromAccountEntity(accountEntity, correlationId, accountFilter?.tenantId, accountFilter);
2771
2789
  });
2772
2790
  }
2773
- getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, tenantProfileFilter) {
2791
+ getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, correlationId, tenantProfileFilter) {
2774
2792
  let tenantedAccountInfo = null;
2775
2793
  let idTokenClaims;
2776
2794
  if (tenantProfileFilter) {
@@ -2778,7 +2796,7 @@
2778
2796
  return null;
2779
2797
  }
2780
2798
  }
2781
- const idToken = this.getIdToken(accountInfo, tokenKeys, tenantProfile.tenantId);
2799
+ const idToken = this.getIdToken(accountInfo, correlationId, tokenKeys, tenantProfile.tenantId);
2782
2800
  if (idToken) {
2783
2801
  idTokenClaims = extractTokenClaims(idToken.secret, this.cryptoImpl.base64Decode);
2784
2802
  if (!this.idTokenClaimsMatchTenantProfileFilter(idTokenClaims, tenantProfileFilter)) {
@@ -2790,7 +2808,7 @@
2790
2808
  tenantedAccountInfo = updateAccountTenantProfileData(accountInfo, tenantProfile, idTokenClaims, idToken?.secret);
2791
2809
  return tenantedAccountInfo;
2792
2810
  }
2793
- getTenantProfilesFromAccountEntity(accountEntity, targetTenantId, tenantProfileFilter) {
2811
+ getTenantProfilesFromAccountEntity(accountEntity, correlationId, targetTenantId, tenantProfileFilter) {
2794
2812
  const accountInfo = accountEntity.getAccountInfo();
2795
2813
  let searchTenantProfiles = accountInfo.tenantProfiles || new Map();
2796
2814
  const tokenKeys = this.getTokenKeys();
@@ -2810,7 +2828,7 @@
2810
2828
  }
2811
2829
  const matchingTenantProfiles = [];
2812
2830
  searchTenantProfiles.forEach((tenantProfile) => {
2813
- const tenantedAccountInfo = this.getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, tenantProfileFilter);
2831
+ const tenantedAccountInfo = this.getTenantedAccountInfoByFilter(accountInfo, tokenKeys, tenantProfile, correlationId, tenantProfileFilter);
2814
2832
  if (tenantedAccountInfo) {
2815
2833
  matchingTenantProfiles.push(tenantedAccountInfo);
2816
2834
  }
@@ -2864,46 +2882,36 @@
2864
2882
  * @param storeInCache {?StoreInCache}
2865
2883
  * @param correlationId {?string} correlation id
2866
2884
  */
2867
- async saveCacheRecord(cacheRecord, storeInCache, correlationId) {
2885
+ async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
2868
2886
  if (!cacheRecord) {
2869
2887
  throw createClientAuthError(invalidCacheRecord);
2870
2888
  }
2871
2889
  try {
2872
2890
  if (!!cacheRecord.account) {
2873
- this.setAccount(cacheRecord.account);
2891
+ this.setAccount(cacheRecord.account, correlationId);
2874
2892
  }
2875
2893
  if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
2876
- this.setIdTokenCredential(cacheRecord.idToken);
2894
+ this.setIdTokenCredential(cacheRecord.idToken, correlationId);
2877
2895
  }
2878
2896
  if (!!cacheRecord.accessToken &&
2879
2897
  storeInCache?.accessToken !== false) {
2880
- await this.saveAccessToken(cacheRecord.accessToken);
2898
+ await this.saveAccessToken(cacheRecord.accessToken, correlationId);
2881
2899
  }
2882
2900
  if (!!cacheRecord.refreshToken &&
2883
2901
  storeInCache?.refreshToken !== false) {
2884
- this.setRefreshTokenCredential(cacheRecord.refreshToken);
2902
+ this.setRefreshTokenCredential(cacheRecord.refreshToken, correlationId);
2885
2903
  }
2886
2904
  if (!!cacheRecord.appMetadata) {
2887
- this.setAppMetadata(cacheRecord.appMetadata);
2905
+ this.setAppMetadata(cacheRecord.appMetadata, correlationId);
2888
2906
  }
2889
2907
  }
2890
2908
  catch (e) {
2891
2909
  this.commonLogger?.error(`CacheManager.saveCacheRecord: failed`);
2892
- if (e instanceof Error) {
2893
- this.commonLogger?.errorPii(`CacheManager.saveCacheRecord: ${e.message}`, correlationId);
2894
- if (e.name === "QuotaExceededError" ||
2895
- e.name === "NS_ERROR_DOM_QUOTA_REACHED" ||
2896
- e.message.includes("exceeded the quota")) {
2897
- this.commonLogger?.error(`CacheManager.saveCacheRecord: exceeded storage quota`, correlationId);
2898
- throw new CacheError(cacheQuotaExceededErrorCode);
2899
- }
2900
- else {
2901
- throw new CacheError(e.name, e.message);
2902
- }
2910
+ if (e instanceof AuthError) {
2911
+ throw e;
2903
2912
  }
2904
2913
  else {
2905
- this.commonLogger?.errorPii(`CacheManager.saveCacheRecord: ${e}`, correlationId);
2906
- throw new CacheError(cacheUnknownErrorCode);
2914
+ throw createCacheError(e);
2907
2915
  }
2908
2916
  }
2909
2917
  }
@@ -2911,7 +2919,7 @@
2911
2919
  * saves access token credential
2912
2920
  * @param credential
2913
2921
  */
2914
- async saveAccessToken(credential) {
2922
+ async saveAccessToken(credential, correlationId) {
2915
2923
  const accessTokenFilter = {
2916
2924
  clientId: credential.clientId,
2917
2925
  credentialType: credential.credentialType,
@@ -2923,29 +2931,27 @@
2923
2931
  };
2924
2932
  const tokenKeys = this.getTokenKeys();
2925
2933
  const currentScopes = ScopeSet.fromString(credential.target);
2926
- const removedAccessTokens = [];
2927
2934
  tokenKeys.accessToken.forEach((key) => {
2928
2935
  if (!this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
2929
2936
  return;
2930
2937
  }
2931
- const tokenEntity = this.getAccessTokenCredential(key);
2938
+ const tokenEntity = this.getAccessTokenCredential(key, correlationId);
2932
2939
  if (tokenEntity &&
2933
2940
  this.credentialMatchesFilter(tokenEntity, accessTokenFilter)) {
2934
2941
  const tokenScopeSet = ScopeSet.fromString(tokenEntity.target);
2935
2942
  if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
2936
- removedAccessTokens.push(this.removeAccessToken(key));
2943
+ this.removeAccessToken(key, correlationId);
2937
2944
  }
2938
2945
  }
2939
2946
  });
2940
- await Promise.all(removedAccessTokens);
2941
- this.setAccessTokenCredential(credential);
2947
+ this.setAccessTokenCredential(credential, correlationId);
2942
2948
  }
2943
2949
  /**
2944
2950
  * Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
2945
2951
  * Not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
2946
2952
  * @param accountFilter - An object containing Account properties to filter by
2947
2953
  */
2948
- getAccountsFilteredBy(accountFilter) {
2954
+ getAccountsFilteredBy(accountFilter, correlationId) {
2949
2955
  const allAccountKeys = this.getAccountKeys();
2950
2956
  const matchingAccounts = [];
2951
2957
  allAccountKeys.forEach((cacheKey) => {
@@ -2953,7 +2959,7 @@
2953
2959
  // Don't parse value if the key doesn't match the account filters
2954
2960
  return;
2955
2961
  }
2956
- const entity = this.getAccount(cacheKey, this.commonLogger);
2962
+ const entity = this.getAccount(cacheKey, correlationId, this.commonLogger);
2957
2963
  // Match base account fields
2958
2964
  if (!entity) {
2959
2965
  return;
@@ -3179,11 +3185,11 @@
3179
3185
  /**
3180
3186
  * Removes all accounts and related tokens from cache.
3181
3187
  */
3182
- async removeAllAccounts() {
3188
+ async removeAllAccounts(correlationId) {
3183
3189
  const allAccountKeys = this.getAccountKeys();
3184
3190
  const removedAccounts = [];
3185
3191
  allAccountKeys.forEach((cacheKey) => {
3186
- removedAccounts.push(this.removeAccount(cacheKey));
3192
+ removedAccounts.push(this.removeAccount(cacheKey, correlationId));
3187
3193
  });
3188
3194
  await Promise.all(removedAccounts);
3189
3195
  }
@@ -3191,38 +3197,41 @@
3191
3197
  * Removes the account and related tokens for a given account key
3192
3198
  * @param account
3193
3199
  */
3194
- async removeAccount(accountKey) {
3195
- const account = this.getAccount(accountKey, this.commonLogger);
3200
+ async removeAccount(accountKey, correlationId) {
3201
+ const account = this.getAccount(accountKey, correlationId, this.commonLogger);
3196
3202
  if (!account) {
3197
3203
  return;
3198
3204
  }
3199
- await this.removeAccountContext(account);
3200
- this.removeItem(accountKey);
3205
+ await this.removeAccountContext(account, correlationId);
3206
+ this.removeItem(accountKey, correlationId);
3201
3207
  }
3202
3208
  /**
3203
3209
  * Removes credentials associated with the provided account
3204
3210
  * @param account
3205
3211
  */
3206
- async removeAccountContext(account) {
3212
+ async removeAccountContext(account, correlationId) {
3207
3213
  const allTokenKeys = this.getTokenKeys();
3208
3214
  const accountId = account.generateAccountId();
3209
- const removedCredentials = [];
3210
3215
  allTokenKeys.idToken.forEach((key) => {
3211
3216
  if (key.indexOf(accountId) === 0) {
3212
- this.removeIdToken(key);
3217
+ this.removeIdToken(key, correlationId);
3213
3218
  }
3214
3219
  });
3215
3220
  allTokenKeys.accessToken.forEach((key) => {
3216
3221
  if (key.indexOf(accountId) === 0) {
3217
- removedCredentials.push(this.removeAccessToken(key));
3222
+ this.removeAccessToken(key, correlationId);
3218
3223
  }
3219
3224
  });
3220
3225
  allTokenKeys.refreshToken.forEach((key) => {
3221
3226
  if (key.indexOf(accountId) === 0) {
3222
- this.removeRefreshToken(key);
3227
+ this.removeRefreshToken(key, correlationId);
3228
+ }
3229
+ });
3230
+ this.getKeys().forEach((key) => {
3231
+ if (key.includes(accountId)) {
3232
+ this.removeItem(key, correlationId);
3223
3233
  }
3224
3234
  });
3225
- await Promise.all(removedCredentials);
3226
3235
  }
3227
3236
  /**
3228
3237
  * Migrates a single-tenant account and all it's associated alternate cross-tenant account objects in the
@@ -3232,7 +3241,7 @@
3232
3241
  * @param logger
3233
3242
  * @returns
3234
3243
  */
3235
- updateOutdatedCachedAccount(accountKey, accountEntity, logger) {
3244
+ updateOutdatedCachedAccount(accountKey, accountEntity, correlationId, logger) {
3236
3245
  // Only update if account entity is defined and has no tenantProfiles object (is outdated)
3237
3246
  if (accountEntity && accountEntity.isSingleTenant()) {
3238
3247
  this.commonLogger?.verbose("updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity");
@@ -3243,7 +3252,7 @@
3243
3252
  // Get all account entities belonging to user
3244
3253
  const accountsToMerge = [];
3245
3254
  matchingAccountKeys.forEach((key) => {
3246
- const account = this.getCachedAccountEntity(key);
3255
+ const account = this.getCachedAccountEntity(key, correlationId);
3247
3256
  if (account) {
3248
3257
  accountsToMerge.push(account);
3249
3258
  }
@@ -3268,11 +3277,11 @@
3268
3277
  // Clear cache of legacy account objects that have been collpsed into tenant profiles
3269
3278
  matchingAccountKeys.forEach((key) => {
3270
3279
  if (key !== newAccountKey) {
3271
- this.removeOutdatedAccount(accountKey);
3280
+ this.removeOutdatedAccount(accountKey, correlationId);
3272
3281
  }
3273
3282
  });
3274
3283
  // Cache updated account object
3275
- this.setAccount(updatedAccount);
3284
+ this.setAccount(updatedAccount, correlationId);
3276
3285
  logger?.verbose("Updated an outdated account entity in the cache");
3277
3286
  return updatedAccount;
3278
3287
  }
@@ -3283,37 +3292,31 @@
3283
3292
  * returns a boolean if the given credential is removed
3284
3293
  * @param credential
3285
3294
  */
3286
- async removeAccessToken(key) {
3287
- const credential = this.getAccessTokenCredential(key);
3288
- if (!credential) {
3295
+ removeAccessToken(key, correlationId) {
3296
+ const credential = this.getAccessTokenCredential(key, correlationId);
3297
+ this.removeItem(key, correlationId);
3298
+ if (!credential ||
3299
+ credential.credentialType.toLowerCase() !==
3300
+ CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase() ||
3301
+ credential.tokenType !== AuthenticationScheme.POP) {
3289
3302
  return;
3290
3303
  }
3291
3304
  // Remove Token Binding Key from key store for PoP Tokens Credentials
3292
- if (credential.credentialType.toLowerCase() ===
3293
- CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) {
3294
- if (credential.tokenType === AuthenticationScheme.POP) {
3295
- const accessTokenWithAuthSchemeEntity = credential;
3296
- const kid = accessTokenWithAuthSchemeEntity.keyId;
3297
- if (kid) {
3298
- try {
3299
- await this.cryptoImpl.removeTokenBindingKey(kid);
3300
- }
3301
- catch (error) {
3302
- throw createClientAuthError(bindingKeyNotRemoved);
3303
- }
3304
- }
3305
- }
3305
+ const kid = credential.keyId;
3306
+ if (kid) {
3307
+ void this.cryptoImpl.removeTokenBindingKey(kid).catch(() => {
3308
+ this.commonLogger.error("Binding key could not be removed");
3309
+ });
3306
3310
  }
3307
- return this.removeItem(key);
3308
3311
  }
3309
3312
  /**
3310
3313
  * Removes all app metadata objects from cache.
3311
3314
  */
3312
- removeAppMetadata() {
3315
+ removeAppMetadata(correlationId) {
3313
3316
  const allCacheKeys = this.getKeys();
3314
3317
  allCacheKeys.forEach((cacheKey) => {
3315
3318
  if (this.isAppMetadata(cacheKey)) {
3316
- this.removeItem(cacheKey);
3319
+ this.removeItem(cacheKey, correlationId);
3317
3320
  }
3318
3321
  });
3319
3322
  return true;
@@ -3322,9 +3325,9 @@
3322
3325
  * Retrieve AccountEntity from cache
3323
3326
  * @param account
3324
3327
  */
3325
- readAccountFromCache(account) {
3328
+ readAccountFromCache(account, correlationId) {
3326
3329
  const accountKey = AccountEntity.generateAccountCacheKey(account);
3327
- return this.getAccount(accountKey, this.commonLogger);
3330
+ return this.getAccount(accountKey, correlationId, this.commonLogger);
3328
3331
  }
3329
3332
  /**
3330
3333
  * Retrieve IdTokenEntity from cache
@@ -3334,7 +3337,7 @@
3334
3337
  * @param performanceClient {?IPerformanceClient}
3335
3338
  * @param correlationId {?string}
3336
3339
  */
3337
- getIdToken(account, tokenKeys, targetRealm, performanceClient, correlationId) {
3340
+ getIdToken(account, correlationId, tokenKeys, targetRealm, performanceClient) {
3338
3341
  this.commonLogger.trace("CacheManager - getIdToken called");
3339
3342
  const idTokenFilter = {
3340
3343
  homeAccountId: account.homeAccountId,
@@ -3343,7 +3346,7 @@
3343
3346
  clientId: this.clientId,
3344
3347
  realm: targetRealm,
3345
3348
  };
3346
- const idTokenMap = this.getIdTokensByFilter(idTokenFilter, tokenKeys);
3349
+ const idTokenMap = this.getIdTokensByFilter(idTokenFilter, correlationId, tokenKeys);
3347
3350
  const numIdTokens = idTokenMap.size;
3348
3351
  if (numIdTokens < 1) {
3349
3352
  this.commonLogger.info("CacheManager:getIdToken - No token found");
@@ -3376,7 +3379,7 @@
3376
3379
  // Multiple tokens for a single tenant profile, remove all and return null
3377
3380
  this.commonLogger.info("CacheManager:getIdToken - Multiple matching ID tokens found, clearing them");
3378
3381
  tokensToBeRemoved.forEach((idToken, key) => {
3379
- this.removeIdToken(key);
3382
+ this.removeIdToken(key, correlationId);
3380
3383
  });
3381
3384
  if (performanceClient && correlationId) {
3382
3385
  performanceClient.addFields({ multiMatchedID: idTokenMap.size }, correlationId);
@@ -3391,7 +3394,7 @@
3391
3394
  * @param filter
3392
3395
  * @returns
3393
3396
  */
3394
- getIdTokensByFilter(filter, tokenKeys) {
3397
+ getIdTokensByFilter(filter, correlationId, tokenKeys) {
3395
3398
  const idTokenKeys = (tokenKeys && tokenKeys.idToken) || this.getTokenKeys().idToken;
3396
3399
  const idTokens = new Map();
3397
3400
  idTokenKeys.forEach((key) => {
@@ -3401,7 +3404,7 @@
3401
3404
  })) {
3402
3405
  return;
3403
3406
  }
3404
- const idToken = this.getIdTokenCredential(key);
3407
+ const idToken = this.getIdTokenCredential(key, correlationId);
3405
3408
  if (idToken && this.credentialMatchesFilter(idToken, filter)) {
3406
3409
  idTokens.set(key, idToken);
3407
3410
  }
@@ -3430,15 +3433,15 @@
3430
3433
  * Removes idToken from the cache
3431
3434
  * @param key
3432
3435
  */
3433
- removeIdToken(key) {
3434
- this.removeItem(key);
3436
+ removeIdToken(key, correlationId) {
3437
+ this.removeItem(key, correlationId);
3435
3438
  }
3436
3439
  /**
3437
3440
  * Removes refresh token from the cache
3438
3441
  * @param key
3439
3442
  */
3440
- removeRefreshToken(key) {
3441
- this.removeItem(key);
3443
+ removeRefreshToken(key, correlationId) {
3444
+ this.removeItem(key, correlationId);
3442
3445
  }
3443
3446
  /**
3444
3447
  * Retrieve AccessTokenEntity from cache
@@ -3448,7 +3451,7 @@
3448
3451
  * @param performanceClient {?IPerformanceClient}
3449
3452
  * @param correlationId {?string}
3450
3453
  */
3451
- getAccessToken(account, request, tokenKeys, targetRealm, performanceClient, correlationId) {
3454
+ getAccessToken(account, request, tokenKeys, targetRealm, performanceClient) {
3452
3455
  this.commonLogger.trace("CacheManager - getAccessToken called");
3453
3456
  const scopes = ScopeSet.createSearchScopes(request.scopes);
3454
3457
  const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
@@ -3478,7 +3481,7 @@
3478
3481
  accessTokenKeys.forEach((key) => {
3479
3482
  // Validate key
3480
3483
  if (this.accessTokenKeyMatchesFilter(key, accessTokenFilter, true)) {
3481
- const accessToken = this.getAccessTokenCredential(key);
3484
+ const accessToken = this.getAccessTokenCredential(key, request.correlationId);
3482
3485
  // Validate value
3483
3486
  if (accessToken &&
3484
3487
  this.credentialMatchesFilter(accessToken, accessTokenFilter)) {
@@ -3494,10 +3497,10 @@
3494
3497
  else if (numAccessTokens > 1) {
3495
3498
  this.commonLogger.info("CacheManager:getAccessToken - Multiple access tokens found, clearing them");
3496
3499
  accessTokens.forEach((accessToken) => {
3497
- void this.removeAccessToken(generateCredentialKey(accessToken));
3500
+ void this.removeAccessToken(generateCredentialKey(accessToken), request.correlationId);
3498
3501
  });
3499
- if (performanceClient && correlationId) {
3500
- performanceClient.addFields({ multiMatchedAT: accessTokens.length }, correlationId);
3502
+ if (performanceClient && request.correlationId) {
3503
+ performanceClient.addFields({ multiMatchedAT: accessTokens.length }, request.correlationId);
3501
3504
  }
3502
3505
  return null;
3503
3506
  }
@@ -3550,14 +3553,14 @@
3550
3553
  * @param filter
3551
3554
  * @returns
3552
3555
  */
3553
- getAccessTokensByFilter(filter) {
3556
+ getAccessTokensByFilter(filter, correlationId) {
3554
3557
  const tokenKeys = this.getTokenKeys();
3555
3558
  const accessTokens = [];
3556
3559
  tokenKeys.accessToken.forEach((key) => {
3557
3560
  if (!this.accessTokenKeyMatchesFilter(key, filter, true)) {
3558
3561
  return;
3559
3562
  }
3560
- const accessToken = this.getAccessTokenCredential(key);
3563
+ const accessToken = this.getAccessTokenCredential(key, correlationId);
3561
3564
  if (accessToken &&
3562
3565
  this.credentialMatchesFilter(accessToken, filter)) {
3563
3566
  accessTokens.push(accessToken);
@@ -3573,7 +3576,7 @@
3573
3576
  * @param performanceClient {?IPerformanceClient}
3574
3577
  * @param correlationId {?string}
3575
3578
  */
3576
- getRefreshToken(account, familyRT, tokenKeys, performanceClient, correlationId) {
3579
+ getRefreshToken(account, familyRT, correlationId, tokenKeys, performanceClient) {
3577
3580
  this.commonLogger.trace("CacheManager - getRefreshToken called");
3578
3581
  const id = familyRT ? THE_FAMILY_ID : undefined;
3579
3582
  const refreshTokenFilter = {
@@ -3589,7 +3592,7 @@
3589
3592
  refreshTokenKeys.forEach((key) => {
3590
3593
  // Validate key
3591
3594
  if (this.refreshTokenKeyMatchesFilter(key, refreshTokenFilter)) {
3592
- const refreshToken = this.getRefreshTokenCredential(key);
3595
+ const refreshToken = this.getRefreshTokenCredential(key, correlationId);
3593
3596
  // Validate value
3594
3597
  if (refreshToken &&
3595
3598
  this.credentialMatchesFilter(refreshToken, refreshTokenFilter)) {
@@ -3948,7 +3951,7 @@
3948
3951
  }
3949
3952
  }
3950
3953
 
3951
- /*! @azure/msal-common v14.16.0 2024-12-12 */
3954
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
3952
3955
 
3953
3956
  /*
3954
3957
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4047,7 +4050,7 @@
4047
4050
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4048
4051
  }
4049
4052
 
4050
- /*! @azure/msal-common v14.16.0 2024-12-12 */
4053
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
4051
4054
  /*
4052
4055
  * Copyright (c) Microsoft Corporation. All rights reserved.
4053
4056
  * Licensed under the MIT License.
@@ -4057,7 +4060,7 @@
4057
4060
  UPN: "UPN",
4058
4061
  };
4059
4062
 
4060
- /*! @azure/msal-common v14.16.0 2024-12-12 */
4063
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
4061
4064
  /*
4062
4065
  * Copyright (c) Microsoft Corporation. All rights reserved.
4063
4066
  * Licensed under the MIT License.
@@ -4107,7 +4110,7 @@
4107
4110
  const BROKER_CLIENT_ID = "brk_client_id";
4108
4111
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4109
4112
 
4110
- /*! @azure/msal-common v14.16.0 2024-12-12 */
4113
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
4111
4114
 
4112
4115
  /*
4113
4116
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4174,7 +4177,7 @@
4174
4177
  }
4175
4178
  }
4176
4179
 
4177
- /*! @azure/msal-common v14.16.0 2024-12-12 */
4180
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
4178
4181
 
4179
4182
  /*
4180
4183
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4582,7 +4585,7 @@
4582
4585
  }
4583
4586
  }
4584
4587
 
4585
- /*! @azure/msal-common v14.16.0 2024-12-12 */
4588
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
4586
4589
  /*
4587
4590
  * Copyright (c) Microsoft Corporation. All rights reserved.
4588
4591
  * Licensed under the MIT License.
@@ -4594,7 +4597,7 @@
4594
4597
  response.hasOwnProperty("jwks_uri"));
4595
4598
  }
4596
4599
 
4597
- /*! @azure/msal-common v14.16.0 2024-12-12 */
4600
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
4598
4601
  /*
4599
4602
  * Copyright (c) Microsoft Corporation. All rights reserved.
4600
4603
  * Licensed under the MIT License.
@@ -4604,7 +4607,7 @@
4604
4607
  response.hasOwnProperty("metadata"));
4605
4608
  }
4606
4609
 
4607
- /*! @azure/msal-common v14.16.0 2024-12-12 */
4610
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
4608
4611
  /*
4609
4612
  * Copyright (c) Microsoft Corporation. All rights reserved.
4610
4613
  * Licensed under the MIT License.
@@ -4614,7 +4617,7 @@
4614
4617
  response.hasOwnProperty("error_description"));
4615
4618
  }
4616
4619
 
4617
- /*! @azure/msal-common v14.16.0 2024-12-12 */
4620
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
4618
4621
  /*
4619
4622
  * Copyright (c) Microsoft Corporation. All rights reserved.
4620
4623
  * Licensed under the MIT License.
@@ -5101,7 +5104,7 @@
5101
5104
  "multiMatchedRT",
5102
5105
  ]);
5103
5106
 
5104
- /*! @azure/msal-common v14.16.0 2024-12-12 */
5107
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
5105
5108
  /*
5106
5109
  * Copyright (c) Microsoft Corporation. All rights reserved.
5107
5110
  * Licensed under the MIT License.
@@ -5197,7 +5200,7 @@
5197
5200
  };
5198
5201
  };
5199
5202
 
5200
- /*! @azure/msal-common v14.16.0 2024-12-12 */
5203
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
5201
5204
 
5202
5205
  /*
5203
5206
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5306,7 +5309,7 @@
5306
5309
  },
5307
5310
  };
5308
5311
 
5309
- /*! @azure/msal-common v14.16.0 2024-12-12 */
5312
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
5310
5313
 
5311
5314
  /*
5312
5315
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6145,7 +6148,7 @@
6145
6148
  };
6146
6149
  }
6147
6150
 
6148
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6151
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6149
6152
 
6150
6153
  /*
6151
6154
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6176,7 +6179,7 @@
6176
6179
  }
6177
6180
  }
6178
6181
 
6179
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6182
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6180
6183
 
6181
6184
  /*
6182
6185
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6195,7 +6198,7 @@
6195
6198
  }
6196
6199
  }
6197
6200
 
6198
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6201
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6199
6202
 
6200
6203
  /*
6201
6204
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6215,12 +6218,12 @@
6215
6218
  * @param cacheManager
6216
6219
  * @param thumbprint
6217
6220
  */
6218
- static preProcess(cacheManager, thumbprint) {
6221
+ static preProcess(cacheManager, thumbprint, correlationId) {
6219
6222
  const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
6220
6223
  const value = cacheManager.getThrottlingCache(key);
6221
6224
  if (value) {
6222
6225
  if (value.throttleTime < Date.now()) {
6223
- cacheManager.removeItem(key);
6226
+ cacheManager.removeItem(key, correlationId);
6224
6227
  return;
6225
6228
  }
6226
6229
  throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
@@ -6232,7 +6235,7 @@
6232
6235
  * @param thumbprint
6233
6236
  * @param response
6234
6237
  */
6235
- static postProcess(cacheManager, thumbprint, response) {
6238
+ static postProcess(cacheManager, thumbprint, response, correlationId) {
6236
6239
  if (ThrottlingUtils.checkResponseStatus(response) ||
6237
6240
  ThrottlingUtils.checkResponseForRetryAfter(response)) {
6238
6241
  const thumbprintValue = {
@@ -6242,7 +6245,7 @@
6242
6245
  errorMessage: response.body.error_description,
6243
6246
  subError: response.body.suberror,
6244
6247
  };
6245
- cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
6248
+ cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue, correlationId);
6246
6249
  }
6247
6250
  }
6248
6251
  /**
@@ -6289,11 +6292,11 @@
6289
6292
  sshKid: request.sshKid,
6290
6293
  };
6291
6294
  const key = this.generateThrottlingStorageKey(thumbprint);
6292
- cacheManager.removeItem(key);
6295
+ cacheManager.removeItem(key, request.correlationId);
6293
6296
  }
6294
6297
  }
6295
6298
 
6296
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6299
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6297
6300
 
6298
6301
  /*
6299
6302
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6323,7 +6326,7 @@
6323
6326
  return new NetworkError(error, httpStatus, responseHeaders);
6324
6327
  }
6325
6328
 
6326
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6329
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6327
6330
 
6328
6331
  /*
6329
6332
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6405,7 +6408,7 @@
6405
6408
  * @param correlationId - CorrelationId for telemetry
6406
6409
  */
6407
6410
  async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
6408
- ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
6411
+ ThrottlingUtils.preProcess(this.cacheManager, thumbprint, correlationId);
6409
6412
  let response;
6410
6413
  try {
6411
6414
  response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), PerformanceEvents.NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
@@ -6440,7 +6443,7 @@
6440
6443
  throw createClientAuthError(networkError);
6441
6444
  }
6442
6445
  }
6443
- ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
6446
+ ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response, correlationId);
6444
6447
  return response;
6445
6448
  }
6446
6449
  /**
@@ -6473,7 +6476,7 @@
6473
6476
  }
6474
6477
  }
6475
6478
 
6476
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6479
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6477
6480
  /*
6478
6481
  * Copyright (c) Microsoft Corporation. All rights reserved.
6479
6482
  * Licensed under the MIT License.
@@ -6499,7 +6502,7 @@
6499
6502
  refreshTokenExpired: refreshTokenExpired
6500
6503
  });
6501
6504
 
6502
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6505
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6503
6506
 
6504
6507
  /*
6505
6508
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6587,7 +6590,7 @@
6587
6590
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6588
6591
  }
6589
6592
 
6590
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6593
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6591
6594
 
6592
6595
  /*
6593
6596
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6659,7 +6662,7 @@
6659
6662
  }
6660
6663
  }
6661
6664
 
6662
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6665
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6663
6666
 
6664
6667
  /*
6665
6668
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6743,7 +6746,7 @@
6743
6746
  }
6744
6747
  }
6745
6748
 
6746
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6749
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6747
6750
  /*
6748
6751
  * Copyright (c) Microsoft Corporation. All rights reserved.
6749
6752
  * Licensed under the MIT License.
@@ -6770,7 +6773,7 @@
6770
6773
  }
6771
6774
  }
6772
6775
 
6773
- /*! @azure/msal-common v14.16.0 2024-12-12 */
6776
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
6774
6777
 
6775
6778
  /*
6776
6779
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6930,13 +6933,13 @@
6930
6933
  !forceCacheRefreshTokenResponse &&
6931
6934
  cacheRecord.account) {
6932
6935
  const key = cacheRecord.account.generateAccountKey();
6933
- const account = this.cacheStorage.getAccount(key, this.logger);
6936
+ const account = this.cacheStorage.getAccount(key, request.correlationId, this.logger);
6934
6937
  if (!account) {
6935
6938
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
6936
6939
  return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
6937
6940
  }
6938
6941
  }
6939
- await this.cacheStorage.saveCacheRecord(cacheRecord, request.storeInCache, request.correlationId);
6942
+ await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, request.storeInCache);
6940
6943
  }
6941
6944
  finally {
6942
6945
  if (this.persistencePlugin &&
@@ -6965,7 +6968,7 @@
6965
6968
  let cachedAccount;
6966
6969
  if (serverTokenResponse.id_token && !!idTokenClaims) {
6967
6970
  cachedIdToken = createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token, this.clientId, claimsTenantId || "");
6968
- cachedAccount = buildAccountToCache(this.cacheStorage, authority, this.homeAccountIdentifier, this.cryptoObj.base64Decode, idTokenClaims, serverTokenResponse.client_info, env, claimsTenantId, authCodePayload, undefined, // nativeAccountId
6971
+ cachedAccount = buildAccountToCache(this.cacheStorage, authority, this.homeAccountIdentifier, this.cryptoObj.base64Decode, request.correlationId, idTokenClaims, serverTokenResponse.client_info, env, claimsTenantId, authCodePayload, undefined, // nativeAccountId
6969
6972
  this.logger);
6970
6973
  }
6971
6974
  // AccessToken
@@ -7113,7 +7116,7 @@
7113
7116
  };
7114
7117
  }
7115
7118
  }
7116
- function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, environment, claimsTenantId, authCodePayload, nativeAccountId, logger) {
7119
+ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decode, correlationId, idTokenClaims, clientInfo, environment, claimsTenantId, authCodePayload, nativeAccountId, logger) {
7117
7120
  logger?.verbose("setCachedAccount called");
7118
7121
  // Check if base account is already cached
7119
7122
  const accountKeys = cacheStorage.getAccountKeys();
@@ -7122,7 +7125,7 @@
7122
7125
  });
7123
7126
  let cachedAccount = null;
7124
7127
  if (baseAccountKey) {
7125
- cachedAccount = cacheStorage.getAccount(baseAccountKey, logger);
7128
+ cachedAccount = cacheStorage.getAccount(baseAccountKey, correlationId, logger);
7126
7129
  }
7127
7130
  const baseAccount = cachedAccount ||
7128
7131
  AccountEntity.createAccount({
@@ -7147,7 +7150,7 @@
7147
7150
  return baseAccount;
7148
7151
  }
7149
7152
 
7150
- /*! @azure/msal-common v14.16.0 2024-12-12 */
7153
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
7151
7154
  /*
7152
7155
  * Copyright (c) Microsoft Corporation. All rights reserved.
7153
7156
  * Licensed under the MIT License.
@@ -7165,7 +7168,7 @@
7165
7168
  }
7166
7169
  }
7167
7170
 
7168
- /*! @azure/msal-common v14.16.0 2024-12-12 */
7171
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
7169
7172
 
7170
7173
  /*
7171
7174
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7607,7 +7610,7 @@
7607
7610
  }
7608
7611
  }
7609
7612
 
7610
- /*! @azure/msal-common v14.16.0 2024-12-12 */
7613
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
7611
7614
 
7612
7615
  /*
7613
7616
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7680,7 +7683,7 @@
7680
7683
  async acquireTokenWithCachedRefreshToken(request, foci) {
7681
7684
  this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
7682
7685
  // fetches family RT or application RT based on FOCI value
7683
- const refreshToken = invoke(this.cacheManager.getRefreshToken.bind(this.cacheManager), PerformanceEvents.CacheManagerGetRefreshToken, this.logger, this.performanceClient, request.correlationId)(request.account, foci, undefined, this.performanceClient, request.correlationId);
7686
+ const refreshToken = invoke(this.cacheManager.getRefreshToken.bind(this.cacheManager), PerformanceEvents.CacheManagerGetRefreshToken, this.logger, this.performanceClient, request.correlationId)(request.account, foci, request.correlationId, undefined, this.performanceClient);
7684
7687
  if (!refreshToken) {
7685
7688
  throw createInteractionRequiredAuthError(noTokensFound);
7686
7689
  }
@@ -7708,7 +7711,7 @@
7708
7711
  // Remove bad refresh token from cache
7709
7712
  this.logger.verbose("acquireTokenWithRefreshToken: bad refresh token, removing from cache");
7710
7713
  const badRefreshTokenKey = generateCredentialKey(refreshToken);
7711
- this.cacheManager.removeRefreshToken(badRefreshTokenKey);
7714
+ this.cacheManager.removeRefreshToken(badRefreshTokenKey, request.correlationId);
7712
7715
  }
7713
7716
  throw e;
7714
7717
  }
@@ -7827,7 +7830,7 @@
7827
7830
  }
7828
7831
  }
7829
7832
 
7830
- /*! @azure/msal-common v14.16.0 2024-12-12 */
7833
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
7831
7834
 
7832
7835
  /*
7833
7836
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7897,7 +7900,7 @@
7897
7900
  const requestTenantId = request.account.tenantId ||
7898
7901
  getTenantFromAuthorityString(request.authority);
7899
7902
  const tokenKeys = this.cacheManager.getTokenKeys();
7900
- const cachedAccessToken = this.cacheManager.getAccessToken(request.account, request, tokenKeys, requestTenantId, this.performanceClient, request.correlationId);
7903
+ const cachedAccessToken = this.cacheManager.getAccessToken(request.account, request, tokenKeys, requestTenantId, this.performanceClient);
7901
7904
  if (!cachedAccessToken) {
7902
7905
  // must refresh due to non-existent access_token
7903
7906
  this.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN, request.correlationId);
@@ -7917,9 +7920,9 @@
7917
7920
  }
7918
7921
  const environment = request.authority || this.authority.getPreferredCache();
7919
7922
  const cacheRecord = {
7920
- account: this.cacheManager.readAccountFromCache(request.account),
7923
+ account: this.cacheManager.readAccountFromCache(request.account, request.correlationId),
7921
7924
  accessToken: cachedAccessToken,
7922
- idToken: this.cacheManager.getIdToken(request.account, tokenKeys, requestTenantId, this.performanceClient, request.correlationId),
7925
+ idToken: this.cacheManager.getIdToken(request.account, request.correlationId, tokenKeys, requestTenantId, this.performanceClient),
7923
7926
  refreshToken: null,
7924
7927
  appMetadata: this.cacheManager.readAppMetadataFromCache(environment),
7925
7928
  };
@@ -7963,7 +7966,7 @@
7963
7966
  }
7964
7967
  }
7965
7968
 
7966
- /*! @azure/msal-common v14.16.0 2024-12-12 */
7969
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
7967
7970
 
7968
7971
  /*
7969
7972
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7978,7 +7981,7 @@
7978
7981
  },
7979
7982
  };
7980
7983
 
7981
- /*! @azure/msal-common v14.16.0 2024-12-12 */
7984
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
7982
7985
 
7983
7986
  /*
7984
7987
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8036,7 +8039,7 @@
8036
8039
  }
8037
8040
  }
8038
8041
 
8039
- /*! @azure/msal-common v14.16.0 2024-12-12 */
8042
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
8040
8043
 
8041
8044
  /*
8042
8045
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8175,7 +8178,7 @@
8175
8178
  else {
8176
8179
  lastRequests.errors.push(SERVER_TELEM_CONSTANTS.UNKNOWN_ERROR);
8177
8180
  }
8178
- this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
8181
+ this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
8179
8182
  return;
8180
8183
  }
8181
8184
  /**
@@ -8184,7 +8187,7 @@
8184
8187
  incrementCacheHits() {
8185
8188
  const lastRequests = this.getLastRequests();
8186
8189
  lastRequests.cacheHits += 1;
8187
- this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
8190
+ this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
8188
8191
  return lastRequests.cacheHits;
8189
8192
  }
8190
8193
  /**
@@ -8208,7 +8211,7 @@
8208
8211
  const errorCount = lastRequests.errors.length;
8209
8212
  if (numErrorsFlushed === errorCount) {
8210
8213
  // All errors were sent on last request, clear Telemetry cache
8211
- this.cacheManager.removeItem(this.telemetryCacheKey);
8214
+ this.cacheManager.removeItem(this.telemetryCacheKey, this.correlationId);
8212
8215
  }
8213
8216
  else {
8214
8217
  // Partial data was flushed to server, construct a new telemetry cache item with errors that were not flushed
@@ -8217,7 +8220,7 @@
8217
8220
  errors: lastRequests.errors.slice(numErrorsFlushed),
8218
8221
  cacheHits: 0,
8219
8222
  };
8220
- this.cacheManager.setServerTelemetry(this.telemetryCacheKey, serverTelemEntity);
8223
+ this.cacheManager.setServerTelemetry(this.telemetryCacheKey, serverTelemEntity, this.correlationId);
8221
8224
  }
8222
8225
  }
8223
8226
  /**
@@ -8284,7 +8287,7 @@
8284
8287
  setNativeBrokerErrorCode(errorCode) {
8285
8288
  const lastRequests = this.getLastRequests();
8286
8289
  lastRequests.nativeBrokerErrorCode = errorCode;
8287
- this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
8290
+ this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
8288
8291
  }
8289
8292
  getNativeBrokerErrorCode() {
8290
8293
  return this.getLastRequests().nativeBrokerErrorCode;
@@ -8292,14 +8295,14 @@
8292
8295
  clearNativeBrokerErrorCode() {
8293
8296
  const lastRequests = this.getLastRequests();
8294
8297
  delete lastRequests.nativeBrokerErrorCode;
8295
- this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests);
8298
+ this.cacheManager.setServerTelemetry(this.telemetryCacheKey, lastRequests, this.correlationId);
8296
8299
  }
8297
8300
  static makeExtraSkuString(params) {
8298
8301
  return makeExtraSkuString(params);
8299
8302
  }
8300
8303
  }
8301
8304
 
8302
- /*! @azure/msal-common v14.16.0 2024-12-12 */
8305
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
8303
8306
  /*
8304
8307
  * Copyright (c) Microsoft Corporation. All rights reserved.
8305
8308
  * Licensed under the MIT License.
@@ -8307,7 +8310,7 @@
8307
8310
  const missingKidError = "missing_kid_error";
8308
8311
  const missingAlgError = "missing_alg_error";
8309
8312
 
8310
- /*! @azure/msal-common v14.16.0 2024-12-12 */
8313
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
8311
8314
 
8312
8315
  /*
8313
8316
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8332,7 +8335,7 @@
8332
8335
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
8333
8336
  }
8334
8337
 
8335
- /*! @azure/msal-common v14.16.0 2024-12-12 */
8338
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
8336
8339
 
8337
8340
  /*
8338
8341
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8372,7 +8375,7 @@
8372
8375
  }
8373
8376
  }
8374
8377
 
8375
- /*! @azure/msal-common v14.16.0 2024-12-12 */
8378
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
8376
8379
 
8377
8380
  /*
8378
8381
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8451,7 +8454,7 @@
8451
8454
  }
8452
8455
  }
8453
8456
 
8454
- /*! @azure/msal-common v14.16.0 2024-12-12 */
8457
+ /*! @azure/msal-common v14.16.1 2025-08-05 */
8455
8458
 
8456
8459
  /*
8457
8460
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9514,6 +9517,7 @@
9514
9517
  const StaticCacheKeys = {
9515
9518
  ACCOUNT_KEYS: "msal.account.keys",
9516
9519
  TOKEN_KEYS: "msal.token.keys",
9520
+ VERSION: "msal.version",
9517
9521
  };
9518
9522
  /**
9519
9523
  * Cache keys stored in-memory
@@ -9721,14 +9725,14 @@
9721
9725
  /**
9722
9726
  * Check whether browser crypto is available.
9723
9727
  */
9724
- function validateCryptoAvailable() {
9728
+ function validateCryptoAvailable(skipValidateSubtleCrypto) {
9725
9729
  if (!window) {
9726
9730
  throw createBrowserAuthError(nonBrowserEnvironment);
9727
9731
  }
9728
9732
  if (!window.crypto) {
9729
9733
  throw createBrowserAuthError(cryptoNonExistent);
9730
9734
  }
9731
- if (!window.crypto.subtle) {
9735
+ if (!skipValidateSubtleCrypto && !window.crypto.subtle) {
9732
9736
  throw createBrowserAuthError(cryptoNonExistent, SUBTLE_SUBERROR);
9733
9737
  }
9734
9738
  }
@@ -9943,7 +9947,9 @@
9943
9947
  * Returns current window URL as redirect uri
9944
9948
  */
9945
9949
  function getCurrentUri() {
9946
- return window.location.href.split("?")[0].split("#")[0];
9950
+ return typeof window !== "undefined" && window.location
9951
+ ? window.location.href.split("?")[0].split("#")[0]
9952
+ : "";
9947
9953
  }
9948
9954
  /**
9949
9955
  * Gets the homepage url for the current window location.
@@ -10370,7 +10376,7 @@
10370
10376
 
10371
10377
  /* eslint-disable header/header */
10372
10378
  const name = "@azure/msal-browser";
10373
- const version = "3.28.0";
10379
+ const version = "3.30.0";
10374
10380
 
10375
10381
  /*
10376
10382
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11157,10 +11163,10 @@
11157
11163
  * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
11158
11164
  */
11159
11165
  class CryptoOps {
11160
- constructor(logger, performanceClient) {
11166
+ constructor(logger, performanceClient, skipValidateSubtleCrypto) {
11161
11167
  this.logger = logger;
11162
11168
  // Browser crypto needs to be validated first before any other classes can be set.
11163
- validateCryptoAvailable();
11169
+ validateCryptoAvailable(skipValidateSubtleCrypto ?? false);
11164
11170
  this.cache = new AsyncMemoryStorage(this.logger);
11165
11171
  this.performanceClient = performanceClient;
11166
11172
  }
@@ -11511,6 +11517,13 @@
11511
11517
  * @param storeAuthStateInCookie
11512
11518
  */
11513
11519
  migrateCacheEntries() {
11520
+ const previousVersion = this.browserStorage.getItem(StaticCacheKeys.VERSION);
11521
+ if (previousVersion) {
11522
+ this.logger.info(`MSAL.js was last initialized with version ${previousVersion}`);
11523
+ }
11524
+ if (previousVersion !== version) {
11525
+ this.browserStorage.setItem(StaticCacheKeys.VERSION, version);
11526
+ }
11514
11527
  const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
11515
11528
  const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
11516
11529
  const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
@@ -11545,6 +11558,7 @@
11545
11558
  */
11546
11559
  createKeyMaps() {
11547
11560
  this.logger.trace("BrowserCacheManager - createKeyMaps called.");
11561
+ const correlationId = this.cryptoImpl.createNewGuid();
11548
11562
  const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
11549
11563
  const tokenKeys = this.getItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
11550
11564
  if (accountKeys && tokenKeys) {
@@ -11566,8 +11580,8 @@
11566
11580
  this.logger.trace("BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map");
11567
11581
  this.logger.tracePii(`BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`);
11568
11582
  const idTokenEntity = credObj;
11569
- const newKey = this.updateCredentialCacheKey(key, idTokenEntity);
11570
- this.addTokenKey(newKey, CredentialType.ID_TOKEN);
11583
+ const newKey = this.updateCredentialCacheKey(key, idTokenEntity, correlationId);
11584
+ this.addTokenKey(newKey, CredentialType.ID_TOKEN, correlationId);
11571
11585
  return;
11572
11586
  }
11573
11587
  else {
@@ -11581,8 +11595,8 @@
11581
11595
  this.logger.trace("BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map");
11582
11596
  this.logger.tracePii(`BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`);
11583
11597
  const accessTokenEntity = credObj;
11584
- const newKey = this.updateCredentialCacheKey(key, accessTokenEntity);
11585
- this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN);
11598
+ const newKey = this.updateCredentialCacheKey(key, accessTokenEntity, correlationId);
11599
+ this.addTokenKey(newKey, CredentialType.ACCESS_TOKEN, correlationId);
11586
11600
  return;
11587
11601
  }
11588
11602
  else {
@@ -11595,8 +11609,8 @@
11595
11609
  this.logger.trace("BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map");
11596
11610
  this.logger.tracePii(`BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`);
11597
11611
  const refreshTokenEntity = credObj;
11598
- const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity);
11599
- this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN);
11612
+ const newKey = this.updateCredentialCacheKey(key, refreshTokenEntity, correlationId);
11613
+ this.addTokenKey(newKey, CredentialType.REFRESH_TOKEN, correlationId);
11600
11614
  return;
11601
11615
  }
11602
11616
  else {
@@ -11617,7 +11631,7 @@
11617
11631
  AccountEntity.isAccountEntity(accountObj)) {
11618
11632
  this.logger.trace("BrowserCacheManager:createKeyMaps - account found, saving key to account key map");
11619
11633
  this.logger.tracePii(`BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`);
11620
- this.addAccountKeyToMap(key);
11634
+ this.addAccountKeyToMap(key, correlationId);
11621
11635
  }
11622
11636
  }
11623
11637
  }
@@ -11656,17 +11670,58 @@
11656
11670
  * @param key
11657
11671
  * @param value
11658
11672
  */
11659
- setItem(key, value) {
11660
- this.browserStorage.setItem(key, value);
11673
+ setItem(key, value, correlationId) {
11674
+ let accessTokenKeys = [];
11675
+ const maxRetries = 20;
11676
+ for (let i = 0; i <= maxRetries; i++) {
11677
+ try {
11678
+ this.browserStorage.setItem(key, value);
11679
+ if (i > 0) {
11680
+ // Finally update the token keys array with the tokens removed
11681
+ this.removeAccessTokenKeys(accessTokenKeys.slice(0, i), correlationId);
11682
+ }
11683
+ break; // If setItem succeeds, exit the loop
11684
+ }
11685
+ catch (e) {
11686
+ const cacheError = createCacheError(e);
11687
+ if (cacheError.errorCode ===
11688
+ cacheQuotaExceeded &&
11689
+ i < maxRetries) {
11690
+ if (!accessTokenKeys.length) {
11691
+ if (key ===
11692
+ `${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`) {
11693
+ // If we are currently trying to set the token keys, use the value we're trying to set
11694
+ accessTokenKeys = JSON.parse(value)
11695
+ .accessToken;
11696
+ }
11697
+ else {
11698
+ // If token keys have not been initialized, get them
11699
+ accessTokenKeys = this.getTokenKeys().accessToken;
11700
+ }
11701
+ }
11702
+ if (accessTokenKeys.length <= i) {
11703
+ // Nothing to remove, rethrow the error
11704
+ throw cacheError;
11705
+ }
11706
+ // When cache quota is exceeded, start removing access tokens until we can successfully set the item
11707
+ this.removeAccessToken(accessTokenKeys[i], correlationId, false // Don't save token keys yet, do it at the end
11708
+ );
11709
+ }
11710
+ else {
11711
+ // If the error is not a quota exceeded error, rethrow it
11712
+ throw cacheError;
11713
+ }
11714
+ }
11715
+ }
11661
11716
  }
11662
11717
  /**
11663
11718
  * fetch the account entity from the platform cache
11664
11719
  * @param accountKey
11665
11720
  */
11666
- getAccount(accountKey, logger) {
11721
+ getAccount(accountKey, correlationId, logger) {
11667
11722
  this.logger.trace("BrowserCacheManager.getAccount called");
11668
- const accountEntity = this.getCachedAccountEntity(accountKey);
11669
- return this.updateOutdatedCachedAccount(accountKey, accountEntity, logger);
11723
+ const accountEntity = this.getCachedAccountEntity(accountKey, correlationId);
11724
+ return this.updateOutdatedCachedAccount(accountKey, accountEntity, correlationId, logger);
11670
11725
  }
11671
11726
  /**
11672
11727
  * Reads account from cache, deserializes it into an account entity and returns it.
@@ -11674,15 +11729,14 @@
11674
11729
  * @param accountKey
11675
11730
  * @returns
11676
11731
  */
11677
- getCachedAccountEntity(accountKey) {
11732
+ getCachedAccountEntity(accountKey, correlationId) {
11678
11733
  const serializedAccount = this.getItem(accountKey);
11679
11734
  if (!serializedAccount) {
11680
- this.removeAccountKeyFromMap(accountKey);
11735
+ this.removeAccountKeyFromMap(accountKey, correlationId);
11681
11736
  return null;
11682
11737
  }
11683
11738
  const parsedAccount = this.validateAndParseJson(serializedAccount);
11684
11739
  if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {
11685
- this.removeAccountKeyFromMap(accountKey);
11686
11740
  return null;
11687
11741
  }
11688
11742
  return CacheManager.toObject(new AccountEntity(), parsedAccount);
@@ -11691,11 +11745,12 @@
11691
11745
  * set account entity in the platform cache
11692
11746
  * @param account
11693
11747
  */
11694
- setAccount(account) {
11748
+ setAccount(account, correlationId) {
11695
11749
  this.logger.trace("BrowserCacheManager.setAccount called");
11696
11750
  const key = account.generateAccountKey();
11697
- this.setItem(key, JSON.stringify(account));
11698
- this.addAccountKeyToMap(key);
11751
+ account.lastUpdatedAt = Date.now().toString();
11752
+ this.setItem(key, JSON.stringify(account), correlationId);
11753
+ this.addAccountKeyToMap(key, correlationId);
11699
11754
  }
11700
11755
  /**
11701
11756
  * Returns the array of account keys currently cached
@@ -11714,14 +11769,14 @@
11714
11769
  * Add a new account to the key map
11715
11770
  * @param key
11716
11771
  */
11717
- addAccountKeyToMap(key) {
11772
+ addAccountKeyToMap(key, correlationId) {
11718
11773
  this.logger.trace("BrowserCacheManager.addAccountKeyToMap called");
11719
11774
  this.logger.tracePii(`BrowserCacheManager.addAccountKeyToMap called with key: ${key}`);
11720
11775
  const accountKeys = this.getAccountKeys();
11721
11776
  if (accountKeys.indexOf(key) === -1) {
11722
11777
  // Only add key if it does not already exist in the map
11723
11778
  accountKeys.push(key);
11724
- this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11779
+ this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys), correlationId);
11725
11780
  this.logger.verbose("BrowserCacheManager.addAccountKeyToMap account key added");
11726
11781
  }
11727
11782
  else {
@@ -11732,14 +11787,21 @@
11732
11787
  * Remove an account from the key map
11733
11788
  * @param key
11734
11789
  */
11735
- removeAccountKeyFromMap(key) {
11790
+ removeAccountKeyFromMap(key, correlationId) {
11736
11791
  this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap called");
11737
11792
  this.logger.tracePii(`BrowserCacheManager.removeAccountKeyFromMap called with key: ${key}`);
11738
11793
  const accountKeys = this.getAccountKeys();
11739
11794
  const removalIndex = accountKeys.indexOf(key);
11740
11795
  if (removalIndex > -1) {
11741
11796
  accountKeys.splice(removalIndex, 1);
11742
- this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys));
11797
+ if (accountKeys.length === 0) {
11798
+ // If no keys left, remove the map
11799
+ this.removeItem(StaticCacheKeys.ACCOUNT_KEYS);
11800
+ return;
11801
+ }
11802
+ else {
11803
+ this.setItem(StaticCacheKeys.ACCOUNT_KEYS, JSON.stringify(accountKeys), correlationId);
11804
+ }
11743
11805
  this.logger.trace("BrowserCacheManager.removeAccountKeyFromMap account key removed");
11744
11806
  }
11745
11807
  else {
@@ -11750,41 +11812,60 @@
11750
11812
  * Extends inherited removeAccount function to include removal of the account key from the map
11751
11813
  * @param key
11752
11814
  */
11753
- async removeAccount(key) {
11754
- void super.removeAccount(key);
11755
- this.removeAccountKeyFromMap(key);
11815
+ async removeAccount(key, correlationId) {
11816
+ void super.removeAccount(key, correlationId);
11817
+ this.removeAccountKeyFromMap(key, correlationId);
11756
11818
  }
11757
11819
  /**
11758
11820
  * Remove account entity from the platform cache if it's outdated
11759
11821
  * @param accountKey
11760
11822
  */
11761
- removeOutdatedAccount(accountKey) {
11823
+ removeOutdatedAccount(accountKey, correlationId) {
11762
11824
  this.removeItem(accountKey);
11763
- this.removeAccountKeyFromMap(accountKey);
11825
+ this.removeAccountKeyFromMap(accountKey, correlationId);
11764
11826
  }
11765
11827
  /**
11766
11828
  * Removes given idToken from the cache and from the key map
11767
11829
  * @param key
11768
11830
  */
11769
- removeIdToken(key) {
11770
- super.removeIdToken(key);
11771
- this.removeTokenKey(key, CredentialType.ID_TOKEN);
11831
+ removeIdToken(key, correlationId) {
11832
+ super.removeIdToken(key, correlationId);
11833
+ this.removeTokenKey(key, CredentialType.ID_TOKEN, correlationId);
11772
11834
  }
11773
11835
  /**
11774
11836
  * Removes given accessToken from the cache and from the key map
11775
11837
  * @param key
11776
11838
  */
11777
- async removeAccessToken(key) {
11778
- void super.removeAccessToken(key);
11779
- this.removeTokenKey(key, CredentialType.ACCESS_TOKEN);
11839
+ removeAccessToken(key, correlationId, updateTokenKeys = true) {
11840
+ super.removeAccessToken(key, correlationId);
11841
+ this.performanceClient?.incrementFields({ accessTokensRemoved: 1 }, correlationId);
11842
+ updateTokenKeys &&
11843
+ this.removeTokenKey(key, CredentialType.ACCESS_TOKEN, correlationId);
11844
+ }
11845
+ removeAccessTokenKeys(keys, correlationId) {
11846
+ this.logger.trace("removeAccessTokenKey called");
11847
+ const tokenKeys = this.getTokenKeys();
11848
+ let keysRemoved = 0;
11849
+ keys.forEach((key) => {
11850
+ const accessRemoval = tokenKeys.accessToken.indexOf(key);
11851
+ if (accessRemoval > -1) {
11852
+ tokenKeys.accessToken.splice(accessRemoval, 1);
11853
+ keysRemoved++;
11854
+ }
11855
+ });
11856
+ if (keysRemoved > 0) {
11857
+ this.logger.info(`removed ${keysRemoved} accessToken keys from tokenKeys map`);
11858
+ this.setTokenKeys(tokenKeys, correlationId);
11859
+ return;
11860
+ }
11780
11861
  }
11781
11862
  /**
11782
11863
  * Removes given refreshToken from the cache and from the key map
11783
11864
  * @param key
11784
11865
  */
11785
- removeRefreshToken(key) {
11786
- super.removeRefreshToken(key);
11787
- this.removeTokenKey(key, CredentialType.REFRESH_TOKEN);
11866
+ removeRefreshToken(key, correlationId) {
11867
+ super.removeRefreshToken(key, correlationId);
11868
+ this.removeTokenKey(key, CredentialType.REFRESH_TOKEN, correlationId);
11788
11869
  }
11789
11870
  /**
11790
11871
  * Gets the keys for the cached tokens associated with this clientId
@@ -11814,12 +11895,30 @@
11814
11895
  refreshToken: [],
11815
11896
  };
11816
11897
  }
11898
+ /**
11899
+ * Stores the token keys in the cache
11900
+ * @param tokenKeys
11901
+ * @param correlationId
11902
+ * @returns
11903
+ */
11904
+ setTokenKeys(tokenKeys, correlationId) {
11905
+ if (tokenKeys.idToken.length === 0 &&
11906
+ tokenKeys.accessToken.length === 0 &&
11907
+ tokenKeys.refreshToken.length === 0) {
11908
+ // If no keys left, remove the map
11909
+ this.removeItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`);
11910
+ return;
11911
+ }
11912
+ else {
11913
+ this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys), correlationId);
11914
+ }
11915
+ }
11817
11916
  /**
11818
11917
  * Adds the given key to the token key map
11819
11918
  * @param key
11820
11919
  * @param type
11821
11920
  */
11822
- addTokenKey(key, type) {
11921
+ addTokenKey(key, type, correlationId) {
11823
11922
  this.logger.trace("BrowserCacheManager addTokenKey called");
11824
11923
  const tokenKeys = this.getTokenKeys();
11825
11924
  switch (type) {
@@ -11830,10 +11929,12 @@
11830
11929
  }
11831
11930
  break;
11832
11931
  case CredentialType.ACCESS_TOKEN:
11833
- if (tokenKeys.accessToken.indexOf(key) === -1) {
11834
- this.logger.info("BrowserCacheManager: addTokenKey - accessToken added to map");
11835
- tokenKeys.accessToken.push(key);
11932
+ const index = tokenKeys.accessToken.indexOf(key);
11933
+ if (index !== -1) {
11934
+ tokenKeys.accessToken.splice(index, 1); // Remove existing key before pushing to the end
11836
11935
  }
11936
+ this.logger.trace(`access token ${index === -1 ? "added to" : "updated in"} map`);
11937
+ tokenKeys.accessToken.push(key);
11837
11938
  break;
11838
11939
  case CredentialType.REFRESH_TOKEN:
11839
11940
  if (tokenKeys.refreshToken.indexOf(key) === -1) {
@@ -11845,16 +11946,15 @@
11845
11946
  this.logger.error(`BrowserCacheManager:addTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
11846
11947
  throw createClientAuthError(unexpectedCredentialType);
11847
11948
  }
11848
- this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11949
+ this.setTokenKeys(tokenKeys, correlationId);
11849
11950
  }
11850
11951
  /**
11851
11952
  * Removes the given key from the token key map
11852
11953
  * @param key
11853
11954
  * @param type
11854
11955
  */
11855
- removeTokenKey(key, type) {
11956
+ removeTokenKey(key, type, correlationId, tokenKeys = this.getTokenKeys()) {
11856
11957
  this.logger.trace("BrowserCacheManager removeTokenKey called");
11857
- const tokenKeys = this.getTokenKeys();
11858
11958
  switch (type) {
11859
11959
  case CredentialType.ID_TOKEN:
11860
11960
  this.logger.infoPii(`BrowserCacheManager: removeTokenKey - attempting to remove idToken with key: ${key} from map`);
@@ -11893,23 +11993,22 @@
11893
11993
  this.logger.error(`BrowserCacheManager:removeTokenKey - CredentialType provided invalid. CredentialType: ${type}`);
11894
11994
  throw createClientAuthError(unexpectedCredentialType);
11895
11995
  }
11896
- this.setItem(`${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`, JSON.stringify(tokenKeys));
11996
+ this.setTokenKeys(tokenKeys, correlationId);
11897
11997
  }
11898
11998
  /**
11899
11999
  * generates idToken entity from a string
11900
12000
  * @param idTokenKey
11901
12001
  */
11902
- getIdTokenCredential(idTokenKey) {
12002
+ getIdTokenCredential(idTokenKey, correlationId) {
11903
12003
  const value = this.getItem(idTokenKey);
11904
12004
  if (!value) {
11905
12005
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
11906
- this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
12006
+ this.removeIdToken(idTokenKey, correlationId);
11907
12007
  return null;
11908
12008
  }
11909
12009
  const parsedIdToken = this.validateAndParseJson(value);
11910
12010
  if (!parsedIdToken || !isIdTokenEntity(parsedIdToken)) {
11911
12011
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: called, no cache hit");
11912
- this.removeTokenKey(idTokenKey, CredentialType.ID_TOKEN);
11913
12012
  return null;
11914
12013
  }
11915
12014
  this.logger.trace("BrowserCacheManager.getIdTokenCredential: cache hit");
@@ -11919,28 +12018,28 @@
11919
12018
  * set IdToken credential to the platform cache
11920
12019
  * @param idToken
11921
12020
  */
11922
- setIdTokenCredential(idToken) {
12021
+ setIdTokenCredential(idToken, correlationId) {
11923
12022
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
11924
12023
  const idTokenKey = generateCredentialKey(idToken);
11925
- this.setItem(idTokenKey, JSON.stringify(idToken));
11926
- this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
12024
+ idToken.lastUpdatedAt = Date.now().toString();
12025
+ this.setItem(idTokenKey, JSON.stringify(idToken), correlationId);
12026
+ this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN, correlationId);
11927
12027
  }
11928
12028
  /**
11929
12029
  * generates accessToken entity from a string
11930
12030
  * @param key
11931
12031
  */
11932
- getAccessTokenCredential(accessTokenKey) {
12032
+ getAccessTokenCredential(accessTokenKey, correlationId) {
11933
12033
  const value = this.getItem(accessTokenKey);
11934
12034
  if (!value) {
11935
12035
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
11936
- this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
12036
+ this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN, correlationId);
11937
12037
  return null;
11938
12038
  }
11939
12039
  const parsedAccessToken = this.validateAndParseJson(value);
11940
12040
  if (!parsedAccessToken ||
11941
12041
  !isAccessTokenEntity(parsedAccessToken)) {
11942
12042
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: called, no cache hit");
11943
- this.removeTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
11944
12043
  return null;
11945
12044
  }
11946
12045
  this.logger.trace("BrowserCacheManager.getAccessTokenCredential: cache hit");
@@ -11950,28 +12049,28 @@
11950
12049
  * set accessToken credential to the platform cache
11951
12050
  * @param accessToken
11952
12051
  */
11953
- setAccessTokenCredential(accessToken) {
12052
+ setAccessTokenCredential(accessToken, correlationId) {
11954
12053
  this.logger.trace("BrowserCacheManager.setAccessTokenCredential called");
11955
12054
  const accessTokenKey = generateCredentialKey(accessToken);
11956
- this.setItem(accessTokenKey, JSON.stringify(accessToken));
11957
- this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
12055
+ accessToken.lastUpdatedAt = Date.now().toString();
12056
+ this.setItem(accessTokenKey, JSON.stringify(accessToken), correlationId);
12057
+ this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN, correlationId);
11958
12058
  }
11959
12059
  /**
11960
12060
  * generates refreshToken entity from a string
11961
12061
  * @param refreshTokenKey
11962
12062
  */
11963
- getRefreshTokenCredential(refreshTokenKey) {
12063
+ getRefreshTokenCredential(refreshTokenKey, correlationId) {
11964
12064
  const value = this.getItem(refreshTokenKey);
11965
12065
  if (!value) {
11966
12066
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
11967
- this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
12067
+ this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN, correlationId);
11968
12068
  return null;
11969
12069
  }
11970
12070
  const parsedRefreshToken = this.validateAndParseJson(value);
11971
12071
  if (!parsedRefreshToken ||
11972
12072
  !isRefreshTokenEntity(parsedRefreshToken)) {
11973
12073
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: called, no cache hit");
11974
- this.removeTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
11975
12074
  return null;
11976
12075
  }
11977
12076
  this.logger.trace("BrowserCacheManager.getRefreshTokenCredential: cache hit");
@@ -11981,11 +12080,12 @@
11981
12080
  * set refreshToken credential to the platform cache
11982
12081
  * @param refreshToken
11983
12082
  */
11984
- setRefreshTokenCredential(refreshToken) {
12083
+ setRefreshTokenCredential(refreshToken, correlationId) {
11985
12084
  this.logger.trace("BrowserCacheManager.setRefreshTokenCredential called");
11986
12085
  const refreshTokenKey = generateCredentialKey(refreshToken);
11987
- this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
11988
- this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
12086
+ refreshToken.lastUpdatedAt = Date.now().toString();
12087
+ this.setItem(refreshTokenKey, JSON.stringify(refreshToken), correlationId);
12088
+ this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN, correlationId);
11989
12089
  }
11990
12090
  /**
11991
12091
  * fetch appMetadata entity from the platform cache
@@ -12010,10 +12110,10 @@
12010
12110
  * set appMetadata entity to the platform cache
12011
12111
  * @param appMetadata
12012
12112
  */
12013
- setAppMetadata(appMetadata) {
12113
+ setAppMetadata(appMetadata, correlationId) {
12014
12114
  this.logger.trace("BrowserCacheManager.setAppMetadata called");
12015
12115
  const appMetadataKey = generateAppMetadataKey(appMetadata);
12016
- this.setItem(appMetadataKey, JSON.stringify(appMetadata));
12116
+ this.setItem(appMetadataKey, JSON.stringify(appMetadata), correlationId);
12017
12117
  }
12018
12118
  /**
12019
12119
  * fetch server telemetry entity from the platform cache
@@ -12039,9 +12139,9 @@
12039
12139
  * @param serverTelemetryKey
12040
12140
  * @param serverTelemetry
12041
12141
  */
12042
- setServerTelemetry(serverTelemetryKey, serverTelemetry) {
12142
+ setServerTelemetry(serverTelemetryKey, serverTelemetry, correlationId) {
12043
12143
  this.logger.trace("BrowserCacheManager.setServerTelemetry called");
12044
- this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
12144
+ this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry), correlationId);
12045
12145
  }
12046
12146
  /**
12047
12147
  *
@@ -12099,7 +12199,7 @@
12099
12199
  /**
12100
12200
  * Gets the active account
12101
12201
  */
12102
- getActiveAccount() {
12202
+ getActiveAccount(correlationId) {
12103
12203
  const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
12104
12204
  const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
12105
12205
  if (!activeAccountValueFilters) {
@@ -12113,11 +12213,11 @@
12113
12213
  }
12114
12214
  const activeAccount = this.getAccountInfoFilteredBy({
12115
12215
  localAccountId: activeAccountValueLocal,
12116
- });
12216
+ }, correlationId);
12117
12217
  if (activeAccount) {
12118
12218
  this.logger.trace("BrowserCacheManager.getActiveAccount: Legacy active account cache schema found");
12119
12219
  this.logger.trace("BrowserCacheManager.getActiveAccount: Adding active account filters cache schema");
12120
- this.setActiveAccount(activeAccount);
12220
+ this.setActiveAccount(activeAccount, correlationId);
12121
12221
  return activeAccount;
12122
12222
  }
12123
12223
  return null;
@@ -12129,7 +12229,7 @@
12129
12229
  homeAccountId: activeAccountValueObj.homeAccountId,
12130
12230
  localAccountId: activeAccountValueObj.localAccountId,
12131
12231
  tenantId: activeAccountValueObj.tenantId,
12132
- });
12232
+ }, correlationId);
12133
12233
  }
12134
12234
  this.logger.trace("BrowserCacheManager.getActiveAccount: No active account found");
12135
12235
  return null;
@@ -12138,7 +12238,7 @@
12138
12238
  * Sets the active account's localAccountId in cache
12139
12239
  * @param account
12140
12240
  */
12141
- setActiveAccount(account) {
12241
+ setActiveAccount(account, correlationId) {
12142
12242
  const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
12143
12243
  const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
12144
12244
  if (account) {
@@ -12147,9 +12247,10 @@
12147
12247
  homeAccountId: account.homeAccountId,
12148
12248
  localAccountId: account.localAccountId,
12149
12249
  tenantId: account.tenantId,
12250
+ lastUpdatedAt: Date.now().toString(),
12150
12251
  };
12151
- this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
12152
- this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
12252
+ this.setItem(activeAccountKey, JSON.stringify(activeAccountValue), correlationId);
12253
+ this.setItem(activeAccountKeyLocal, account.localAccountId, correlationId);
12153
12254
  }
12154
12255
  else {
12155
12256
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
@@ -12181,9 +12282,9 @@
12181
12282
  * @param throttlingCacheKey
12182
12283
  * @param throttlingCache
12183
12284
  */
12184
- setThrottlingCache(throttlingCacheKey, throttlingCache) {
12285
+ setThrottlingCache(throttlingCacheKey, throttlingCache, correlationId) {
12185
12286
  this.logger.trace("BrowserCacheManager.setThrottlingCache called");
12186
- this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
12287
+ this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache), correlationId);
12187
12288
  }
12188
12289
  /**
12189
12290
  * Gets cache item with given key.
@@ -12259,10 +12360,10 @@
12259
12360
  /**
12260
12361
  * Clears all cache entries created by MSAL.
12261
12362
  */
12262
- async clear() {
12363
+ async clear(correlationId) {
12263
12364
  // Removes all accounts and their credentials
12264
- await this.removeAllAccounts();
12265
- this.removeAppMetadata();
12365
+ await this.removeAllAccounts(correlationId);
12366
+ this.removeAppMetadata(correlationId);
12266
12367
  // Remove temp storage first to make sure any cookies are cleared
12267
12368
  this.temporaryCacheStorage.getKeys().forEach((cacheKey) => {
12268
12369
  if (cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
@@ -12288,19 +12389,19 @@
12288
12389
  async clearTokensAndKeysWithClaims(performanceClient, correlationId) {
12289
12390
  performanceClient.addQueueMeasurement(PerformanceEvents.ClearTokensAndKeysWithClaims, correlationId);
12290
12391
  const tokenKeys = this.getTokenKeys();
12291
- const removedAccessTokens = [];
12392
+ let removedAccessTokens = 0;
12292
12393
  tokenKeys.accessToken.forEach((key) => {
12293
12394
  // if the access token has claims in its key, remove the token key and the token
12294
- const credential = this.getAccessTokenCredential(key);
12395
+ const credential = this.getAccessTokenCredential(key, correlationId);
12295
12396
  if (credential?.requestedClaimsHash &&
12296
12397
  key.includes(credential.requestedClaimsHash.toLowerCase())) {
12297
- removedAccessTokens.push(this.removeAccessToken(key));
12398
+ this.removeAccessToken(key, correlationId);
12399
+ removedAccessTokens++;
12298
12400
  }
12299
12401
  });
12300
- await Promise.all(removedAccessTokens);
12301
12402
  // warn if any access tokens are removed
12302
- if (removedAccessTokens.length > 0) {
12303
- this.logger.warning(`${removedAccessTokens.length} access tokens with claims in the cache keys have been removed from the cache.`);
12403
+ if (removedAccessTokens > 0) {
12404
+ this.logger.warning(`${removedAccessTokens} access tokens with claims in the cache keys have been removed from the cache.`);
12304
12405
  }
12305
12406
  }
12306
12407
  /**
@@ -12575,13 +12676,13 @@
12575
12676
  /**
12576
12677
  * Updates a credential's cache key if the current cache key is outdated
12577
12678
  */
12578
- updateCredentialCacheKey(currentCacheKey, credential) {
12679
+ updateCredentialCacheKey(currentCacheKey, credential, correlationId) {
12579
12680
  const updatedCacheKey = generateCredentialKey(credential);
12580
12681
  if (currentCacheKey !== updatedCacheKey) {
12581
12682
  const cacheItem = this.getItem(currentCacheKey);
12582
12683
  if (cacheItem) {
12583
12684
  this.browserStorage.removeItem(currentCacheKey);
12584
- this.setItem(updatedCacheKey, cacheItem);
12685
+ this.setItem(updatedCacheKey, cacheItem, correlationId);
12585
12686
  this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
12586
12687
  return updatedCacheKey;
12587
12688
  }
@@ -12616,7 +12717,7 @@
12616
12717
  idToken: idTokenEntity,
12617
12718
  accessToken: accessTokenEntity,
12618
12719
  };
12619
- return this.saveCacheRecord(cacheRecord);
12720
+ return this.saveCacheRecord(cacheRecord, result.correlationId);
12620
12721
  }
12621
12722
  /**
12622
12723
  * saves a cache record
@@ -12624,9 +12725,9 @@
12624
12725
  * @param storeInCache {?StoreInCache}
12625
12726
  * @param correlationId {?string} correlation id
12626
12727
  */
12627
- async saveCacheRecord(cacheRecord, storeInCache, correlationId) {
12728
+ async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
12628
12729
  try {
12629
- await super.saveCacheRecord(cacheRecord, storeInCache, correlationId);
12730
+ await super.saveCacheRecord(cacheRecord, correlationId, storeInCache);
12630
12731
  }
12631
12732
  catch (e) {
12632
12733
  if (e instanceof CacheError &&
@@ -12667,22 +12768,24 @@
12667
12768
  * @param accountFilter - (Optional) filter to narrow down the accounts returned
12668
12769
  * @returns Array of AccountInfo objects in cache
12669
12770
  */
12670
- function getAllAccounts(logger, browserStorage, isInBrowser, accountFilter) {
12771
+ function getAllAccounts(logger, browserStorage, isInBrowser, correlationId, accountFilter) {
12671
12772
  logger.verbose("getAllAccounts called");
12672
- return isInBrowser ? browserStorage.getAllAccounts(accountFilter) : [];
12773
+ return isInBrowser
12774
+ ? browserStorage.getAllAccounts(correlationId, accountFilter)
12775
+ : [];
12673
12776
  }
12674
12777
  /**
12675
12778
  * Returns the first account found in the cache that matches the account filter passed in.
12676
12779
  * @param accountFilter
12677
12780
  * @returns The first account found in the cache matching the provided filter or null if no account could be found.
12678
12781
  */
12679
- function getAccount(accountFilter, logger, browserStorage) {
12782
+ function getAccount(accountFilter, logger, browserStorage, correlationId) {
12680
12783
  logger.trace("getAccount called");
12681
12784
  if (Object.keys(accountFilter).length === 0) {
12682
12785
  logger.warning("getAccount: No accountFilter provided");
12683
12786
  return null;
12684
12787
  }
12685
- const account = browserStorage.getAccountInfoFilteredBy(accountFilter);
12788
+ const account = browserStorage.getAccountInfoFilteredBy(accountFilter, correlationId);
12686
12789
  if (account) {
12687
12790
  logger.verbose("getAccount: Account matching provided filter found, returning");
12688
12791
  return account;
@@ -12700,7 +12803,7 @@
12700
12803
  * @param username
12701
12804
  * @returns The account object stored in MSAL
12702
12805
  */
12703
- function getAccountByUsername(username, logger, browserStorage) {
12806
+ function getAccountByUsername(username, logger, browserStorage, correlationId) {
12704
12807
  logger.trace("getAccountByUsername called");
12705
12808
  if (!username) {
12706
12809
  logger.warning("getAccountByUsername: No username provided");
@@ -12708,7 +12811,7 @@
12708
12811
  }
12709
12812
  const account = browserStorage.getAccountInfoFilteredBy({
12710
12813
  username,
12711
- });
12814
+ }, correlationId);
12712
12815
  if (account) {
12713
12816
  logger.verbose("getAccountByUsername: Account matching username found, returning");
12714
12817
  logger.verbosePii(`getAccountByUsername: Returning signed-in accounts matching username: ${username}`);
@@ -12726,7 +12829,7 @@
12726
12829
  * @param homeAccountId
12727
12830
  * @returns The account object stored in MSAL
12728
12831
  */
12729
- function getAccountByHomeId(homeAccountId, logger, browserStorage) {
12832
+ function getAccountByHomeId(homeAccountId, logger, browserStorage, correlationId) {
12730
12833
  logger.trace("getAccountByHomeId called");
12731
12834
  if (!homeAccountId) {
12732
12835
  logger.warning("getAccountByHomeId: No homeAccountId provided");
@@ -12734,7 +12837,7 @@
12734
12837
  }
12735
12838
  const account = browserStorage.getAccountInfoFilteredBy({
12736
12839
  homeAccountId,
12737
- });
12840
+ }, correlationId);
12738
12841
  if (account) {
12739
12842
  logger.verbose("getAccountByHomeId: Account matching homeAccountId found, returning");
12740
12843
  logger.verbosePii(`getAccountByHomeId: Returning signed-in accounts matching homeAccountId: ${homeAccountId}`);
@@ -12752,7 +12855,7 @@
12752
12855
  * @param localAccountId
12753
12856
  * @returns The account object stored in MSAL
12754
12857
  */
12755
- function getAccountByLocalId(localAccountId, logger, browserStorage) {
12858
+ function getAccountByLocalId(localAccountId, logger, browserStorage, correlationId) {
12756
12859
  logger.trace("getAccountByLocalId called");
12757
12860
  if (!localAccountId) {
12758
12861
  logger.warning("getAccountByLocalId: No localAccountId provided");
@@ -12760,7 +12863,7 @@
12760
12863
  }
12761
12864
  const account = browserStorage.getAccountInfoFilteredBy({
12762
12865
  localAccountId,
12763
- });
12866
+ }, correlationId);
12764
12867
  if (account) {
12765
12868
  logger.verbose("getAccountByLocalId: Account matching localAccountId found, returning");
12766
12869
  logger.verbosePii(`getAccountByLocalId: Returning signed-in accounts matching localAccountId: ${localAccountId}`);
@@ -12775,14 +12878,14 @@
12775
12878
  * Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
12776
12879
  * @param account
12777
12880
  */
12778
- function setActiveAccount(account, browserStorage) {
12779
- browserStorage.setActiveAccount(account);
12881
+ function setActiveAccount(account, browserStorage, correlationId) {
12882
+ browserStorage.setActiveAccount(account, correlationId);
12780
12883
  }
12781
12884
  /**
12782
12885
  * Gets the currently active account
12783
12886
  */
12784
- function getActiveAccount(browserStorage) {
12785
- return browserStorage.getActiveAccount();
12887
+ function getActiveAccount(browserStorage, correlationId) {
12888
+ return browserStorage.getActiveAccount(correlationId);
12786
12889
  }
12787
12890
 
12788
12891
  /*
@@ -12900,13 +13003,13 @@
12900
13003
  }
12901
13004
  async clearCacheOnLogout(account) {
12902
13005
  if (account) {
12903
- if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(), false)) {
13006
+ if (AccountEntity.accountInfoIsEqual(account, this.browserStorage.getActiveAccount(this.correlationId), false)) {
12904
13007
  this.logger.verbose("Setting active account to null");
12905
- this.browserStorage.setActiveAccount(null);
13008
+ this.browserStorage.setActiveAccount(null, this.correlationId);
12906
13009
  }
12907
13010
  // Clear given account.
12908
13011
  try {
12909
- await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account));
13012
+ await this.browserStorage.removeAccount(AccountEntity.generateAccountCacheKey(account), this.correlationId);
12910
13013
  this.logger.verbose("Cleared cache items belonging to the account provided in the logout request.");
12911
13014
  }
12912
13015
  catch (error) {
@@ -12917,7 +13020,7 @@
12917
13020
  try {
12918
13021
  this.logger.verbose("No account provided in logout request, clearing all cache items.", this.correlationId);
12919
13022
  // Clear all accounts and tokens
12920
- await this.browserStorage.clear();
13023
+ await this.browserStorage.clear(this.correlationId);
12921
13024
  // Clear any stray keys from IndexedDB
12922
13025
  await this.browserCrypto.clearKeystore();
12923
13026
  }
@@ -13311,7 +13414,8 @@
13311
13414
  if (request.loginHint || request.sid) {
13312
13415
  return validatedRequest;
13313
13416
  }
13314
- const account = request.account || this.browserStorage.getActiveAccount();
13417
+ const account = request.account ||
13418
+ this.browserStorage.getActiveAccount(this.correlationId);
13315
13419
  if (account) {
13316
13420
  this.logger.verbose("Setting validated request account", this.correlationId);
13317
13421
  this.logger.verbosePii(`Setting validated request account: ${account.homeAccountId}`, this.correlationId);
@@ -13584,7 +13688,7 @@
13584
13688
  // fetch the account from browser cache
13585
13689
  const account = this.browserStorage.getBaseAccountInfo({
13586
13690
  nativeAccountId,
13587
- });
13691
+ }, request.correlationId);
13588
13692
  if (!account) {
13589
13693
  throw createClientAuthError(noAccountFound);
13590
13694
  }
@@ -13711,7 +13815,7 @@
13711
13815
  const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenClaims);
13712
13816
  const cachedhomeAccountId = this.browserStorage.getAccountInfoFilteredBy({
13713
13817
  nativeAccountId: request.accountId,
13714
- })?.homeAccountId;
13818
+ }, this.correlationId)?.homeAccountId;
13715
13819
  if (homeAccountIdentifier !== cachedhomeAccountId &&
13716
13820
  response.account.id !== request.accountId) {
13717
13821
  // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
@@ -13721,7 +13825,7 @@
13721
13825
  const authority = await this.getDiscoveredAuthority({
13722
13826
  requestAuthority: request.authority,
13723
13827
  });
13724
- const baseAccount = buildAccountToCache(this.browserStorage, authority, homeAccountIdentifier, base64Decode, idTokenClaims, response.client_info, undefined, // environment
13828
+ const baseAccount = buildAccountToCache(this.browserStorage, authority, homeAccountIdentifier, base64Decode, this.correlationId, idTokenClaims, response.client_info, undefined, // environment
13725
13829
  idTokenClaims.tid, undefined, // auth code payload
13726
13830
  response.account.id, this.logger);
13727
13831
  // generate authenticationResult
@@ -13854,9 +13958,11 @@
13854
13958
  */
13855
13959
  cacheAccount(accountEntity) {
13856
13960
  // Store the account info and hence `nativeAccountId` in browser cache
13857
- this.browserStorage.setAccount(accountEntity);
13961
+ this.browserStorage.setAccount(accountEntity, this.correlationId);
13858
13962
  // Remove any existing cached tokens for this account in browser storage
13859
- this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
13963
+ this.browserStorage
13964
+ .removeAccountContext(accountEntity, this.correlationId)
13965
+ .catch((e) => {
13860
13966
  this.logger.error(`Error occurred while removing account context from browser storage. ${e}`);
13861
13967
  });
13862
13968
  }
@@ -13885,7 +13991,7 @@
13885
13991
  idToken: cachedIdToken,
13886
13992
  accessToken: cachedAccessToken,
13887
13993
  };
13888
- void this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.storeInCache);
13994
+ void this.nativeStorageManager.saveCacheRecord(nativeCacheRecord, request.correlationId, request.storeInCache);
13889
13995
  }
13890
13996
  addTelemetryFromNativeResponse(response) {
13891
13997
  const mats = this.getMATSFromResponse(response);
@@ -14661,7 +14767,7 @@
14661
14767
  if (validRequest.account?.homeAccountId &&
14662
14768
  validRequest.postLogoutRedirectUri &&
14663
14769
  authClient.authority.protocolMode === ProtocolMode.OIDC) {
14664
- void this.browserStorage.removeAccount(validRequest.account?.homeAccountId);
14770
+ void this.browserStorage.removeAccount(validRequest.account?.homeAccountId, this.correlationId);
14665
14771
  this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
14666
14772
  if (mainWindowRedirectUri) {
14667
14773
  const navigationOptions = {
@@ -15336,7 +15442,7 @@
15336
15442
  }
15337
15443
  catch {
15338
15444
  if (validLogoutRequest.account?.homeAccountId) {
15339
- void this.browserStorage.removeAccount(validLogoutRequest.account?.homeAccountId);
15445
+ void this.browserStorage.removeAccount(validLogoutRequest.account?.homeAccountId, this.correlationId);
15340
15446
  this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, exports.InteractionType.Redirect, validLogoutRequest);
15341
15447
  return;
15342
15448
  }
@@ -15736,6 +15842,7 @@
15736
15842
  if (!this.isBrowserEnvironment) {
15737
15843
  throw createBrowserAuthError(nonBrowserEnvironment);
15738
15844
  }
15845
+ const correlationId = request.correlationId || createNewGuid();
15739
15846
  const idTokenClaims = response.id_token
15740
15847
  ? extractTokenClaims(response.id_token, base64Decode)
15741
15848
  : undefined;
@@ -15749,10 +15856,10 @@
15749
15856
  const authority = request.authority
15750
15857
  ? new Authority(Authority.generateAuthority(request.authority, request.azureCloudOptions), this.config.system.networkClient, this.storage, authorityOptions, this.logger, request.correlationId || createNewGuid())
15751
15858
  : undefined;
15752
- const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", idTokenClaims, authority);
15753
- const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm);
15754
- const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options);
15755
- const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment);
15859
+ const cacheRecordAccount = this.loadAccount(request, options.clientInfo || response.client_info || "", correlationId, idTokenClaims, authority);
15860
+ const idToken = this.loadIdToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, correlationId);
15861
+ const accessToken = this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, cacheRecordAccount.realm, options, correlationId);
15862
+ const refreshToken = this.loadRefreshToken(response, cacheRecordAccount.homeAccountId, cacheRecordAccount.environment, correlationId);
15756
15863
  return this.generateAuthenticationResult(request, {
15757
15864
  account: cacheRecordAccount,
15758
15865
  idToken,
@@ -15769,11 +15876,11 @@
15769
15876
  * @param requestHomeAccountId
15770
15877
  * @returns `AccountEntity`
15771
15878
  */
15772
- loadAccount(request, clientInfo, idTokenClaims, authority) {
15879
+ loadAccount(request, clientInfo, correlationId, idTokenClaims, authority) {
15773
15880
  this.logger.verbose("TokenCache - loading account");
15774
15881
  if (request.account) {
15775
15882
  const accountEntity = AccountEntity.createFromAccountInfo(request.account);
15776
- this.storage.setAccount(accountEntity);
15883
+ this.storage.setAccount(accountEntity, correlationId);
15777
15884
  return accountEntity;
15778
15885
  }
15779
15886
  else if (!authority || (!clientInfo && !idTokenClaims)) {
@@ -15782,10 +15889,10 @@
15782
15889
  }
15783
15890
  const homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authority.authorityType, this.logger, this.cryptoObj, idTokenClaims);
15784
15891
  const claimsTenantId = idTokenClaims?.tid;
15785
- const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
15892
+ const cachedAccount = buildAccountToCache(this.storage, authority, homeAccountId, base64Decode, correlationId, idTokenClaims, clientInfo, authority.hostnameAndPort, claimsTenantId, undefined, // authCodePayload
15786
15893
  undefined, // nativeAccountId
15787
15894
  this.logger);
15788
- this.storage.setAccount(cachedAccount);
15895
+ this.storage.setAccount(cachedAccount, correlationId);
15789
15896
  return cachedAccount;
15790
15897
  }
15791
15898
  /**
@@ -15796,14 +15903,14 @@
15796
15903
  * @param tenantId
15797
15904
  * @returns `IdTokenEntity`
15798
15905
  */
15799
- loadIdToken(response, homeAccountId, environment, tenantId) {
15906
+ loadIdToken(response, homeAccountId, environment, tenantId, correlationId) {
15800
15907
  if (!response.id_token) {
15801
15908
  this.logger.verbose("TokenCache - no id token found in response");
15802
15909
  return null;
15803
15910
  }
15804
15911
  this.logger.verbose("TokenCache - loading id token");
15805
15912
  const idTokenEntity = createIdTokenEntity(homeAccountId, environment, response.id_token, this.config.auth.clientId, tenantId);
15806
- this.storage.setIdTokenCredential(idTokenEntity);
15913
+ this.storage.setIdTokenCredential(idTokenEntity, correlationId);
15807
15914
  return idTokenEntity;
15808
15915
  }
15809
15916
  /**
@@ -15815,7 +15922,7 @@
15815
15922
  * @param tenantId
15816
15923
  * @returns `AccessTokenEntity`
15817
15924
  */
15818
- loadAccessToken(request, response, homeAccountId, environment, tenantId, options) {
15925
+ loadAccessToken(request, response, homeAccountId, environment, tenantId, options, correlationId) {
15819
15926
  if (!response.access_token) {
15820
15927
  this.logger.verbose("TokenCache - no access token found in response");
15821
15928
  return null;
@@ -15839,7 +15946,7 @@
15839
15946
  (response.ext_expires_in || response.expires_in) +
15840
15947
  new Date().getTime() / 1000;
15841
15948
  const accessTokenEntity = createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes.printScopes(), expiresOn, extendedExpiresOn, base64Decode);
15842
- this.storage.setAccessTokenCredential(accessTokenEntity);
15949
+ this.storage.setAccessTokenCredential(accessTokenEntity, correlationId);
15843
15950
  return accessTokenEntity;
15844
15951
  }
15845
15952
  /**
@@ -15850,7 +15957,7 @@
15850
15957
  * @param environment
15851
15958
  * @returns `RefreshTokenEntity`
15852
15959
  */
15853
- loadRefreshToken(response, homeAccountId, environment) {
15960
+ loadRefreshToken(response, homeAccountId, environment, correlationId) {
15854
15961
  if (!response.refresh_token) {
15855
15962
  this.logger.verbose("TokenCache - no refresh token found in response");
15856
15963
  return null;
@@ -15858,7 +15965,7 @@
15858
15965
  this.logger.verbose("TokenCache - loading refresh token");
15859
15966
  const refreshTokenEntity = createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId, response.foci, undefined, // userAssertionHash
15860
15967
  response.refresh_token_expires_in);
15861
- this.storage.setRefreshTokenCredential(refreshTokenEntity);
15968
+ this.storage.setRefreshTokenCredential(refreshTokenEntity, correlationId);
15862
15969
  return refreshTokenEntity;
15863
15970
  }
15864
15971
  /**
@@ -16767,7 +16874,8 @@
16767
16874
  * @returns Array of AccountInfo objects in cache
16768
16875
  */
16769
16876
  getAllAccounts(accountFilter) {
16770
- return getAllAccounts(this.logger, this.browserStorage, this.isBrowserEnvironment, accountFilter);
16877
+ const correlationId = this.getRequestCorrelationId();
16878
+ return getAllAccounts(this.logger, this.browserStorage, this.isBrowserEnvironment, correlationId, accountFilter);
16771
16879
  }
16772
16880
  /**
16773
16881
  * Returns the first account found in the cache that matches the account filter passed in.
@@ -16775,7 +16883,8 @@
16775
16883
  * @returns The first account found in the cache matching the provided filter or null if no account could be found.
16776
16884
  */
16777
16885
  getAccount(accountFilter) {
16778
- return getAccount(accountFilter, this.logger, this.browserStorage);
16886
+ const correlationId = this.getRequestCorrelationId();
16887
+ return getAccount(accountFilter, this.logger, this.browserStorage, correlationId);
16779
16888
  }
16780
16889
  /**
16781
16890
  * Returns the signed in account matching username.
@@ -16786,7 +16895,8 @@
16786
16895
  * @returns The account object stored in MSAL
16787
16896
  */
16788
16897
  getAccountByUsername(username) {
16789
- return getAccountByUsername(username, this.logger, this.browserStorage);
16898
+ const correlationId = this.getRequestCorrelationId();
16899
+ return getAccountByUsername(username, this.logger, this.browserStorage, correlationId);
16790
16900
  }
16791
16901
  /**
16792
16902
  * Returns the signed in account matching homeAccountId.
@@ -16796,7 +16906,8 @@
16796
16906
  * @returns The account object stored in MSAL
16797
16907
  */
16798
16908
  getAccountByHomeId(homeAccountId) {
16799
- return getAccountByHomeId(homeAccountId, this.logger, this.browserStorage);
16909
+ const correlationId = this.getRequestCorrelationId();
16910
+ return getAccountByHomeId(homeAccountId, this.logger, this.browserStorage, correlationId);
16800
16911
  }
16801
16912
  /**
16802
16913
  * Returns the signed in account matching localAccountId.
@@ -16806,20 +16917,23 @@
16806
16917
  * @returns The account object stored in MSAL
16807
16918
  */
16808
16919
  getAccountByLocalId(localAccountId) {
16809
- return getAccountByLocalId(localAccountId, this.logger, this.browserStorage);
16920
+ const correlationId = this.getRequestCorrelationId();
16921
+ return getAccountByLocalId(localAccountId, this.logger, this.browserStorage, correlationId);
16810
16922
  }
16811
16923
  /**
16812
16924
  * Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
16813
16925
  * @param account
16814
16926
  */
16815
16927
  setActiveAccount(account) {
16816
- setActiveAccount(account, this.browserStorage);
16928
+ const correlationId = this.getRequestCorrelationId();
16929
+ setActiveAccount(account, this.browserStorage, correlationId);
16817
16930
  }
16818
16931
  /**
16819
16932
  * Gets the currently active account
16820
16933
  */
16821
16934
  getActiveAccount() {
16822
- return getActiveAccount(this.browserStorage);
16935
+ const correlationId = this.getRequestCorrelationId();
16936
+ return getActiveAccount(this.browserStorage, correlationId);
16823
16937
  }
16824
16938
  // #endregion
16825
16939
  /**
@@ -16832,7 +16946,7 @@
16832
16946
  this.logger.verbose("hydrateCache called");
16833
16947
  // Account gets saved to browser storage regardless of native or not
16834
16948
  const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
16835
- this.browserStorage.setAccount(accountEntity);
16949
+ this.browserStorage.setAccount(accountEntity, result.correlationId);
16836
16950
  if (result.fromNativeBroker) {
16837
16951
  this.logger.verbose("Response was from native broker, storing in-memory");
16838
16952
  // Tokens from native broker are stored in-memory
@@ -17605,7 +17719,7 @@
17605
17719
  this.performanceClient = this.config.telemetry.client;
17606
17720
  // Initialize the crypto class.
17607
17721
  this.browserCrypto = operatingContext.isBrowserEnvironment()
17608
- ? new CryptoOps(this.logger, this.performanceClient)
17722
+ ? new CryptoOps(this.logger, this.performanceClient, true)
17609
17723
  : DEFAULT_CRYPTO_IMPLEMENTATION;
17610
17724
  // Initialize the browser storage class.
17611
17725
  this.browserStorage = this.operatingContext.isBrowserEnvironment()
@@ -17616,8 +17730,9 @@
17616
17730
  // Set the active account if available
17617
17731
  const accountContext = this.bridgeProxy.getAccountContext();
17618
17732
  if (accountContext) {
17619
- const cachedAccount = getAccount(accountContext, this.logger, this.browserStorage);
17620
- setActiveAccount(cachedAccount, this.browserStorage);
17733
+ const correlationId = createNewGuid();
17734
+ const cachedAccount = getAccount(accountContext, this.logger, this.browserStorage, correlationId);
17735
+ setActiveAccount(cachedAccount, this.browserStorage, correlationId);
17621
17736
  }
17622
17737
  }
17623
17738
  /**
@@ -17670,7 +17785,7 @@
17670
17785
  };
17671
17786
  // cache the tokens in the response
17672
17787
  await this.hydrateCache(result, request);
17673
- this.browserStorage.setActiveAccount(result.account);
17788
+ this.browserStorage.setActiveAccount(result.account, result.correlationId);
17674
17789
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
17675
17790
  atPopupMeasurement.add({
17676
17791
  accessTokenSize: result.accessToken.length,
@@ -17720,7 +17835,7 @@
17720
17835
  const result = this.nestedAppAuthAdapter.fromNaaTokenResponse(naaRequest, response, reqTimestamp);
17721
17836
  // cache the tokens in the response
17722
17837
  await this.hydrateCache(result, request);
17723
- this.browserStorage.setActiveAccount(result.account);
17838
+ this.browserStorage.setActiveAccount(result.account, result.correlationId);
17724
17839
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, result);
17725
17840
  ssoSilentMeasurement?.add({
17726
17841
  accessTokenSize: result.accessToken.length,
@@ -17791,10 +17906,11 @@
17791
17906
  * @returns
17792
17907
  */
17793
17908
  async acquireTokenFromCacheInternal(request) {
17909
+ const correlationId = request.correlationId || createNewGuid();
17794
17910
  const accountContext = this.bridgeProxy.getAccountContext();
17795
17911
  let currentAccount = null;
17796
17912
  if (accountContext) {
17797
- const hubAccount = getAccount(accountContext, this.logger, this.browserStorage);
17913
+ const hubAccount = getAccount(accountContext, this.logger, this.browserStorage, correlationId);
17798
17914
  // always prioritize for hub account context, the reqirement of `request.account` will be removed soon
17799
17915
  currentAccount = hubAccount || request.account;
17800
17916
  }
@@ -17806,7 +17922,7 @@
17806
17922
  this.logger.verbose("active account found, attempting to acquire token silently");
17807
17923
  const authRequest = {
17808
17924
  ...request,
17809
- correlationId: request.correlationId || this.browserCrypto.createNewGuid(),
17925
+ correlationId: correlationId,
17810
17926
  authority: request.authority || currentAccount.environment,
17811
17927
  scopes: request.scopes?.length
17812
17928
  ? request.scopes
@@ -17814,7 +17930,7 @@
17814
17930
  };
17815
17931
  // fetch access token and check for expiry
17816
17932
  const tokenKeys = this.browserStorage.getTokenKeys();
17817
- const cachedAccessToken = this.browserStorage.getAccessToken(currentAccount, authRequest, tokenKeys, currentAccount.tenantId, this.performanceClient, authRequest.correlationId);
17933
+ const cachedAccessToken = this.browserStorage.getAccessToken(currentAccount, authRequest, tokenKeys, currentAccount.tenantId, this.performanceClient);
17818
17934
  // If there is no access token, log it and return null
17819
17935
  if (!cachedAccessToken) {
17820
17936
  this.logger.verbose("No cached access token found");
@@ -17825,7 +17941,7 @@
17825
17941
  this.logger.verbose("Cached access token has expired");
17826
17942
  return Promise.resolve(null);
17827
17943
  }
17828
- const cachedIdToken = this.browserStorage.getIdToken(currentAccount, tokenKeys, currentAccount.tenantId, this.performanceClient, authRequest.correlationId);
17944
+ const cachedIdToken = this.browserStorage.getIdToken(currentAccount, authRequest.correlationId, tokenKeys, currentAccount.tenantId, this.performanceClient);
17829
17945
  if (!cachedIdToken) {
17830
17946
  this.logger.verbose("No cached id token found");
17831
17947
  return Promise.resolve(null);
@@ -17922,7 +18038,8 @@
17922
18038
  * @returns Array of AccountInfo objects in cache
17923
18039
  */
17924
18040
  getAllAccounts(accountFilter) {
17925
- return getAllAccounts(this.logger, this.browserStorage, this.isBrowserEnv(), accountFilter);
18041
+ const correlationId = createNewGuid();
18042
+ return getAllAccounts(this.logger, this.browserStorage, this.isBrowserEnv(), correlationId, accountFilter);
17926
18043
  }
17927
18044
  /**
17928
18045
  * Returns the first account found in the cache that matches the account filter passed in.
@@ -17930,7 +18047,8 @@
17930
18047
  * @returns The first account found in the cache matching the provided filter or null if no account could be found.
17931
18048
  */
17932
18049
  getAccount(accountFilter) {
17933
- return getAccount(accountFilter, this.logger, this.browserStorage);
18050
+ const correlationId = createNewGuid();
18051
+ return getAccount(accountFilter, this.logger, this.browserStorage, correlationId);
17934
18052
  }
17935
18053
  /**
17936
18054
  * Returns the signed in account matching username.
@@ -17941,7 +18059,8 @@
17941
18059
  * @returns The account object stored in MSAL
17942
18060
  */
17943
18061
  getAccountByUsername(username) {
17944
- return getAccountByUsername(username, this.logger, this.browserStorage);
18062
+ const correlationId = createNewGuid();
18063
+ return getAccountByUsername(username, this.logger, this.browserStorage, correlationId);
17945
18064
  }
17946
18065
  /**
17947
18066
  * Returns the signed in account matching homeAccountId.
@@ -17951,7 +18070,8 @@
17951
18070
  * @returns The account object stored in MSAL
17952
18071
  */
17953
18072
  getAccountByHomeId(homeAccountId) {
17954
- return getAccountByHomeId(homeAccountId, this.logger, this.browserStorage);
18073
+ const correlationId = createNewGuid();
18074
+ return getAccountByHomeId(homeAccountId, this.logger, this.browserStorage, correlationId);
17955
18075
  }
17956
18076
  /**
17957
18077
  * Returns the signed in account matching localAccountId.
@@ -17961,7 +18081,8 @@
17961
18081
  * @returns The account object stored in MSAL
17962
18082
  */
17963
18083
  getAccountByLocalId(localAccountId) {
17964
- return getAccountByLocalId(localAccountId, this.logger, this.browserStorage);
18084
+ const correlationId = createNewGuid();
18085
+ return getAccountByLocalId(localAccountId, this.logger, this.browserStorage, correlationId);
17965
18086
  }
17966
18087
  /**
17967
18088
  * Sets the account to use as the active account. If no account is passed to the acquireToken APIs, then MSAL will use this active account.
@@ -17972,13 +18093,15 @@
17972
18093
  * StandardController uses this to allow the developer to set the active account
17973
18094
  * in the nested app auth scenario the active account is controlled by the app hosting the nested app
17974
18095
  */
17975
- return setActiveAccount(account, this.browserStorage);
18096
+ const correlationId = createNewGuid();
18097
+ return setActiveAccount(account, this.browserStorage, correlationId);
17976
18098
  }
17977
18099
  /**
17978
18100
  * Gets the currently active account
17979
18101
  */
17980
18102
  getActiveAccount() {
17981
- return getActiveAccount(this.browserStorage);
18103
+ const correlationId = createNewGuid();
18104
+ return getActiveAccount(this.browserStorage, correlationId);
17982
18105
  }
17983
18106
  // #endregion
17984
18107
  handleRedirectPromise(hash // eslint-disable-line @typescript-eslint/no-unused-vars
@@ -18060,7 +18183,7 @@
18060
18183
  async hydrateCache(result, request) {
18061
18184
  this.logger.verbose("hydrateCache called");
18062
18185
  const accountEntity = AccountEntity.createFromAccountInfo(result.account, result.cloudGraphHostName, result.msGraphHost);
18063
- this.browserStorage.setAccount(accountEntity);
18186
+ this.browserStorage.setAccount(accountEntity, result.correlationId);
18064
18187
  return this.browserStorage.hydrateCache(result, request);
18065
18188
  }
18066
18189
  }