@azure/msal-browser 2.28.2 → 2.29.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 (129) 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 +37 -10
  10. package/dist/app/PublicClientApplication.js.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  12. package/dist/cache/AsyncMemoryStorage.d.ts +7 -2
  13. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
  14. package/dist/cache/AsyncMemoryStorage.js +19 -15
  15. package/dist/cache/AsyncMemoryStorage.js.map +1 -1
  16. package/dist/cache/BrowserCacheManager.js +1 -1
  17. package/dist/cache/BrowserStorage.js +1 -1
  18. package/dist/cache/CryptoKeyStore.d.ts +18 -0
  19. package/dist/cache/CryptoKeyStore.d.ts.map +1 -0
  20. package/dist/cache/CryptoKeyStore.js +58 -0
  21. package/dist/cache/CryptoKeyStore.js.map +1 -0
  22. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  23. package/dist/cache/DatabaseStorage.js +10 -22
  24. package/dist/cache/DatabaseStorage.js.map +1 -1
  25. package/dist/cache/MemoryStorage.js +1 -1
  26. package/dist/cache/TokenCache.js +1 -1
  27. package/dist/config/Configuration.d.ts +16 -0
  28. package/dist/config/Configuration.d.ts.map +1 -1
  29. package/dist/config/Configuration.js +5 -2
  30. package/dist/config/Configuration.js.map +1 -1
  31. package/dist/crypto/BrowserCrypto.d.ts +19 -59
  32. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  33. package/dist/crypto/BrowserCrypto.js +65 -180
  34. package/dist/crypto/BrowserCrypto.js.map +1 -1
  35. package/dist/crypto/CryptoOps.d.ts +2 -13
  36. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  37. package/dist/crypto/CryptoOps.js +10 -40
  38. package/dist/crypto/CryptoOps.js.map +1 -1
  39. package/dist/crypto/GuidGenerator.js +1 -1
  40. package/dist/crypto/ISubtleCrypto.d.ts +10 -0
  41. package/dist/crypto/ISubtleCrypto.d.ts.map +1 -0
  42. package/dist/crypto/ModernBrowserCrypto.d.ts +10 -0
  43. package/dist/crypto/ModernBrowserCrypto.d.ts.map +1 -0
  44. package/dist/crypto/ModernBrowserCrypto.js +55 -0
  45. package/dist/crypto/ModernBrowserCrypto.js.map +1 -0
  46. package/dist/crypto/MsBrowserCrypto.d.ts +10 -0
  47. package/dist/crypto/MsBrowserCrypto.d.ts.map +1 -0
  48. package/dist/crypto/MsBrowserCrypto.js +112 -0
  49. package/dist/crypto/MsBrowserCrypto.js.map +1 -0
  50. package/dist/crypto/MsrBrowserCrypto.d.ts +18 -0
  51. package/dist/crypto/MsrBrowserCrypto.d.ts.map +1 -0
  52. package/dist/crypto/MsrBrowserCrypto.js +59 -0
  53. package/dist/crypto/MsrBrowserCrypto.js.map +1 -0
  54. package/dist/crypto/PkceGenerator.js +1 -1
  55. package/dist/crypto/SignedHttpRequest.js +1 -1
  56. package/dist/encode/Base64Decode.js +1 -1
  57. package/dist/encode/Base64Encode.js +1 -1
  58. package/dist/error/BrowserAuthError.js +2 -2
  59. package/dist/error/BrowserAuthError.js.map +1 -1
  60. package/dist/error/BrowserConfigurationAuthError.d.ts +8 -0
  61. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  62. package/dist/error/BrowserConfigurationAuthError.js +11 -1
  63. package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
  64. package/dist/error/NativeAuthError.js +1 -1
  65. package/dist/event/EventHandler.js +1 -1
  66. package/dist/event/EventMessage.js +1 -1
  67. package/dist/event/EventType.js +1 -1
  68. package/dist/index.cjs.js +710 -410
  69. package/dist/index.cjs.js.map +1 -1
  70. package/dist/index.d.ts +1 -1
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +2 -2
  73. package/dist/interaction_client/BaseInteractionClient.js +1 -1
  74. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  75. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  76. package/dist/interaction_client/NativeInteractionClient.js +3 -2
  77. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  78. package/dist/interaction_client/PopupClient.js +1 -1
  79. package/dist/interaction_client/RedirectClient.js +1 -1
  80. package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
  81. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  82. package/dist/interaction_client/SilentCacheClient.js +1 -1
  83. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  84. package/dist/interaction_client/SilentIframeClient.d.ts +1 -1
  85. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  86. package/dist/interaction_client/SilentIframeClient.js +8 -7
  87. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  88. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  89. package/dist/interaction_client/SilentRefreshClient.js +3 -2
  90. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  91. package/dist/interaction_client/StandardInteractionClient.js +1 -1
  92. package/dist/interaction_handler/InteractionHandler.js +1 -1
  93. package/dist/interaction_handler/RedirectHandler.js +1 -1
  94. package/dist/interaction_handler/SilentHandler.js +1 -1
  95. package/dist/internals.js +1 -1
  96. package/dist/navigation/NavigationClient.js +1 -1
  97. package/dist/network/FetchClient.js +1 -1
  98. package/dist/network/XhrClient.js +1 -1
  99. package/dist/packageMetadata.d.ts +1 -1
  100. package/dist/packageMetadata.js +2 -2
  101. package/dist/packageMetadata.js.map +1 -1
  102. package/dist/request/PopupRequest.d.ts +1 -0
  103. package/dist/request/PopupRequest.d.ts.map +1 -1
  104. package/dist/request/RedirectRequest.d.ts +1 -0
  105. package/dist/request/RedirectRequest.d.ts.map +1 -1
  106. package/dist/request/SilentRequest.d.ts +9 -2
  107. package/dist/request/SilentRequest.d.ts.map +1 -1
  108. package/dist/request/SsoSilentRequest.d.ts +1 -0
  109. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  110. package/dist/telemetry/BrowserPerformanceClient.d.ts +2 -1
  111. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  112. package/dist/telemetry/BrowserPerformanceClient.js +3 -3
  113. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
  114. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  115. package/dist/utils/BrowserConstants.d.ts +8 -0
  116. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  117. package/dist/utils/BrowserConstants.js +40 -3
  118. package/dist/utils/BrowserConstants.js.map +1 -1
  119. package/dist/utils/BrowserProtocolUtils.js +1 -1
  120. package/dist/utils/BrowserStringUtils.d.ts +5 -0
  121. package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
  122. package/dist/utils/BrowserStringUtils.js +8 -1
  123. package/dist/utils/BrowserStringUtils.js.map +1 -1
  124. package/dist/utils/BrowserUtils.js +1 -1
  125. package/dist/utils/MathUtils.js +1 -1
  126. package/lib/msal-browser.js +710 -410
  127. package/lib/msal-browser.js.map +1 -1
  128. package/lib/msal-browser.min.js +37 -37
  129. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.28.2 2022-09-06 */
1
+ /*! @azure/msal-browser v2.29.0 2022-10-03 */
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.0 2022-09-06 */
122
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
209
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
590
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
646
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
721
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
1216
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
1341
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
1521
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
1495
1522
  /* eslint-disable header/header */
1496
1523
  var name$1 = "@azure/msal-common";
1497
- var version$1 = "7.4.0";
1524
+ var version$1 = "7.5.0";
1498
1525
 
1499
- /*! @azure/msal-common v7.4.0 2022-09-06 */
1526
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
1547
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
1706
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
1961
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
2145
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
2183
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
2198
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
2437
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
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.0 2022-09-06 */
2489
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
2444
2490
 
2445
2491
  /*
2446
2492
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3315,7 +3361,7 @@
3315
3361
  return DefaultStorageClass;
3316
3362
  }(CacheManager));
3317
3363
 
3318
- /*! @azure/msal-common v7.4.0 2022-09-06 */
3364
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
3319
3365
 
3320
3366
  /*
3321
3367
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3409,7 +3455,7 @@
3409
3455
  return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3410
3456
  }
3411
3457
 
3412
- /*! @azure/msal-common v7.4.0 2022-09-06 */
3458
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
3413
3459
 
3414
3460
  /*
3415
3461
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3429,7 +3475,7 @@
3429
3475
  return ServerError;
3430
3476
  }(AuthError));
3431
3477
 
3432
- /*! @azure/msal-common v7.4.0 2022-09-06 */
3478
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
3433
3479
 
3434
3480
  /*
3435
3481
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3525,7 +3571,7 @@
3525
3571
  return ThrottlingUtils;
3526
3572
  }());
3527
3573
 
3528
- /*! @azure/msal-common v7.4.0 2022-09-06 */
3574
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
3529
3575
 
3530
3576
  /*
3531
3577
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3574,7 +3620,7 @@
3574
3620
  return NetworkManager;
3575
3621
  }());
3576
3622
 
3577
- /*! @azure/msal-common v7.4.0 2022-09-06 */
3623
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
3578
3624
  /*
3579
3625
  * Copyright (c) Microsoft Corporation. All rights reserved.
3580
3626
  * Licensed under the MIT License.
@@ -3585,7 +3631,7 @@
3585
3631
  CcsCredentialType["UPN"] = "UPN";
3586
3632
  })(CcsCredentialType || (CcsCredentialType = {}));
3587
3633
 
3588
- /*! @azure/msal-common v7.4.0 2022-09-06 */
3634
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
3589
3635
 
3590
3636
  /*
3591
3637
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3676,7 +3722,7 @@
3676
3722
  return BaseClient;
3677
3723
  }());
3678
3724
 
3679
- /*! @azure/msal-common v7.4.0 2022-09-06 */
3725
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
3680
3726
 
3681
3727
  /*
3682
3728
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3762,7 +3808,7 @@
3762
3808
  return RequestValidator;
3763
3809
  }());
3764
3810
 
3765
- /*! @azure/msal-common v7.4.0 2022-09-06 */
3811
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
3766
3812
 
