@azure/msal-browser 2.28.3 → 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +19 -10
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +67 -66
  6. package/dist/app/ClientApplication.js.map +1 -1
  7. package/dist/app/IPublicClientApplication.js +1 -1
  8. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  9. package/dist/app/PublicClientApplication.js +35 -10
  10. package/dist/app/PublicClientApplication.js.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  12. package/dist/cache/AsyncMemoryStorage.js +1 -1
  13. package/dist/cache/BrowserCacheManager.js +1 -1
  14. package/dist/cache/BrowserStorage.js +1 -1
  15. package/dist/cache/CryptoKeyStore.js +1 -1
  16. package/dist/cache/DatabaseStorage.js +1 -1
  17. package/dist/cache/ITokenCache.d.ts +6 -3
  18. package/dist/cache/ITokenCache.d.ts.map +1 -1
  19. package/dist/cache/MemoryStorage.js +1 -1
  20. package/dist/cache/TokenCache.d.ts +33 -5
  21. package/dist/cache/TokenCache.d.ts.map +1 -1
  22. package/dist/cache/TokenCache.js +121 -20
  23. package/dist/cache/TokenCache.js.map +1 -1
  24. package/dist/config/Configuration.d.ts +20 -0
  25. package/dist/config/Configuration.d.ts.map +1 -1
  26. package/dist/config/Configuration.js +6 -3
  27. package/dist/config/Configuration.js.map +1 -1
  28. package/dist/crypto/BrowserCrypto.d.ts +19 -59
  29. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  30. package/dist/crypto/BrowserCrypto.js +65 -180
  31. package/dist/crypto/BrowserCrypto.js.map +1 -1
  32. package/dist/crypto/CryptoOps.d.ts +2 -1
  33. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  34. package/dist/crypto/CryptoOps.js +5 -5
  35. package/dist/crypto/CryptoOps.js.map +1 -1
  36. package/dist/crypto/GuidGenerator.js +1 -1
  37. package/dist/crypto/ISubtleCrypto.d.ts +10 -0
  38. package/dist/crypto/ISubtleCrypto.d.ts.map +1 -0
  39. package/dist/crypto/ModernBrowserCrypto.d.ts +10 -0
  40. package/dist/crypto/ModernBrowserCrypto.d.ts.map +1 -0
  41. package/dist/crypto/ModernBrowserCrypto.js +55 -0
  42. package/dist/crypto/ModernBrowserCrypto.js.map +1 -0
  43. package/dist/crypto/MsBrowserCrypto.d.ts +10 -0
  44. package/dist/crypto/MsBrowserCrypto.d.ts.map +1 -0
  45. package/dist/crypto/MsBrowserCrypto.js +112 -0
  46. package/dist/crypto/MsBrowserCrypto.js.map +1 -0
  47. package/dist/crypto/MsrBrowserCrypto.d.ts +18 -0
  48. package/dist/crypto/MsrBrowserCrypto.d.ts.map +1 -0
  49. package/dist/crypto/MsrBrowserCrypto.js +59 -0
  50. package/dist/crypto/MsrBrowserCrypto.js.map +1 -0
  51. package/dist/crypto/PkceGenerator.js +1 -1
  52. package/dist/crypto/SignedHttpRequest.js +1 -1
  53. package/dist/encode/Base64Decode.js +1 -1
  54. package/dist/encode/Base64Encode.js +1 -1
  55. package/dist/error/BrowserAuthError.js +2 -2
  56. package/dist/error/BrowserAuthError.js.map +1 -1
  57. package/dist/error/BrowserConfigurationAuthError.d.ts +8 -0
  58. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  59. package/dist/error/BrowserConfigurationAuthError.js +11 -1
  60. package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
  61. package/dist/error/NativeAuthError.js +1 -1
  62. package/dist/event/EventHandler.js +1 -1
  63. package/dist/event/EventMessage.js +1 -1
  64. package/dist/event/EventType.js +1 -1
  65. package/dist/index.cjs.js +767 -376
  66. package/dist/index.cjs.js.map +1 -1
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +2 -2
  70. package/dist/interaction_client/BaseInteractionClient.js +1 -1
  71. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  72. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  73. package/dist/interaction_client/NativeInteractionClient.js +3 -2
  74. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  75. package/dist/interaction_client/PopupClient.js +4 -4
  76. package/dist/interaction_client/PopupClient.js.map +1 -1
  77. package/dist/interaction_client/RedirectClient.js +1 -1
  78. package/dist/interaction_client/SilentAuthCodeClient.js +2 -2
  79. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  80. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  81. package/dist/interaction_client/SilentCacheClient.js +1 -1
  82. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  83. package/dist/interaction_client/SilentIframeClient.d.ts +1 -1
  84. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  85. package/dist/interaction_client/SilentIframeClient.js +9 -8
  86. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  87. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  88. package/dist/interaction_client/SilentRefreshClient.js +3 -2
  89. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  90. package/dist/interaction_client/StandardInteractionClient.js +1 -1
  91. package/dist/interaction_handler/InteractionHandler.js +1 -1
  92. package/dist/interaction_handler/RedirectHandler.js +1 -1
  93. package/dist/interaction_handler/SilentHandler.d.ts +3 -1
  94. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  95. package/dist/interaction_handler/SilentHandler.js +5 -5
  96. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  97. package/dist/internals.js +1 -1
  98. package/dist/navigation/NavigationClient.js +1 -1
  99. package/dist/network/FetchClient.js +1 -1
  100. package/dist/network/XhrClient.js +1 -1
  101. package/dist/packageMetadata.d.ts +1 -1
  102. package/dist/packageMetadata.js +2 -2
  103. package/dist/packageMetadata.js.map +1 -1
  104. package/dist/request/PopupRequest.d.ts +1 -0
  105. package/dist/request/PopupRequest.d.ts.map +1 -1
  106. package/dist/request/RedirectRequest.d.ts +1 -0
  107. package/dist/request/RedirectRequest.d.ts.map +1 -1
  108. package/dist/request/SilentRequest.d.ts +9 -2
  109. package/dist/request/SilentRequest.d.ts.map +1 -1
  110. package/dist/request/SsoSilentRequest.d.ts +1 -0
  111. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  112. package/dist/telemetry/BrowserPerformanceClient.d.ts +2 -1
  113. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  114. package/dist/telemetry/BrowserPerformanceClient.js +3 -3
  115. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
  116. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  117. package/dist/utils/BrowserConstants.d.ts +9 -1
  118. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  119. package/dist/utils/BrowserConstants.js +41 -4
  120. package/dist/utils/BrowserConstants.js.map +1 -1
  121. package/dist/utils/BrowserProtocolUtils.js +1 -1
  122. package/dist/utils/BrowserStringUtils.d.ts +5 -0
  123. package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
  124. package/dist/utils/BrowserStringUtils.js +8 -1
  125. package/dist/utils/BrowserStringUtils.js.map +1 -1
  126. package/dist/utils/BrowserUtils.js +1 -1
  127. package/dist/utils/MathUtils.js +1 -1
  128. package/lib/msal-browser.js +767 -376
  129. package/lib/msal-browser.js.map +1 -1
  130. package/lib/msal-browser.min.js +37 -37
  131. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.28.3 2022-09-12 */
1
+ /*! @azure/msal-browser v2.30.0 2022-10-10 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -119,7 +119,7 @@
119
119
  return ar;
120
120
  }
121
121
 
122
- /*! @azure/msal-common v7.4.1 2022-09-12 */
122
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
123
123
  /*! *****************************************************************************
124
124
  Copyright (c) Microsoft Corporation.
125
125
 
@@ -206,7 +206,7 @@
206
206
  return r;
207
207
  }
208
208
 
209
- /*! @azure/msal-common v7.4.1 2022-09-12 */
209
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
210
210
 
211
211
  /*
212
212
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -223,6 +223,7 @@
223
223
  DEFAULT_COMMON_TENANT: "common",
224
224
  // ADFS String
225
225
  ADFS: "adfs",
226
+ DSTS: "dstsv2",
226
227
  // Default AAD Instance Discovery Endpoint
227
228
  AAD_INSTANCE_DISCOVERY_ENDPT: "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=",
228
229
  // Resource delimiter - used for certain cache entries
@@ -254,6 +255,7 @@
254
255
  IMDS_TIMEOUT: 2000,
255
256
  AZURE_REGION_AUTO_DISCOVER_FLAG: "TryAutoDetect",
256
257
  REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
258
+ REGIONAL_AUTH_NON_MSI_QUERY_STRING: "allowestsrnonmsi=true",
257
259
  KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
258
260
  TOKEN_RESPONSE_TYPE: "token",
259
261
  ID_TOKEN_RESPONSE_TYPE: "id_token",
@@ -277,6 +279,7 @@
277
279
  HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
278
280
  HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
279
281
  HeaderNames["AuthenticationInfo"] = "Authentication-Info";
282
+ HeaderNames["X_MS_REQUEST_ID"] = "x-ms-request-id";
280
283
  })(HeaderNames || (HeaderNames = {}));
281
284
  /**
282
285
  * Persistent cache keys MSAL which stay while user is logged in.
@@ -372,7 +375,8 @@
372
375
  SELECT_ACCOUNT: "select_account",
373
376
  CONSENT: "consent",
374
377
  NONE: "none",
375
- CREATE: "create"
378
+ CREATE: "create",
379
+ NO_SESSION: "no_session"
376
380
  };
377
381
  /**
378
382
  * SSO Types - generated to populate hints
@@ -583,7 +587,7 @@
583
587
  JsonTypes["Jwk"] = "JWK";
584
588
  })(JsonTypes || (JsonTypes = {}));
585
589
 
586
- /*! @azure/msal-common v7.4.1 2022-09-12 */
590
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
587
591
 
588
592
  /*
589
593
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -639,7 +643,7 @@
639
643
  return AuthError;
640
644
  }(Error));
641
645
 
642
- /*! @azure/msal-common v7.4.1 2022-09-12 */
646
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
643
647
 
644
648
  /*
645
649
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -714,7 +718,7 @@
714
718
  }
715
719
  };
716
720
 
717
- /*! @azure/msal-common v7.4.1 2022-09-12 */
721
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
718
722
 
719
723
  /*
720
724
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -780,6 +784,16 @@
780
784
  code: "nonce_not_found",
781
785
  desc: "nonce not found"
782
786
  },
787
+ authTimeNotFoundError: {
788
+ code: "auth_time_not_found",
789
+ desc: "Max Age was requested and the ID token is missing the auth_time variable." +
790
+ " auth_time is an optional claim and is not enabled by default - it must be enabled." +
791
+ " See https://aka.ms/msaljs/optional-claims for more information."
792
+ },
793
+ maxAgeTranspiredError: {
794
+ code: "max_age_transpired",
795
+ desc: "Max Age is set to 0, or too much time has elapsed since the last end-user authentication."
796
+ },
783
797
  noTokensFoundError: {
784
798
  code: "no_tokens_found",
785
799
  desc: "No tokens were found for the given scopes, and no authorization code was passed to acquireToken. You must retrieve an authorization code before making a call to acquireToken()."
@@ -1000,6 +1014,19 @@
1000
1014
  ClientAuthError.createNonceMismatchError = function () {
1001
1015
  return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code, ClientAuthErrorMessage.nonceMismatchError.desc);
1002
1016
  };
1017
+ /**
1018
+ * Creates an error thrown when max_age was provided in the request, but auth_time is not in the token claims
1019
+ * @param missingNonce
1020
+ */
1021
+ ClientAuthError.createAuthTimeNotFoundError = function () {
1022
+ return new ClientAuthError(ClientAuthErrorMessage.authTimeNotFoundError.code, ClientAuthErrorMessage.authTimeNotFoundError.desc);
1023
+ };
1024
+ /**
1025
+ * Creates an error thrown when too much time has elapsed since the last end-user authentication
1026
+ */
1027
+ ClientAuthError.createMaxAgeTranspiredError = function () {
1028
+ return new ClientAuthError(ClientAuthErrorMessage.maxAgeTranspiredError.code, ClientAuthErrorMessage.maxAgeTranspiredError.desc);
1029
+ };
1003
1030
  /**
1004
1031
  * Creates an error thrown when the mnonce is not present
1005
1032
  * @param missingNonce
@@ -1186,7 +1213,7 @@
1186
1213
  return ClientAuthError;
1187
1214
  }(AuthError));
1188
1215
 
1189
- /*! @azure/msal-common v7.4.1 2022-09-12 */
1216
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
1190
1217
 
1191
1218
  /*
1192
1219
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1311,7 +1338,7 @@
1311
1338
  return StringUtils;
1312
1339
  }());
1313
1340
 
1314
- /*! @azure/msal-common v7.4.1 2022-09-12 */
1341
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
1315
1342
 
1316
1343
  /*
1317
1344
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1491,12 +1518,12 @@
1491
1518
  return Logger;
1492
1519
  }());
1493
1520
 
1494
- /*! @azure/msal-common v7.4.1 2022-09-12 */
1521
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
1495
1522
  /* eslint-disable header/header */
1496
1523
  var name$1 = "@azure/msal-common";
1497
- var version$1 = "7.4.1";
1524
+ var version$1 = "7.6.0";
1498
1525
 
