@azure/msal-browser 3.26.1 → 3.28.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 (168) 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/NativeRequest.d.ts +1 -0
  6. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
  7. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  8. package/dist/cache/AccountManager.mjs +1 -1
  9. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  10. package/dist/cache/BrowserCacheManager.d.ts +2 -38
  11. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  12. package/dist/cache/BrowserCacheManager.mjs +21 -115
  13. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  14. package/dist/cache/BrowserStorage.d.ts +3 -1
  15. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  16. package/dist/cache/BrowserStorage.mjs +13 -8
  17. package/dist/cache/BrowserStorage.mjs.map +1 -1
  18. package/dist/cache/CookieStorage.d.ts +14 -0
  19. package/dist/cache/CookieStorage.d.ts.map +1 -0
  20. package/dist/cache/CookieStorage.mjs +62 -0
  21. package/dist/cache/CookieStorage.mjs.map +1 -0
  22. package/dist/cache/DatabaseStorage.mjs +1 -1
  23. package/dist/cache/LocalStorage.d.ts +10 -0
  24. package/dist/cache/LocalStorage.d.ts.map +1 -0
  25. package/dist/cache/LocalStorage.mjs +34 -0
  26. package/dist/cache/LocalStorage.mjs.map +1 -0
  27. package/dist/cache/MemoryStorage.mjs +1 -1
  28. package/dist/cache/SessionStorage.d.ts +10 -0
  29. package/dist/cache/SessionStorage.d.ts.map +1 -0
  30. package/dist/cache/SessionStorage.mjs +34 -0
  31. package/dist/cache/SessionStorage.mjs.map +1 -0
  32. package/dist/cache/TokenCache.mjs +1 -1
  33. package/dist/config/Configuration.d.ts.map +1 -1
  34. package/dist/config/Configuration.mjs +4 -3
  35. package/dist/config/Configuration.mjs.map +1 -1
  36. package/dist/controllers/ControllerFactory.mjs +1 -1
  37. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  38. package/dist/controllers/StandardController.d.ts.map +1 -1
  39. package/dist/controllers/StandardController.mjs +1 -8
  40. package/dist/controllers/StandardController.mjs.map +1 -1
  41. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  42. package/dist/crypto/BrowserCrypto.d.ts +2 -2
  43. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  44. package/dist/crypto/BrowserCrypto.mjs +10 -7
  45. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  46. package/dist/crypto/CryptoOps.mjs +2 -2
  47. package/dist/crypto/CryptoOps.mjs.map +1 -1
  48. package/dist/crypto/PkceGenerator.mjs +1 -1
  49. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  50. package/dist/encode/Base64Decode.mjs +1 -1
  51. package/dist/encode/Base64Encode.mjs +1 -1
  52. package/dist/error/BrowserAuthError.d.ts +4 -2
  53. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  54. package/dist/error/BrowserAuthError.mjs +8 -6
  55. package/dist/error/BrowserAuthError.mjs.map +1 -1
  56. package/dist/error/BrowserAuthErrorCodes.d.ts +2 -0
  57. package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  58. package/dist/error/BrowserAuthErrorCodes.mjs +5 -3
  59. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  60. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  61. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  62. package/dist/error/NativeAuthError.mjs +1 -1
  63. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  64. package/dist/error/NestedAppAuthError.mjs +1 -1
  65. package/dist/event/EventHandler.mjs +1 -1
  66. package/dist/event/EventMessage.mjs +1 -1
  67. package/dist/event/EventType.mjs +1 -1
  68. package/dist/index.d.ts +3 -0
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.mjs +3 -1
  71. package/dist/index.mjs.map +1 -1
  72. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  73. package/dist/interaction_client/BaseInteractionClient.mjs +2 -4
  74. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  75. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  76. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  77. package/dist/interaction_client/NativeInteractionClient.mjs +25 -17
  78. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  79. package/dist/interaction_client/PopupClient.mjs +1 -1
  80. package/dist/interaction_client/RedirectClient.mjs +1 -1
  81. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  82. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  83. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  84. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  85. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  86. package/dist/interaction_client/StandardInteractionClient.mjs +6 -1
  87. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  88. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  89. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  90. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  91. package/dist/naa/BridgeError.mjs +1 -1
  92. package/dist/naa/BridgeProxy.mjs +1 -1
  93. package/dist/naa/BridgeStatusCode.mjs +1 -1
  94. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  95. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +4 -5
  96. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  97. package/dist/navigation/NavigationClient.mjs +1 -1
  98. package/dist/network/FetchClient.d.ts +0 -6
  99. package/dist/network/FetchClient.d.ts.map +1 -1
  100. package/dist/network/FetchClient.mjs +51 -32
  101. package/dist/network/FetchClient.mjs.map +1 -1
  102. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  103. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  104. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  105. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  106. package/dist/packageMetadata.d.ts +1 -1
  107. package/dist/packageMetadata.mjs +2 -2
  108. package/dist/request/RequestHelpers.mjs +1 -1
  109. package/dist/response/ResponseHandler.mjs +1 -1
  110. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  111. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  112. package/dist/utils/BrowserConstants.mjs +1 -1
  113. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  114. package/dist/utils/BrowserUtils.mjs +1 -1
  115. package/lib/msal-browser.cjs +627 -472
  116. package/lib/msal-browser.cjs.map +1 -1
  117. package/lib/msal-browser.js +627 -472
  118. package/lib/msal-browser.js.map +1 -1
  119. package/lib/msal-browser.min.js +66 -66
  120. package/lib/types/broker/nativeBroker/NativeRequest.d.ts +1 -0
  121. package/lib/types/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
  122. package/lib/types/cache/BrowserCacheManager.d.ts +2 -38
  123. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  124. package/lib/types/cache/BrowserStorage.d.ts +3 -1
  125. package/lib/types/cache/BrowserStorage.d.ts.map +1 -1
  126. package/lib/types/cache/CookieStorage.d.ts +14 -0
  127. package/lib/types/cache/CookieStorage.d.ts.map +1 -0
  128. package/lib/types/cache/LocalStorage.d.ts +10 -0
  129. package/lib/types/cache/LocalStorage.d.ts.map +1 -0
  130. package/lib/types/cache/SessionStorage.d.ts +10 -0
  131. package/lib/types/cache/SessionStorage.d.ts.map +1 -0
  132. package/lib/types/config/Configuration.d.ts.map +1 -1
  133. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  134. package/lib/types/crypto/BrowserCrypto.d.ts +2 -2
  135. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  136. package/lib/types/error/BrowserAuthError.d.ts +4 -2
  137. package/lib/types/error/BrowserAuthError.d.ts.map +1 -1
  138. package/lib/types/error/BrowserAuthErrorCodes.d.ts +2 -0
  139. package/lib/types/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  140. package/lib/types/index.d.ts +3 -0
  141. package/lib/types/index.d.ts.map +1 -1
  142. package/lib/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  143. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  144. package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  145. package/lib/types/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  146. package/lib/types/network/FetchClient.d.ts +0 -6
  147. package/lib/types/network/FetchClient.d.ts.map +1 -1
  148. package/lib/types/packageMetadata.d.ts +1 -1
  149. package/package.json +3 -3
  150. package/src/broker/nativeBroker/NativeRequest.ts +1 -0
  151. package/src/cache/BrowserCacheManager.ts +27 -141
  152. package/src/cache/BrowserStorage.ts +11 -11
  153. package/src/cache/CookieStorage.ts +80 -0
  154. package/src/cache/LocalStorage.ts +40 -0
  155. package/src/cache/SessionStorage.ts +40 -0
  156. package/src/config/Configuration.ts +3 -1
  157. package/src/controllers/StandardController.ts +0 -7
  158. package/src/crypto/BrowserCrypto.ts +15 -6
  159. package/src/crypto/CryptoOps.ts +1 -1
  160. package/src/error/BrowserAuthError.ts +11 -4
  161. package/src/error/BrowserAuthErrorCodes.ts +2 -0
  162. package/src/index.ts +3 -0
  163. package/src/interaction_client/BaseInteractionClient.ts +1 -4
  164. package/src/interaction_client/NativeInteractionClient.ts +35 -25
  165. package/src/interaction_client/StandardInteractionClient.ts +6 -0
  166. package/src/naa/mapping/NestedAppAuthAdapter.ts +4 -5
  167. package/src/network/FetchClient.ts +67 -40
  168. package/src/packageMetadata.ts +1 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v3.26.1 2024-10-08 */
1
+ /*! @azure/msal-browser v3.28.0 2024-12-12 */
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.15.0 2024-10-08 */
9
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
10
10
  /*
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.
12
12
  * Licensed under the MIT License.
@@ -101,6 +101,7 @@
101
101
  */