3767
3813
  /*
3768
3814
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4140,7 +4186,7 @@
4140
4186
  return RequestParameterBuilder;
4141
4187
  }());
4142
4188
 
4143
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4189
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4144
4190
 
4145
4191
  /*
4146
4192
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4204,7 +4250,7 @@
4204
4250
  return IdTokenEntity;
4205
4251
  }(CredentialEntity));
4206
4252
 
4207
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4253
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4208
4254
  /*
4209
4255
  * Copyright (c) Microsoft Corporation. All rights reserved.
4210
4256
  * Licensed under the MIT License.
@@ -4254,7 +4300,7 @@
4254
4300
  return TimeUtils;
4255
4301
  }());
4256
4302
 
4257
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4303
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4258
4304
 
4259
4305
  /*
4260
4306
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4368,7 +4414,7 @@
4368
4414
  return AccessTokenEntity;
4369
4415
  }(CredentialEntity));
4370
4416
 
4371
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4417
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4372
4418
 
4373
4419
  /*
4374
4420
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4435,7 +4481,7 @@
4435
4481
  return RefreshTokenEntity;
4436
4482
  }(CredentialEntity));
4437
4483
 
4438
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4484
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4439
4485
 
4440
4486
  /*
4441
4487
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4510,7 +4556,7 @@
4510
4556
  return InteractionRequiredAuthError;
4511
4557
  }(AuthError));
4512
4558
 
4513
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4559
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4514
4560
  /*
4515
4561
  * Copyright (c) Microsoft Corporation. All rights reserved.
4516
4562
  * Licensed under the MIT License.
@@ -4526,7 +4572,7 @@
4526
4572
  return CacheRecord;
4527
4573
  }());
4528
4574
 
4529
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4575
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4530
4576
 
4531
4577
  /*
4532
4578
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4597,7 +4643,7 @@
4597
4643
  return ProtocolUtils;
4598
4644
  }());
4599
4645
 
4600
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4646
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4601
4647
 
4602
4648
  /*
4603
4649
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4831,7 +4877,7 @@
4831
4877
  return UrlString;
4832
4878
  }());
4833
4879
 
4834
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4880
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4835
4881
 
4836
4882
  /*
4837
4883
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4932,7 +4978,7 @@
4932
4978
  return PopTokenGenerator;
4933
4979
  }());
4934
4980
 
4935
- /*! @azure/msal-common v7.4.0 2022-09-06 */
4981
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
4936
4982
 
4937
4983
  /*
4938
4984
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5002,7 +5048,7 @@
5002
5048
  return AppMetadataEntity;
5003
5049
  }());
5004
5050
 
5005
- /*! @azure/msal-common v7.4.0 2022-09-06 */
5051
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
5006
5052
  /*
5007
5053
  * Copyright (c) Microsoft Corporation. All rights reserved.
5008
5054
  * Licensed under the MIT License.
@@ -5038,7 +5084,7 @@
5038
5084
  return TokenCacheContext;
5039
5085
  }());
5040
5086
 
5041
- /*! @azure/msal-common v7.4.0 2022-09-06 */
5087
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
5042
5088
 
5043
5089
  /*
5044
5090
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5099,9 +5145,9 @@
5099
5145
  * @param serverTokenResponse
5100
5146
  * @param authority
5101
5147
  */
5102
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
5148
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
5103
5149
  return __awaiter(this, void 0, void 0, function () {
5104
- var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
5150
+ var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
5105
5151
  return __generator(this, function (_a) {
5106
5152
  switch (_a.label) {
5107
5153
  case 0:
@@ -5113,6 +5159,14 @@
5113
5159
  throw ClientAuthError.createNonceMismatchError();
5114
5160
  }
5115
5161
  }
5162
+ // token max_age check
5163
+ if (request.maxAge || (request.maxAge === 0)) {
5164
+ authTime = idTokenObj.claims.auth_time;
5165
+ if (!authTime) {
5166
+ throw ClientAuthError.createAuthTimeNotFoundError();
5167
+ }
5168
+ AuthToken.checkMaxAge(authTime, request.maxAge);
5169
+ }
5116
5170
  }
5117
5171
  // generate homeAccountId
5118
5172
  this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
@@ -5144,7 +5198,7 @@
5144
5198
  account = this.cacheStorage.getAccount(key);
5145
5199
  if (!account) {
5146
5200
  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)];
5201
+ return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId)];
5148
5202
  }
5149
5203
  }
5150
5204
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
@@ -5159,7 +5213,7 @@
5159
5213
  _a.sent();
5160
5214
  _a.label = 7;
5161
5215
  case 7: return [7 /*endfinally*/];
5162
- case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
5216
+ case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
5163
5217
  }
5164
5218
  });
5165
5219
  });
@@ -5245,7 +5299,7 @@
5245
5299
  * @param fromTokenCache
5246
5300
  * @param stateString
5247
5301
  */
5248
- ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
5302
+ ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code, requestId) {
5249
5303
  var _a, _b, _c;
5250
5304
  return __awaiter(this, void 0, void 0, function () {
5251
5305
  var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
@@ -5293,6 +5347,7 @@
5293
5347
  fromCache: fromTokenCache,
5294
5348
  expiresOn: expiresOn,
5295
5349
  correlationId: request.correlationId,
5350
+ requestId: requestId || Constants.EMPTY_STRING,
5296
5351
  extExpiresOn: extExpiresOn,
5297
5352
  familyId: familyId,
5298
5353
  tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
@@ -5309,7 +5364,7 @@
5309
5364
  return ResponseHandler;
5310
5365
  }());
5311
5366
 
5312
- /*! @azure/msal-common v7.4.0 2022-09-06 */
5367
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
5313
5368
 
5314
5369
  /*
5315
5370
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5355,10 +5410,11 @@
5355
5410
  * @param request
5356
5411
  */
5357
5412
  AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
5413
+ var _a;
5358
5414
  return __awaiter(this, void 0, void 0, function () {
5359
- var reqTimestamp, response, responseHandler;
5360
- return __generator(this, function (_a) {
5361
- switch (_a.label) {
5415
+ var reqTimestamp, response, requestId, responseHandler;
5416
+ return __generator(this, function (_b) {
5417
+ switch (_b.label) {
5362
5418
  case 0:
5363
5419
  this.logger.info("in acquireToken call");
5364
5420
  if (!request || StringUtils.isEmpty(request.code)) {
@@ -5367,12 +5423,13 @@
5367
5423
  reqTimestamp = TimeUtils.nowSeconds();
5368
5424
  return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
5369
5425
  case 1:
5370
- response = _a.sent();
5426
+ response = _b.sent();
5427
+ requestId = (_a = response.headers) === null || _a === void 0 ? void 0 : _a[HeaderNames.X_MS_REQUEST_ID];
5371
5428
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5372
5429
  // Validate response. This function throws a server error if an error is returned by the server.
5373
5430
  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()];
5431
+ return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)];
5432
+ case 2: return [2 /*return*/, _b.sent()];
5376
5433
  }
5377
5434
  });
5378
5435
  });
@@ -5760,7 +5817,7 @@
5760
5817
  return AuthorizationCodeClient;
5761
5818
  }(BaseClient));
5762
5819
 
5763
- /*! @azure/msal-common v7.4.0 2022-09-06 */
5820
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
5764
5821
  /*
5765
5822
  * Copyright (c) Microsoft Corporation. All rights reserved.
5766
5823
  * Licensed under the MIT License.
@@ -5843,10 +5900,6 @@
5843
5900
  * Used to acquire a token from Native component when native brokering is enabled.
5844
5901
  */
5845
5902
  PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5846
- /**
5847
- * Time spent on the network for refresh token acquisition
5848
- */
5849
- PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5850
5903
  /**
5851
5904
  * Time spent creating default headers for requests to token endpoint
5852
5905
  */
@@ -5860,10 +5913,21 @@
5860
5913
  */
5861
5914
  PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5862
5915
  /**
5863
- * acquireToken API in BrokerClientApplication.
5864
- * Used to acquire a token on behalf of the embedded application (PW-Broker).
5916
+ * Time taken for token acquisition by broker
5865
5917
  */
5866
5918
  PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5919
+ /**
5920
+ * Time spent on the network for refresh token acquisition
5921
+ */
5922
+ PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5923
+ /**
5924
+ * Time taken for acquiring refresh token , records RT size
5925
+ */
5926
+ PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
5927
+ /**
5928
+ * Time taken for acquiring cached refresh token
5929
+ */
5930
+ PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
5867
5931
  })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5868
5932
  /**
5869
5933
  * State of the performance event.
@@ -5878,7 +5942,7 @@
5878
5942
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5879
5943
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
5880
5944
 
5881
- /*! @azure/msal-common v7.4.0 2022-09-06 */
5945
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
5882
5946
 
5883
5947
  /*
5884
5948
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5893,18 +5957,40 @@
5893
5957
  return _super.call(this, configuration, performanceClient) || this;
5894
5958
  }
5895
5959
  RefreshTokenClient.prototype.acquireToken = function (request) {
5960
+ var _a, _b;
5896
5961
  return __awaiter(this, void 0, void 0, function () {
5897
- var reqTimestamp, response, responseHandler;
5898
- return __generator(this, function (_a) {
5899
- switch (_a.label) {
5962
+ var atsMeasurement, reqTimestamp, response, requestId, responseHandler;
5963
+ var _this = this;
5964
+ return __generator(this, function (_c) {
5965
+ switch (_c.label) {
5900
5966
  case 0:
5967
+ atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
5968
+ this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
5901
5969
  reqTimestamp = TimeUtils.nowSeconds();
5902
5970
  return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
5903
5971
  case 1:
5904
- response = _a.sent();
5972
+ response = _c.sent();
5973
+ requestId = (_b = response.headers) === null || _b === void 0 ? void 0 : _b[HeaderNames.X_MS_REQUEST_ID];
5905
5974
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5906
5975
  responseHandler.validateTokenResponse(response.body);
5907
- return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
5976
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
5977
+ var _a;
5978
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
5979
+ success: true,
5980
+ refreshTokenSize: ((_a = response.body.refresh_token) === null || _a === void 0 ? void 0 : _a.length) || 0
5981
+ });
5982
+ return result;
5983
+ })
5984
+ .catch(function (error) {
5985
+ _this.logger.verbose("Error in fetching refresh token", request.correlationId);
5986
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
5987
+ errorCode: error.errorCode,
5988
+ subErrorCode: error.subError,
5989
+ success: false,
5990
+ refreshTokenSize: undefined
5991
+ });
5992
+ throw error;
5993
+ })];
5908
5994
  }
5909
5995
  });
5910
5996
  });
@@ -5954,14 +6040,21 @@
5954
6040
  * @param request
5955
6041
  */