1499
- /*! @azure/msal-common v7.4.1 2022-09-12 */
1526
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
1500
1527
  /*
1501
1528
  * Copyright (c) Microsoft Corporation. All rights reserved.
1502
1529
  * Licensed under the MIT License.
@@ -1517,7 +1544,7 @@
1517
1544
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1518
1545
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1519
1546
 
1520
- /*! @azure/msal-common v7.4.1 2022-09-12 */
1547
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
1521
1548
 
1522
1549
  /*
1523
1550
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1676,7 +1703,7 @@
1676
1703
  return CredentialEntity;
1677
1704
  }());
1678
1705
 
1679
- /*! @azure/msal-common v7.4.1 2022-09-12 */
1706
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
1680
1707
 
1681
1708
  /*
1682
1709
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1724,7 +1751,7 @@
1724
1751
  },
1725
1752
  invalidPrompt: {
1726
1753
  code: "invalid_prompt_value",
1727
- desc: "Supported prompt values are 'login', 'select_account', 'consent', 'create' and 'none'. Please see here for valid configuration options: https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#commonauthorizationurlrequest",
1754
+ desc: "Supported prompt values are 'login', 'select_account', 'consent', 'create', 'none' and 'no_session'. Please see here for valid configuration options: https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#commonauthorizationurlrequest",
1728
1755
  },
1729
1756
  invalidClaimsRequest: {
1730
1757
  code: "invalid_claims",
@@ -1931,7 +1958,7 @@
1931
1958
  return ClientConfigurationError;
1932
1959
  }(ClientAuthError));
1933
1960
 
1934
- /*! @azure/msal-common v7.4.1 2022-09-12 */
1961
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
1935
1962
 
1936
1963
  /*
1937
1964
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2115,7 +2142,7 @@
2115
2142
  return ScopeSet;
2116
2143
  }());
2117
2144
 
2118
- /*! @azure/msal-common v7.4.1 2022-09-12 */
2145
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
2119
2146
 
2120
2147
  /*
2121
2148
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2153,7 +2180,7 @@
2153
2180
  };
2154
2181
  }
2155
2182
 
2156
- /*! @azure/msal-common v7.4.1 2022-09-12 */
2183
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
2157
2184
  /*
2158
2185
  * Copyright (c) Microsoft Corporation. All rights reserved.
2159
2186
  * Licensed under the MIT License.
@@ -2165,9 +2192,10 @@
2165
2192
  (function (AuthorityType) {
2166
2193
  AuthorityType[AuthorityType["Default"] = 0] = "Default";
2167
2194
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2195
+ AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
2168
2196
  })(AuthorityType || (AuthorityType = {}));
2169
2197
 
2170
- /*! @azure/msal-common v7.4.1 2022-09-12 */
2198
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
2171
2199
 
2172
2200
  /*
2173
2201
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2289,10 +2317,13 @@
2289
2317
  // How do you account for MSA CID here?
2290
2318
  account.localAccountId = ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.oid) || ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.sub) || Constants.EMPTY_STRING;
2291
2319
  /*
2292
- * In B2C scenarios the emails claim is used instead of preferred_username and it is an array. In most cases it will contain a single email.
2293
- * This field should not be relied upon if a custom policy is configured to return more than 1 email.
2320
+ * In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
2321
+ * In most cases it will contain a single email. This field should not be relied upon if a custom
2322
+ * policy is configured to return more than 1 email.
2294
2323
  */
2295
- account.username = ((_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username) || (((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] : Constants.EMPTY_STRING);
2324
+ var preferredUsername = (_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username;
2325
+ var email = ((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] : null;
2326
+ account.username = preferredUsername || email || Constants.EMPTY_STRING;
2296
2327
  account.name = (_f = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _f === void 0 ? void 0 : _f.name;
2297
2328
  }
2298
2329
  account.cloudGraphHostName = cloudGraphHostName;
@@ -2307,7 +2338,8 @@
2307
2338
  AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment) {
2308
2339
  var _a, _b, _c, _d;
2309
2340
  var account = new AccountEntity();
2310
- account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
2341
+ account.authorityType = (authority &&
2342
+ authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
2311
2343
  account.homeAccountId = homeAccountId;
2312
2344
  // non AAD scenarios can have empty realm
2313
2345
  account.realm = Constants.EMPTY_STRING;
@@ -2341,7 +2373,7 @@
2341
2373
  var _a;
2342
2374
  var accountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.sub) ? idToken.claims.sub : Constants.EMPTY_STRING;
2343
2375
  // since ADFS does not have tid and does not set client_info
2344
- if (authType === AuthorityType.Adfs) {
2376
+ if (authType === AuthorityType.Adfs || authType === AuthorityType.Dsts) {
2345
2377
  return accountId;
2346
2378
  }
2347
2379
  // for cases where there is clientInfo
@@ -2402,7 +2434,7 @@
2402
2434
  return AccountEntity;
2403
2435
  }());
2404
2436
 
2405
- /*! @azure/msal-common v7.4.1 2022-09-12 */
2437
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
2406
2438
 
2407
2439
  /*
2408
2440
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2437,10 +2469,24 @@
2437
2469
  throw ClientAuthError.createTokenParsingError(err);
2438
2470
  }
2439
2471
  };
2472
+ /**
2473
+ * Determine if the token's max_age has transpired
2474
+ */
2475
+ AuthToken.checkMaxAge = function (authTime, maxAge) {
2476
+ /*
2477
+ * per https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
2478
+ * To force an immediate re-authentication: If an app requires that a user re-authenticate prior to access,
2479
+ * provide a value of 0 for the max_age parameter and the AS will force a fresh login.
2480
+ */
2481
+ var fiveMinuteSkew = 300000; // five minutes in milliseconds
2482
+ if ((maxAge === 0) || ((Date.now() - fiveMinuteSkew) > (authTime + maxAge))) {
2483
+ throw ClientAuthError.createMaxAgeTranspiredError();
2484
+ }
2485
+ };
2440
2486
  return AuthToken;
2441
2487
  }());
2442
2488
 
2443
- /*! @azure/msal-common v7.4.1 2022-09-12 */
2489
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
2444
2490
 
2445
2491
  /*
2446
2492
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2642,7 +2688,11 @@
2642
2688
  if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
2643
2689
  return;
2644
2690
  }
2645
- if (!!homeAccountId && !_this.matchHomeAccountId(entity, homeAccountId)) {
2691
+ /*
2692
+ * homeAccountId can undefined, and we want to filter out cached items that have a homeAccountId of ""
2693
+ * because we don't want a client_credential request to return a cached token that has a homeAccountId
2694
+ */
2695
+ if ((typeof homeAccountId === "string") && !_this.matchHomeAccountId(entity, homeAccountId)) {
2646
2696
  return;
2647
2697
  }
2648
2698
  if (!!environment && !_this.matchEnvironment(entity, environment)) {
@@ -3061,7 +3111,7 @@
3061
3111
  * @param homeAccountId
3062
3112
  */
3063
3113
  CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {
3064
- return !!(entity.homeAccountId && homeAccountId === entity.homeAccountId);
3114
+ return !!((typeof entity.homeAccountId === "string") && (homeAccountId === entity.homeAccountId));
3065
3115
  };
3066
3116
  /**
3067
3117
  * helper to match assertion
@@ -3315,7 +3365,7 @@
3315
3365
  return DefaultStorageClass;
3316
3366
  }(CacheManager));
3317
3367
 
3318
- /*! @azure/msal-common v7.4.1 2022-09-12 */
3368
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
3319
3369
 
3320
3370
  /*
3321
3371
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3409,7 +3459,7 @@
3409
3459
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3410
3460
  }
3411
3461
 
3412
- /*! @azure/msal-common v7.4.1 2022-09-12 */
3462
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
3413
3463
 
3414
3464
  /*
3415
3465
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3429,7 +3479,7 @@
3429
3479
  return ServerError;
3430
3480
  }(AuthError));
3431
3481
 
3432
- /*! @azure/msal-common v7.4.1 2022-09-12 */
3482
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
3433
3483
 
3434
3484
  /*
3435
3485
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3525,7 +3575,7 @@
3525
3575
  return ThrottlingUtils;
3526
3576
  }());
3527
3577
 
3528
- /*! @azure/msal-common v7.4.1 2022-09-12 */
3578
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
3529
3579
 
3530
3580
  /*
3531
3581
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3574,7 +3624,7 @@
3574
3624
  return NetworkManager;
3575
3625
  }());
3576
3626
 
3577
- /*! @azure/msal-common v7.4.1 2022-09-12 */
3627
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
3578
3628
  /*
3579
3629
  * Copyright (c) Microsoft Corporation. All rights reserved.
3580
3630
  * Licensed under the MIT License.
@@ -3585,7 +3635,7 @@
3585
3635
  CcsCredentialType["UPN"] = "UPN";
3586
3636
  })(CcsCredentialType || (CcsCredentialType = {}));
3587
3637
 
3588
- /*! @azure/msal-common v7.4.1 2022-09-12 */
3638
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
3589
3639
 
3590
3640
  /*
3591
3641
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3676,7 +3726,7 @@
3676
3726
  return BaseClient;
3677
3727
  }());
3678
3728
 
3679
- /*! @azure/msal-common v7.4.1 2022-09-12 */
3729
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
3680
3730
 
3681
3731
  /*
3682
3732
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3762,7 +3812,7 @@
3762
3812
  return RequestValidator;
3763
3813
  }());
3764
3814
 
3765
- /*! @azure/msal-common v7.4.1 2022-09-12 */
3815
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
3766
3816
 
3767
3817
  /*
3768
3818
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4140,7 +4190,7 @@
4140
4190
  return RequestParameterBuilder;
4141
4191
  }());
4142
4192
 
4143
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4193
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4144
4194
 
4145
4195
  /*
4146
4196
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4204,7 +4254,7 @@
4204
4254
  return IdTokenEntity;
4205
4255
  }(CredentialEntity));
4206
4256
 
4207
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4257
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4208
4258
  /*
4209
4259
  * Copyright (c) Microsoft Corporation. All rights reserved.
4210
4260
  * Licensed under the MIT License.
@@ -4254,7 +4304,7 @@
4254
4304
  return TimeUtils;
4255
4305
  }());
4256
4306
 
4257
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4307
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4258
4308
 
4259
4309
  /*
4260
4310
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4368,7 +4418,7 @@
4368
4418
  return AccessTokenEntity;
4369
4419
  }(CredentialEntity));
4370
4420
 
4371
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4421
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4372
4422
 
4373
4423
  /*
4374
4424
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4435,7 +4485,7 @@
4435
4485
  return RefreshTokenEntity;
4436
4486
  }(CredentialEntity));
4437
4487
 
4438
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4488
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4439
4489
 
4440
4490
  /*
4441
4491
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4510,7 +4560,7 @@
4510
4560
  return InteractionRequiredAuthError;
4511
4561
  }(AuthError));
4512
4562
 
4513
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4563
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4514
4564
  /*
4515
4565
  * Copyright (c) Microsoft Corporation. All rights reserved.
4516
4566
  * Licensed under the MIT License.
@@ -4526,7 +4576,7 @@
4526
4576
  return CacheRecord;
4527
4577
  }());
4528
4578
 
4529
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4579
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4530
4580
 
4531
4581
  /*
4532
4582
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4597,7 +4647,7 @@
4597
4647
  return ProtocolUtils;
4598
4648
  }());
4599
4649
 
4600
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4650
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4601
4651
 
4602
4652
  /*
4603
4653
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4831,7 +4881,7 @@
4831
4881
  return UrlString;
4832
4882
  }());
4833
4883
 
4834
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4884
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4835
4885
 
4836
4886
  /*
4837
4887
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4932,7 +4982,7 @@
4932
4982
  return PopTokenGenerator;
4933
4983
  }());
4934
4984
 
4935
- /*! @azure/msal-common v7.4.1 2022-09-12 */
4985
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
4936
4986
 
4937
4987
  /*
4938
4988
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5002,7 +5052,7 @@
5002
5052
  return AppMetadataEntity;
5003
5053
  }());
5004
5054
 
5005
- /*! @azure/msal-common v7.4.1 2022-09-12 */
5055
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
5006
5056
  /*
5007
5057
  * Copyright (c) Microsoft Corporation. All rights reserved.
5008
5058
  * Licensed under the MIT License.
@@ -5038,7 +5088,7 @@
5038
5088
  return TokenCacheContext;
5039
5089
  }());
5040
5090
 
5041
- /*! @azure/msal-common v7.4.1 2022-09-12 */
5091
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
5042
5092
 
5043
5093
  /*
5044
5094
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5099,9 +5149,9 @@
5099
5149
  * @param serverTokenResponse
5100
5150
  * @param authority
5101
5151
  */
5102
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
5152
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
5103
5153
  return __awaiter(this, void 0, void 0, function () {
5104
- var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
5154
+ var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
5105
5155
  return __generator(this, function (_a) {
5106
5156
  switch (_a.label) {
5107
5157
  case 0:
@@ -5113,6 +5163,14 @@
5113
5163
  throw ClientAuthError.createNonceMismatchError();
5114
5164
  }
5115
5165
  }
5166
+ // token max_age check
5167
+ if (request.maxAge || (request.maxAge === 0)) {
5168
+ authTime = idTokenObj.claims.auth_time;
5169
+ if (!authTime) {
5170
+ throw ClientAuthError.createAuthTimeNotFoundError();
5171
+ }
5172
+ AuthToken.checkMaxAge(authTime, request.maxAge);
5173
+ }
5116
5174
  }
5117
5175
  // generate homeAccountId
5118
5176
  this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
@@ -5144,7 +5202,7 @@
5144
5202
  account = this.cacheStorage.getAccount(key);
5145
5203
  if (!account) {
5146
5204
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
5147
- return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
5205
+ return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId)];
5148
5206
  }
5149
5207
  }
5150
5208
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
@@ -5159,7 +5217,7 @@
5159
5217
  _a.sent();
5160
5218
  _a.label = 7;
5161
5219
  case 7: return [7 /*endfinally*/];
5162
- case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
5220
+ case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
5163
5221
  }