102
102
  const HeaderNames = {
103
103
  CONTENT_TYPE: "Content-Type",
104
+ CONTENT_LENGTH: "Content-Length",
104
105
  RETRY_AFTER: "Retry-After",
105
106
  CCS_HEADER: "X-AnchorMailbox",
106
107
  WWWAuthenticate: "WWW-Authenticate",
@@ -315,7 +316,7 @@
315
316
  // Token renewal offset default in seconds
316
317
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
317
318
 
318
- /*! @azure/msal-common v14.15.0 2024-10-08 */
319
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
319
320
  /*
320
321
  * Copyright (c) Microsoft Corporation. All rights reserved.
321
322
  * Licensed under the MIT License.
@@ -332,7 +333,7 @@
332
333
  unexpectedError: unexpectedError
333
334
  });
334
335
 
335
- /*! @azure/msal-common v14.15.0 2024-10-08 */
336
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
336
337
 
337
338
  /*
338
339
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -381,7 +382,7 @@
381
382
  : AuthErrorMessages[code]);
382
383
  }
383
384
 
384
- /*! @azure/msal-common v14.15.0 2024-10-08 */
385
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
385
386
  /*
386
387
  * Copyright (c) Microsoft Corporation. All rights reserved.
387
388
  * Licensed under the MIT License.
@@ -479,7 +480,7 @@
479
480
  userTimeoutReached: userTimeoutReached
480
481
  });
481
482
 
482
- /*! @azure/msal-common v14.15.0 2024-10-08 */
483
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
483
484
 
484
485
  /*
485
486
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -731,7 +732,7 @@
731
732
  return new ClientAuthError(errorCode, additionalMessage);
732
733
  }
733
734
 
734
- /*! @azure/msal-common v14.15.0 2024-10-08 */
735
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
735
736
 
736
737
  /*
737
738
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -770,7 +771,7 @@
770
771
  },
771
772
  };
772
773
 
773
- /*! @azure/msal-common v14.15.0 2024-10-08 */
774
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
774
775
 
775
776
  /*
776
777
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -961,12 +962,12 @@
961
962
  }
962
963
  }
963
964
 
964
- /*! @azure/msal-common v14.15.0 2024-10-08 */
965
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
965
966
  /* eslint-disable header/header */
966
967
  const name$1 = "@azure/msal-common";
967
- const version$1 = "14.15.0";
968
+ const version$1 = "14.16.0";
968
969
 
969
- /*! @azure/msal-common v14.15.0 2024-10-08 */
970
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
970
971
  /*
971
972
  * Copyright (c) Microsoft Corporation. All rights reserved.
972
973
  * Licensed under the MIT License.
@@ -986,7 +987,7 @@
986
987
  AzureUsGovernment: "https://login.microsoftonline.us",
987
988
  };
988
989
 
989
- /*! @azure/msal-common v14.15.0 2024-10-08 */
990
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
990
991
 
991
992
  /*
992
993
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1047,7 +1048,7 @@
1047
1048
  }
1048
1049
  }
1049
1050
 
1050
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1051
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1051
1052
  /*
1052
1053
  * Copyright (c) Microsoft Corporation. All rights reserved.
1053
1054
  * Licensed under the MIT License.
@@ -1084,7 +1085,7 @@
1084
1085
  return cachedAtSec > nowSeconds();
1085
1086
  }
1086
1087
 
1087
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1088
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1088
1089
 
1089
1090
  /*
1090
1091
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1411,7 +1412,7 @@
1411
1412
  return metadata.expiresAt <= nowSeconds();
1412
1413
  }
1413
1414
 
1414
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1415
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1415
1416
  /*
1416
1417
  * Copyright (c) Microsoft Corporation. All rights reserved.
1417
1418
  * Licensed under the MIT License.
@@ -1465,7 +1466,7 @@
1465
1466
  urlParseError: urlParseError
1466
1467
  });
1467
1468
 
1468
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1469
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1469
1470
 
1470
1471
  /*
1471
1472
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1603,7 +1604,7 @@
1603
1604
  return new ClientConfigurationError(errorCode);
1604
1605
  }
1605
1606
 
1606
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1607
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1607
1608
  /*
1608
1609
  * Copyright (c) Microsoft Corporation. All rights reserved.
1609
1610
  * Licensed under the MIT License.
@@ -1700,7 +1701,7 @@
1700
1701
  }
1701
1702
  }
1702
1703
 
1703
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1704
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1704
1705
 
1705
1706
  /*
1706
1707
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1900,7 +1901,7 @@
1900
1901
  }
1901
1902
  }
1902
1903
 
1903
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1904
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1904
1905
 
1905
1906
  /*
1906
1907
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1940,7 +1941,7 @@
1940
1941
  };
1941
1942
  }
1942
1943
 
1943
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1944
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1944
1945
  /*
1945
1946
  * Copyright (c) Microsoft Corporation. All rights reserved.
1946
1947
  * Licensed under the MIT License.
@@ -2019,7 +2020,7 @@
2019
2020
  return updatedAccountInfo;
2020
2021
  }
2021
2022
 
2022
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2023
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2023
2024
  /*
2024
2025
  * Copyright (c) Microsoft Corporation. All rights reserved.
2025
2026
  * Licensed under the MIT License.
@@ -2034,7 +2035,7 @@
2034
2035
  Ciam: 3,
2035
2036
  };
2036
2037
 
2037
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2038
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2038
2039
  /*
2039
2040
  * Copyright (c) Microsoft Corporation. All rights reserved.
2040
2041
  * Licensed under the MIT License.
@@ -2056,7 +2057,7 @@
2056
2057
  return null;
2057
2058
  }
2058
2059
 
2059
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2060
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2060
2061
  /*
2061
2062
  * Copyright (c) Microsoft Corporation. All rights reserved.
2062
2063
  * Licensed under the MIT License.
@@ -2069,7 +2070,7 @@
2069
2070
  OIDC: "OIDC",
2070
2071
  };
2071
2072
 
2072
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2073
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2073
2074
 
2074
2075
  /*
2075
2076
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2312,7 +2313,7 @@
2312
2313
  }
2313
2314
  }
2314
2315
 
2315
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2316
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2316
2317
 
2317
2318
  /*
2318
2319
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2359,7 +2360,7 @@
2359
2360
  return null;
2360
2361
  }
2361
2362
 
2362
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2363
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2363
2364
 
2364
2365
  /*
2365
2366
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2523,7 +2524,7 @@
2523
2524
  }
2524
2525
  }
2525
2526
 
2526
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2527
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2527
2528
 
2528
2529
  /*
2529
2530
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2663,7 +2664,7 @@
2663
2664
  return null;
2664
2665
  }
2665
2666
 
2666
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2667
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2667
2668
  /*
2668
2669
  * Copyright (c) Microsoft Corporation. All rights reserved.
2669
2670
  * Licensed under the MIT License.
@@ -2671,7 +2672,7 @@
2671
2672
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2672
2673
  const cacheUnknownErrorCode = "cache_error_unknown";
2673
2674
 
2674
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2675
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2675
2676
 
2676
2677
  /*
2677
2678
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2698,7 +2699,7 @@
2698
2699
  }
2699
2700
  }
2700
2701
 
2701
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2702
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2702
2703
 
2703
2704
  /*
2704
2705
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3939,9 +3940,6 @@
3939
3940
  getTokenKeys() {
3940
3941
  throw createClientAuthError(methodNotImplemented);
3941
3942
  }
3942
- async clear() {
3943
- throw createClientAuthError(methodNotImplemented);
3944
- }
3945
3943
  updateCredentialCacheKey() {
3946
3944
  throw createClientAuthError(methodNotImplemented);
3947
3945
  }
@@ -3950,7 +3948,7 @@
3950
3948
  }
3951
3949
  }
3952
3950
 
3953
- /*! @azure/msal-common v14.15.0 2024-10-08 */
3951
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
3954
3952
 
3955
3953
  /*
3956
3954
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4049,161 +4047,7 @@
4049
4047
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4050
4048
  }
4051
4049
 
4052
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4053
-
4054
- /*
4055
- * Copyright (c) Microsoft Corporation. All rights reserved.
4056
- * Licensed under the MIT License.
4057
- */
4058
- /**
4059
- * Error thrown when there is an error with the server code, for example, unavailability.
4060
- */
4061
- class ServerError extends AuthError {
4062
- constructor(errorCode, errorMessage, subError, errorNo, status) {
4063
- super(errorCode, errorMessage, subError);
4064
- this.name = "ServerError";
4065
- this.errorNo = errorNo;
4066
- this.status = status;
4067
- Object.setPrototypeOf(this, ServerError.prototype);
4068
- }
4069
- }
4070
-
4071
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4072
-
4073
- /*
4074
- * Copyright (c) Microsoft Corporation. All rights reserved.
4075
- * Licensed under the MIT License.
4076
- */
4077
- /** @internal */
4078
- class ThrottlingUtils {
4079
- /**
4080
- * Prepares a RequestThumbprint to be stored as a key.
4081
- * @param thumbprint
4082
- */
4083
- static generateThrottlingStorageKey(thumbprint) {
4084
- return `${ThrottlingConstants.THROTTLING_PREFIX}.${JSON.stringify(thumbprint)}`;
4085
- }
4086
- /**
4087
- * Performs necessary throttling checks before a network request.
4088
- * @param cacheManager
4089
- * @param thumbprint
4090
- */
4091
- static preProcess(cacheManager, thumbprint) {
4092
- const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
4093
- const value = cacheManager.getThrottlingCache(key);
4094
- if (value) {
4095
- if (value.throttleTime < Date.now()) {
4096
- cacheManager.removeItem(key);
4097
- return;
4098
- }
4099
- throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
4100
- }
4101
- }
4102
- /**
4103
- * Performs necessary throttling checks after a network request.
4104
- * @param cacheManager
4105
- * @param thumbprint
4106
- * @param response
4107
- */
4108
- static postProcess(cacheManager, thumbprint, response) {
4109
- if (ThrottlingUtils.checkResponseStatus(response) ||
4110
- ThrottlingUtils.checkResponseForRetryAfter(response)) {
4111
- const thumbprintValue = {
4112
- throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
4113
- error: response.body.error,
4114
- errorCodes: response.body.error_codes,
4115
- errorMessage: response.body.error_description,
4116
- subError: response.body.suberror,
4117
- };
4118
- cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
4119
- }
4120
- }
4121
- /**
4122
- * Checks a NetworkResponse object's status codes against 429 or 5xx
4123
- * @param response
4124
- */
4125
- static checkResponseStatus(response) {
4126
- return (response.status === 429 ||
4127
- (response.status >= 500 && response.status < 600));
4128
- }
4129
- /**
4130
- * Checks a NetworkResponse object's RetryAfter header
4131
- * @param response
4132
- */
4133
- static checkResponseForRetryAfter(response) {
4134
- if (response.headers) {
4135
- return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
4136
- (response.status < 200 || response.status >= 300));
4137
- }
4138
- return false;
4139
- }
4140
- /**
4141
- * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
4142
- * @param throttleTime
4143
- */
4144
- static calculateThrottleTime(throttleTime) {
4145
- const time = throttleTime <= 0 ? 0 : throttleTime;
4146
- const currentSeconds = Date.now() / 1000;
4147
- return Math.floor(Math.min(currentSeconds +
4148
- (time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds +
4149
- ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
4150
- }
4151
- static removeThrottle(cacheManager, clientId, request, homeAccountIdentifier) {
4152
- const thumbprint = {
4153
- clientId: clientId,
4154
- authority: request.authority,
4155
- scopes: request.scopes,
4156
- homeAccountIdentifier: homeAccountIdentifier,
4157
- claims: request.claims,
4158
- authenticationScheme: request.authenticationScheme,
4159
- resourceRequestMethod: request.resourceRequestMethod,
4160
- resourceRequestUri: request.resourceRequestUri,
4161
- shrClaims: request.shrClaims,
4162
- sshKid: request.sshKid,
4163
- };
4164
- const key = this.generateThrottlingStorageKey(thumbprint);
4165
- cacheManager.removeItem(key);
4166
- }
4167
- }
4168
-
4169
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4170
-
4171
- /*
4172
- * Copyright (c) Microsoft Corporation. All rights reserved.
4173
- * Licensed under the MIT License.
4174
- */
4175
- /** @internal */
4176
- class NetworkManager {
4177
- constructor(networkClient, cacheManager) {
4178
- this.networkClient = networkClient;
4179
- this.cacheManager = cacheManager;
4180
- }
4181
- /**
4182
- * Wraps sendPostRequestAsync with necessary preflight and postflight logic
4183
- * @param thumbprint
4184
- * @param tokenEndpoint
4185
- * @param options
4186
- */
4187
- async sendPostRequest(thumbprint, tokenEndpoint, options) {
4188
- ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
4189
- let response;
4190
- try {
4191
- response = await this.networkClient.sendPostRequestAsync(tokenEndpoint, options);
4192
- }
4193
- catch (e) {
4194
- if (e instanceof AuthError) {
4195
- throw e;
4196
- }
4197
- else {
4198
- throw createClientAuthError(networkError);
4199
- }
4200
- }
4201
- ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
4202
- return response;
4203
- }
4204
- }
4205
-
4206
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4050
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4207
4051
  /*
4208
4052
  * Copyright (c) Microsoft Corporation. All rights reserved.
4209
4053
  * Licensed under the MIT License.
@@ -4213,7 +4057,7 @@
4213
4057
  UPN: "UPN",
4214
4058
  };
4215
4059
 
4216
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4060
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4217
4061
  /*
4218
4062
  * Copyright (c) Microsoft Corporation. All rights reserved.
4219
4063
  * Licensed under the MIT License.
@@ -4259,9 +4103,11 @@
4259
4103
  const SID = "sid";
4260
4104
  const LOGIN_HINT = "login_hint";
4261
4105
  const DOMAIN_HINT = "domain_hint";
4262
- const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
4106
+ const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
4107
+ const BROKER_CLIENT_ID = "brk_client_id";
4108
+ const BROKER_REDIRECT_URI = "brk_redirect_uri";
4263
4109
 
4264
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4110
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4265
4111
 
4266
4112
  /*
4267
4113
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4328,16 +4174,30 @@
4328
4174
  }
4329
4175
  }
4330
4176
 
4331
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4177
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4332
4178
 
4333
4179
  /*
4334
4180
  * Copyright (c) Microsoft Corporation. All rights reserved.
4335
4181
  * Licensed under the MIT License.
4336
4182
  */
4183
+ function instrumentBrokerParams(parameters, correlationId, performanceClient) {
4184
+ if (!correlationId) {
4185
+ return;
4186
+ }
4187
+ const clientId = parameters.get(CLIENT_ID);
4188
+ if (clientId && parameters.has(BROKER_CLIENT_ID)) {
4189
+ performanceClient?.addFields({
4190
+ embeddedClientId: clientId,
4191
+ embeddedRedirectUri: parameters.get(REDIRECT_URI),
4192
+ }, correlationId);
4193
+ }
4194
+ }
4337
4195
  /** @internal */
4338
4196
  class RequestParameterBuilder {
4339
- constructor() {
4197
+ constructor(correlationId, performanceClient) {
4340
4198
  this.parameters = new Map();
4199
+ this.performanceClient = performanceClient;
4200
+ this.correlationId = correlationId;
4341
4201
  }
4342
4202
  /**
4343
4203
  * add response_type = code
@@ -4701,6 +4561,14 @@
4701
4561
  addLogoutHint(logoutHint) {
4702
4562
  this.parameters.set(LOGOUT_HINT, encodeURIComponent(logoutHint));
4703
4563
  }
4564
+ addBrokerParameters(params) {
4565
+ const brokerParams = {};
4566
+ brokerParams[BROKER_CLIENT_ID] =
4567
+ params.brokerClientId;
4568
+ brokerParams[BROKER_REDIRECT_URI] =
4569
+ params.brokerRedirectUri;
4570
+ this.addExtraQueryParameters(brokerParams);
4571
+ }
4704
4572
  /**
4705
4573
  * Utility to create a URL from the params map
4706
4574
  */
@@ -4709,11 +4577,12 @@
4709
4577
  this.parameters.forEach((value, key) => {
4710
4578
  queryParameterArray.push(`${key}=${value}`);
4711
4579
  });
4580
+ instrumentBrokerParams(this.parameters, this.correlationId, this.performanceClient);
4712
4581
  return queryParameterArray.join("&");
4713
4582
  }
4714
4583
  }
4715
4584
 
4716
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4585
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4717
4586
  /*
4718
4587
  * Copyright (c) Microsoft Corporation. All rights reserved.
4719
4588
  * Licensed under the MIT License.
@@ -4725,7 +4594,7 @@
4725
4594
  response.hasOwnProperty("jwks_uri"));
4726
4595
  }
4727
4596
 
4728
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4597
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4729
4598
  /*
4730
4599
  * Copyright (c) Microsoft Corporation. All rights reserved.
4731
4600
  * Licensed under the MIT License.
@@ -4735,7 +4604,7 @@
4735
4604
  response.hasOwnProperty("metadata"));
4736
4605
  }
4737
4606
 
4738
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4607
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4739
4608
  /*
4740
4609
  * Copyright (c) Microsoft Corporation. All rights reserved.
4741
4610
  * Licensed under the MIT License.
@@ -4745,7 +4614,7 @@
4745
4614
  response.hasOwnProperty("error_description"));
4746
4615
  }
4747
4616
 
4748
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4617
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4749
4618
  /*
4750
4619
  * Copyright (c) Microsoft Corporation. All rights reserved.
4751
4620
  * Licensed under the MIT License.
@@ -4847,6 +4716,7 @@
4847
4716
  /**
4848
4717
  * Time spent sending/waiting for the response of a request to the token endpoint
4849
4718
  */
4719
+ NetworkClientSendPostRequestAsync: "networkClientSendPostRequestAsync",
4850
4720
  RefreshTokenClientExecutePostToTokenEndpoint: "refreshTokenClientExecutePostToTokenEndpoint",
4851
4721
  AuthorizationCodeClientExecutePostToTokenEndpoint: "authorizationCodeClientExecutePostToTokenEndpoint",
4852
4722
  /**
@@ -5020,6 +4890,10 @@
5020
4890
  PerformanceEvents.BaseClientCreateTokenRequestHeaders,
5021
4891
  "BaseClientCreateTReqHead",
5022
4892
  ],
4893
+ [
4894
+ PerformanceEvents.NetworkClientSendPostRequestAsync,
4895
+ "NetClientSendPost",
4896
+ ],
5023
4897
  [
5024
4898
  PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint,
5025
4899
  "RTClientExecPost",
@@ -5227,7 +5101,7 @@
5227
5101
  "multiMatchedRT",
5228
5102
  ]);
5229
5103
 
5230
- /*! @azure/msal-common v14.15.0 2024-10-08 */
5104
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
5231
5105
  /*
5232
5106
  * Copyright (c) Microsoft Corporation. All rights reserved.
5233
5107
  * Licensed under the MIT License.
@@ -5323,7 +5197,7 @@
5323
5197
  };
5324
5198
  };
5325
5199
 
5326
- /*! @azure/msal-common v14.15.0 2024-10-08 */
5200
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
5327
5201
 
5328
5202
  /*
5329
5203
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5432,7 +5306,7 @@
5432
5306
  },
5433
5307
  };
5434
5308
 
5435
- /*! @azure/msal-common v14.15.0 2024-10-08 */
5309
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
5436
5310
 
5437
5311
  /*
5438
5312
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6271,38 +6145,185 @@
6271
6145
  };
6272
6146
  }
6273
6147
 
6274
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6148
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6149
+
6150
+ /*
6151
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6152
+ * Licensed under the MIT License.
6153
+ */
6154
+ /**
6155
+ * Create an authority object of the correct type based on the url
6156
+ * Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)
6157
+ *
6158
+ * Also performs endpoint discovery.
6159
+ *
6160
+ * @param authorityUri
6161
+ * @param networkClient
6162
+ * @param protocolMode
6163
+ * @internal
6164
+ */
6165
+ async function createDiscoveredInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, correlationId, performanceClient) {
6166
+ performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
6167
+ const authorityUriFinal = Authority.transformCIAMAuthority(formatAuthorityUri(authorityUri));
6168
+ // Initialize authority and perform discovery endpoint check.
6169
+ const acquireTokenAuthority = new Authority(authorityUriFinal, networkClient, cacheManager, authorityOptions, logger, correlationId, performanceClient);
6170
+ try {
6171
+ await invokeAsync(acquireTokenAuthority.resolveEndpointsAsync.bind(acquireTokenAuthority), PerformanceEvents.AuthorityResolveEndpointsAsync, logger, performanceClient, correlationId)();
6172
+ return acquireTokenAuthority;
6173
+ }
6174
+ catch (e) {
6175
+ throw createClientAuthError(endpointResolutionError);
6176
+ }
6177
+ }
6178
+
6179
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6180
+
6181
+ /*
6182
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6183
+ * Licensed under the MIT License.
6184
+ */
6185
+ /**
6186
+ * Error thrown when there is an error with the server code, for example, unavailability.
6187
+ */
6188
+ class ServerError extends AuthError {
6189
+ constructor(errorCode, errorMessage, subError, errorNo, status) {
6190
+ super(errorCode, errorMessage, subError);
6191
+ this.name = "ServerError";
6192
+ this.errorNo = errorNo;
6193
+ this.status = status;
6194
+ Object.setPrototypeOf(this, ServerError.prototype);
6195
+ }
6196
+ }
6197
+
6198
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6199
+
6200
+ /*
6201
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6202
+ * Licensed under the MIT License.
6203
+ */
6204
+ /** @internal */
6205
+ class ThrottlingUtils {
6206
+ /**
6207
+ * Prepares a RequestThumbprint to be stored as a key.
6208
+ * @param thumbprint
6209
+ */
6210
+ static generateThrottlingStorageKey(thumbprint) {
6211
+ return `${ThrottlingConstants.THROTTLING_PREFIX}.${JSON.stringify(thumbprint)}`;
6212
+ }
6213
+ /**
6214
+ * Performs necessary throttling checks before a network request.
6215
+ * @param cacheManager
6216
+ * @param thumbprint
6217
+ */
6218
+ static preProcess(cacheManager, thumbprint) {
6219
+ const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
6220
+ const value = cacheManager.getThrottlingCache(key);
6221
+ if (value) {
6222
+ if (value.throttleTime < Date.now()) {
6223
+ cacheManager.removeItem(key);
6224
+ return;
6225
+ }
6226
+ throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
6227
+ }
6228
+ }
6229
+ /**
6230
+ * Performs necessary throttling checks after a network request.
6231
+ * @param cacheManager
6232
+ * @param thumbprint
6233
+ * @param response
6234
+ */
6235
+ static postProcess(cacheManager, thumbprint, response) {
6236
+ if (ThrottlingUtils.checkResponseStatus(response) ||
6237
+ ThrottlingUtils.checkResponseForRetryAfter(response)) {
6238
+ const thumbprintValue = {
6239
+ throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
6240
+ error: response.body.error,
6241
+ errorCodes: response.body.error_codes,
6242
+ errorMessage: response.body.error_description,
6243
+ subError: response.body.suberror,
6244
+ };
6245
+ cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
6246
+ }
6247
+ }
6248
+ /**
6249
+ * Checks a NetworkResponse object's status codes against 429 or 5xx
6250
+ * @param response
6251
+ */
6252
+ static checkResponseStatus(response) {
6253
+ return (response.status === 429 ||
6254
+ (response.status >= 500 && response.status < 600));
6255
+ }
6256
+ /**
6257
+ * Checks a NetworkResponse object's RetryAfter header
6258
+ * @param response
6259
+ */
6260
+ static checkResponseForRetryAfter(response) {
6261
+ if (response.headers) {
6262
+ return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
6263
+ (response.status < 200 || response.status >= 300));
6264
+ }
6265
+ return false;
6266
+ }
6267
+ /**
6268
+ * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
6269
+ * @param throttleTime
6270
+ */
6271
+ static calculateThrottleTime(throttleTime) {
6272
+ const time = throttleTime <= 0 ? 0 : throttleTime;
6273
+ const currentSeconds = Date.now() / 1000;
6274
+ return Math.floor(Math.min(currentSeconds +
6275
+ (time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds +
6276
+ ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
6277
+ }
6278
+ static removeThrottle(cacheManager, clientId, request, homeAccountIdentifier) {
6279
+ const thumbprint = {
6280
+ clientId: clientId,
6281
+ authority: request.authority,
6282
+ scopes: request.scopes,
6283
+ homeAccountIdentifier: homeAccountIdentifier,
6284
+ claims: request.claims,
6285
+ authenticationScheme: request.authenticationScheme,
6286
+ resourceRequestMethod: request.resourceRequestMethod,
6287
+ resourceRequestUri: request.resourceRequestUri,
6288
+ shrClaims: request.shrClaims,
6289
+ sshKid: request.sshKid,
6290
+ };
6291
+ const key = this.generateThrottlingStorageKey(thumbprint);
6292
+ cacheManager.removeItem(key);
6293
+ }
6294
+ }
6295
+
6296
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6275
6297
 
6276
6298
  /*
6277
6299
  * Copyright (c) Microsoft Corporation. All rights reserved.
6278
6300
  * Licensed under the MIT License.
6279
6301
  */
6280
6302
  /**
6281
- * Create an authority object of the correct type based on the url
6282
- * Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)
6283
- *
6284
- * Also performs endpoint discovery.
6285
- *
6286
- * @param authorityUri
6287
- * @param networkClient
6288
- * @param protocolMode
6289
- * @internal
6303
+ * Represents network related errors
6290
6304
  */
6291
- async function createDiscoveredInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, correlationId, performanceClient) {
6292
- performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
6293
- const authorityUriFinal = Authority.transformCIAMAuthority(formatAuthorityUri(authorityUri));
6294
- // Initialize authority and perform discovery endpoint check.
6295
- const acquireTokenAuthority = new Authority(authorityUriFinal, networkClient, cacheManager, authorityOptions, logger, correlationId, performanceClient);
6296
- try {
6297
- await invokeAsync(acquireTokenAuthority.resolveEndpointsAsync.bind(acquireTokenAuthority), PerformanceEvents.AuthorityResolveEndpointsAsync, logger, performanceClient, correlationId)();
6298
- return acquireTokenAuthority;
6299
- }
6300
- catch (e) {
6301
- throw createClientAuthError(endpointResolutionError);
6305
+ class NetworkError extends AuthError {
6306
+ constructor(error, httpStatus, responseHeaders) {
6307
+ super(error.errorCode, error.errorMessage, error.subError);
6308
+ Object.setPrototypeOf(this, NetworkError.prototype);
6309
+ this.name = "NetworkError";
6310
+ this.error = error;
6311
+ this.httpStatus = httpStatus;
6312
+ this.responseHeaders = responseHeaders;
6302
6313
  }
6314
+ }
6315
+ /**
6316
+ * Creates NetworkError object for a failed network request
6317
+ * @param error - Error to be thrown back to the caller
6318
+ * @param httpStatus - Status code of the network request
6319
+ * @param responseHeaders - Response headers of the network request, when available
6320
+ * @returns NetworkError object
6321
+ */
6322
+ function createNetworkError(error, httpStatus, responseHeaders) {
6323
+ return new NetworkError(error, httpStatus, responseHeaders);
6303
6324
  }
6304
6325
 
6305
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6326
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6306
6327
 
6307
6328
  /*
6308
6329
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6324,8 +6345,6 @@
6324
6345
  this.cacheManager = this.config.storageInterface;
6325
6346
  // Set the network interface
6326
6347
  this.networkClient = this.config.networkInterface;
6327
- // Set the NetworkManager
6328
- this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
6329
6348
  // Set TelemetryManager
6330
6349
  this.serverTelemetryManager = this.config.serverTelemetryManager;
6331
6350
  // set Authority
@@ -6369,11 +6388,7 @@
6369
6388
  if (queuedEvent) {
6370
6389
  this.performanceClient?.addQueueMeasurement(queuedEvent, correlationId);
6371
6390
  }
6372
- const response = await this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers });
6373
- this.performanceClient?.addFields({
6374
- refreshTokenSize: response.body.refresh_token?.length || 0,
6375
- httpVerToken: response.headers?.[HeaderNames.X_MS_HTTP_VERSION] || "",
6376
- }, correlationId);
6391
+ const response = await this.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers }, correlationId);
6377
6392
  if (this.config.serverTelemetryManager &&
6378
6393
  response.status < 500 &&
6379
6394
  response.status !== 429) {
@@ -6382,6 +6397,52 @@
6382
6397
  }
6383
6398
  return response;
6384
6399
  }
6400
+ /**
6401
+ * Wraps sendPostRequestAsync with necessary preflight and postflight logic
6402
+ * @param thumbprint - Request thumbprint for throttling
6403
+ * @param tokenEndpoint - Endpoint to make the POST to
6404
+ * @param options - Body and Headers to include on the POST request
6405
+ * @param correlationId - CorrelationId for telemetry
6406
+ */
6407
+ async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
6408
+ ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
6409
+ let response;
6410
+ try {
6411
+ response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), PerformanceEvents.NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
6412
+ const responseHeaders = response.headers || {};
6413
+ this.performanceClient?.addFields({
6414
+ refreshTokenSize: response.body.refresh_token?.length || 0,
6415
+ httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
6416
+ requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
6417
+ }, correlationId);
6418
+ }
6419
+ catch (e) {
6420
+ if (e instanceof NetworkError) {
6421
+ const responseHeaders = e.responseHeaders;
6422
+ if (responseHeaders) {
6423
+ this.performanceClient?.addFields({
6424
+ httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
6425
+ requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] ||
6426
+ "",
6427
+ contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
6428
+ undefined,
6429
+ contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
6430
+ undefined,
6431
+ httpStatus: e.httpStatus,
6432
+ }, correlationId);
6433
+ }
6434
+ throw e.error;
6435
+ }
6436
+ if (e instanceof AuthError) {
6437
+ throw e;
6438
+ }
6439
+ else {
6440
+ throw createClientAuthError(networkError);
6441
+ }
6442
+ }
6443
+ ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
6444
+ return response;
6445
+ }
6385
6446
  /**
6386
6447
  * Updates the authority object of the client. Endpoint discovery must be completed.
6387
6448
  * @param updatedAuthority
@@ -6397,15 +6458,22 @@
6397
6458
  * @param request
6398
6459
  */
6399
6460
  createTokenQueryParameters(request) {
6400
- const parameterBuilder = new RequestParameterBuilder();
6461
+ const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
6462
+ if (request.embeddedClientId) {
6463
+ parameterBuilder.addBrokerParameters({
6464
+ brokerClientId: this.config.authOptions.clientId,
6465
+ brokerRedirectUri: this.config.authOptions.redirectUri,
6466
+ });
6467
+ }
6401
6468
  if (request.tokenQueryParameters) {
6402
6469
  parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
6403
6470
  }
6471
+ parameterBuilder.addCorrelationId(request.correlationId);
6404
6472
  return parameterBuilder.createQueryString();
6405
6473
  }
6406
6474
  }
6407
6475
 
6408
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6476
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6409
6477
  /*
6410
6478
  * Copyright (c) Microsoft Corporation. All rights reserved.
6411
6479
  * Licensed under the MIT License.
@@ -6431,7 +6499,7 @@
6431
6499
  refreshTokenExpired: refreshTokenExpired
6432
6500
  });
6433
6501
 
6434
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6502
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6435
6503
 
6436
6504
  /*
6437
6505
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6519,7 +6587,7 @@
6519
6587
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6520
6588
  }
6521
6589
 
6522
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6590
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6523
6591
 
6524
6592
  /*
6525
6593
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6591,7 +6659,7 @@
6591
6659
  }
6592
6660
  }
6593
6661
 
6594
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6662
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6595
6663
 
6596
6664
  /*
6597
6665
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6675,7 +6743,7 @@
6675
6743
  }
6676
6744
  }
6677
6745
 
6678
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6746
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6679
6747
  /*
6680
6748
  * Copyright (c) Microsoft Corporation. All rights reserved.
6681
6749
  * Licensed under the MIT License.
@@ -6702,7 +6770,7 @@
6702
6770
  }
6703
6771
  }
6704
6772
 
6705
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6773
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6706
6774
 
6707
6775
  /*
6708
6776
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7079,7 +7147,7 @@
7079
7147
  return baseAccount;
7080
7148
  }
7081
7149
 
7082
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7150
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7083
7151
  /*
7084
7152
  * Copyright (c) Microsoft Corporation. All rights reserved.
7085
7153
  * Licensed under the MIT License.
@@ -7097,7 +7165,7 @@
7097
7165
  }
7098
7166
  }
7099
7167
 
7100
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7168
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7101
7169
 
7102
7170
  /*
7103
7171
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7223,8 +7291,9 @@
7223
7291
  */
7224
7292
  async createTokenRequestBody(request) {
7225
7293
  this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
7226
- const parameterBuilder = new RequestParameterBuilder();
7227
- parameterBuilder.addClientId(request.tokenBodyParameters?.[CLIENT_ID] ||
7294
+ const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
7295
+ parameterBuilder.addClientId(request.embeddedClientId ||
7296
+ request.tokenBodyParameters?.[CLIENT_ID] ||
7228
7297
  this.config.authOptions.clientId);
7229
7298
  /*
7230
7299
  * For hybrid spa flow, there will be a code but no verifier
@@ -7284,9 +7353,6 @@
7284
7353
  throw createClientConfigurationError(missingSshJwk);
7285
7354
  }
7286
7355
  }
7287
- const correlationId = request.correlationId ||
7288
- this.config.cryptoInterface.createNewGuid();
7289
- parameterBuilder.addCorrelationId(correlationId);
7290
7356
  if (!StringUtils.isEmptyObj(request.claims) ||
7291
7357
  (this.config.authOptions.clientCapabilities &&
7292
7358
  this.config.authOptions.clientCapabilities.length > 0)) {
@@ -7326,6 +7392,12 @@
7326
7392
  break;
7327
7393
  }
7328
7394
  }
7395
+ if (request.embeddedClientId) {
7396
+ parameterBuilder.addBrokerParameters({
7397
+ brokerClientId: this.config.authOptions.clientId,
7398
+ brokerRedirectUri: this.config.authOptions.redirectUri,
7399
+ });
7400
+ }
7329
7401
  if (request.tokenBodyParameters) {
7330
7402
  parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
7331
7403
  }
@@ -7344,9 +7416,13 @@
7344
7416
  * @param request
7345
7417
  */
7346
7418
  async createAuthCodeUrlQueryString(request) {
7347
- this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
7348
- const parameterBuilder = new RequestParameterBuilder();
7349
- parameterBuilder.addClientId(request.extraQueryParameters?.[CLIENT_ID] ||
7419
+ // generate the correlationId if not set by the user and add
7420
+ const correlationId = request.correlationId ||
7421
+ this.config.cryptoInterface.createNewGuid();
7422
+ this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, correlationId);
7423
+ const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
7424
+ parameterBuilder.addClientId(request.embeddedClientId ||
7425
+ request.extraQueryParameters?.[CLIENT_ID] ||
7350
7426
  this.config.authOptions.clientId);
7351
7427
  const requestScopes = [
7352
7428
  ...(request.scopes || []),
@@ -7355,9 +7431,6 @@
7355
7431
  parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
7356
7432
  // validate the redirectUri (to be a non null value)
7357
7433
  parameterBuilder.addRedirectUri(request.redirectUri);
7358
- // generate the correlationId if not set by the user and add
7359
- const correlationId = request.correlationId ||
7360
- this.config.cryptoInterface.createNewGuid();
7361
7434
  parameterBuilder.addCorrelationId(correlationId);
7362
7435
  // add response_mode. If not passed in it defaults to query.
7363
7436
  parameterBuilder.addResponseMode(request.responseMode);
@@ -7459,6 +7532,12 @@
7459
7532
  this.config.authOptions.clientCapabilities.length > 0)) {
7460
7533
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
7461
7534
  }
7535
+ if (request.embeddedClientId) {
7536
+ parameterBuilder.addBrokerParameters({
7537
+ brokerClientId: this.config.authOptions.clientId,
7538
+ brokerRedirectUri: this.config.authOptions.redirectUri,
7539
+ });
7540
+ }
7462
7541
  this.addExtraQueryParams(request, parameterBuilder);
7463
7542
  if (request.nativeBroker) {
7464
7543
  // signal ests that this is a WAM call
@@ -7485,7 +7564,7 @@
7485
7564
  * @param request
7486
7565
  */
7487
7566
  createLogoutUrlQueryString(request) {
7488
- const parameterBuilder = new RequestParameterBuilder();
7567
+ const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
7489
7568
  if (request.postLogoutRedirectUri) {
7490
7569
  parameterBuilder.addPostLogoutRedirectUri(request.postLogoutRedirectUri);
7491
7570
  }
@@ -7528,7 +7607,7 @@
7528
7607
  }
7529
7608
  }
7530
7609
 
7531
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7610
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7532
7611
 
7533
7612
  /*
7534
7613
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7666,8 +7745,9 @@
7666
7745
  async createTokenRequestBody(request) {
7667
7746
  this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
7668
7747
  const correlationId = request.correlationId;
7669
- const parameterBuilder = new RequestParameterBuilder();
7670
- parameterBuilder.addClientId(request.tokenBodyParameters?.[CLIENT_ID] ||
7748
+ const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
7749
+ parameterBuilder.addClientId(request.embeddedClientId ||
7750
+ request.tokenBodyParameters?.[CLIENT_ID] ||
7671
7751
  this.config.authOptions.clientId);
7672
7752
  if (request.redirectUri) {
7673
7753
  parameterBuilder.addRedirectUri(request.redirectUri);
@@ -7681,7 +7761,6 @@
7681
7761
  if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
7682
7762
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
7683
7763
  }
7684
- parameterBuilder.addCorrelationId(correlationId);
7685
7764
  parameterBuilder.addRefreshToken(request.refreshToken);
7686
7765
  if (this.config.clientCredentials.clientSecret) {
7687
7766
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
@@ -7735,6 +7814,12 @@
7735
7814
  break;
7736
7815
  }
7737
7816
  }
7817
+ if (request.embeddedClientId) {
7818
+ parameterBuilder.addBrokerParameters({
7819
+ brokerClientId: this.config.authOptions.clientId,
7820
+ brokerRedirectUri: this.config.authOptions.redirectUri,
7821
+ });
7822
+ }
7738
7823
  if (request.tokenBodyParameters) {
7739
7824
  parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
7740
7825
  }
@@ -7742,7 +7827,7 @@
7742
7827
  }
7743
7828
  }
7744
7829
 
7745
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7830
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7746
7831
 
7747
7832
  /*
7748
7833
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7878,7 +7963,7 @@
7878
7963
  }
7879
7964
  }
7880
7965
 
7881
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7966
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7882
7967
 
7883
7968
  /*
7884
7969
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7893,7 +7978,7 @@
7893
7978
  },
7894
7979
  };
7895
7980
 
7896
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7981
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7897
7982
 
7898
7983
  /*
7899
7984
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7951,7 +8036,7 @@
7951
8036
  }
7952
8037
  }
7953
8038
 
7954
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8039
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7955
8040
 
7956
8041
  /*
7957
8042
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8214,7 +8299,7 @@
8214
8299
  }
8215
8300
  }
8216
8301
 
8217
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8302
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8218
8303
  /*
8219
8304
  * Copyright (c) Microsoft Corporation. All rights reserved.
8220
8305
  * Licensed under the MIT License.
@@ -8222,7 +8307,7 @@
8222
8307
  const missingKidError = "missing_kid_error";
8223
8308
  const missingAlgError = "missing_alg_error";
8224
8309
 
8225
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8310
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8226
8311
 
8227
8312
  /*
8228
8313
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8247,7 +8332,7 @@
8247
8332
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
8248
8333
  }
8249
8334
 
8250
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8335
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8251
8336
 
8252
8337
  /*
8253
8338
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8287,7 +8372,7 @@
8287
8372
  }
8288
8373
  }
8289
8374
 
8290
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8375
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8291
8376
 
8292
8377
  /*
8293
8378
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8366,7 +8451,7 @@
8366
8451
  }
8367
8452
  }
8368
8453
 
8369
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8454
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8370
8455
 
8371
8456
  /*
8372
8457
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8498,18 +8583,30 @@
8498
8583
  return [];
8499
8584
  }
8500
8585
  const stackArr = stack.split("\n") || [];
8501
- if (stackArr.length < 2) {
8502
- return [];
8503
- }
8504
8586
  const res = [];
8587
+ // Check for a handful of known, common runtime errors and log them (with redaction where applicable).
8588
+ const firstLine = stackArr[0];
8589
+ if (firstLine.startsWith("TypeError: Cannot read property") ||
8590
+ firstLine.startsWith("TypeError: Cannot read properties of") ||
8591
+ firstLine.startsWith("TypeError: Cannot set property") ||
8592
+ firstLine.startsWith("TypeError: Cannot set properties of") ||
8593
+ firstLine.endsWith("is not a function")) {
8594
+ // These types of errors are not at risk of leaking PII. They will indicate unavailable APIs
8595
+ res.push(compactStackLine(firstLine));
8596
+ }
8597
+ else if (firstLine.startsWith("SyntaxError") ||
8598
+ firstLine.startsWith("TypeError")) {
8599
+ // Prevent unintentional leaking of arbitrary info by redacting contents between both single and double quotes
8600
+ res.push(compactStackLine(
8601
+ // Example: SyntaxError: Unexpected token 'e', "test" is not valid JSON -> SyntaxError: Unexpected token <redacted>, <redacted> is not valid JSON
8602
+ firstLine.replace(/['].*[']|["].*["]/g, "<redacted>")));
8603
+ }
8505
8604
  // Get top N stack lines
8506
- for (
8507
- // Skip first line as it may contain PII data
8508
- let ix = Math.max(stackArr.length - stackMaxSize - 1, 1); ix < stackArr.length; ix++) {
8509
- const line = stackArr[ix];
8605
+ for (let ix = 1; ix < stackArr.length; ix++) {
8510
8606
  if (res.length >= stackMaxSize) {
8511
8607
  break;
8512
8608
  }
8609
+ const line = stackArr[ix];
8513
8610
  res.push(compactStackLine(line));
8514
8611
  }
8515
8612
  return res;
@@ -8756,13 +8853,20 @@
8756
8853
  rootEvent.incompleteSubMeasurements?.delete(event.eventId);
8757
8854
  }
8758
8855
  this.logger.trace(`PerformanceClient: Performance measurement ended for ${event.name}: ${event.durationMs} ms`, event.correlationId);
8856
+ if (error) {
8857
+ addError(error, this.logger, rootEvent);
8858
+ }
8759
8859
  // Add sub-measurement attribute to root event.
8760
8860
  if (!isRoot) {
8761
8861
  rootEvent[event.name + "DurationMs"] = Math.floor(event.durationMs);
8762
8862
  return { ...rootEvent };
8763
8863
  }
8764
- if (error) {
8765
- addError(error, this.logger, rootEvent);
8864
+ if (isRoot &&
8865
+ !error &&
8866
+ (rootEvent.errorCode || rootEvent.subErrorCode)) {
8867
+ this.logger.trace(`PerformanceClient: Remove error and sub-error codes for root event ${event.name} as intermediate error was successfully handled`, event.correlationId);
8868
+ rootEvent.errorCode = undefined;
8869
+ rootEvent.subErrorCode = undefined;
8766
8870
  }
8767
8871
  let finalEvent = { ...rootEvent, ...event };
8768
8872
  let incompleteSubsCount = 0;
@@ -9005,7 +9109,9 @@
9005
9109
  const uninitializedPublicClientApplication = "uninitialized_public_client_application";
9006
9110
  const nativePromptNotSupported = "native_prompt_not_supported";
9007
9111
  const invalidBase64String = "invalid_base64_string";
9008
- const invalidPopTokenRequest = "invalid_pop_token_request";
9112
+ const invalidPopTokenRequest = "invalid_pop_token_request";
9113
+ const failedToBuildHeaders = "failed_to_build_headers";
9114
+ const failedToParseHeaders = "failed_to_parse_headers";
9009
9115
 
9010
9116
  var BrowserAuthErrorCodes = /*#__PURE__*/Object.freeze({
9011
9117
  __proto__: null,
@@ -9020,6 +9126,8 @@
9020
9126
  databaseUnavailable: databaseUnavailable,
9021
9127
  emptyNavigateUri: emptyNavigateUri,
9022
9128
  emptyWindowError: emptyWindowError,
9129
+ failedToBuildHeaders: failedToBuildHeaders,
9130
+ failedToParseHeaders: failedToParseHeaders,
9023
9131
  failedToParseResponse: failedToParseResponse,
9024
9132
  getRequestFailed: getRequestFailed,
9025
9133
  hashDoesNotContainKnownProperties: hashDoesNotContainKnownProperties,
@@ -9112,6 +9220,8 @@
9112
9220
  [nativePromptNotSupported]: "The provided prompt is not supported by the native platform. This request should be routed to the web based flow.",
9113
9221
  [invalidBase64String]: "Invalid base64 encoded string.",
9114
9222
  [invalidPopTokenRequest]: "Invalid PoP token request. The request should not have both a popKid value and signPopToken set to true.",
9223
+ [failedToBuildHeaders]: "Failed to build request headers object.",
9224
+ [failedToParseHeaders]: "Failed to parse response headers",
9115
9225
  };
9116
9226
  /**
9117
9227
  * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
@@ -9311,14 +9421,14 @@
9311
9421
  * Browser library error class thrown by the MSAL.js library for SPAs
9312
9422
  */
9313
9423
  class BrowserAuthError extends AuthError {
9314
- constructor(errorCode) {
9315
- super(errorCode, BrowserAuthErrorMessages[errorCode]);
9424
+ constructor(errorCode, subError) {
9425
+ super(errorCode, BrowserAuthErrorMessages[errorCode], subError);
9316
9426
  Object.setPrototypeOf(this, BrowserAuthError.prototype);
9317
9427
  this.name = "BrowserAuthError";
9318
9428
  }
9319
9429
  }
9320
- function createBrowserAuthError(errorCode) {
9321
- return new BrowserAuthError(errorCode);
9430
+ function createBrowserAuthError(errorCode, subError) {
9431
+ return new BrowserAuthError(errorCode, subError);
9322
9432
  }
9323
9433
 
9324
9434
  /*
@@ -9601,6 +9711,7 @@
9601
9711
  const UUID_CHARS = "0123456789abcdef";
9602
9712
  // Array to store UINT32 random value
9603
9713
  const UINT32_ARR = new Uint32Array(1);
9714
+ const SUBTLE_SUBERROR = "crypto_subtle_undefined";
9604
9715
  const keygenAlgorithmOptions = {
9605
9716
  name: PKCS1_V15_KEYGEN_ALG,
9606
9717
  hash: S256_HASH_ALG,
@@ -9610,14 +9721,16 @@
9610
9721
  /**
9611
9722
  * Check whether browser crypto is available.
9612
9723
  */
9613
- function validateCryptoAvailable(logger) {
9614
- if ("crypto" in window) {
9615
- logger.verbose("BrowserCrypto: modern crypto interface available");
9724
+ function validateCryptoAvailable() {
9725
+ if (!window) {
9726
+ throw createBrowserAuthError(nonBrowserEnvironment);
9616
9727
  }
9617
- else {
9618
- logger.error("BrowserCrypto: crypto interface is unavailable");
9728
+ if (!window.crypto) {
9619
9729
  throw createBrowserAuthError(cryptoNonExistent);
9620
9730
  }
9731
+ if (!window.crypto.subtle) {
9732
+ throw createBrowserAuthError(cryptoNonExistent, SUBTLE_SUBERROR);
9733
+ }
9621
9734
  }
9622
9735
  /**
9623
9736
  * Returns a sha-256 hash of the given dataString as an ArrayBuffer.
@@ -10022,29 +10135,31 @@
10022
10135
  */
10023
10136
  async sendGetRequestAsync(url, options) {
10024
10137
  let response;
10138
+ let responseHeaders = {};
10139
+ let responseStatus = 0;
10140
+ const reqHeaders = getFetchHeaders(options);
10025
10141
  try {
10026
10142
  response = await fetch(url, {
10027
10143
  method: HTTP_REQUEST_TYPE.GET,
10028
- headers: this.getFetchHeaders(options),
10144
+ headers: reqHeaders,
10029
10145
  });
10030
10146
  }
10031
10147
  catch (e) {
10032
- if (window.navigator.onLine) {
10033
- throw createBrowserAuthError(getRequestFailed);
10034
- }
10035
- else {
10036
- throw createBrowserAuthError(noNetworkConnectivity);
10037
- }
10148
+ throw createBrowserAuthError(window.navigator.onLine
10149
+ ? getRequestFailed
10150
+ : noNetworkConnectivity);
10038
10151
  }
10152
+ responseHeaders = getHeaderDict(response.headers);
10039
10153
  try {
10154
+ responseStatus = response.status;
10040
10155
  return {
10041
- headers: this.getHeaderDict(response.headers),
10156
+ headers: responseHeaders,
10042
10157
  body: (await response.json()),
10043
- status: response.status,
10158
+ status: responseStatus,
10044
10159
  };
10045
10160
  }
10046
10161
  catch (e) {
10047
- throw createBrowserAuthError(failedToParseResponse);
10162
+ throw createNetworkError(createBrowserAuthError(failedToParseResponse), responseStatus, responseHeaders);
10048
10163
  }
10049
10164
  }
10050
10165
  /**
@@ -10054,56 +10169,73 @@
10054
10169
  * @param body
10055
10170
  */
10056
10171
  async sendPostRequestAsync(url, options) {
10057
- const reqBody = (options && options.body) || Constants.EMPTY_STRING;
10172
+ const reqBody = (options && options.body) || "";
10173
+ const reqHeaders = getFetchHeaders(options);
10058
10174
  let response;
10175
+ let responseStatus = 0;
10176
+ let responseHeaders = {};
10059
10177
  try {
10060
10178
  response = await fetch(url, {
10061
10179
  method: HTTP_REQUEST_TYPE.POST,
10062
- headers: this.getFetchHeaders(options),
10180
+ headers: reqHeaders,
10063
10181
  body: reqBody,
10064
10182
  });
10065
10183
  }
10066
10184
  catch (e) {
10067
- if (window.navigator.onLine) {
10068
- throw createBrowserAuthError(postRequestFailed);
10069
- }
10070
- else {
10071
- throw createBrowserAuthError(noNetworkConnectivity);
10072
- }
10185
+ throw createBrowserAuthError(window.navigator.onLine
10186
+ ? postRequestFailed
10187
+ : noNetworkConnectivity);
10073
10188
  }
10189
+ responseHeaders = getHeaderDict(response.headers);
10074
10190
  try {
10191
+ responseStatus = response.status;
10075
10192
  return {
10076
- headers: this.getHeaderDict(response.headers),
10193
+ headers: responseHeaders,
10077
10194
  body: (await response.json()),
10078
- status: response.status,
10195
+ status: responseStatus,
10079
10196
  };
10080
10197
  }
10081
10198
  catch (e) {
10082
- throw createBrowserAuthError(failedToParseResponse);
10199
+ throw createNetworkError(createBrowserAuthError(failedToParseResponse), responseStatus, responseHeaders);
10083
10200
  }
10084
10201
  }
10085
- /**
10086
- * Get Fetch API Headers object from string map
10087
- * @param inputHeaders
10088
- */
10089
- getFetchHeaders(options) {
10202
+ }
10203
+ /**
10204
+ * Get Fetch API Headers object from string map
10205
+ * @param inputHeaders
10206
+ */
10207
+ function getFetchHeaders(options) {
10208
+ try {
10090
10209
  const headers = new Headers();
10091
10210
  if (!(options && options.headers)) {
10092
10211
  return headers;
10093
10212
  }
10094
10213
  const optionsHeaders = options.headers;
10095
- Object.keys(optionsHeaders).forEach((key) => {
10096
- headers.append(key, optionsHeaders[key]);
10214
+ Object.entries(optionsHeaders).forEach(([key, value]) => {
10215
+ headers.append(key, value);
10097
10216
  });
10098
10217
  return headers;
10099
10218
  }
10100
- getHeaderDict(headers) {
10219
+ catch (e) {
10220
+ throw createBrowserAuthError(failedToBuildHeaders);
10221
+ }
10222
+ }
10223
+ /**
10224
+ * Returns object representing response headers
10225
+ * @param headers
10226
+ * @returns
10227
+ */
10228
+ function getHeaderDict(headers) {
10229
+ try {
10101
10230
  const headerDict = {};
10102
10231
  headers.forEach((value, key) => {
10103
10232
  headerDict[key] = value;
10104
10233
  });
10105
10234
  return headerDict;
10106
10235
  }
10236
+ catch (e) {
10237
+ throw createBrowserAuthError(failedToParseHeaders);
10238
+ }
10107
10239
  }
10108
10240
 
10109
10241
  /*
@@ -10132,7 +10264,7 @@
10132
10264
  knownAuthorities: [],
10133
10265
  cloudDiscoveryMetadata: Constants.EMPTY_STRING,
10134
10266
  authorityMetadata: Constants.EMPTY_STRING,
10135
- redirectUri: Constants.EMPTY_STRING,
10267
+ redirectUri: typeof window !== "undefined" ? getCurrentUri() : "",
10136
10268
  postLogoutRedirectUri: Constants.EMPTY_STRING,
10137
10269
  navigateToLoginRequestUrl: true,
10138
10270
  clientCapabilities: [],
@@ -10238,7 +10370,7 @@
10238
10370
 
10239
10371
  /* eslint-disable header/header */
10240
10372
  const name = "@azure/msal-browser";
10241
- const version = "3.26.1";
10373
+ const version = "3.28.0";
10242
10374
 
10243
10375
  /*
10244
10376
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11028,7 +11160,7 @@
11028
11160
  constructor(logger, performanceClient) {
11029
11161
  this.logger = logger;
11030
11162
  // Browser crypto needs to be validated first before any other classes can be set.
11031
- validateCryptoAvailable(logger);
11163
+ validateCryptoAvailable();
11032
11164
  this.cache = new AsyncMemoryStorage(this.logger);
11033
11165
  this.performanceClient = performanceClient;
11034
11166
  }
@@ -11197,32 +11329,53 @@
11197
11329
  * Copyright (c) Microsoft Corporation. All rights reserved.
11198
11330
  * Licensed under the MIT License.
11199
11331
  */
11200
- class BrowserStorage {
11201
- constructor(cacheLocation) {
11202
- this.validateWindowStorage(cacheLocation);
11203
- this.windowStorage = window[cacheLocation];
11332
+ class LocalStorage {
11333
+ constructor() {
11334
+ if (!window.localStorage) {
11335
+ throw createBrowserConfigurationAuthError(storageNotSupported);
11336
+ }
11337
+ }
11338
+ getItem(key) {
11339
+ return window.localStorage.getItem(key);
11340
+ }
11341
+ setItem(key, value) {
11342
+ window.localStorage.setItem(key, value);
11343
+ }
11344
+ removeItem(key) {
11345
+ window.localStorage.removeItem(key);
11346
+ }
11347
+ getKeys() {
11348
+ return Object.keys(window.localStorage);
11349
+ }
11350
+ containsKey(key) {
11351
+ return window.localStorage.hasOwnProperty(key);
11204
11352
  }
11205
- validateWindowStorage(cacheLocation) {
11206
- if ((cacheLocation !== BrowserCacheLocation.LocalStorage &&
11207
- cacheLocation !== BrowserCacheLocation.SessionStorage) ||
11208
- !window[cacheLocation]) {
11353
+ }
11354
+
11355
+ /*
11356
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11357
+ * Licensed under the MIT License.
11358
+ */
11359
+ class SessionStorage {
11360
+ constructor() {
11361
+ if (!window.sessionStorage) {
11209
11362
  throw createBrowserConfigurationAuthError(storageNotSupported);
11210
11363
  }
11211
11364
  }
11212
11365
  getItem(key) {
11213
- return this.windowStorage.getItem(key);
11366
+ return window.sessionStorage.getItem(key);
11214
11367
  }
11215
11368
  setItem(key, value) {
11216
- this.windowStorage.setItem(key, value);
11369
+ window.sessionStorage.setItem(key, value);
11217
11370
  }
11218
11371
  removeItem(key) {
11219
- this.windowStorage.removeItem(key);
11372
+ window.sessionStorage.removeItem(key);
11220
11373
  }
11221
11374
  getKeys() {
11222
- return Object.keys(this.windowStorage);
11375
+ return Object.keys(window.sessionStorage);
11223
11376
  }
11224
11377
  containsKey(key) {
11225
- return this.windowStorage.hasOwnProperty(key);
11378
+ return window.sessionStorage.hasOwnProperty(key);
11226
11379
  }
11227
11380
  }
11228
11381
 
@@ -11248,6 +11401,64 @@
11248
11401
  }
11249
11402
  }
11250
11403
 
11404
+ /*
11405
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11406
+ * Licensed under the MIT License.
11407
+ */
11408
+ // Cookie life calculation (hours * minutes * seconds * ms)
11409
+ const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11410
+ class CookieStorage {
11411
+ getItem(key) {
11412
+ const name = `${encodeURIComponent(key)}`;
11413
+ const cookieList = document.cookie.split(";");
11414
+ for (let i = 0; i < cookieList.length; i++) {
11415
+ const cookie = cookieList[i];
11416
+ const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
11417
+ const value = rest.join("=");
11418
+ if (key === name) {
11419
+ return value;
11420
+ }
11421
+ }
11422
+ return "";
11423
+ }
11424
+ setItem(key, value, cookieLifeDays, secure = true) {
11425
+ let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
11426
+ if (cookieLifeDays) {
11427
+ const expireTime = getCookieExpirationTime(cookieLifeDays);
11428
+ cookieStr += `expires=${expireTime};`;
11429
+ }
11430
+ if (secure) {
11431
+ cookieStr += "Secure;";
11432
+ }
11433
+ document.cookie = cookieStr;
11434
+ }
11435
+ removeItem(key) {
11436
+ // Setting expiration to -1 removes it
11437
+ this.setItem(key, "", -1);
11438
+ }
11439
+ getKeys() {
11440
+ const cookieList = document.cookie.split(";");
11441
+ const keys = [];
11442
+ cookieList.forEach((cookie) => {
11443
+ const cookieParts = decodeURIComponent(cookie).trim().split("=");
11444
+ keys.push(cookieParts[0]);
11445
+ });
11446
+ return keys;
11447
+ }
11448
+ containsKey(key) {
11449
+ return this.getKeys().includes(key);
11450
+ }
11451
+ }
11452
+ /**
11453
+ * Get cookie expiration time
11454
+ * @param cookieLifeDays
11455
+ */
11456
+ function getCookieExpirationTime(cookieLifeDays) {
11457
+ const today = new Date();
11458
+ const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
11459
+ return expr.toUTCString();
11460
+ }
11461
+
11251
11462
  /*
11252
11463
  * Copyright (c) Microsoft Corporation. All rights reserved.
11253
11464
  * Licensed under the MIT License.
@@ -11260,13 +11471,12 @@
11260
11471
  class BrowserCacheManager extends CacheManager {
11261
11472
  constructor(clientId, cacheConfig, cryptoImpl, logger, staticAuthorityOptions, performanceClient) {
11262
11473
  super(clientId, cryptoImpl, logger, staticAuthorityOptions);
11263
- // Cookie life calculation (hours * minutes * seconds * ms)
11264
- this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11265
11474
  this.cacheConfig = cacheConfig;
11266
11475
  this.logger = logger;
11267
11476
  this.internalStorage = new MemoryStorage();
11268
11477
  this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);
11269
- this.temporaryCacheStorage = this.setupTemporaryCacheStorage(this.cacheConfig.temporaryCacheLocation, this.cacheConfig.cacheLocation);
11478
+ this.temporaryCacheStorage = this.setupBrowserStorage(this.cacheConfig.temporaryCacheLocation);
11479
+ this.cookieStorage = new CookieStorage();
11270
11480
  // Migrate cache entries from older versions of MSAL.
11271
11481
  if (cacheConfig.cacheMigrationEnabled) {
11272
11482
  this.migrateCacheEntries();
@@ -11279,44 +11489,23 @@
11279
11489
  * @param cacheLocation
11280
11490
  */
11281
11491
  setupBrowserStorage(cacheLocation) {
11282
- switch (cacheLocation) {
11283
- case BrowserCacheLocation.LocalStorage:
11284
- case BrowserCacheLocation.SessionStorage:
11285
- try {
11286
- return new BrowserStorage(cacheLocation);
11287
- }
11288
- catch (e) {
11289
- this.logger.verbose(e);
11492
+ try {
11493
+ switch (cacheLocation) {
11494
+ case BrowserCacheLocation.LocalStorage:
11495
+ return new LocalStorage();
11496
+ case BrowserCacheLocation.SessionStorage:
11497
+ return new SessionStorage();
11498
+ case BrowserCacheLocation.MemoryStorage:
11499
+ default:
11290
11500
  break;
11291
- }
11292
- case BrowserCacheLocation.MemoryStorage:
11501
+ }
11502
+ }
11503
+ catch (e) {
11504
+ this.logger.error(e);
11293
11505
  }
11294
11506
  this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
11295
11507
  return new MemoryStorage();
11296
11508
  }
11297
- /**
11298
- * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured temporaryCacheLocation.
11299
- * @param temporaryCacheLocation
11300
- * @param cacheLocation
11301
- */
11302
- setupTemporaryCacheStorage(temporaryCacheLocation, cacheLocation) {
11303
- switch (cacheLocation) {
11304
- case BrowserCacheLocation.LocalStorage:
11305
- case BrowserCacheLocation.SessionStorage:
11306
- try {
11307
- // Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
11308
- return new BrowserStorage(temporaryCacheLocation ||
11309
- BrowserCacheLocation.SessionStorage);
11310
- }
11311
- catch (e) {
11312
- this.logger.verbose(e);
11313
- return this.internalStorage;
11314
- }
11315
- case BrowserCacheLocation.MemoryStorage:
11316
- default:
11317
- return this.internalStorage;
11318
- }
11319
- }
11320
11509
  /**
11321
11510
  * Migrate all old cache entries to new schema. No rollback supported.
11322
11511
  * @param storeAuthStateInCookie
@@ -12004,7 +12193,7 @@
12004
12193
  getTemporaryCache(cacheKey, generateKey) {
12005
12194
  const key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;
12006
12195
  if (this.cacheConfig.storeAuthStateInCookie) {
12007
- const itemCookie = this.getItemCookie(key);
12196
+ const itemCookie = this.cookieStorage.getItem(key);
12008
12197
  if (itemCookie) {
12009
12198
  this.logger.trace("BrowserCacheManager.getTemporaryCache: storeAuthStateInCookies set to true, retrieving from cookies");
12010
12199
  return itemCookie;
@@ -12039,7 +12228,7 @@
12039
12228
  this.temporaryCacheStorage.setItem(key, value);
12040
12229
  if (this.cacheConfig.storeAuthStateInCookie) {
12041
12230
  this.logger.trace("BrowserCacheManager.setTemporaryCache: storeAuthStateInCookie set to true, setting item cookie");
12042
- this.setItemCookie(key, value);
12231
+ this.cookieStorage.setItem(key, value, undefined, this.cacheConfig.secureCookies);
12043
12232
  }
12044
12233
  }
12045
12234
  /**
@@ -12058,7 +12247,7 @@
12058
12247
  this.temporaryCacheStorage.removeItem(key);
12059
12248
  if (this.cacheConfig.storeAuthStateInCookie) {
12060
12249
  this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
12061
- this.clearItemCookie(key);
12250
+ this.cookieStorage.removeItem(key);
12062
12251
  }
12063
12252
  }
12064
12253
  /**
@@ -12114,79 +12303,6 @@
12114
12303
  this.logger.warning(`${removedAccessTokens.length} access tokens with claims in the cache keys have been removed from the cache.`);
12115
12304
  }
12116
12305
  }
12117
- /**
12118
- * Add value to cookies
12119
- * @param cookieName
12120
- * @param cookieValue
12121
- * @param expires
12122
- * @deprecated
12123
- */
12124
- setItemCookie(cookieName, cookieValue, expires) {
12125
- let cookieStr = `${encodeURIComponent(cookieName)}=${encodeURIComponent(cookieValue)};path=/;SameSite=Lax;`;
12126
- if (expires) {
12127
- const expireTime = this.getCookieExpirationTime(expires);
12128
- cookieStr += `expires=${expireTime};`;
12129
- }
12130
- if (this.cacheConfig.secureCookies) {
12131
- cookieStr += "Secure;";
12132
- }
12133
- document.cookie = cookieStr;
12134
- }
12135
- /**
12136
- * Get one item by key from cookies
12137
- * @param cookieName
12138
- * @deprecated
12139
- */
12140
- getItemCookie(cookieName) {
12141
- const name = `${encodeURIComponent(cookieName)}=`;
12142
- const cookieList = document.cookie.split(";");
12143
- for (let i = 0; i < cookieList.length; i++) {
12144
- let cookie = cookieList[i];
12145
- while (cookie.charAt(0) === " ") {
12146
- cookie = cookie.substring(1);
12147
- }
12148
- if (cookie.indexOf(name) === 0) {
12149
- return decodeURIComponent(cookie.substring(name.length, cookie.length));
12150
- }
12151
- }
12152
- return Constants.EMPTY_STRING;
12153
- }
12154
- /**
12155
- * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
12156
- * @deprecated
12157
- */
12158
- clearMsalCookies() {
12159
- const cookiePrefix = `${Constants.CACHE_PREFIX}.${this.clientId}`;
12160
- const cookieList = document.cookie.split(";");
12161
- cookieList.forEach((cookie) => {
12162
- while (cookie.charAt(0) === " ") {
12163
- // eslint-disable-next-line no-param-reassign
12164
- cookie = cookie.substring(1);
12165
- }
12166
- if (cookie.indexOf(cookiePrefix) === 0) {
12167
- const cookieKey = cookie.split("=")[0];
12168
- this.clearItemCookie(cookieKey);
12169
- }
12170
- });
12171
- }
12172
- /**
12173
- * Clear an item in the cookies by key
12174
- * @param cookieName
12175
- * @deprecated
12176
- */
12177
- clearItemCookie(cookieName) {
12178
- this.setItemCookie(cookieName, Constants.EMPTY_STRING, -1);
12179
- }
12180
- /**
12181
- * Get cookie expiration time
12182
- * @param cookieLifeDays
12183
- * @deprecated
12184
- */
12185
- getCookieExpirationTime(cookieLifeDays) {
12186
- const today = new Date();
12187
- const expr = new Date(today.getTime() + cookieLifeDays * this.COOKIE_LIFE_MULTIPLIER);
12188
- return expr.toUTCString();
12189
- }
12190
12306
  /**
12191
12307
  * Prepend msal.<client-id> to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)
12192
12308
  * @param key
@@ -12310,7 +12426,6 @@
12310
12426
  this.logger.infoPii(`BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: ${cachedState}`);
12311
12427
  this.resetRequestCache(cachedState || Constants.EMPTY_STRING);
12312
12428
  }
12313
- this.clearMsalCookies();
12314
12429
  }
12315
12430
  /**
12316
12431
  * Looks in temporary cache for any state values with the provided interactionType and removes all temporary cache items for that state
@@ -12338,7 +12453,6 @@
12338
12453
  this.resetRequestCache(stateValue);
12339
12454
  }
12340
12455
  });
12341
- this.clearMsalCookies();
12342
12456
  this.setInteractionInProgress(false);
12343
12457
  }
12344
12458
  cacheCodeRequest(authCodeRequest) {
@@ -12821,9 +12935,7 @@
12821
12935
  */
12822
12936
  getRedirectUri(requestRedirectUri) {
12823
12937
  this.logger.verbose("getRedirectUri called");
12824
- const redirectUri = requestRedirectUri ||
12825
- this.config.auth.redirectUri ||
12826
- getCurrentUri();
12938
+ const redirectUri = requestRedirectUri || this.config.auth.redirectUri;
12827
12939
  return UrlString.getAbsoluteUrl(redirectUri, getCurrentUri());
12828
12940
  }
12829
12941
  /**
@@ -13146,6 +13258,7 @@
13146
13258
  clientId: this.config.auth.clientId,
13147
13259
  authority: discoveredAuthority,
13148
13260
  clientCapabilities: this.config.auth.clientCapabilities,
13261
+ redirectUri: this.config.auth.redirectUri,
13149
13262
  },
13150
13263
  systemOptions: {
13151
13264
  tokenRenewalOffsetSeconds: this.config.system.tokenRenewalOffsetSeconds,
@@ -13194,6 +13307,10 @@
13194
13307
  responseMode: this.config.auth.OIDCOptions
13195
13308
  .serverResponseType,
13196
13309
  };
13310
+ // Skip active account lookup if either login hint or session id is set
13311
+ if (request.loginHint || request.sid) {
13312
+ return validatedRequest;
13313
+ }
13197
13314
  const account = request.account || this.browserStorage.getActiveAccount();
13198
13315
  if (account) {
13199
13316
  this.logger.verbose("Setting validated request account", this.correlationId);
@@ -13343,10 +13460,6 @@
13343
13460
  * Copyright (c) Microsoft Corporation. All rights reserved.
13344
13461
  * Licensed under the MIT License.
13345
13462
  */
13346
- const BrokerServerParamKeys = {
13347
- BROKER_CLIENT_ID: "brk_client_id",
13348
- BROKER_REDIRECT_URI: "brk_redirect_uri",
13349
- };
13350
13463
  class NativeInteractionClient extends BaseInteractionClient {
13351
13464
  constructor(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
13352
13465
  super(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
@@ -13949,21 +14062,33 @@
13949
14062
  * @private
13950
14063
  */
13951
14064
  handleExtraBrokerParams(request) {
13952
- if (!request.extraParameters) {
14065
+ const hasExtraBrokerParams = request.extraParameters &&
14066
+ request.extraParameters.hasOwnProperty(BROKER_CLIENT_ID) &&
14067
+ request.extraParameters.hasOwnProperty(BROKER_REDIRECT_URI) &&
14068
+ request.extraParameters.hasOwnProperty(CLIENT_ID);
14069
+ if (!request.embeddedClientId && !hasExtraBrokerParams) {
13953
14070
  return;
13954
14071
  }
13955
- if (request.extraParameters.hasOwnProperty(BrokerServerParamKeys.BROKER_CLIENT_ID) &&
13956
- request.extraParameters.hasOwnProperty(BrokerServerParamKeys.BROKER_REDIRECT_URI) &&
13957
- request.extraParameters.hasOwnProperty(CLIENT_ID)) {
13958
- const child_client_id = request.extraParameters[CLIENT_ID];
13959
- const child_redirect_uri = request.redirectUri;
13960
- const brk_redirect_uri = request.extraParameters[BrokerServerParamKeys.BROKER_REDIRECT_URI];
13961
- request.extraParameters = {
13962
- child_client_id,
13963
- child_redirect_uri,
13964
- };
13965
- request.redirectUri = brk_redirect_uri;
14072
+ let child_client_id = "";
14073
+ const child_redirect_uri = request.redirectUri;
14074
+ if (request.embeddedClientId) {
14075
+ request.redirectUri = this.config.auth.redirectUri;
14076
+ child_client_id = request.embeddedClientId;
13966
14077
  }
14078
+ else if (request.extraParameters) {
14079
+ request.redirectUri =
14080
+ request.extraParameters[BROKER_REDIRECT_URI];
14081
+ child_client_id =
14082
+ request.extraParameters[CLIENT_ID];
14083
+ }
14084
+ request.extraParameters = {
14085
+ child_client_id,
14086
+ child_redirect_uri,
14087
+ };
14088
+ this.performanceClient?.addFields({
14089
+ embeddedClientId: child_client_id,
14090
+ embeddedRedirectUri: child_redirect_uri,
14091
+ }, request.correlationId);
13967
14092
  }
13968
14093
  }
13969
14094
 
@@ -16255,7 +16380,6 @@
16255
16380
  atPopupMeasurement.end({
16256
16381
  success: true,
16257
16382
  isNativeBroker: true,
16258
- requestId: response.requestId,
16259
16383
  accountType: getAccountType(response.account),
16260
16384
  });
16261
16385
  return response;
@@ -16294,7 +16418,6 @@
16294
16418
  }
16295
16419
  atPopupMeasurement.end({
16296
16420
  success: true,
16297
- requestId: result.requestId,
16298
16421
  accessTokenSize: result.accessToken.length,
16299
16422
  idTokenSize: result.idToken.length,
16300
16423
  accountType: getAccountType(result.account),
@@ -16385,7 +16508,6 @@
16385
16508
  this.ssoSilentMeasurement?.end({
16386
16509
  success: true,
16387
16510
  isNativeBroker: response.fromNativeBroker,
16388
- requestId: response.requestId,
16389
16511
  accessTokenSize: response.accessToken.length,
16390
16512
  idTokenSize: response.idToken.length,
16391
16513
  accountType: getAccountType(response.account),
@@ -16440,7 +16562,6 @@
16440
16562
  atbcMeasurement.end({
16441
16563
  success: true,
16442
16564
  isNativeBroker: result.fromNativeBroker,
16443
- requestId: result.requestId,
16444
16565
  accessTokenSize: result.accessToken.length,
16445
16566
  idTokenSize: result.idToken.length,
16446
16567
  accountType: getAccountType(result.account),
@@ -16519,7 +16640,6 @@
16519
16640
  success: true,
16520
16641
  fromCache: response.fromCache,
16521
16642
  isNativeBroker: response.fromNativeBroker,
16522
- requestId: response.requestId,
16523
16643
  });
16524
16644
  return response;
16525
16645
  })
@@ -17070,7 +17190,6 @@
17070
17190
  fromCache: result.fromCache,
17071
17191
  isNativeBroker: result.fromNativeBroker,
17072
17192
  cacheLookupPolicy: request.cacheLookupPolicy,
17073
- requestId: result.requestId,
17074
17193
  accessTokenSize: result.accessToken.length,
17075
17194
  idTokenSize: result.idToken.length,
17076
17195
  });
@@ -17181,7 +17300,6 @@
17181
17300
  this.performanceClient.addFields({
17182
17301
  fromCache: response.fromCache,
17183
17302
  isNativeBroker: response.fromNativeBroker,
17184
- requestId: response.requestId,
17185
17303
  }, request.correlationId);
17186
17304
  }
17187
17305
  return response;
@@ -17281,7 +17399,8 @@
17281
17399
  else {
17282
17400
  extraParams = new Map(Object.entries(request.extraQueryParameters));
17283
17401
  }
17284
- const requestBuilder = new RequestParameterBuilder();
17402
+ const correlationId = request.correlationId || this.crypto.createNewGuid();
17403
+ const requestBuilder = new RequestParameterBuilder(correlationId);
17285
17404
  const claims = requestBuilder.addClientCapabilitiesToClaims(request.claims, this.clientCapabilities);
17286
17405
  const scopes = request.scopes || OIDC_DEFAULT_SCOPES;
17287
17406
  const tokenRequest = {
@@ -17289,9 +17408,7 @@
17289
17408
  clientId: this.clientId,
17290
17409
  authority: request.authority,
17291
17410
  scope: scopes.join(" "),
17292
- correlationId: request.correlationId !== undefined
17293
- ? request.correlationId
17294
- : this.crypto.createNewGuid(),
17411
+ correlationId,
17295
17412
  claims: !StringUtils.isEmptyObj(claims) ? claims : undefined,
17296
17413
  state: request.state,
17297
17414
  authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER,
@@ -19101,6 +19218,42 @@
19101
19218
  },
19102
19219
  };
19103
19220
 
19221
+ /*
19222
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19223
+ * Licensed under the MIT License.
19224
+ */
19225
+ /**
19226
+ * @deprecated This class will be removed in a future major version
19227
+ */
19228
+ class BrowserStorage {
19229
+ constructor(cacheLocation) {
19230
+ if (cacheLocation === BrowserCacheLocation.LocalStorage) {
19231
+ this.windowStorage = new LocalStorage();
19232
+ }
19233
+ else if (cacheLocation === BrowserCacheLocation.SessionStorage) {
19234
+ this.windowStorage = new SessionStorage();
19235
+ }
19236
+ else {
19237
+ throw createBrowserConfigurationAuthError(storageNotSupported);
19238
+ }
19239
+ }
19240
+ getItem(key) {
19241
+ return this.windowStorage.getItem(key);
19242
+ }
19243
+ setItem(key, value) {
19244
+ this.windowStorage.setItem(key, value);
19245
+ }
19246
+ removeItem(key) {
19247
+ this.windowStorage.removeItem(key);
19248
+ }
19249
+ getKeys() {
19250
+ return Object.keys(this.windowStorage);
19251
+ }
19252
+ containsKey(key) {
19253
+ return this.windowStorage.hasOwnProperty(key);
19254
+ }
19255
+ }
19256
+
19104
19257
  /*
19105
19258
  * Copyright (c) Microsoft Corporation. All rights reserved.
19106
19259
  * Licensed under the MIT License.
@@ -19506,6 +19659,7 @@
19506
19659
  exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
19507
19660
  exports.InteractionStatus = InteractionStatus;
19508
19661
  exports.JsonWebTokenTypes = JsonWebTokenTypes;
19662
+ exports.LocalStorage = LocalStorage;
19509
19663
  exports.Logger = Logger;
19510
19664
  exports.MemoryStorage = MemoryStorage;
19511
19665
  exports.NavigationClient = NavigationClient;
@@ -19517,6 +19671,7 @@
19517
19671
  exports.PublicClientNext = PublicClientNext;
19518
19672
  exports.ServerError = ServerError;
19519
19673
  exports.ServerResponseType = ServerResponseType;
19674
+ exports.SessionStorage = SessionStorage;
19520
19675
  exports.SignedHttpRequest = SignedHttpRequest;
19521
19676
  exports.StringUtils = StringUtils;
19522
19677
  exports.StubPerformanceClient = StubPerformanceClient;