5956
6042
  RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
6043
+ var _a;
5957
6044
  return __awaiter(this, void 0, void 0, function () {
5958
- var refreshToken, refreshTokenRequest;
5959
- return __generator(this, function (_a) {
6045
+ var atsMeasurement, refreshToken, refreshTokenRequest;
6046
+ return __generator(this, function (_b) {
6047
+ atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
6048
+ this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
5960
6049
  refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
5961
- // no refresh Token
5962
6050
  if (!refreshToken) {
6051
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.discardMeasurement();
5963
6052
  throw InteractionRequiredAuthError.createNoTokensFoundError();
5964
6053
  }
6054
+ // attach cached RT size to the current measurement
6055
+ atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
6056
+ success: true
6057
+ });
5965
6058
  refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || exports.AuthenticationScheme.BEARER, ccsCredential: {
5966
6059
  credential: request.account.homeAccountId,
5967
6060
  type: CcsCredentialType.HOME_ACCOUNT_ID
@@ -6114,7 +6207,7 @@
6114
6207
  return RefreshTokenClient;
6115
6208
  }(BaseClient));
6116
6209
 
6117
- /*! @azure/msal-common v7.4.0 2022-09-06 */
6210
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
6118
6211
 
6119
6212
  /*
6120
6213
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6214,13 +6307,21 @@
6214
6307
  */
6215
6308
  SilentFlowClient.prototype.generateResultFromCacheRecord = function (cacheRecord, request) {
6216
6309
  return __awaiter(this, void 0, void 0, function () {
6217
- var idTokenObj;
6310
+ var idTokenObj, authTime;
6218
6311
  return __generator(this, function (_a) {
6219
6312
  switch (_a.label) {
6220
6313
  case 0:
6221
6314
  if (cacheRecord.idToken) {
6222
6315
  idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);
6223
6316
  }
6317
+ // token max_age check
6318
+ if (request.maxAge || (request.maxAge === 0)) {
6319
+ authTime = idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.auth_time;
6320
+ if (!authTime) {
6321
+ throw ClientAuthError.createAuthTimeNotFoundError();
6322
+ }
6323
+ AuthToken.checkMaxAge(authTime, request.maxAge);
6324
+ }
6224
6325
  return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, cacheRecord, true, request, idTokenObj)];
6225
6326
  case 1: return [2 /*return*/, _a.sent()];
6226
6327
  }
@@ -6230,7 +6331,7 @@
6230
6331
  return SilentFlowClient;
6231
6332
  }(BaseClient));
6232
6333
 
6233
- /*! @azure/msal-common v7.4.0 2022-09-06 */
6334
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
6234
6335
  /*
6235
6336
  * Copyright (c) Microsoft Corporation. All rights reserved.
6236
6337
  * Licensed under the MIT License.
@@ -6242,7 +6343,7 @@
6242
6343
  response.hasOwnProperty("jwks_uri"));
6243
6344
  }
6244
6345
 
6245
- /*! @azure/msal-common v7.4.0 2022-09-06 */
6346
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
6246
6347
  /*
6247
6348
  * Copyright (c) Microsoft Corporation. All rights reserved.
6248
6349
  * Licensed under the MIT License.
@@ -6251,7 +6352,7 @@
6251
6352
  var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6252
6353
  var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6253
6354
 
6254
- /*! @azure/msal-common v7.4.0 2022-09-06 */
6355
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
6255
6356
  /*
6256
6357
  * Copyright (c) Microsoft Corporation. All rights reserved.
6257
6358
  * Licensed under the MIT License.
@@ -6265,7 +6366,7 @@
6265
6366
  ProtocolMode["OIDC"] = "OIDC";
6266
6367
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
6267
6368
 
6268
- /*! @azure/msal-common v7.4.0 2022-09-06 */
6369
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
6269
6370
 
6270
6371
  /*
6271
6372
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6342,7 +6443,7 @@
6342
6443
  return AuthorityMetadataEntity;
6343
6444
  }());
6344
6445
 
6345
- /*! @azure/msal-common v7.4.0 2022-09-06 */
6446
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
6346
6447
  /*
6347
6448
  * Copyright (c) Microsoft Corporation. All rights reserved.
6348
6449
  * Licensed under the MIT License.
@@ -6352,7 +6453,7 @@
6352
6453
  response.hasOwnProperty("metadata"));
6353
6454
  }
6354
6455
 
6355
- /*! @azure/msal-common v7.4.0 2022-09-06 */
6456
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
6356
6457
 
6357
6458
  /*
6358
6459
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6474,7 +6575,7 @@
6474
6575
  return RegionDiscovery;
6475
6576
  }());
6476
6577
 
6477
- /*! @azure/msal-common v7.4.0 2022-09-06 */
6578
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
6478
6579
 
6479
6580
  /*
6480
6581
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6499,8 +6600,13 @@
6499
6600
  // See above for AuthorityType
6500
6601
  get: function () {
6501
6602
  var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
6502
- if (pathSegments.length && pathSegments[0].toLowerCase() === Constants.ADFS) {
6503
- return AuthorityType.Adfs;
6603
+ if (pathSegments.length) {
6604
+ switch (pathSegments[0].toLowerCase()) {
6605
+ case Constants.ADFS:
6606
+ return AuthorityType.Adfs;
6607
+ case Constants.DSTS:
6608
+ return AuthorityType.Dsts;
6609
+ }
6504
6610
  }
6505
6611
  return AuthorityType.Default;
6506
6612
  },
@@ -6704,7 +6810,9 @@
6704
6810
  * The default open id configuration endpoint for any canonical authority.
6705
6811
  */
6706
6812
  get: function () {
6707
- if (this.authorityType === AuthorityType.Adfs || this.protocolMode === exports.ProtocolMode.OIDC) {
6813
+ if (this.authorityType === AuthorityType.Adfs ||
6814
+ this.authorityType === AuthorityType.Dsts ||
6815
+ this.protocolMode === exports.ProtocolMode.OIDC) {
6708
6816
  return this.canonicalAuthority + ".well-known/openid-configuration";
6709
6817
  }
6710
6818
  return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
@@ -6802,8 +6910,9 @@
6802
6910
  });
6803
6911
  };
6804
6912
  /**
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
6913
+ * Compares the number of url components after the domain to determine if the cached
6914
+ * authority metadata can be used for the requested authority. Protects against same domain different
6915
+ * authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
6807
6916
  * @param metadataEntity
6808
6917
  */
6809
6918
  Authority.prototype.isAuthoritySameType = function (metadataEntity) {
@@ -6843,7 +6952,8 @@
6843
6952
  _a.label = 1;
6844
6953
  case 1:
6845
6954
  _a.trys.push([1, 3, , 4]);
6846
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
6955
+ return [4 /*yield*/, this.networkInterface.
6956
+ sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
6847
6957
  case 2:
6848
6958
  response = _a.sent();
6849
6959
  return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
@@ -6904,7 +7014,8 @@
6904
7014
  });
6905
7015
  };
6906
7016
  /**
6907
- * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
7017
+ * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
7018
+ * and returns where the information was retrieved from
6908
7019
  * @param cachedMetadata
6909
7020
  * @param newMetadata
6910
7021
  */
@@ -7127,7 +7238,7 @@
7127
7238
  Authority.replaceWithRegionalInformation = function (metadata, azureRegion) {
7128
7239
  metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
7129
7240
  // 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");
7241
+ metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
7131
7242
  if (metadata.end_session_endpoint) {
7132
7243
  metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
7133
7244
  }
@@ -7136,7 +7247,7 @@
7136
7247
  return Authority;
7137
7248
  }());
7138
7249
 
7139
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7250
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7140
7251
 
7141
7252
  /*
7142
7253
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7197,7 +7308,7 @@
7197
7308
  return AuthorityFactory;
7198
7309
  }());
7199
7310
 
7200
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7311
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7201
7312
 
7202
7313
  /*
7203
7314
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7228,7 +7339,7 @@
7228
7339
  return ServerTelemetryEntity;
7229
7340
  }());
7230
7341
 
7231
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7342
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7232
7343
 
7233
7344
  /*
7234
7345
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7256,7 +7367,7 @@
7256
7367
  return ThrottlingEntity;
7257
7368
  }());
7258
7369
 
7259
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7370
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7260
7371
 
7261
7372
  /*
7262
7373
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7273,7 +7384,7 @@
7273
7384
  }
7274
7385
  };
7275
7386
 
7276
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7387
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7277
7388
 
7278
7389
  /*
7279
7390
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7318,7 +7429,7 @@
7318
7429
  return JoseHeaderError;
7319
7430
  }(AuthError));
7320
7431
 
7321
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7432
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7322
7433
 
7323
7434
  /*
7324
7435
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7358,7 +7469,7 @@
7358
7469
  return JoseHeader;
7359
7470
  }());
7360
7471
 
7361
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7472
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7362
7473
 
7363
7474
  /*
7364
7475
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7417,7 +7528,7 @@
7417
7528
  return AuthenticationHeaderParser;
7418
7529
  }());
7419
7530
 
7420
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7531
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7421
7532
 
7422
7533
  /*
7423
7534
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7579,7 +7690,7 @@
7579
7690
  return ServerTelemetryManager;
7580
7691
  }());
7581
7692
 
7582
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7693
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7583
7694
 
7584
7695
  /*
7585
7696
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7788,6 +7899,9 @@
7788
7899
  if (current.idTokenSize) {
7789
7900
  previous.idTokenSize = current.idTokenSize;
7790
7901
  }
7902
+ if (current.refreshTokenSize) {
7903
+ previous.refreshTokenSize = current.refreshTokenSize;
7904
+ }
7791
7905
  }
7792
7906
  return previous;
7793
7907
  }, topLevelEvent);
@@ -7855,7 +7969,7 @@
7855
7969
  return PerformanceClient;
7856
7970
  }());
7857
7971
 
7858
- /*! @azure/msal-common v7.4.0 2022-09-06 */
7972
+ /*! @azure/msal-common v7.5.0 2022-10-03 */
7859
7973
 