5164
5222
  });
5165
5223
  });
@@ -5245,7 +5303,7 @@
5245
5303
  * @param fromTokenCache
5246
5304
  * @param stateString
5247
5305
  */
5248
- ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
5306
+ ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code, requestId) {
5249
5307
  var _a, _b, _c;
5250
5308
  return __awaiter(this, void 0, void 0, function () {
5251
5309
  var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
@@ -5293,6 +5351,7 @@
5293
5351
  fromCache: fromTokenCache,
5294
5352
  expiresOn: expiresOn,
5295
5353
  correlationId: request.correlationId,
5354
+ requestId: requestId || Constants.EMPTY_STRING,
5296
5355
  extExpiresOn: extExpiresOn,
5297
5356
  familyId: familyId,
5298
5357
  tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
@@ -5309,7 +5368,7 @@
5309
5368
  return ResponseHandler;
5310
5369
  }());
5311
5370
 
5312
- /*! @azure/msal-common v7.4.1 2022-09-12 */
5371
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
5313
5372
 
5314
5373
  /*
5315
5374
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5355,10 +5414,11 @@
5355
5414
  * @param request
5356
5415
  */
5357
5416
  AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
5417
+ var _a;
5358
5418
  return __awaiter(this, void 0, void 0, function () {
5359
- var reqTimestamp, response, responseHandler;
5360
- return __generator(this, function (_a) {
5361
- switch (_a.label) {
5419
+ var reqTimestamp, response, requestId, responseHandler;
5420
+ return __generator(this, function (_b) {
5421
+ switch (_b.label) {
5362
5422
  case 0:
5363
5423
  this.logger.info("in acquireToken call");
5364
5424
  if (!request || StringUtils.isEmpty(request.code)) {
@@ -5367,12 +5427,13 @@
5367
5427
  reqTimestamp = TimeUtils.nowSeconds();
5368
5428
  return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
5369
5429
  case 1:
5370
- response = _a.sent();
5430
+ response = _b.sent();
5431
+ requestId = (_a = response.headers) === null || _a === void 0 ? void 0 : _a[HeaderNames.X_MS_REQUEST_ID];
5371
5432
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5372
5433
  // Validate response. This function throws a server error if an error is returned by the server.
5373
5434
  responseHandler.validateTokenResponse(response.body);
5374
- return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload)];
5375
- case 2: return [2 /*return*/, _a.sent()];
5435
+ return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)];
5436
+ case 2: return [2 /*return*/, _b.sent()];
5376
5437
  }
5377
5438
  });
5378
5439
  });
@@ -5760,7 +5821,7 @@
5760
5821
  return AuthorizationCodeClient;
5761
5822
  }(BaseClient));
5762
5823
 
5763
- /*! @azure/msal-common v7.4.1 2022-09-12 */
5824
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
5764
5825
  /*
5765
5826
  * Copyright (c) Microsoft Corporation. All rights reserved.
5766
5827
  * Licensed under the MIT License.
@@ -5843,10 +5904,6 @@
5843
5904
  * Used to acquire a token from Native component when native brokering is enabled.
5844
5905
  */
5845
5906
  PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5846
- /**
5847
- * Time spent on the network for refresh token acquisition
5848
- */
5849
- PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5850
5907
  /**
5851
5908
  * Time spent creating default headers for requests to token endpoint
5852
5909
  */
@@ -5860,10 +5917,21 @@
5860
5917
  */
5861
5918
  PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5862
5919
  /**
5863
- * acquireToken API in BrokerClientApplication.
5864
- * Used to acquire a token on behalf of the embedded application (PW-Broker).
5920
+ * Time taken for token acquisition by broker
5865
5921
  */
5866
5922
  PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5923
+ /**
5924
+ * Time spent on the network for refresh token acquisition
5925
+ */
5926
+ PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5927
+ /**
5928
+ * Time taken for acquiring refresh token , records RT size
5929
+ */
5930
+ PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
5931
+ /**
5932
+ * Time taken for acquiring cached refresh token
5933
+ */
5934
+ PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
5867
5935
  })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5868
5936
  /**
5869
5937
  * State of the performance event.
@@ -5878,7 +5946,7 @@
5878
5946
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5879
5947
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
5880
5948
 
5881
- /*! @azure/msal-common v7.4.1 2022-09-12 */
5949
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
5882
5950
 
5883
5951
  /*
5884
5952
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5893,18 +5961,40 @@
5893
5961
  return _super.call(this, configuration, performanceClient) || this;
5894
5962
  }
5895
5963
  RefreshTokenClient.prototype.acquireToken = function (request) {
5964
+ var _a, _b;
5896
5965
  return __awaiter(this, void 0, void 0, function () {
5897
- var reqTimestamp, response, responseHandler;
5898
- return __generator(this, function (_a) {
5899
- switch (_a.label) {
5966
+ var atsMeasurement, reqTimestamp, response, requestId, responseHandler;
5967
+ var _this = this;
5968
+ return __generator(this, function (_c) {
5969
+ switch (_c.label) {
5900
5970
  case 0:
5971
+ atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
5972
+ this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
5901
5973
  reqTimestamp = TimeUtils.nowSeconds();
5902
5974
  return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
5903
5975
  case 1:
5904
- response = _a.sent();
5976
+ response = _c.sent();
5977
+ requestId = (_b = response.headers) === null || _b === void 0 ? void 0 : _b[HeaderNames.X_MS_REQUEST_ID];
5905
5978
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5906
5979
  responseHandler.validateTokenResponse(response.body);
5907
- return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
5980
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
5981
+ var _a;
5982
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
5983
+ success: true,
5984
+ refreshTokenSize: ((_a = response.body.refresh_token) === null || _a === void 0 ? void 0 : _a.length) || 0
5985
+ });
5986
+ return result;
5987
+ })
5988
+ .catch(function (error) {
5989
+ _this.logger.verbose("Error in fetching refresh token", request.correlationId);
5990
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
5991
+ errorCode: error.errorCode,
5992
+ subErrorCode: error.subError,
5993
+ success: false,
5994
+ refreshTokenSize: undefined
5995
+ });
5996
+ throw error;
5997
+ })];
5908
5998
  }
5909
5999
  });
5910
6000
  });
@@ -5954,14 +6044,21 @@
5954
6044
  * @param request
5955
6045
  */
5956
6046
  RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
6047
+ var _a;
5957
6048
  return __awaiter(this, void 0, void 0, function () {
5958
- var refreshToken, refreshTokenRequest;
5959
- return __generator(this, function (_a) {
6049
+ var atsMeasurement, refreshToken, refreshTokenRequest;
6050
+ return __generator(this, function (_b) {
6051
+ atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6052
+ this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
5960
6053
  refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
5961
- // no refresh Token
5962
6054
  if (!refreshToken) {
6055
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.discardMeasurement();
5963
6056
  throw InteractionRequiredAuthError.createNoTokensFoundError();
5964
6057
  }
6058
+ // attach cached RT size to the current measurement
6059
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
6060
+ success: true
6061
+ });
5965
6062
  refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || exports.AuthenticationScheme.BEARER, ccsCredential: {
5966
6063
  credential: request.account.homeAccountId,
5967
6064
  type: CcsCredentialType.HOME_ACCOUNT_ID
@@ -6114,7 +6211,7 @@
6114
6211
  return RefreshTokenClient;
6115
6212
  }(BaseClient));
6116
6213
 
6117
- /*! @azure/msal-common v7.4.1 2022-09-12 */
6214
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
6118
6215
 
6119
6216
  /*
6120
6217
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6214,13 +6311,21 @@
6214
6311
  */
6215
6312
  SilentFlowClient.prototype.generateResultFromCacheRecord = function (cacheRecord, request) {
6216
6313
  return __awaiter(this, void 0, void 0, function () {
6217
- var idTokenObj;
6314
+ var idTokenObj, authTime;
6218
6315
  return __generator(this, function (_a) {
6219
6316
  switch (_a.label) {
6220
6317
  case 0:
6221
6318
  if (cacheRecord.idToken) {
6222
6319
  idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);
6223
6320
  }
6321
+ // token max_age check
6322
+ if (request.maxAge || (request.maxAge === 0)) {
6323
+ authTime = idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.auth_time;
6324
+ if (!authTime) {
6325
+ throw ClientAuthError.createAuthTimeNotFoundError();
6326
+ }
6327
+ AuthToken.checkMaxAge(authTime, request.maxAge);
6328
+ }
6224
6329
  return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, cacheRecord, true, request, idTokenObj)];
6225
6330
  case 1: return [2 /*return*/, _a.sent()];
6226
6331
  }
@@ -6230,7 +6335,7 @@
6230
6335
  return SilentFlowClient;
6231
6336
  }(BaseClient));
6232
6337
 
6233
- /*! @azure/msal-common v7.4.1 2022-09-12 */
6338
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
6234
6339
  /*
6235
6340
  * Copyright (c) Microsoft Corporation. All rights reserved.
6236
6341
  * Licensed under the MIT License.
@@ -6242,7 +6347,7 @@
6242
6347
  response.hasOwnProperty("jwks_uri"));
6243
6348
  }
6244
6349
 
6245
- /*! @azure/msal-common v7.4.1 2022-09-12 */
6350
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
6246
6351
  /*
6247
6352
  * Copyright (c) Microsoft Corporation. All rights reserved.
6248
6353
  * Licensed under the MIT License.
@@ -6251,7 +6356,7 @@
6251
6356
  var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6252
6357
  var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6253
6358
 
6254
- /*! @azure/msal-common v7.4.1 2022-09-12 */
6359
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
6255
6360
  /*
6256
6361
  * Copyright (c) Microsoft Corporation. All rights reserved.
6257
6362
  * Licensed under the MIT License.
@@ -6265,7 +6370,7 @@
6265
6370
  ProtocolMode["OIDC"] = "OIDC";
6266
6371
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
6267
6372
 
6268
- /*! @azure/msal-common v7.4.1 2022-09-12 */
6373
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
6269
6374
 
6270
6375
  /*
6271
6376
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6342,7 +6447,7 @@
6342
6447
  return AuthorityMetadataEntity;
6343
6448
  }());
6344
6449
 
6345
- /*! @azure/msal-common v7.4.1 2022-09-12 */
6450
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
6346
6451
  /*
6347
6452
  * Copyright (c) Microsoft Corporation. All rights reserved.
6348
6453
  * Licensed under the MIT License.
@@ -6352,7 +6457,7 @@
6352
6457
  response.hasOwnProperty("metadata"));
6353
6458
  }
6354
6459
 
6355
- /*! @azure/msal-common v7.4.1 2022-09-12 */
6460
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
6356
6461
 
6357
6462
  /*
6358
6463
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6474,7 +6579,7 @@
6474
6579
  return RegionDiscovery;
6475
6580
  }());
6476
6581
 
6477
- /*! @azure/msal-common v7.4.1 2022-09-12 */
6582
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
6478
6583
 
6479
6584
  /*
6480
6585
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6499,8 +6604,13 @@
6499
6604
  // See above for AuthorityType
6500
6605
  get: function () {
6501
6606
  var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
6502
- if (pathSegments.length && pathSegments[0].toLowerCase() === Constants.ADFS) {
6503
- return AuthorityType.Adfs;
6607
+ if (pathSegments.length) {
6608
+ switch (pathSegments[0].toLowerCase()) {
6609
+ case Constants.ADFS:
6610
+ return AuthorityType.Adfs;
6611
+ case Constants.DSTS:
6612
+ return AuthorityType.Dsts;
6613
+ }
6504
6614
  }
6505
6615
  return AuthorityType.Default;
6506
6616
  },
@@ -6704,7 +6814,9 @@
6704
6814
  * The default open id configuration endpoint for any canonical authority.
6705
6815
  */
6706
6816
  get: function () {
6707
- if (this.authorityType === AuthorityType.Adfs || this.protocolMode === exports.ProtocolMode.OIDC) {
6817
+ if (this.authorityType === AuthorityType.Adfs ||
6818
+ this.authorityType === AuthorityType.Dsts ||
6819
+ this.protocolMode === exports.ProtocolMode.OIDC) {
6708
6820
  return this.canonicalAuthority + ".well-known/openid-configuration";
6709
6821
  }
6710
6822
  return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
@@ -6802,8 +6914,9 @@
6802
6914
  });
6803
6915
  };
6804
6916
  /**
6805
- * Compares the number of url components after the domain to determine if the cached authority metadata can be used for the requested authority
6806
- * Protects against same domain different authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
6917
+ * Compares the number of url components after the domain to determine if the cached
6918
+ * authority metadata can be used for the requested authority. Protects against same domain different
6919
+ * authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
6807
6920
  * @param metadataEntity
6808
6921
  */
6809
6922
  Authority.prototype.isAuthoritySameType = function (metadataEntity) {
@@ -6843,7 +6956,8 @@
6843
6956
  _a.label = 1;
6844
6957
  case 1:
6845
6958
  _a.trys.push([1, 3, , 4]);
6846
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
6959
+ return [4 /*yield*/, this.networkInterface.
6960
+ sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
6847
6961
  case 2:
6848
6962
  response = _a.sent();
6849
6963
  return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
@@ -6904,7 +7018,8 @@
6904
7018
  });
6905
7019
  };
6906
7020
  /**
6907
- * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
7021
+ * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
7022
+ * and returns where the information was retrieved from
6908
7023
  * @param cachedMetadata
6909
7024
  * @param newMetadata
6910
7025
  */
@@ -7127,7 +7242,7 @@
7127
7242
  Authority.replaceWithRegionalInformation = function (metadata, azureRegion) {
7128
7243
  metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
7129
7244
  // TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
7130
- metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, "allowestsrnonmsi=true");
7245
+ metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
7131
7246
  if (metadata.end_session_endpoint) {
7132
7247
  metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
7133
7248
  }
@@ -7136,7 +7251,7 @@
7136
7251
  return Authority;
7137
7252
  }());
