@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,8 +1,8 @@
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
  'use strict';
4
4
 
5
- /*! @azure/msal-common v14.15.0 2024-10-08 */
5
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6
6
  /*
7
7
  * Copyright (c) Microsoft Corporation. All rights reserved.
8
8
  * Licensed under the MIT License.
@@ -97,6 +97,7 @@ const OIDC_SCOPES = [...OIDC_DEFAULT_SCOPES, Constants.EMAIL_SCOPE];
97
97
  */
98
98
  const HeaderNames = {
99
99
  CONTENT_TYPE: "Content-Type",
100
+ CONTENT_LENGTH: "Content-Length",
100
101
  RETRY_AFTER: "Retry-After",
101
102
  CCS_HEADER: "X-AnchorMailbox",
102
103
  WWWAuthenticate: "WWW-Authenticate",
@@ -311,7 +312,7 @@ const JsonWebTokenTypes = {
311
312
  // Token renewal offset default in seconds
312
313
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
313
314
 
314
- /*! @azure/msal-common v14.15.0 2024-10-08 */
315
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
315
316
  /*
316
317
  * Copyright (c) Microsoft Corporation. All rights reserved.
317
318
  * Licensed under the MIT License.
@@ -328,7 +329,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
328
329
  unexpectedError: unexpectedError
329
330
  });
330
331
 
331
- /*! @azure/msal-common v14.15.0 2024-10-08 */
332
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
332
333
 
333
334
  /*
334
335
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -377,7 +378,7 @@ function createAuthError(code, additionalMessage) {
377
378
  : AuthErrorMessages[code]);
378
379
  }
379
380
 
380
- /*! @azure/msal-common v14.15.0 2024-10-08 */
381
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
381
382
  /*
382
383
  * Copyright (c) Microsoft Corporation. All rights reserved.
383
384
  * Licensed under the MIT License.
@@ -475,7 +476,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
475
476
  userTimeoutReached: userTimeoutReached
476
477
  });
477
478
 
478
- /*! @azure/msal-common v14.15.0 2024-10-08 */
479
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
479
480
 
480
481
  /*
481
482
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -727,7 +728,7 @@ function createClientAuthError(errorCode, additionalMessage) {
727
728
  return new ClientAuthError(errorCode, additionalMessage);
728
729
  }
729
730
 
730
- /*! @azure/msal-common v14.15.0 2024-10-08 */
731
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
731
732
 
732
733
  /*
733
734
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -766,7 +767,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
766
767
  },
767
768
  };
768
769
 
769
- /*! @azure/msal-common v14.15.0 2024-10-08 */
770
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
770
771
 
771
772
  /*
772
773
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -957,12 +958,12 @@ class Logger {
957
958
  }
958
959
  }
959
960
 
960
- /*! @azure/msal-common v14.15.0 2024-10-08 */
961
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
961
962
  /* eslint-disable header/header */
962
963
  const name$1 = "@azure/msal-common";
963
- const version$1 = "14.15.0";
964
+ const version$1 = "14.16.0";
964
965
 
965
- /*! @azure/msal-common v14.15.0 2024-10-08 */
966
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
966
967
  /*
967
968
  * Copyright (c) Microsoft Corporation. All rights reserved.
968
969
  * Licensed under the MIT License.
@@ -982,7 +983,7 @@ const AzureCloudInstance = {
982
983
  AzureUsGovernment: "https://login.microsoftonline.us",
983
984
  };
984
985
 
985
- /*! @azure/msal-common v14.15.0 2024-10-08 */
986
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
986
987
 
987
988
  /*
988
989
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1043,7 +1044,7 @@ function checkMaxAge(authTime, maxAge) {
1043
1044
  }
1044
1045
  }
1045
1046
 
1046
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1047
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1047
1048
  /*
1048
1049
  * Copyright (c) Microsoft Corporation. All rights reserved.
1049
1050
  * Licensed under the MIT License.
@@ -1080,7 +1081,7 @@ function wasClockTurnedBack(cachedAt) {
1080
1081
  return cachedAtSec > nowSeconds();
1081
1082
  }
1082
1083
 
1083
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1084
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1084
1085
 
1085
1086
  /*
1086
1087
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1407,7 +1408,7 @@ function isAuthorityMetadataExpired(metadata) {
1407
1408
  return metadata.expiresAt <= nowSeconds();
1408
1409
  }
1409
1410
 
1410
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1411
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1411
1412
  /*
1412
1413
  * Copyright (c) Microsoft Corporation. All rights reserved.
1413
1414
  * Licensed under the MIT License.
@@ -1461,7 +1462,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1461
1462
  urlParseError: urlParseError
1462
1463
  });
1463
1464
 
1464
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1465
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1465
1466
 
1466
1467
  /*
1467
1468
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1599,7 +1600,7 @@ function createClientConfigurationError(errorCode) {
1599
1600
  return new ClientConfigurationError(errorCode);
1600
1601
  }
1601
1602
 
1602
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1603
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1603
1604
  /*
1604
1605
  * Copyright (c) Microsoft Corporation. All rights reserved.
1605
1606
  * Licensed under the MIT License.
@@ -1696,7 +1697,7 @@ class StringUtils {
1696
1697
  }
1697
1698
  }
1698
1699
 
1699
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1700
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1700
1701
 
1701
1702
  /*
1702
1703
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1896,7 +1897,7 @@ class ScopeSet {
1896
1897
  }
1897
1898
  }
1898
1899
 
1899
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1900
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1900
1901
 
1901
1902
  /*
1902
1903
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1936,7 +1937,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
1936
1937
  };
1937
1938
  }
1938
1939
 
1939
- /*! @azure/msal-common v14.15.0 2024-10-08 */
1940
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
1940
1941
  /*
1941
1942
  * Copyright (c) Microsoft Corporation. All rights reserved.
1942
1943
  * Licensed under the MIT License.
@@ -2015,7 +2016,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
2015
2016
  return updatedAccountInfo;
2016
2017
  }
2017
2018
 
2018
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2019
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2019
2020
  /*
2020
2021
  * Copyright (c) Microsoft Corporation. All rights reserved.
2021
2022
  * Licensed under the MIT License.
@@ -2030,7 +2031,7 @@ const AuthorityType = {
2030
2031
  Ciam: 3,
2031
2032
  };
2032
2033
 
2033
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2034
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2034
2035
  /*
2035
2036
  * Copyright (c) Microsoft Corporation. All rights reserved.
2036
2037
  * Licensed under the MIT License.
@@ -2052,7 +2053,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2052
2053
  return null;
2053
2054
  }
2054
2055
 
2055
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2056
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2056
2057
  /*
2057
2058
  * Copyright (c) Microsoft Corporation. All rights reserved.
2058
2059
  * Licensed under the MIT License.
@@ -2065,7 +2066,7 @@ const ProtocolMode = {
2065
2066
  OIDC: "OIDC",
2066
2067
  };
2067
2068
 
2068
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2069
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2069
2070
 
2070
2071
  /*
2071
2072
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2308,7 +2309,7 @@ class AccountEntity {
2308
2309
  }
2309
2310
  }
2310
2311
 
2311
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2312
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2312
2313
 
2313
2314
  /*
2314
2315
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2355,7 +2356,7 @@ function getDeserializedResponse(responseString) {
2355
2356
  return null;
2356
2357
  }
2357
2358
 
2358
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2359
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2359
2360
 
2360
2361
  /*
2361
2362
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2519,7 +2520,7 @@ class UrlString {
2519
2520
  }
2520
2521
  }
2521
2522
 
2522
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2523
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2523
2524
 
2524
2525
  /*
2525
2526
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2659,7 +2660,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2659
2660
  return null;
2660
2661
  }
2661
2662
 
2662
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2663
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2663
2664
  /*
2664
2665
  * Copyright (c) Microsoft Corporation. All rights reserved.
2665
2666
  * Licensed under the MIT License.
@@ -2667,7 +2668,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2667
2668
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2668
2669
  const cacheUnknownErrorCode = "cache_error_unknown";
2669
2670
 
2670
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2671
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2671
2672
 
2672
2673
  /*
2673
2674
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2694,7 +2695,7 @@ class CacheError extends Error {
2694
2695
  }
2695
2696
  }
2696
2697
 
2697
- /*! @azure/msal-common v14.15.0 2024-10-08 */
2698
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
2698
2699
 
2699
2700
  /*
2700
2701
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3935,9 +3936,6 @@ class DefaultStorageClass extends CacheManager {
3935
3936
  getTokenKeys() {
3936
3937
  throw createClientAuthError(methodNotImplemented);
3937
3938
  }
3938
- async clear() {
3939
- throw createClientAuthError(methodNotImplemented);
3940
- }
3941
3939
  updateCredentialCacheKey() {
3942
3940
  throw createClientAuthError(methodNotImplemented);
3943
3941
  }
@@ -3946,7 +3944,7 @@ class DefaultStorageClass extends CacheManager {
3946
3944
  }
3947
3945
  }
3948
3946
 
3949
- /*! @azure/msal-common v14.15.0 2024-10-08 */
3947
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
3950
3948
 
3951
3949
  /*
3952
3950
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4045,161 +4043,7 @@ function isOidcProtocolMode(config) {
4045
4043
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4046
4044
  }
4047
4045
 
4048
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4049
-
4050
- /*
4051
- * Copyright (c) Microsoft Corporation. All rights reserved.
4052
- * Licensed under the MIT License.
4053
- */
4054
- /**
4055
- * Error thrown when there is an error with the server code, for example, unavailability.
4056
- */
4057
- class ServerError extends AuthError {
4058
- constructor(errorCode, errorMessage, subError, errorNo, status) {
4059
- super(errorCode, errorMessage, subError);
4060
- this.name = "ServerError";
4061
- this.errorNo = errorNo;
4062
- this.status = status;
4063
- Object.setPrototypeOf(this, ServerError.prototype);
4064
- }
4065
- }
4066
-
4067
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4068
-
4069
- /*
4070
- * Copyright (c) Microsoft Corporation. All rights reserved.
4071
- * Licensed under the MIT License.
4072
- */
4073
- /** @internal */
4074
- class ThrottlingUtils {
4075
- /**
4076
- * Prepares a RequestThumbprint to be stored as a key.
4077
- * @param thumbprint
4078
- */
4079
- static generateThrottlingStorageKey(thumbprint) {
4080
- return `${ThrottlingConstants.THROTTLING_PREFIX}.${JSON.stringify(thumbprint)}`;
4081
- }
4082
- /**
4083
- * Performs necessary throttling checks before a network request.
4084
- * @param cacheManager
4085
- * @param thumbprint
4086
- */
4087
- static preProcess(cacheManager, thumbprint) {
4088
- const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
4089
- const value = cacheManager.getThrottlingCache(key);
4090
- if (value) {
4091
- if (value.throttleTime < Date.now()) {
4092
- cacheManager.removeItem(key);
4093
- return;
4094
- }
4095
- throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
4096
- }
4097
- }
4098
- /**
4099
- * Performs necessary throttling checks after a network request.
4100
- * @param cacheManager
4101
- * @param thumbprint
4102
- * @param response
4103
- */
4104
- static postProcess(cacheManager, thumbprint, response) {
4105
- if (ThrottlingUtils.checkResponseStatus(response) ||
4106
- ThrottlingUtils.checkResponseForRetryAfter(response)) {
4107
- const thumbprintValue = {
4108
- throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
4109
- error: response.body.error,
4110
- errorCodes: response.body.error_codes,
4111
- errorMessage: response.body.error_description,
4112
- subError: response.body.suberror,
4113
- };
4114
- cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
4115
- }
4116
- }
4117
- /**
4118
- * Checks a NetworkResponse object's status codes against 429 or 5xx
4119
- * @param response
4120
- */
4121
- static checkResponseStatus(response) {
4122
- return (response.status === 429 ||
4123
- (response.status >= 500 && response.status < 600));
4124
- }
4125
- /**
4126
- * Checks a NetworkResponse object's RetryAfter header
4127
- * @param response
4128
- */
4129
- static checkResponseForRetryAfter(response) {
4130
- if (response.headers) {
4131
- return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
4132
- (response.status < 200 || response.status >= 300));
4133
- }
4134
- return false;
4135
- }
4136
- /**
4137
- * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
4138
- * @param throttleTime
4139
- */
4140
- static calculateThrottleTime(throttleTime) {
4141
- const time = throttleTime <= 0 ? 0 : throttleTime;
4142
- const currentSeconds = Date.now() / 1000;
4143
- return Math.floor(Math.min(currentSeconds +
4144
- (time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds +
4145
- ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
4146
- }
4147
- static removeThrottle(cacheManager, clientId, request, homeAccountIdentifier) {
4148
- const thumbprint = {
4149
- clientId: clientId,
4150
- authority: request.authority,
4151
- scopes: request.scopes,
4152
- homeAccountIdentifier: homeAccountIdentifier,
4153
- claims: request.claims,
4154
- authenticationScheme: request.authenticationScheme,
4155
- resourceRequestMethod: request.resourceRequestMethod,
4156
- resourceRequestUri: request.resourceRequestUri,
4157
- shrClaims: request.shrClaims,
4158
- sshKid: request.sshKid,
4159
- };
4160
- const key = this.generateThrottlingStorageKey(thumbprint);
4161
- cacheManager.removeItem(key);
4162
- }
4163
- }
4164
-
4165
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4166
-
4167
- /*
4168
- * Copyright (c) Microsoft Corporation. All rights reserved.
4169
- * Licensed under the MIT License.
4170
- */
4171
- /** @internal */
4172
- class NetworkManager {
4173
- constructor(networkClient, cacheManager) {
4174
- this.networkClient = networkClient;
4175
- this.cacheManager = cacheManager;
4176
- }
4177
- /**
4178
- * Wraps sendPostRequestAsync with necessary preflight and postflight logic
4179
- * @param thumbprint
4180
- * @param tokenEndpoint
4181
- * @param options
4182
- */
4183
- async sendPostRequest(thumbprint, tokenEndpoint, options) {
4184
- ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
4185
- let response;
4186
- try {
4187
- response = await this.networkClient.sendPostRequestAsync(tokenEndpoint, options);
4188
- }
4189
- catch (e) {
4190
- if (e instanceof AuthError) {
4191
- throw e;
4192
- }
4193
- else {
4194
- throw createClientAuthError(networkError);
4195
- }
4196
- }
4197
- ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
4198
- return response;
4199
- }
4200
- }
4201
-
4202
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4046
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4203
4047
  /*
4204
4048
  * Copyright (c) Microsoft Corporation. All rights reserved.
4205
4049
  * Licensed under the MIT License.
@@ -4209,7 +4053,7 @@ const CcsCredentialType = {
4209
4053
  UPN: "UPN",
4210
4054
  };
4211
4055
 
4212
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4056
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4213
4057
  /*
4214
4058
  * Copyright (c) Microsoft Corporation. All rights reserved.
4215
4059
  * Licensed under the MIT License.
@@ -4255,9 +4099,11 @@ const LOGOUT_HINT = "logout_hint";
4255
4099
  const SID = "sid";
4256
4100
  const LOGIN_HINT = "login_hint";
4257
4101
  const DOMAIN_HINT = "domain_hint";
4258
- const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
4102
+ const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
4103
+ const BROKER_CLIENT_ID = "brk_client_id";
4104
+ const BROKER_REDIRECT_URI = "brk_redirect_uri";
4259
4105
 
4260
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4106
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4261
4107
 
4262
4108
  /*
4263
4109
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4324,16 +4170,30 @@ class RequestValidator {
4324
4170
  }
4325
4171
  }
4326
4172
 
4327
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4173
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4328
4174
 
4329
4175
  /*
4330
4176
  * Copyright (c) Microsoft Corporation. All rights reserved.
4331
4177
  * Licensed under the MIT License.
4332
4178
  */
4179
+ function instrumentBrokerParams(parameters, correlationId, performanceClient) {
4180
+ if (!correlationId) {
4181
+ return;
4182
+ }
4183
+ const clientId = parameters.get(CLIENT_ID);
4184
+ if (clientId && parameters.has(BROKER_CLIENT_ID)) {
4185
+ performanceClient?.addFields({
4186
+ embeddedClientId: clientId,
4187
+ embeddedRedirectUri: parameters.get(REDIRECT_URI),
4188
+ }, correlationId);
4189
+ }
4190
+ }
4333
4191
  /** @internal */
4334
4192
  class RequestParameterBuilder {
4335
- constructor() {
4193
+ constructor(correlationId, performanceClient) {
4336
4194
  this.parameters = new Map();
4195
+ this.performanceClient = performanceClient;
4196
+ this.correlationId = correlationId;
4337
4197
  }
4338
4198
  /**
4339
4199
  * add response_type = code
@@ -4697,6 +4557,14 @@ class RequestParameterBuilder {
4697
4557
  addLogoutHint(logoutHint) {
4698
4558
  this.parameters.set(LOGOUT_HINT, encodeURIComponent(logoutHint));
4699
4559
  }
4560
+ addBrokerParameters(params) {
4561
+ const brokerParams = {};
4562
+ brokerParams[BROKER_CLIENT_ID] =
4563
+ params.brokerClientId;
4564
+ brokerParams[BROKER_REDIRECT_URI] =
4565
+ params.brokerRedirectUri;
4566
+ this.addExtraQueryParameters(brokerParams);
4567
+ }
4700
4568
  /**
4701
4569
  * Utility to create a URL from the params map
4702
4570
  */
@@ -4705,11 +4573,12 @@ class RequestParameterBuilder {
4705
4573
  this.parameters.forEach((value, key) => {
4706
4574
  queryParameterArray.push(`${key}=${value}`);
4707
4575
  });
4576
+ instrumentBrokerParams(this.parameters, this.correlationId, this.performanceClient);
4708
4577
  return queryParameterArray.join("&");
4709
4578
  }
4710
4579
  }
4711
4580
 
4712
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4581
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4713
4582
  /*
4714
4583
  * Copyright (c) Microsoft Corporation. All rights reserved.
4715
4584
  * Licensed under the MIT License.
@@ -4721,7 +4590,7 @@ function isOpenIdConfigResponse(response) {
4721
4590
  response.hasOwnProperty("jwks_uri"));
4722
4591
  }
4723
4592
 
4724
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4593
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4725
4594
  /*
4726
4595
  * Copyright (c) Microsoft Corporation. All rights reserved.
4727
4596
  * Licensed under the MIT License.
@@ -4731,7 +4600,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4731
4600
  response.hasOwnProperty("metadata"));
4732
4601
  }
4733
4602
 
4734
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4603
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4735
4604
  /*
4736
4605
  * Copyright (c) Microsoft Corporation. All rights reserved.
4737
4606
  * Licensed under the MIT License.
@@ -4741,7 +4610,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4741
4610
  response.hasOwnProperty("error_description"));
4742
4611
  }
4743
4612
 
4744
- /*! @azure/msal-common v14.15.0 2024-10-08 */
4613
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
4745
4614
  /*
4746
4615
  * Copyright (c) Microsoft Corporation. All rights reserved.
4747
4616
  * Licensed under the MIT License.
@@ -4843,6 +4712,7 @@ const PerformanceEvents = {
4843
4712
  /**
4844
4713
  * Time spent sending/waiting for the response of a request to the token endpoint
4845
4714
  */
4715
+ NetworkClientSendPostRequestAsync: "networkClientSendPostRequestAsync",
4846
4716
  RefreshTokenClientExecutePostToTokenEndpoint: "refreshTokenClientExecutePostToTokenEndpoint",
4847
4717
  AuthorizationCodeClientExecutePostToTokenEndpoint: "authorizationCodeClientExecutePostToTokenEndpoint",
4848
4718
  /**
@@ -5016,6 +4886,10 @@ const PerformanceEventAbbreviations = new Map([
5016
4886
  PerformanceEvents.BaseClientCreateTokenRequestHeaders,
5017
4887
  "BaseClientCreateTReqHead",
5018
4888
  ],
4889
+ [
4890
+ PerformanceEvents.NetworkClientSendPostRequestAsync,
4891
+ "NetClientSendPost",
4892
+ ],
5019
4893
  [
5020
4894
  PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint,
5021
4895
  "RTClientExecPost",
@@ -5223,7 +5097,7 @@ const IntFields = new Set([
5223
5097
  "multiMatchedRT",
5224
5098
  ]);
5225
5099
 
5226
- /*! @azure/msal-common v14.15.0 2024-10-08 */
5100
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
5227
5101
  /*
5228
5102
  * Copyright (c) Microsoft Corporation. All rights reserved.
5229
5103
  * Licensed under the MIT License.
@@ -5319,7 +5193,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
5319
5193
  };
5320
5194
  };
5321
5195
 
5322
- /*! @azure/msal-common v14.15.0 2024-10-08 */
5196
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
5323
5197
 
5324
5198
  /*
5325
5199
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5428,7 +5302,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5428
5302
  },
5429
5303
  };
5430
5304
 
5431
- /*! @azure/msal-common v14.15.0 2024-10-08 */
5305
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
5432
5306
 
5433
5307
  /*
5434
5308
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6267,38 +6141,185 @@ function buildStaticAuthorityOptions(authOptions) {
6267
6141
  };
6268
6142
  }
6269
6143
 
6270
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6144
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6145
+
6146
+ /*
6147
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6148
+ * Licensed under the MIT License.
6149
+ */
6150
+ /**
6151
+ * Create an authority object of the correct type based on the url
6152
+ * Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)
6153
+ *
6154
+ * Also performs endpoint discovery.
6155
+ *
6156
+ * @param authorityUri
6157
+ * @param networkClient
6158
+ * @param protocolMode
6159
+ * @internal
6160
+ */
6161
+ async function createDiscoveredInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, correlationId, performanceClient) {
6162
+ performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
6163
+ const authorityUriFinal = Authority.transformCIAMAuthority(formatAuthorityUri(authorityUri));
6164
+ // Initialize authority and perform discovery endpoint check.
6165
+ const acquireTokenAuthority = new Authority(authorityUriFinal, networkClient, cacheManager, authorityOptions, logger, correlationId, performanceClient);
6166
+ try {
6167
+ await invokeAsync(acquireTokenAuthority.resolveEndpointsAsync.bind(acquireTokenAuthority), PerformanceEvents.AuthorityResolveEndpointsAsync, logger, performanceClient, correlationId)();
6168
+ return acquireTokenAuthority;
6169
+ }
6170
+ catch (e) {
6171
+ throw createClientAuthError(endpointResolutionError);
6172
+ }
6173
+ }
6174
+
6175
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6176
+
6177
+ /*
6178
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6179
+ * Licensed under the MIT License.
6180
+ */
6181
+ /**
6182
+ * Error thrown when there is an error with the server code, for example, unavailability.
6183
+ */
6184
+ class ServerError extends AuthError {
6185
+ constructor(errorCode, errorMessage, subError, errorNo, status) {
6186
+ super(errorCode, errorMessage, subError);
6187
+ this.name = "ServerError";
6188
+ this.errorNo = errorNo;
6189
+ this.status = status;
6190
+ Object.setPrototypeOf(this, ServerError.prototype);
6191
+ }
6192
+ }
6193
+
6194
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6195
+
6196
+ /*
6197
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6198
+ * Licensed under the MIT License.
6199
+ */
6200
+ /** @internal */
6201
+ class ThrottlingUtils {
6202
+ /**
6203
+ * Prepares a RequestThumbprint to be stored as a key.
6204
+ * @param thumbprint
6205
+ */
6206
+ static generateThrottlingStorageKey(thumbprint) {
6207
+ return `${ThrottlingConstants.THROTTLING_PREFIX}.${JSON.stringify(thumbprint)}`;
6208
+ }
6209
+ /**
6210
+ * Performs necessary throttling checks before a network request.
6211
+ * @param cacheManager
6212
+ * @param thumbprint
6213
+ */
6214
+ static preProcess(cacheManager, thumbprint) {
6215
+ const key = ThrottlingUtils.generateThrottlingStorageKey(thumbprint);
6216
+ const value = cacheManager.getThrottlingCache(key);
6217
+ if (value) {
6218
+ if (value.throttleTime < Date.now()) {
6219
+ cacheManager.removeItem(key);
6220
+ return;
6221
+ }
6222
+ throw new ServerError(value.errorCodes?.join(" ") || Constants.EMPTY_STRING, value.errorMessage, value.subError);
6223
+ }
6224
+ }
6225
+ /**
6226
+ * Performs necessary throttling checks after a network request.
6227
+ * @param cacheManager
6228
+ * @param thumbprint
6229
+ * @param response
6230
+ */
6231
+ static postProcess(cacheManager, thumbprint, response) {
6232
+ if (ThrottlingUtils.checkResponseStatus(response) ||
6233
+ ThrottlingUtils.checkResponseForRetryAfter(response)) {
6234
+ const thumbprintValue = {
6235
+ throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
6236
+ error: response.body.error,
6237
+ errorCodes: response.body.error_codes,
6238
+ errorMessage: response.body.error_description,
6239
+ subError: response.body.suberror,
6240
+ };
6241
+ cacheManager.setThrottlingCache(ThrottlingUtils.generateThrottlingStorageKey(thumbprint), thumbprintValue);
6242
+ }
6243
+ }
6244
+ /**
6245
+ * Checks a NetworkResponse object's status codes against 429 or 5xx
6246
+ * @param response
6247
+ */
6248
+ static checkResponseStatus(response) {
6249
+ return (response.status === 429 ||
6250
+ (response.status >= 500 && response.status < 600));
6251
+ }
6252
+ /**
6253
+ * Checks a NetworkResponse object's RetryAfter header
6254
+ * @param response
6255
+ */
6256
+ static checkResponseForRetryAfter(response) {
6257
+ if (response.headers) {
6258
+ return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
6259
+ (response.status < 200 || response.status >= 300));
6260
+ }
6261
+ return false;
6262
+ }
6263
+ /**
6264
+ * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
6265
+ * @param throttleTime
6266
+ */
6267
+ static calculateThrottleTime(throttleTime) {
6268
+ const time = throttleTime <= 0 ? 0 : throttleTime;
6269
+ const currentSeconds = Date.now() / 1000;
6270
+ return Math.floor(Math.min(currentSeconds +
6271
+ (time || ThrottlingConstants.DEFAULT_THROTTLE_TIME_SECONDS), currentSeconds +
6272
+ ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
6273
+ }
6274
+ static removeThrottle(cacheManager, clientId, request, homeAccountIdentifier) {
6275
+ const thumbprint = {
6276
+ clientId: clientId,
6277
+ authority: request.authority,
6278
+ scopes: request.scopes,
6279
+ homeAccountIdentifier: homeAccountIdentifier,
6280
+ claims: request.claims,
6281
+ authenticationScheme: request.authenticationScheme,
6282
+ resourceRequestMethod: request.resourceRequestMethod,
6283
+ resourceRequestUri: request.resourceRequestUri,
6284
+ shrClaims: request.shrClaims,
6285
+ sshKid: request.sshKid,
6286
+ };
6287
+ const key = this.generateThrottlingStorageKey(thumbprint);
6288
+ cacheManager.removeItem(key);
6289
+ }
6290
+ }
6291
+
6292
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6271
6293
 
6272
6294
  /*
6273
6295
  * Copyright (c) Microsoft Corporation. All rights reserved.
6274
6296
  * Licensed under the MIT License.
6275
6297
  */
6276
6298
  /**
6277
- * Create an authority object of the correct type based on the url
6278
- * Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)
6279
- *
6280
- * Also performs endpoint discovery.
6281
- *
6282
- * @param authorityUri
6283
- * @param networkClient
6284
- * @param protocolMode
6285
- * @internal
6299
+ * Represents network related errors
6286
6300
  */
6287
- async function createDiscoveredInstance(authorityUri, networkClient, cacheManager, authorityOptions, logger, correlationId, performanceClient) {
6288
- performanceClient?.addQueueMeasurement(PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance, correlationId);
6289
- const authorityUriFinal = Authority.transformCIAMAuthority(formatAuthorityUri(authorityUri));
6290
- // Initialize authority and perform discovery endpoint check.
6291
- const acquireTokenAuthority = new Authority(authorityUriFinal, networkClient, cacheManager, authorityOptions, logger, correlationId, performanceClient);
6292
- try {
6293
- await invokeAsync(acquireTokenAuthority.resolveEndpointsAsync.bind(acquireTokenAuthority), PerformanceEvents.AuthorityResolveEndpointsAsync, logger, performanceClient, correlationId)();
6294
- return acquireTokenAuthority;
6295
- }
6296
- catch (e) {
6297
- throw createClientAuthError(endpointResolutionError);
6301
+ class NetworkError extends AuthError {
6302
+ constructor(error, httpStatus, responseHeaders) {
6303
+ super(error.errorCode, error.errorMessage, error.subError);
6304
+ Object.setPrototypeOf(this, NetworkError.prototype);
6305
+ this.name = "NetworkError";
6306
+ this.error = error;
6307
+ this.httpStatus = httpStatus;
6308
+ this.responseHeaders = responseHeaders;
6298
6309
  }
6310
+ }
6311
+ /**
6312
+ * Creates NetworkError object for a failed network request
6313
+ * @param error - Error to be thrown back to the caller
6314
+ * @param httpStatus - Status code of the network request
6315
+ * @param responseHeaders - Response headers of the network request, when available
6316
+ * @returns NetworkError object
6317
+ */
6318
+ function createNetworkError(error, httpStatus, responseHeaders) {
6319
+ return new NetworkError(error, httpStatus, responseHeaders);
6299
6320
  }
6300
6321
 
6301
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6322
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6302
6323
 
6303
6324
  /*
6304
6325
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6320,8 +6341,6 @@ class BaseClient {
6320
6341
  this.cacheManager = this.config.storageInterface;
6321
6342
  // Set the network interface
6322
6343
  this.networkClient = this.config.networkInterface;
6323
- // Set the NetworkManager
6324
- this.networkManager = new NetworkManager(this.networkClient, this.cacheManager);
6325
6344
  // Set TelemetryManager
6326
6345
  this.serverTelemetryManager = this.config.serverTelemetryManager;
6327
6346
  // set Authority
@@ -6365,11 +6384,7 @@ class BaseClient {
6365
6384
  if (queuedEvent) {
6366
6385
  this.performanceClient?.addQueueMeasurement(queuedEvent, correlationId);
6367
6386
  }
6368
- const response = await this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers });
6369
- this.performanceClient?.addFields({
6370
- refreshTokenSize: response.body.refresh_token?.length || 0,
6371
- httpVerToken: response.headers?.[HeaderNames.X_MS_HTTP_VERSION] || "",
6372
- }, correlationId);
6387
+ const response = await this.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers }, correlationId);
6373
6388
  if (this.config.serverTelemetryManager &&
6374
6389
  response.status < 500 &&
6375
6390
  response.status !== 429) {
@@ -6378,6 +6393,52 @@ class BaseClient {
6378
6393
  }
6379
6394
  return response;
6380
6395
  }
6396
+ /**
6397
+ * Wraps sendPostRequestAsync with necessary preflight and postflight logic
6398
+ * @param thumbprint - Request thumbprint for throttling
6399
+ * @param tokenEndpoint - Endpoint to make the POST to
6400
+ * @param options - Body and Headers to include on the POST request
6401
+ * @param correlationId - CorrelationId for telemetry
6402
+ */
6403
+ async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
6404
+ ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
6405
+ let response;
6406
+ try {
6407
+ response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), PerformanceEvents.NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
6408
+ const responseHeaders = response.headers || {};
6409
+ this.performanceClient?.addFields({
6410
+ refreshTokenSize: response.body.refresh_token?.length || 0,
6411
+ httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
6412
+ requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
6413
+ }, correlationId);
6414
+ }
6415
+ catch (e) {
6416
+ if (e instanceof NetworkError) {
6417
+ const responseHeaders = e.responseHeaders;
6418
+ if (responseHeaders) {
6419
+ this.performanceClient?.addFields({
6420
+ httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
6421
+ requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] ||
6422
+ "",
6423
+ contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
6424
+ undefined,
6425
+ contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
6426
+ undefined,
6427
+ httpStatus: e.httpStatus,
6428
+ }, correlationId);
6429
+ }
6430
+ throw e.error;
6431
+ }
6432
+ if (e instanceof AuthError) {
6433
+ throw e;
6434
+ }
6435
+ else {
6436
+ throw createClientAuthError(networkError);
6437
+ }
6438
+ }
6439
+ ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
6440
+ return response;
6441
+ }
6381
6442
  /**
6382
6443
  * Updates the authority object of the client. Endpoint discovery must be completed.
6383
6444
  * @param updatedAuthority
@@ -6393,15 +6454,22 @@ class BaseClient {
6393
6454
  * @param request
6394
6455
  */
6395
6456
  createTokenQueryParameters(request) {
6396
- const parameterBuilder = new RequestParameterBuilder();
6457
+ const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
6458
+ if (request.embeddedClientId) {
6459
+ parameterBuilder.addBrokerParameters({
6460
+ brokerClientId: this.config.authOptions.clientId,
6461
+ brokerRedirectUri: this.config.authOptions.redirectUri,
6462
+ });
6463
+ }
6397
6464
  if (request.tokenQueryParameters) {
6398
6465
  parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
6399
6466
  }
6467
+ parameterBuilder.addCorrelationId(request.correlationId);
6400
6468
  return parameterBuilder.createQueryString();
6401
6469
  }
6402
6470
  }
6403
6471
 
6404
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6472
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6405
6473
  /*
6406
6474
  * Copyright (c) Microsoft Corporation. All rights reserved.
6407
6475
  * Licensed under the MIT License.
@@ -6427,7 +6495,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6427
6495
  refreshTokenExpired: refreshTokenExpired
6428
6496
  });
6429
6497
 
6430
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6498
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6431
6499
 
6432
6500
  /*
6433
6501
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6515,7 +6583,7 @@ function createInteractionRequiredAuthError(errorCode) {
6515
6583
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6516
6584
  }
6517
6585
 
6518
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6586
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6519
6587
 
6520
6588
  /*
6521
6589
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6587,7 +6655,7 @@ class ProtocolUtils {
6587
6655
  }
6588
6656
  }
6589
6657
 
6590
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6658
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6591
6659
 
6592
6660
  /*
6593
6661
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6671,7 +6739,7 @@ class PopTokenGenerator {
6671
6739
  }
6672
6740
  }
6673
6741
 
6674
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6742
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6675
6743
  /*
6676
6744
  * Copyright (c) Microsoft Corporation. All rights reserved.
6677
6745
  * Licensed under the MIT License.
@@ -6698,7 +6766,7 @@ class PopTokenGenerator {
6698
6766
  }
6699
6767
  }
6700
6768
 
6701
- /*! @azure/msal-common v14.15.0 2024-10-08 */
6769
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
6702
6770
 
6703
6771
  /*
6704
6772
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7075,7 +7143,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
7075
7143
  return baseAccount;
7076
7144
  }
7077
7145
 
7078
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7146
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7079
7147
  /*
7080
7148
  * Copyright (c) Microsoft Corporation. All rights reserved.
7081
7149
  * Licensed under the MIT License.
@@ -7093,7 +7161,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
7093
7161
  }
7094
7162
  }
7095
7163
 
7096
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7164
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7097
7165
 
7098
7166
  /*
7099
7167
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7219,8 +7287,9 @@ class AuthorizationCodeClient extends BaseClient {
7219
7287
  */
7220
7288
  async createTokenRequestBody(request) {
7221
7289
  this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
7222
- const parameterBuilder = new RequestParameterBuilder();
7223
- parameterBuilder.addClientId(request.tokenBodyParameters?.[CLIENT_ID] ||
7290
+ const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
7291
+ parameterBuilder.addClientId(request.embeddedClientId ||
7292
+ request.tokenBodyParameters?.[CLIENT_ID] ||
7224
7293
  this.config.authOptions.clientId);
7225
7294
  /*
7226
7295
  * For hybrid spa flow, there will be a code but no verifier
@@ -7280,9 +7349,6 @@ class AuthorizationCodeClient extends BaseClient {
7280
7349
  throw createClientConfigurationError(missingSshJwk);
7281
7350
  }
7282
7351
  }
7283
- const correlationId = request.correlationId ||
7284
- this.config.cryptoInterface.createNewGuid();
7285
- parameterBuilder.addCorrelationId(correlationId);
7286
7352
  if (!StringUtils.isEmptyObj(request.claims) ||
7287
7353
  (this.config.authOptions.clientCapabilities &&
7288
7354
  this.config.authOptions.clientCapabilities.length > 0)) {
@@ -7322,6 +7388,12 @@ class AuthorizationCodeClient extends BaseClient {
7322
7388
  break;
7323
7389
  }
7324
7390
  }
7391
+ if (request.embeddedClientId) {
7392
+ parameterBuilder.addBrokerParameters({
7393
+ brokerClientId: this.config.authOptions.clientId,
7394
+ brokerRedirectUri: this.config.authOptions.redirectUri,
7395
+ });
7396
+ }
7325
7397
  if (request.tokenBodyParameters) {
7326
7398
  parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
7327
7399
  }
@@ -7340,9 +7412,13 @@ class AuthorizationCodeClient extends BaseClient {
7340
7412
  * @param request
7341
7413
  */
7342
7414
  async createAuthCodeUrlQueryString(request) {
7343
- this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, request.correlationId);
7344
- const parameterBuilder = new RequestParameterBuilder();
7345
- parameterBuilder.addClientId(request.extraQueryParameters?.[CLIENT_ID] ||
7415
+ // generate the correlationId if not set by the user and add
7416
+ const correlationId = request.correlationId ||
7417
+ this.config.cryptoInterface.createNewGuid();
7418
+ this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, correlationId);
7419
+ const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
7420
+ parameterBuilder.addClientId(request.embeddedClientId ||
7421
+ request.extraQueryParameters?.[CLIENT_ID] ||
7346
7422
  this.config.authOptions.clientId);
7347
7423
  const requestScopes = [
7348
7424
  ...(request.scopes || []),
@@ -7351,9 +7427,6 @@ class AuthorizationCodeClient extends BaseClient {
7351
7427
  parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
7352
7428
  // validate the redirectUri (to be a non null value)
7353
7429
  parameterBuilder.addRedirectUri(request.redirectUri);
7354
- // generate the correlationId if not set by the user and add
7355
- const correlationId = request.correlationId ||
7356
- this.config.cryptoInterface.createNewGuid();
7357
7430
  parameterBuilder.addCorrelationId(correlationId);
7358
7431
  // add response_mode. If not passed in it defaults to query.
7359
7432
  parameterBuilder.addResponseMode(request.responseMode);
@@ -7455,6 +7528,12 @@ class AuthorizationCodeClient extends BaseClient {
7455
7528
  this.config.authOptions.clientCapabilities.length > 0)) {
7456
7529
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
7457
7530
  }
7531
+ if (request.embeddedClientId) {
7532
+ parameterBuilder.addBrokerParameters({
7533
+ brokerClientId: this.config.authOptions.clientId,
7534
+ brokerRedirectUri: this.config.authOptions.redirectUri,
7535
+ });
7536
+ }
7458
7537
  this.addExtraQueryParams(request, parameterBuilder);
7459
7538
  if (request.nativeBroker) {
7460
7539
  // signal ests that this is a WAM call
@@ -7481,7 +7560,7 @@ class AuthorizationCodeClient extends BaseClient {
7481
7560
  * @param request
7482
7561
  */
7483
7562
  createLogoutUrlQueryString(request) {
7484
- const parameterBuilder = new RequestParameterBuilder();
7563
+ const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
7485
7564
  if (request.postLogoutRedirectUri) {
7486
7565
  parameterBuilder.addPostLogoutRedirectUri(request.postLogoutRedirectUri);
7487
7566
  }
@@ -7524,7 +7603,7 @@ class AuthorizationCodeClient extends BaseClient {
7524
7603
  }
7525
7604
  }
7526
7605
 
7527
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7606
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7528
7607
 
7529
7608
  /*
7530
7609
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7662,8 +7741,9 @@ class RefreshTokenClient extends BaseClient {
7662
7741
  async createTokenRequestBody(request) {
7663
7742
  this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
7664
7743
  const correlationId = request.correlationId;
7665
- const parameterBuilder = new RequestParameterBuilder();
7666
- parameterBuilder.addClientId(request.tokenBodyParameters?.[CLIENT_ID] ||
7744
+ const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
7745
+ parameterBuilder.addClientId(request.embeddedClientId ||
7746
+ request.tokenBodyParameters?.[CLIENT_ID] ||
7667
7747
  this.config.authOptions.clientId);
7668
7748
  if (request.redirectUri) {
7669
7749
  parameterBuilder.addRedirectUri(request.redirectUri);
@@ -7677,7 +7757,6 @@ class RefreshTokenClient extends BaseClient {
7677
7757
  if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
7678
7758
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
7679
7759
  }
7680
- parameterBuilder.addCorrelationId(correlationId);
7681
7760
  parameterBuilder.addRefreshToken(request.refreshToken);
7682
7761
  if (this.config.clientCredentials.clientSecret) {
7683
7762
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
@@ -7731,6 +7810,12 @@ class RefreshTokenClient extends BaseClient {
7731
7810
  break;
7732
7811
  }
7733
7812
  }
7813
+ if (request.embeddedClientId) {
7814
+ parameterBuilder.addBrokerParameters({
7815
+ brokerClientId: this.config.authOptions.clientId,
7816
+ brokerRedirectUri: this.config.authOptions.redirectUri,
7817
+ });
7818
+ }
7734
7819
  if (request.tokenBodyParameters) {
7735
7820
  parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
7736
7821
  }
@@ -7738,7 +7823,7 @@ class RefreshTokenClient extends BaseClient {
7738
7823
  }
7739
7824
  }
7740
7825
 
7741
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7826
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7742
7827
 
7743
7828
  /*
7744
7829
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7874,7 +7959,7 @@ class SilentFlowClient extends BaseClient {
7874
7959
  }
7875
7960
  }
7876
7961
 
7877
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7962
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7878
7963
 
7879
7964
  /*
7880
7965
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7889,7 +7974,7 @@ const StubbedNetworkModule = {
7889
7974
  },
7890
7975
  };
7891
7976
 
7892
- /*! @azure/msal-common v14.15.0 2024-10-08 */
7977
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7893
7978
 
7894
7979
  /*
7895
7980
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7947,7 +8032,7 @@ class AuthenticationHeaderParser {
7947
8032
  }
7948
8033
  }
7949
8034
 
7950
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8035
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
7951
8036
 
7952
8037
  /*
7953
8038
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8210,7 +8295,7 @@ class ServerTelemetryManager {
8210
8295
  }
8211
8296
  }
8212
8297
 
8213
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8298
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8214
8299
  /*
8215
8300
  * Copyright (c) Microsoft Corporation. All rights reserved.
8216
8301
  * Licensed under the MIT License.
@@ -8218,7 +8303,7 @@ class ServerTelemetryManager {
8218
8303
  const missingKidError = "missing_kid_error";
8219
8304
  const missingAlgError = "missing_alg_error";
8220
8305
 
8221
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8306
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8222
8307
 
8223
8308
  /*
8224
8309
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8243,7 +8328,7 @@ function createJoseHeaderError(code) {
8243
8328
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
8244
8329
  }
8245
8330
 
8246
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8331
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8247
8332
 
8248
8333
  /*
8249
8334
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8283,7 +8368,7 @@ class JoseHeader {
8283
8368
  }
8284
8369
  }
8285
8370
 
8286
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8371
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8287
8372
 
8288
8373
  /*
8289
8374
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8362,7 +8447,7 @@ class StubPerformanceClient {
8362
8447
  }
8363
8448
  }
8364
8449
 
8365
- /*! @azure/msal-common v14.15.0 2024-10-08 */
8450
+ /*! @azure/msal-common v14.16.0 2024-12-12 */
8366
8451
 
8367
8452
  /*
8368
8453
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8494,18 +8579,30 @@ function compactStack(stack, stackMaxSize) {
8494
8579
  return [];
8495
8580
  }
8496
8581
  const stackArr = stack.split("\n") || [];
8497
- if (stackArr.length < 2) {
8498
- return [];
8499
- }
8500
8582
  const res = [];
8583
+ // Check for a handful of known, common runtime errors and log them (with redaction where applicable).
8584
+ const firstLine = stackArr[0];
8585
+ if (firstLine.startsWith("TypeError: Cannot read property") ||
8586
+ firstLine.startsWith("TypeError: Cannot read properties of") ||
8587
+ firstLine.startsWith("TypeError: Cannot set property") ||
8588
+ firstLine.startsWith("TypeError: Cannot set properties of") ||
8589
+ firstLine.endsWith("is not a function")) {
8590
+ // These types of errors are not at risk of leaking PII. They will indicate unavailable APIs
8591
+ res.push(compactStackLine(firstLine));
8592
+ }
8593
+ else if (firstLine.startsWith("SyntaxError") ||
8594
+ firstLine.startsWith("TypeError")) {
8595
+ // Prevent unintentional leaking of arbitrary info by redacting contents between both single and double quotes
8596
+ res.push(compactStackLine(
8597
+ // Example: SyntaxError: Unexpected token 'e', "test" is not valid JSON -> SyntaxError: Unexpected token <redacted>, <redacted> is not valid JSON
8598
+ firstLine.replace(/['].*[']|["].*["]/g, "<redacted>")));
8599
+ }
8501
8600
  // Get top N stack lines
8502
- for (
8503
- // Skip first line as it may contain PII data
8504
- let ix = Math.max(stackArr.length - stackMaxSize - 1, 1); ix < stackArr.length; ix++) {
8505
- const line = stackArr[ix];
8601
+ for (let ix = 1; ix < stackArr.length; ix++) {
8506
8602
  if (res.length >= stackMaxSize) {
8507
8603
  break;
8508
8604
  }
8605
+ const line = stackArr[ix];
8509
8606
  res.push(compactStackLine(line));
8510
8607
  }
8511
8608
  return res;
@@ -8752,13 +8849,20 @@ class PerformanceClient {
8752
8849
  rootEvent.incompleteSubMeasurements?.delete(event.eventId);
8753
8850
  }
8754
8851
  this.logger.trace(`PerformanceClient: Performance measurement ended for ${event.name}: ${event.durationMs} ms`, event.correlationId);
8852
+ if (error) {
8853
+ addError(error, this.logger, rootEvent);
8854
+ }
8755
8855
  // Add sub-measurement attribute to root event.
8756
8856
  if (!isRoot) {
8757
8857
  rootEvent[event.name + "DurationMs"] = Math.floor(event.durationMs);
8758
8858
  return { ...rootEvent };
8759
8859
  }
8760
- if (error) {
8761
- addError(error, this.logger, rootEvent);
8860
+ if (isRoot &&
8861
+ !error &&
8862
+ (rootEvent.errorCode || rootEvent.subErrorCode)) {
8863
+ this.logger.trace(`PerformanceClient: Remove error and sub-error codes for root event ${event.name} as intermediate error was successfully handled`, event.correlationId);
8864
+ rootEvent.errorCode = undefined;
8865
+ rootEvent.subErrorCode = undefined;
8762
8866
  }
8763
8867
  let finalEvent = { ...rootEvent, ...event };
8764
8868
  let incompleteSubsCount = 0;
@@ -9001,7 +9105,9 @@ const nativeConnectionNotEstablished = "native_connection_not_established";
9001
9105
  const uninitializedPublicClientApplication = "uninitialized_public_client_application";
9002
9106
  const nativePromptNotSupported = "native_prompt_not_supported";
9003
9107
  const invalidBase64String = "invalid_base64_string";
9004
- const invalidPopTokenRequest = "invalid_pop_token_request";
9108
+ const invalidPopTokenRequest = "invalid_pop_token_request";
9109
+ const failedToBuildHeaders = "failed_to_build_headers";
9110
+ const failedToParseHeaders = "failed_to_parse_headers";
9005
9111
 
9006
9112
  var BrowserAuthErrorCodes = /*#__PURE__*/Object.freeze({
9007
9113
  __proto__: null,
@@ -9016,6 +9122,8 @@ var BrowserAuthErrorCodes = /*#__PURE__*/Object.freeze({
9016
9122
  databaseUnavailable: databaseUnavailable,
9017
9123
  emptyNavigateUri: emptyNavigateUri,
9018
9124
  emptyWindowError: emptyWindowError,
9125
+ failedToBuildHeaders: failedToBuildHeaders,
9126
+ failedToParseHeaders: failedToParseHeaders,
9019
9127
  failedToParseResponse: failedToParseResponse,
9020
9128
  getRequestFailed: getRequestFailed,
9021
9129
  hashDoesNotContainKnownProperties: hashDoesNotContainKnownProperties,
@@ -9108,6 +9216,8 @@ const BrowserAuthErrorMessages = {
9108
9216
  [nativePromptNotSupported]: "The provided prompt is not supported by the native platform. This request should be routed to the web based flow.",
9109
9217
  [invalidBase64String]: "Invalid base64 encoded string.",
9110
9218
  [invalidPopTokenRequest]: "Invalid PoP token request. The request should not have both a popKid value and signPopToken set to true.",
9219
+ [failedToBuildHeaders]: "Failed to build request headers object.",
9220
+ [failedToParseHeaders]: "Failed to parse response headers",
9111
9221
  };
9112
9222
  /**
9113
9223
  * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
@@ -9307,14 +9417,14 @@ const BrowserAuthErrorMessage = {
9307
9417
  * Browser library error class thrown by the MSAL.js library for SPAs
9308
9418
  */
9309
9419
  class BrowserAuthError extends AuthError {
9310
- constructor(errorCode) {
9311
- super(errorCode, BrowserAuthErrorMessages[errorCode]);
9420
+ constructor(errorCode, subError) {
9421
+ super(errorCode, BrowserAuthErrorMessages[errorCode], subError);
9312
9422
  Object.setPrototypeOf(this, BrowserAuthError.prototype);
9313
9423
  this.name = "BrowserAuthError";
9314
9424
  }
9315
9425
  }
9316
- function createBrowserAuthError(errorCode) {
9317
- return new BrowserAuthError(errorCode);
9426
+ function createBrowserAuthError(errorCode, subError) {
9427
+ return new BrowserAuthError(errorCode, subError);
9318
9428
  }
9319
9429
 
9320
9430
  /*
@@ -9597,6 +9707,7 @@ const PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
9597
9707
  const UUID_CHARS = "0123456789abcdef";
9598
9708
  // Array to store UINT32 random value
9599
9709
  const UINT32_ARR = new Uint32Array(1);
9710
+ const SUBTLE_SUBERROR = "crypto_subtle_undefined";
9600
9711
  const keygenAlgorithmOptions = {
9601
9712
  name: PKCS1_V15_KEYGEN_ALG,
9602
9713
  hash: S256_HASH_ALG,
@@ -9606,14 +9717,16 @@ const keygenAlgorithmOptions = {
9606
9717
  /**
9607
9718
  * Check whether browser crypto is available.
9608
9719
  */
9609
- function validateCryptoAvailable(logger) {
9610
- if ("crypto" in window) {
9611
- logger.verbose("BrowserCrypto: modern crypto interface available");
9720
+ function validateCryptoAvailable() {
9721
+ if (!window) {
9722
+ throw createBrowserAuthError(nonBrowserEnvironment);
9612
9723
  }
9613
- else {
9614
- logger.error("BrowserCrypto: crypto interface is unavailable");
9724
+ if (!window.crypto) {
9615
9725
  throw createBrowserAuthError(cryptoNonExistent);
9616
9726
  }
9727
+ if (!window.crypto.subtle) {
9728
+ throw createBrowserAuthError(cryptoNonExistent, SUBTLE_SUBERROR);
9729
+ }
9617
9730
  }
9618
9731
  /**
9619
9732
  * Returns a sha-256 hash of the given dataString as an ArrayBuffer.
@@ -10018,29 +10131,31 @@ class FetchClient {
10018
10131
  */
10019
10132
  async sendGetRequestAsync(url, options) {
10020
10133
  let response;
10134
+ let responseHeaders = {};
10135
+ let responseStatus = 0;
10136
+ const reqHeaders = getFetchHeaders(options);
10021
10137
  try {
10022
10138
  response = await fetch(url, {
10023
10139
  method: HTTP_REQUEST_TYPE.GET,
10024
- headers: this.getFetchHeaders(options),
10140
+ headers: reqHeaders,
10025
10141
  });
10026
10142
  }
10027
10143
  catch (e) {
10028
- if (window.navigator.onLine) {
10029
- throw createBrowserAuthError(getRequestFailed);
10030
- }
10031
- else {
10032
- throw createBrowserAuthError(noNetworkConnectivity);
10033
- }
10144
+ throw createBrowserAuthError(window.navigator.onLine
10145
+ ? getRequestFailed
10146
+ : noNetworkConnectivity);
10034
10147
  }
10148
+ responseHeaders = getHeaderDict(response.headers);
10035
10149
  try {
10150
+ responseStatus = response.status;
10036
10151
  return {
10037
- headers: this.getHeaderDict(response.headers),
10152
+ headers: responseHeaders,
10038
10153
  body: (await response.json()),
10039
- status: response.status,
10154
+ status: responseStatus,
10040
10155
  };
10041
10156
  }
10042
10157
  catch (e) {
10043
- throw createBrowserAuthError(failedToParseResponse);
10158
+ throw createNetworkError(createBrowserAuthError(failedToParseResponse), responseStatus, responseHeaders);
10044
10159
  }
10045
10160
  }
10046
10161
  /**
@@ -10050,56 +10165,73 @@ class FetchClient {
10050
10165
  * @param body
10051
10166
  */
10052
10167
  async sendPostRequestAsync(url, options) {
10053
- const reqBody = (options && options.body) || Constants.EMPTY_STRING;
10168
+ const reqBody = (options && options.body) || "";
10169
+ const reqHeaders = getFetchHeaders(options);
10054
10170
  let response;
10171
+ let responseStatus = 0;
10172
+ let responseHeaders = {};
10055
10173
  try {
10056
10174
  response = await fetch(url, {
10057
10175
  method: HTTP_REQUEST_TYPE.POST,
10058
- headers: this.getFetchHeaders(options),
10176
+ headers: reqHeaders,
10059
10177
  body: reqBody,
10060
10178
  });
10061
10179
  }
10062
10180
  catch (e) {
10063
- if (window.navigator.onLine) {
10064
- throw createBrowserAuthError(postRequestFailed);
10065
- }
10066
- else {
10067
- throw createBrowserAuthError(noNetworkConnectivity);
10068
- }
10181
+ throw createBrowserAuthError(window.navigator.onLine
10182
+ ? postRequestFailed
10183
+ : noNetworkConnectivity);
10069
10184
  }
10185
+ responseHeaders = getHeaderDict(response.headers);
10070
10186
  try {
10187
+ responseStatus = response.status;
10071
10188
  return {
10072
- headers: this.getHeaderDict(response.headers),
10189
+ headers: responseHeaders,
10073
10190
  body: (await response.json()),
10074
- status: response.status,
10191
+ status: responseStatus,
10075
10192
  };
10076
10193
  }
10077
10194
  catch (e) {
10078
- throw createBrowserAuthError(failedToParseResponse);
10195
+ throw createNetworkError(createBrowserAuthError(failedToParseResponse), responseStatus, responseHeaders);
10079
10196
  }
10080
10197
  }
10081
- /**
10082
- * Get Fetch API Headers object from string map
10083
- * @param inputHeaders
10084
- */
10085
- getFetchHeaders(options) {
10198
+ }
10199
+ /**
10200
+ * Get Fetch API Headers object from string map
10201
+ * @param inputHeaders
10202
+ */
10203
+ function getFetchHeaders(options) {
10204
+ try {
10086
10205
  const headers = new Headers();
10087
10206
  if (!(options && options.headers)) {
10088
10207
  return headers;
10089
10208
  }
10090
10209
  const optionsHeaders = options.headers;
10091
- Object.keys(optionsHeaders).forEach((key) => {
10092
- headers.append(key, optionsHeaders[key]);
10210
+ Object.entries(optionsHeaders).forEach(([key, value]) => {
10211
+ headers.append(key, value);
10093
10212
  });
10094
10213
  return headers;
10095
10214
  }
10096
- getHeaderDict(headers) {
10215
+ catch (e) {
10216
+ throw createBrowserAuthError(failedToBuildHeaders);
10217
+ }
10218
+ }
10219
+ /**
10220
+ * Returns object representing response headers
10221
+ * @param headers
10222
+ * @returns
10223
+ */
10224
+ function getHeaderDict(headers) {
10225
+ try {
10097
10226
  const headerDict = {};
10098
10227
  headers.forEach((value, key) => {
10099
10228
  headerDict[key] = value;
10100
10229
  });
10101
10230
  return headerDict;
10102
10231
  }
10232
+ catch (e) {
10233
+ throw createBrowserAuthError(failedToParseHeaders);
10234
+ }
10103
10235
  }
10104
10236
 
10105
10237
  /*
@@ -10128,7 +10260,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
10128
10260
  knownAuthorities: [],
10129
10261
  cloudDiscoveryMetadata: Constants.EMPTY_STRING,
10130
10262
  authorityMetadata: Constants.EMPTY_STRING,
10131
- redirectUri: Constants.EMPTY_STRING,
10263
+ redirectUri: typeof window !== "undefined" ? getCurrentUri() : "",
10132
10264
  postLogoutRedirectUri: Constants.EMPTY_STRING,
10133
10265
  navigateToLoginRequestUrl: true,
10134
10266
  clientCapabilities: [],
@@ -10234,7 +10366,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
10234
10366
 
10235
10367
  /* eslint-disable header/header */
10236
10368
  const name = "@azure/msal-browser";
10237
- const version = "3.26.1";
10369
+ const version = "3.28.0";
10238
10370
 
10239
10371
  /*
10240
10372
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11024,7 +11156,7 @@ class CryptoOps {
11024
11156
  constructor(logger, performanceClient) {
11025
11157
  this.logger = logger;
11026
11158
  // Browser crypto needs to be validated first before any other classes can be set.
11027
- validateCryptoAvailable(logger);
11159
+ validateCryptoAvailable();
11028
11160
  this.cache = new AsyncMemoryStorage(this.logger);
11029
11161
  this.performanceClient = performanceClient;
11030
11162
  }
@@ -11193,32 +11325,53 @@ function getSortedObjectString(obj) {
11193
11325
  * Copyright (c) Microsoft Corporation. All rights reserved.
11194
11326
  * Licensed under the MIT License.
11195
11327
  */
11196
- class BrowserStorage {
11197
- constructor(cacheLocation) {
11198
- this.validateWindowStorage(cacheLocation);
11199
- this.windowStorage = window[cacheLocation];
11328
+ class LocalStorage {
11329
+ constructor() {
11330
+ if (!window.localStorage) {
11331
+ throw createBrowserConfigurationAuthError(storageNotSupported);
11332
+ }
11333
+ }
11334
+ getItem(key) {
11335
+ return window.localStorage.getItem(key);
11336
+ }
11337
+ setItem(key, value) {
11338
+ window.localStorage.setItem(key, value);
11339
+ }
11340
+ removeItem(key) {
11341
+ window.localStorage.removeItem(key);
11342
+ }
11343
+ getKeys() {
11344
+ return Object.keys(window.localStorage);
11345
+ }
11346
+ containsKey(key) {
11347
+ return window.localStorage.hasOwnProperty(key);
11200
11348
  }
11201
- validateWindowStorage(cacheLocation) {
11202
- if ((cacheLocation !== BrowserCacheLocation.LocalStorage &&
11203
- cacheLocation !== BrowserCacheLocation.SessionStorage) ||
11204
- !window[cacheLocation]) {
11349
+ }
11350
+
11351
+ /*
11352
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11353
+ * Licensed under the MIT License.
11354
+ */
11355
+ class SessionStorage {
11356
+ constructor() {
11357
+ if (!window.sessionStorage) {
11205
11358
  throw createBrowserConfigurationAuthError(storageNotSupported);
11206
11359
  }
11207
11360
  }
11208
11361
  getItem(key) {
11209
- return this.windowStorage.getItem(key);
11362
+ return window.sessionStorage.getItem(key);
11210
11363
  }
11211
11364
  setItem(key, value) {
11212
- this.windowStorage.setItem(key, value);
11365
+ window.sessionStorage.setItem(key, value);
11213
11366
  }
11214
11367
  removeItem(key) {
11215
- this.windowStorage.removeItem(key);
11368
+ window.sessionStorage.removeItem(key);
11216
11369
  }
11217
11370
  getKeys() {
11218
- return Object.keys(this.windowStorage);
11371
+ return Object.keys(window.sessionStorage);
11219
11372
  }
11220
11373
  containsKey(key) {
11221
- return this.windowStorage.hasOwnProperty(key);
11374
+ return window.sessionStorage.hasOwnProperty(key);
11222
11375
  }
11223
11376
  }
11224
11377
 
@@ -11244,6 +11397,64 @@ function extractBrowserRequestState(browserCrypto, state) {
11244
11397
  }
11245
11398
  }
11246
11399
 
11400
+ /*
11401
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11402
+ * Licensed under the MIT License.
11403
+ */
11404
+ // Cookie life calculation (hours * minutes * seconds * ms)
11405
+ const COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11406
+ class CookieStorage {
11407
+ getItem(key) {
11408
+ const name = `${encodeURIComponent(key)}`;
11409
+ const cookieList = document.cookie.split(";");
11410
+ for (let i = 0; i < cookieList.length; i++) {
11411
+ const cookie = cookieList[i];
11412
+ const [key, ...rest] = decodeURIComponent(cookie).trim().split("=");
11413
+ const value = rest.join("=");
11414
+ if (key === name) {
11415
+ return value;
11416
+ }
11417
+ }
11418
+ return "";
11419
+ }
11420
+ setItem(key, value, cookieLifeDays, secure = true) {
11421
+ let cookieStr = `${encodeURIComponent(key)}=${encodeURIComponent(value)};path=/;SameSite=Lax;`;
11422
+ if (cookieLifeDays) {
11423
+ const expireTime = getCookieExpirationTime(cookieLifeDays);
11424
+ cookieStr += `expires=${expireTime};`;
11425
+ }
11426
+ if (secure) {
11427
+ cookieStr += "Secure;";
11428
+ }
11429
+ document.cookie = cookieStr;
11430
+ }
11431
+ removeItem(key) {
11432
+ // Setting expiration to -1 removes it
11433
+ this.setItem(key, "", -1);
11434
+ }
11435
+ getKeys() {
11436
+ const cookieList = document.cookie.split(";");
11437
+ const keys = [];
11438
+ cookieList.forEach((cookie) => {
11439
+ const cookieParts = decodeURIComponent(cookie).trim().split("=");
11440
+ keys.push(cookieParts[0]);
11441
+ });
11442
+ return keys;
11443
+ }
11444
+ containsKey(key) {
11445
+ return this.getKeys().includes(key);
11446
+ }
11447
+ }
11448
+ /**
11449
+ * Get cookie expiration time
11450
+ * @param cookieLifeDays
11451
+ */
11452
+ function getCookieExpirationTime(cookieLifeDays) {
11453
+ const today = new Date();
11454
+ const expr = new Date(today.getTime() + cookieLifeDays * COOKIE_LIFE_MULTIPLIER);
11455
+ return expr.toUTCString();
11456
+ }
11457
+
11247
11458
  /*
11248
11459
  * Copyright (c) Microsoft Corporation. All rights reserved.
11249
11460
  * Licensed under the MIT License.
@@ -11256,13 +11467,12 @@ function extractBrowserRequestState(browserCrypto, state) {
11256
11467
  class BrowserCacheManager extends CacheManager {
11257
11468
  constructor(clientId, cacheConfig, cryptoImpl, logger, staticAuthorityOptions, performanceClient) {
11258
11469
  super(clientId, cryptoImpl, logger, staticAuthorityOptions);
11259
- // Cookie life calculation (hours * minutes * seconds * ms)
11260
- this.COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;
11261
11470
  this.cacheConfig = cacheConfig;
11262
11471
  this.logger = logger;
11263
11472
  this.internalStorage = new MemoryStorage();
11264
11473
  this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);
11265
- this.temporaryCacheStorage = this.setupTemporaryCacheStorage(this.cacheConfig.temporaryCacheLocation, this.cacheConfig.cacheLocation);
11474
+ this.temporaryCacheStorage = this.setupBrowserStorage(this.cacheConfig.temporaryCacheLocation);
11475
+ this.cookieStorage = new CookieStorage();
11266
11476
  // Migrate cache entries from older versions of MSAL.
11267
11477
  if (cacheConfig.cacheMigrationEnabled) {
11268
11478
  this.migrateCacheEntries();
@@ -11275,44 +11485,23 @@ class BrowserCacheManager extends CacheManager {
11275
11485
  * @param cacheLocation
11276
11486
  */
11277
11487
  setupBrowserStorage(cacheLocation) {
11278
- switch (cacheLocation) {
11279
- case BrowserCacheLocation.LocalStorage:
11280
- case BrowserCacheLocation.SessionStorage:
11281
- try {
11282
- return new BrowserStorage(cacheLocation);
11283
- }
11284
- catch (e) {
11285
- this.logger.verbose(e);
11488
+ try {
11489
+ switch (cacheLocation) {
11490
+ case BrowserCacheLocation.LocalStorage:
11491
+ return new LocalStorage();
11492
+ case BrowserCacheLocation.SessionStorage:
11493
+ return new SessionStorage();
11494
+ case BrowserCacheLocation.MemoryStorage:
11495
+ default:
11286
11496
  break;
11287
- }
11288
- case BrowserCacheLocation.MemoryStorage:
11497
+ }
11498
+ }
11499
+ catch (e) {
11500
+ this.logger.error(e);
11289
11501
  }
11290
11502
  this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;
11291
11503
  return new MemoryStorage();
11292
11504
  }
11293
- /**
11294
- * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured temporaryCacheLocation.
11295
- * @param temporaryCacheLocation
11296
- * @param cacheLocation
11297
- */
11298
- setupTemporaryCacheStorage(temporaryCacheLocation, cacheLocation) {
11299
- switch (cacheLocation) {
11300
- case BrowserCacheLocation.LocalStorage:
11301
- case BrowserCacheLocation.SessionStorage:
11302
- try {
11303
- // Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
11304
- return new BrowserStorage(temporaryCacheLocation ||
11305
- BrowserCacheLocation.SessionStorage);
11306
- }
11307
- catch (e) {
11308
- this.logger.verbose(e);
11309
- return this.internalStorage;
11310
- }
11311
- case BrowserCacheLocation.MemoryStorage:
11312
- default:
11313
- return this.internalStorage;
11314
- }
11315
- }
11316
11505
  /**
11317
11506
  * Migrate all old cache entries to new schema. No rollback supported.
11318
11507
  * @param storeAuthStateInCookie
@@ -12000,7 +12189,7 @@ class BrowserCacheManager extends CacheManager {
12000
12189
  getTemporaryCache(cacheKey, generateKey) {
12001
12190
  const key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;
12002
12191
  if (this.cacheConfig.storeAuthStateInCookie) {
12003
- const itemCookie = this.getItemCookie(key);
12192
+ const itemCookie = this.cookieStorage.getItem(key);
12004
12193
  if (itemCookie) {
12005
12194
  this.logger.trace("BrowserCacheManager.getTemporaryCache: storeAuthStateInCookies set to true, retrieving from cookies");
12006
12195
  return itemCookie;
@@ -12035,7 +12224,7 @@ class BrowserCacheManager extends CacheManager {
12035
12224
  this.temporaryCacheStorage.setItem(key, value);
12036
12225
  if (this.cacheConfig.storeAuthStateInCookie) {
12037
12226
  this.logger.trace("BrowserCacheManager.setTemporaryCache: storeAuthStateInCookie set to true, setting item cookie");
12038
- this.setItemCookie(key, value);
12227
+ this.cookieStorage.setItem(key, value, undefined, this.cacheConfig.secureCookies);
12039
12228
  }
12040
12229
  }
12041
12230
  /**
@@ -12054,7 +12243,7 @@ class BrowserCacheManager extends CacheManager {
12054
12243
  this.temporaryCacheStorage.removeItem(key);
12055
12244
  if (this.cacheConfig.storeAuthStateInCookie) {
12056
12245
  this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
12057
- this.clearItemCookie(key);
12246
+ this.cookieStorage.removeItem(key);
12058
12247
  }
12059
12248
  }
12060
12249
  /**
@@ -12110,79 +12299,6 @@ class BrowserCacheManager extends CacheManager {
12110
12299
  this.logger.warning(`${removedAccessTokens.length} access tokens with claims in the cache keys have been removed from the cache.`);
12111
12300
  }
12112
12301
  }
12113
- /**
12114
- * Add value to cookies
12115
- * @param cookieName
12116
- * @param cookieValue
12117
- * @param expires
12118
- * @deprecated
12119
- */
12120
- setItemCookie(cookieName, cookieValue, expires) {
12121
- let cookieStr = `${encodeURIComponent(cookieName)}=${encodeURIComponent(cookieValue)};path=/;SameSite=Lax;`;
12122
- if (expires) {
12123
- const expireTime = this.getCookieExpirationTime(expires);
12124
- cookieStr += `expires=${expireTime};`;
12125
- }
12126
- if (this.cacheConfig.secureCookies) {
12127
- cookieStr += "Secure;";
12128
- }
12129
- document.cookie = cookieStr;
12130
- }
12131
- /**
12132
- * Get one item by key from cookies
12133
- * @param cookieName
12134
- * @deprecated
12135
- */
12136
- getItemCookie(cookieName) {
12137
- const name = `${encodeURIComponent(cookieName)}=`;
12138
- const cookieList = document.cookie.split(";");
12139
- for (let i = 0; i < cookieList.length; i++) {
12140
- let cookie = cookieList[i];
12141
- while (cookie.charAt(0) === " ") {
12142
- cookie = cookie.substring(1);
12143
- }
12144
- if (cookie.indexOf(name) === 0) {
12145
- return decodeURIComponent(cookie.substring(name.length, cookie.length));
12146
- }
12147
- }
12148
- return Constants.EMPTY_STRING;
12149
- }
12150
- /**
12151
- * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
12152
- * @deprecated
12153
- */
12154
- clearMsalCookies() {
12155
- const cookiePrefix = `${Constants.CACHE_PREFIX}.${this.clientId}`;
12156
- const cookieList = document.cookie.split(";");
12157
- cookieList.forEach((cookie) => {
12158
- while (cookie.charAt(0) === " ") {
12159
- // eslint-disable-next-line no-param-reassign
12160
- cookie = cookie.substring(1);
12161
- }
12162
- if (cookie.indexOf(cookiePrefix) === 0) {
12163
- const cookieKey = cookie.split("=")[0];
12164
- this.clearItemCookie(cookieKey);
12165
- }
12166
- });
12167
- }
12168
- /**
12169
- * Clear an item in the cookies by key
12170
- * @param cookieName
12171
- * @deprecated
12172
- */
12173
- clearItemCookie(cookieName) {
12174
- this.setItemCookie(cookieName, Constants.EMPTY_STRING, -1);
12175
- }
12176
- /**
12177
- * Get cookie expiration time
12178
- * @param cookieLifeDays
12179
- * @deprecated
12180
- */
12181
- getCookieExpirationTime(cookieLifeDays) {
12182
- const today = new Date();
12183
- const expr = new Date(today.getTime() + cookieLifeDays * this.COOKIE_LIFE_MULTIPLIER);
12184
- return expr.toUTCString();
12185
- }
12186
12302
  /**
12187
12303
  * 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)
12188
12304
  * @param key
@@ -12306,7 +12422,6 @@ class BrowserCacheManager extends CacheManager {
12306
12422
  this.logger.infoPii(`BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: ${cachedState}`);
12307
12423
  this.resetRequestCache(cachedState || Constants.EMPTY_STRING);
12308
12424
  }
12309
- this.clearMsalCookies();
12310
12425
  }
12311
12426
  /**
12312
12427
  * Looks in temporary cache for any state values with the provided interactionType and removes all temporary cache items for that state
@@ -12334,7 +12449,6 @@ class BrowserCacheManager extends CacheManager {
12334
12449
  this.resetRequestCache(stateValue);
12335
12450
  }
12336
12451
  });
12337
- this.clearMsalCookies();
12338
12452
  this.setInteractionInProgress(false);
12339
12453
  }
12340
12454
  cacheCodeRequest(authCodeRequest) {
@@ -12817,9 +12931,7 @@ class BaseInteractionClient {
12817
12931
  */
12818
12932
  getRedirectUri(requestRedirectUri) {
12819
12933
  this.logger.verbose("getRedirectUri called");
12820
- const redirectUri = requestRedirectUri ||
12821
- this.config.auth.redirectUri ||
12822
- getCurrentUri();
12934
+ const redirectUri = requestRedirectUri || this.config.auth.redirectUri;
12823
12935
  return UrlString.getAbsoluteUrl(redirectUri, getCurrentUri());
12824
12936
  }
12825
12937
  /**
@@ -13142,6 +13254,7 @@ class StandardInteractionClient extends BaseInteractionClient {
13142
13254
  clientId: this.config.auth.clientId,
13143
13255
  authority: discoveredAuthority,
13144
13256
  clientCapabilities: this.config.auth.clientCapabilities,
13257
+ redirectUri: this.config.auth.redirectUri,
13145
13258
  },
13146
13259
  systemOptions: {
13147
13260
  tokenRenewalOffsetSeconds: this.config.system.tokenRenewalOffsetSeconds,
@@ -13190,6 +13303,10 @@ class StandardInteractionClient extends BaseInteractionClient {
13190
13303
  responseMode: this.config.auth.OIDCOptions
13191
13304
  .serverResponseType,
13192
13305
  };
13306
+ // Skip active account lookup if either login hint or session id is set
13307
+ if (request.loginHint || request.sid) {
13308
+ return validatedRequest;
13309
+ }
13193
13310
  const account = request.account || this.browserStorage.getActiveAccount();
13194
13311
  if (account) {
13195
13312
  this.logger.verbose("Setting validated request account", this.correlationId);
@@ -13339,10 +13456,6 @@ class SilentCacheClient extends StandardInteractionClient {
13339
13456
  * Copyright (c) Microsoft Corporation. All rights reserved.
13340
13457
  * Licensed under the MIT License.
13341
13458
  */
13342
- const BrokerServerParamKeys = {
13343
- BROKER_CLIENT_ID: "brk_client_id",
13344
- BROKER_REDIRECT_URI: "brk_redirect_uri",
13345
- };
13346
13459
  class NativeInteractionClient extends BaseInteractionClient {
13347
13460
  constructor(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
13348
13461
  super(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
@@ -13945,21 +14058,33 @@ class NativeInteractionClient extends BaseInteractionClient {
13945
14058
  * @private
13946
14059
  */
13947
14060
  handleExtraBrokerParams(request) {
13948
- if (!request.extraParameters) {
14061
+ const hasExtraBrokerParams = request.extraParameters &&
14062
+ request.extraParameters.hasOwnProperty(BROKER_CLIENT_ID) &&
14063
+ request.extraParameters.hasOwnProperty(BROKER_REDIRECT_URI) &&
14064
+ request.extraParameters.hasOwnProperty(CLIENT_ID);
14065
+ if (!request.embeddedClientId && !hasExtraBrokerParams) {
13949
14066
  return;
13950
14067
  }
13951
- if (request.extraParameters.hasOwnProperty(BrokerServerParamKeys.BROKER_CLIENT_ID) &&
13952
- request.extraParameters.hasOwnProperty(BrokerServerParamKeys.BROKER_REDIRECT_URI) &&
13953
- request.extraParameters.hasOwnProperty(CLIENT_ID)) {
13954
- const child_client_id = request.extraParameters[CLIENT_ID];
13955
- const child_redirect_uri = request.redirectUri;
13956
- const brk_redirect_uri = request.extraParameters[BrokerServerParamKeys.BROKER_REDIRECT_URI];
13957
- request.extraParameters = {
13958
- child_client_id,
13959
- child_redirect_uri,
13960
- };
13961
- request.redirectUri = brk_redirect_uri;
14068
+ let child_client_id = "";
14069
+ const child_redirect_uri = request.redirectUri;
14070
+ if (request.embeddedClientId) {
14071
+ request.redirectUri = this.config.auth.redirectUri;
14072
+ child_client_id = request.embeddedClientId;
13962
14073
  }
14074
+ else if (request.extraParameters) {
14075
+ request.redirectUri =
14076
+ request.extraParameters[BROKER_REDIRECT_URI];
14077
+ child_client_id =
14078
+ request.extraParameters[CLIENT_ID];
14079
+ }
14080
+ request.extraParameters = {
14081
+ child_client_id,
14082
+ child_redirect_uri,
14083
+ };
14084
+ this.performanceClient?.addFields({
14085
+ embeddedClientId: child_client_id,
14086
+ embeddedRedirectUri: child_redirect_uri,
14087
+ }, request.correlationId);
13963
14088
  }
13964
14089
  }
13965
14090
 
@@ -16251,7 +16376,6 @@ class StandardController {
16251
16376
  atPopupMeasurement.end({
16252
16377
  success: true,
16253
16378
  isNativeBroker: true,
16254
- requestId: response.requestId,
16255
16379
  accountType: getAccountType(response.account),
16256
16380
  });
16257
16381
  return response;
@@ -16290,7 +16414,6 @@ class StandardController {
16290
16414
  }
16291
16415
  atPopupMeasurement.end({
16292
16416
  success: true,
16293
- requestId: result.requestId,
16294
16417
  accessTokenSize: result.accessToken.length,
16295
16418
  idTokenSize: result.idToken.length,
16296
16419
  accountType: getAccountType(result.account),
@@ -16381,7 +16504,6 @@ class StandardController {
16381
16504
  this.ssoSilentMeasurement?.end({
16382
16505
  success: true,
16383
16506
  isNativeBroker: response.fromNativeBroker,
16384
- requestId: response.requestId,
16385
16507
  accessTokenSize: response.accessToken.length,
16386
16508
  idTokenSize: response.idToken.length,
16387
16509
  accountType: getAccountType(response.account),
@@ -16436,7 +16558,6 @@ class StandardController {
16436
16558
  atbcMeasurement.end({
16437
16559
  success: true,
16438
16560
  isNativeBroker: result.fromNativeBroker,
16439
- requestId: result.requestId,
16440
16561
  accessTokenSize: result.accessToken.length,
16441
16562
  idTokenSize: result.idToken.length,
16442
16563
  accountType: getAccountType(result.account),
@@ -16515,7 +16636,6 @@ class StandardController {
16515
16636
  success: true,
16516
16637
  fromCache: response.fromCache,
16517
16638
  isNativeBroker: response.fromNativeBroker,
16518
- requestId: response.requestId,
16519
16639
  });
16520
16640
  return response;
16521
16641
  })
@@ -17066,7 +17186,6 @@ class StandardController {
17066
17186
  fromCache: result.fromCache,
17067
17187
  isNativeBroker: result.fromNativeBroker,
17068
17188
  cacheLookupPolicy: request.cacheLookupPolicy,
17069
- requestId: result.requestId,
17070
17189
  accessTokenSize: result.accessToken.length,
17071
17190
  idTokenSize: result.idToken.length,
17072
17191
  });
@@ -17177,7 +17296,6 @@ class StandardController {
17177
17296
  this.performanceClient.addFields({
17178
17297
  fromCache: response.fromCache,
17179
17298
  isNativeBroker: response.fromNativeBroker,
17180
- requestId: response.requestId,
17181
17299
  }, request.correlationId);
17182
17300
  }
17183
17301
  return response;
@@ -17277,7 +17395,8 @@ class NestedAppAuthAdapter {
17277
17395
  else {
17278
17396
  extraParams = new Map(Object.entries(request.extraQueryParameters));
17279
17397
  }
17280
- const requestBuilder = new RequestParameterBuilder();
17398
+ const correlationId = request.correlationId || this.crypto.createNewGuid();
17399
+ const requestBuilder = new RequestParameterBuilder(correlationId);
17281
17400
  const claims = requestBuilder.addClientCapabilitiesToClaims(request.claims, this.clientCapabilities);
17282
17401
  const scopes = request.scopes || OIDC_DEFAULT_SCOPES;
17283
17402
  const tokenRequest = {
@@ -17285,9 +17404,7 @@ class NestedAppAuthAdapter {
17285
17404
  clientId: this.clientId,
17286
17405
  authority: request.authority,
17287
17406
  scope: scopes.join(" "),
17288
- correlationId: request.correlationId !== undefined
17289
- ? request.correlationId
17290
- : this.crypto.createNewGuid(),
17407
+ correlationId,
17291
17408
  claims: !StringUtils.isEmptyObj(claims) ? claims : undefined,
17292
17409
  state: request.state,
17293
17410
  authenticationScheme: request.authenticationScheme || AuthenticationScheme.BEARER,
@@ -19097,6 +19214,42 @@ const stubbedPublicClientApplication = {
19097
19214
  },
19098
19215
  };
19099
19216
 
19217
+ /*
19218
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19219
+ * Licensed under the MIT License.
19220
+ */
19221
+ /**
19222
+ * @deprecated This class will be removed in a future major version
19223
+ */
19224
+ class BrowserStorage {
19225
+ constructor(cacheLocation) {
19226
+ if (cacheLocation === BrowserCacheLocation.LocalStorage) {
19227
+ this.windowStorage = new LocalStorage();
19228
+ }
19229
+ else if (cacheLocation === BrowserCacheLocation.SessionStorage) {
19230
+ this.windowStorage = new SessionStorage();
19231
+ }
19232
+ else {
19233
+ throw createBrowserConfigurationAuthError(storageNotSupported);
19234
+ }
19235
+ }
19236
+ getItem(key) {
19237
+ return this.windowStorage.getItem(key);
19238
+ }
19239
+ setItem(key, value) {
19240
+ this.windowStorage.setItem(key, value);
19241
+ }
19242
+ removeItem(key) {
19243
+ this.windowStorage.removeItem(key);
19244
+ }
19245
+ getKeys() {
19246
+ return Object.keys(this.windowStorage);
19247
+ }
19248
+ containsKey(key) {
19249
+ return this.windowStorage.hasOwnProperty(key);
19250
+ }
19251
+ }
19252
+
19100
19253
  /*
19101
19254
  * Copyright (c) Microsoft Corporation. All rights reserved.
19102
19255
  * Licensed under the MIT License.
@@ -19502,6 +19655,7 @@ exports.InteractionRequiredAuthErrorCodes = InteractionRequiredAuthErrorCodes;
19502
19655
  exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
19503
19656
  exports.InteractionStatus = InteractionStatus;
19504
19657
  exports.JsonWebTokenTypes = JsonWebTokenTypes;
19658
+ exports.LocalStorage = LocalStorage;
19505
19659
  exports.Logger = Logger;
19506
19660
  exports.MemoryStorage = MemoryStorage;
19507
19661
  exports.NavigationClient = NavigationClient;
@@ -19513,6 +19667,7 @@ exports.PublicClientApplication = PublicClientApplication;
19513
19667
  exports.PublicClientNext = PublicClientNext;
19514
19668
  exports.ServerError = ServerError;
19515
19669
  exports.ServerResponseType = ServerResponseType;
19670
+ exports.SessionStorage = SessionStorage;
19516
19671
  exports.SignedHttpRequest = SignedHttpRequest;
19517
19672
  exports.StringUtils = StringUtils;
19518
19673
  exports.StubPerformanceClient = StubPerformanceClient;