7860
7974
  /*
7861
7975
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7981,7 +8095,7 @@
7981
8095
  },
7982
8096
  silentPromptValueError: {
7983
8097
  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'."
8098
+ desc: "The value given for the prompt value is not valid for silent requests - must be set to 'none' or 'no_session'."
7985
8099
  },
7986
8100
  noTokenRequestCacheError: {
7987
8101
  code: "no_token_request_cache_error",
@@ -8532,7 +8646,44 @@
8532
8646
  // DatabaseStorage Constants
8533
8647
  var DB_NAME = "msal.db";
8534
8648
  var DB_VERSION = 1;
8535
- var DB_TABLE_NAME = DB_NAME + ".keys";
8649
+ var DB_TABLE_NAME = DB_NAME + ".keys";
8650
+ exports.CacheLookupPolicy = void 0;
8651
+ (function (CacheLookupPolicy) {
8652
+ /*
8653
+ * acquireTokenSilent will attempt to retrieve an access token from the cache. If the access token is expired
8654
+ * or cannot be found the refresh token will be used to acquire a new one. Finally, if the refresh token
8655
+ * is expired acquireTokenSilent will attempt to acquire new access and refresh tokens.
8656
+ */
8657
+ CacheLookupPolicy[CacheLookupPolicy["Default"] = 0] = "Default";
8658
+ /*
8659
+ * acquireTokenSilent will only look for access tokens in the cache. It will not attempt to renew access or
8660
+ * refresh tokens.
8661
+ */
8662
+ CacheLookupPolicy[CacheLookupPolicy["AccessToken"] = 1] = "AccessToken";
8663
+ /*
8664
+ * acquireTokenSilent will attempt to retrieve an access token from the cache. If the access token is expired or
8665
+ * cannot be found, the refresh token will be used to acquire a new one. If the refresh token is expired, it
8666
+ * will not be renewed and acquireTokenSilent will fail.
8667
+ */
8668
+ CacheLookupPolicy[CacheLookupPolicy["AccessTokenAndRefreshToken"] = 2] = "AccessTokenAndRefreshToken";
8669
+ /*
8670
+ * acquireTokenSilent will not attempt to retrieve access tokens from the cache and will instead attempt to
8671
+ * exchange the cached refresh token for a new access token. If the refresh token is expired, it will not be
8672
+ * renewed and acquireTokenSilent will fail.
8673
+ */
8674
+ CacheLookupPolicy[CacheLookupPolicy["RefreshToken"] = 3] = "RefreshToken";
8675
+ /*
8676
+ * acquireTokenSilent will not look in the cache for the access token. It will go directly to network with the
8677
+ * cached refresh token. If the refresh token is expired an attempt will be made to renew it. This is equivalent to
8678
+ * setting "forceRefresh: true".
8679
+ */
8680
+ CacheLookupPolicy[CacheLookupPolicy["RefreshTokenAndNetwork"] = 4] = "RefreshTokenAndNetwork";
8681
+ /*
8682
+ * acquireTokenSilent will attempt to renew both access and refresh tokens. It will not look in the cache. This will
8683
+ * always fail if 3rd party cookies are blocked by the browser.
8684
+ */
8685
+ CacheLookupPolicy[CacheLookupPolicy["Skip"] = 5] = "Skip";
8686
+ })(exports.CacheLookupPolicy || (exports.CacheLookupPolicy = {}));
8536
8687
 
8537
8688
  /*
8538
8689
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8571,6 +8722,10 @@
8571
8722
  inMemRedirectUnavailable: {
8572
8723
  code: "in_mem_redirect_unavailable",
8573
8724
  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."
8725
+ },
8726
+ entropyNotProvided: {
8727
+ code: "entropy_not_provided",
8728
+ desc: "The available browser crypto interface requires entropy set via system.cryptoOptions.entropy configuration option."
8574
8729
  }
8575
8730
  };
8576
8731
  /**
@@ -8621,6 +8776,12 @@
8621
8776
  BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError = function () {
8622
8777
  return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.inMemRedirectUnavailable.code, BrowserConfigurationAuthErrorMessage.inMemRedirectUnavailable.desc);
8623
8778
  };
8779
+ /**
8780
+ * Creates an error thrown when a crypto interface that requires entropy is initialized without entropy
8781
+ */
8782
+ BrowserConfigurationAuthError.createEntropyNotProvided = function () {
8783
+ return new BrowserConfigurationAuthError(BrowserConfigurationAuthErrorMessage.entropyNotProvided.code, BrowserConfigurationAuthErrorMessage.entropyNotProvided.desc);
8784
+ };
8624
8785
  return BrowserConfigurationAuthError;
8625
8786
  }(AuthError));
8626
8787
 
@@ -9683,7 +9844,7 @@
9683
9844
 
9684
9845
  /* eslint-disable header/header */
9685
9846
  var name = "@azure/msal-browser";
9686
- var version = "2.28.2";
9847
+ var version = "2.29.0";
9687
9848
 
9688
9849
  /*
9689
9850
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11086,7 +11247,8 @@
11086
11247
  .then(function (result) {
11087
11248
  nativeATMeasurement.endMeasurement({
11088
11249
  success: true,
11089
- isNativeBroker: true
11250
+ isNativeBroker: true,
11251
+ requestId: result.requestId
11090
11252
  });
11091
11253
  return result;
11092
11254
  })
@@ -12626,7 +12788,10 @@
12626
12788
  // Default system options for browser
12627
12789
  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
12790
  // 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 });
12791
+ 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, cryptoOptions: {
12792
+ useMsrCrypto: false,
12793
+ entropy: undefined
12794
+ } });
12630
12795
  var DEFAULT_TELEMETRY_OPTIONS = {
12631
12796
  application: {
12632
12797
  appName: Constants.EMPTY_STRING,
@@ -12807,7 +12972,7 @@
12807
12972
  return _this;
12808
12973
  }
12809
12974
  /**
12810
- * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none
12975
+ * Acquires a token silently by opening a hidden iframe to the /authorize endpoint with prompt=none or prompt=no_session
12811
12976
  * @param request
12812
12977
  */
12813
12978
  SilentIframeClient.prototype.acquireToken = function (request) {
@@ -12822,14 +12987,14 @@
12822
12987
  if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {
12823
12988
  this.logger.warning("No user hint provided. The authorization server may need more information to complete this request.");
12824
12989
  }
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) {
12990
+ // Check that prompt is set to none or no_session, throw error if it is set to anything else.
12991
+ if (request.prompt && (request.prompt !== PromptValue.NONE) && (request.prompt !== PromptValue.NO_SESSION)) {
12827
12992
  acquireTokenMeasurement.endMeasurement({
12828
12993
  success: false
12829
12994
  });
12830
12995
  throw BrowserAuthError.createSilentPromptValueError(request.prompt);
12831
12996
  }
12832
- return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent)];
12997
+ return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: request.prompt || PromptValue.NONE }), exports.InteractionType.Silent)];
12833
12998
  case 1:
12834
12999
  silentRequest = _a.sent();
12835
13000
  this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || Constants.EMPTY_STRING, silentRequest.account || null);
@@ -12844,7 +13009,8 @@
12844
13009
  return [4 /*yield*/, this.silentTokenHelper(authClient, silentRequest).then(function (result) {
12845
13010
  acquireTokenMeasurement.endMeasurement({
12846
13011
  success: true,
12847
- fromCache: false
13012
+ fromCache: false,
13013
+ requestId: result.requestId
12848
13014
  });
12849
13015
  return result;
12850
13016
  })];
@@ -12908,7 +13074,7 @@
12908
13074
  }
12909
13075
  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
13076
  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 () {
13077
+ return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: silentRequest.prompt || PromptValue.NONE })).finally(function () {
12912
13078
  _this.browserStorage.cleanRequestByState(state);
12913
13079
  })];
12914
13080
  }
@@ -12956,7 +13122,8 @@
12956
13122
  .then(function (result) {
12957
13123
  acquireTokenMeasurement.endMeasurement({
12958
13124
  success: true,
12959
- fromCache: result.fromCache
13125
+ fromCache: result.fromCache,
13126
+ requestId: result.requestId
12960
13127
  });
12961
13128
  return result;
12962
13129
  })
@@ -13362,6 +13529,13 @@
13362
13529
  }
13363
13530
  return sView;
13364
13531
  };
13532
+ /**
13533
+ * Returns stringified jwk.
13534
+ * @param jwk
13535
+ */
13536
+ BrowserStringUtils.getSortedObjectString = function (obj) {
13537
+ return JSON.stringify(obj, Object.keys(obj).sort());
13538
+ };
13365
13539
  return BrowserStringUtils;
13366
13540
  }());
13367
13541
 
@@ -13604,178 +13778,117 @@
13604
13778
  * Copyright (c) Microsoft Corporation. All rights reserved.
13605
13779
  * Licensed under the MIT License.
13606
13780
  */
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
- };
13781
+ var ModernBrowserCrypto = /** @class */ (function () {
13782
+ function ModernBrowserCrypto() {
13634
13783
  }
13635
- /**
13636
- * Returns a sha-256 hash of the given dataString as an ArrayBuffer.
13637
- * @param dataString
13638
- */
13639
- BrowserCrypto.prototype.sha256Digest = function (dataString) {
13784
+ ModernBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
13785
+ return window.crypto.getRandomValues(dataBuffer);
13786
+ };
13787
+ ModernBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
13640
13788
  return __awaiter$1(this, void 0, void 0, function () {
13641
- var data;
13642
13789
  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)];
13790
+ return [2 /*return*/, window.crypto.subtle.generateKey(algorithm, extractable, keyUsages)];
13645
13791
  });
13646
13792
  });
13647
13793
  };
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) {
13794
+ ModernBrowserCrypto.prototype.exportKey = function (key) {
13665
13795
  return __awaiter$1(this, void 0, void 0, function () {
13666
13796
  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))];
13797
+ return [2 /*return*/, window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key)];
13670
13798
  });
13671
13799
  });
13672
13800
  };
13673
- /**
13674
- * Export key as Json Web Key (JWK)
13675
- * @param key
13676
- * @param format
13677
- */
13678
- BrowserCrypto.prototype.exportJwk = function (key) {
13801
+ ModernBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
13679
13802
  return __awaiter$1(this, void 0, void 0, function () {
13680
13803
  return __generator$1(this, function (_a) {
13681
- return [2 /*return*/, this.hasIECrypto() ? this.msCryptoExportJwk(key) : window.crypto.subtle.exportKey(KEY_FORMAT_JWK, key)];
13804
+ return [2 /*return*/, window.crypto.subtle.importKey(KEY_FORMAT_JWK, keyData, algorithm, extractable, keyUsages)];
13682
13805
  });
13683
13806
  });
13684
13807
  };
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) {
13808
+ ModernBrowserCrypto.prototype.sign = function (algorithm, key, data) {
13693
13809
  return __awaiter$1(this, void 0, void 0, function () {
13694
- var keyString, keyBuffer;
13695
13810
  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)];
13811
+ return [2 /*return*/, window.crypto.subtle.sign(algorithm, key, data)];
13701
13812
  });