7138
7253
 
7139
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7254
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7140
7255
 
7141
7256
  /*
7142
7257
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7197,7 +7312,7 @@
7197
7312
  return AuthorityFactory;
7198
7313
  }());
7199
7314
 
7200
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7315
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7201
7316
 
7202
7317
  /*
7203
7318
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7228,7 +7343,7 @@
7228
7343
  return ServerTelemetryEntity;
7229
7344
  }());
7230
7345
 
7231
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7346
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7232
7347
 
7233
7348
  /*
7234
7349
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7256,7 +7371,7 @@
7256
7371
  return ThrottlingEntity;
7257
7372
  }());
7258
7373
 
7259
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7374
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7260
7375
 
7261
7376
  /*
7262
7377
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7273,7 +7388,7 @@
7273
7388
  }
7274
7389
  };
7275
7390
 
7276
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7391
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7277
7392
 
7278
7393
  /*
7279
7394
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7318,7 +7433,7 @@
7318
7433
  return JoseHeaderError;
7319
7434
  }(AuthError));
7320
7435
 
7321
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7436
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7322
7437
 
7323
7438
  /*
7324
7439
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7358,7 +7473,7 @@
7358
7473
  return JoseHeader;
7359
7474
  }());
7360
7475
 
7361
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7476
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7362
7477
 
7363
7478
  /*
7364
7479
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7417,7 +7532,7 @@
7417
7532
  return AuthenticationHeaderParser;
7418
7533
  }());
7419
7534
 
7420
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7535
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7421
7536
 
7422
7537
  /*
7423
7538
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7579,7 +7694,7 @@
7579
7694
  return ServerTelemetryManager;
7580
7695
  }());
7581
7696
 
7582
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7697
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7583
7698
 
7584
7699
  /*
7585
7700
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7788,6 +7903,9 @@
7788
7903
  if (current.idTokenSize) {
7789
7904
  previous.idTokenSize = current.idTokenSize;
7790
7905
  }
7906
+ if (current.refreshTokenSize) {
7907
+ previous.refreshTokenSize = current.refreshTokenSize;
7908
+ }
7791
7909
  }
7792
7910
  return previous;
7793
7911
  }, topLevelEvent);
@@ -7855,7 +7973,7 @@
7855
7973
  return PerformanceClient;
7856
7974
  }());
7857
7975
 
7858
- /*! @azure/msal-common v7.4.1 2022-09-12 */
7976
+ /*! @azure/msal-common v7.6.0 2022-10-10 */
7859
7977
 
7860
7978
  /*
7861
7979
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7981,7 +8099,7 @@
7981
8099
  },
7982
8100
  silentPromptValueError: {
7983
8101
  code: "silent_prompt_value_error",
7984
- desc: "The value given for the prompt value is not valid for silent requests - must be set to 'none'."
8102
+ desc: "The value given for the prompt value is not valid for silent requests - must be set to 'none' or 'no_session'."
7985
8103
  },
7986
8104
  noTokenRequestCacheError: {
7987
8105
  code: "no_token_request_cache_error",
@@ -8393,7 +8511,7 @@
8393
8511
  /**
8394
8512
  * Default popup monitor poll interval in milliseconds
8395
8513
  */
8396
- POLL_INTERVAL_MS: 50,
8514
+ DEFAULT_POLL_INTERVAL_MS: 30,
8397
8515
  /**
8398
8516
  * Msal-browser SKU
8399
8517
  */
@@ -8532,7 +8650,44 @@
8532
8650
  // DatabaseStorage Constants
8533
8651
  var DB_NAME = "msal.db";
8534
8652
  var DB_VERSION = 1;
8535
- var DB_TABLE_NAME = DB_NAME + ".keys";
8653
+ var DB_TABLE_NAME = DB_NAME + ".keys";
8654
+ exports.CacheLookupPolicy = void 0;
8655
+ (function (CacheLookupPolicy) {
8656
+ /*
8657
+ * acquireTokenSilent will attempt to retrieve an access token from the cache. If the access token is expired
8658
+ * or cannot be found the refresh token will be used to acquire a new one. Finally, if the refresh token
8659
+ * is expired acquireTokenSilent will attempt to acquire new access and refresh tokens.
8660
+ */
8661
+ CacheLookupPolicy[CacheLookupPolicy["Default"] = 0] = "Default";
8662
+ /*
8663
+ * acquireTokenSilent will only look for access tokens in the cache. It will not attempt to renew access or
8664
+ * refresh tokens.
8665
+ */
8666
+ CacheLookupPolicy[CacheLookupPolicy["AccessToken"] = 1] = "AccessToken";
8667
+ /*
8668
+ * acquireTokenSilent will attempt to retrieve an access token from the cache. If the access token is expired or
8669
+ * cannot be found, the refresh token will be used to acquire a new one. If the refresh token is expired, it
8670
+ * will not be renewed and acquireTokenSilent will fail.
8671
+ */
8672
+ CacheLookupPolicy[CacheLookupPolicy["AccessTokenAndRefreshToken"] = 2] = "AccessTokenAndRefreshToken";
8673
+ /*
8674
+ * acquireTokenSilent will not attempt to retrieve access tokens from the cache and will instead attempt to
8675
+ * exchange the cached refresh token for a new access token. If the refresh token is expired, it will not be
8676
+ * renewed and acquireTokenSilent will fail.
8677
+ */
8678
+ CacheLookupPolicy[CacheLookupPolicy["RefreshToken"] = 3] = "RefreshToken";
8679
+ /*
8680
+ * acquireTokenSilent will not look in the cache for the access token. It will go directly to network with the
8681
+ * cached refresh token. If the refresh token is expired an attempt will be made to renew it. This is equivalent to
8682
+ * setting "forceRefresh: true".
8683
+ */
8684
+ CacheLookupPolicy[CacheLookupPolicy["RefreshTokenAndNetwork"] = 4] = "RefreshTokenAndNetwork";
8685
+ /*
8686
+ * acquireTokenSilent will attempt to renew both access and refresh tokens. It will not look in the cache. This will
8687
+ * always fail if 3rd party cookies are blocked by the browser.
8688
+ */
8689
+ CacheLookupPolicy[CacheLookupPolicy["Skip"] = 5] = "Skip";
8690
+ })(exports.CacheLookupPolicy || (exports.CacheLookupPolicy = {}));
8536
8691
 
8537
8692
  /*
8538
8693
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8571,6 +8726,10 @@
8571
8726
  inMemRedirectUnavailable: {
8572
8727
  code: "in_mem_redirect_unavailable",
8573
8728
  desc: "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."
8729
+ },
8730
+ entropyNotProvided: {
8731
+ code: "entropy_not_provided",
8732
+ desc: "The available browser crypto interface requires entropy set via system.cryptoOptions.entropy configuration option."
8574
8733
  }
8575
8734
  };
8576
8735
  /**
@@ -8621,6 +8780,12 @@
8621
8780
  BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError = function () {
8622
8781
  return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.inMemRedirectUnavailable.code, BrowserConfigurationAuthErrorMessage.inMemRedirectUnavailable.desc);
8623
8782
  };
8783
+ /**
8784
+ * Creates an error thrown when a crypto interface that requires entropy is initialized without entropy
8785
+ */
8786
+ BrowserConfigurationAuthError.createEntropyNotProvided = function () {
8787
+ return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.entropyNotProvided.code, BrowserConfigurationAuthErrorMessage.entropyNotProvided.desc);
8788
+ };
8624
8789
  return BrowserConfigurationAuthError;
8625
8790
  }(AuthError));
8626
8791
 
@@ -9683,7 +9848,7 @@
9683
9848
 
9684
9849
  /* eslint-disable header/header */
9685
9850
  var name = "@azure/msal-browser";
9686
- var version = "2.28.3";
9851
+ var version = "2.30.0";
9687
9852
 
9688
9853
  /*
9689
9854
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11086,7 +11251,8 @@
11086
11251
  .then(function (result) {
11087
11252
  nativeATMeasurement.endMeasurement({
11088
11253
  success: true,
11089
- isNativeBroker: true
11254
+ isNativeBroker: true,
11255
+ requestId: result.requestId
11090
11256
  });
11091
11257
  return result;
11092
11258
  })
@@ -12302,7 +12468,7 @@
12302
12468
  * Polling for popups needs to be tick-based,
12303
12469
  * since a non-trivial amount of time can be spent on interaction (which should not count against the timeout).
12304
12470
  */
12305
- var maxTicks = _this.config.system.windowHashTimeout / BrowserConstants.POLL_INTERVAL_MS;
12471
+ var maxTicks = _this.config.system.windowHashTimeout / _this.config.system.pollIntervalMilliseconds;
12306
12472
  var ticks = 0;
12307
12473
  _this.logger.verbose("PopupHandler.monitorPopupForHash - polling started");
12308
12474
  var intervalId = setInterval(function () {
@@ -12355,7 +12521,7 @@
12355
12521
  clearInterval(intervalId);
12356
12522
  reject(BrowserAuthError.createMonitorPopupTimeoutError());
12357
12523
  }
12358
- }, BrowserConstants.POLL_INTERVAL_MS);
12524
+ }, _this.config.system.pollIntervalMilliseconds);
12359
12525
  });
12360
12526
  };
12361
12527
  /**
@@ -12393,7 +12559,7 @@
12393
12559
  clearInterval(intervalId);
12394
12560
  _this.cleanPopup(popupWindow);
12395
12561
  resolve();
12396
- }, BrowserConstants.POLL_INTERVAL_MS);
12562
+ }, _this.config.system.pollIntervalMilliseconds);
12397
12563
  });
12398
12564
  };
12399
12565
  /**
@@ -12626,7 +12792,10 @@
12626
12792
  // Default system options for browser
12627
12793
  var DEFAULT_BROWSER_SYSTEM_OPTIONS = __assign$1(__assign$1({}, DEFAULT_SYSTEM_OPTIONS), { loggerOptions: DEFAULT_LOGGER_OPTIONS, networkClient: isBrowserEnvironment ? BrowserUtils.getBrowserNetworkClient() : StubbedNetworkModule, navigationClient: new NavigationClient(), loadFrameTimeout: 0,
12628
12794
  // If loadFrameTimeout is provided, use that as default.
12629
- windowHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS, iframeHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS, navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0, redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS, asyncPopups: false, allowRedirectInIframe: false, allowNativeBroker: false, nativeBrokerHandshakeTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.nativeBrokerHandshakeTimeout) || DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS });
12795
+ windowHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_POPUP_TIMEOUT_MS, iframeHashTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.loadFrameTimeout) || DEFAULT_IFRAME_TIMEOUT_MS, navigateFrameWait: isBrowserEnvironment && BrowserUtils.detectIEOrEdge() ? 500 : 0, redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS, asyncPopups: false, allowRedirectInIframe: false, allowNativeBroker: false, nativeBrokerHandshakeTimeout: (userInputSystem === null || userInputSystem === void 0 ? void 0 : userInputSystem.nativeBrokerHandshakeTimeout) || DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS, pollIntervalMilliseconds: BrowserConstants.DEFAULT_POLL_INTERVAL_MS, cryptoOptions: {
12796
+ useMsrCrypto: false,
12797
+ entropy: undefined
12798
+ } });
12630
12799
  var DEFAULT_TELEMETRY_OPTIONS = {
12631
12800
  application: {
12632
12801
  appName: Constants.EMPTY_STRING,
@@ -12648,9 +12817,10 @@
12648
12817
  */
