@azure/msal-browser 3.9.0 → 3.11.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 (155) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/app/PublicClientNext.mjs +1 -1
  4. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  5. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  6. package/dist/cache/AsyncMemoryStorage.d.ts +2 -3
  7. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
  8. package/dist/cache/AsyncMemoryStorage.mjs +4 -5
  9. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  10. package/dist/cache/BrowserCacheManager.d.ts +8 -27
  11. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  12. package/dist/cache/BrowserCacheManager.mjs +48 -75
  13. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  14. package/dist/cache/BrowserStorage.mjs +1 -1
  15. package/dist/cache/DatabaseStorage.d.ts +1 -1
  16. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  17. package/dist/cache/DatabaseStorage.mjs +14 -4
  18. package/dist/cache/DatabaseStorage.mjs.map +1 -1
  19. package/dist/cache/{IAsyncMemoryStorage.d.ts → IAsyncStorage.d.ts} +1 -1
  20. package/dist/cache/IAsyncStorage.d.ts.map +1 -0
  21. package/dist/cache/MemoryStorage.mjs +1 -1
  22. package/dist/cache/TokenCache.mjs +1 -1
  23. package/dist/config/Configuration.mjs +1 -1
  24. package/dist/controllers/ControllerFactory.mjs +1 -1
  25. package/dist/controllers/IController.d.ts +1 -3
  26. package/dist/controllers/IController.d.ts.map +1 -1
  27. package/dist/controllers/NestedAppAuthController.d.ts +2 -3
  28. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  29. package/dist/controllers/NestedAppAuthController.mjs +21 -19
  30. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  31. package/dist/controllers/StandardController.d.ts +5 -23
  32. package/dist/controllers/StandardController.d.ts.map +1 -1
  33. package/dist/controllers/StandardController.mjs +47 -127
  34. package/dist/controllers/StandardController.mjs.map +1 -1
  35. package/dist/controllers/UnknownOperatingContextController.d.ts +1 -2
  36. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  37. package/dist/controllers/UnknownOperatingContextController.mjs +28 -36
  38. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  39. package/dist/crypto/BrowserCrypto.d.ts +5 -0
  40. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  41. package/dist/crypto/BrowserCrypto.mjs +12 -2
  42. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  43. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  44. package/dist/crypto/CryptoOps.mjs +28 -12
  45. package/dist/crypto/CryptoOps.mjs.map +1 -1
  46. package/dist/crypto/PkceGenerator.mjs +1 -1
  47. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  48. package/dist/encode/Base64Decode.mjs +1 -1
  49. package/dist/encode/Base64Encode.mjs +1 -1
  50. package/dist/error/BrowserAuthError.mjs +1 -1
  51. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  52. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  53. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  54. package/dist/error/NativeAuthError.mjs +1 -1
  55. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  56. package/dist/error/NestedAppAuthError.mjs +1 -1
  57. package/dist/event/EventHandler.mjs +1 -1
  58. package/dist/event/EventMessage.mjs +1 -1
  59. package/dist/event/EventType.mjs +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.mjs +2 -2
  63. package/dist/interaction_client/BaseInteractionClient.d.ts +1 -6
  64. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  65. package/dist/interaction_client/BaseInteractionClient.mjs +2 -43
  66. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  67. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  68. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  69. package/dist/interaction_client/NativeInteractionClient.mjs +18 -6
  70. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  71. package/dist/interaction_client/PopupClient.mjs +1 -1
  72. package/dist/interaction_client/RedirectClient.mjs +1 -1
  73. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  74. package/dist/interaction_client/SilentCacheClient.d.ts +1 -9
  75. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  76. package/dist/interaction_client/SilentCacheClient.mjs +3 -22
  77. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  78. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  79. package/dist/interaction_client/SilentIframeClient.mjs +14 -11
  80. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  81. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  82. package/dist/interaction_client/SilentRefreshClient.mjs +3 -2
  83. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  84. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  85. package/dist/interaction_client/StandardInteractionClient.mjs +3 -2
  86. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  87. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  88. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  89. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  90. package/dist/naa/BridgeError.mjs +1 -1
  91. package/dist/naa/BridgeProxy.mjs +1 -1
  92. package/dist/naa/BridgeStatusCode.mjs +1 -1
  93. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +3 -1
  94. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  95. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +4 -3
  96. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  97. package/dist/navigation/NavigationClient.mjs +1 -1
  98. package/dist/network/FetchClient.mjs +1 -1
  99. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  100. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  101. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  102. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  103. package/dist/packageMetadata.d.ts +1 -1
  104. package/dist/packageMetadata.d.ts.map +1 -1
  105. package/dist/packageMetadata.mjs +2 -2
  106. package/dist/request/RequestHelpers.d.ts +14 -0
  107. package/dist/request/RequestHelpers.d.ts.map +1 -0
  108. package/dist/request/RequestHelpers.mjs +61 -0
  109. package/dist/request/RequestHelpers.mjs.map +1 -0
  110. package/dist/response/ResponseHandler.mjs +1 -1
  111. package/dist/telemetry/BrowserPerformanceClient.d.ts +1 -1
  112. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  113. package/dist/telemetry/BrowserPerformanceClient.mjs +7 -6
  114. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  115. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  116. package/dist/utils/BrowserConstants.mjs +1 -1
  117. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  118. package/dist/utils/BrowserUtils.d.ts +19 -3
  119. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  120. package/dist/utils/BrowserUtils.mjs +45 -10
  121. package/dist/utils/BrowserUtils.mjs.map +1 -1
  122. package/lib/msal-browser.cjs +1116 -808
  123. package/lib/msal-browser.cjs.map +1 -1
  124. package/lib/msal-browser.js +1116 -808
  125. package/lib/msal-browser.js.map +1 -1
  126. package/lib/msal-browser.min.js +66 -66
  127. package/package.json +2 -2
  128. package/src/cache/AsyncMemoryStorage.ts +4 -6
  129. package/src/cache/BrowserCacheManager.ts +54 -90
  130. package/src/cache/DatabaseStorage.ts +14 -4
  131. package/src/controllers/IController.ts +1 -7
  132. package/src/controllers/NestedAppAuthController.ts +38 -23
  133. package/src/controllers/StandardController.ts +107 -179
  134. package/src/controllers/UnknownOperatingContextController.ts +28 -37
  135. package/src/crypto/BrowserCrypto.ts +11 -0
  136. package/src/crypto/CryptoOps.ts +31 -13
  137. package/src/index.ts +2 -0
  138. package/src/interaction_client/BaseInteractionClient.ts +0 -66
  139. package/src/interaction_client/NativeInteractionClient.ts +28 -9
  140. package/src/interaction_client/SilentCacheClient.ts +11 -51
  141. package/src/interaction_client/SilentIframeClient.ts +15 -16
  142. package/src/interaction_client/SilentRefreshClient.ts +3 -2
  143. package/src/interaction_client/StandardInteractionClient.ts +8 -2
  144. package/src/naa/mapping/NestedAppAuthAdapter.ts +10 -2
  145. package/src/packageMetadata.ts +1 -1
  146. package/src/request/RequestHelpers.ts +112 -0
  147. package/src/telemetry/BrowserPerformanceClient.ts +20 -10
  148. package/src/utils/BrowserUtils.ts +59 -15
  149. package/dist/cache/CryptoKeyStore.d.ts +0 -19
  150. package/dist/cache/CryptoKeyStore.d.ts.map +0 -1
  151. package/dist/cache/CryptoKeyStore.mjs +0 -47
  152. package/dist/cache/CryptoKeyStore.mjs.map +0 -1
  153. package/dist/cache/IAsyncMemoryStorage.d.ts.map +0 -1
  154. package/src/cache/CryptoKeyStore.ts +0 -63
  155. /package/src/cache/{IAsyncMemoryStorage.ts → IAsyncStorage.ts} +0 -0
@@ -1,8 +1,8 @@
1
- /*! @azure/msal-browser v3.9.0 2024-02-07 */
1
+ /*! @azure/msal-browser v3.11.0 2024-03-22 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
- /*! @azure/msal-common v14.7.0 2024-02-07 */
5
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6
6
  /*
7
7
  * Copyright (c) Microsoft Corporation. All rights reserved.
8
8
  * Licensed under the MIT License.
@@ -297,7 +297,7 @@ const JsonWebTokenTypes = {
297
297
  Pop: "pop",
298
298
  };
299
299
 
300
- /*! @azure/msal-common v14.7.0 2024-02-07 */
300
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
301
301
  /*
302
302
  * Copyright (c) Microsoft Corporation. All rights reserved.
303
303
  * Licensed under the MIT License.
@@ -314,7 +314,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
314
314
  unexpectedError: unexpectedError
315
315
  });
316
316
 
317
- /*! @azure/msal-common v14.7.0 2024-02-07 */
317
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
318
318
 
319
319
  /*
320
320
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -363,7 +363,7 @@ function createAuthError(code, additionalMessage) {
363
363
  : AuthErrorMessages[code]);
364
364
  }
365
365
 
366
- /*! @azure/msal-common v14.7.0 2024-02-07 */
366
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
367
367
  /*
368
368
  * Copyright (c) Microsoft Corporation. All rights reserved.
369
369
  * Licensed under the MIT License.
@@ -461,7 +461,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
461
461
  userTimeoutReached: userTimeoutReached
462
462
  });
463
463
 
464
- /*! @azure/msal-common v14.7.0 2024-02-07 */
464
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
465
465
 
466
466
  /*
467
467
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -713,7 +713,7 @@ function createClientAuthError(errorCode, additionalMessage) {
713
713
  return new ClientAuthError(errorCode, additionalMessage);
714
714
  }
715
715
 
716
- /*! @azure/msal-common v14.7.0 2024-02-07 */
716
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
717
717
 
718
718
  /*
719
719
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -746,7 +746,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
746
746
  },
747
747
  };
748
748
 
749
- /*! @azure/msal-common v14.7.0 2024-02-07 */
749
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
750
750
 
751
751
  /*
752
752
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -937,12 +937,12 @@ class Logger {
937
937
  }
938
938
  }
939
939
 
940
- /*! @azure/msal-common v14.7.0 2024-02-07 */
940
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
941
941
  /* eslint-disable header/header */
942
942
  const name$1 = "@azure/msal-common";
943
- const version$1 = "14.7.0";
943
+ const version$1 = "14.8.0";
944
944
 
945
- /*! @azure/msal-common v14.7.0 2024-02-07 */
945
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
946
946
  /*
947
947
  * Copyright (c) Microsoft Corporation. All rights reserved.
948
948
  * Licensed under the MIT License.
@@ -962,7 +962,7 @@ const AzureCloudInstance = {
962
962
  AzureUsGovernment: "https://login.microsoftonline.us",
963
963
  };
964
964
 
965
- /*! @azure/msal-common v14.7.0 2024-02-07 */
965
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
966
966
 
967
967
  /*
968
968
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1023,7 +1023,7 @@ function checkMaxAge(authTime, maxAge) {
1023
1023
  }
1024
1024
  }
1025
1025
 
1026
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1026
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1027
1027
  /*
1028
1028
  * Copyright (c) Microsoft Corporation. All rights reserved.
1029
1029
  * Licensed under the MIT License.
@@ -1060,7 +1060,7 @@ function wasClockTurnedBack(cachedAt) {
1060
1060
  return cachedAtSec > nowSeconds();
1061
1061
  }
1062
1062
 
1063
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1063
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1064
1064
 
1065
1065
  /*
1066
1066
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1387,7 +1387,7 @@ function isAuthorityMetadataExpired(metadata) {
1387
1387
  return metadata.expiresAt <= nowSeconds();
1388
1388
  }
1389
1389
 
1390
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1390
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1391
1391
  /*
1392
1392
  * Copyright (c) Microsoft Corporation. All rights reserved.
1393
1393
  * Licensed under the MIT License.
@@ -1441,7 +1441,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1441
1441
  urlParseError: urlParseError
1442
1442
  });
1443
1443
 
1444
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1444
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1445
1445
 
1446
1446
  /*
1447
1447
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1579,7 +1579,7 @@ function createClientConfigurationError(errorCode) {
1579
1579
  return new ClientConfigurationError(errorCode);
1580
1580
  }
1581
1581
 
1582
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1582
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1583
1583
  /*
1584
1584
  * Copyright (c) Microsoft Corporation. All rights reserved.
1585
1585
  * Licensed under the MIT License.
@@ -1676,7 +1676,7 @@ class StringUtils {
1676
1676
  }
1677
1677
  }
1678
1678
 
1679
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1679
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1680
1680
 
1681
1681
  /*
1682
1682
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1876,7 +1876,7 @@ class ScopeSet {
1876
1876
  }
1877
1877
  }
1878
1878
 
1879
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1879
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1880
1880
 
1881
1881
  /*
1882
1882
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1916,7 +1916,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
1916
1916
  };
1917
1917
  }
1918
1918
 
1919
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1919
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1920
1920
  /*
1921
1921
  * Copyright (c) Microsoft Corporation. All rights reserved.
1922
1922
  * Licensed under the MIT License.
@@ -1954,7 +1954,7 @@ function buildTenantProfileFromIdTokenClaims(homeAccountId, idTokenClaims) {
1954
1954
  * @param idTokenClaims
1955
1955
  * @returns
1956
1956
  */
1957
- function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenClaims) {
1957
+ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenClaims, idTokenSecret) {
1958
1958
  let updatedAccountInfo = baseAccountInfo;
1959
1959
  // Tenant Profile overrides passed in account info
1960
1960
  if (tenantProfile) {
@@ -1971,13 +1971,14 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
1971
1971
  ...updatedAccountInfo,
1972
1972
  ...claimsSourcedTenantProfile,
1973
1973
  idTokenClaims: idTokenClaims,
1974
+ idToken: idTokenSecret,
1974
1975
  };
1975
1976
  return updatedAccountInfo;
1976
1977
  }
1977
1978
  return updatedAccountInfo;
1978
1979
  }
1979
1980
 
1980
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1981
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1981
1982
  /*
1982
1983
  * Copyright (c) Microsoft Corporation. All rights reserved.
1983
1984
  * Licensed under the MIT License.
@@ -1992,7 +1993,7 @@ const AuthorityType = {
1992
1993
  Ciam: 3,
1993
1994
  };
1994
1995
 
1995
- /*! @azure/msal-common v14.7.0 2024-02-07 */
1996
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
1996
1997
  /*
1997
1998
  * Copyright (c) Microsoft Corporation. All rights reserved.
1998
1999
  * Licensed under the MIT License.
@@ -2014,7 +2015,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2014
2015
  return null;
2015
2016
  }
2016
2017
 
2017
- /*! @azure/msal-common v14.7.0 2024-02-07 */
2018
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
2018
2019
  /*
2019
2020
  * Copyright (c) Microsoft Corporation. All rights reserved.
2020
2021
  * Licensed under the MIT License.
@@ -2027,7 +2028,7 @@ const ProtocolMode = {
2027
2028
  OIDC: "OIDC",
2028
2029
  };
2029
2030
 
2030
- /*! @azure/msal-common v14.7.0 2024-02-07 */
2031
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
2031
2032
 
2032
2033
  /*
2033
2034
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2274,7 +2275,7 @@ class AccountEntity {
2274
2275
  }
2275
2276
  }
2276
2277
 
2277
- /*! @azure/msal-common v14.7.0 2024-02-07 */
2278
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
2278
2279
 
2279
2280
  /*
2280
2281
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2321,7 +2322,7 @@ function getDeserializedResponse(responseString) {
2321
2322
  return null;
2322
2323
  }
2323
2324
 
2324
- /*! @azure/msal-common v14.7.0 2024-02-07 */
2325
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
2325
2326
 
2326
2327
  /*
2327
2328
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2485,7 +2486,7 @@ class UrlString {
2485
2486
  }
2486
2487
  }
2487
2488
 
2488
- /*! @azure/msal-common v14.7.0 2024-02-07 */
2489
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
2489
2490
 
2490
2491
  /*
2491
2492
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2625,7 +2626,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2625
2626
  return null;
2626
2627
  }
2627
2628
 
2628
- /*! @azure/msal-common v14.7.0 2024-02-07 */
2629
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
2629
2630
 
2630
2631
  /*
2631
2632
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2716,7 +2717,7 @@ class CacheManager {
2716
2717
  }
2717
2718
  }
2718
2719
  // Expand tenant profile into account info based on matching tenant profile and if available matching ID token claims
2719
- tenantedAccountInfo = updateAccountTenantProfileData(accountInfo, tenantProfile, idTokenClaims);
2720
+ tenantedAccountInfo = updateAccountTenantProfileData(accountInfo, tenantProfile, idTokenClaims, idToken?.secret);
2720
2721
  return tenantedAccountInfo;
2721
2722
  }
2722
2723
  getTenantProfilesFromAccountEntity(accountEntity, targetTenantId, tenantProfileFilter) {
@@ -3032,14 +3033,6 @@ class CacheManager {
3032
3033
  * @param filter
3033
3034
  */