13702
13813
  });
13703
13814
  };
13704
- /**
13705
- * Signs given data with given key
13706
- * @param key
13707
- * @param data
13708
- */
13709
- BrowserCrypto.prototype.sign = function (key, data) {
13815
+ ModernBrowserCrypto.prototype.digest = function (algorithm, data) {
13710
13816
  return __awaiter$1(this, void 0, void 0, function () {
13711
13817
  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)];
13818
+ return [2 /*return*/, window.crypto.subtle.digest(algorithm, data)];
13715
13819
  });
13716
13820
  });
13717
13821
  };
13718
- /**
13719
- * Check whether IE crypto or other browser cryptography is available.
13720
- */
13721
- BrowserCrypto.prototype.hasCryptoAPI = function () {
13722
- return this.hasIECrypto() || this.hasBrowserCrypto();
13822
+ return ModernBrowserCrypto;
13823
+ }());
13824
+
13825
+ /*
13826
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13827
+ * Licensed under the MIT License.
13828
+ */
13829
+ var MsrBrowserCrypto = /** @class */ (function () {
13830
+ function MsrBrowserCrypto() {
13831
+ }
13832
+ MsrBrowserCrypto.prototype.initPrng = function (entropy) {
13833
+ // Turn into array, as initPrng seems to not always like Uint8Array (even though it should support both)
13834
+ return window.msrCrypto.initPrng(__spread(entropy));
13723
13835
  };
13724
- /**
13725
- * Checks whether IE crypto (AKA msCrypto) is available.
13726
- */
13727
- BrowserCrypto.prototype.hasIECrypto = function () {
13728
- return "msCrypto" in window;
13836
+ MsrBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
13837
+ return window.msrCrypto.getRandomValues(dataBuffer);
13729
13838
  };
13730
- /**
13731
- * Check whether browser crypto is available.
13732
- */
13733
- BrowserCrypto.prototype.hasBrowserCrypto = function () {
13734
- return "crypto" in window;
13839
+ MsrBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
13840
+ return __awaiter$1(this, void 0, void 0, function () {
13841
+ return __generator$1(this, function (_a) {
13842
+ return [2 /*return*/, window.msrCrypto.subtle.generateKey(algorithm, extractable, keyUsages)];
13843
+ });
13844
+ });
13735
13845
  };
13736
- /**
13737
- * Helper function for SHA digest.
13738
- * @param algorithm
13739
- * @param data
13740
- */
13741
- BrowserCrypto.prototype.getSubtleCryptoDigest = function (algorithm, data) {
13846
+ MsrBrowserCrypto.prototype.exportKey = function (key) {
13742
13847
  return __awaiter$1(this, void 0, void 0, function () {
13743
13848
  return __generator$1(this, function (_a) {
13744
- return [2 /*return*/, window.crypto.subtle.digest(algorithm, data)];
13849
+ return [2 /*return*/, window.msrCrypto.subtle.exportKey(KEY_FORMAT_JWK, key)];
13745
13850
  });
13746
13851
  });
13747
13852
  };
13748
- /**
13749
- * IE Helper function for SHA digest.
13750
- * @param algorithm
13751
- * @param data
13752
- */
13753
- BrowserCrypto.prototype.getMSCryptoDigest = function (algorithm, data) {
13853
+ MsrBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
13754
13854
  return __awaiter$1(this, void 0, void 0, function () {
13755
13855
  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
- })];
13856
+ return [2 /*return*/, window.msrCrypto.subtle.importKey(KEY_FORMAT_JWK, keyData, algorithm, extractable, keyUsages)];
13765
13857
  });
13766
13858
  });
13767
13859
  };