12649
12818
  var SilentHandler = /** @class */ (function (_super) {
12650
12819
  __extends$1(SilentHandler, _super);
12651
- function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, navigateFrameWait) {
12820
+ function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, systemOptions) {
12652
12821
  var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
12653
- _this.navigateFrameWait = navigateFrameWait;
12822
+ _this.navigateFrameWait = systemOptions.navigateFrameWait;
12823
+ _this.pollIntervalMilliseconds = systemOptions.pollIntervalMilliseconds;
12654
12824
  return _this;
12655
12825
  }
12656
12826
  /**
@@ -12728,7 +12898,7 @@
12728
12898
  resolve(contentHash);
12729
12899
  return;
12730
12900
  }
12731
- }, BrowserConstants.POLL_INTERVAL_MS);
12901
+ }, _this.pollIntervalMilliseconds);
12732
12902
  });
12733
12903
  };
12734
12904
  /**
@@ -12807,7 +12977,7 @@
12807
12977
  return _this;
12808
12978
  }
12809
12979
  /**
12810
- * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none
12980
+ * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none or prompt=no_session
12811
12981
  * @param request
12812
12982
  */
12813
12983
  SilentIframeClient.prototype.acquireToken = function (request) {
@@ -12822,14 +12992,14 @@
12822
12992
  if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {
12823
12993
  this.logger.warning("No user hint provided. The authorization server may need more information to complete this request.");
12824
12994
  }
12825
- // Check that prompt is set to none, throw error if it is set to anything else.
12826
- if (request.prompt && request.prompt !== PromptValue.NONE) {
12995
+ // Check that prompt is set to none or no_session, throw error if it is set to anything else.
12996
+ if (request.prompt && (request.prompt !== PromptValue.NONE) && (request.prompt !== PromptValue.NO_SESSION)) {
12827
12997
  acquireTokenMeasurement.endMeasurement({
12828
12998
  success: false
12829
12999
  });
12830
13000
  throw BrowserAuthError.createSilentPromptValueError(request.prompt);
12831
13001
  }
12832
- return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent)];
13002
+ return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: request.prompt || PromptValue.NONE }), exports.InteractionType.Silent)];
12833
13003
  case 1:
12834
13004
  silentRequest = _a.sent();
12835
13005
  this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || Constants.EMPTY_STRING, silentRequest.account || null);
@@ -12844,7 +13014,8 @@
12844
13014
  return [4 /*yield*/, this.silentTokenHelper(authClient, silentRequest).then(function (result) {
12845
13015
  acquireTokenMeasurement.endMeasurement({
12846
13016
  success: true,
12847
- fromCache: false
13017
+ fromCache: false,
13018
+ requestId: result.requestId
12848
13019
  });
12849
13020
  return result;
12850
13021
  })];
@@ -12892,7 +13063,7 @@
12892
13063
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, silentRequest), { nativeBroker: NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, silentRequest.authenticationScheme) }))];
12893
13064
  case 2:
12894
13065
  navigateUrl = _a.sent();
12895
- silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system.navigateFrameWait);
13066
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
12896
13067
  return [4 /*yield*/, silentHandler.initiateAuthRequest(navigateUrl)];
12897
13068
  case 3:
12898
13069
  msalFrame = _a.sent();
@@ -12908,7 +13079,7 @@
12908
13079
  }
12909
13080
  nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.apiId, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.browserStorage, this.correlationId);
12910
13081
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
12911
- return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
13082
+ return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: silentRequest.prompt || PromptValue.NONE })).finally(function () {
12912
13083
  _this.browserStorage.cleanRequestByState(state);
12913
13084
  })];
12914
13085
  }
@@ -12956,7 +13127,8 @@
12956
13127
  .then(function (result) {
12957
13128
  acquireTokenMeasurement.endMeasurement({
12958
13129
  success: true,
12959
- fromCache: result.fromCache
13130
+ fromCache: result.fromCache,
13131
+ requestId: result.requestId
12960
13132
  });
12961
13133
  return result;
12962
13134
  })
@@ -13362,6 +13534,13 @@
13362
13534
  }
13363
13535
  return sView;
13364
13536
  };
13537
+ /**
13538
+ * Returns stringified jwk.
13539
+ * @param jwk
13540
+ */
13541
+ BrowserStringUtils.getSortedObjectString = function (obj) {
13542
+ return JSON.stringify(obj, Object.keys(obj).sort());
13543
+ };
13365
13544
  return BrowserStringUtils;
13366
13545
  }());
13367
13546
 
@@ -13604,178 +13783,117 @@
13604
13783
  * Copyright (c) Microsoft Corporation. All rights reserved.
13605
13784
  * Licensed under the MIT License.
13606
13785
  */