3034
3035
  getAppMetadataFilteredBy(filter) {
3035
- return this.getAppMetadataFilteredByInternal(filter.environment, filter.clientId);
3036
- }
3037
- /**
3038
- * Support function to help match appMetadata
3039
- * @param environment
3040
- * @param clientId
3041
- */
3042
- getAppMetadataFilteredByInternal(environment, clientId) {
3043
3036
  const allCacheKeys = this.getKeys();
3044
3037
  const matchingAppMetadata = {};
3045
3038
  allCacheKeys.forEach((cacheKey) => {
@@ -3052,10 +3045,12 @@ class CacheManager {
3052
3045
  if (!entity) {
3053
3046
  return;
3054
3047
  }
3055
- if (!!environment && !this.matchEnvironment(entity, environment)) {
3048
+ if (!!filter.environment &&
3049
+ !this.matchEnvironment(entity, filter.environment)) {
3056
3050
  return;
3057
3051
  }
3058
- if (!!clientId && !this.matchClientId(entity, clientId)) {
3052
+ if (!!filter.clientId &&
3053
+ !this.matchClientId(entity, filter.clientId)) {
3059
3054
  return;
3060
3055
  }
3061
3056
  matchingAppMetadata[cacheKey] = entity;
@@ -3842,9 +3837,6 @@ class DefaultStorageClass extends CacheManager {
3842
3837
  removeItem() {
3843
3838
  throw createClientAuthError(methodNotImplemented);
3844
3839
  }
3845
- containsKey() {
3846
- throw createClientAuthError(methodNotImplemented);
3847
- }
3848
3840
  getKeys() {
3849
3841
  throw createClientAuthError(methodNotImplemented);
3850
3842
  }
@@ -3865,7 +3857,7 @@ class DefaultStorageClass extends CacheManager {
3865
3857
  }
3866
3858
  }
3867
3859
 
3868
- /*! @azure/msal-common v14.7.0 2024-02-07 */
3860
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
3869
3861
 
3870
3862
  /*
3871
3863
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3965,7 +3957,7 @@ function isOidcProtocolMode(config) {
3965
3957
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
3966
3958
  }
3967
3959
 
3968
- /*! @azure/msal-common v14.7.0 2024-02-07 */
3960
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
3969
3961
 
3970
3962
  /*
3971
3963
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3982,7 +3974,7 @@ class ServerError extends AuthError {
3982
3974
  }
3983
3975
  }
3984
3976
 
3985
- /*! @azure/msal-common v14.7.0 2024-02-07 */
3977
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
3986
3978
 
3987
3979
  /*
3988
3980
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4080,7 +4072,7 @@ class ThrottlingUtils {
4080
4072
  }
4081
4073
  }
4082
4074
 
4083
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4075
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4084
4076
 
4085
4077
  /*
4086
4078
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4117,7 +4109,7 @@ class NetworkManager {
4117
4109
  }
4118
4110
  }
4119
4111
 
4120
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4112
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4121
4113
  /*
4122
4114
  * Copyright (c) Microsoft Corporation. All rights reserved.
4123
4115
  * Licensed under the MIT License.
@@ -4127,7 +4119,7 @@ const CcsCredentialType = {
4127
4119
  UPN: "UPN",
4128
4120
  };
4129
4121
 
4130
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4122
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4131
4123
  /*
4132
4124
  * Copyright (c) Microsoft Corporation. All rights reserved.
4133
4125
  * Licensed under the MIT License.
@@ -4174,7 +4166,7 @@ const SID = "sid";
4174
4166
  const LOGIN_HINT = "login_hint";
4175
4167
  const DOMAIN_HINT = "domain_hint";
4176
4168
 
4177
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4169
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4178
4170
 
4179
4171
  /*
4180
4172
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4258,7 +4250,7 @@ class RequestValidator {
4258
4250
  }
4259
4251
  }
4260
4252
 
4261
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4253
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4262
4254
 
4263
4255
  /*
4264
4256
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4642,7 +4634,7 @@ class RequestParameterBuilder {
4642
4634
  }
4643
4635
  }
4644
4636
 
4645
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4637
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4646
4638
  /*
4647
4639
  * Copyright (c) Microsoft Corporation. All rights reserved.
4648
4640
  * Licensed under the MIT License.
@@ -4654,7 +4646,7 @@ function isOpenIdConfigResponse(response) {
4654
4646
  response.hasOwnProperty("jwks_uri"));
4655
4647
  }
4656
4648
 
4657
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4649
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4658
4650
  /*
4659
4651
  * Copyright (c) Microsoft Corporation. All rights reserved.
4660
4652
  * Licensed under the MIT License.
@@ -4664,7 +4656,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4664
4656
  response.hasOwnProperty("metadata"));
4665
4657
  }
4666
4658
 
4667
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4659
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4668
4660
  /*
4669
4661
  * Copyright (c) Microsoft Corporation. All rights reserved.
4670
4662
  * Licensed under the MIT License.
@@ -4674,7 +4666,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4674
4666
  response.hasOwnProperty("error_description"));
4675
4667
  }
4676
4668
 
4677
- /*! @azure/msal-common v14.7.0 2024-02-07 */
4669
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4678
4670
  /*
4679
4671
  * Copyright (c) Microsoft Corporation. All rights reserved.
4680
4672
  * Licensed under the MIT License.
@@ -4909,6 +4901,219 @@ const PerformanceEvents = {
4909
4901
  Sha256Digest: "sha256Digest",
4910
4902
  GetRandomValues: "getRandomValues",
4911
4903
  };
4904
+ const PerformanceEventAbbreviations = new Map([
4905
+ [PerformanceEvents.AcquireTokenByCode, "ATByCode"],
4906
+ [PerformanceEvents.AcquireTokenByRefreshToken, "ATByRT"],
4907
+ [PerformanceEvents.AcquireTokenSilent, "ATS"],
4908
+ [PerformanceEvents.AcquireTokenSilentAsync, "ATSAsync"],
4909
+ [PerformanceEvents.AcquireTokenPopup, "ATPopup"],
4910
+ [PerformanceEvents.AcquireTokenRedirect, "ATRedirect"],
4911
+ [
4912
+ PerformanceEvents.CryptoOptsGetPublicKeyThumbprint,
4913
+ "CryptoGetPKThumb",
4914
+ ],
4915
+ [PerformanceEvents.CryptoOptsSignJwt, "CryptoSignJwt"],
4916
+ [PerformanceEvents.SilentCacheClientAcquireToken, "SltCacheClientAT"],
4917
+ [PerformanceEvents.SilentIframeClientAcquireToken, "SltIframeClientAT"],
4918
+ [PerformanceEvents.SilentRefreshClientAcquireToken, "SltRClientAT"],
4919
+ [PerformanceEvents.SsoSilent, "SsoSlt"],
4920
+ [
4921
+ PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority,
4922
+ "StdIntClientGetDiscAuth",
4923
+ ],
4924
+ [
4925
+ PerformanceEvents.FetchAccountIdWithNativeBroker,
4926
+ "FetchAccIdWithNtvBroker",
4927
+ ],
4928
+ [
4929
+ PerformanceEvents.NativeInteractionClientAcquireToken,
4930
+ "NtvIntClientAT",
4931
+ ],
4932
+ [
4933
+ PerformanceEvents.BaseClientCreateTokenRequestHeaders,
4934
+ "BaseClientCreateTReqHead",
4935
+ ],
4936
+ [
4937
+ PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint,
4938
+ "RTClientExecPost",
4939
+ ],
4940
+ [
4941
+ PerformanceEvents.AuthorizationCodeClientExecutePostToTokenEndpoint,
4942
+ "AuthCodeClientExecPost",
4943
+ ],
4944
+ [PerformanceEvents.BrokerHandhshake, "BrokerHandshake"],
4945
+ [
4946
+ PerformanceEvents.AcquireTokenByRefreshTokenInBroker,
4947
+ "ATByRTInBroker",
4948
+ ],
4949
+ [PerformanceEvents.AcquireTokenByBroker, "ATByBroker"],
4950
+ [
4951
+ PerformanceEvents.RefreshTokenClientExecuteTokenRequest,
4952
+ "RTClientExecTReq",
4953
+ ],
4954
+ [PerformanceEvents.RefreshTokenClientAcquireToken, "RTClientAT"],
4955
+ [
4956
+ PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken,
4957
+ "RTClientATWithCachedRT",
4958
+ ],
4959
+ [
4960
+ PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken,
4961
+ "RTClientATByRT",
4962
+ ],
4963
+ [
4964
+ PerformanceEvents.RefreshTokenClientCreateTokenRequestBody,
4965
+ "RTClientCreateTReqBody",
4966
+ ],
4967
+ [PerformanceEvents.AcquireTokenFromCache, "ATFromCache"],
4968
+ [
4969
+ PerformanceEvents.SilentFlowClientAcquireCachedToken,
4970
+ "SltFlowClientATCached",
4971
+ ],
4972
+ [
4973
+ PerformanceEvents.SilentFlowClientGenerateResultFromCacheRecord,
4974
+ "SltFlowClientGenResFromCache",
4975
+ ],
4976
+ [PerformanceEvents.AcquireTokenBySilentIframe, "ATBySltIframe"],
4977
+ [PerformanceEvents.InitializeBaseRequest, "InitBaseReq"],
4978
+ [PerformanceEvents.InitializeSilentRequest, "InitSltReq"],
4979
+ [
4980
+ PerformanceEvents.InitializeClientApplication,
4981
+ "InitClientApplication",
4982
+ ],
4983
+ [PerformanceEvents.SilentIframeClientTokenHelper, "SIClientTHelper"],
4984
+ [
4985
+ PerformanceEvents.SilentHandlerInitiateAuthRequest,
4986
+ "SHandlerInitAuthReq",
4987
+ ],
4988
+ [
4989
+ PerformanceEvents.SilentHandlerMonitorIframeForHash,
4990
+ "SltHandlerMonitorIframeForHash",
4991
+ ],
4992
+ [PerformanceEvents.SilentHandlerLoadFrame, "SHandlerLoadFrame"],
4993
+ [PerformanceEvents.SilentHandlerLoadFrameSync, "SHandlerLoadFrameSync"],
4994
+ [
4995
+ PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
4996
+ "StdIntClientCreateAuthCodeClient",
4997
+ ],
4998
+ [
4999
+ PerformanceEvents.StandardInteractionClientGetClientConfiguration,
5000
+ "StdIntClientGetClientConf",
5001
+ ],
5002
+ [
5003
+ PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
5004
+ "StdIntClientInitAuthReq",
5005
+ ],
5006
+ [
5007
+ PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
5008
+ "StdIntClientInitAuthCodeReq",
5009
+ ],
5010
+ [PerformanceEvents.GetAuthCodeUrl, "GetAuthCodeUrl"],
5011
+ [
5012
+ PerformanceEvents.HandleCodeResponseFromServer,
5013
+ "HandleCodeResFromServer",
5014
+ ],
5015
+ [PerformanceEvents.HandleCodeResponse, "HandleCodeResp"],
5016
+ [PerformanceEvents.UpdateTokenEndpointAuthority, "UpdTEndpointAuth"],
5017
+ [PerformanceEvents.AuthClientAcquireToken, "AuthClientAT"],
5018
+ [PerformanceEvents.AuthClientExecuteTokenRequest, "AuthClientExecTReq"],
5019
+ [
5020
+ PerformanceEvents.AuthClientCreateTokenRequestBody,
5021
+ "AuthClientCreateTReqBody",
5022
+ ],
5023
+ [
5024
+ PerformanceEvents.AuthClientCreateQueryString,
5025
+ "AuthClientCreateQueryStr",
5026
+ ],
5027
+ [PerformanceEvents.PopTokenGenerateCnf, "PopTGenCnf"],
5028
+ [PerformanceEvents.PopTokenGenerateKid, "PopTGenKid"],
5029
+ [PerformanceEvents.HandleServerTokenResponse, "HandleServerTRes"],
5030
+ [PerformanceEvents.DeserializeResponse, "DeserializeRes"],
5031
+ [
5032
+ PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance,
5033
+ "AuthFactCreateDiscInst",
5034
+ ],
5035
+ [
5036
+ PerformanceEvents.AuthorityResolveEndpointsAsync,
5037
+ "AuthResolveEndpointsAsync",
5038
+ ],
5039
+ [
5040
+ PerformanceEvents.AuthorityResolveEndpointsFromLocalSources,
5041
+ "AuthResolveEndpointsFromLocal",
5042
+ ],
5043
+ [
5044
+ PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork,
5045
+ "AuthGetCDMetaFromNet",
5046
+ ],
5047
+ [
5048
+ PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata,
5049
+ "AuthUpdCDMeta",
5050
+ ],
5051
+ [
5052
+ PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork,
5053
+ "AuthUpdCDMetaFromNet",
5054
+ ],
5055
+ [
5056
+ PerformanceEvents.AuthorityUpdateEndpointMetadata,
5057
+ "AuthUpdEndpointMeta",
5058
+ ],
5059
+ [
5060
+ PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
5061
+ "AuthUpdMetaWithRegInfo",
5062
+ ],
5063
+ [PerformanceEvents.RegionDiscoveryDetectRegion, "RegDiscDetectReg"],
5064
+ [
5065
+ PerformanceEvents.RegionDiscoveryGetRegionFromIMDS,
5066
+ "RegDiscGetRegFromIMDS",
5067
+ ],
5068
+ [
5069
+ PerformanceEvents.RegionDiscoveryGetCurrentVersion,
5070
+ "RegDiscGetCurrentVer",
5071
+ ],
5072
+ [PerformanceEvents.AcquireTokenByCodeAsync, "ATByCodeAsync"],
5073
+ [
5074
+ PerformanceEvents.GetEndpointMetadataFromNetwork,
5075
+ "GetEndpointMetaFromNet",
5076
+ ],
5077
+ [
5078
+ PerformanceEvents.GetCloudDiscoveryMetadataFromNetworkMeasurement,
5079
+ "GetCDMetaFromNet",
5080
+ ],
5081
+ [
5082
+ PerformanceEvents.HandleRedirectPromiseMeasurement,
5083
+ "HandleRedirectPromise",
5084
+ ],
5085
+ [
5086
+ PerformanceEvents.HandleNativeRedirectPromiseMeasurement,
5087
+ "HandleNtvRedirectPromise",
5088
+ ],
5089
+ [
5090
+ PerformanceEvents.UpdateCloudDiscoveryMetadataMeasurement,
5091
+ "UpdateCDMeta",
5092
+ ],
5093
+ [
5094
+ PerformanceEvents.UsernamePasswordClientAcquireToken,
5095
+ "UserPassClientAT",
5096
+ ],
5097
+ [
5098
+ PerformanceEvents.NativeMessageHandlerHandshake,
5099
+ "NtvMsgHandlerHandshake",
5100
+ ],
5101
+ [PerformanceEvents.NativeGenerateAuthResult, "NtvGenAuthRes"],
5102
+ [PerformanceEvents.RemoveHiddenIframe, "RemoveHiddenIframe"],
5103
+ [
5104
+ PerformanceEvents.ClearTokensAndKeysWithClaims,
5105
+ "ClearTAndKeysWithClaims",
5106
+ ],
5107
+ [PerformanceEvents.CacheManagerGetRefreshToken, "CacheManagerGetRT"],
5108
+ [PerformanceEvents.GeneratePkceCodes, "GenPkceCodes"],
5109
+ [PerformanceEvents.GenerateCodeVerifier, "GenCodeVerifier"],
5110
+ [
5111
+ PerformanceEvents.GenerateCodeChallengeFromVerifier,
5112
+ "GenCodeChallengeFromVerifier",
5113
+ ],
5114
+ [PerformanceEvents.Sha256Digest, "Sha256Digest"],
5115
+ [PerformanceEvents.GetRandomValues, "GetRandomValues"],
5116
+ ]);
4912
5117
  /**
4913
5118
  * State of the performance event.
4914
5119
  *
@@ -4935,7 +5140,7 @@ const IntFields = new Set([
4935
5140
  "multiMatchedRT",
4936
5141
  ]);
4937
5142
 
4938
- /*! @azure/msal-common v14.7.0 2024-02-07 */
5143
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
4939
5144
  /*
4940
5145
  * Copyright (c) Microsoft Corporation. All rights reserved.
4941
5146
  * Licensed under the MIT License.
@@ -4979,7 +5184,7 @@ const invoke = (callback, eventName, logger, telemetryClient, correlationId) =>
4979
5184
  }
4980
5185
  inProgressEvent?.end({
4981
5186
  success: false,
4982
- });
5187
+ }, e);
4983
5188
  throw e;
4984
5189
  }
4985
5190
  };
@@ -5025,13 +5230,13 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
5025
5230
  }
5026
5231
  inProgressEvent?.end({
5027
5232
  success: false,
5028
- });
5233
+ }, e);
5029
5234
  throw e;
5030
5235
  });
5031
5236
  };
5032
5237
  };
5033
5238
 
5034
- /*! @azure/msal-common v14.7.0 2024-02-07 */
5239
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
5035
5240
 
5036
5241
  /*
5037
5242
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5140,7 +5345,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5140
5345
  },
5141
5346
  };
5142
5347
 
5143
- /*! @azure/msal-common v14.7.0 2024-02-07 */
5348
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
5144
5349
 
5145
5350
  /*
5146
5351
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5937,8 +6142,10 @@ function getTenantFromAuthorityString(authority) {
5937
6142
  * AAD Authority - domain/tenantId -> Credentials are cached with realm = tenantId
5938
6143
  * B2C Authority - domain/{tenantId}?/.../policy -> Credentials are cached with realm = policy
5939
6144
  * tenantId is downcased because B2C policies can have mixed case but tfp claim is downcased
6145
+ *
6146
+ * Note that we may not have any path segments in certain OIDC scenarios.
5940
6147
  */
5941
- const tenantId = authorityUrlComponents.PathSegments.slice(-1)[0].toLowerCase();
6148
+ const tenantId = authorityUrlComponents.PathSegments.slice(-1)[0]?.toLowerCase();
5942
6149
  switch (tenantId) {
5943
6150
  case AADAuthorityConstants.COMMON:
5944
6151
  case AADAuthorityConstants.ORGANIZATIONS:
@@ -5973,7 +6180,7 @@ function buildStaticAuthorityOptions(authOptions) {
5973
6180
  };
5974
6181
  }
5975
6182
 
5976
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6183
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
5977
6184
 
5978
6185
  /*
5979
6186
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6004,7 +6211,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
6004
6211
  }
6005
6212
  }
6006
6213
 
6007
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6214
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6008
6215
 
6009
6216
  /*
6010
6217
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6107,7 +6314,7 @@ class BaseClient {
6107
6314
  }
6108
6315
  }
6109
6316
 
6110
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6317
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6111
6318
  /*
6112
6319
  * Copyright (c) Microsoft Corporation. All rights reserved.
6113
6320
  * Licensed under the MIT License.
@@ -6133,7 +6340,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6133
6340
  refreshTokenExpired: refreshTokenExpired
6134
6341
  });
6135
6342
 
6136
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6343
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6137
6344
 
6138
6345
  /*
6139
6346
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6220,7 +6427,7 @@ function createInteractionRequiredAuthError(errorCode) {
6220
6427
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6221
6428
  }
6222
6429
 
6223
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6430
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6224
6431
  /*
6225
6432
  * Copyright (c) Microsoft Corporation. All rights reserved.
6226
6433
  * Licensed under the MIT License.
@@ -6236,7 +6443,7 @@ class CacheRecord {
6236
6443
  }
6237
6444
  }
6238
6445
 
6239
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6446
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6240
6447
 
6241
6448
  /*
6242
6449
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6308,7 +6515,7 @@ class ProtocolUtils {
6308
6515
  }
6309
6516
  }
6310
6517
 
6311
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6518
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6312
6519
 
6313
6520
  /*
6314
6521
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6393,7 +6600,7 @@ class PopTokenGenerator {
6393
6600
  }
6394
6601
  }
6395
6602
 
6396
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6603
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6397
6604
  /*
6398
6605
  * Copyright (c) Microsoft Corporation. All rights reserved.
6399
6606
  * Licensed under the MIT License.
@@ -6420,7 +6627,7 @@ class PopTokenGenerator {
6420
6627
  }
6421
6628
  }
6422
6629
 
6423
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6630
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6424
6631
 
6425
6632
  /*
6426
6633
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6710,7 +6917,7 @@ class ResponseHandler {
6710
6917
  }
6711
6918
  const accountInfo = cacheRecord.account
6712
6919
  ? updateAccountTenantProfileData(cacheRecord.account.getAccountInfo(), undefined, // tenantProfile optional
6713
- idTokenClaims)
6920
+ idTokenClaims, cacheRecord.idToken?.secret)
6714
6921
  : null;
6715
6922
  return {
6716
6923
  authority: authority.canonicalAuthority,
@@ -6773,7 +6980,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, idTokenClai
6773
6980
  return baseAccount;
6774
6981
  }
6775
6982
 
6776
- /*! @azure/msal-common v14.7.0 2024-02-07 */
6983
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
6777
6984
 
6778
6985
  /*
6779
6986
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7178,7 +7385,7 @@ class AuthorizationCodeClient extends BaseClient {
7178
7385
  }
7179
7386
  }
7180
7387
 
7181
- /*! @azure/msal-common v14.7.0 2024-02-07 */
7388
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7182
7389
 
7183
7390
  /*
7184
7391
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7385,7 +7592,7 @@ class RefreshTokenClient extends BaseClient {
7385
7592
  }
7386
7593
  }
7387
7594
 
7388
- /*! @azure/msal-common v14.7.0 2024-02-07 */
7595
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7389
7596
 
7390
7597
  /*
7391
7598
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7403,7 +7610,12 @@ class SilentFlowClient extends BaseClient {
7403
7610
  */
7404
7611
  async acquireToken(request) {
7405
7612
  try {
7406
- const [authResponse, cacheOutcome] = await this.acquireCachedToken(request);
7613
+ const [authResponse, cacheOutcome] = await this.acquireCachedToken({
7614
+ ...request,
7615
+ scopes: request.scopes?.length
7616
+ ? request.scopes
7617
+ : [...OIDC_DEFAULT_SCOPES],
7618
+ });
7407
7619
  // if the token is not expired but must be refreshed; get a new one in the background
7408
7620
  if (cacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
7409
7621
  this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
@@ -7516,7 +7728,7 @@ class SilentFlowClient extends BaseClient {
7516
7728
  }
7517
7729
  }
7518
7730
 
7519
- /*! @azure/msal-common v14.7.0 2024-02-07 */
7731
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7520
7732
 
7521
7733
  /*
7522
7734
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7531,7 +7743,7 @@ const StubbedNetworkModule = {
7531
7743
  },
7532
7744
  };
7533
7745
 
7534
- /*! @azure/msal-common v14.7.0 2024-02-07 */
7746
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7535
7747
  /*
7536
7748
  * Copyright (c) Microsoft Corporation. All rights reserved.
7537
7749
  * Licensed under the MIT License.
@@ -7539,7 +7751,7 @@ const StubbedNetworkModule = {
7539
7751
  const missingKidError = "missing_kid_error";
7540
7752
  const missingAlgError = "missing_alg_error";
7541
7753
 
7542
- /*! @azure/msal-common v14.7.0 2024-02-07 */
7754
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7543
7755
 
7544
7756
  /*
7545
7757
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7564,7 +7776,7 @@ function createJoseHeaderError(code) {
7564
7776
  return new JoseHeaderError(code, JoseHeaderErrorMessages[code]);
7565
7777
  }
7566
7778
 
7567
- /*! @azure/msal-common v14.7.0 2024-02-07 */
7779
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7568
7780
 
7569
7781
  /*
7570
7782
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7604,7 +7816,7 @@ class JoseHeader {
7604
7816
  }
7605
7817
  }
7606
7818
 
7607
- /*! @azure/msal-common v14.7.0 2024-02-07 */
7819
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7608
7820
 
7609
7821
  /*
7610
7822
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7662,7 +7874,7 @@ class AuthenticationHeaderParser {
7662
7874
  }
7663
7875
  }
7664
7876
 
7665
- /*! @azure/msal-common v14.7.0 2024-02-07 */
7877
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7666
7878
 
7667
7879
  /*
7668
7880
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7866,7 +8078,7 @@ class ServerTelemetryManager {
7866
8078
  }
7867
8079
  }
7868
8080
 
7869
- /*! @azure/msal-common v14.7.0 2024-02-07 */
8081
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7870
8082
 
7871
8083
  /*
7872
8084
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7945,12 +8157,168 @@ class StubPerformanceClient {
7945
8157
  }
7946
8158
  }
7947
8159
 
7948
- /*! @azure/msal-common v14.7.0 2024-02-07 */
8160
+ /*! @azure/msal-common v14.8.0 2024-03-22 */
7949
8161
 
7950
8162
  /*
7951
8163
  * Copyright (c) Microsoft Corporation. All rights reserved.
7952
8164
  * Licensed under the MIT License.
7953
8165
  */
8166
+ /**
8167
+ * Starts context by adding payload to the stack
8168
+ * @param event {PerformanceEvent}
8169
+ * @param abbreviations {Map<string, string>} event name abbreviations
8170
+ * @param stack {?PerformanceEventStackedContext[]} stack
8171
+ */
8172
+ function startContext(event, abbreviations, stack) {
8173
+ if (!stack) {
8174
+ return;
8175
+ }
8176
+ stack.push({
8177
+ name: abbreviations.get(event.name) || event.name,
8178
+ });
8179
+ }
8180
+ /**
8181
+ * Ends context by removing payload from the stack and returning parent or self, if stack is empty, payload
8182
+ *
8183
+ * @param event {PerformanceEvent}
8184
+ * @param abbreviations {Map<string, string>} event name abbreviations
8185
+ * @param stack {?PerformanceEventStackedContext[]} stack
8186
+ * @param error {?unknown} error
8187
+ */
8188
+ function endContext(event, abbreviations, stack, error) {
8189
+ if (!stack?.length) {
8190
+ return;
8191
+ }
8192
+ const peek = (stack) => {
8193
+ return stack.length ? stack[stack.length - 1] : undefined;
8194
+ };
8195
+ const abbrEventName = abbreviations.get(event.name) || event.name;
8196
+ const top = peek(stack);
8197
+ if (top?.name !== abbrEventName) {
8198
+ return;
8199
+ }
8200
+ const current = stack?.pop();
8201
+ if (!current) {
8202
+ return;
8203
+ }
8204
+ const errorCode = error instanceof AuthError
8205
+ ? error.errorCode
8206
+ : error instanceof Error
8207
+ ? error.name
8208
+ : undefined;
8209
+ const subErr = error instanceof AuthError ? error.subError : undefined;
8210
+ if (errorCode && current.childErr !== errorCode) {
8211
+ current.err = errorCode;
8212
+ if (subErr) {
8213
+ current.subErr = subErr;
8214
+ }
8215
+ }
8216
+ delete current.name;
8217
+ delete current.childErr;
8218
+ const context = {
8219
+ ...current,
8220
+ dur: event.durationMs,
8221
+ };
8222
+ if (!event.success) {
8223
+ context.fail = 1;
8224
+ }
8225
+ const parent = peek(stack);
8226
+ if (!parent) {
8227
+ return { [abbrEventName]: context };
8228
+ }
8229
+ if (errorCode) {
8230
+ parent.childErr = errorCode;
8231
+ }
8232
+ let childName;
8233
+ if (!parent[abbrEventName]) {
8234
+ childName = abbrEventName;
8235
+ }
8236
+ else {
8237
+ const siblings = Object.keys(parent).filter((key) => key.startsWith(abbrEventName)).length;
8238
+ childName = `${abbrEventName}_${siblings + 1}`;
8239
+ }
8240
+ parent[childName] = context;
8241
+ return parent;
8242
+ }
8243
+ /**
8244
+ * Adds error name and stack trace to the telemetry event
8245
+ * @param error {Error}
8246
+ * @param logger {Logger}
8247
+ * @param event {PerformanceEvent}
8248
+ * @param stackMaxSize {number} max error stack size to capture
8249
+ */
8250
+ function addError(error, logger, event, stackMaxSize = 5) {
8251
+ if (!(error instanceof Error)) {
8252
+ logger.trace("PerformanceClient.addErrorStack: Input error is not instance of Error", event.correlationId);
8253
+ return;
8254
+ }
8255
+ else if (error instanceof AuthError) {
8256
+ event.errorCode = error.errorCode;
8257
+ event.subErrorCode = error.subError;
8258
+ return;
8259
+ }
8260
+ else if (event.errorStack?.length) {
8261
+ logger.trace("PerformanceClient.addErrorStack: Stack already exist", event.correlationId);
8262
+ return;
8263
+ }
8264
+ else if (!error.stack?.length) {
8265
+ logger.trace("PerformanceClient.addErrorStack: Input stack is empty", event.correlationId);
8266
+ return;
8267
+ }
8268
+ if (error.stack) {
8269
+ event.errorStack = compactStack(error.stack, stackMaxSize);
8270
+ }
8271
+ event.errorName = error.name;
8272
+ }
8273
+ /**
8274
+ * Compacts error stack into array by fetching N first entries
8275
+ * @param stack {string} error stack
8276
+ * @param stackMaxSize {number} max error stack size to capture
8277
+ * @returns {string[]}
8278
+ */
8279
+ function compactStack(stack, stackMaxSize) {
8280
+ if (stackMaxSize < 0) {
8281
+ return [];
8282
+ }
8283
+ const stackArr = stack.split("\n") || [];
8284
+ if (stackArr.length < 2) {
8285
+ return [];
8286
+ }
8287
+ const res = [];
8288
+ // Get top N stack lines
8289
+ for (
8290
+ // Skip first line as it may contain PII data
8291
+ let ix = Math.max(stackArr.length - stackMaxSize - 1, 1); ix < stackArr.length; ix++) {
8292
+ const line = stackArr[ix];
8293
+ if (res.length >= stackMaxSize) {
8294
+ break;
8295
+ }
8296
+ res.push(compactStackLine(line));
8297
+ }
8298
+ return res;
8299
+ }
8300
+ /**
8301
+ * Compacts error stack line by shortening file path
8302
+ * Example: https://localhost/msal-common/src/authority/Authority.js:100:1 -> Authority.js:100:1
8303
+ * @param line {string} stack line
8304
+ * @returns {string}
8305
+ */
8306
+ function compactStackLine(line) {
8307
+ const filePathIx = line.lastIndexOf(" ") + 1;
8308
+ if (filePathIx < 1) {
8309
+ return line;
8310
+ }
8311
+ const filePath = line.substring(filePathIx);
8312
+ let fileNameIx = filePath.lastIndexOf("/");
8313
+ fileNameIx = fileNameIx < 0 ? filePath.lastIndexOf("\\") : fileNameIx;
8314
+ if (fileNameIx >= 0) {
8315
+ return (line.substring(0, filePathIx) +
8316
+ "(" +
8317
+ filePath.substring(fileNameIx + 1) +
8318
+ (filePath.charAt(filePath.length - 1) === ")" ? "" : ")")).trimStart();
8319
+ }
8320
+ return line.trimStart();
8321
+ }
7954
8322
  class PerformanceClient {
7955
8323
  /**
7956
8324
  * Creates an instance of PerformanceClient,
@@ -7964,8 +8332,9 @@ class PerformanceClient {
7964
8332
  * @param {string} libraryVersion Version of the library
7965
8333
  * @param {ApplicationTelemetry} applicationTelemetry application name and version
7966
8334
  * @param {Set<String>} intFields integer fields to be truncated
8335
+ * @param {Map<string, string>} abbreviations event name abbreviations
7967
8336
  */
7968
- constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields) {
8337
+ constructor(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, intFields, abbreviations) {
7969
8338
  this.authority = authority;
7970
8339
  this.libraryName = libraryName;
7971
8340
  this.libraryVersion = libraryVersion;
@@ -7974,12 +8343,17 @@ class PerformanceClient {
7974
8343
  this.logger = logger;
7975
8344
  this.callbacks = new Map();
7976
8345
  this.eventsByCorrelationId = new Map();
8346
+ this.eventStack = new Map();
7977
8347
  this.queueMeasurements = new Map();
7978
8348
  this.preQueueTimeByCorrelationId = new Map();
7979
8349
  this.intFields = intFields || new Set();
7980
8350
  for (const item of IntFields) {
7981
8351
  this.intFields.add(item);
7982
8352
  }
8353
+ this.abbreviations = abbreviations || new Map();
8354
+ for (const [key, value] of PerformanceEventAbbreviations) {
8355
+ this.abbreviations.set(key, value);
8356
+ }
7983
8357
  }
7984
8358
  /**
7985
8359
  * Starts and returns an platform-specific implementation of IPerformanceMeasurement.
@@ -8109,15 +8483,16 @@ class PerformanceClient {
8109
8483
  };
8110
8484
  // Store in progress events so they can be discarded if not ended properly
8111
8485
  this.cacheEventByCorrelationId(inProgressEvent);
8486
+ startContext(inProgressEvent, this.abbreviations, this.eventStack.get(eventCorrelationId));
8112
8487
  // Return the event and functions the caller can use to properly end/flush the measurement
8113
8488
  return {
8114
- end: (event) => {
8489
+ end: (event, error) => {
8115
8490
  return this.endMeasurement({
8116
8491
  // Initial set of event properties
8117
8492
  ...inProgressEvent,
8118
8493
  // Properties set when event ends
8119
8494
  ...event,
8120
- });
8495
+ }, error);
8121
8496
  },
8122
8497
  discard: () => {
8123
8498
  return this.discardMeasurements(inProgressEvent.correlationId);
@@ -8139,10 +8514,10 @@ class PerformanceClient {
8139
8514
  * otherwise.
8140
8515
  *
8141
8516
  * @param {PerformanceEvent} event
8142
- * @param {IPerformanceMeasurement} measurement
8517
+ * @param {unknown} error
8143
8518
  * @returns {(PerformanceEvent | null)}
8144
8519
  */
8145
- endMeasurement(event) {
8520
+ endMeasurement(event, error) {
8146
8521
  const rootEvent = this.eventsByCorrelationId.get(event.correlationId);
8147
8522
  if (!rootEvent) {
8148
8523
  this.logger.trace(`PerformanceClient: Measurement not found for ${event.eventId}`, event.correlationId);
@@ -8154,6 +8529,8 @@ class PerformanceClient {
8154
8529
  totalQueueCount: 0,
8155
8530
  manuallyCompletedCount: 0,
8156
8531
  };
8532
+ event.durationMs = Math.round(event.durationMs || this.getDurationMs(event.startTimeMs));
8533
+ const context = endContext(event, this.abbreviations, this.eventStack.get(rootEvent.correlationId), error);
8157
8534
  if (isRoot) {
8158
8535
  queueInfo = this.getQueueInfo(event.correlationId);
8159
8536
  this.discardCache(rootEvent.correlationId);
@@ -8161,13 +8538,15 @@ class PerformanceClient {
8161
8538
  else {
8162
8539
  rootEvent.incompleteSubMeasurements?.delete(event.eventId);
8163
8540
  }
8164
- const durationMs = event.durationMs || this.getDurationMs(event.startTimeMs);
8165
- this.logger.trace(`PerformanceClient: Performance measurement ended for ${event.name}: ${durationMs} ms`, event.correlationId);
8541
+ this.logger.trace(`PerformanceClient: Performance measurement ended for ${event.name}: ${event.durationMs} ms`, event.correlationId);
8166
8542
  // Add sub-measurement attribute to root event.
8167
8543
  if (!isRoot) {
8168
- rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
8544
+ rootEvent[event.name + "DurationMs"] = Math.floor(event.durationMs);
8169
8545
  return { ...rootEvent };
8170
8546
  }
8547
+ if (error) {
8548
+ addError(error, this.logger, rootEvent);
8549
+ }
8171
8550
  let finalEvent = { ...rootEvent, ...event };
8172
8551
  let incompleteSubsCount = 0;
8173
8552
  // Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
@@ -8178,12 +8557,12 @@ class PerformanceClient {
8178
8557
  finalEvent.incompleteSubMeasurements = undefined;
8179
8558
  finalEvent = {
8180
8559
  ...finalEvent,
8181
- durationMs: Math.round(durationMs),
8182
8560
  queuedTimeMs: queueInfo.totalQueueTime,
8183
8561
  queuedCount: queueInfo.totalQueueCount,
8184
8562
  queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount,
8185
8563
  status: PerformanceEventStatus.Completed,
8186
8564
  incompleteSubsCount,
8565
+ context,
8187
8566
  };
8188
8567
  this.truncateIntegralFields(finalEvent);
8189
8568
  this.emitEvents([finalEvent], event.correlationId);
@@ -8253,6 +8632,7 @@ class PerformanceClient {
8253
8632
  else {
8254
8633
  this.logger.trace(`PerformanceClient: Performance measurement for ${event.name} started`, event.correlationId);
8255
8634
  this.eventsByCorrelationId.set(event.correlationId, { ...event });
8635
+ this.eventStack.set(event.correlationId, []);
8256
8636
  }
8257
8637
  }
8258
8638
  getQueueInfo(correlationId) {
@@ -8294,6 +8674,8 @@ class PerformanceClient {
8294
8674
  this.queueMeasurements.delete(correlationId);
8295
8675
  this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
8296
8676
  this.preQueueTimeByCorrelationId.delete(correlationId);
8677
+ this.logger.trace("PerformanceClient: Event stack discarded", correlationId);
8678
+ this.eventStack.delete(correlationId);
8297
8679
  }
8298
8680
  /**
8299
8681
  * Registers a callback function to receive performance events.
@@ -8339,7 +8721,6 @@ class PerformanceClient {
8339
8721
  /**
8340
8722
  * Enforce truncation of integral fields in performance event.
8341
8723
  * @param {PerformanceEvent} event performance event to update.
8342
- * @param {Set<string>} intFields integral fields.
8343
8724
  */
8344
8725
  truncateIntegralFields(event) {
8345
8726
  this.intFields.forEach((key) => {
@@ -8936,114 +9317,391 @@ const BROWSER_PERF_ENABLED_KEY = "msal.browser.performance.enabled";
8936
9317
  * Licensed under the MIT License.
8937
9318
  */
8938
9319
  /**
8939
- * Clears hash from window url.
9320
+ * Class which exposes APIs to encode plaintext to base64 encoded string. See here for implementation details:
9321
+ * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_2_%E2%80%93_JavaScript's_UTF-16_%3E_UTF-8_%3E_base64
8940
9322
  */
8941
- function clearHash(contentWindow) {
8942
- // Office.js sets history.replaceState to null
8943
- contentWindow.location.hash = "";
8944
- if (typeof contentWindow.history.replaceState === "function") {
8945
- // Full removes "#" from url
8946
- contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`);
8947
- }
8948
- }
8949
9323
  /**
8950
- * Replaces current hash with hash from provided url
9324
+ * Returns URL Safe b64 encoded string from a plaintext string.
9325
+ * @param input
8951
9326
  */
8952
- function replaceHash(url) {
8953
- const urlParts = url.split("#");
8954
- urlParts.shift(); // Remove part before the hash
8955
- window.location.hash = urlParts.length > 0 ? urlParts.join("#") : "";
9327
+ function urlEncode(input) {
9328
+ return encodeURIComponent(base64Encode(input)
9329
+ .replace(/=/g, "")
9330
+ .replace(/\+/g, "-")
9331
+ .replace(/\//g, "_"));
8956
9332
  }
8957
9333
  /**
8958
- * Returns boolean of whether the current window is in an iframe or not.
9334
+ * Returns URL Safe b64 encoded string from an int8Array.
9335
+ * @param inputArr
8959
9336
  */
8960
- function isInIframe() {
8961
- return window.parent !== window;
9337
+ function urlEncodeArr(inputArr) {
9338
+ return base64EncArr(inputArr)
9339
+ .replace(/=/g, "")
9340
+ .replace(/\+/g, "-")
9341
+ .replace(/\//g, "_");
8962
9342
  }
8963
9343
  /**
8964
- * Returns boolean of whether or not the current window is a popup opened by msal
9344
+ * Returns b64 encoded string from plaintext string.
9345
+ * @param input
8965
9346
  */
8966
- function isInPopup() {
8967
- return (typeof window !== "undefined" &&
8968
- !!window.opener &&
8969
- window.opener !== window &&
8970
- typeof window.name === "string" &&
8971
- window.name.indexOf(`${BrowserConstants.POPUP_NAME_PREFIX}.`) === 0);
9347
+ function base64Encode(input) {
9348
+ return base64EncArr(new TextEncoder().encode(input));
8972
9349
  }
8973
- // #endregion
8974
9350
  /**
8975
- * Returns current window URL as redirect uri
9351
+ * Base64 encode byte array
9352
+ * @param aBytes
8976
9353
  */
8977
- function getCurrentUri() {
8978
- return window.location.href.split("?")[0].split("#")[0];
9354
+ function base64EncArr(aBytes) {
9355
+ const binString = Array.from(aBytes, (x) => String.fromCodePoint(x)).join("");
9356
+ return btoa(binString);
8979
9357
  }
9358
+
9359
+ /*
9360
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9361
+ * Licensed under the MIT License.
9362
+ */
8980
9363
  /**
8981
- * Gets the homepage url for the current window location.
9364
+ * This file defines functions used by the browser library to perform cryptography operations such as
9365
+ * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
8982
9366
  */
8983
- function getHomepage() {
8984
- const currentUrl = new UrlString(window.location.href);
8985
- const urlComponents = currentUrl.getUrlComponents();
8986
- return `${urlComponents.Protocol}//${urlComponents.HostNameAndPort}/`;
8987
- }
8988
9367
  /**
8989
- * Throws error if we have completed an auth and are
8990
- * attempting another auth request inside an iframe.
9368
+ * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
8991
9369
  */
8992
- function blockReloadInHiddenIframes() {
8993
- const isResponseHash = UrlString.hashContainsKnownProperties(window.location.hash);
8994
- // return an error if called from the hidden iframe created by the msal js silent calls
8995
- if (isResponseHash && isInIframe()) {
8996
- throw createBrowserAuthError(blockIframeReload);
8997
- }
8998
- }
9370
+ // RSA KeyGen Algorithm
9371
+ const PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
9372
+ // SHA-256 hashing algorithm
9373
+ const S256_HASH_ALG = "SHA-256";
9374
+ // MOD length for PoP tokens
9375
+ const MODULUS_LENGTH = 2048;
9376
+ // Public Exponent
9377
+ const PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
9378
+ // UUID hex digits
9379
+ const UUID_CHARS = "0123456789abcdef";
9380
+ // Array to store UINT32 random value
9381
+ const UINT32_ARR = new Uint32Array(1);
9382
+ const keygenAlgorithmOptions = {
9383
+ name: PKCS1_V15_KEYGEN_ALG,
9384
+ hash: S256_HASH_ALG,
9385
+ modulusLength: MODULUS_LENGTH,
9386
+ publicExponent: PUBLIC_EXPONENT,
9387
+ };
8999
9388
  /**
9000
- * Block redirect operations in iframes unless explicitly allowed
9001
- * @param interactionType Interaction type for the request
9002
- * @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
9389
+ * Check whether browser crypto is available.
9003
9390
  */
9004
- function blockRedirectInIframe(interactionType, allowRedirectInIframe) {
9005
- const isIframedApp = isInIframe();
9006
- if (interactionType === exports.InteractionType.Redirect &&
9007
- isIframedApp &&
9008
- !allowRedirectInIframe) {
9009
- // If we are not in top frame, we shouldn't redirect. This is also handled by the service.
9010
- throw createBrowserAuthError(redirectInIframe);
9391
+ function validateCryptoAvailable(logger) {
9392
+ if ("crypto" in window) {
9393
+ logger.verbose("BrowserCrypto: modern crypto interface available");
9394
+ }
9395
+ else {
9396
+ logger.error("BrowserCrypto: crypto interface is unavailable");
9397
+ throw createBrowserAuthError(cryptoNonExistent);
9011
9398
  }
9012
9399
  }
9013
9400
  /**
9014
- * Block redirectUri loaded in popup from calling AcquireToken APIs
9401
+ * Returns a sha-256 hash of the given dataString as an ArrayBuffer.
9402
+ * @param dataString {string} data string
9403
+ * @param performanceClient {?IPerformanceClient}
9404
+ * @param correlationId {?string} correlation id
9015
9405
  */
9016
- function blockAcquireTokenInPopups() {
9017
- // Popups opened by msal popup APIs are given a name that starts with "msal."
9018
- if (isInPopup()) {
9019
- throw createBrowserAuthError(blockNestedPopups);
9020
- }
9406
+ async function sha256Digest(dataString, performanceClient, correlationId) {
9407
+ performanceClient?.addQueueMeasurement(PerformanceEvents.Sha256Digest, correlationId);
9408
+ const encoder = new TextEncoder();
9409
+ const data = encoder.encode(dataString);
9410
+ return window.crypto.subtle.digest(S256_HASH_ALG, data);
9021
9411
  }
9022
9412
  /**
9023
- * Throws error if token requests are made in non-browser environment
9024
- * @param isBrowserEnvironment Flag indicating if environment is a browser.
9413
+ * Populates buffer with cryptographically random values.
9414
+ * @param dataBuffer
9025
9415
  */
9026
- function blockNonBrowserEnvironment(isBrowserEnvironment) {
9027
- if (!isBrowserEnvironment) {
9028
- throw createBrowserAuthError(nonBrowserEnvironment);
9029
- }
9416
+ function getRandomValues(dataBuffer) {
9417
+ return window.crypto.getRandomValues(dataBuffer);
9030
9418
  }
9031
9419
  /**
9032
- * Throws error if initialize hasn't been called
9033
- * @param initialized
9420
+ * Returns random Uint32 value.
9421
+ * @returns {number}
9034
9422
  */
9035
- function blockAPICallsBeforeInitialize(initialized) {
9036
- if (!initialized) {
9037
- throw createBrowserAuthError(uninitializedPublicClientApplication);
9038
- }
9423
+ function getRandomUint32() {
9424
+ window.crypto.getRandomValues(UINT32_ARR);
9425
+ return UINT32_ARR[0];
9039
9426
  }
9040
9427
  /**
9041
- * Adds a preconnect link element to the header which begins DNS resolution and SSL connection in anticipation of the /token request
9042
- * @param loginDomain Authority domain, including https protocol e.g. https://login.microsoftonline.com
9043
- * @returns
9428
+ * Creates a UUID v7 from the current timestamp.
9429
+ * Implementation relies on the system clock to guarantee increasing order of generated identifiers.
9430
+ * @returns {number}
9044
9431
  */
9045
- function preconnect(authority) {
9046
- const link = document.createElement("link");
9432
+ function createNewGuid() {
9433
+ const currentTimestamp = Date.now();
9434
+ const baseRand = getRandomUint32() * 0x400 + (getRandomUint32() & 0x3ff);
9435
+ // Result byte array
9436
+ const bytes = new Uint8Array(16);
9437
+ // A 12-bit `rand_a` field value
9438
+ const randA = Math.trunc(baseRand / 2 ** 30);
9439
+ // The higher 30 bits of 62-bit `rand_b` field value
9440
+ const randBHi = baseRand & (2 ** 30 - 1);
9441
+ // The lower 32 bits of 62-bit `rand_b` field value
9442
+ const randBLo = getRandomUint32();
9443
+ bytes[0] = currentTimestamp / 2 ** 40;
9444
+ bytes[1] = currentTimestamp / 2 ** 32;
9445
+ bytes[2] = currentTimestamp / 2 ** 24;
9446
+ bytes[3] = currentTimestamp / 2 ** 16;
9447
+ bytes[4] = currentTimestamp / 2 ** 8;
9448
+ bytes[5] = currentTimestamp;
9449
+ bytes[6] = 0x70 | (randA >>> 8);
9450
+ bytes[7] = randA;
9451
+ bytes[8] = 0x80 | (randBHi >>> 24);
9452
+ bytes[9] = randBHi >>> 16;
9453
+ bytes[10] = randBHi >>> 8;
9454
+ bytes[11] = randBHi;
9455
+ bytes[12] = randBLo >>> 24;
9456
+ bytes[13] = randBLo >>> 16;
9457
+ bytes[14] = randBLo >>> 8;
9458
+ bytes[15] = randBLo;
9459
+ let text = "";
9460
+ for (let i = 0; i < bytes.length; i++) {
9461
+ text += UUID_CHARS.charAt(bytes[i] >>> 4);
9462
+ text += UUID_CHARS.charAt(bytes[i] & 0xf);
9463
+ if (i === 3 || i === 5 || i === 7 || i === 9) {
9464
+ text += "-";
9465
+ }
9466
+ }
9467
+ return text;
9468
+ }
9469
+ /**
9470
+ * Generates a keypair based on current keygen algorithm config.
9471
+ * @param extractable
9472
+ * @param usages
9473
+ */
9474
+ async function generateKeyPair(extractable, usages) {
9475
+ return window.crypto.subtle.generateKey(keygenAlgorithmOptions, extractable, usages);
9476
+ }
9477
+ /**
9478
+ * Export key as Json Web Key (JWK)
9479
+ * @param key
9480
+ */
9481
+ async function exportJwk(key) {
9482
+ return window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key);
9483
+ }
9484
+ /**
9485
+ * Imports key as Json Web Key (JWK), can set extractable and usages.
9486
+ * @param key
9487
+ * @param extractable
9488
+ * @param usages
9489
+ */
9490
+ async function importJwk(key, extractable, usages) {
9491
+ return window.crypto.subtle.importKey(KEY_FORMAT_JWK, key, keygenAlgorithmOptions, extractable, usages);
9492
+ }
9493
+ /**
9494
+ * Signs given data with given key
9495
+ * @param key
9496
+ * @param data
9497
+ */
9498
+ async function sign(key, data) {
9499
+ return window.crypto.subtle.sign(keygenAlgorithmOptions, key, data);
9500
+ }
9501
+ /**
9502
+ * Returns the SHA-256 hash of an input string
9503
+ * @param plainText
9504
+ */
9505
+ async function hashString(plainText) {
9506
+ const hashBuffer = await sha256Digest(plainText);
9507
+ const hashBytes = new Uint8Array(hashBuffer);
9508
+ return urlEncodeArr(hashBytes);
9509
+ }
9510
+
9511
+ /*
9512
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9513
+ * Licensed under the MIT License.
9514
+ */
9515
+ const storageNotSupported = "storage_not_supported";
9516
+ const stubbedPublicClientApplicationCalled = "stubbed_public_client_application_called";
9517
+ const inMemRedirectUnavailable = "in_mem_redirect_unavailable";
9518
+
9519
+ var BrowserConfigurationAuthErrorCodes = /*#__PURE__*/Object.freeze({
9520
+ __proto__: null,
9521
+ inMemRedirectUnavailable: inMemRedirectUnavailable,
9522
+ storageNotSupported: storageNotSupported,
9523
+ stubbedPublicClientApplicationCalled: stubbedPublicClientApplicationCalled
9524
+ });
9525
+
9526
+ /*
9527
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9528
+ * Licensed under the MIT License.
9529
+ */
9530
+ const BrowserConfigurationAuthErrorMessages = {
9531
+ [storageNotSupported]: "Given storage configuration option was not supported.",
9532
+ [stubbedPublicClientApplicationCalled]: "Stub instance of Public Client Application was called. If using msal-react, please ensure context is not used without a provider. For more visit: aka.ms/msaljs/browser-errors",
9533
+ [inMemRedirectUnavailable]: "Redirect cannot be supported. In-memory storage was selected and storeAuthStateInCookie=false, which would cause the library to be unable to handle the incoming hash. If you would like to use the redirect API, please use session/localStorage or set storeAuthStateInCookie=true.",
9534
+ };
9535
+ /**
9536
+ * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
9537
+ * @deprecated Use BrowserAuthErrorCodes instead
9538
+ */
9539
+ const BrowserConfigurationAuthErrorMessage = {
9540
+ storageNotSupportedError: {
9541
+ code: storageNotSupported,
9542
+ desc: BrowserConfigurationAuthErrorMessages[storageNotSupported],
9543
+ },
9544
+ stubPcaInstanceCalled: {
9545
+ code: stubbedPublicClientApplicationCalled,
9546
+ desc: BrowserConfigurationAuthErrorMessages[stubbedPublicClientApplicationCalled],
9547
+ },
9548
+ inMemRedirectUnavailable: {
9549
+ code: inMemRedirectUnavailable,
9550
+ desc: BrowserConfigurationAuthErrorMessages[inMemRedirectUnavailable],
9551
+ },
9552
+ };
9553
+ /**
9554
+ * Browser library error class thrown by the MSAL.js library for SPAs
9555
+ */
9556
+ class BrowserConfigurationAuthError extends AuthError {
9557
+ constructor(errorCode, errorMessage) {
9558
+ super(errorCode, errorMessage);
9559
+ this.name = "BrowserConfigurationAuthError";
9560
+ Object.setPrototypeOf(this, BrowserConfigurationAuthError.prototype);
9561
+ }
9562
+ }
9563
+ function createBrowserConfigurationAuthError(errorCode) {
9564
+ return new BrowserConfigurationAuthError(errorCode, BrowserConfigurationAuthErrorMessages[errorCode]);
9565
+ }
9566
+
9567
+ /*
9568
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9569
+ * Licensed under the MIT License.
9570
+ */
9571
+ /**
9572
+ * Clears hash from window url.
9573
+ */
9574
+ function clearHash(contentWindow) {
9575
+ // Office.js sets history.replaceState to null
9576
+ contentWindow.location.hash = "";
9577
+ if (typeof contentWindow.history.replaceState === "function") {
9578
+ // Full removes "#" from url
9579
+ contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`);
9580
+ }
9581
+ }
9582
+ /**
9583
+ * Replaces current hash with hash from provided url
9584
+ */
9585
+ function replaceHash(url) {
9586
+ const urlParts = url.split("#");
9587
+ urlParts.shift(); // Remove part before the hash
9588
+ window.location.hash = urlParts.length > 0 ? urlParts.join("#") : "";
9589
+ }
9590
+ /**
9591
+ * Returns boolean of whether the current window is in an iframe or not.
9592
+ */
9593
+ function isInIframe() {
9594
+ return window.parent !== window;
9595
+ }
9596
+ /**
9597
+ * Returns boolean of whether or not the current window is a popup opened by msal
9598
+ */
9599
+ function isInPopup() {
9600
+ return (typeof window !== "undefined" &&
9601
+ !!window.opener &&
9602
+ window.opener !== window &&
9603
+ typeof window.name === "string" &&
9604
+ window.name.indexOf(`${BrowserConstants.POPUP_NAME_PREFIX}.`) === 0);
9605
+ }
9606
+ // #endregion
9607
+ /**
9608
+ * Returns current window URL as redirect uri
9609
+ */
9610
+ function getCurrentUri() {
9611
+ return window.location.href.split("?")[0].split("#")[0];
9612
+ }
9613
+ /**
9614
+ * Gets the homepage url for the current window location.
9615
+ */
9616
+ function getHomepage() {
9617
+ const currentUrl = new UrlString(window.location.href);
9618
+ const urlComponents = currentUrl.getUrlComponents();
9619
+ return `${urlComponents.Protocol}//${urlComponents.HostNameAndPort}/`;
9620
+ }
9621
+ /**
9622
+ * Throws error if we have completed an auth and are
9623
+ * attempting another auth request inside an iframe.
9624
+ */
9625
+ function blockReloadInHiddenIframes() {
9626
+ const isResponseHash = UrlString.hashContainsKnownProperties(window.location.hash);
9627
+ // return an error if called from the hidden iframe created by the msal js silent calls
9628
+ if (isResponseHash && isInIframe()) {
9629
+ throw createBrowserAuthError(blockIframeReload);
9630
+ }
9631
+ }
9632
+ /**
9633
+ * Block redirect operations in iframes unless explicitly allowed
9634
+ * @param interactionType Interaction type for the request
9635
+ * @param allowRedirectInIframe Config value to allow redirects when app is inside an iframe
9636
+ */
9637
+ function blockRedirectInIframe(allowRedirectInIframe) {
9638
+ if (isInIframe() && !allowRedirectInIframe) {
9639
+ // If we are not in top frame, we shouldn't redirect. This is also handled by the service.
9640
+ throw createBrowserAuthError(redirectInIframe);
9641
+ }
9642
+ }
9643
+ /**
9644
+ * Block redirectUri loaded in popup from calling AcquireToken APIs
9645
+ */
9646
+ function blockAcquireTokenInPopups() {
9647
+ // Popups opened by msal popup APIs are given a name that starts with "msal."
9648
+ if (isInPopup()) {
9649
+ throw createBrowserAuthError(blockNestedPopups);
9650
+ }
9651
+ }
9652
+ /**
9653
+ * Throws error if token requests are made in non-browser environment
9654
+ * @param isBrowserEnvironment Flag indicating if environment is a browser.
9655
+ */
9656
+ function blockNonBrowserEnvironment() {
9657
+ if (typeof window === "undefined") {
9658
+ throw createBrowserAuthError(nonBrowserEnvironment);
9659
+ }
9660
+ }
9661
+ /**
9662
+ * Throws error if initialize hasn't been called
9663
+ * @param initialized
9664
+ */
9665
+ function blockAPICallsBeforeInitialize(initialized) {
9666
+ if (!initialized) {
9667
+ throw createBrowserAuthError(uninitializedPublicClientApplication);
9668
+ }
9669
+ }
9670
+ /**
9671
+ * Helper to validate app environment before making an auth request
9672
+ * @param initialized
9673
+ */
9674
+ function preflightCheck(initialized) {
9675
+ // Block request if not in browser environment
9676
+ blockNonBrowserEnvironment();
9677
+ // Block auth requests inside a hidden iframe
9678
+ blockReloadInHiddenIframes();
9679
+ // Block redirectUri opened in a popup from calling MSAL APIs
9680
+ blockAcquireTokenInPopups();
9681
+ // Block token acquisition before initialize has been called
9682
+ blockAPICallsBeforeInitialize(initialized);
9683
+ }
9684
+ /**
9685
+ * Helper to validate app enviornment before making redirect request
9686
+ * @param initialized
9687
+ * @param config
9688
+ */
9689
+ function redirectPreflightCheck(initialized, config) {
9690
+ preflightCheck(initialized);
9691
+ blockRedirectInIframe(config.system.allowRedirectInIframe);
9692
+ // Block redirects if memory storage is enabled but storeAuthStateInCookie is not
9693
+ if (config.cache.cacheLocation === BrowserCacheLocation.MemoryStorage &&
9694
+ !config.cache.storeAuthStateInCookie) {
9695
+ throw createBrowserConfigurationAuthError(inMemRedirectUnavailable);
9696
+ }
9697
+ }
9698
+ /**
9699
+ * Adds a preconnect link element to the header which begins DNS resolution and SSL connection in anticipation of the /token request
9700
+ * @param loginDomain Authority domain, including https protocol e.g. https://login.microsoftonline.com
9701
+ * @returns
9702
+ */
9703
+ function preconnect(authority) {
9704
+ const link = document.createElement("link");
9047
9705
  link.rel = "preconnect";
9048
9706
  link.href = new URL(authority).origin;
9049
9707
  link.crossOrigin = "anonymous";
@@ -9056,6 +9714,13 @@ function preconnect(authority) {
9056
9714
  catch { }
9057
9715
  }, 10000); // 10s Timeout
9058
9716
  }
9717
+ /**
9718
+ * Wrapper function that creates a UUID v7 from the current timestamp.
9719
+ * @returns {string}
9720
+ */
9721
+ function createGuid() {
9722
+ return createNewGuid();
9723
+ }
9059
9724
 
9060
9725
  var BrowserUtils = /*#__PURE__*/Object.freeze({
9061
9726
  __proto__: null,
@@ -9065,11 +9730,14 @@ var BrowserUtils = /*#__PURE__*/Object.freeze({
9065
9730
  blockRedirectInIframe: blockRedirectInIframe,
9066
9731
  blockReloadInHiddenIframes: blockReloadInHiddenIframes,
9067
9732
  clearHash: clearHash,
9733
+ createGuid: createGuid,
9068
9734
  getCurrentUri: getCurrentUri,
9069
9735
  getHomepage: getHomepage,
9070
9736
  isInIframe: isInIframe,
9071
9737
  isInPopup: isInPopup,
9072
9738
  preconnect: preconnect,
9739
+ preflightCheck: preflightCheck,
9740
+ redirectPreflightCheck: redirectPreflightCheck,
9073
9741
  replaceHash: replaceHash
9074
9742
  });
9075
9743
 
@@ -9345,7 +10013,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
9345
10013
 
9346
10014
  /* eslint-disable header/header */
9347
10015
  const name = "@azure/msal-browser";
9348
- const version = "3.9.0";
10016
+ const version = "3.11.0";
9349
10017
 
9350
10018
  /*
9351
10019
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9771,50 +10439,6 @@ async function createController(config) {
9771
10439
  }
9772
10440
  }
9773
10441
 
9774
- /*
9775
- * Copyright (c) Microsoft Corporation. All rights reserved.
9776
- * Licensed under the MIT License.
9777
- */
9778
- /**
9779
- * Class which exposes APIs to encode plaintext to base64 encoded string. See here for implementation details:
9780
- * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_2_%E2%80%93_JavaScript's_UTF-16_%3E_UTF-8_%3E_base64
9781
- */
9782
- /**
9783
- * Returns URL Safe b64 encoded string from a plaintext string.
9784
- * @param input
9785
- */
9786
- function urlEncode(input) {
9787
- return encodeURIComponent(base64Encode(input)
9788
- .replace(/=/g, "")
9789
- .replace(/\+/g, "-")
9790
- .replace(/\//g, "_"));
9791
- }
9792
- /**
9793
- * Returns URL Safe b64 encoded string from an int8Array.
9794
- * @param inputArr
9795
- */
9796
- function urlEncodeArr(inputArr) {
9797
- return base64EncArr(inputArr)
9798
- .replace(/=/g, "")
9799
- .replace(/\+/g, "-")
9800
- .replace(/\//g, "_");
9801
- }
9802
- /**
9803
- * Returns b64 encoded string from plaintext string.
9804
- * @param input
9805
- */
9806
- function base64Encode(input) {
9807
- return base64EncArr(new TextEncoder().encode(input));
9808
- }
9809
- /**
9810
- * Base64 encode byte array
9811
- * @param aBytes
9812
- */
9813
- function base64EncArr(aBytes) {
9814
- const binString = Array.from(aBytes, (x) => String.fromCodePoint(x)).join("");
9815
- return btoa(binString);
9816
- }
9817
-
9818
10442
  /*
9819
10443
  * Copyright (c) Microsoft Corporation. All rights reserved.
9820
10444
  * Licensed under the MIT License.
@@ -9852,149 +10476,6 @@ function base64DecToArr(base64String) {
9852
10476
  return Uint8Array.from(binString, (m) => m.codePointAt(0) || 0);
9853
10477
  }
9854
10478
 
9855
- /*
9856
- * Copyright (c) Microsoft Corporation. All rights reserved.
9857
- * Licensed under the MIT License.
9858
- */
9859
- /**
9860
- * This file defines functions used by the browser library to perform cryptography operations such as
9861
- * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
9862
- */
9863
- /**
9864
- * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
9865
- */
9866
- // RSA KeyGen Algorithm
9867
- const PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
9868
- // SHA-256 hashing algorithm
9869
- const S256_HASH_ALG = "SHA-256";
9870
- // MOD length for PoP tokens
9871
- const MODULUS_LENGTH = 2048;
9872
- // Public Exponent
9873
- const PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
9874
- // UUID hex digits
9875
- const UUID_CHARS = "0123456789abcdef";
9876
- // Array to store UINT32 random value
9877
- const UINT32_ARR = new Uint32Array(1);
9878
- const keygenAlgorithmOptions = {
9879
- name: PKCS1_V15_KEYGEN_ALG,
9880
- hash: S256_HASH_ALG,
9881
- modulusLength: MODULUS_LENGTH,
9882
- publicExponent: PUBLIC_EXPONENT,
9883
- };
9884
- /**
9885
- * Check whether browser crypto is available.
9886
- */
9887
- function validateCryptoAvailable(logger) {
9888
- if ("crypto" in window) {
9889
- logger.verbose("BrowserCrypto: modern crypto interface available");
9890
- }
9891
- else {
9892
- logger.error("BrowserCrypto: crypto interface is unavailable");
9893
- throw createBrowserAuthError(cryptoNonExistent);
9894
- }
9895
- }
9896
- /**
9897
- * Returns a sha-256 hash of the given dataString as an ArrayBuffer.
9898
- * @param dataString {string} data string
9899
- * @param performanceClient {?IPerformanceClient}
9900
- * @param correlationId {?string} correlation id
9901
- */
9902
- async function sha256Digest(dataString, performanceClient, correlationId) {
9903
- performanceClient?.addQueueMeasurement(PerformanceEvents.Sha256Digest, correlationId);
9904
- const encoder = new TextEncoder();
9905
- const data = encoder.encode(dataString);
9906
- return window.crypto.subtle.digest(S256_HASH_ALG, data);
9907
- }
9908
- /**
9909
- * Populates buffer with cryptographically random values.
9910
- * @param dataBuffer
9911
- */
9912
- function getRandomValues(dataBuffer) {
9913
- return window.crypto.getRandomValues(dataBuffer);
9914
- }
9915
- /**
9916
- * Returns random Uint32 value.
9917
- * @returns {number}
9918
- */
9919
- function getRandomUint32() {
9920
- window.crypto.getRandomValues(UINT32_ARR);
9921
- return UINT32_ARR[0];
9922
- }
9923
- /**
9924
- * Creates a UUID v7 from the current timestamp.
9925
- * Implementation relies on the system clock to guarantee increasing order of generated identifiers.
9926
- * @returns {number}
9927
- */
9928
- function createNewGuid() {
9929
- const currentTimestamp = Date.now();
9930
- const baseRand = getRandomUint32() * 0x400 + (getRandomUint32() & 0x3ff);
9931
- // Result byte array
9932
- const bytes = new Uint8Array(16);
9933
- // A 12-bit `rand_a` field value
9934
- const randA = Math.trunc(baseRand / 2 ** 30);
9935
- // The higher 30 bits of 62-bit `rand_b` field value
9936
- const randBHi = baseRand & (2 ** 30 - 1);
9937
- // The lower 32 bits of 62-bit `rand_b` field value
9938
- const randBLo = getRandomUint32();
9939
- bytes[0] = currentTimestamp / 2 ** 40;
9940
- bytes[1] = currentTimestamp / 2 ** 32;
9941
- bytes[2] = currentTimestamp / 2 ** 24;
9942
- bytes[3] = currentTimestamp / 2 ** 16;
9943
- bytes[4] = currentTimestamp / 2 ** 8;
9944
- bytes[5] = currentTimestamp;
9945
- bytes[6] = 0x70 | (randA >>> 8);
9946
- bytes[7] = randA;
9947
- bytes[8] = 0x80 | (randBHi >>> 24);
9948
- bytes[9] = randBHi >>> 16;
9949
- bytes[10] = randBHi >>> 8;
9950
- bytes[11] = randBHi;
9951
- bytes[12] = randBLo >>> 24;
9952
- bytes[13] = randBLo >>> 16;
9953
- bytes[14] = randBLo >>> 8;
9954
- bytes[15] = randBLo;
9955
- let text = "";
9956
- for (let i = 0; i < bytes.length; i++) {
9957
- text += UUID_CHARS.charAt(bytes[i] >>> 4);
9958
- text += UUID_CHARS.charAt(bytes[i] & 0xf);
9959
- if (i === 3 || i === 5 || i === 7 || i === 9) {
9960
- text += "-";
9961
- }
9962
- }
9963
- return text;
9964
- }
9965
- /**
9966
- * Generates a keypair based on current keygen algorithm config.
9967
- * @param extractable
9968
- * @param usages
9969
- */
9970
- async function generateKeyPair(extractable, usages) {
9971
- return window.crypto.subtle.generateKey(keygenAlgorithmOptions, extractable, usages);
9972
- }
9973
- /**
9974
- * Export key as Json Web Key (JWK)
9975
- * @param key
9976
- */
9977
- async function exportJwk(key) {
9978
- return window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key);
9979
- }
9980
- /**
9981
- * Imports key as Json Web Key (JWK), can set extractable and usages.
9982
- * @param key
9983
- * @param extractable
9984
- * @param usages
9985
- */
9986
- async function importJwk(key, extractable, usages) {
9987
- return window.crypto.subtle.importKey(KEY_FORMAT_JWK, key, keygenAlgorithmOptions, extractable, usages);
9988
- }
9989
- /**
9990
- * Signs given data with given key
9991
- * @param key
9992
- * @param data
9993
- */
9994
- async function sign(key, data) {
9995
- return window.crypto.subtle.sign(keygenAlgorithmOptions, key, data);
9996
- }
9997
-
9998
10479
  /*
9999
10480
  * Copyright (c) Microsoft Corporation. All rights reserved.
10000
10481
  * Licensed under the MIT License.
@@ -10179,9 +10660,19 @@ class DatabaseStorage {
10179
10660
  }
10180
10661
  return new Promise((resolve, reject) => {
10181
10662
  const deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
10182
- deleteDbRequest.addEventListener("success", () => resolve(true));
10183
- deleteDbRequest.addEventListener("blocked", () => resolve(true));
10184
- deleteDbRequest.addEventListener("error", () => reject(false));
10663
+ const id = setTimeout(() => reject(false), 200); // Reject if events aren't raised within 200ms
10664
+ deleteDbRequest.addEventListener("success", () => {
10665
+ clearTimeout(id);
10666
+ return resolve(true);
10667
+ });
10668
+ deleteDbRequest.addEventListener("blocked", () => {
10669
+ clearTimeout(id);
10670
+ return resolve(true);
10671
+ });
10672
+ deleteDbRequest.addEventListener("error", () => {
10673
+ clearTimeout(id);
10674
+ return reject(false);
10675
+ });
10185
10676
  });
10186
10677
  }
10187
10678
  }
@@ -10227,11 +10718,10 @@ class MemoryStorage {
10227
10718
  * backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
10228
10719
  */
10229
10720
  class AsyncMemoryStorage {
10230
- constructor(logger, storeName) {
10721
+ constructor(logger) {
10231
10722
  this.inMemoryCache = new MemoryStorage();
10232
10723
  this.indexedDBCache = new DatabaseStorage();
10233
10724
  this.logger = logger;
10234
- this.storeName = storeName;
10235
10725
  }
10236
10726
  handleDatabaseAccessError(error) {
10237
10727
  if (error instanceof BrowserAuthError &&
@@ -10327,9 +10817,9 @@ class AsyncMemoryStorage {
10327
10817
  */
10328
10818
  clearInMemory() {
10329
10819
  // InMemory cache is a Map instance, clear is straightforward
10330
- this.logger.verbose(`Deleting in-memory keystore ${this.storeName}`);
10820
+ this.logger.verbose(`Deleting in-memory keystore`);
10331
10821
  this.inMemoryCache.clear();
10332
- this.logger.verbose(`In-memory keystore ${this.storeName} deleted`);
10822
+ this.logger.verbose(`In-memory keystore deleted`);
10333
10823
  }
10334
10824
  /**
10335
10825
  * Tries to delete the IndexedDB database
@@ -10339,54 +10829,13 @@ class AsyncMemoryStorage {
10339
10829
  try {
10340
10830
  this.logger.verbose("Deleting persistent keystore");
10341
10831
  const dbDeleted = await this.indexedDBCache.deleteDatabase();
10342
- if (dbDeleted) {
10343
- this.logger.verbose("Persistent keystore deleted");
10344
- }
10345
- return dbDeleted;
10346
- }
10347
- catch (e) {
10348
- this.handleDatabaseAccessError(e);
10349
- return false;
10350
- }
10351
- }
10352
- }
10353
-
10354
- /*
10355
- * Copyright (c) Microsoft Corporation. All rights reserved.
10356
- * Licensed under the MIT License.
10357
- */
10358
- const CryptoKeyStoreNames = {
10359
- asymmetricKeys: "asymmetricKeys",
10360
- symmetricKeys: "symmetricKeys",
10361
- };
10362
- /**
10363
- * MSAL CryptoKeyStore DB Version 2
10364
- */
10365
- class CryptoKeyStore {
10366
- constructor(logger) {
10367
- this.logger = logger;
10368
- this.asymmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys);
10369
- this.symmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys);
10370
- }
10371
- async clear() {
10372
- // Delete in-memory keystores
10373
- this.asymmetricKeys.clearInMemory();
10374
- this.symmetricKeys.clearInMemory();
10375
- /**
10376
- * There is only one database, so calling clearPersistent on asymmetric keystore takes care of
10377
- * every persistent keystore
10378
- */
10379
- try {
10380
- await this.asymmetricKeys.clearPersistent();
10381
- return true;
10382
- }
10383
- catch (e) {
10384
- if (e instanceof Error) {
10385
- this.logger.error(`Clearing keystore failed with error: ${e.message}`);
10386
- }
10387
- else {
10388
- this.logger.error("Clearing keystore failed with unknown error");
10832
+ if (dbDeleted) {
10833
+ this.logger.verbose("Persistent keystore deleted");
10389
10834
  }
10835
+ return dbDeleted;
10836
+ }
10837
+ catch (e) {
10838
+ this.handleDatabaseAccessError(e);
10390
10839
  return false;
10391
10840
  }
10392
10841
  }
@@ -10405,7 +10854,7 @@ class CryptoOps {
10405
10854
  this.logger = logger;
10406
10855
  // Browser crypto needs to be validated first before any other classes can be set.
10407
10856
  validateCryptoAvailable(logger);
10408
- this.cache = new CryptoKeyStore(this.logger);
10857
+ this.cache = new AsyncMemoryStorage(this.logger);
10409
10858
  this.performanceClient = performanceClient;
10410
10859
  }
10411
10860
  /**
@@ -10451,7 +10900,7 @@ class CryptoOps {
10451
10900
  // Re-import private key to make it unextractable
10452
10901
  const unextractablePrivateKey = await importJwk(privateKeyJwk, false, ["sign"]);
10453
10902
  // Store Keypair data in keystore
10454
- await this.cache.asymmetricKeys.setItem(publicJwkHash, {
10903
+ await this.cache.setItem(publicJwkHash, {
10455
10904
  privateKey: unextractablePrivateKey,
10456
10905
  publicKey: keyPair.publicKey,
10457
10906
  requestMethod: request.resourceRequestMethod,
@@ -10469,15 +10918,33 @@ class CryptoOps {
10469
10918
  * @param kid
10470
10919
  */
10471
10920
  async removeTokenBindingKey(kid) {
10472
- await this.cache.asymmetricKeys.removeItem(kid);
10473
- const keyFound = await this.cache.asymmetricKeys.containsKey(kid);
10921
+ await this.cache.removeItem(kid);
10922
+ const keyFound = await this.cache.containsKey(kid);
10474
10923
  return !keyFound;
10475
10924
  }
10476
10925
  /**
10477
10926
  * Removes all cryptographic keys from IndexedDB storage
10478
10927
  */
10479
10928
  async clearKeystore() {
10480
- return this.cache.clear();
10929
+ // Delete in-memory keystores
10930
+ this.cache.clearInMemory();
10931
+ /**
10932
+ * There is only one database, so calling clearPersistent on asymmetric keystore takes care of
10933
+ * every persistent keystore
10934
+ */
10935
+ try {
10936
+ await this.cache.clearPersistent();
10937
+ return true;
10938
+ }
10939
+ catch (e) {
10940
+ if (e instanceof Error) {
10941
+ this.logger.error(`Clearing keystore failed with error: ${e.message}`);
10942
+ }
10943
+ else {
10944
+ this.logger.error("Clearing keystore failed with unknown error");
10945
+ }
10946
+ return false;
10947
+ }
10481
10948
  }
10482
10949
  /**
10483
10950
  * Signs the given object as a jwt payload with private key retrieved by given kid.
@@ -10486,7 +10953,7 @@ class CryptoOps {
10486
10953
  */
10487
10954
  async signJwt(payload, kid, shrOptions, correlationId) {
10488
10955
  const signJwtMeasurement = this.performanceClient?.startMeasurement(PerformanceEvents.CryptoOptsSignJwt, correlationId);
10489
- const cachedKeyPair = await this.cache.asymmetricKeys.getItem(kid);
10956
+ const cachedKeyPair = await this.cache.getItem(kid);
10490
10957
  if (!cachedKeyPair) {
10491
10958
  throw createBrowserAuthError(cryptoKeyNotFound);
10492
10959
  }
@@ -10527,9 +10994,7 @@ class CryptoOps {
10527
10994
  * @param plainText
10528
10995
  */
10529
10996
  async hashString(plainText) {
10530
- const hashBuffer = await sha256Digest(plainText);
10531
- const hashBytes = new Uint8Array(hashBuffer);
10532
- return urlEncodeArr(hashBytes);
10997
+ return hashString(plainText);
10533
10998
  }
10534
10999
  }
10535
11000
  CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
@@ -10538,62 +11003,6 @@ function getSortedObjectString(obj) {
10538
11003
  return JSON.stringify(obj, Object.keys(obj).sort());
10539
11004
  }
10540
11005
 
10541
- /*
10542
- * Copyright (c) Microsoft Corporation. All rights reserved.
10543
- * Licensed under the MIT License.
10544
- */
10545
- const storageNotSupported = "storage_not_supported";
10546
- const stubbedPublicClientApplicationCalled = "stubbed_public_client_application_called";
10547
- const inMemRedirectUnavailable = "in_mem_redirect_unavailable";
10548
-
10549
- var BrowserConfigurationAuthErrorCodes = /*#__PURE__*/Object.freeze({
10550
- __proto__: null,
10551
- inMemRedirectUnavailable: inMemRedirectUnavailable,
10552
- storageNotSupported: storageNotSupported,
10553
- stubbedPublicClientApplicationCalled: stubbedPublicClientApplicationCalled
10554
- });
10555
-
10556
- /*
10557
- * Copyright (c) Microsoft Corporation. All rights reserved.
10558
- * Licensed under the MIT License.
10559
- */
10560
- const BrowserConfigurationAuthErrorMessages = {
10561
- [storageNotSupported]: "Given storage configuration option was not supported.",
10562
- [stubbedPublicClientApplicationCalled]: "Stub instance of Public Client Application was called. If using msal-react, please ensure context is not used without a provider. For more visit: aka.ms/msaljs/browser-errors",
10563
- [inMemRedirectUnavailable]: "Redirect cannot be supported. In-memory storage was selected and storeAuthStateInCookie=false, which would cause the library to be unable to handle the incoming hash. If you would like to use the redirect API, please use session/localStorage or set storeAuthStateInCookie=true.",
10564
- };
10565
- /**
10566
- * BrowserAuthErrorMessage class containing string constants used by error codes and messages.
10567
- * @deprecated Use BrowserAuthErrorCodes instead
10568
- */
10569
- const BrowserConfigurationAuthErrorMessage = {
10570
- storageNotSupportedError: {
10571
- code: storageNotSupported,
10572
- desc: BrowserConfigurationAuthErrorMessages[storageNotSupported],
10573
- },
10574
- stubPcaInstanceCalled: {
10575
- code: stubbedPublicClientApplicationCalled,
10576
- desc: BrowserConfigurationAuthErrorMessages[stubbedPublicClientApplicationCalled],
10577
- },
10578
- inMemRedirectUnavailable: {
10579
- code: inMemRedirectUnavailable,
10580
- desc: BrowserConfigurationAuthErrorMessages[inMemRedirectUnavailable],
10581
- },
10582
- };
10583
- /**
10584
- * Browser library error class thrown by the MSAL.js library for SPAs
10585
- */
10586
- class BrowserConfigurationAuthError extends AuthError {
10587
- constructor(errorCode, errorMessage) {
10588
- super(errorCode, errorMessage);
10589
- this.name = "BrowserConfigurationAuthError";
10590
- Object.setPrototypeOf(this, BrowserConfigurationAuthError.prototype);
10591
- }
10592
- }
10593
- function createBrowserConfigurationAuthError(errorCode) {
10594
- return new BrowserConfigurationAuthError(errorCode, BrowserConfigurationAuthErrorMessages[errorCode]);
10595
- }
10596
-
10597
11006
  /*
10598
11007
  * Copyright (c) Microsoft Corporation. All rights reserved.
10599
11008
  * Licensed under the MIT License.
@@ -10742,18 +11151,12 @@ class BrowserCacheManager extends CacheManager {
10742
11151
  PersistentCacheKeys.ERROR,
10743
11152
  PersistentCacheKeys.ERROR_DESC,
10744
11153
  ];
10745
- keysToMigrate.forEach((cacheKey, index) => this.migrateCacheEntry(cacheKey, values[index]));
10746
- }
10747
- /**
10748
- * Utility function to help with migration.
10749
- * @param newKey
10750
- * @param value
10751
- * @param storeAuthStateInCookie
10752
- */
10753
- migrateCacheEntry(newKey, value) {
10754
- if (value) {
10755
- this.setTemporaryCache(newKey, value, true);
10756
- }
11154
+ keysToMigrate.forEach((cacheKey, index) => {
11155
+ const value = values[index];
11156
+ if (value) {
11157
+ this.setTemporaryCache(cacheKey, value, true);
11158
+ }
11159
+ });
10757
11160
  }
10758
11161
  /**
10759
11162
  * Searches all cache entries for MSAL accounts and creates the account key map
@@ -11450,33 +11853,28 @@ class BrowserCacheManager extends CacheManager {
11450
11853
  }
11451
11854
  /**
11452
11855
  * Removes the cache item with the given key.
11453
- * Will also clear the cookie item if storeAuthStateInCookie is set to true.
11454
11856
  * @param key
11455
11857
  */
11456
11858
  removeItem(key) {
11457
11859
  this.browserStorage.removeItem(key);
11860
+ }
11861
+ /**
11862
+ * Removes the temporary cache item with the given key.
11863
+ * Will also clear the cookie item if storeAuthStateInCookie is set to true.
11864
+ * @param key
11865
+ */
11866
+ removeTemporaryItem(key) {
11458
11867
  this.temporaryCacheStorage.removeItem(key);
11459
11868
  if (this.cacheConfig.storeAuthStateInCookie) {
11460
11869
  this.logger.trace("BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie");
11461
11870
  this.clearItemCookie(key);
11462
11871
  }
11463
11872
  }
11464
- /**
11465
- * Checks whether key is in cache.
11466
- * @param key
11467
- */
11468
- containsKey(key) {
11469
- return (this.browserStorage.containsKey(key) ||
11470
- this.temporaryCacheStorage.containsKey(key));
11471
- }
11472
11873
  /**
11473
11874
  * Gets all keys in window.
11474
11875
  */
11475
11876
  getKeys() {
11476
- return [
11477
- ...this.browserStorage.getKeys(),
11478
- ...this.temporaryCacheStorage.getKeys(),
11479
- ];
11877
+ return this.browserStorage.getKeys();
11480
11878
  }
11481
11879
  /**
11482
11880
  * Clears all cache entries created by MSAL.
@@ -11485,14 +11883,18 @@ class BrowserCacheManager extends CacheManager {
11485
11883
  // Removes all accounts and their credentials
11486
11884
  await this.removeAllAccounts();
11487
11885
  this.removeAppMetadata();
11886
+ // Remove temp storage first to make sure any cookies are cleared
11887
+ this.temporaryCacheStorage.getKeys().forEach((cacheKey) => {
11888
+ if (cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
11889
+ cacheKey.indexOf(this.clientId) !== -1) {
11890
+ this.removeTemporaryItem(cacheKey);
11891
+ }
11892
+ });
11488
11893
  // Removes all remaining MSAL cache items
11489
- this.getKeys().forEach((cacheKey) => {
11490
- // Check if key contains msal prefix; For now, we are clearing all the cache items created by MSAL.js
11491
- if ((this.browserStorage.containsKey(cacheKey) ||
11492
- this.temporaryCacheStorage.containsKey(cacheKey)) &&
11493
- (cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
11494
- cacheKey.indexOf(this.clientId) !== -1)) {
11495
- this.removeItem(cacheKey);
11894
+ this.browserStorage.getKeys().forEach((cacheKey) => {
11895
+ if (cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
11896
+ cacheKey.indexOf(this.clientId) !== -1) {
11897
+ this.browserStorage.removeItem(cacheKey);
11496
11898
  }
11497
11899
  });
11498
11900
  this.internalStorage.clear();
@@ -11525,6 +11927,7 @@ class BrowserCacheManager extends CacheManager {
11525
11927
  * @param cookieName
11526
11928
  * @param cookieValue
11527
11929
  * @param expires
11930
+ * @deprecated
11528
11931
  */
11529
11932
  setItemCookie(cookieName, cookieValue, expires) {
11530
11933
  let cookieStr = `${encodeURIComponent(cookieName)}=${encodeURIComponent(cookieValue)};path=/;SameSite=Lax;`;
@@ -11540,6 +11943,7 @@ class BrowserCacheManager extends CacheManager {
11540
11943
  /**
11541
11944
  * Get one item by key from cookies
11542
11945
  * @param cookieName
11946
+ * @deprecated
11543
11947
  */
11544
11948
  getItemCookie(cookieName) {
11545
11949
  const name = `${encodeURIComponent(cookieName)}=`;
@@ -11557,6 +11961,7 @@ class BrowserCacheManager extends CacheManager {
11557
11961
  }
11558
11962
  /**
11559
11963
  * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
11964
+ * @deprecated
11560
11965
  */
11561
11966
  clearMsalCookies() {
11562
11967
  const cookiePrefix = `${Constants.CACHE_PREFIX}.${this.clientId}`;
@@ -11575,6 +11980,7 @@ class BrowserCacheManager extends CacheManager {
11575
11980
  /**
11576
11981
  * Clear an item in the cookies by key
11577
11982
  * @param cookieName
11983
+ * @deprecated
11578
11984
  */
11579
11985
  clearItemCookie(cookieName) {
11580
11986
  this.setItemCookie(cookieName, Constants.EMPTY_STRING, -1);
@@ -11582,24 +11988,13 @@ class BrowserCacheManager extends CacheManager {
11582
11988
  /**
11583
11989
  * Get cookie expiration time
11584
11990
  * @param cookieLifeDays
11991
+ * @deprecated
11585
11992
  */
11586
11993
  getCookieExpirationTime(cookieLifeDays) {
11587
11994
  const today = new Date();
11588
11995
  const expr = new Date(today.getTime() + cookieLifeDays * this.COOKIE_LIFE_MULTIPLIER);
11589
11996
  return expr.toUTCString();
11590
11997
  }
11591
- /**
11592
- * Gets the cache object referenced by the browser
11593
- */
11594
- getCache() {
11595
- return this.browserStorage;
11596
- }
11597
- /**
11598
- * interface compat, we cannot overwrite browser cache; Functionality is supported by individual entities in browser
11599
- */
11600
- setCache() {
11601
- // sets nothing
11602
- }
11603
11998
  /**
11604
11999
  * 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)
11605
12000
  * @param key
@@ -11692,22 +12087,22 @@ class BrowserCacheManager extends CacheManager {
11692
12087
  this.logger.trace("BrowserCacheManager.resetRequestCache called");
11693
12088
  // check state and remove associated cache items
11694
12089
  if (state) {
11695
- this.getKeys().forEach((key) => {
12090
+ this.temporaryCacheStorage.getKeys().forEach((key) => {
11696
12091
  if (key.indexOf(state) !== -1) {
11697
- this.removeItem(key);
12092
+ this.removeTemporaryItem(key);
11698
12093
  }
11699
12094
  });
11700
12095
  // delete generic interactive request parameters
11701
- this.removeItem(this.generateStateKey(state));
11702
- this.removeItem(this.generateNonceKey(state));
11703
- this.removeItem(this.generateAuthorityKey(state));
11704
- }
11705
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
11706
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));
11707
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));
11708
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID));
11709
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL));
11710
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));
12096
+ this.removeTemporaryItem(this.generateStateKey(state));
12097
+ this.removeTemporaryItem(this.generateNonceKey(state));
12098
+ this.removeTemporaryItem(this.generateAuthorityKey(state));
12099
+ }
12100
+ this.removeTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
12101
+ this.removeTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));
12102
+ this.removeTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));
12103
+ this.removeTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID));
12104
+ this.removeTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL));
12105
+ this.removeTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));
11711
12106
  this.setInteractionInProgress(false);
11712
12107
  }
11713
12108
  /**
@@ -11733,7 +12128,7 @@ class BrowserCacheManager extends CacheManager {
11733
12128
  cleanRequestByInteractionType(interactionType) {
11734
12129
  this.logger.trace("BrowserCacheManager.cleanRequestByInteractionType called");
11735
12130
  // Loop through all keys to find state key
11736
- this.getKeys().forEach((key) => {
12131
+ this.temporaryCacheStorage.getKeys().forEach((key) => {
11737
12132
  // If this key is not the state key, move on
11738
12133
  if (key.indexOf(TemporaryCacheKeys.REQUEST_STATE) === -1) {
11739
12134
  return;
@@ -11778,7 +12173,7 @@ class BrowserCacheManager extends CacheManager {
11778
12173
  this.logger.error(`Parsing cached token request threw with error: ${e}`);
11779
12174
  throw createBrowserAuthError(unableToParseTokenRequestCacheError);
11780
12175
  }
11781
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
12176
+ this.removeTemporaryItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
11782
12177
  // Get cached authority and use if no authority is cached with request.
11783
12178
  if (!parsedRequest.authority) {
11784
12179
  const authorityCacheKey = this.generateAuthorityKey(state);
@@ -11834,7 +12229,7 @@ class BrowserCacheManager extends CacheManager {
11834
12229
  }
11835
12230
  else if (!inProgress &&
11836
12231
  this.getInteractionInProgress() === this.clientId) {
11837
- this.removeItem(key);
12232
+ this.removeTemporaryItem(key);
11838
12233
  }
11839
12234
  }
11840
12235
  /**
@@ -11851,7 +12246,7 @@ class BrowserCacheManager extends CacheManager {
11851
12246
  // Check for cached MSAL v1 id token
11852
12247
  const msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
11853
12248
  if (msalIdTokenString) {
11854
- this.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
12249
+ this.browserStorage.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
11855
12250
  this.logger.verbose("Cached MSAL.js v1 id token retrieved");
11856
12251
  }
11857
12252
  const cachedIdTokenString = msalIdTokenString || adalIdTokenString;
@@ -11879,7 +12274,7 @@ class BrowserCacheManager extends CacheManager {
11879
12274
  if (currentCacheKey !== updatedCacheKey) {
11880
12275
  const cacheItem = this.getItem(currentCacheKey);
11881
12276
  if (cacheItem) {
11882
- this.removeItem(currentCacheKey);
12277
+ this.browserStorage.removeItem(currentCacheKey);
11883
12278
  this.setItem(updatedCacheKey, cacheItem);
11884
12279
  this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);
11885
12280
  return updatedCacheKey;
@@ -11890,19 +12285,6 @@ class BrowserCacheManager extends CacheManager {
11890
12285
  }
11891
12286
  return currentCacheKey;
11892
12287
  }
11893
- /**
11894
- * Returns application id as redirect context during AcquireTokenRedirect flow.
11895
- */
11896
- getRedirectRequestContext() {
11897
- return this.getTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, true);
11898
- }
11899
- /**
11900
- * Sets application id as the redirect context during AcquireTokenRedirect flow.
11901
- * @param value
11902
- */
11903
- setRedirectRequestContext(value) {
11904
- this.setTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, value, true);
11905
- }
11906
12288
  /**
11907
12289
  * Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
11908
12290
  * @param result
@@ -12137,47 +12519,6 @@ class BaseInteractionClient {
12137
12519
  }
12138
12520
  }
12139
12521
  }
12140
- /**
12141
- * Initializer function for all request APIs
12142
- * @param request
12143
- */
12144
- async initializeBaseRequest(request) {
12145
- this.performanceClient.addQueueMeasurement(PerformanceEvents.InitializeBaseRequest, this.correlationId);
12146
- const authority = request.authority || this.config.auth.authority;
12147
- const scopes = [...((request && request.scopes) || [])];
12148
- const validatedRequest = {
12149
- ...request,
12150
- correlationId: this.correlationId,
12151
- authority,
12152
- scopes,
12153
- };
12154
- // Set authenticationScheme to BEARER if not explicitly set in the request
12155
- if (!validatedRequest.authenticationScheme) {
12156
- validatedRequest.authenticationScheme = AuthenticationScheme.BEARER;
12157
- this.logger.verbose('Authentication Scheme wasn\'t explicitly set in request, defaulting to "Bearer" request');
12158
- }
12159
- else {
12160
- if (validatedRequest.authenticationScheme ===
12161
- AuthenticationScheme.SSH) {
12162
- if (!request.sshJwk) {
12163
- throw createClientConfigurationError(missingSshJwk);
12164
- }
12165
- if (!request.sshKid) {
12166
- throw createClientConfigurationError(missingSshKid);
12167
- }
12168
- }
12169
- this.logger.verbose(`Authentication Scheme set to "${validatedRequest.authenticationScheme}" as configured in Auth request`);
12170
- }
12171
- // Set requested claims hash if claims-based caching is enabled and claims were requested
12172
- if (this.config.cache.claimsBasedCachingEnabled &&
12173
- request.claims &&
12174
- // Checks for empty stringified object "{}" which doesn't qualify as requested claims
12175
- !StringUtils.isEmptyObj(request.claims)) {
12176
- validatedRequest.requestedClaimsHash =
12177
- await this.browserCrypto.hashString(request.claims);
12178
- }
12179
- return validatedRequest;
12180
- }
12181
12522
  /**
12182
12523
  *
12183
12524
  * Use to get the redirect uri configured in MSAL or null.
@@ -12295,6 +12636,60 @@ async function generateCodeChallengeFromVerifier(pkceCodeVerifier, performanceCl
12295
12636
  }
12296
12637
  }
12297
12638
 
12639
+ /*
12640
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12641
+ * Licensed under the MIT License.
12642
+ */
12643
+ /**
12644
+ * Initializer function for all request APIs
12645
+ * @param request
12646
+ */
12647
+ async function initializeBaseRequest(request, config, performanceClient, logger) {
12648
+ performanceClient.addQueueMeasurement(PerformanceEvents.InitializeBaseRequest, request.correlationId);
12649
+ const authority = request.authority || config.auth.authority;
12650
+ const scopes = [...((request && request.scopes) || [])];
12651
+ const validatedRequest = {
12652
+ ...request,
12653
+ correlationId: request.correlationId,
12654
+ authority,
12655
+ scopes,
12656
+ };
12657
+ // Set authenticationScheme to BEARER if not explicitly set in the request
12658
+ if (!validatedRequest.authenticationScheme) {
12659
+ validatedRequest.authenticationScheme = AuthenticationScheme.BEARER;
12660
+ logger.verbose('Authentication Scheme wasn\'t explicitly set in request, defaulting to "Bearer" request');
12661
+ }
12662
+ else {
12663
+ if (validatedRequest.authenticationScheme === AuthenticationScheme.SSH) {
12664
+ if (!request.sshJwk) {
12665
+ throw createClientConfigurationError(missingSshJwk);
12666
+ }
12667
+ if (!request.sshKid) {
12668
+ throw createClientConfigurationError(missingSshKid);
12669
+ }
12670
+ }
12671
+ logger.verbose(`Authentication Scheme set to "${validatedRequest.authenticationScheme}" as configured in Auth request`);
12672
+ }
12673
+ // Set requested claims hash if claims-based caching is enabled and claims were requested
12674
+ if (config.cache.claimsBasedCachingEnabled &&
12675
+ request.claims &&
12676
+ // Checks for empty stringified object "{}" which doesn't qualify as requested claims
12677
+ !StringUtils.isEmptyObj(request.claims)) {
12678
+ validatedRequest.requestedClaimsHash = await hashString(request.claims);
12679
+ }
12680
+ return validatedRequest;
12681
+ }
12682
+ async function initializeSilentRequest(request, account, config, performanceClient, logger) {
12683
+ performanceClient.addQueueMeasurement(PerformanceEvents.InitializeSilentRequest, request.correlationId);
12684
+ const baseRequest = await invokeAsync(initializeBaseRequest, PerformanceEvents.InitializeBaseRequest, logger, performanceClient, request.correlationId)(request, config, performanceClient, logger);
12685
+ return {
12686
+ ...request,
12687
+ ...baseRequest,
12688
+ account: account,
12689
+ forceRefresh: request.forceRefresh || false,
12690
+ };
12691
+ }
12692
+
12298
12693
  /*
12299
12694
  * Copyright (c) Microsoft Corporation. All rights reserved.
12300
12695
  * Licensed under the MIT License.
@@ -12469,7 +12864,7 @@ class StandardInteractionClient extends BaseInteractionClient {
12469
12864
  interactionType: interactionType,
12470
12865
  };
12471
12866
  const state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || Constants.EMPTY_STRING, browserState);
12472
- const baseRequest = await invokeAsync(this.initializeBaseRequest.bind(this), PerformanceEvents.InitializeBaseRequest, this.logger, this.performanceClient, this.correlationId)(request);
12867
+ const baseRequest = await invokeAsync(initializeBaseRequest, PerformanceEvents.InitializeBaseRequest, this.logger, this.performanceClient, this.correlationId)({ ...request, correlationId: this.correlationId }, this.config, this.performanceClient, this.logger);
12473
12868
  const validatedRequest = {
12474
12869
  ...baseRequest,
12475
12870
  redirectUri: redirectUri,
@@ -12588,7 +12983,8 @@ class SilentCacheClient extends StandardInteractionClient {
12588
12983
  this.performanceClient.addQueueMeasurement(PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
12589
12984
  // Telemetry manager only used to increment cacheHits here
12590
12985
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);
12591
- const silentAuthClient = await this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions, silentRequest.account);
12986
+ const clientConfig = await invokeAsync(this.getClientConfiguration.bind(this), PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.logger, this.performanceClient, this.correlationId)(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions, silentRequest.account);
12987
+ const silentAuthClient = new SilentFlowClient(clientConfig, this.performanceClient);
12592
12988
  this.logger.verbose("Silent auth client created");
12593
12989
  try {
12594
12990
  const response = await invokeAsync(silentAuthClient.acquireCachedToken.bind(silentAuthClient), PerformanceEvents.SilentFlowClientAcquireCachedToken, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest);
@@ -12615,26 +13011,6 @@ class SilentCacheClient extends StandardInteractionClient {
12615
13011
  const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
12616
13012
  return this.clearCacheOnLogout(validLogoutRequest?.account);
12617
13013
  }
12618
- /**
12619
- * Creates an Silent Flow Client with the given authority, or the default authority.
12620
- * @param serverTelemetryManager
12621
- * @param authorityUrl
12622
- */
12623
- async createSilentFlowClient(serverTelemetryManager, authorityUrl, azureCloudOptions, account) {
12624
- // Create auth module.
12625
- const clientConfig = await invokeAsync(this.getClientConfiguration.bind(this), PerformanceEvents.StandardInteractionClientGetClientConfiguration, this.logger, this.performanceClient, this.correlationId)(serverTelemetryManager, authorityUrl, azureCloudOptions, account);
12626
- return new SilentFlowClient(clientConfig, this.performanceClient);
12627
- }
12628
- async initializeSilentRequest(request, account) {
12629
- this.performanceClient.addQueueMeasurement(PerformanceEvents.InitializeSilentRequest, this.correlationId);
12630
- const baseRequest = await invokeAsync(this.initializeBaseRequest.bind(this), PerformanceEvents.InitializeBaseRequest, this.logger, this.performanceClient, this.correlationId)(request);
12631
- return {
12632
- ...request,
12633
- ...baseRequest,
12634
- account: account,
12635
- forceRefresh: request.forceRefresh || false,
12636
- };
12637
- }
12638
13014
  }
12639
13015
 
12640
13016
  /*
@@ -12746,6 +13122,7 @@ class NativeInteractionClient extends BaseInteractionClient {
12746
13122
  const fullAccount = {
12747
13123
  ...account,
12748
13124
  idTokenClaims: result?.idTokenClaims,
13125
+ idToken: result?.idToken,
12749
13126
  };
12750
13127
  return {
12751
13128
  ...result,
@@ -12847,15 +13224,19 @@ class NativeInteractionClient extends BaseInteractionClient {
12847
13224
  */
12848
13225
  async handleNativeResponse(response, request, reqTimestamp) {
12849
13226
  this.logger.trace("NativeInteractionClient - handleNativeResponse called.");
12850
- if (response.account.id !== request.accountId) {
13227
+ // generate identifiers
13228
+ const idTokenClaims = extractTokenClaims(response.id_token, base64Decode);
13229
+ const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenClaims);
13230
+ const cachedhomeAccountId = this.browserStorage.getAccountInfoFilteredBy({
13231
+ nativeAccountId: request.accountId,
13232
+ })?.homeAccountId;
13233
+ if (homeAccountIdentifier !== cachedhomeAccountId &&
13234
+ response.account.id !== request.accountId) {
12851
13235
  // User switch in native broker prompt is not supported. All users must first sign in through web flow to ensure server state is in sync
12852
13236
  throw createNativeAuthError(userSwitch);
12853
13237
  }
12854
13238
  // Get the preferred_cache domain for the given authority
12855
13239
  const authority = await this.getDiscoveredAuthority(request.authority);
12856
- // generate identifiers
12857
- const idTokenClaims = extractTokenClaims(response.id_token, base64Decode);
12858
- const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenClaims);
12859
13240
  const baseAccount = buildAccountToCache(this.browserStorage, authority, homeAccountIdentifier, idTokenClaims, base64Decode, response.client_info, undefined, // environment
12860
13241
  idTokenClaims.tid, undefined, // auth code payload
12861
13242
  response.account.id, this.logger);
@@ -12951,7 +13332,14 @@ class NativeInteractionClient extends BaseInteractionClient {
12951
13332
  idTokenClaims.tid ||
12952
13333
  Constants.EMPTY_STRING;
12953
13334
  const accountInfo = updateAccountTenantProfileData(accountEntity.getAccountInfo(), undefined, // tenantProfile optional
12954
- idTokenClaims);
13335
+ idTokenClaims, response.id_token);
13336
+ /**
13337
+ * In pairwise broker flows, this check prevents the broker's native account id
13338
+ * from being returned over the embedded app's account id.
13339
+ */
13340
+ if (accountInfo.nativeAccountId !== response.account.id) {
13341
+ accountInfo.nativeAccountId = response.account.id;
13342
+ }
12955
13343
  // generate PoP token as needed
12956
13344
  const responseAccessToken = await this.generatePopAccessToken(response, request);
12957
13345
  const tokenType = request.tokenType === AuthenticationScheme.POP
@@ -14613,17 +15001,20 @@ class SilentIframeClient extends StandardInteractionClient {
14613
15001
  (!request.account || !request.account.username)) {
14614
15002
  this.logger.warning("No user hint provided. The authorization server may need more information to complete this request.");
14615
15003
  }
14616
- // Check that prompt is set to none or no_session, throw error if it is set to anything else.
14617
- if (request.prompt &&
14618
- request.prompt !== PromptValue.NONE &&
14619
- request.prompt !== PromptValue.NO_SESSION) {
14620
- throw createBrowserAuthError(silentPromptValueError);
15004
+ // Check the prompt value
15005
+ const inputRequest = { ...request };
15006
+ if (inputRequest.prompt) {
15007
+ if (inputRequest.prompt !== PromptValue.NONE &&
15008
+ inputRequest.prompt !== PromptValue.NO_SESSION) {
15009
+ this.logger.warning(`SilentIframeClient. Replacing invalid prompt ${inputRequest.prompt} with ${PromptValue.NONE}`);
15010
+ inputRequest.prompt = PromptValue.NONE;
15011
+ }
15012
+ }
15013
+ else {
15014
+ inputRequest.prompt = PromptValue.NONE;
14621
15015
  }
14622
15016
  // Create silent request
14623
- const silentRequest = await invokeAsync(this.initializeAuthorizationRequest.bind(this), PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, this.logger, this.performanceClient, request.correlationId)({
14624
- ...request,
14625
- prompt: request.prompt || PromptValue.NONE,
14626
- }, exports.InteractionType.Silent);
15017
+ const silentRequest = await invokeAsync(this.initializeAuthorizationRequest.bind(this), PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, this.logger, this.performanceClient, request.correlationId)(inputRequest, exports.InteractionType.Silent);
14627
15018
  preconnect(silentRequest.authority);
14628
15019
  const serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
14629
15020
  try {
@@ -14699,7 +15090,7 @@ class SilentRefreshClient extends StandardInteractionClient {
14699
15090
  */
14700
15091
  async acquireToken(request) {
14701
15092
  this.performanceClient.addQueueMeasurement(PerformanceEvents.SilentRefreshClientAcquireToken, request.correlationId);
14702
- const baseRequest = await invokeAsync(this.initializeBaseRequest.bind(this), PerformanceEvents.InitializeBaseRequest, this.logger, this.performanceClient, request.correlationId)(request);
15093
+ const baseRequest = await invokeAsync(initializeBaseRequest, PerformanceEvents.InitializeBaseRequest, this.logger, this.performanceClient, request.correlationId)(request, this.config, this.performanceClient, this.logger);
14703
15094
  const silentRequest = {
14704
15095
  ...request,
14705
15096
  ...baseRequest,
@@ -15055,7 +15446,6 @@ class StandardController {
15055
15446
  * @param configuration Object for the MSAL PublicClientApplication instance
15056
15447
  */
15057
15448
  constructor(operatingContext) {
15058
- this.atsAsyncMeasurement = undefined;
15059
15449
  this.operatingContext = operatingContext;
15060
15450
  this.isBrowserEnvironment =
15061
15451
  this.operatingContext.isBrowserEnvironment();
@@ -15107,14 +15497,12 @@ class StandardController {
15107
15497
  await controller.initialize();
15108
15498
  return controller;
15109
15499
  }
15110
- trackPageVisibility() {
15111
- if (!this.atsAsyncMeasurement) {
15500
+ trackPageVisibility(correlationId) {
15501
+ if (!correlationId) {
15112
15502
  return;
15113
15503
  }
15114
15504
  this.logger.info("Perf: Visibility change detected");
15115
- this.atsAsyncMeasurement.increment({
15116
- visibilityChangeCount: 1,
15117
- });
15505
+ this.performanceClient.incrementFields({ visibilityChangeCount: 1 }, correlationId);
15118
15506
  }
15119
15507
  /**
15120
15508
  * Initializer function to perform async startup tasks such as connecting to WAM extension
@@ -15219,18 +15607,9 @@ class StandardController {
15219
15607
  this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, exports.InteractionType.Redirect, null, eventError);
15220
15608
  }
15221
15609
  this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_END, exports.InteractionType.Redirect);
15222
- if (eventError instanceof AuthError) {
15223
- rootMeasurement.end({
15224
- success: false,
15225
- errorCode: eventError.errorCode,
15226
- subErrorCode: eventError.subError,
15227
- });
15228
- }
15229
- else {
15230
- rootMeasurement.end({
15231
- success: false,
15232
- });
15233
- }
15610
+ rootMeasurement.end({
15611
+ success: false,
15612
+ }, eventError);
15234
15613
  throw e;
15235
15614
  });
15236
15615
  this.redirectResponse.set(redirectResponseKey, response);
@@ -15256,7 +15635,8 @@ class StandardController {
15256
15635
  // Preflight request
15257
15636
  const correlationId = this.getRequestCorrelationId(request);
15258
15637
  this.logger.verbose("acquireTokenRedirect called", correlationId);
15259
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
15638
+ redirectPreflightCheck(this.initialized, this.config);
15639
+ this.browserStorage.setInteractionInProgress(true);
15260
15640
  // If logged in, emit acquire token events
15261
15641
  const isLoggedIn = this.getAllAccounts().length > 0;
15262
15642
  if (isLoggedIn) {
@@ -15282,7 +15662,7 @@ class StandardController {
15282
15662
  const redirectClient = this.createRedirectClient(correlationId);
15283
15663
  return redirectClient.acquireToken(request);
15284
15664
  }
15285
- this.getBrowserStorage().setInteractionInProgress(false);
15665
+ this.browserStorage.setInteractionInProgress(false);
15286
15666
  throw e;
15287
15667
  });
15288
15668
  }
@@ -15315,7 +15695,8 @@ class StandardController {
15315
15695
  const atPopupMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenPopup, correlationId);
15316
15696
  try {
15317
15697
  this.logger.verbose("acquireTokenPopup called", correlationId);
15318
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
15698
+ preflightCheck(this.initialized);
15699
+ this.browserStorage.setInteractionInProgress(true);
15319
15700
  }
15320
15701
  catch (e) {
15321
15702
  // Since this function is syncronous we need to reject
@@ -15336,7 +15717,7 @@ class StandardController {
15336
15717
  correlationId,
15337
15718
  }, ApiId.acquireTokenPopup)
15338
15719
  .then((response) => {
15339
- this.getBrowserStorage().setInteractionInProgress(false);
15720
+ this.browserStorage.setInteractionInProgress(false);
15340
15721
  atPopupMeasurement.end({
15341
15722
  success: true,
15342
15723
  isNativeBroker: true,
@@ -15356,7 +15737,7 @@ class StandardController {
15356
15737
  const popupClient = this.createPopupClient(correlationId);
15357
15738
  return popupClient.acquireToken(request);
15358
15739
  }
15359
- this.getBrowserStorage().setInteractionInProgress(false);
15740
+ this.browserStorage.setInteractionInProgress(false);
15360
15741
  throw e;
15361
15742
  });
15362
15743
  }
@@ -15394,10 +15775,8 @@ class StandardController {
15394
15775
  this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, exports.InteractionType.Popup, null, e);
15395
15776
  }
15396
15777
  atPopupMeasurement.end({
15397
- errorCode: e.errorCode,
15398
- subErrorCode: e.subError,
15399
15778
  success: false,
15400
- });
15779
+ }, e);
15401
15780
  // Since this function is syncronous we need to reject
15402
15781
  return Promise.reject(e);
15403
15782
  });
@@ -15438,7 +15817,7 @@ class StandardController {
15438
15817
  prompt: request.prompt,
15439
15818
  correlationId: correlationId,
15440
15819
  };
15441
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
15820
+ preflightCheck(this.initialized);
15442
15821
  this.ssoSilentMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.SsoSilent, correlationId);
15443
15822
  this.ssoSilentMeasurement?.increment({
15444
15823
  visibilityChangeCount: 0,
@@ -15479,10 +15858,8 @@ class StandardController {
15479
15858
  .catch((e) => {
15480
15859
  this.eventHandler.emitEvent(EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
15481
15860
  this.ssoSilentMeasurement?.end({
15482
- errorCode: e.errorCode,
15483
- subErrorCode: e.subError,
15484
15861
  success: false,
15485
- });
15862
+ }, e);
15486
15863
  throw e;
15487
15864
  })
15488
15865
  .finally(() => {
@@ -15501,8 +15878,8 @@ class StandardController {
15501
15878
  */
15502
15879
  async acquireTokenByCode(request) {
15503
15880
  const correlationId = this.getRequestCorrelationId(request);
15504
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
15505
15881
  this.logger.trace("acquireTokenByCode called", correlationId);
15882
+ preflightCheck(this.initialized);
15506
15883
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
15507
15884
  const atbcMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenByCode, correlationId);
15508
15885
  try {
@@ -15537,10 +15914,8 @@ class StandardController {
15537
15914
  this.hybridAuthCodeResponses.delete(hybridAuthCode);
15538
15915
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
15539
15916
  atbcMeasurement.end({
15540
- errorCode: error.errorCode,
15541
- subErrorCode: error.subError,
15542
15917
  success: false,
15543
- });
15918
+ }, error);
15544
15919
  throw error;
15545
15920
  });
15546
15921
  this.hybridAuthCodeResponses.set(hybridAuthCode, response);
@@ -15576,10 +15951,8 @@ class StandardController {
15576
15951
  catch (e) {
15577
15952
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
15578
15953
  atbcMeasurement.end({
15579
- errorCode: (e instanceof AuthError && e.errorCode) || undefined,
15580
- subErrorCode: (e instanceof AuthError && e.subError) || undefined,
15581
15954
  success: false,
15582
- });
15955
+ }, e);
15583
15956
  throw e;
15584
15957
  }
15585
15958
  }
@@ -15610,10 +15983,8 @@ class StandardController {
15610
15983
  })
15611
15984
  .catch((tokenRenewalError) => {
15612
15985
  this.acquireTokenByCodeAsyncMeasurement?.end({
15613
- errorCode: tokenRenewalError.errorCode,
15614
- subErrorCode: tokenRenewalError.subError,
15615
15986
  success: false,
15616
- });
15987
+ }, tokenRenewalError);
15617
15988
  throw tokenRenewalError;
15618
15989
  })
15619
15990
  .finally(() => {
@@ -15628,12 +15999,13 @@ class StandardController {
15628
15999
  * @param silentRequest SilentRequest
15629
16000
  * @returns A promise that, when resolved, returns the access token
15630
16001
  */
15631
- async acquireTokenFromCache(silentCacheClient, commonRequest, cacheLookupPolicy) {
16002
+ async acquireTokenFromCache(commonRequest, cacheLookupPolicy) {
15632
16003
  this.performanceClient.addQueueMeasurement(PerformanceEvents.AcquireTokenFromCache, commonRequest.correlationId);
15633
16004
  switch (cacheLookupPolicy) {
15634
16005
  case CacheLookupPolicy.Default:
15635
16006
  case CacheLookupPolicy.AccessToken:
15636
16007
  case CacheLookupPolicy.AccessTokenAndRefreshToken:
16008
+ const silentCacheClient = this.createSilentCacheClient(commonRequest.correlationId);
15637
16009
  return invokeAsync(silentCacheClient.acquireToken.bind(silentCacheClient), PerformanceEvents.SilentCacheClientAcquireToken, this.logger, this.performanceClient, commonRequest.correlationId)(commonRequest);
15638
16010
  default:
15639
16011
  throw createClientAuthError(tokenRefreshRequired);
@@ -15690,7 +16062,8 @@ class StandardController {
15690
16062
  */
15691
16063
  async logoutRedirect(logoutRequest) {
15692
16064
  const correlationId = this.getRequestCorrelationId(logoutRequest);
15693
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
16065
+ redirectPreflightCheck(this.initialized, this.config);
16066
+ this.browserStorage.setInteractionInProgress(true);
15694
16067
  const redirectClient = this.createRedirectClient(correlationId);
15695
16068
  return redirectClient.logout(logoutRequest);
15696
16069
  }
@@ -15701,7 +16074,8 @@ class StandardController {
15701
16074
  logoutPopup(logoutRequest) {
15702
16075
  try {
15703
16076
  const correlationId = this.getRequestCorrelationId(logoutRequest);
15704
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
16077
+ preflightCheck(this.initialized);
16078
+ this.browserStorage.setInteractionInProgress(true);
15705
16079
  const popupClient = this.createPopupClient(correlationId);
15706
16080
  return popupClient.logout(logoutRequest);
15707
16081
  }
@@ -15867,52 +16241,6 @@ class StandardController {
15867
16241
  }
15868
16242
  }
15869
16243
  // #region Helpers
15870
- /**
15871
- * Helper to validate app environment before making an auth request
15872
- *
15873
- * @protected
15874
- * @param {InteractionType} interactionType What kind of interaction is being used
15875
- * @param {boolean} [isAppEmbedded=false] Whether to set interaction in progress temp cache flag
15876
- */
15877
- preflightBrowserEnvironmentCheck(interactionType, isAppEmbedded = false) {
15878
- this.logger.verbose("preflightBrowserEnvironmentCheck started");
15879
- // Block request if not in browser environment
15880
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
15881
- // Block redirects if in an iframe
15882
- blockRedirectInIframe(interactionType, this.config.system.allowRedirectInIframe);
15883
- // Block auth requests inside a hidden iframe
15884
- blockReloadInHiddenIframes();
15885
- // Block redirectUri opened in a popup from calling MSAL APIs
15886
- blockAcquireTokenInPopups();
15887
- // Block token acquisition before initialize has been called
15888
- blockAPICallsBeforeInitialize(this.initialized);
15889
- // Block redirects if memory storage is enabled but storeAuthStateInCookie is not
15890
- if (interactionType === exports.InteractionType.Redirect &&
15891
- this.config.cache.cacheLocation ===
15892
- BrowserCacheLocation.MemoryStorage &&
15893
- !this.config.cache.storeAuthStateInCookie) {
15894
- throw createBrowserConfigurationAuthError(inMemRedirectUnavailable);
15895
- }
15896
- if (interactionType === exports.InteractionType.Redirect ||
15897
- interactionType === exports.InteractionType.Popup) {
15898
- this.preflightInteractiveRequest(!isAppEmbedded);
15899
- }
15900
- }
15901
- /**
15902
- * Preflight check for interactive requests
15903
- *
15904
- * @protected
15905
- * @param {boolean} setInteractionInProgress Whether to set interaction in progress temp cache flag
15906
- */
15907
- preflightInteractiveRequest(setInteractionInProgress) {
15908
- this.logger.verbose("preflightInteractiveRequest called, validating app environment");
15909
- // block the reload if it occurred inside a hidden iframe
15910
- blockReloadInHiddenIframes();
15911
- // Set interaction in progress temporary cache or throw if alread set.
15912
- if (setInteractionInProgress) {
15913
- this.getBrowserStorage().setInteractionInProgress(true);
15914
- }
15915
- }
15916
16244
  /**
15917
16245
  * Acquire a token from native device (e.g. WAM)
15918
16246
  * @param request
@@ -16097,12 +16425,6 @@ class StandardController {
16097
16425
  getPerformanceClient() {
16098
16426
  return this.performanceClient;
16099
16427
  }
16100
- /**
16101
- * Returns the browser storage
16102
- */
16103
- getBrowserStorage() {
16104
- return this.browserStorage;
16105
- }
16106
16428
  /**
16107
16429
  * Returns the browser env indicator
16108
16430
  */
@@ -16180,7 +16502,7 @@ class StandardController {
16180
16502
  atsMeasurement.add({
16181
16503
  cacheLookupPolicy: request.cacheLookupPolicy,
16182
16504
  });
16183
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
16505
+ preflightCheck(this.initialized);
16184
16506
  this.logger.verbose("acquireTokenSilent called", correlationId);
16185
16507
  const account = request.account || this.getActiveAccount();
16186
16508
  if (!account) {
@@ -16225,10 +16547,8 @@ class StandardController {
16225
16547
  .catch((error) => {
16226
16548
  this.activeSilentTokenRequests.delete(silentRequestKey);
16227
16549
  atsMeasurement.end({
16228
- errorCode: error.errorCode,
16229
- subErrorCode: error.subError,
16230
16550
  success: false,
16231
- });
16551
+ }, error);
16232
16552
  throw error;
16233
16553
  });
16234
16554
  this.activeSilentTokenRequests.set(silentRequestKey, response);
@@ -16256,11 +16576,10 @@ class StandardController {
16256
16576
  async acquireTokenSilentAsync(request, account) {
16257
16577
  this.performanceClient.addQueueMeasurement(PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
16258
16578
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
16259
- this.atsAsyncMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenSilentAsync, request.correlationId);
16260
- this.atsAsyncMeasurement?.increment({
16261
- visibilityChangeCount: 0,
16262
- });
16263
- document.addEventListener("visibilitychange", this.trackPageVisibility);
16579
+ if (request.correlationId) {
16580
+ this.performanceClient.incrementFields({ visibilityChangeCount: 0 }, request.correlationId);
16581
+ }
16582
+ document.addEventListener("visibilitychange", () => this.trackPageVisibility(request.correlationId));
16264
16583
  let result;
16265
16584
  if (NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme) &&
16266
16585
  account.nativeAccountId) {
@@ -16283,16 +16602,13 @@ class StandardController {
16283
16602
  }
16284
16603
  else {
16285
16604
  this.logger.verbose("acquireTokenSilent - attempting to acquire token from web flow");
16286
- const silentCacheClient = this.createSilentCacheClient(request.correlationId);
16287
- const silentRequest = await invokeAsync(silentCacheClient.initializeSilentRequest.bind(silentCacheClient), PerformanceEvents.InitializeSilentRequest, this.logger, this.performanceClient, request.correlationId)(request, account);
16605
+ const silentRequest = await invokeAsync(initializeSilentRequest, PerformanceEvents.InitializeSilentRequest, this.logger, this.performanceClient, request.correlationId)(request, account, this.config, this.performanceClient, this.logger);
16288
16606
  const cacheLookupPolicy = request.cacheLookupPolicy || CacheLookupPolicy.Default;
16289
- result = invokeAsync(this.acquireTokenFromCache.bind(this), PerformanceEvents.AcquireTokenFromCache, this.logger, this.performanceClient, silentRequest.correlationId)(silentCacheClient, silentRequest, cacheLookupPolicy).catch((cacheError) => {
16607
+ result = invokeAsync(this.acquireTokenFromCache.bind(this), PerformanceEvents.AcquireTokenFromCache, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest, cacheLookupPolicy).catch((cacheError) => {
16290
16608
  if (request.cacheLookupPolicy ===
16291
16609
  CacheLookupPolicy.AccessToken) {
16292
16610
  throw cacheError;
16293
16611
  }
16294
- // block the reload if it occurred inside a hidden iframe
16295
- blockReloadInHiddenIframes();
16296
16612
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest);
16297
16613
  return invokeAsync(this.acquireTokenByRefreshToken.bind(this), PerformanceEvents.AcquireTokenByRefreshToken, this.logger, this.performanceClient, silentRequest.correlationId)(silentRequest, cacheLookupPolicy).catch((refreshTokenError) => {
16298
16614
  const shouldTryToResolveSilently = checkIfRefreshTokenErrorCanBeResolvedSilently(refreshTokenError, silentRequest, cacheLookupPolicy);
@@ -16310,25 +16626,21 @@ class StandardController {
16310
16626
  return result
16311
16627
  .then((response) => {
16312
16628
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
16313
- this.atsAsyncMeasurement?.end({
16314
- success: true,
16315
- fromCache: response.fromCache,
16316
- isNativeBroker: response.fromNativeBroker,
16317
- requestId: response.requestId,
16318
- });
16629
+ if (request.correlationId) {
16630
+ this.performanceClient.addFields({
16631
+ fromCache: response.fromCache,
16632
+ isNativeBroker: response.fromNativeBroker,
16633
+ requestId: response.requestId,
16634
+ }, request.correlationId);
16635
+ }
16319
16636
  return response;
16320
16637
  })
16321
16638
  .catch((tokenRenewalError) => {
16322
16639
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
16323
- this.atsAsyncMeasurement?.end({
16324
- errorCode: tokenRenewalError.errorCode,
16325
- subErrorCode: tokenRenewalError.subError,
16326
- success: false,
16327
- });
16328
16640
  throw tokenRenewalError;
16329
16641
  })
16330
16642
  .finally(() => {
16331
- document.removeEventListener("visibilitychange", this.trackPageVisibility);
16643
+ document.removeEventListener("visibilitychange", () => this.trackPageVisibility(request.correlationId));
16332
16644
  });
16333
16645
  }
16334
16646
  }
@@ -16769,27 +17081,27 @@ class UnknownOperatingContextController {
16769
17081
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16770
17082
  acquireTokenPopup(request) {
16771
17083
  blockAPICallsBeforeInitialize(this.initialized);
16772
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17084
+ blockNonBrowserEnvironment();
16773
17085
  return {};
16774
17086
  }
16775
17087
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16776
17088
  acquireTokenRedirect(request) {
16777
17089
  blockAPICallsBeforeInitialize(this.initialized);
16778
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17090
+ blockNonBrowserEnvironment();
16779
17091
  return Promise.resolve();
16780
17092
  }
16781
17093
  acquireTokenSilent(
16782
17094
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16783
17095
  silentRequest) {
16784
17096
  blockAPICallsBeforeInitialize(this.initialized);
16785
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17097
+ blockNonBrowserEnvironment();
16786
17098
  return {};
16787
17099
  }
16788
17100
  acquireTokenByCode(
16789
17101
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16790
17102
  request) {
16791
17103
  blockAPICallsBeforeInitialize(this.initialized);
16792
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17104
+ blockNonBrowserEnvironment();
16793
17105
  return {};
16794
17106
  }
16795
17107
  acquireTokenNative(
@@ -16800,7 +17112,7 @@ class UnknownOperatingContextController {
16800
17112
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16801
17113
  accountId) {
16802
17114
  blockAPICallsBeforeInitialize(this.initialized);
16803
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17115
+ blockNonBrowserEnvironment();
16804
17116
  return {};
16805
17117
  }
16806
17118
  acquireTokenByRefreshToken(
@@ -16809,7 +17121,7 @@ class UnknownOperatingContextController {
16809
17121
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16810
17122
  silentRequest) {
16811
17123
  blockAPICallsBeforeInitialize(this.initialized);
16812
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17124
+ blockNonBrowserEnvironment();
16813
17125
  return {};
16814
17126
  }
16815
17127
  addEventCallback(callback) {
@@ -16821,22 +17133,22 @@ class UnknownOperatingContextController {
16821
17133
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16822
17134
  addPerformanceCallback(callback) {
16823
17135
  blockAPICallsBeforeInitialize(this.initialized);
16824
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17136
+ blockNonBrowserEnvironment();
16825
17137
  return "";
16826
17138
  }
16827
17139
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16828
17140
  removePerformanceCallback(callbackId) {
16829
17141
  blockAPICallsBeforeInitialize(this.initialized);
16830
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17142
+ blockNonBrowserEnvironment();
16831
17143
  return true;
16832
17144
  }
16833
17145
  enableAccountStorageEvents() {
16834
17146
  blockAPICallsBeforeInitialize(this.initialized);
16835
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17147
+ blockNonBrowserEnvironment();
16836
17148
  }
16837
17149
  disableAccountStorageEvents() {
16838
17150
  blockAPICallsBeforeInitialize(this.initialized);
16839
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17151
+ blockNonBrowserEnvironment();
16840
17152
  }
16841
17153
  handleRedirectPromise(
16842
17154
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -16848,45 +17160,45 @@ class UnknownOperatingContextController {
16848
17160
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16849
17161
  request) {
16850
17162
  blockAPICallsBeforeInitialize(this.initialized);
16851
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17163
+ blockNonBrowserEnvironment();
16852
17164
  return {};
16853
17165
  }
16854
17166
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16855
17167
  loginRedirect(request) {
16856
17168
  blockAPICallsBeforeInitialize(this.initialized);
16857
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17169
+ blockNonBrowserEnvironment();
16858
17170
  return {};
16859
17171
  }
16860
17172
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16861
17173
  logout(logoutRequest) {
16862
17174
  blockAPICallsBeforeInitialize(this.initialized);
16863
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17175
+ blockNonBrowserEnvironment();
16864
17176
  return {};
16865
17177
  }
16866
17178
  logoutRedirect(
16867
17179
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16868
17180
  logoutRequest) {
16869
17181
  blockAPICallsBeforeInitialize(this.initialized);
16870
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17182
+ blockNonBrowserEnvironment();
16871
17183
  return {};
16872
17184
  }
16873
17185
  logoutPopup(
16874
17186
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16875
17187
  logoutRequest) {
16876
17188
  blockAPICallsBeforeInitialize(this.initialized);
16877
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17189
+ blockNonBrowserEnvironment();
16878
17190
  return {};
16879
17191
  }
16880
17192
  ssoSilent(
16881
17193
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16882
17194
  request) {
16883
17195
  blockAPICallsBeforeInitialize(this.initialized);
16884
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17196
+ blockNonBrowserEnvironment();
16885
17197
  return {};
16886
17198
  }
16887
17199
  getTokenCache() {
16888
17200
  blockAPICallsBeforeInitialize(this.initialized);
16889
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17201
+ blockNonBrowserEnvironment();
16890
17202
  return {};
16891
17203
  }
16892
17204
  getLogger() {
@@ -16895,16 +17207,16 @@ class UnknownOperatingContextController {
16895
17207
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16896
17208
  setLogger(logger) {
16897
17209
  blockAPICallsBeforeInitialize(this.initialized);
16898
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17210
+ blockNonBrowserEnvironment();
16899
17211
  }
16900
17212
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16901
17213
  setActiveAccount(account) {
16902
17214
  blockAPICallsBeforeInitialize(this.initialized);
16903
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17215
+ blockNonBrowserEnvironment();
16904
17216
  }
16905
17217
  getActiveAccount() {
16906
17218
  blockAPICallsBeforeInitialize(this.initialized);
16907
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17219
+ blockNonBrowserEnvironment();
16908
17220
  return null;
16909
17221
  }
16910
17222
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -16914,43 +17226,35 @@ class UnknownOperatingContextController {
16914
17226
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16915
17227
  setNavigationClient(navigationClient) {
16916
17228
  blockAPICallsBeforeInitialize(this.initialized);
16917
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17229
+ blockNonBrowserEnvironment();
16918
17230
  }
16919
17231
  getConfiguration() {
16920
17232
  return this.config;
16921
17233
  }
16922
17234
  isBrowserEnv() {
16923
17235
  blockAPICallsBeforeInitialize(this.initialized);
16924
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17236
+ blockNonBrowserEnvironment();
16925
17237
  return true;
16926
17238
  }
16927
17239
  getBrowserCrypto() {
16928
17240
  blockAPICallsBeforeInitialize(this.initialized);
16929
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17241
+ blockNonBrowserEnvironment();
16930
17242
  return {};
16931
17243
  }
16932
17244
  getPerformanceClient() {
16933
17245
  blockAPICallsBeforeInitialize(this.initialized);
16934
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17246
+ blockNonBrowserEnvironment();
16935
17247
  return {};
16936
17248
  }
16937
17249
  getRedirectResponse() {
16938
17250
  blockAPICallsBeforeInitialize(this.initialized);
16939
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17251
+ blockNonBrowserEnvironment();
16940
17252
  return {};
16941
17253
  }
16942
- preflightBrowserEnvironmentCheck(
16943
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
16944
- interactionType,
16945
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
16946
- isAppEmbedded) {
16947
- blockAPICallsBeforeInitialize(this.initialized);
16948
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
16949
- }
16950
17254
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16951
17255
  async clearCache(logoutRequest) {
16952
17256
  blockAPICallsBeforeInitialize(this.initialized);
16953
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17257
+ blockNonBrowserEnvironment();
16954
17258
  }
16955
17259
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16956
17260
  async hydrateCache(
@@ -16959,7 +17263,7 @@ class UnknownOperatingContextController {
16959
17263
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
16960
17264
  request) {
16961
17265
  blockAPICallsBeforeInitialize(this.initialized);
16962
- blockNonBrowserEnvironment(this.isBrowserEnvironment);
17266
+ blockNonBrowserEnvironment();
16963
17267
  }
16964
17268
  }
16965
17269
 
@@ -17610,14 +17914,14 @@ function getPerfDurationMs(startTime) {
17610
17914
  return Math.round(window.performance.now() - startTime);
17611
17915
  }
17612
17916
  class BrowserPerformanceClient extends PerformanceClient {
17613
- constructor(configuration, intFields) {
17917
+ constructor(configuration, intFields, abbreviations) {
17614
17918
  super(configuration.auth.clientId, configuration.auth.authority || `${Constants.DEFAULT_AUTHORITY}`, new Logger(configuration.system?.loggerOptions || {}, name, version), name, version, configuration.telemetry?.application || {
17615
17919
  appName: "",
17616
17920
  appVersion: "",
17617
- }, intFields);
17921
+ }, intFields, abbreviations);
17618
17922
  }
17619
17923
  generateId() {
17620
- return window.crypto.randomUUID();
17924
+ return createNewGuid();
17621
17925
  }
17622
17926
  getPageVisibility() {
17623
17927
  return document.visibilityState?.toString() || null;
@@ -17658,13 +17962,13 @@ class BrowserPerformanceClient extends PerformanceClient {
17658
17962
  void browserMeasurement?.then((measurement) => measurement.startMeasurement());
17659
17963
  return {
17660
17964
  ...inProgressEvent,
17661
- end: (event) => {
17965
+ end: (event, error) => {
17662
17966
  const res = inProgressEvent.end({
17663
17967
  ...event,
17664
17968
  startPageVisibility,
17665
17969
  endPageVisibility: this.getPageVisibility(),
17666
17970
  durationMs: getPerfDurationMs(startTime),
17667
- });
17971
+ }, error);
17668
17972
  void browserMeasurement?.then((measurement) => measurement.endMeasurement());
17669
17973
  this.deleteIncompleteSubMeasurements(inProgressEvent);
17670
17974
  return res;
@@ -17860,11 +18164,12 @@ class NestedAppAuthAdapter {
17860
18164
  }
17861
18165
  const requestBuilder = new RequestParameterBuilder();
17862
18166
  const claims = requestBuilder.addClientCapabilitiesToClaims(request.claims, this.clientCapabilities);
18167
+ const scopes = request.scopes || OIDC_DEFAULT_SCOPES;
17863
18168
  const tokenRequest = {
17864
18169
  platformBrokerId: request.account?.homeAccountId,
17865
18170
  clientId: this.clientId,
17866
18171
  authority: request.authority,
17867
- scope: request.scopes.join(" "),
18172
+ scope: scopes.join(" "),
17868
18173
  correlationId: request.correlationId !== undefined
17869
18174
  ? request.correlationId
17870
18175
  : this.crypto.createNewGuid(),
@@ -18046,12 +18351,22 @@ class NestedAppAuthController {
18046
18351
  // do nothing not required by this controller
18047
18352
  return Promise.resolve();
18048
18353
  }
18354
+ ensureValidRequest(request) {
18355
+ if (request?.correlationId) {
18356
+ return request;
18357
+ }
18358
+ return {
18359
+ ...request,
18360
+ correlationId: this.browserCrypto.createNewGuid(),
18361
+ };
18362
+ }
18049
18363
  async acquireTokenInteractive(request) {
18050
- this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Popup, request);
18051
- const atPopupMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenPopup, request.correlationId);
18364
+ const validRequest = this.ensureValidRequest(request);
18365
+ this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Popup, validRequest);
18366
+ const atPopupMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenPopup, validRequest.correlationId);
18052
18367
  atPopupMeasurement?.add({ nestedAppAuthRequest: true });
18053
18368
  try {
18054
- const naaRequest = this.nestedAppAuthAdapter.toNaaTokenRequest(request);
18369
+ const naaRequest = this.nestedAppAuthAdapter.toNaaTokenRequest(validRequest);
18055
18370
  const reqTimestamp = nowSeconds();
18056
18371
  const response = await this.bridgeProxy.getTokenInteractive(naaRequest);
18057
18372
  const result = this.nestedAppAuthAdapter.fromNaaTokenResponse(naaRequest, response, reqTimestamp);
@@ -18071,16 +18386,15 @@ class NestedAppAuthController {
18071
18386
  const error = this.nestedAppAuthAdapter.fromBridgeError(e);
18072
18387
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Popup, null, e);
18073
18388
  atPopupMeasurement.end({
18074
- errorCode: error.errorCode,
18075
- subErrorCode: error.subError,
18076
18389
  success: false,
18077
- });
18390
+ }, e);
18078
18391
  throw error;
18079
18392
  }
18080
18393
  }
18081
18394
  async acquireTokenSilentInternal(request) {
18082
- this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
18083
- const ssoSilentMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.SsoSilent, request.correlationId);
18395
+ const validRequest = this.ensureValidRequest(request);
18396
+ this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, validRequest);
18397
+ const ssoSilentMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.SsoSilent, validRequest.correlationId);
18084
18398
  ssoSilentMeasurement?.increment({
18085
18399
  visibilityChangeCount: 0,
18086
18400
  });
@@ -18088,7 +18402,7 @@ class NestedAppAuthController {
18088
18402
  nestedAppAuthRequest: true,
18089
18403
  });
18090
18404
  try {
18091
- const naaRequest = this.nestedAppAuthAdapter.toNaaTokenRequest(request);
18405
+ const naaRequest = this.nestedAppAuthAdapter.toNaaTokenRequest(validRequest);
18092
18406
  const reqTimestamp = nowSeconds();
18093
18407
  const response = await this.bridgeProxy.getTokenSilent(naaRequest);
18094
18408
  const result = this.nestedAppAuthAdapter.fromNaaTokenResponse(naaRequest, response, reqTimestamp);
@@ -18108,10 +18422,8 @@ class NestedAppAuthController {
18108
18422
  const error = this.nestedAppAuthAdapter.fromBridgeError(e);
18109
18423
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, e);
18110
18424
  ssoSilentMeasurement?.end({
18111
- errorCode: error.errorCode,
18112
- subErrorCode: error.subError,
18113
18425
  success: false,
18114
- });
18426
+ }, e);
18115
18427
  throw error;
18116
18428
  }
18117
18429
  }
@@ -18228,7 +18540,7 @@ class NestedAppAuthController {
18228
18540
  }
18229
18541
  handleRedirectPromise(hash // eslint-disable-line @typescript-eslint/no-unused-vars
18230
18542
  ) {
18231
- throw NestedAppAuthError.createUnsupportedError();
18543
+ return Promise.resolve(null);
18232
18544
  }
18233
18545
  loginPopup(request // eslint-disable-line @typescript-eslint/no-unused-vars
18234
18546
  ) {
@@ -18321,11 +18633,6 @@ class NestedAppAuthController {
18321
18633
  getRedirectResponse() {
18322
18634
  throw NestedAppAuthError.createUnsupportedError();
18323
18635
  }
18324
- preflightBrowserEnvironmentCheck(interactionType, // eslint-disable-line @typescript-eslint/no-unused-vars
18325
- setInteractionInProgress // eslint-disable-line @typescript-eslint/no-unused-vars
18326
- ) {
18327
- throw NestedAppAuthError.createUnsupportedError();
18328
- }
18329
18636
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
18330
18637
  async clearCache(logoutRequest) {
18331
18638
  throw NestedAppAuthError.createUnsupportedError();
@@ -18392,6 +18699,7 @@ exports.ServerError = ServerError;
18392
18699
  exports.ServerResponseType = ServerResponseType;
18393
18700
  exports.SignedHttpRequest = SignedHttpRequest;
18394
18701
  exports.StringUtils = StringUtils;
18702
+ exports.StubPerformanceClient = StubPerformanceClient;
18395
18703
  exports.UrlString = UrlString;
18396
18704
  exports.WrapperSKU = WrapperSKU;
18397
18705
  exports.stubbedPublicClientApplication = stubbedPublicClientApplication;