13768
- /**
13769
- * IE Helper function for generating a keypair
13770
- * @param extractable
13771
- * @param usages
13772
- */
13773
- BrowserCrypto.prototype.msCryptoGenerateKey = function (extractable, usages) {
13860
+ MsrBrowserCrypto.prototype.sign = function (algorithm, key, data) {
13861
+ return __awaiter$1(this, void 0, void 0, function () {
13862
+ return __generator$1(this, function (_a) {
13863
+ return [2 /*return*/, window.msrCrypto.subtle.sign(algorithm, key, data)];
13864
+ });
13865
+ });
13866
+ };
13867
+ MsrBrowserCrypto.prototype.digest = function (algorithm, data) {
13868
+ return __awaiter$1(this, void 0, void 0, function () {
13869
+ return __generator$1(this, function (_a) {
13870
+ return [2 /*return*/, window.msrCrypto.subtle.digest(algorithm, data)];
13871
+ });
13872
+ });
13873
+ };
13874
+ return MsrBrowserCrypto;
13875
+ }());
13876
+
13877
+ /*
13878
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13879
+ * Licensed under the MIT License.
13880
+ */
13881
+ var MsBrowserCrypto = /** @class */ (function () {
13882
+ function MsBrowserCrypto() {
13883
+ }
13884
+ MsBrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
13885
+ return window["msCrypto"].getRandomValues(dataBuffer);
13886
+ };
13887
+ MsBrowserCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
13774
13888
  return __awaiter$1(this, void 0, void 0, function () {
13775
- var _this = this;
13776
13889
  return __generator$1(this, function (_a) {
13777
13890
  return [2 /*return*/, new Promise(function (resolve, reject) {
13778
- var msGenerateKey = window["msCrypto"].subtle.generateKey(_this._keygenAlgorithmOptions, extractable, usages);
13891
+ var msGenerateKey = window["msCrypto"].subtle.generateKey(algorithm, extractable, keyUsages);
13779
13892
  msGenerateKey.addEventListener("complete", function (e) {
13780
13893
  resolve(e.target.result);
13781
13894
  });
@@ -13786,12 +13899,7 @@
13786
13899
  });
13787
13900
  });
13788
13901
  };
13789
- /**
13790
- * IE Helper function for exportKey
13791
- * @param key
13792
- * @param format
13793
- */
13794
- BrowserCrypto.prototype.msCryptoExportJwk = function (key) {
13902
+ MsBrowserCrypto.prototype.exportKey = function (key) {
13795
13903
  return __awaiter$1(this, void 0, void 0, function () {
13796
13904
  return __generator$1(this, function (_a) {
13797
13905
  return [2 /*return*/, new Promise(function (resolve, reject) {
@@ -13818,19 +13926,14 @@
13818
13926
  });
13819
13927
  });
13820
13928
  };
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) {
13929
+ MsBrowserCrypto.prototype.importKey = function (keyData, algorithm, extractable, keyUsages) {
13829
13930
  return __awaiter$1(this, void 0, void 0, function () {
13830
- var _this = this;
13931
+ var keyString, keyBuffer;
13831
13932
  return __generator$1(this, function (_a) {
13933
+ keyString = BrowserStringUtils.getSortedObjectString(keyData);
13934
+ keyBuffer = BrowserStringUtils.stringToArrayBuffer(keyString);
13832
13935
  return [2 /*return*/, new Promise(function (resolve, reject) {
13833
- var msImportKey = window["msCrypto"].subtle.importKey(KEY_FORMAT_JWK, keyBuffer, _this._keygenAlgorithmOptions, extractable, usages);
13936
+ var msImportKey = window["msCrypto"].subtle.importKey(KEY_FORMAT_JWK, keyBuffer, algorithm, extractable, keyUsages);
13834
13937
  msImportKey.addEventListener("complete", function (e) {
13835
13938
  resolve(e.target.result);
13836
13939
  });
@@ -13841,17 +13944,11 @@
13841
13944
  });
13842
13945
  });
13843
13946
  };
13844
- /**
13845
- * IE Helper function for sign JWT
13846
- * @param key
13847
- * @param data
13848
- */
13849
- BrowserCrypto.prototype.msCryptoSign = function (key, data) {
13947
+ MsBrowserCrypto.prototype.sign = function (algorithm, key, data) {
13850
13948
  return __awaiter$1(this, void 0, void 0, function () {
13851
- var _this = this;
13852
13949
  return __generator$1(this, function (_a) {
13853
13950
  return [2 /*return*/, new Promise(function (resolve, reject) {
13854
- var msSign = window["msCrypto"].subtle.sign(_this._keygenAlgorithmOptions, key, data);
13951
+ var msSign = window["msCrypto"].subtle.sign(algorithm, key, data);
13855
13952
  msSign.addEventListener("complete", function (e) {
13856
13953
  resolve(e.target.result);
13857
13954
  });
@@ -13862,12 +13959,175 @@
13862
13959
  });
13863
13960
  });
13864
13961
  };
13962
+ MsBrowserCrypto.prototype.digest = function (algorithm, data) {
13963
+ return __awaiter$1(this, void 0, void 0, function () {
13964
+ return __generator$1(this, function (_a) {
13965
+ return [2 /*return*/, new Promise(function (resolve, reject) {
13966
+ var digestOperation = window["msCrypto"].subtle.digest(algorithm, data.buffer);
13967
+ digestOperation.addEventListener("complete", function (e) {
13968
+ resolve(e.target.result);
13969
+ });
13970
+ digestOperation.addEventListener("error", function (error) {
13971
+ reject(error);
13972
+ });
13973
+ })];
13974
+ });
13975
+ });
13976
+ };
13977
+ return MsBrowserCrypto;
13978
+ }());
13979
+
13980
+ /*
13981
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13982
+ * Licensed under the MIT License.
13983
+ */
13984
+ /**
13985
+ * See here for more info on RsaHashedKeyGenParams: https://developer.mozilla.org/en-US/docs/Web/API/RsaHashedKeyGenParams
13986
+ */
13987
+ // RSA KeyGen Algorithm
13988
+ var PKCS1_V15_KEYGEN_ALG = "RSASSA-PKCS1-v1_5";
13989
+ // SHA-256 hashing algorithm
13990
+ var S256_HASH_ALG = "SHA-256";
13991
+ // MOD length for PoP tokens
13992
+ var MODULUS_LENGTH = 2048;
13993
+ // Public Exponent
13994
+ var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
13995
+ /**
13996
+ * This class implements functions used by the browser library to perform cryptography operations such as
13997
+ * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
13998
+ */
13999
+ var BrowserCrypto = /** @class */ (function () {
14000
+ function BrowserCrypto(logger, cryptoOptions) {
14001
+ var _a, _b;
14002
+ this.logger = logger;
14003
+ this.cryptoOptions = cryptoOptions;
14004
+ if (this.hasBrowserCrypto()) {
14005
+ // Use standard modern web crypto if available
14006
+ this.logger.verbose("BrowserCrypto: modern crypto interface available");
14007
+ this.subtleCrypto = new ModernBrowserCrypto();
14008
+ }
14009
+ else if (this.hasIECrypto()) {
14010
+ // For IE11, use msCrypto interface
14011
+ this.logger.verbose("BrowserCrypto: MS crypto interface available");
14012
+ this.subtleCrypto = new MsBrowserCrypto();
14013
+ }
14014
+ else if (this.hasMsrCrypto() && ((_a = this.cryptoOptions) === null || _a === void 0 ? void 0 : _a.useMsrCrypto)) {
14015
+ // For other browsers, use MSR Crypto if found
14016
+ this.logger.verbose("BrowserCrypto: MSR crypto interface available");
14017
+ this.subtleCrypto = new MsrBrowserCrypto();
14018
+ }
14019
+ else {
14020
+ if (this.hasMsrCrypto()) {
14021
+ this.logger.info("BrowserCrypto: MSR Crypto interface available but system.cryptoOptions.useMsrCrypto not enabled");
14022
+ }
14023
+ this.logger.error("BrowserCrypto: No crypto interfaces available.");
14024
+ throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto, msCrypto, or msrCrypto interfaces not available.");
14025
+ }
14026
+ // Mainly needed for MSR Crypto: https://github.com/microsoft/MSR-JavaScript-Crypto#random-number-generator-prng
14027
+ if (this.subtleCrypto.initPrng) {
14028
+ this.logger.verbose("BrowserCrypto: Interface requires entropy");
14029
+ if (!((_b = this.cryptoOptions) === null || _b === void 0 ? void 0 : _b.entropy)) {
14030
+ this.logger.error("BrowserCrypto: Interface requires entropy but none provided.");
14031
+ throw BrowserConfigurationAuthError.createEntropyNotProvided();
14032
+ }
14033
+ this.logger.verbose("BrowserCrypto: Entropy provided");
14034
+ this.subtleCrypto.initPrng(this.cryptoOptions.entropy);
14035
+ }
14036
+ this.keygenAlgorithmOptions = {
14037
+ name: PKCS1_V15_KEYGEN_ALG,
14038
+ hash: S256_HASH_ALG,
14039
+ modulusLength: MODULUS_LENGTH,
14040
+ publicExponent: PUBLIC_EXPONENT
14041
+ };
14042
+ }
13865
14043
  /**
13866
- * Returns stringified jwk.
13867
- * @param jwk
14044
+ * Check whether IE crypto or other browser cryptography is available.
14045
+ */
14046
+ BrowserCrypto.prototype.hasIECrypto = function () {
14047
+ return "msCrypto" in window;
14048
+ };
14049
+ /**
14050
+ * Check whether browser crypto is available.
13868
14051
  */
13869
- BrowserCrypto.getJwkString = function (jwk) {
13870
- return JSON.stringify(jwk, Object.keys(jwk).sort());
14052
+ BrowserCrypto.prototype.hasBrowserCrypto = function () {
14053
+ return "crypto" in window;
14054
+ };
14055
+ /**
14056
+ * Check whether MSR crypto polyfill is available
14057
+ */
14058
+ BrowserCrypto.prototype.hasMsrCrypto = function () {
14059
+ return "msrCrypto" in window;
14060
+ };
14061
+ /**
14062
+ * Returns a sha-256 hash of the given dataString as an ArrayBuffer.
14063
+ * @param dataString
14064
+ */
14065
+ BrowserCrypto.prototype.sha256Digest = function (dataString) {
14066
+ return __awaiter$1(this, void 0, void 0, function () {
14067
+ var data;
14068
+ return __generator$1(this, function (_a) {
14069
+ data = BrowserStringUtils.stringToUtf8Arr(dataString);
14070
+ // MSR Crypto wants object with name property, instead of string
14071
+ return [2 /*return*/, this.subtleCrypto.digest({ name: S256_HASH_ALG }, data)];
14072
+ });
14073
+ });
14074
+ };
14075
+ /**
14076
+ * Populates buffer with cryptographically random values.
14077
+ * @param dataBuffer
14078
+ */
14079
+ BrowserCrypto.prototype.getRandomValues = function (dataBuffer) {
14080
+ return this.subtleCrypto.getRandomValues(dataBuffer);
14081
+ };
14082
+ /**
14083
+ * Generates a keypair based on current keygen algorithm config.
14084
+ * @param extractable
14085
+ * @param usages
14086
+ */
14087
+ BrowserCrypto.prototype.generateKeyPair = function (extractable, usages) {
14088
+ return __awaiter$1(this, void 0, void 0, function () {
14089
+ return __generator$1(this, function (_a) {
14090
+ return [2 /*return*/, this.subtleCrypto.generateKey(this.keygenAlgorithmOptions, extractable, usages)];
14091
+ });
14092
+ });
14093
+ };
14094
+ /**
14095
+ * Export key as Json Web Key (JWK)
14096
+ * @param key
14097
+ * @param format
14098
+ */
14099
+ BrowserCrypto.prototype.exportJwk = function (key) {
14100
+ return __awaiter$1(this, void 0, void 0, function () {
14101
+ return __generator$1(this, function (_a) {
14102
+ return [2 /*return*/, this.subtleCrypto.exportKey(key)];
14103
+ });
14104
+ });
14105
+ };
14106
+ /**
14107
+ * Imports key as Json Web Key (JWK), can set extractable and usages.
14108
+ * @param key
14109
+ * @param format
14110
+ * @param extractable
14111
+ * @param usages
14112
+ */
14113
+ BrowserCrypto.prototype.importJwk = function (key, extractable, usages) {
14114
+ return __awaiter$1(this, void 0, void 0, function () {
14115
+ return __generator$1(this, function (_a) {
14116
+ return [2 /*return*/, this.subtleCrypto.importKey(key, this.keygenAlgorithmOptions, extractable, usages)];
14117
+ });
14118
+ });
14119
+ };
14120
+ /**
14121
+ * Signs given data with given key
14122
+ * @param key
14123
+ * @param data
14124
+ */
14125
+ BrowserCrypto.prototype.sign = function (key, data) {
14126
+ return __awaiter$1(this, void 0, void 0, function () {
14127
+ return __generator$1(this, function (_a) {
14128
+ return [2 /*return*/, this.subtleCrypto.sign(this.keygenAlgorithmOptions, key, data)];
14129
+ });
14130
+ });
13871
14131
  };
13872
14132
  return BrowserCrypto;
13873
14133
  }());
@@ -14109,29 +14369,17 @@
14109
14369
  */
14110
14370
  DatabaseStorage.prototype.deleteDatabase = function () {
14111
14371
  return __awaiter$1(this, void 0, void 0, function () {
14112
- var existingDatabases, database;
14113
14372
  return __generator$1(this, function (_a) {
14114
- switch (_a.label) {
14115
- case 0:
14116
- // Check if database being deleted exists
14117
- if (this.db && this.dbOpen) {
14118
- this.closeConnection();
14119
- }
14120
- return [4 /*yield*/, window.indexedDB.databases()];
14121
- case 1:
14122
- existingDatabases = _a.sent();
14123
- database = existingDatabases.find(function (database) { return database.name === DB_NAME; });
14124
- // If database exists, delete it
14125
- if (database) {
14126
- return [2 /*return*/, new Promise(function (resolve, reject) {
14127
- var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
14128
- deleteDbRequest.addEventListener("success", function () { return resolve(true); });
14129
- deleteDbRequest.addEventListener("error", function () { return reject(false); });
14130
- })];
14131
- }
14132
- // Database doesn't exist, return true
14133
- return [2 /*return*/, true];
14373
+ // Check if database being deleted exists
14374
+ if (this.db && this.dbOpen) {
14375
+ this.closeConnection();
14134
14376
  }
14377
+ return [2 /*return*/, new Promise(function (resolve, reject) {
14378
+ var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
14379
+ deleteDbRequest.addEventListener("success", function () { return resolve(true); });
14380
+ deleteDbRequest.addEventListener("blocked", function () { return resolve(true); });
14381
+ deleteDbRequest.addEventListener("error", function () { return reject(false); });
14382
+ })];
14135
14383
  });
14136
14384
  });
14137
14385
  };
@@ -14300,34 +14548,38 @@
14300
14548
  });
14301
14549
  };
14302
14550
  /**
14303
- * Clears in-memory Map and tries to delete the IndexedDB database.
14551
+ * Clears in-memory Map
14552
+ */
14553
+ AsyncMemoryStorage.prototype.clearInMemory = function () {
14554
+ // InMemory cache is a Map instance, clear is straightforward
14555
+ this.logger.verbose("Deleting in-memory keystore " + this.storeName);
14556
+ this.inMemoryCache.clear();
14557
+ this.logger.verbose("In-memory keystore " + this.storeName + " deleted");
14558
+ };
14559
+ /**
14560
+ * Tries to delete the IndexedDB database
14561
+ * @returns
14304
14562
  */
14305
- AsyncMemoryStorage.prototype.clear = function () {
14563
+ AsyncMemoryStorage.prototype.clearPersistent = function () {
14306
14564
  return __awaiter$1(this, void 0, void 0, function () {
14307
14565
  var dbDeleted, e_6;
14308
14566
  return __generator$1(this, function (_a) {
14309
14567
  switch (_a.label) {
14310
14568
  case 0:
14311
- // InMemory cache is a Map instance, clear is straightforward
14312
- this.logger.verbose("Deleting in-memory keystore " + this.storeName);
14313
- this.inMemoryCache.clear();
14314
- this.logger.verbose("In-memory keystore " + this.storeName + " deleted");
14315
- this.logger.verbose("Deleting persistent keystore " + this.storeName);
14316
- _a.label = 1;
14317
- case 1:
14318
- _a.trys.push([1, 3, , 4]);
14569
+ _a.trys.push([0, 2, , 3]);
14570
+ this.logger.verbose("Deleting persistent keystore");
14319
14571
  return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
14320
- case 2:
14572
+ case 1:
14321
14573
  dbDeleted = _a.sent();
14322
14574
  if (dbDeleted) {
14323
- this.logger.verbose("Persistent keystore " + this.storeName + " deleted");
14575
+ this.logger.verbose("Persistent keystore deleted");
14324
14576
  }
14325
14577
  return [2 /*return*/, dbDeleted];
14326
- case 3:
14578
+ case 2:
14327
14579
  e_6 = _a.sent();
14328
14580
  this.handleDatabaseAccessError(e_6);
14329
14581
  return [2 /*return*/, false];
14330
- case 4: return [2 /*return*/];
14582
+ case 3: return [2 /*return*/];
14331
14583
  }
14332
14584
  });
14333
14585
  });
@@ -14344,23 +14596,66 @@
14344
14596
  CryptoKeyStoreNames["asymmetricKeys"] = "asymmetricKeys";
14345
14597
  CryptoKeyStoreNames["symmetricKeys"] = "symmetricKeys";
14346
14598
  })(CryptoKeyStoreNames || (CryptoKeyStoreNames = {}));
14599
+ /**
14600
+ * MSAL CryptoKeyStore DB Version 2
14601
+ */
14602
+ var CryptoKeyStore = /** @class */ (function () {
14603
+ function CryptoKeyStore(logger) {
14604
+ this.logger = logger;
14605
+ this.asymmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys);
14606
+ this.symmetricKeys = new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys);
14607
+ }
14608
+ CryptoKeyStore.prototype.clear = function () {
14609
+ return __awaiter$1(this, void 0, void 0, function () {
14610
+ var e_1;
14611
+ return __generator$1(this, function (_a) {
14612
+ switch (_a.label) {
14613
+ case 0:
14614
+ // Delete in-memory keystores
14615
+ this.asymmetricKeys.clearInMemory();
14616
+ this.symmetricKeys.clearInMemory();
14617
+ _a.label = 1;
14618
+ case 1:
14619
+ _a.trys.push([1, 3, , 4]);
14620
+ return [4 /*yield*/, this.asymmetricKeys.clearPersistent()];
14621
+ case 2:
14622
+ _a.sent();
14623
+ return [2 /*return*/, true];
14624
+ case 3:
14625
+ e_1 = _a.sent();
14626
+ if (e_1 instanceof Error) {
14627
+ this.logger.error("Clearing keystore failed with error: " + e_1.message);
14628
+ }
14629
+ else {
14630
+ this.logger.error("Clearing keystore failed with unknown error");
14631
+ }
14632
+ return [2 /*return*/, false];
14633
+ case 4: return [2 /*return*/];
14634
+ }
14635
+ });
14636
+ });
14637
+ };
14638
+ return CryptoKeyStore;
14639
+ }());
14640
+
14641
+ /*
14642
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14643
+ * Licensed under the MIT License.
14644
+ */
14347
14645
  /**
14348
14646
  * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
14349
14647
  * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
14350
14648
  */
14351
14649
  var CryptoOps = /** @class */ (function () {
14352
- function CryptoOps(logger, performanceClient) {
14650
+ function CryptoOps(logger, performanceClient, cryptoConfig) {
14353
14651
  this.logger = logger;
14354
14652
  // Browser crypto needs to be validated first before any other classes can be set.
14355
- this.browserCrypto = new BrowserCrypto(this.logger);
14653
+ this.browserCrypto = new BrowserCrypto(this.logger, cryptoConfig);
14356
14654
  this.b64Encode = new Base64Encode();
14357
14655
  this.b64Decode = new Base64Decode();
14358
14656
  this.guidGenerator = new GuidGenerator(this.browserCrypto);
14359
14657
  this.pkceGenerator = new PkceGenerator(this.browserCrypto);
14360
- this.cache = {
14361
- asymmetricKeys: new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.asymmetricKeys),
14362
- symmetricKeys: new AsyncMemoryStorage(this.logger, CryptoKeyStoreNames.symmetricKeys)
14363
- };
14658
+ this.cache = new CryptoKeyStore(this.logger);
14364
14659
  this.performanceClient = performanceClient;
14365
14660
  }
14366
14661
  /**
@@ -14417,7 +14712,7 @@
14417
14712
  kty: publicKeyJwk.kty,
14418
14713
  n: publicKeyJwk.n
14419
14714
  };
14420
- publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
14715
+ publicJwkString = BrowserStringUtils.getSortedObjectString(pubKeyThumprintObj);
14421
14716
  return [4 /*yield*/, this.hashString(publicJwkString)];
14422
14717
  case 3:
14423
14718
  publicJwkHash = _b.sent();
@@ -14472,32 +14767,10 @@
14472
14767
  */
14473
14768
  CryptoOps.prototype.clearKeystore = function () {
14474
14769
  return __awaiter$1(this, void 0, void 0, function () {
14475
- var e_1;
14476
14770
  return __generator$1(this, function (_a) {
14477
14771
  switch (_a.label) {
14478
- case 0:
14479
- _a.trys.push([0, 3, , 4]);
14480
- this.logger.verbose("Deleting in-memory and persistent asymmetric key stores");
14481
- return [4 /*yield*/, this.cache.asymmetricKeys.clear()];
14482
- case 1:
14483
- _a.sent();
14484
- this.logger.verbose("Successfully deleted asymmetric key stores");
14485
- this.logger.verbose("Deleting in-memory and persistent symmetric key stores");
14486
- return [4 /*yield*/, this.cache.symmetricKeys.clear()];
14487
- case 2:
14488
- _a.sent();
14489
- this.logger.verbose("Successfully deleted symmetric key stores");
14490
- return [2 /*return*/, true];
14491
- case 3:
14492
- e_1 = _a.sent();
14493
- if (e_1 instanceof Error) {
14494
- this.logger.error("Clearing keystore failed with error: " + e_1.message);
14495
- }
14496
- else {
14497
- this.logger.error("Clearing keystore failed with unknown error");
14498
- }
14499
- return [2 /*return*/, false];
14500
- case 4: return [2 /*return*/];
14772
+ case 0: return [4 /*yield*/, this.cache.clear()];
14773
+ case 1: return [2 /*return*/, _a.sent()];
14501
14774
  }
14502
14775
  });
14503
14776
  });
@@ -14524,7 +14797,7 @@
14524
14797
  return [4 /*yield*/, this.browserCrypto.exportJwk(cachedKeyPair.publicKey)];
14525
14798
  case 2:
14526
14799
  publicKeyJwk = _b.sent();
14527
- publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
14800
+ publicKeyJwkString = BrowserStringUtils.getSortedObjectString(publicKeyJwk);
14528
14801
  encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
14529
14802
  shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
14530
14803
  encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
@@ -14845,9 +15118,9 @@
14845
15118
  */
14846
15119
  var BrowserPerformanceClient = /** @class */ (function (_super) {
14847
15120
  __extends$1(BrowserPerformanceClient, _super);
14848
- function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
15121
+ function BrowserPerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry, cryptoOptions) {
14849
15122
  var _this = _super.call(this, clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) || this;
14850
- _this.browserCrypto = new BrowserCrypto(_this.logger);
15123
+ _this.browserCrypto = new BrowserCrypto(_this.logger, cryptoOptions);
14851
15124
  _this.guidGenerator = new GuidGenerator(_this.browserCrypto);
14852
15125
  return _this;
14853
15126
  }
@@ -14929,10 +15202,10 @@
14929
15202
  this.hybridAuthCodeResponses = new Map();
14930
15203
  // Initialize performance client
14931
15204
  this.performanceClient = this.isBrowserEnvironment ?
14932
- new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application) :
15205
+ new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application, this.config.system.cryptoOptions) :
14933
15206
  new StubPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application);
14934
15207
  // Initialize the crypto class.
14935
- this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger, this.performanceClient) : DEFAULT_CRYPTO_IMPLEMENTATION;
15208
+ this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger, this.performanceClient, this.config.system.cryptoOptions) : DEFAULT_CRYPTO_IMPLEMENTATION;
14936
15209
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
14937
15210
  // Initialize the browser storage class.
14938
15211
  this.browserStorage = this.isBrowserEnvironment ?
@@ -15154,6 +15427,7 @@
15154
15427
  isNativeBroker: true,
15155
15428
  accessTokenSize: response.accessToken.length,
15156
15429
  idTokenSize: response.idToken.length,
15430
+ requestId: response.requestId
15157
15431
  });
15158
15432
  atPopupMeasurement.flushMeasurement();
15159
15433
  return response;
@@ -15191,6 +15465,7 @@
15191
15465
  success: true,
15192
15466
  accessTokenSize: result.accessToken.length,
15193
15467
  idTokenSize: result.idToken.length,
15468
+ requestId: result.requestId
15194
15469
  });
15195
15470
  atPopupMeasurement.flushMeasurement();
15196
15471
  return result;
@@ -15234,7 +15509,9 @@
15234
15509
  var _this = this;
15235
15510
  return __generator$1(this, function (_a) {
15236
15511
  correlationId = this.getRequestCorrelationId(request);
15237
- validRequest = __assign$1(__assign$1({}, request), { prompt: PromptValue.NONE, correlationId: correlationId });
15512
+ validRequest = __assign$1(__assign$1({}, request), {
15513
+ // will be PromptValue.NONE or PromptValue.NO_SESSION
15514
+ prompt: request.prompt, correlationId: correlationId });
15238
15515
  this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
15239
15516
  ssoSilentMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SsoSilent, correlationId);
15240
15517
  this.logger.verbose("ssoSilent called", correlationId);
@@ -15260,7 +15537,8 @@
15260
15537
  success: true,
15261
15538
  isNativeBroker: response.fromNativeBroker,
15262
15539
  accessTokenSize: response.accessToken.length,
15263
- idTokenSize: response.idToken.length
15540
+ idTokenSize: response.idToken.length,
15541
+ requestId: response.requestId
15264
15542
  });
15265
15543
  ssoSilentMeasurement.flushMeasurement();
15266
15544
  return response;
@@ -15311,7 +15589,8 @@
15311
15589
  success: true,
15312
15590
  accessTokenSize: result.accessToken.length,
15313
15591
  idTokenSize: result.idToken.length,
15314
- isNativeBroker: result.fromNativeBroker
15592
+ isNativeBroker: result.fromNativeBroker,
15593
+ requestId: result.requestId
15315
15594
  });