13607
- /**
13608
- * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
13609
- */
13610
- // RSA KeyGen Algorithm
13611
- var PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
13612
- // SHA-256 hashing algorithm
13613
- var S256_HASH_ALG = "SHA-256";
13614
- // MOD length for PoP tokens
13615
- var MODULUS_LENGTH = 2048;
13616
- // Public Exponent
13617
- var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
13618
- /**
13619
- * This class implements functions used by the browser library to perform cryptography operations such as
13620
- * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
13621
- */
13622
- var BrowserCrypto = /** @class */ (function () {
13623
- function BrowserCrypto(logger) {
13624
- this.logger = logger;
13625
- if (!(this.hasCryptoAPI())) {
13626
- throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto or msCrypto object not available.");
13627
- }
13628
- this._keygenAlgorithmOptions = {
13629
- name: PKCS1_V15_KEYGEN_ALG,
13630
- hash: S256_HASH_ALG,
13631
- modulusLength: MODULUS_LENGTH,
13632
- publicExponent: PUBLIC_EXPONENT
13633
- };
13786
+ var ModernBrowserCrypto = /** @class */ (function () {
13787
+ function ModernBrowserCrypto() {
13634
13788
  }
13635
- /**
13636
- * Returns a sha-256 hash of the given dataString as an ArrayBuffer.
13637
- * @param dataString
13638
- */
13639
- BrowserCrypto.prototype.sha256Digest = function (dataString) {
13789
+ ModernBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
13790
+ return window.crypto.getRandomValues(dataBuffer);
13791
+ };
13792
+ ModernBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
13640
13793
  return __awaiter$1(this, void 0, void 0, function () {
13641
- var data;
13642
13794
  return __generator$1(this, function (_a) {
13643
- data = BrowserStringUtils.stringToUtf8Arr(dataString);
13644
- return [2 /*return*/, this.hasIECrypto() ? this.getMSCryptoDigest(S256_HASH_ALG, data) : this.getSubtleCryptoDigest(S256_HASH_ALG, data)];
13795
+ return [2 /*return*/, window.crypto.subtle.generateKey(algorithm, extractable, keyUsages)];
13645
13796
  });
13646
13797
  });
13647
13798
  };
13648
- /**
13649
- * Populates buffer with cryptographically random values.
13650
- * @param dataBuffer
13651
- */
13652
- BrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
13653
- var cryptoObj = window["msCrypto"] || window.crypto;
13654
- if (!cryptoObj.getRandomValues) {
13655
- throw BrowserAuthError.createCryptoNotAvailableError("getRandomValues does not exist.");
13656
- }
13657
- cryptoObj.getRandomValues(dataBuffer);
13658
- };
13659
- /**
13660
- * Generates a keypair based on current keygen algorithm config.
13661
- * @param extractable
13662
- * @param usages
13663
- */
13664
- BrowserCrypto.prototype.generateKeyPair = function (extractable, usages) {
13799
+ ModernBrowserCrypto.prototype.exportKey = function (key) {
13665
13800
  return __awaiter$1(this, void 0, void 0, function () {
13666
13801
  return __generator$1(this, function (_a) {
13667
- return [2 /*return*/, (this.hasIECrypto() ?
13668
- this.msCryptoGenerateKey(extractable, usages)
13669
- : window.crypto.subtle.generateKey(this._keygenAlgorithmOptions, extractable, usages))];
13802
+ return [2 /*return*/, window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key)];
13670
13803
  });
13671
13804
  });
13672
13805
  };
13673
- /**
13674
- * Export key as Json Web Key (JWK)
13675
- * @param key
13676
- * @param format
13677
- */
13678
- BrowserCrypto.prototype.exportJwk = function (key) {
13806
+ ModernBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
13679
13807
  return __awaiter$1(this, void 0, void 0, function () {
13680
13808
  return __generator$1(this, function (_a) {
13681
- return [2 /*return*/, this.hasIECrypto() ? this.msCryptoExportJwk(key) : window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key)];
13809
+ return [2 /*return*/, window.crypto.subtle.importKey(KEY_FORMAT_JWK, keyData, algorithm, extractable, keyUsages)];
13682
13810
  });
13683
13811
  });
13684
13812
  };
13685
- /**
13686
- * Imports key as Json Web Key (JWK), can set extractable and usages.
13687
- * @param key
13688
- * @param format
13689
- * @param extractable
13690
- * @param usages
13691
- */
13692
- BrowserCrypto.prototype.importJwk = function (key, extractable, usages) {
13813
+ ModernBrowserCrypto.prototype.sign = function (algorithm, key, data) {
13693
13814
  return __awaiter$1(this, void 0, void 0, function () {
13694
- var keyString, keyBuffer;
13695
13815
  return __generator$1(this, function (_a) {
13696
- keyString = BrowserCrypto.getJwkString(key);
13697
- keyBuffer = BrowserStringUtils.stringToArrayBuffer(keyString);
13698
- return [2 /*return*/, this.hasIECrypto() ?
13699
- this.msCryptoImportKey(keyBuffer, extractable, usages)
13700
- : window.crypto.subtle.importKey(KEY_FORMAT_JWK, key, this._keygenAlgorithmOptions, extractable, usages)];
13816
+ return [2 /*return*/, window.crypto.subtle.sign(algorithm, key, data)];
13701
13817
  });
13702
13818
  });
13703
13819
  };
13704
- /**
13705
- * Signs given data with given key
13706
- * @param key
13707
- * @param data
13708
- */
13709
- BrowserCrypto.prototype.sign = function (key, data) {
13820
+ ModernBrowserCrypto.prototype.digest = function (algorithm, data) {
13710
13821
  return __awaiter$1(this, void 0, void 0, function () {
13711
13822
  return __generator$1(this, function (_a) {
13712
- return [2 /*return*/, this.hasIECrypto() ?
13713
- this.msCryptoSign(key, data)
13714
- : window.crypto.subtle.sign(this._keygenAlgorithmOptions, key, data)];
13823
+ return [2 /*return*/, window.crypto.subtle.digest(algorithm, data)];
13715
13824
  });
13716
13825
  });
13717
13826
  };
13718
- /**
13719
- * Check whether IE crypto or other browser cryptography is available.
13720
- */
13721
- BrowserCrypto.prototype.hasCryptoAPI = function () {
13722
- return this.hasIECrypto() || this.hasBrowserCrypto();
13827
+ return ModernBrowserCrypto;
13828
+ }());
13829
+
13830
+ /*
13831
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13832
+ * Licensed under the MIT License.
13833
+ */
13834
+ var MsrBrowserCrypto = /** @class */ (function () {
13835
+ function MsrBrowserCrypto() {
13836
+ }
13837
+ MsrBrowserCrypto.prototype.initPrng = function (entropy) {
13838
+ // Turn into array, as initPrng seems to not always like Uint8Array (even though it should support both)
13839
+ return window.msrCrypto.initPrng(__spread(entropy));
13723
13840
  };
13724
- /**
13725
- * Checks whether IE crypto (AKA msCrypto) is available.
13726
- */
13727
- BrowserCrypto.prototype.hasIECrypto = function () {
13728
- return "msCrypto" in window;
13841
+ MsrBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
13842
+ return window.msrCrypto.getRandomValues(dataBuffer);
13729
13843
  };
13730
- /**
13731
- * Check whether browser crypto is available.
13732
- */
13733
- BrowserCrypto.prototype.hasBrowserCrypto = function () {
13734
- return "crypto" in window;
13844
+ MsrBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
13845
+ return __awaiter$1(this, void 0, void 0, function () {
13846
+ return __generator$1(this, function (_a) {
13847
+ return [2 /*return*/, window.msrCrypto.subtle.generateKey(algorithm, extractable, keyUsages)];
13848
+ });
13849
+ });
13735
13850
  };
13736
- /**
13737
- * Helper function for SHA digest.
13738
- * @param algorithm
13739
- * @param data
13740
- */
13741
- BrowserCrypto.prototype.getSubtleCryptoDigest = function (algorithm, data) {
13851
+ MsrBrowserCrypto.prototype.exportKey = function (key) {
13742
13852
  return __awaiter$1(this, void 0, void 0, function () {
13743
13853
  return __generator$1(this, function (_a) {
13744
- return [2 /*return*/, window.crypto.subtle.digest(algorithm, data)];
13854
+ return [2 /*return*/, window.msrCrypto.subtle.exportKey(KEY_FORMAT_JWK, key)];
13745
13855
  });
13746
13856
  });
13747
13857
  };
13748
- /**
13749
- * IE Helper function for SHA digest.
13750
- * @param algorithm
13751
- * @param data
13752
- */
13753
- BrowserCrypto.prototype.getMSCryptoDigest = function (algorithm, data) {
13858
+ MsrBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
13754
13859
  return __awaiter$1(this, void 0, void 0, function () {
13755
13860
  return __generator$1(this, function (_a) {
13756
- return [2 /*return*/, new Promise(function (resolve, reject) {
13757
- var digestOperation = window["msCrypto"].subtle.digest(algorithm, data.buffer);
13758
- digestOperation.addEventListener("complete", function (e) {
13759
- resolve(e.target.result);
13760
- });
13761
- digestOperation.addEventListener("error", function (error) {
13762
- reject(error);
13763
- });
13764
- })];
13861
+ return [2 /*return*/, window.msrCrypto.subtle.importKey(KEY_FORMAT_JWK, keyData, algorithm, extractable, keyUsages)];
13765
13862
  });
13766
13863
  });
13767
13864
  };
13768
- /**
13769
- * IE Helper function for generating a keypair
13770
- * @param extractable
13771
- * @param usages
13772
- */
13773
- BrowserCrypto.prototype.msCryptoGenerateKey = function (extractable, usages) {
13865
+ MsrBrowserCrypto.prototype.sign = function (algorithm, key, data) {
13866
+ return __awaiter$1(this, void 0, void 0, function () {
13867
+ return __generator$1(this, function (_a) {
13868
+ return [2 /*return*/, window.msrCrypto.subtle.sign(algorithm, key, data)];
13869
+ });
13870
+ });
13871
+ };
13872
+ MsrBrowserCrypto.prototype.digest = function (algorithm, data) {
13873
+ return __awaiter$1(this, void 0, void 0, function () {
13874
+ return __generator$1(this, function (_a) {
13875
+ return [2 /*return*/, window.msrCrypto.subtle.digest(algorithm, data)];
13876
+ });
13877
+ });
13878
+ };
13879
+ return MsrBrowserCrypto;
13880
+ }());
13881
+
13882
+ /*
13883
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13884
+ * Licensed under the MIT License.
13885
+ */
13886
+ var MsBrowserCrypto = /** @class */ (function () {
13887
+ function MsBrowserCrypto() {
13888
+ }
13889
+ MsBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
13890
+ return window["msCrypto"].getRandomValues(dataBuffer);
13891
+ };
13892
+ MsBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
13774
13893
  return __awaiter$1(this, void 0, void 0, function () {
13775
- var _this = this;
13776
13894
  return __generator$1(this, function (_a) {
13777
13895
  return [2 /*return*/, new Promise(function (resolve, reject) {
13778
- var msGenerateKey = window["msCrypto"].subtle.generateKey(_this._keygenAlgorithmOptions, extractable, usages);
13896
+ var msGenerateKey = window["msCrypto"].subtle.generateKey(algorithm, extractable, keyUsages);
13779
13897
  msGenerateKey.addEventListener("complete", function (e) {
13780
13898
  resolve(e.target.result);
13781
13899
  });
@@ -13786,12 +13904,7 @@
13786
13904
  });
13787
13905
  });
13788
13906
  };
13789
- /**
13790
- * IE Helper function for exportKey
13791
- * @param key
13792
- * @param format
13793
- */
13794
- BrowserCrypto.prototype.msCryptoExportJwk = function (key) {
13907
+ MsBrowserCrypto.prototype.exportKey = function (key) {
13795
13908
  return __awaiter$1(this, void 0, void 0, function () {
13796
13909
  return __generator$1(this, function (_a) {
13797
13910
  return [2 /*return*/, new Promise(function (resolve, reject) {
@@ -13818,19 +13931,14 @@
13818
13931
  });
13819
13932
  });
13820
13933
  };
13821
- /**
13822
- * IE Helper function for importKey
13823
- * @param key
13824
- * @param format
13825
- * @param extractable
13826
- * @param usages
13827
- */
13828
- BrowserCrypto.prototype.msCryptoImportKey = function (keyBuffer, extractable, usages) {
13934
+ MsBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
13829
13935
  return __awaiter$1(this, void 0, void 0, function () {
13830
- var _this = this;
13936
+ var keyString, keyBuffer;
13831
13937
  return __generator$1(this, function (_a) {
13938
+ keyString = BrowserStringUtils.getSortedObjectString(keyData);
13939
+ keyBuffer = BrowserStringUtils.stringToArrayBuffer(keyString);
13832
13940
  return [2 /*return*/, new Promise(function (resolve, reject) {
13833
- var msImportKey = window["msCrypto"].subtle.importKey(KEY_FORMAT_JWK, keyBuffer, _this._keygenAlgorithmOptions, extractable, usages);
13941
+ var msImportKey = window["msCrypto"].subtle.importKey(KEY_FORMAT_JWK, keyBuffer, algorithm, extractable, keyUsages);
13834
13942
  msImportKey.addEventListener("complete", function (e) {
13835
13943
  resolve(e.target.result);
13836
13944
  });
@@ -13841,17 +13949,11 @@
13841
13949
  });
13842
13950
  });
13843
13951
  };
13844
- /**
13845
- * IE Helper function for sign JWT
13846
- * @param key
13847
- * @param data
13848
- */
13849
- BrowserCrypto.prototype.msCryptoSign = function (key, data) {
13952
+ MsBrowserCrypto.prototype.sign = function (algorithm, key, data) {
13850
13953
  return __awaiter$1(this, void 0, void 0, function () {
13851
- var _this = this;
13852
13954
  return __generator$1(this, function (_a) {
13853
13955
  return [2 /*return*/, new Promise(function (resolve, reject) {
13854
- var msSign = window["msCrypto"].subtle.sign(_this._keygenAlgorithmOptions, key, data);
13956
+ var msSign = window["msCrypto"].subtle.sign(algorithm, key, data);
13855
13957
  msSign.addEventListener("complete", function (e) {
13856
13958
  resolve(e.target.result);
13857
13959
  });
@@ -13862,12 +13964,175 @@
13862
13964
  });
13863
13965
  });
13864
13966
  };
13967
+ MsBrowserCrypto.prototype.digest = function (algorithm, data) {
13968
+ return __awaiter$1(this, void 0, void 0, function () {
13969
+ return __generator$1(this, function (_a) {
13970
+ return [2 /*return*/, new Promise(function (resolve, reject) {
13971
+ var digestOperation = window["msCrypto"].subtle.digest(algorithm, data.buffer);
13972
+ digestOperation.addEventListener("complete", function (e) {
13973
+ resolve(e.target.result);
13974
+ });
13975
+ digestOperation.addEventListener("error", function (error) {
13976
+ reject(error);
13977
+ });
13978
+ })];
13979
+ });
13980
+ });
13981
+ };
13982
+ return MsBrowserCrypto;
13983
+ }());
13984
+
13985
+ /*
13986
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13987
+ * Licensed under the MIT License.
13988
+ */
13989
+ /**
13990
+ * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
13991
+ */
13992
+ // RSA KeyGen Algorithm
13993
+ var PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
13994
+ // SHA-256 hashing algorithm
13995
+ var S256_HASH_ALG = "SHA-256";
13996
+ // MOD length for PoP tokens
13997
+ var MODULUS_LENGTH = 2048;
13998
+ // Public Exponent
13999
+ var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
14000
+ /**
14001
+ * This class implements functions used by the browser library to perform cryptography operations such as
14002
+ * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
14003
+ */
14004
+ var BrowserCrypto = /** @class */ (function () {
14005
+ function BrowserCrypto(logger, cryptoOptions) {
14006
+ var _a, _b;
14007
+ this.logger = logger;
14008
+ this.cryptoOptions = cryptoOptions;
14009
+ if (this.hasBrowserCrypto()) {
14010
+ // Use standard modern web crypto if available
14011
+ this.logger.verbose("BrowserCrypto: modern crypto interface available");
14012
+ this.subtleCrypto = new ModernBrowserCrypto();
14013
+ }
14014
+ else if (this.hasIECrypto()) {
14015
+ // For IE11, use msCrypto interface
14016
+ this.logger.verbose("BrowserCrypto: MS crypto interface available");
14017
+ this.subtleCrypto = new MsBrowserCrypto();
14018
+ }
14019
+ else if (this.hasMsrCrypto() && ((_a = this.cryptoOptions) === null || _a === void 0 ? void 0 : _a.useMsrCrypto)) {
14020
+ // For other browsers, use MSR Crypto if found
14021
+ this.logger.verbose("BrowserCrypto: MSR crypto interface available");
14022
+ this.subtleCrypto = new MsrBrowserCrypto();
14023
+ }
14024
+ else {
14025
+ if (this.hasMsrCrypto()) {
14026
+ this.logger.info("BrowserCrypto: MSR Crypto interface available but system.cryptoOptions.useMsrCrypto not enabled");
14027
+ }
14028
+ this.logger.error("BrowserCrypto: No crypto interfaces available.");
14029
+ throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto, msCrypto, or msrCrypto interfaces not available.");
14030
+ }
14031
+ // Mainly needed for MSR Crypto: https://github.com/microsoft/MSR-JavaScript-Crypto#random-number-generator-prng
14032
+ if (this.subtleCrypto.initPrng) {
14033
+ this.logger.verbose("BrowserCrypto: Interface requires entropy");
14034
+ if (!((_b = this.cryptoOptions) === null || _b === void 0 ? void 0 : _b.entropy)) {
14035
+ this.logger.error("BrowserCrypto: Interface requires entropy but none provided.");
14036
+ throw BrowserConfigurationAuthError.createEntropyNotProvided();
14037
+ }
14038
+ this.logger.verbose("BrowserCrypto: Entropy provided");
14039
+ this.subtleCrypto.initPrng(this.cryptoOptions.entropy);
14040
+ }
14041
+ this.keygenAlgorithmOptions = {
14042
+ name: PKCS1_V15_KEYGEN_ALG,
14043
+ hash: S256_HASH_ALG,
14044
+ modulusLength: MODULUS_LENGTH,
14045
+ publicExponent: PUBLIC_EXPONENT
14046
+ };
14047
+ }
13865
14048
  /**
13866
- * Returns stringified jwk.
13867
- * @param jwk
14049
+ * Check whether IE crypto or other browser cryptography is available.
14050
+ */
14051
+ BrowserCrypto.prototype.hasIECrypto = function () {
14052
+ return "msCrypto" in window;
14053
+ };
14054
+ /**
14055
+ * Check whether browser crypto is available.
14056
+ */
14057
+ BrowserCrypto.prototype.hasBrowserCrypto = function () {
14058
+ return "crypto" in window;
14059
+ };
14060
+ /**
14061
+ * Check whether MSR crypto polyfill is available
14062
+ */
14063
+ BrowserCrypto.prototype.hasMsrCrypto = function () {
14064
+ return "msrCrypto" in window;
14065
+ };
14066
+ /**
14067
+ * Returns a sha-256 hash of the given dataString as an ArrayBuffer.
14068
+ * @param dataString
14069
+ */
14070
+ BrowserCrypto.prototype.sha256Digest = function (dataString) {
14071
+ return __awaiter$1(this, void 0, void 0, function () {
14072
+ var data;
14073
+ return __generator$1(this, function (_a) {
14074
+ data = BrowserStringUtils.stringToUtf8Arr(dataString);
14075
+ // MSR Crypto wants object with name property, instead of string
14076
+ return [2 /*return*/, this.subtleCrypto.digest({ name: S256_HASH_ALG }, data)];
14077
+ });
14078
+ });
14079
+ };
14080
+ /**
14081
+ * Populates buffer with cryptographically random values.
14082
+ * @param dataBuffer
14083
+ */
14084
+ BrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
14085
+ return this.subtleCrypto.getRandomValues(dataBuffer);
14086
+ };
14087
+ /**
14088
+ * Generates a keypair based on current keygen algorithm config.
14089
+ * @param extractable
14090
+ * @param usages
14091
+ */
14092
+ BrowserCrypto.prototype.generateKeyPair = function (extractable, usages) {
14093
+ return __awaiter$1(this, void 0, void 0, function () {
14094
+ return __generator$1(this, function (_a) {
14095
+ return [2 /*return*/, this.subtleCrypto.generateKey(this.keygenAlgorithmOptions, extractable, usages)];
14096
+ });
14097
+ });
14098
+ };
14099
+ /**
14100
+ * Export key as Json Web Key (JWK)
14101
+ * @param key
14102
+ * @param format
14103
+ */
14104
+ BrowserCrypto.prototype.exportJwk = function (key) {
14105
+ return __awaiter$1(this, void 0, void 0, function () {
14106
+ return __generator$1(this, function (_a) {
14107
+ return [2 /*return*/, this.subtleCrypto.exportKey(key)];
14108
+ });
14109
+ });
14110
+ };
14111
+ /**
14112
+ * Imports key as Json Web Key (JWK), can set extractable and usages.
14113
+ * @param key
14114
+ * @param format
14115
+ * @param extractable
14116
+ * @param usages
14117
+ */
14118
+ BrowserCrypto.prototype.importJwk = function (key, extractable, usages) {
14119
+ return __awaiter$1(this, void 0, void 0, function () {
14120
+ return __generator$1(this, function (_a) {
14121
+ return [2 /*return*/, this.subtleCrypto.importKey(key, this.keygenAlgorithmOptions, extractable, usages)];
14122
+ });
14123
+ });
14124
+ };
14125
+ /**
14126
+ * Signs given data with given key
14127
+ * @param key
14128
+ * @param data
13868
14129
  */
13869
- BrowserCrypto.getJwkString = function (jwk) {
13870
- return JSON.stringify(jwk, Object.keys(jwk).sort());
14130
+ BrowserCrypto.prototype.sign = function (key, data) {
14131
+ return __awaiter$1(this, void 0, void 0, function () {
14132
+ return __generator$1(this, function (_a) {
14133
+ return [2 /*return*/, this.subtleCrypto.sign(this.keygenAlgorithmOptions, key, data)];
14134
+ });
14135
+ });
13871
14136
  };
13872
14137
  return BrowserCrypto;
13873
14138
  }());
@@ -14387,10 +14652,10 @@
14387
14652
  * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
14388
14653
  */
14389
14654
  var CryptoOps = /** @class */ (function () {
14390
- function CryptoOps(logger, performanceClient) {
14655
+ function CryptoOps(logger, performanceClient, cryptoConfig) {
14391
14656
  this.logger = logger;
14392
14657
  // Browser crypto needs to be validated first before any other classes can be set.
14393
- this.browserCrypto = new BrowserCrypto(this.logger);
14658
+ this.browserCrypto = new BrowserCrypto(this.logger, cryptoConfig);
14394
14659
  this.b64Encode = new Base64Encode();
14395
14660
  this.b64Decode = new Base64Decode();
14396
14661
  this.guidGenerator = new GuidGenerator(this.browserCrypto);
@@ -14452,7 +14717,7 @@
14452
14717
  kty: publicKeyJwk.kty,
14453
14718
  n: publicKeyJwk.n
14454
14719
  };
14455
- publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
14720
+ publicJwkString = BrowserStringUtils.getSortedObjectString(pubKeyThumprintObj);
14456
14721
  return [4 /*yield*/, this.hashString(publicJwkString)];
14457
14722
  case 3:
14458
14723
  publicJwkHash = _b.sent();
@@ -14537,7 +14802,7 @@
14537
14802
  return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
14538
14803
  case 2:
14539
14804
  publicKeyJwk = _b.sent();
14540
- publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
14805
+ publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
14541
14806
  encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
14542
14807
  shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
14543
14808
  encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
@@ -14607,15 +14872,19 @@
14607
14872
  * @param request
14608
14873
  * @param response
14609
14874
  * @param options
14875
+ * @returns `AuthenticationResult` for the response that was loaded.
14610
14876
  */
14611
14877
  TokenCache.prototype.loadExternalTokens = function (request, response, options) {
14612
14878
  this.logger.info("TokenCache - loadExternalTokens called");
14613
14879
  if (!response.id_token) {
14614
14880
  throw BrowserAuthError.createUnableToLoadTokenError("Please ensure server response includes id token.");
14615
14881
  }
14882
+ var idToken = new AuthToken(response.id_token, this.cryptoObj);
14883
+ var cacheRecord;
14884
+ var authority;
14616
14885
  if (request.account) {
14617
- this.loadIdToken(response.id_token, request.account.homeAccountId, request.account.environment, request.account.tenantId, options);
14618
- this.loadAccessToken(request, response, request.account.homeAccountId, request.account.environment, request.account.tenantId, options);
14886
+ var cacheRecordAccount = this.loadAccount(idToken, request.account.environment, undefined, undefined, request.account.homeAccountId);
14887
+ cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment, request.account.tenantId, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, request.account.environment));
14619
14888
  }
14620
14889
  else if (request.authority) {
14621
14890
  var authorityUrl = Authority.generateAuthority(request.authority, request.azureCloudOptions);
@@ -14626,17 +14895,17 @@
14626
14895
  authorityMetadata: this.config.auth.authorityMetadata,
14627
14896
  skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
14628
14897
  };
14629
- var authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
14898
+ authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
14630
14899
  // "clientInfo" from options takes precedence over "clientInfo" in response
14631
14900
  if (options.clientInfo) {
14632
14901
  this.logger.trace("TokenCache - homeAccountId from options");
14633
- this.loadIdToken(response.id_token, options.clientInfo, authority.hostnameAndPort, authority.tenant, options);
14634
- this.loadAccessToken(request, response, options.clientInfo, authority.hostnameAndPort, authority.tenant, options);
14902
+ var cacheRecordAccount = this.loadAccount(idToken, authority.hostnameAndPort, options.clientInfo, authority.authorityType);
14903
+ cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort));
14635
14904
  }
14636
14905
  else if (response.client_info) {
14637
14906
  this.logger.trace("TokenCache - homeAccountId from response");
14638
- this.loadIdToken(response.id_token, response.client_info, authority.hostnameAndPort, authority.tenant, options);
14639
- this.loadAccessToken(request, response, response.client_info, authority.hostnameAndPort, authority.tenant, options);
14907
+ var cacheRecordAccount = this.loadAccount(idToken, authority.hostnameAndPort, response.client_info, authority.authorityType);
14908
+ cacheRecord = new CacheRecord(cacheRecordAccount, this.loadIdToken(idToken, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant), this.loadAccessToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort, authority.tenant, options), this.loadRefreshToken(request, response, cacheRecordAccount.homeAccountId, authority.hostnameAndPort));
14640
14909
  }
14641
14910
  else {
14642
14911
  throw BrowserAuthError.createUnableToLoadTokenError("Please provide clientInfo in the response or options.");
@@ -14645,6 +14914,39 @@
14645
14914
  else {
14646
14915
  throw BrowserAuthError.createUnableToLoadTokenError("Please provide a request with an account or a request with authority.");
14647
14916
  }
14917
+ return this.generateAuthenticationResult(request, idToken, cacheRecord, authority);
14918
+ };
14919
+ /**
14920
+ * Helper function to load account to msal-browser cache
14921
+ * @param idToken
14922
+ * @param environment
14923
+ * @param clientInfo
14924
+ * @param authorityType
14925
+ * @param requestHomeAccountId
14926
+ * @returns `AccountEntity`
14927
+ */
14928
+ TokenCache.prototype.loadAccount = function (idToken, environment, clientInfo, authorityType, requestHomeAccountId) {
14929
+ var homeAccountId;
14930
+ if (requestHomeAccountId) {
14931
+ homeAccountId = requestHomeAccountId;
14932
+ }
14933
+ else if (authorityType !== undefined && clientInfo) {
14934
+ homeAccountId = AccountEntity.generateHomeAccountId(clientInfo, authorityType, this.logger, this.cryptoObj, idToken);
14935
+ }
14936
+ if (!homeAccountId) {
14937
+ throw BrowserAuthError.createUnableToLoadTokenError("Unexpected missing homeAccountId");
14938
+ }
14939
+ var accountEntity = clientInfo ?
14940
+ AccountEntity.createAccount(clientInfo, homeAccountId, idToken, undefined, undefined, undefined, environment) :
14941
+ AccountEntity.createGenericAccount(homeAccountId, idToken, undefined, undefined, undefined, environment);
14942
+ if (this.isBrowserEnvironment) {
14943
+ this.logger.verbose("TokenCache - loading account");
14944
+ this.storage.setAccount(accountEntity);
14945
+ return accountEntity;
14946
+ }
14947
+ else {
14948
+ throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
14949
+ }
14648
14950
  };
14649
14951
  /**
14650
14952
  * Helper function to load id tokens to msal-browser cache
@@ -14652,18 +14954,14 @@
14652
14954
  * @param homeAccountId
14653
14955
  * @param environment
14654
14956
  * @param tenantId
14655
- * @param options
14957
+ * @returns `IdTokenEntity`
14656
14958
  */
14657
- TokenCache.prototype.loadIdToken = function (idToken, homeAccountId, environment, tenantId, options) {
14658
- var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken, this.config.auth.clientId, tenantId);
14659
- var idAuthToken = new AuthToken(idToken, this.cryptoObj);
14660
- var accountEntity = options.clientInfo ?
14661
- AccountEntity.createAccount(options.clientInfo, homeAccountId, idAuthToken, undefined, undefined, undefined, environment) :
14662
- AccountEntity.createGenericAccount(homeAccountId, idAuthToken, undefined, undefined, undefined, environment);
14959
+ TokenCache.prototype.loadIdToken = function (idToken, homeAccountId, environment, tenantId) {
14960
+ var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken.rawToken, this.config.auth.clientId, tenantId);
14663
14961
  if (this.isBrowserEnvironment) {
14664
14962
  this.logger.verbose("TokenCache - loading id token");
14665
- this.storage.setAccount(accountEntity);
14666
14963
  this.storage.setIdTokenCredential(idTokenEntity);
14964
+ return idTokenEntity;
14667
14965
  }
14668
14966
  else {
14669
14967
  throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
@@ -14673,16 +14971,15 @@
14673
14971
  * Helper function to load access tokens to msal-browser cache
14674
14972
  * @param request
14675
14973
  * @param response
14676
- * @param options
14677
14974
  * @param homeAccountId
14678
14975
  * @param environment
14679
14976
  * @param tenantId
14680
- * @returns
14977
+ * @returns `AccessTokenEntity`
14681
14978
  */
14682
14979
  TokenCache.prototype.loadAccessToken = function (request, response, homeAccountId, environment, tenantId, options) {
14683
14980
  if (!response.access_token) {
14684
14981
  this.logger.verbose("TokenCache - No access token provided for caching");
14685
- return;
14982
+ return null;
14686
14983
  }
14687
14984
  if (!response.expires_in) {
14688
14985
  throw BrowserAuthError.createUnableToLoadTokenError("Please ensure server response includes expires_in value.");
@@ -14697,11 +14994,80 @@
14697
14994
  if (this.isBrowserEnvironment) {
14698
14995
  this.logger.verbose("TokenCache - loading access token");
14699
14996
  this.storage.setAccessTokenCredential(accessTokenEntity);
14997
+ return accessTokenEntity;
14700
14998
  }
14701
14999
  else {
14702
15000
  throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
14703
15001
  }
14704
15002
  };
15003
+ /**
15004
+ * Helper function to load refresh tokens to msal-browser cache
15005
+ * @param request
15006
+ * @param response
15007
+ * @param homeAccountId
15008
+ * @param environment
15009
+ * @returns `RefreshTokenEntity`
15010
+ */
15011
+ TokenCache.prototype.loadRefreshToken = function (request, response, homeAccountId, environment) {
15012
+ if (!response.refresh_token) {
15013
+ this.logger.verbose("TokenCache - No refresh token provided for caching");
15014
+ return null;
15015
+ }
15016
+ var refreshTokenEntity = RefreshTokenEntity.createRefreshTokenEntity(homeAccountId, environment, response.refresh_token, this.config.auth.clientId);
15017
+ if (this.isBrowserEnvironment) {
15018
+ this.logger.verbose("TokenCache - loading refresh token");
15019
+ this.storage.setRefreshTokenCredential(refreshTokenEntity);
15020
+ return refreshTokenEntity;
15021
+ }
15022
+ else {
15023
+ throw BrowserAuthError.createUnableToLoadTokenError("loadExternalTokens is designed to work in browser environments only.");
15024
+ }
15025
+ };
15026
+ /**
15027
+ * Helper function to generate an `AuthenticationResult` for the result.
15028
+ * @param request
15029
+ * @param idTokenObj
15030
+ * @param cacheRecord
15031
+ * @param authority
15032
+ * @returns `AuthenticationResult`
15033
+ */
15034
+ TokenCache.prototype.generateAuthenticationResult = function (request, idTokenObj, cacheRecord, authority) {
15035
+ var _a, _b, _c;
15036
+ var accessToken = Constants.EMPTY_STRING;
15037
+ var responseScopes = [];
15038
+ var expiresOn = null;
15039
+ var extExpiresOn;
15040
+ if (cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.accessToken) {
15041
+ accessToken = cacheRecord.accessToken.secret;
15042
+ responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
15043
+ expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);
15044
+ extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);
15045
+ }
15046
+ var uid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.oid) || (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.sub) || Constants.EMPTY_STRING;
15047
+ var tid = (idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.tid) || Constants.EMPTY_STRING;
15048
+ return {
15049
+ authority: authority ? authority.canonicalAuthority : Constants.EMPTY_STRING,
15050
+ uniqueId: uid,
15051
+ tenantId: tid,
15052
+ scopes: responseScopes,
15053
+ account: (cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) ? cacheRecord.account.getAccountInfo() : null,
15054
+ idToken: idTokenObj ? idTokenObj.rawToken : Constants.EMPTY_STRING,
15055
+ idTokenClaims: idTokenObj ? idTokenObj.claims : {},
15056
+ accessToken: accessToken,
15057
+ fromCache: true,
15058
+ expiresOn: expiresOn,
15059
+ correlationId: request.correlationId || Constants.EMPTY_STRING,
15060
+ requestId: Constants.EMPTY_STRING,
15061
+ extExpiresOn: extExpiresOn,
15062
+ familyId: Constants.EMPTY_STRING,
15063
+ tokenType: ((_a = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
15064
+ state: Constants.EMPTY_STRING,
15065
+ cloudGraphHostName: ((_b = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
15066
+ msGraphHost: ((_c = cacheRecord === null || cacheRecord === void 0 ? void 0 : cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
15067
+ code: undefined,
15068
+ fromNativeBroker: false
15069
+ };
15070
+ };
14705
15071
  return TokenCache;
14706
15072
  }());
14707
15073
 
@@ -14759,7 +15125,7 @@
14759
15125
  clientConfig = _a.sent();
14760
15126
  authClient = new HybridSpaAuthorizationCodeClient(clientConfig);
14761
15127
  this.logger.verbose("Auth code client created");
14762
- silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system.navigateFrameWait);
15128
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system);
14763
15129
  // Handle auth code parameters from request
14764
15130
  return [2 /*return*/, silentHandler.handleCodeResponseFromServer({
14765
15131
  code: request.code,
@@ -14858,9 +15224,9 @@
14858
15224
  */
14859
15225
  var BrowserPerformanceClient = /** @class */ (function (_super) {
14860
15226
  __extends$1(BrowserPerformanceClient, _super);
14861
- function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
15227
+ function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
14862
15228
  var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
14863
- _this.browserCrypto = new BrowserCrypto(_this.logger);
15229
+ _this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
14864
15230
  _this.guidGenerator = new GuidGenerator(_this.browserCrypto);
14865
15231
  return _this;
14866
15232
  }
@@ -14942,10 +15308,10 @@
14942
15308
  this.hybridAuthCodeResponses = new Map();
14943
15309
  // Initialize performance client
14944
15310
  this.performanceClient = this.isBrowserEnvironment ?
14945
- new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application) :
15311
+ new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application, this.config.system.cryptoOptions) :
14946
15312
  new StubPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application);
14947
15313
  // Initialize the crypto class.
14948
- this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger, this.performanceClient) : DEFAULT_CRYPTO_IMPLEMENTATION;
15314
+ this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger, this.performanceClient, this.config.system.cryptoOptions) : DEFAULT_CRYPTO_IMPLEMENTATION;
14949
15315
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
14950
15316
  // Initialize the browser storage class.
14951
15317
  this.browserStorage = this.isBrowserEnvironment ?
@@ -15167,6 +15533,7 @@
15167
15533
  isNativeBroker: true,
15168
15534
  accessTokenSize: response.accessToken.length,
15169
15535
  idTokenSize: response.idToken.length,
15536
+ requestId: response.requestId
15170
15537
  });
15171
15538
  atPopupMeasurement.flushMeasurement();
15172
15539
  return response;
@@ -15204,6 +15571,7 @@
15204
15571
  success: true,
15205
15572
  accessTokenSize: result.accessToken.length,
15206
15573
  idTokenSize: result.idToken.length,
15574
+ requestId: result.requestId
15207
15575
  });
15208
15576
  atPopupMeasurement.flushMeasurement();
15209
15577
  return result;
@@ -15247,7 +15615,9 @@
15247
15615
  var _this = this;
15248
15616
  return __generator$1(this, function (_a) {
15249
15617
  correlationId = this.getRequestCorrelationId(request);
15250
- validRequest = __assign$1(__assign$1({}, request), { prompt: PromptValue.NONE, correlationId: correlationId });
15618
+ validRequest = __assign$1(__assign$1({}, request), {
15619
+ // will be PromptValue.NONE or PromptValue.NO_SESSION
15620
+ prompt: request.prompt, correlationId: correlationId });
15251
15621
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
15252
15622
  ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
15253
15623
  this.logger.verbose("ssoSilent called", correlationId);
@@ -15273,7 +15643,8 @@
15273
15643
  success: true,
15274
15644
  isNativeBroker: response.fromNativeBroker,
15275
15645
  accessTokenSize: response.accessToken.length,
15276
- idTokenSize: response.idToken.length
15646
+ idTokenSize: response.idToken.length,
15647
+ requestId: response.requestId
15277
15648
  });
15278
15649
  ssoSilentMeasurement.flushMeasurement();
15279
15650
  return response;
@@ -15324,7 +15695,8 @@
15324
15695
  success: true,
15325
15696
  accessTokenSize: result.accessToken.length,
15326
15697
  idTokenSize: result.idToken.length,
15327
- isNativeBroker: result.fromNativeBroker
15698
+ isNativeBroker: result.fromNativeBroker,
15699
+ requestId: result.requestId
15328
15700
  });
15329
15701
  atbcMeasurement.flushMeasurement();
15330
15702
  return result;
@@ -15404,67 +15776,62 @@
15404
15776
  });
15405
15777
  };
15406
15778
  /**
15407
- * Use this function to obtain a token before every call to the API / resource provider
15408
- *
15409
- * MSAL return's a cached token when available
15410
- * Or it send's a request to the STS to obtain a new token using a refresh token.
15411
- *
15412
- * @param {@link SilentRequest}
15413
- *
15414
- * To renew idToken, please pass clientId as the only scope in the Authentication Parameters
15415
- * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
15779
+ * Attempt to acquire an access token from the cache
15780
+ * @param silentCacheClient SilentCacheClient
15781
+ * @param commonRequest CommonSilentFlowRequest
15782
+ * @param silentRequest SilentRequest
15783
+ * @returns A promise that, when resolved, returns the access token
15416
15784
  */
15417
- ClientApplication.prototype.acquireTokenByRefreshToken = function (request) {
15785
+ ClientApplication.prototype.acquireTokenFromCache = function (silentCacheClient, commonRequest, silentRequest) {
15418
15786
  return __awaiter$1(this, void 0, void 0, function () {
15419
- var atbrtMeasurement, silentRefreshClient;
15420
- var _this = this;
15421
15787
  return __generator$1(this, function (_a) {
15422
- // block the reload if it occurred inside a hidden iframe
15423
- BrowserUtils.blockReloadInHiddenIframes();
15424
- atbrtMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByRefreshToken, request.correlationId);
15425
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, request);
15426
- silentRefreshClient = this.createSilentRefreshClient(request.correlationId);
15427
- return [2 /*return*/, silentRefreshClient.acquireToken(request)
15428
- .then(function (result) {
15429
- atbrtMeasurement.endMeasurement({
15430
- success: true,
15431
- fromCache: result.fromCache,
15432
- accessTokenSize: result.accessToken.length,
15433
- idTokenSize: result.idToken.length,
15434
- });
15435
- return result;
15436
- })
15437
- .catch(function (e) {
15438
- var isServerError = e instanceof ServerError;
15439
- var isInteractionRequiredError = e instanceof InteractionRequiredAuthError;
15440
- var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
15441
- if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
15442
- _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
15443
- var silentIframeClient = _this.createSilentIframeClient(request.correlationId);
15444
- return silentIframeClient.acquireToken(request)
15445
- .then(function (result) {
15446
- atbrtMeasurement.endMeasurement({
15447
- success: true,
15448
- fromCache: result.fromCache,
15449
- accessTokenSize: result.accessToken.length,
15450
- idTokenSize: result.idToken.length,
15451
- });
15452
- return result;
15453
- })
15454
- .catch(function (error) {
15455
- atbrtMeasurement.endMeasurement({
15456
- errorCode: error.errorCode,
15457
- subErrorCode: error.subError,
15458
- success: false
15459
- });
15460
- throw error;
15461
- });
15462
- }
15463
- atbrtMeasurement.endMeasurement({
15464
- success: false
15465
- });
15466
- throw e;
15467
- })];
15788
+ switch (silentRequest.cacheLookupPolicy) {
15789
+ case exports.CacheLookupPolicy.Default:
15790
+ case exports.CacheLookupPolicy.AccessToken:
15791
+ case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
15792
+ return [2 /*return*/, silentCacheClient.acquireToken(commonRequest)];
15793
+ default:
15794
+ throw ClientAuthError.createRefreshRequiredError();
15795
+ }
15796
+ return [2 /*return*/];
15797
+ });
15798
+ });
15799
+ };
15800
+ /**
15801
+ * Attempt to acquire an access token via a refresh token
15802
+ * @param commonRequest CommonSilentFlowRequest
15803
+ * @param silentRequest SilentRequest
15804
+ * @returns A promise that, when resolved, returns the access token
15805
+ */
15806
+ ClientApplication.prototype.acquireTokenByRefreshToken = function (commonRequest, silentRequest) {
15807
+ return __awaiter$1(this, void 0, void 0, function () {
15808
+ var silentRefreshClient;
15809
+ return __generator$1(this, function (_a) {
15810
+ switch (silentRequest.cacheLookupPolicy) {
15811
+ case exports.CacheLookupPolicy.Default:
15812
+ case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
15813
+ case exports.CacheLookupPolicy.RefreshToken:
15814
+ case exports.CacheLookupPolicy.RefreshTokenAndNetwork:
15815
+ silentRefreshClient = this.createSilentRefreshClient(commonRequest.correlationId);
15816
+ return [2 /*return*/, silentRefreshClient.acquireToken(commonRequest)];
15817
+ default:
15818
+ throw ClientAuthError.createRefreshRequiredError();
15819
+ }
15820
+ return [2 /*return*/];
15821
+ });
15822
+ });
15823
+ };
15824
+ /**
15825
+ * Attempt to acquire an access token via an iframe
15826
+ * @param request CommonSilentFlowRequest
15827
+ * @returns A promise that, when resolved, returns the access token
15828
+ */
15829
+ ClientApplication.prototype.acquireTokenBySilentIframe = function (request) {
15830
+ return __awaiter$1(this, void 0, void 0, function () {
15831
+ var silentIframeClient;
15832
+ return __generator$1(this, function (_a) {
15833
+ silentIframeClient = this.createSilentIframeClient(request.correlationId);
15834
+ return [2 /*return*/, silentIframeClient.acquireToken(request)];
15468
15835
  });
15469
15836
  });
15470
15837
  };
@@ -15958,7 +16325,9 @@
15958
16325
  fromCache: result.fromCache,
15959
16326
  accessTokenSize: result.accessToken.length,
15960
16327
  idTokenSize: result.idToken.length,
15961
- isNativeBroker: result.fromNativeBroker
16328
+ isNativeBroker: result.fromNativeBroker,
16329
+ cacheLookupPolicy: request.cacheLookupPolicy,
16330
+ requestId: result.requestId
15962
16331
  });
15963
16332
  atsMeasurement.flushMeasurement();
15964
16333
  return result;
@@ -15996,7 +16365,7 @@
15996
16365
  */
15997
16366
  PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
15998
16367
  return __awaiter$1(this, void 0, void 0, function () {
15999
- var astsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1;
16368
+ var astsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1, requestWithCLP_1;
16000
16369
  var _this = this;
16001
16370
  return __generator$1(this, function (_a) {
16002
16371
  switch (_a.label) {
@@ -16026,11 +16395,32 @@
16026
16395
  return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
16027
16396
  case 2:
16028
16397
  silentRequest_1 = _a.sent();
16029
- result = silentCacheClient.acquireToken(silentRequest_1).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
16030
- return __generator$1(this, function (_a) {
16031
- return [2 /*return*/, this.acquireTokenByRefreshToken(silentRequest_1)];
16398
+ requestWithCLP_1 = __assign$1(__assign$1({}, request), {
16399
+ // set the request's CacheLookupPolicy to Default if it was not optionally passed in
16400
+ cacheLookupPolicy: request.cacheLookupPolicy || exports.CacheLookupPolicy.Default });
16401
+ result = this.acquireTokenFromCache(silentCacheClient, silentRequest_1, requestWithCLP_1).catch(function (cacheError) {
16402
+ if (requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessToken) {
16403
+ throw cacheError;
16404
+ }
16405
+ // block the reload if it occurred inside a hidden iframe
16406
+ BrowserUtils.blockReloadInHiddenIframes();
16407
+ _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest_1);
16408
+ return _this.acquireTokenByRefreshToken(silentRequest_1, requestWithCLP_1).catch(function (refreshTokenError) {
16409
+ var isServerError = refreshTokenError instanceof ServerError;
16410
+ var isInteractionRequiredError = refreshTokenError instanceof InteractionRequiredAuthError;
16411
+ var isInvalidGrantError = (refreshTokenError.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
16412
+ if ((!isServerError ||
16413
+ !isInvalidGrantError ||
16414
+ isInteractionRequiredError ||
16415
+ requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessTokenAndRefreshToken ||
16416
+ requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.RefreshToken)
16417
+ && (requestWithCLP_1.cacheLookupPolicy !== exports.CacheLookupPolicy.Skip)) {
16418
+ throw refreshTokenError;
16419
+ }
16420
+ _this.logger.verbose("Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.", request.correlationId);
16421
+ return _this.acquireTokenBySilentIframe(silentRequest_1);
16032
16422
  });
16033
- }); });
16423
+ });
16034
16424
  _a.label = 3;
16035
16425
  case 3: return [2 /*return*/, result.then(function (response) {
16036
16426
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
@@ -16039,7 +16429,8 @@
16039
16429
  fromCache: response.fromCache,
16040
16430
  accessTokenSize: response.accessToken.length,
16041
16431
  idTokenSize: response.idToken.length,
16042
- isNativeBroker: response.fromNativeBroker
16432
+ isNativeBroker: response.fromNativeBroker,
16433
+ requestId: response.requestId
16043
16434
  });
16044
16435
  return response;
16045
16436
  }).catch(function (tokenRenewalError) {