15316
15595
  atbcMeasurement.flushMeasurement();
15317
15596
  return result;
@@ -15391,67 +15670,62 @@
15391
15670
  });
15392
15671
  };
15393
15672
  /**
15394
- * Use this function to obtain a token before every call to the API / resource provider
15395
- *
15396
- * MSAL return's a cached token when available
15397
- * Or it send's a request to the STS to obtain a new token using a refresh token.
15398
- *
15399
- * @param {@link SilentRequest}
15400
- *
15401
- * To renew idToken, please pass clientId as the only scope in the Authentication Parameters
15402
- * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
15673
+ * Attempt to acquire an access token from the cache
15674
+ * @param silentCacheClient SilentCacheClient
15675
+ * @param commonRequest CommonSilentFlowRequest
15676
+ * @param silentRequest SilentRequest
15677
+ * @returns A promise that, when resolved, returns the access token
15403
15678
  */
15404
- ClientApplication.prototype.acquireTokenByRefreshToken = function (request) {
15679
+ ClientApplication.prototype.acquireTokenFromCache = function (silentCacheClient, commonRequest, silentRequest) {
15405
15680
  return __awaiter$1(this, void 0, void 0, function () {
15406
- var atbrtMeasurement, silentRefreshClient;
15407
- var _this = this;
15408
15681
  return __generator$1(this, function (_a) {
15409
- // block the reload if it occurred inside a hidden iframe
15410
- BrowserUtils.blockReloadInHiddenIframes();
15411
- atbrtMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.AcquireTokenByRefreshToken, request.correlationId);
15412
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, request);
15413
- silentRefreshClient = this.createSilentRefreshClient(request.correlationId);
15414
- return [2 /*return*/, silentRefreshClient.acquireToken(request)
15415
- .then(function (result) {
15416
- atbrtMeasurement.endMeasurement({
15417
- success: true,
15418
- fromCache: result.fromCache,
15419
- accessTokenSize: result.accessToken.length,
15420
- idTokenSize: result.idToken.length,
15421
- });
15422
- return result;
15423
- })
15424
- .catch(function (e) {
15425
- var isServerError = e instanceof ServerError;
15426
- var isInteractionRequiredError = e instanceof InteractionRequiredAuthError;
15427
- var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
15428
- if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
15429
- _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
15430
- var silentIframeClient = _this.createSilentIframeClient(request.correlationId);
15431
- return silentIframeClient.acquireToken(request)
15432
- .then(function (result) {
15433
- atbrtMeasurement.endMeasurement({
15434
- success: true,
15435
- fromCache: result.fromCache,
15436
- accessTokenSize: result.accessToken.length,
15437
- idTokenSize: result.idToken.length,
15438
- });
15439
- return result;
15440
- })
15441
- .catch(function (error) {
15442
- atbrtMeasurement.endMeasurement({
15443
- errorCode: error.errorCode,
15444
- subErrorCode: error.subError,
15445
- success: false
15446
- });
15447
- throw error;
15448
- });
15449
- }
15450
- atbrtMeasurement.endMeasurement({
15451
- success: false
15452
- });
15453
- throw e;
15454
- })];
15682
+ switch (silentRequest.cacheLookupPolicy) {
15683
+ case exports.CacheLookupPolicy.Default:
15684
+ case exports.CacheLookupPolicy.AccessToken:
15685
+ case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
15686
+ return [2 /*return*/, silentCacheClient.acquireToken(commonRequest)];
15687
+ default:
15688
+ throw ClientAuthError.createRefreshRequiredError();
15689
+ }
15690
+ return [2 /*return*/];
15691
+ });
15692
+ });
15693
+ };
15694
+ /**
15695
+ * Attempt to acquire an access token via a refresh token
15696
+ * @param commonRequest CommonSilentFlowRequest
15697
+ * @param silentRequest SilentRequest
15698
+ * @returns A promise that, when resolved, returns the access token
15699
+ */
15700
+ ClientApplication.prototype.acquireTokenByRefreshToken = function (commonRequest, silentRequest) {
15701
+ return __awaiter$1(this, void 0, void 0, function () {
15702
+ var silentRefreshClient;
15703
+ return __generator$1(this, function (_a) {
15704
+ switch (silentRequest.cacheLookupPolicy) {
15705
+ case exports.CacheLookupPolicy.Default:
15706
+ case exports.CacheLookupPolicy.AccessTokenAndRefreshToken:
15707
+ case exports.CacheLookupPolicy.RefreshToken:
15708
+ case exports.CacheLookupPolicy.RefreshTokenAndNetwork:
15709
+ silentRefreshClient = this.createSilentRefreshClient(commonRequest.correlationId);
15710
+ return [2 /*return*/, silentRefreshClient.acquireToken(commonRequest)];
15711
+ default:
15712
+ throw ClientAuthError.createRefreshRequiredError();
15713
+ }
15714
+ return [2 /*return*/];
15715
+ });
15716
+ });
15717
+ };
15718
+ /**
15719
+ * Attempt to acquire an access token via an iframe
15720
+ * @param request CommonSilentFlowRequest
15721
+ * @returns A promise that, when resolved, returns the access token
15722
+ */
15723
+ ClientApplication.prototype.acquireTokenBySilentIframe = function (request) {
15724
+ return __awaiter$1(this, void 0, void 0, function () {
15725
+ var silentIframeClient;
15726
+ return __generator$1(this, function (_a) {
15727
+ silentIframeClient = this.createSilentIframeClient(request.correlationId);
15728
+ return [2 /*return*/, silentIframeClient.acquireToken(request)];
15455
15729
  });
15456
15730
  });
15457
15731
  };
@@ -15945,7 +16219,9 @@
15945
16219
  fromCache: result.fromCache,
15946
16220
  accessTokenSize: result.accessToken.length,
15947
16221
  idTokenSize: result.idToken.length,
15948
- isNativeBroker: result.fromNativeBroker
16222
+ isNativeBroker: result.fromNativeBroker,
16223
+ cacheLookupPolicy: request.cacheLookupPolicy,
16224
+ requestId: result.requestId
15949
16225
  });
15950
16226
  atsMeasurement.flushMeasurement();
15951
16227
  return result;
@@ -15953,6 +16229,8 @@
15953
16229
  .catch(function (error) {
15954
16230
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15955
16231
  atsMeasurement.endMeasurement({
16232
+ errorCode: error.errorCode,
16233
+ subErrorCode: error.subError,
15956
16234
  success: false
15957
16235
  });
15958
16236
  atsMeasurement.flushMeasurement();
@@ -15981,7 +16259,7 @@
15981
16259
  */
15982
16260
  PublicClientApplication.prototype.acquireTokenSilentAsync = function (request, account) {
15983
16261
  return __awaiter$1(this, void 0, void 0, function () {
15984
- var astsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1;
16262
+ var astsAsyncMeasurement, result, silentRequest, silentCacheClient, silentRequest_1, requestWithCLP_1;
15985
16263
  var _this = this;
15986
16264
  return __generator$1(this, function (_a) {
15987
16265
  switch (_a.label) {
@@ -16011,11 +16289,32 @@
16011
16289
  return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
16012
16290
  case 2:
16013
16291
  silentRequest_1 = _a.sent();
16014
- result = silentCacheClient.acquireToken(silentRequest_1).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
16015
- return __generator$1(this, function (_a) {
16016
- return [2 /*return*/, this.acquireTokenByRefreshToken(silentRequest_1)];
16292
+ requestWithCLP_1 = __assign$1(__assign$1({}, request), {
16293
+ // set the request's CacheLookupPolicy to Default if it was not optionally passed in
16294
+ cacheLookupPolicy: request.cacheLookupPolicy || exports.CacheLookupPolicy.Default });
16295
+ result = this.acquireTokenFromCache(silentCacheClient, silentRequest_1, requestWithCLP_1).catch(function (cacheError) {
16296
+ if (requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessToken) {
16297
+ throw cacheError;
16298
+ }
16299
+ // block the reload if it occurred inside a hidden iframe
16300
+ BrowserUtils.blockReloadInHiddenIframes();
16301
+ _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_NETWORK_START, exports.InteractionType.Silent, silentRequest_1);
16302
+ return _this.acquireTokenByRefreshToken(silentRequest_1, requestWithCLP_1).catch(function (refreshTokenError) {
16303
+ var isServerError = refreshTokenError instanceof ServerError;
16304
+ var isInteractionRequiredError = refreshTokenError instanceof InteractionRequiredAuthError;
16305
+ var isInvalidGrantError = (refreshTokenError.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
16306
+ if ((!isServerError ||
16307
+ !isInvalidGrantError ||
16308
+ isInteractionRequiredError ||
16309
+ requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.AccessTokenAndRefreshToken ||
16310
+ requestWithCLP_1.cacheLookupPolicy === exports.CacheLookupPolicy.RefreshToken)
16311
+ && (requestWithCLP_1.cacheLookupPolicy !== exports.CacheLookupPolicy.Skip)) {
16312
+ throw refreshTokenError;
16313
+ }
16314
+ _this.logger.verbose("Refresh token expired/invalid or CacheLookupPolicy is set to Skip, attempting acquire token by iframe.", request.correlationId);
16315
+ return _this.acquireTokenBySilentIframe(silentRequest_1);
16017
16316
  });
16018
- }); });
16317
+ });
16019
16318
  _a.label = 3;
16020
16319
  case 3: return [2 /*return*/, result.then(function (response) {
16021
16320
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
@@ -16024,7 +16323,8 @@
16024
16323
  fromCache: response.fromCache,
16025
16324
  accessTokenSize: response.accessToken.length,
16026
16325
  idTokenSize: response.idToken.length,
16027
- isNativeBroker: response.fromNativeBroker
16326
+ isNativeBroker: response.fromNativeBroker,
16327
+ requestId: response.requestId
16028
16328
  });
16029
16329
  return response;
16030
16330
  }).catch(function (tokenRenewalError) {