@azure/msal-browser 2.25.0 → 2.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +12 -7
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +77 -24
  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 +11 -3
  10. package/dist/app/PublicClientApplication.js.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  12. package/dist/broker/nativeBroker/NativeResponse.d.ts +26 -1
  13. package/dist/broker/nativeBroker/NativeResponse.d.ts.map +1 -1
  14. package/dist/cache/AsyncMemoryStorage.js +1 -1
  15. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  16. package/dist/cache/BrowserCacheManager.js +40 -9
  17. package/dist/cache/BrowserCacheManager.js.map +1 -1
  18. package/dist/cache/BrowserStorage.js +1 -1
  19. package/dist/cache/DatabaseStorage.js +1 -1
  20. package/dist/cache/MemoryStorage.js +1 -1
  21. package/dist/cache/TokenCache.d.ts.map +1 -1
  22. package/dist/cache/TokenCache.js +4 -3
  23. package/dist/cache/TokenCache.js.map +1 -1
  24. package/dist/config/Configuration.d.ts +4 -0
  25. package/dist/config/Configuration.d.ts.map +1 -1
  26. package/dist/config/Configuration.js +2 -1
  27. package/dist/config/Configuration.js.map +1 -1
  28. package/dist/crypto/BrowserCrypto.js +1 -1
  29. package/dist/crypto/CryptoOps.js +1 -1
  30. package/dist/crypto/GuidGenerator.js +1 -1
  31. package/dist/crypto/PkceGenerator.js +1 -1
  32. package/dist/crypto/SignedHttpRequest.js +1 -1
  33. package/dist/encode/Base64Decode.js +1 -1
  34. package/dist/encode/Base64Encode.js +1 -1
  35. package/dist/error/BrowserAuthError.d.ts +1 -1
  36. package/dist/error/BrowserAuthError.js +3 -3
  37. package/dist/error/BrowserAuthError.js.map +1 -1
  38. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  39. package/dist/error/NativeAuthError.d.ts +11 -1
  40. package/dist/error/NativeAuthError.d.ts.map +1 -1
  41. package/dist/error/NativeAuthError.js +15 -1
  42. package/dist/error/NativeAuthError.js.map +1 -1
  43. package/dist/event/EventHandler.js +1 -1
  44. package/dist/event/EventMessage.js +1 -1
  45. package/dist/event/EventType.js +1 -1
  46. package/dist/index.cjs.js +698 -306
  47. package/dist/index.cjs.js.map +1 -1
  48. package/dist/index.js +1 -1
  49. package/dist/interaction_client/BaseInteractionClient.js +1 -1
  50. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  51. package/dist/interaction_client/NativeInteractionClient.d.ts +30 -1
  52. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  53. package/dist/interaction_client/NativeInteractionClient.js +151 -30
  54. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  55. package/dist/interaction_client/PopupClient.d.ts +2 -1
  56. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  57. package/dist/interaction_client/PopupClient.js +4 -3
  58. package/dist/interaction_client/PopupClient.js.map +1 -1
  59. package/dist/interaction_client/RedirectClient.d.ts +8 -1
  60. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  61. package/dist/interaction_client/RedirectClient.js +6 -4
  62. package/dist/interaction_client/RedirectClient.js.map +1 -1
  63. package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
  64. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  65. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  66. package/dist/interaction_client/SilentCacheClient.js +4 -2
  67. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  68. package/dist/interaction_client/SilentIframeClient.d.ts +2 -1
  69. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  70. package/dist/interaction_client/SilentIframeClient.js +6 -3
  71. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  72. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  73. package/dist/interaction_client/SilentRefreshClient.js +3 -1
  74. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  75. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  76. package/dist/interaction_client/StandardInteractionClient.js +4 -1
  77. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  78. package/dist/interaction_handler/InteractionHandler.js +1 -1
  79. package/dist/interaction_handler/RedirectHandler.js +1 -1
  80. package/dist/interaction_handler/SilentHandler.js +1 -1
  81. package/dist/internals.js +1 -1
  82. package/dist/navigation/NavigationClient.js +1 -1
  83. package/dist/network/FetchClient.js +1 -1
  84. package/dist/network/XhrClient.js +1 -1
  85. package/dist/packageMetadata.d.ts +1 -1
  86. package/dist/packageMetadata.js +2 -2
  87. package/dist/packageMetadata.js.map +1 -1
  88. package/dist/telemetry/BrowserPerformanceClient.js +1 -1
  89. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  90. package/dist/utils/BrowserConstants.d.ts +1 -0
  91. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  92. package/dist/utils/BrowserConstants.js +3 -2
  93. package/dist/utils/BrowserConstants.js.map +1 -1
  94. package/dist/utils/BrowserProtocolUtils.js +1 -1
  95. package/dist/utils/BrowserStringUtils.js +1 -1
  96. package/dist/utils/BrowserUtils.js +1 -1
  97. package/dist/utils/MathUtils.js +1 -1
  98. package/lib/msal-browser.js +698 -306
  99. package/lib/msal-browser.js.map +1 -1
  100. package/lib/msal-browser.min.js +42 -40
  101. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.25.0 2022-06-06 */
1
+ /*! @azure/msal-browser v2.28.0 2022-07-18 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -107,7 +107,7 @@
107
107
  return ar;
108
108
  }
109
109
 
110
- /*! @azure/msal-common v6.4.0 2022-06-06 */
110
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
111
111
  /*! *****************************************************************************
112
112
  Copyright (c) Microsoft Corporation.
113
113
 
@@ -194,7 +194,7 @@
194
194
  return r;
195
195
  }
196
196
 
197
- /*! @azure/msal-common v6.4.0 2022-06-06 */
197
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -244,7 +244,8 @@
244
244
  REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
245
245
  KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
246
246
  TOKEN_RESPONSE_TYPE: "token",
247
- ID_TOKEN_RESPONSE_TYPE: "id_token"
247
+ ID_TOKEN_RESPONSE_TYPE: "id_token",
248
+ SHR_NONCE_VALIDITY: 240,
248
249
  };
249
250
  var OIDC_DEFAULT_SCOPES = [
250
251
  Constants.OPENID_SCOPE,
@@ -276,6 +277,7 @@
276
277
  PersistentCacheKeys["ERROR"] = "error";
277
278
  PersistentCacheKeys["ERROR_DESC"] = "error.description";
278
279
  PersistentCacheKeys["ACTIVE_ACCOUNT"] = "active-account";
280
+ PersistentCacheKeys["ACTIVE_ACCOUNT_FILTERS"] = "active-account-filters"; // new cache entry for active_account for a more robust version for browser
279
281
  })(PersistentCacheKeys || (PersistentCacheKeys = {}));
280
282
  /**
281
283
  * String constants related to AAD Authority
@@ -478,6 +480,7 @@
478
480
  AuthorityMetadataSource["CONFIG"] = "config";
479
481
  AuthorityMetadataSource["CACHE"] = "cache";
480
482
  AuthorityMetadataSource["NETWORK"] = "network";
483
+ AuthorityMetadataSource["HARDCODED_VALUES"] = "hardcoded_values";
481
484
  })(AuthorityMetadataSource || (AuthorityMetadataSource = {}));
482
485
  var SERVER_TELEM_CONSTANTS = {
483
486
  SCHEMA_VERSION: 5,
@@ -568,7 +571,7 @@
568
571
  JsonTypes["Jwk"] = "JWK";
569
572
  })(JsonTypes || (JsonTypes = {}));
570
573
 
571
- /*! @azure/msal-common v6.4.0 2022-06-06 */
574
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
572
575
 
573
576
  /*
574
577
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -612,7 +615,7 @@
612
615
  return AuthError;
613
616
  }(Error));
614
617
 
615
- /*! @azure/msal-common v6.4.0 2022-06-06 */
618
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
616
619
 
617
620
  /*
618
621
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -687,7 +690,7 @@
687
690
  }
688
691
  };
689
692
 
690
- /*! @azure/msal-common v6.4.0 2022-06-06 */
693
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
691
694
 
692
695
  /*
693
696
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1159,7 +1162,7 @@
1159
1162
  return ClientAuthError;
1160
1163
  }(AuthError));
1161
1164
 
1162
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1165
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1163
1166
 
1164
1167
  /*
1165
1168
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1284,7 +1287,7 @@
1284
1287
  return StringUtils;
1285
1288
  }());
1286
1289
 
1287
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1290
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1288
1291
 
1289
1292
  /*
1290
1293
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1464,12 +1467,12 @@
1464
1467
  return Logger;
1465
1468
  }());
1466
1469
 
1467
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1470
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1468
1471
  /* eslint-disable header/header */
1469
1472
  var name$1 = "@azure/msal-common";
1470
- var version$1 = "6.4.0";
1473
+ var version$1 = "7.2.0";
1471
1474
 
1472
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1475
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1473
1476
  /*
1474
1477
  * Copyright (c) Microsoft Corporation. All rights reserved.
1475
1478
  * Licensed under the MIT License.
@@ -1490,7 +1493,7 @@
1490
1493
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1491
1494
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1492
1495
 
1493
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1496
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1494
1497
 
1495
1498
  /*
1496
1499
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1513,9 +1516,9 @@
1513
1516
  * familyId: Family ID identifier, usually only used for refresh tokens
1514
1517
  * realm: Full tenant or organizational identifier that the account belongs to
1515
1518
  * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
1516
- * oboAssertion: access token passed in as part of OBO request
1517
1519
  * tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
1518
1520
  * requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
1521
+ * userAssertionHash: Matches the SHA 256 hash of the obo_assertion for the OBO flow
1519
1522
  * }
1520
1523
  */
1521
1524
  var CredentialEntity = /** @class */ (function () {
@@ -1649,7 +1652,7 @@
1649
1652
  return CredentialEntity;
1650
1653
  }());
1651
1654
 
1652
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1655
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1653
1656
 
1654
1657
  /*
1655
1658
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1904,7 +1907,7 @@
1904
1907
  return ClientConfigurationError;
1905
1908
  }(ClientAuthError));
1906
1909
 
1907
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1910
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1908
1911
 
1909
1912
  /*
1910
1913
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2088,7 +2091,7 @@
2088
2091
  return ScopeSet;
2089
2092
  }());
2090
2093
 
2091
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2094
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2092
2095
 
2093
2096
  /*
2094
2097
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2126,7 +2129,7 @@
2126
2129
  };
2127
2130
  }
2128
2131
 
2129
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2132
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2130
2133
  /*
2131
2134
  * Copyright (c) Microsoft Corporation. All rights reserved.
2132
2135
  * Licensed under the MIT License.
@@ -2140,7 +2143,7 @@
2140
2143
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2141
2144
  })(AuthorityType || (AuthorityType = {}));
2142
2145
 
2143
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2146
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2144
2147
 
2145
2148
  /*
2146
2149
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2165,7 +2168,6 @@
2165
2168
  * clientInfo: Full base64 encoded client info received from ESTS
2166
2169
  * lastModificationTime: last time this entity was modified in the cache
2167
2170
  * lastModificationApp:
2168
- * oboAssertion: access token passed in as part of OBO request
2169
2171
  * idTokenClaims: Object containing claims parsed from ID token
2170
2172
  * nativeAccountId: Account identifier on the native device
2171
2173
  * }
@@ -2244,7 +2246,7 @@
2244
2246
  * @param idToken
2245
2247
  * @param policy
2246
2248
  */
2247
- AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
2249
+ AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
2248
2250
  var _a, _b, _c, _d, _e, _f;
2249
2251
  var account = new AccountEntity();
2250
2252
  account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
@@ -2258,7 +2260,6 @@
2258
2260
  account.environment = env;
2259
2261
  // non AAD scenarios can have empty realm
2260
2262
  account.realm = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.tid) || Constants.EMPTY_STRING;
2261
- account.oboAssertion = oboAssertion;
2262
2263
  if (idToken) {
2263
2264
  account.idTokenClaims = idToken.claims;
2264
2265
  // How do you account for MSA CID here?
@@ -2279,14 +2280,13 @@
2279
2280
  * @param authority
2280
2281
  * @param idToken
2281
2282
  */
2282
- AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment) {
2283
+ AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment) {
2283
2284
  var _a, _b, _c, _d;
2284
2285
  var account = new AccountEntity();
2285
2286
  account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
2286
2287
  account.homeAccountId = homeAccountId;
2287
2288
  // non AAD scenarios can have empty realm
2288
2289
  account.realm = Constants.EMPTY_STRING;
2289
- account.oboAssertion = oboAssertion;
2290
2290
  var env = environment || authority && authority.getPreferredCache();
2291
2291
  if (!env) {
2292
2292
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -2378,7 +2378,7 @@
2378
2378
  return AccountEntity;
2379
2379
  }());
2380
2380
 
2381
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2381
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2382
2382
 
2383
2383
  /*
2384
2384
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2416,7 +2416,7 @@
2416
2416
  return AuthToken;
2417
2417
  }());
2418
2418
 
2419
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2419
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2420
2420
 
2421
2421
  /*
2422
2422
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2538,7 +2538,7 @@
2538
2538
  * @param realm
2539
2539
  */
2540
2540
  CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
2541
- return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING);
2541
+ return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING, accountFilter ? accountFilter.nativeAccountId : Constants.EMPTY_STRING);
2542
2542
  };
2543
2543
  /**
2544
2544
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -2547,7 +2547,7 @@
2547
2547
  * @param environment
2548
2548
  * @param realm
2549
2549
  */
2550
- CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm) {
2550
+ CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
2551
2551
  var _this = this;
2552
2552
  var allCacheKeys = this.getKeys();
2553
2553
  var matchingAccounts = {};
@@ -2565,6 +2565,9 @@
2565
2565
  if (!!realm && !_this.matchRealm(entity, realm)) {
2566
2566
  return;
2567
2567
  }
2568
+ if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
2569
+ return;
2570
+ }
2568
2571
  matchingAccounts[cacheKey] = entity;
2569
2572
  });
2570
2573
  return matchingAccounts;
@@ -2579,7 +2582,7 @@
2579
2582
  * @param target
2580
2583
  */
2581
2584
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
2582
- return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType, filter.keyId, filter.requestedClaimsHash);
2585
+ return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.userAssertionHash, filter.tokenType, filter.keyId, filter.requestedClaimsHash);
2583
2586
  };
2584
2587
  /**
2585
2588
  * Support function to help match credentials
@@ -2589,10 +2592,10 @@
2589
2592
  * @param clientId
2590
2593
  * @param realm
2591
2594
  * @param target
2592
- * @param oboAssertion
2595
+ * @param userAssertionHash
2593
2596
  * @param tokenType
2594
2597
  */
2595
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId, requestedClaimsHash) {
2598
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, userAssertionHash, tokenType, keyId, requestedClaimsHash) {
2596
2599
  var _this = this;
2597
2600
  var allCacheKeys = this.getKeys();
2598
2601
  var matchingCredentials = {
@@ -2611,7 +2614,7 @@
2611
2614
  if (!entity) {
2612
2615
  return;
2613
2616
  }
2614
- if (!!oboAssertion && !_this.matchOboAssertion(entity, oboAssertion)) {
2617
+ if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
2615
2618
  return;
2616
2619
  }
2617
2620
  if (!!homeAccountId && !_this.matchHomeAccountId(entity, homeAccountId)) {
@@ -2893,6 +2896,26 @@
2893
2896
  var accountKey = AccountEntity.generateAccountCacheKey(account);
2894
2897
  return this.getAccount(accountKey);
2895
2898
  };
2899
+ /**
2900
+ * Retrieve AccountEntity from cache
2901
+ * @param nativeAccountId
2902
+ * @returns AccountEntity or Null
2903
+ */
2904
+ CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
2905
+ // fetch account from memory
2906
+ var accountFilter = {
2907
+ nativeAccountId: nativeAccountId
2908
+ };
2909
+ var accountCache = this.getAccountsFilteredBy(accountFilter);
2910
+ var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
2911
+ if (accounts.length < 1) {
2912
+ return null;
2913
+ }
2914
+ else if (accounts.length > 1) {
2915
+ throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
2916
+ }
2917
+ return accountCache[0];
2918
+ };
2896
2919
  /**
2897
2920
  * Retrieve IdTokenEntity from cache
2898
2921
  * @param clientId
@@ -2942,7 +2965,7 @@
2942
2965
  target: scopes.printScopesLowerCase(),
2943
2966
  tokenType: authScheme,
2944
2967
  keyId: request.sshKid,
2945
- requestedClaimsHash: request.requestedClaimsHash
2968
+ requestedClaimsHash: request.requestedClaimsHash,
2946
2969
  };
2947
2970
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
2948
2971
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -2968,7 +2991,7 @@
2968
2991
  environment: account.environment,
2969
2992
  credentialType: CredentialType.REFRESH_TOKEN,
2970
2993
  clientId: clientId,
2971
- familyId: id
2994
+ familyId: id,
2972
2995
  };
2973
2996
  var credentialCache = this.getCredentialsFilteredBy(refreshTokenFilter);
2974
2997
  var refreshTokens = Object.keys(credentialCache.refreshTokens).map(function (key) { return credentialCache.refreshTokens[key]; });
@@ -3020,8 +3043,8 @@
3020
3043
  * @param value
3021
3044
  * @param oboAssertion
3022
3045
  */
3023
- CacheManager.prototype.matchOboAssertion = function (entity, oboAssertion) {
3024
- return !!(entity.oboAssertion && oboAssertion === entity.oboAssertion);
3046
+ CacheManager.prototype.matchUserAssertionHash = function (entity, userAssertionHash) {
3047
+ return !!(entity.userAssertionHash && userAssertionHash === entity.userAssertionHash);
3025
3048
  };
3026
3049
  /**
3027
3050
  * helper to match environment
@@ -3067,6 +3090,15 @@
3067
3090
  CacheManager.prototype.matchRealm = function (entity, realm) {
3068
3091
  return !!(entity.realm && realm === entity.realm);
3069
3092
  };
3093
+ /**
3094
+ * helper to match nativeAccountId
3095
+ * @param entity
3096
+ * @param nativeAccountId
3097
+ * @returns boolean indicating the match result
3098
+ */
3099
+ CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
3100
+ return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
3101
+ };
3070
3102
  /**
3071
3103
  * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
3072
3104
  * @param entity
@@ -3258,7 +3290,7 @@
3258
3290
  return DefaultStorageClass;
3259
3291
  }(CacheManager));
3260
3292
 
3261
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3293
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3262
3294
 
3263
3295
  /*
3264
3296
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3341,7 +3373,7 @@
3341
3373
  telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
3342
3374
  serverTelemetryManager: serverTelemetryManager || null,
3343
3375
  persistencePlugin: persistencePlugin || null,
3344
- serializableCache: serializableCache || null
3376
+ serializableCache: serializableCache || null,
3345
3377
  };
3346
3378
  }
3347
3379
  /**
@@ -3349,10 +3381,10 @@
3349
3381
  * @param authOptions
3350
3382
  */
3351
3383
  function buildAuthOptions(authOptions) {
3352
- return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3384
+ return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3353
3385
  }
3354
3386
 
3355
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3387
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3356
3388
 
3357
3389
  /*
3358
3390
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3372,7 +3404,7 @@
3372
3404
  return ServerError;
3373
3405
  }(AuthError));
3374
3406
 
3375
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3407
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3376
3408
 
3377
3409
  /*
3378
3410
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3468,7 +3500,7 @@
3468
3500
  return ThrottlingUtils;
3469
3501
  }());
3470
3502
 
3471
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3503
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3472
3504
 
3473
3505
  /*
3474
3506
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3517,7 +3549,7 @@
3517
3549
  return NetworkManager;
3518
3550
  }());
3519
3551
 
3520
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3552
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3521
3553
  /*
3522
3554
  * Copyright (c) Microsoft Corporation. All rights reserved.
3523
3555
  * Licensed under the MIT License.
@@ -3528,7 +3560,7 @@
3528
3560
  CcsCredentialType["UPN"] = "UPN";
3529
3561
  })(CcsCredentialType || (CcsCredentialType = {}));
3530
3562
 
3531
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3563
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3532
3564
 
3533
3565
  /*
3534
3566
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3617,7 +3649,7 @@
3617
3649
  return BaseClient;
3618
3650
  }());
3619
3651
 
3620
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3652
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3621
3653
 
3622
3654
  /*
3623
3655
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3703,7 +3735,7 @@
3703
3735
  return RequestValidator;
3704
3736
  }());
3705
3737
 
3706
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3738
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3707
3739
 
3708
3740
  /*
3709
3741
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3937,14 +3969,18 @@
3937
3969
  * @param clientAssertion
3938
3970
  */
3939
3971
  RequestParameterBuilder.prototype.addClientAssertion = function (clientAssertion) {
3940
- this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
3972
+ if (!StringUtils.isEmpty(clientAssertion)) {
3973
+ this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
3974
+ }
3941
3975
  };
3942
3976
  /**
3943
3977
  * add clientAssertionType for confidential client flows
3944
3978
  * @param clientAssertionType
3945
3979
  */
3946
3980
  RequestParameterBuilder.prototype.addClientAssertionType = function (clientAssertionType) {
3947
- this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
3981
+ if (!StringUtils.isEmpty(clientAssertionType)) {
3982
+ this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
3983
+ }
3948
3984
  };
3949
3985
  /**
3950
3986
  * add OBO assertion for confidential client flows
@@ -4077,7 +4113,7 @@
4077
4113
  return RequestParameterBuilder;
4078
4114
  }());
4079
4115
 
4080
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4116
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4081
4117
 
4082
4118
  /*
4083
4119
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4112,7 +4148,7 @@
4112
4148
  * @param clientId
4113
4149
  * @param authority
4114
4150
  */
4115
- IdTokenEntity.createIdTokenEntity = function (homeAccountId, environment, idToken, clientId, tenantId, oboAssertion) {
4151
+ IdTokenEntity.createIdTokenEntity = function (homeAccountId, environment, idToken, clientId, tenantId) {
4116
4152
  var idTokenEntity = new IdTokenEntity();
4117
4153
  idTokenEntity.credentialType = CredentialType.ID_TOKEN;
4118
4154
  idTokenEntity.homeAccountId = homeAccountId;
@@ -4120,7 +4156,6 @@
4120
4156
  idTokenEntity.clientId = clientId;
4121
4157
  idTokenEntity.secret = idToken;
4122
4158
  idTokenEntity.realm = tenantId;
4123
- idTokenEntity.oboAssertion = oboAssertion;
4124
4159
  return idTokenEntity;
4125
4160
  };
4126
4161
  /**
@@ -4142,7 +4177,7 @@
4142
4177
  return IdTokenEntity;
4143
4178
  }(CredentialEntity));
4144
4179
 
4145
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4180
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4146
4181
  /*
4147
4182
  * Copyright (c) Microsoft Corporation. All rights reserved.
4148
4183
  * Licensed under the MIT License.
@@ -4192,7 +4227,7 @@
4192
4227
  return TimeUtils;
4193
4228
  }());
4194
4229
 
4195
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4230
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4196
4231
 
4197
4232
  /*
4198
4233
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4238,7 +4273,7 @@
4238
4273
  * @param expiresOn
4239
4274
  * @param extExpiresOn
4240
4275
  */
4241
- AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId, requestedClaims, requestedClaimsHash) {
4276
+ AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, userAssertionHash, keyId, requestedClaims, requestedClaimsHash) {
4242
4277
  var _a, _b;
4243
4278
  var atEntity = new AccessTokenEntity();
4244
4279
  atEntity.homeAccountId = homeAccountId;
@@ -4259,7 +4294,7 @@
4259
4294
  atEntity.clientId = clientId;
4260
4295
  atEntity.realm = tenantId;
4261
4296
  atEntity.target = scopes;
4262
- atEntity.oboAssertion = oboAssertion;
4297
+ atEntity.userAssertionHash = userAssertionHash;
4263
4298
  atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
4264
4299
  if (requestedClaims) {
4265
4300
  atEntity.requestedClaims = requestedClaims;
@@ -4306,7 +4341,7 @@
4306
4341
  return AccessTokenEntity;
4307
4342
  }(CredentialEntity));
4308
4343
 
4309
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4344
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4310
4345
 
4311
4346
  /*
4312
4347
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4343,14 +4378,14 @@
4343
4378
  * @param clientId
4344
4379
  * @param authority
4345
4380
  */
4346
- RefreshTokenEntity.createRefreshTokenEntity = function (homeAccountId, environment, refreshToken, clientId, familyId, oboAssertion) {
4381
+ RefreshTokenEntity.createRefreshTokenEntity = function (homeAccountId, environment, refreshToken, clientId, familyId, userAssertionHash) {
4347
4382
  var rtEntity = new RefreshTokenEntity();
4348
4383
  rtEntity.clientId = clientId;
4349
4384
  rtEntity.credentialType = CredentialType.REFRESH_TOKEN;
4350
4385
  rtEntity.environment = environment;
4351
4386
  rtEntity.homeAccountId = homeAccountId;
4352
4387
  rtEntity.secret = refreshToken;
4353
- rtEntity.oboAssertion = oboAssertion;
4388
+ rtEntity.userAssertionHash = userAssertionHash;
4354
4389
  if (familyId)
4355
4390
  rtEntity.familyId = familyId;
4356
4391
  return rtEntity;
@@ -4373,7 +4408,7 @@
4373
4408
  return RefreshTokenEntity;
4374
4409
  }(CredentialEntity));
4375
4410
 
4376
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4411
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4377
4412
 
4378
4413
  /*
4379
4414
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4401,6 +4436,10 @@
4401
4436
  noTokensFoundError: {
4402
4437
  code: "no_tokens_found",
4403
4438
  desc: "No refresh token found in the cache. Please sign-in."
4439
+ },
4440
+ native_account_unavailable: {
4441
+ code: "native_account_unavailable",
4442
+ desc: "The requested account is not available in the native broker. It may have been deleted or logged out. Please sign-in again using an interactive API."
4404
4443
  }
4405
4444
  };
4406
4445
  /**
@@ -4434,10 +4473,17 @@
4434
4473
  InteractionRequiredAuthError.createNoTokensFoundError = function () {
4435
4474
  return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);
4436
4475
  };
4476
+ /**
4477
+ * Creates an error thrown when the native broker returns ACCOUNT_UNAVAILABLE status, indicating that the account was removed and interactive sign-in is required
4478
+ * @returns
4479
+ */
4480
+ InteractionRequiredAuthError.createNativeAccountUnavailableError = function () {
4481
+ return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.native_account_unavailable.code, InteractionRequiredAuthErrorMessage.native_account_unavailable.desc);
4482
+ };
4437
4483
  return InteractionRequiredAuthError;
4438
4484
  }(AuthError));
4439
4485
 
4440
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4486
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4441
4487
  /*
4442
4488
  * Copyright (c) Microsoft Corporation. All rights reserved.
4443
4489
  * Licensed under the MIT License.
@@ -4453,7 +4499,7 @@
4453
4499
  return CacheRecord;
4454
4500
  }());
4455
4501
 
4456
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4502
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4457
4503
 
4458
4504
  /*
4459
4505
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4524,7 +4570,7 @@
4524
4570
  return ProtocolUtils;
4525
4571
  }());
4526
4572
 
4527
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4573
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4528
4574
 
4529
4575
  /*
4530
4576
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4725,7 +4771,7 @@
4725
4771
  return UrlString;
4726
4772
  }());
4727
4773
 
4728
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4774
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4729
4775
 
4730
4776
  /*
4731
4777
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4826,7 +4872,7 @@
4826
4872
  return PopTokenGenerator;
4827
4873
  }());
4828
4874
 
4829
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4875
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4830
4876
 
4831
4877
  /*
4832
4878
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4896,7 +4942,7 @@
4896
4942
  return AppMetadataEntity;
4897
4943
  }());
4898
4944
 
4899
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4945
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4900
4946
  /*
4901
4947
  * Copyright (c) Microsoft Corporation. All rights reserved.
4902
4948
  * Licensed under the MIT License.
@@ -4932,7 +4978,7 @@
4932
4978
  return TokenCacheContext;
4933
4979
  }());
4934
4980
 
4935
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4981
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4936
4982
 
4937
4983
  /*
4938
4984
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4993,7 +5039,7 @@
4993
5039
  * @param serverTokenResponse
4994
5040
  * @param authority
4995
5041
  */
4996
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, oboAssertion, handlingRefreshTokenResponse) {
5042
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
4997
5043
  return __awaiter(this, void 0, void 0, function () {
4998
5044
  var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
4999
5045
  return __generator(this, function (_a) {
@@ -5015,7 +5061,7 @@
5015
5061
  }
5016
5062
  // Add keyId from request to serverTokenResponse if defined
5017
5063
  serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
5018
- cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload);
5064
+ cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload);
5019
5065
  _a.label = 1;
5020
5066
  case 1:
5021
5067
  _a.trys.push([1, , 5, 8]);
@@ -5030,14 +5076,15 @@
5030
5076
  /*
5031
5077
  * When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
5032
5078
  * If not present, we should return null, as it's the case that another application called removeAccount in between
5033
- * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal.
5079
+ * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal, unless explicitly flagged by
5080
+ * the developer, as in the case of refresh token flow used in ADAL Node to MSAL Node migration.
5034
5081
  */
5035
- if (handlingRefreshTokenResponse && cacheRecord.account) {
5082
+ if (handlingRefreshTokenResponse && !forceCacheRefreshTokenResponse && cacheRecord.account) {
5036
5083
  key = cacheRecord.account.generateAccountKey();
5037
5084
  account = this.cacheStorage.getAccount(key);
5038
5085
  if (!account) {
5039
5086
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
5040
- return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
5087
+ return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
5041
5088
  }
5042
5089
  }
5043
5090
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
@@ -5063,7 +5110,7 @@
5063
5110
  * @param idTokenObj
5064
5111
  * @param authority
5065
5112
  */
5066
- ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload) {
5113
+ ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload) {
5067
5114
  var env = authority.getPreferredCache();
5068
5115
  if (StringUtils.isEmpty(env)) {
5069
5116
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -5072,8 +5119,8 @@
5072
5119
  var cachedIdToken;
5073
5120
  var cachedAccount;
5074
5121
  if (!StringUtils.isEmpty(serverTokenResponse.id_token) && !!idTokenObj) {
5075
- cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING, oboAssertion);
5076
- cachedAccount = this.generateAccountEntity(serverTokenResponse, idTokenObj, authority, oboAssertion, authCodePayload);
5122
+ cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
5123
+ cachedAccount = this.generateAccountEntity(serverTokenResponse, idTokenObj, authority, authCodePayload);
5077
5124
  }
5078
5125
  // AccessToken
5079
5126
  var cachedAccessToken = null;
@@ -5091,12 +5138,12 @@
5091
5138
  var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
5092
5139
  var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
5093
5140
  // non AAD scenarios can have empty realm
5094
- cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, oboAssertion, serverTokenResponse.key_id, request.claims, request.requestedClaimsHash);
5141
+ cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, userAssertionHash, serverTokenResponse.key_id, request.claims, request.requestedClaimsHash);
5095
5142
  }
5096
5143
  // refreshToken
5097
5144
  var cachedRefreshToken = null;
5098
5145
  if (!StringUtils.isEmpty(serverTokenResponse.refresh_token)) {
5099
- cachedRefreshToken = RefreshTokenEntity.createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token || Constants.EMPTY_STRING, this.clientId, serverTokenResponse.foci, oboAssertion);
5146
+ cachedRefreshToken = RefreshTokenEntity.createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token || Constants.EMPTY_STRING, this.clientId, serverTokenResponse.foci, userAssertionHash);
5100
5147
  }
5101
5148
  // appMetadata
5102
5149
  var cachedAppMetadata = null;
@@ -5111,22 +5158,22 @@
5111
5158
  * @param idToken
5112
5159
  * @param authority
5113
5160
  */
5114
- ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, oboAssertion, authCodePayload) {
5161
+ ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, authCodePayload) {
5115
5162
  var authorityType = authority.authorityType;
5116
5163
  var cloudGraphHostName = authCodePayload ? authCodePayload.cloud_graph_host_name : Constants.EMPTY_STRING;
5117
5164
  var msGraphhost = authCodePayload ? authCodePayload.msgraph_host : Constants.EMPTY_STRING;
5118
5165
  // ADFS does not require client_info in the response
5119
5166
  if (authorityType === AuthorityType.Adfs) {
5120
5167
  this.logger.verbose("Authority type is ADFS, creating ADFS account");
5121
- return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost);
5168
+ return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
5122
5169
  }
5123
5170
  // This fallback applies to B2C as well as they fall under an AAD account type.
5124
5171
  if (StringUtils.isEmpty(serverTokenResponse.client_info) && authority.protocolMode === "AAD") {
5125
5172
  throw ClientAuthError.createClientInfoEmptyError();
5126
5173
  }
5127
5174
  return serverTokenResponse.client_info ?
5128
- AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost) :
5129
- AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost);
5175
+ AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost) :
5176
+ AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
5130
5177
  };
5131
5178
  /**
5132
5179
  * Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
@@ -5202,7 +5249,7 @@
5202
5249
  return ResponseHandler;
5203
5250
  }());
5204
5251
 
5205
- /*! @azure/msal-common v6.4.0 2022-06-06 */
5252
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5206
5253
 
5207
5254
  /*
5208
5255
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5303,7 +5350,7 @@
5303
5350
  throw ClientConfigurationError.createEmptyLogoutRequestError();
5304
5351
  }
5305
5352
  var queryString = this.createLogoutUrlQueryString(logoutRequest);
5306
- // Construct logout URI.
5353
+ // Construct logout URI
5307
5354
  return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);
5308
5355
  };
5309
5356
  /**
@@ -5406,8 +5453,8 @@
5406
5453
  if (this.config.clientCredentials.clientSecret) {
5407
5454
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
5408
5455
  }
5409
- clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
5410
- if (clientAssertion) {
5456
+ if (this.config.clientCredentials.clientAssertion) {
5457
+ clientAssertion = this.config.clientCredentials.clientAssertion;
5411
5458
  parameterBuilder.addClientAssertion(clientAssertion.assertion);
5412
5459
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
5413
5460
  }
@@ -5637,7 +5684,7 @@
5637
5684
  return AuthorizationCodeClient;
5638
5685
  }(BaseClient));
5639
5686
 
5640
- /*! @azure/msal-common v6.4.0 2022-06-06 */
5687
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5641
5688
 
5642
5689
  /*
5643
5690
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5663,7 +5710,7 @@
5663
5710
  response = _a.sent();
5664
5711
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5665
5712
  responseHandler.validateTokenResponse(response.body);
5666
- return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true)];
5713
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
5667
5714
  }
5668
5715
  });
5669
5716
  });
@@ -5799,8 +5846,8 @@
5799
5846
  if (this.config.clientCredentials.clientSecret) {
5800
5847
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
5801
5848
  }
5802
- clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
5803
- if (clientAssertion) {
5849
+ if (this.config.clientCredentials.clientAssertion) {
5850
+ clientAssertion = this.config.clientCredentials.clientAssertion;
5804
5851
  parameterBuilder.addClientAssertion(clientAssertion.assertion);
5805
5852
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
5806
5853
  }
@@ -5850,7 +5897,7 @@
5850
5897
  return RefreshTokenClient;
5851
5898
  }(BaseClient));
5852
5899
 
5853
- /*! @azure/msal-common v6.4.0 2022-06-06 */
5900
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5854
5901
 
5855
5902
  /*
5856
5903
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5966,7 +6013,7 @@
5966
6013
  return SilentFlowClient;
5967
6014
  }(BaseClient));
5968
6015
 
5969
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6016
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5970
6017
  /*
5971
6018
  * Copyright (c) Microsoft Corporation. All rights reserved.
5972
6019
  * Licensed under the MIT License.
@@ -5974,10 +6021,20 @@
5974
6021
  function isOpenIdConfigResponse(response) {
5975
6022
  return (response.hasOwnProperty("authorization_endpoint") &&
5976
6023
  response.hasOwnProperty("token_endpoint") &&
5977
- response.hasOwnProperty("issuer"));
6024
+ response.hasOwnProperty("issuer") &&
6025
+ response.hasOwnProperty("jwks_uri"));
5978
6026
  }
5979
6027
 
5980
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6028
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6029
+ /*
6030
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6031
+ * Licensed under the MIT License.
6032
+ */
6033
+ var rawMetdataJSON = { "endpointMetadata": { "https://login.microsoftonline.com/common/": { "token_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/common/": { "token_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/common/": { "token_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/common/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/common/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/common/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" }, "https://login.microsoftonline.com/consumers/": { "token_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/consumers/": { "token_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/consumers/": { "token_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/consumers/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/9188040d-6c67-4c5b-b112-36a304b66dad/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/consumers/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/consumers/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" }, "https://login.microsoftonline.com/organizations/": { "token_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.com/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.com/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.com/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.com/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.com", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pas.windows.net" }, "https://login.chinacloudapi.cn/organizations/": { "token_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.chinacloudapi.cn/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.partner.microsoftonline.cn/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://microsoftgraph.chinacloudapi.cn/oidc/userinfo", "authorization_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.chinacloudapi.cn/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.chinacloudapi.cn/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "partner.microsoftonline.cn", "cloud_graph_host_name": "graph.chinacloudapi.cn", "msgraph_host": "microsoftgraph.chinacloudapi.cn", "rbac_url": "https://pas.chinacloudapi.cn" }, "https://login.microsoftonline.us/organizations/": { "token_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/token", "token_endpoint_auth_methods_supported": ["client_secret_post", "private_key_jwt", "client_secret_basic"], "jwks_uri": "https://login.microsoftonline.us/organizations/discovery/v2.0/keys", "response_modes_supported": ["query", "fragment", "form_post"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "response_types_supported": ["code", "id_token", "code id_token", "id_token token"], "scopes_supported": ["openid", "profile", "email", "offline_access"], "issuer": "https://login.microsoftonline.us/{tenantid}/v2.0", "request_uri_parameter_supported": false, "userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo", "authorization_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/authorize", "device_authorization_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/devicecode", "http_logout_supported": true, "frontchannel_logout_supported": true, "end_session_endpoint": "https://login.microsoftonline.us/organizations/oauth2/v2.0/logout", "claims_supported": ["sub", "iss", "cloud_instance_name", "cloud_instance_host_name", "cloud_graph_host_name", "msgraph_host", "aud", "exp", "iat", "auth_time", "acr", "nonce", "preferred_username", "name", "tid", "ver", "at_hash", "c_hash", "email"], "kerberos_endpoint": "https://login.microsoftonline.us/organizations/kerberos", "tenant_region_scope": null, "cloud_instance_name": "microsoftonline.us", "cloud_graph_host_name": "graph.windows.net", "msgraph_host": "graph.microsoft.com", "rbac_url": "https://pasff.usgovcloudapi.net" } }, "instanceDiscoveryMetadata": { "https://login.microsoftonline.com/common/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/common/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/common/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/common/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.com/consumers/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/consumers/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/consumers/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/consumers/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.com/organizations/": { "tenant_discovery_endpoint": "https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.chinacloudapi.cn/organizations/": { "tenant_discovery_endpoint": "https://login.chinacloudapi.cn/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] }, "https://login.microsoftonline.us/organizations/": { "tenant_discovery_endpoint": "https://login.microsoftonline.us/organizations/v2.0/.well-known/openid-configuration", "api-version": "1.1", "metadata": [{ "preferred_network": "login.microsoftonline.com", "preferred_cache": "login.windows.net", "aliases": ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"] }, { "preferred_network": "login.partner.microsoftonline.cn", "preferred_cache": "login.partner.microsoftonline.cn", "aliases": ["login.partner.microsoftonline.cn", "login.chinacloudapi.cn"] }, { "preferred_network": "login.microsoftonline.de", "preferred_cache": "login.microsoftonline.de", "aliases": ["login.microsoftonline.de"] }, { "preferred_network": "login.microsoftonline.us", "preferred_cache": "login.microsoftonline.us", "aliases": ["login.microsoftonline.us", "login.usgovcloudapi.net"] }, { "preferred_network": "login-us.microsoftonline.com", "preferred_cache": "login-us.microsoftonline.com", "aliases": ["login-us.microsoftonline.com"] }] } } };
6034
+ var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6035
+ var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6036
+
6037
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5981
6038
  /*
5982
6039
  * Copyright (c) Microsoft Corporation. All rights reserved.
5983
6040
  * Licensed under the MIT License.
@@ -5991,7 +6048,7 @@
5991
6048
  ProtocolMode["OIDC"] = "OIDC";
5992
6049
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5993
6050
 
5994
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6051
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5995
6052
 
5996
6053
  /*
5997
6054
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6023,6 +6080,7 @@
6023
6080
  this.end_session_endpoint = metadata.end_session_endpoint;
6024
6081
  this.issuer = metadata.issuer;
6025
6082
  this.endpointsFromNetwork = fromNetwork;
6083
+ this.jwks_uri = metadata.jwks_uri;
6026
6084
  };
6027
6085
  /**
6028
6086
  * Save the authority that was used to create this cache entry
@@ -6061,12 +6119,13 @@
6061
6119
  entity.hasOwnProperty("issuer") &&
6062
6120
  entity.hasOwnProperty("aliasesFromNetwork") &&
6063
6121
  entity.hasOwnProperty("endpointsFromNetwork") &&
6064
- entity.hasOwnProperty("expiresAt"));
6122
+ entity.hasOwnProperty("expiresAt") &&
6123
+ entity.hasOwnProperty("jwks_uri"));
6065
6124
  };
6066
6125
  return AuthorityMetadataEntity;
6067
6126
  }());
6068
6127
 
6069
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6128
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6070
6129
  /*
6071
6130
  * Copyright (c) Microsoft Corporation. All rights reserved.
6072
6131
  * Licensed under the MIT License.
@@ -6076,7 +6135,7 @@
6076
6135
  response.hasOwnProperty("metadata"));
6077
6136
  }
6078
6137
 
6079
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6138
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6080
6139
 
6081
6140
  /*
6082
6141
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6198,7 +6257,7 @@
6198
6257
  return RegionDiscovery;
6199
6258
  }());
6200
6259
 
6201
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6260
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6202
6261
 
6203
6262
  /*
6204
6263
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6383,6 +6442,22 @@
6383
6442
  enumerable: false,
6384
6443
  configurable: true
6385
6444
  });
6445
+ Object.defineProperty(Authority.prototype, "jwksUri", {
6446
+ /**
6447
+ * Jwks_uri for token signing keys
6448
+ */
6449
+ get: function () {
6450
+ if (this.discoveryComplete()) {
6451
+ var endpoint = this.replacePath(this.metadata.jwks_uri);
6452
+ return this.replaceTenant(endpoint);
6453
+ }
6454
+ else {
6455
+ throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
6456
+ }
6457
+ },
6458
+ enumerable: false,
6459
+ configurable: true
6460
+ });
6386
6461
  /**
6387
6462
  * Replaces tenant in url path with current tenant. Defaults to common.
6388
6463
  * @param urlString
@@ -6466,11 +6541,11 @@
6466
6541
  * @param metadataEntity
6467
6542
  */
6468
6543
  Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
6469
- var _a;
6544
+ var _a, _b;
6470
6545
  return __awaiter(this, void 0, void 0, function () {
6471
- var metadata, autodetectedRegionName, azureRegion;
6472
- return __generator(this, function (_b) {
6473
- switch (_b.label) {
6546
+ var metadata, harcodedMetadata;
6547
+ return __generator(this, function (_c) {
6548
+ switch (_c.label) {
6474
6549
  case 0:
6475
6550
  metadata = this.getEndpointMetadataFromConfig();
6476
6551
  if (metadata) {
@@ -6481,41 +6556,30 @@
6481
6556
  // No need to update
6482
6557
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6483
6558
  }
6559
+ harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
6484
6560
  return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
6485
6561
  case 1:
6486
- metadata = _b.sent();
6562
+ metadata = _c.sent();
6487
6563
  if (!metadata) return [3 /*break*/, 4];
6488
6564
  if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
6489
- return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6565
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
6490
6566
  case 2:
6491
- autodetectedRegionName = _b.sent();
6492
- azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
6493
- ? autodetectedRegionName
6494
- : this.authorityOptions.azureRegionConfiguration.azureRegion;
6495
- if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
6496
- this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
6497
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
6498
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
6499
- }
6500
- else {
6501
- if (autodetectedRegionName) {
6502
- this.regionDiscoveryMetadata.region_outcome = (this.authorityOptions.azureRegionConfiguration.azureRegion === autodetectedRegionName) ?
6503
- RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
6504
- RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
6505
- }
6506
- else {
6507
- this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
6508
- }
6509
- }
6510
- if (azureRegion) {
6511
- this.regionDiscoveryMetadata.region_used = azureRegion;
6512
- metadata = Authority.replaceWithRegionalInformation(metadata, azureRegion);
6513
- }
6514
- _b.label = 3;
6567
+ metadata = _c.sent();
6568
+ _c.label = 3;
6515
6569
  case 3:
6516
6570
  metadataEntity.updateEndpointMetadata(metadata, true);
6517
6571
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6518
- case 4: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
6572
+ case 4:
6573
+ if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
6574
+ if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
6575
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
6576
+ case 5:
6577
+ harcodedMetadata = _c.sent();
6578
+ _c.label = 6;
6579
+ case 6:
6580
+ metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
6581
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
6582
+ case 7: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
6519
6583
  }
6520
6584
  });
6521
6585
  });
@@ -6546,6 +6610,8 @@
6546
6610
  };
6547
6611
  /**
6548
6612
  * Gets OAuth endpoints from the given OpenID configuration endpoint.
6613
+ *
6614
+ * @param hasHardcodedMetadata boolean
6549
6615
  */
6550
6616
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
6551
6617
  return __awaiter(this, void 0, void 0, function () {
@@ -6572,6 +6638,54 @@
6572
6638
  });
6573
6639
  });
6574
6640
  };
6641
+ /**
6642
+ * Get OAuth endpoints for common authorities.
6643
+ */
6644
+ Authority.prototype.getEndpointMetadataFromHardcodedValues = function () {
6645
+ if (this.canonicalAuthority in EndpointMetadata) {
6646
+ return EndpointMetadata[this.canonicalAuthority];
6647
+ }
6648
+ return null;
6649
+ };
6650
+ /**
6651
+ * Update the retrieved metadata with regional information.
6652
+ */
6653
+ Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
6654
+ var _a, _b, _c, _d, _e;
6655
+ return __awaiter(this, void 0, void 0, function () {
6656
+ var autodetectedRegionName, azureRegion;
6657
+ return __generator(this, function (_f) {
6658
+ switch (_f.label) {
6659
+ case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6660
+ case 1:
6661
+ autodetectedRegionName = _f.sent();
6662
+ azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
6663
+ ? autodetectedRegionName
6664
+ : (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
6665
+ if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
6666
+ this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
6667
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
6668
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
6669
+ }
6670
+ else {
6671
+ if (autodetectedRegionName) {
6672
+ this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
6673
+ RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
6674
+ RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
6675
+ }
6676
+ else {
6677
+ this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
6678
+ }
6679
+ }
6680
+ if (azureRegion) {
6681
+ this.regionDiscoveryMetadata.region_used = azureRegion;
6682
+ return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, azureRegion)];
6683
+ }
6684
+ return [2 /*return*/, metadata];
6685
+ }
6686
+ });
6687
+ });
6688
+ };
6575
6689
  /**
6576
6690
  * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
6577
6691
  * @param cachedMetadata
@@ -6579,7 +6693,7 @@
6579
6693
  */
6580
6694
  Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
6581
6695
  return __awaiter(this, void 0, void 0, function () {
6582
- var metadata;
6696
+ var metadata, harcodedMetadata;
6583
6697
  return __generator(this, function (_a) {
6584
6698
  switch (_a.label) {
6585
6699
  case 0:
@@ -6593,6 +6707,7 @@
6593
6707
  // No need to update
6594
6708
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6595
6709
  }
6710
+ harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
6596
6711
  return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
6597
6712
  case 1:
6598
6713
  metadata = _a.sent();
@@ -6600,6 +6715,10 @@
6600
6715
  metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
6601
6716
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6602
6717
  }
6718
+ if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
6719
+ metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
6720
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
6721
+ }
6603
6722
  else {
6604
6723
  // Metadata could not be obtained from config, cache or network
6605
6724
  throw ClientConfigurationError.createUntrustedAuthorityError();
@@ -6633,7 +6752,8 @@
6633
6752
  };
6634
6753
  /**
6635
6754
  * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
6636
- * @param networkInterface
6755
+ *
6756
+ * @param hasHardcodedMetadata boolean
6637
6757
  */
6638
6758
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
6639
6759
  return __awaiter(this, void 0, void 0, function () {
@@ -6653,7 +6773,9 @@
6653
6773
  return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
6654
6774
  case 2:
6655
6775
  response = _a.sent();
6656
- metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];
6776
+ metadata = isCloudInstanceDiscoveryResponse(response.body)
6777
+ ? response.body.metadata
6778
+ : [];
6657
6779
  if (metadata.length === 0) {
6658
6780
  // If no metadata is returned, authority is untrusted
6659
6781
  return [2 /*return*/, null];
@@ -6673,6 +6795,15 @@
6673
6795
  });
6674
6796
  });
6675
6797
  };
6798
+ /**
6799
+ * Get cloud discovery metadata for common authorities
6800
+ */
6801
+ Authority.prototype.getCloudDiscoveryMetadataFromHarcodedValues = function () {
6802
+ if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
6803
+ return InstanceDiscoveryMetadata[this.canonicalAuthority];
6804
+ }
6805
+ return null;
6806
+ };
6676
6807
  /**
6677
6808
  * Helper function to determine if this host is included in the knownAuthorities config option
6678
6809
  */
@@ -6788,7 +6919,7 @@
6788
6919
  return Authority;
6789
6920
  }());
6790
6921
 
6791
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6922
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6792
6923
 
6793
6924
  /*
6794
6925
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6849,7 +6980,7 @@
6849
6980
  return AuthorityFactory;
6850
6981
  }());
6851
6982
 
6852
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6983
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6853
6984
 
6854
6985
  /*
6855
6986
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6880,7 +7011,7 @@
6880
7011
  return ServerTelemetryEntity;
6881
7012
  }());
6882
7013
 
6883
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7014
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6884
7015
 
6885
7016
  /*
6886
7017
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6908,7 +7039,7 @@
6908
7039
  return ThrottlingEntity;
6909
7040
  }());
6910
7041
 
6911
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7042
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6912
7043
 
6913
7044
  /*
6914
7045
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6925,7 +7056,7 @@
6925
7056
  }
6926
7057
  };
6927
7058
 
6928
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7059
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6929
7060
 
6930
7061
  /*
6931
7062
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6970,7 +7101,7 @@
6970
7101
  return JoseHeaderError;
6971
7102
  }(AuthError));
6972
7103
 
6973
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7104
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6974
7105
 
6975
7106
  /*
6976
7107
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7010,7 +7141,7 @@
7010
7141
  return JoseHeader;
7011
7142
  }());
7012
7143
 
7013
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7144
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7014
7145
 
7015
7146
  /*
7016
7147
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7069,7 +7200,7 @@
7069
7200
  return AuthenticationHeaderParser;
7070
7201
  }());
7071
7202
 
7072
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7203
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7073
7204
 
7074
7205
  /*
7075
7206
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7231,7 +7362,7 @@
7231
7362
  return ServerTelemetryManager;
7232
7363
  }());
7233
7364
 
7234
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7365
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7235
7366
  /*
7236
7367
  * Copyright (c) Microsoft Corporation. All rights reserved.
7237
7368
  * Licensed under the MIT License.
@@ -7314,6 +7445,19 @@
7314
7445
  * Used to acquire a token from Native component when native brokering is enabled.
7315
7446
  */
7316
7447
  PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
7448
+ /**
7449
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
7450
+ */
7451
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
7452
+ /**
7453
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
7454
+ */
7455
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
7456
+ /**
7457
+ * acquireToken API in BrokerClientApplication.
7458
+ * Used to acquire a token on behalf of the embedded application (PW-Broker).
7459
+ */
7460
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
7317
7461
  })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
7318
7462
  /**
7319
7463
  * State of the performance event.
@@ -7328,7 +7472,7 @@
7328
7472
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7329
7473
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7330
7474
 
7331
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7475
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7332
7476
 
7333
7477
  /*
7334
7478
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7386,7 +7530,7 @@
7386
7530
  clientId: this.clientId,
7387
7531
  name: measureName,
7388
7532
  startTimeMs: Date.now(),
7389
- correlationId: eventCorrelationId
7533
+ correlationId: eventCorrelationId,
7390
7534
  };
7391
7535
  // Store in progress events so they can be discarded if not ended properly
7392
7536
  this.cacheEventByCorrelationId(inProgressEvent);
@@ -7531,6 +7675,12 @@
7531
7675
  else {
7532
7676
  _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
7533
7677
  }
7678
+ if (current.accessTokenSize) {
7679
+ previous.accessTokenSize = current.accessTokenSize;
7680
+ }
7681
+ if (current.idTokenSize) {
7682
+ previous.idTokenSize = current.idTokenSize;
7683
+ }
7534
7684
  }
7535
7685
  return previous;
7536
7686
  }, topLevelEvent);
@@ -7598,7 +7748,7 @@
7598
7748
  return PerformanceClient;
7599
7749
  }());
7600
7750
 
7601
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7751
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7602
7752
 
7603
7753
  /*
7604
7754
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7700,7 +7850,7 @@
7700
7850
  },
7701
7851
  redirectInIframeError: {
7702
7852
  code: "redirect_in_iframe",
7703
- desc: "Code flow is not supported inside an iframe. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs."
7853
+ desc: "Redirects are not supported for iframed or brokered applications. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs."
7704
7854
  },
7705
7855
  blockTokenRequestsInHiddenIframeError: {
7706
7856
  code: "block_iframe_reload",
@@ -7925,7 +8075,7 @@
7925
8075
  return new BrowserAuthError(BrowserAuthErrorMessage.monitorIframeTimeoutError.code, BrowserAuthErrorMessage.monitorIframeTimeoutError.desc);
7926
8076
  };
7927
8077
  /**
7928
- * Creates an error thrown when navigateWindow is called inside an iframe.
8078
+ * Creates an error thrown when navigateWindow is called inside an iframe or brokered applications.
7929
8079
  * @param windowParentCheck
7930
8080
  */
7931
8081
  BrowserAuthError.createRedirectInIframeError = function (windowParentCheck) {
@@ -8144,7 +8294,8 @@
8144
8294
  };
8145
8295
  var NativeConstants = {
8146
8296
  CHANNEL_ID: "53ee284d-920a-4b59-9d30-a60315b26836",
8147
- PREFERRED_EXTENSION_ID: "ppnbnpeolgkicgegkbkbjmhlideopiji"
8297
+ PREFERRED_EXTENSION_ID: "ppnbnpeolgkicgegkbkbjmhlideopiji",
8298
+ MATS_TELEMETRY: "MATS"
8148
8299
  };
8149
8300
  var NativeExtensionMethod;
8150
8301
  (function (NativeExtensionMethod) {
@@ -8817,26 +8968,57 @@
8817
8968
  * Gets the active account
8818
8969
  */
8819
8970
  BrowserCacheManager.prototype.getActiveAccount = function () {
8820
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8821
- var activeAccountId = this.browserStorage.getItem(activeAccountIdKey);
8822
- if (!activeAccountId) {
8971
+ var activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
8972
+ var activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
8973
+ if (!activeAccountValueFilters) {
8974
+ // if new active account cache type isn't found, it's an old version, so look for that instead
8975
+ this.logger.trace("No active account filters cache schema found, looking for legacy schema");
8976
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8977
+ var activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
8978
+ if (!activeAccountValueLocal) {
8979
+ this.logger.trace("No active account found");
8980
+ return null;
8981
+ }
8982
+ var activeAccount = this.getAccountInfoByFilter({ localAccountId: activeAccountValueLocal })[0] || null;
8983
+ if (activeAccount) {
8984
+ this.logger.trace("Legacy active account cache schema found");
8985
+ this.logger.trace("Adding active account filters cache schema");
8986
+ this.setActiveAccount(activeAccount);
8987
+ return activeAccount;
8988
+ }
8823
8989
  return null;
8824
8990
  }
8825
- return this.getAccountInfoByFilter({ localAccountId: activeAccountId })[0] || null;
8991
+ var activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
8992
+ if (activeAccountValueObj) {
8993
+ this.logger.trace("Active account filters schema found");
8994
+ return this.getAccountInfoByFilter({
8995
+ homeAccountId: activeAccountValueObj.homeAccountId,
8996
+ localAccountId: activeAccountValueObj.localAccountId
8997
+ })[0] || null;
8998
+ }
8999
+ this.logger.trace("No active account found");
9000
+ return null;
8826
9001
  };
8827
9002
  /**
8828
9003
  * Sets the active account's localAccountId in cache
8829
9004
  * @param account
8830
9005
  */
8831
9006
  BrowserCacheManager.prototype.setActiveAccount = function (account) {
8832
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9007
+ var activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
9008
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8833
9009
  if (account) {
8834
9010
  this.logger.verbose("setActiveAccount: Active account set");
8835
- this.browserStorage.setItem(activeAccountIdKey, account.localAccountId);
9011
+ var activeAccountValue = {
9012
+ homeAccountId: account.homeAccountId,
9013
+ localAccountId: account.localAccountId
9014
+ };
9015
+ this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
9016
+ this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
8836
9017
  }
8837
9018
  else {
8838
9019
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
8839
- this.browserStorage.removeItem(activeAccountIdKey);
9020
+ this.browserStorage.removeItem(activeAccountKey);
9021
+ this.browserStorage.removeItem(activeAccountKeyLocal);
8840
9022
  }
8841
9023
  };
8842
9024
  /**
@@ -9022,7 +9204,7 @@
9022
9204
  * @param expires
9023
9205
  */
9024
9206
  BrowserCacheManager.prototype.setItemCookie = function (cookieName, cookieValue, expires) {
9025
- var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;";
9207
+ var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;SameSite=Lax;";
9026
9208
  if (expires) {
9027
9209
  var expireTime = this.getCookieExpirationTime(expires);
9028
9210
  cookieStr += "expires=" + expireTime + ";";
@@ -9394,7 +9576,7 @@
9394
9576
 
9395
9577
  /* eslint-disable header/header */
9396
9578
  var name = "@azure/msal-browser";
9397
- var version = "2.25.0";
9579
+ var version = "2.28.0";
9398
9580
 
9399
9581
  /*
9400
9582
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10175,6 +10357,7 @@
10175
10357
  knownAuthorities: this.config.auth.knownAuthorities,
10176
10358
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10177
10359
  authorityMetadata: this.config.auth.authorityMetadata,
10360
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache
10178
10361
  };
10179
10362
  userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
10180
10363
  builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
@@ -10188,6 +10371,8 @@
10188
10371
  })
10189
10372
  .catch(function (error) {
10190
10373
  getAuthorityMeasurement.endMeasurement({
10374
+ errorCode: error.errorCode,
10375
+ subErrorCode: error.subError,
10191
10376
  success: false
10192
10377
  });
10193
10378
  throw error;
@@ -10563,6 +10748,7 @@
10563
10748
  NativeStatusCode["TRANSIENT_ERROR"] = "TRANSIENT_ERROR";
10564
10749
  NativeStatusCode["PERSISTENT_ERROR"] = "PERSISTENT_ERROR";
10565
10750
  NativeStatusCode["DISABLED"] = "DISABLED";
10751
+ NativeStatusCode["ACCOUNT_UNAVAILABLE"] = "ACCOUNT_UNAVAILABLE";
10566
10752
  })(NativeStatusCode || (NativeStatusCode = {}));
10567
10753
  var NativeAuthErrorMessage = {
10568
10754
  extensionError: {
@@ -10571,6 +10757,10 @@
10571
10757
  userSwitch: {
10572
10758
  code: "user_switch",
10573
10759
  desc: "User attempted to switch accounts in the native broker, which is not allowed. All new accounts must sign-in through the standard web flow first, please try again."
10760
+ },
10761
+ tokensNotFoundInCache: {
10762
+ code: "tokens_not_found_in_internal_memory_cache",
10763
+ desc: "Tokens not cached in MSAL JS internal memory, please make the WAM request"
10574
10764
  }
10575
10765
  };
10576
10766
  var NativeAuthError = /** @class */ (function (_super) {
@@ -10606,6 +10796,8 @@
10606
10796
  NativeAuthError.createError = function (code, description, ext) {
10607
10797
  if (ext && ext.status) {
10608
10798
  switch (ext.status) {
10799
+ case NativeStatusCode.ACCOUNT_UNAVAILABLE:
10800
+ return InteractionRequiredAuthError.createNativeAccountUnavailableError();
10609
10801
  case NativeStatusCode.USER_INTERACTION_REQUIRED:
10610
10802
  return new InteractionRequiredAuthError(code, description);
10611
10803
  case NativeStatusCode.USER_CANCEL:
@@ -10623,20 +10815,122 @@
10623
10815
  NativeAuthError.createUserSwitchError = function () {
10624
10816
  return new NativeAuthError(NativeAuthErrorMessage.userSwitch.code, NativeAuthErrorMessage.userSwitch.desc);
10625
10817
  };
10818
+ /**
10819
+ * Creates a tokens not found error when the internal cache look up fails
10820
+ * @returns NativeAuthError: tokensNotFoundInCache
10821
+ */
10822
+ NativeAuthError.createTokensNotFoundInCacheError = function () {
10823
+ return new NativeAuthError(NativeAuthErrorMessage.tokensNotFoundInCache.code, NativeAuthErrorMessage.tokensNotFoundInCache.desc);
10824
+ };
10626
10825
  return NativeAuthError;
10627
10826
  }(AuthError));
10628
10827
 
10828
+ /*
10829
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10830
+ * Licensed under the MIT License.
10831
+ */
10832
+ var SilentCacheClient = /** @class */ (function (_super) {
10833
+ __extends$1(SilentCacheClient, _super);
10834
+ function SilentCacheClient() {
10835
+ return _super !== null && _super.apply(this, arguments) || this;
10836
+ }
10837
+ /**
10838
+ * Returns unexpired tokens from the cache, if available
10839
+ * @param silentRequest
10840
+ */
10841
+ SilentCacheClient.prototype.acquireToken = function (silentRequest) {
10842
+ return __awaiter$1(this, void 0, void 0, function () {
10843
+ var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
10844
+ return __generator$1(this, function (_a) {
10845
+ switch (_a.label) {
10846
+ case 0:
10847
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
10848
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
10849
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
10850
+ case 1:
10851
+ silentAuthClient = _a.sent();
10852
+ this.logger.verbose("Silent auth client created");
10853
+ _a.label = 2;
10854
+ case 2:
10855
+ _a.trys.push([2, 4, , 5]);
10856
+ return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
10857
+ case 3:
10858
+ cachedToken = _a.sent();
10859
+ acquireTokenMeasurement.endMeasurement({
10860
+ success: true,
10861
+ fromCache: true
10862
+ });
10863
+ return [2 /*return*/, cachedToken];
10864
+ case 4:
10865
+ error_1 = _a.sent();
10866
+ if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
10867
+ this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
10868
+ }
10869
+ acquireTokenMeasurement.endMeasurement({
10870
+ errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
10871
+ subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
10872
+ success: false
10873
+ });
10874
+ throw error_1;
10875
+ case 5: return [2 /*return*/];
10876
+ }
10877
+ });
10878
+ });
10879
+ };
10880
+ /**
10881
+ * Currently Unsupported
10882
+ */
10883
+ SilentCacheClient.prototype.logout = function () {
10884
+ // Synchronous so we must reject
10885
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
10886
+ };
10887
+ /**
10888
+ * Creates an Silent Flow Client with the given authority, or the default authority.
10889
+ * @param serverTelemetryManager
10890
+ * @param authorityUrl
10891
+ */
10892
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
10893
+ return __awaiter$1(this, void 0, void 0, function () {
10894
+ var clientConfig;
10895
+ return __generator$1(this, function (_a) {
10896
+ switch (_a.label) {
10897
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
10898
+ case 1:
10899
+ clientConfig = _a.sent();
10900
+ return [2 /*return*/, new SilentFlowClient(clientConfig)];
10901
+ }
10902
+ });
10903
+ });
10904
+ };
10905
+ SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
10906
+ return __awaiter$1(this, void 0, void 0, function () {
10907
+ var _a;
10908
+ return __generator$1(this, function (_b) {
10909
+ switch (_b.label) {
10910
+ case 0:
10911
+ _a = [__assign$1({}, request)];
10912
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
10913
+ case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
10914
+ }
10915
+ });
10916
+ });
10917
+ };
10918
+ return SilentCacheClient;
10919
+ }(StandardInteractionClient));
10920
+
10629
10921
  /*
10630
10922
  * Copyright (c) Microsoft Corporation. All rights reserved.
10631
10923
  * Licensed under the MIT License.
10632
10924
  */
10633
10925
  var NativeInteractionClient = /** @class */ (function (_super) {
10634
10926
  __extends$1(NativeInteractionClient, _super);
10635
- function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, correlationId) {
10927
+ function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
10636
10928
  var _this = _super.call(this, config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId) || this;
10637
10929
  _this.apiId = apiId;
10638
10930
  _this.accountId = accountId;
10639
10931
  _this.nativeMessageHandler = provider;
10932
+ _this.nativeStorageManager = nativeStorageImpl;
10933
+ _this.silentCacheClient = new SilentCacheClient(config, _this.nativeStorageManager, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
10640
10934
  return _this;
10641
10935
  }
10642
10936
  /**
@@ -10645,22 +10939,40 @@
10645
10939
  */
10646
10940
  NativeInteractionClient.prototype.acquireToken = function (request) {
10647
10941
  return __awaiter$1(this, void 0, void 0, function () {
10648
- var nativeATMeasurement, nativeRequest, messageBody, reqTimestamp, response, validatedResponse;
10942
+ var nativeATMeasurement, reqTimestamp, nativeRequest, result, messageBody, response, validatedResponse;
10649
10943
  return __generator$1(this, function (_a) {
10650
10944
  switch (_a.label) {
10651
10945
  case 0:
10652
10946
  this.logger.trace("NativeInteractionClient - acquireToken called.");
10653
10947
  nativeATMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
10948
+ reqTimestamp = TimeUtils.nowSeconds();
10654
10949
  return [4 /*yield*/, this.initializeNativeRequest(request)];
10655
10950
  case 1:
10656
10951
  nativeRequest = _a.sent();
10952
+ _a.label = 2;
10953
+ case 2:
10954
+ _a.trys.push([2, 4, , 5]);
10955
+ return [4 /*yield*/, this.acquireTokensFromCache(this.accountId, nativeRequest)];
10956
+ case 3:
10957
+ result = _a.sent();
10958
+ nativeATMeasurement.endMeasurement({
10959
+ success: true,
10960
+ isNativeBroker: true,
10961
+ fromCache: true
10962
+ });
10963
+ return [2 /*return*/, result];
10964
+ case 4:
10965
+ _a.sent();
10966
+ // continue with a native call for any and all errors
10967
+ this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call");
10968
+ return [3 /*break*/, 5];
10969
+ case 5:
10657
10970
  messageBody = {
10658
10971
  method: NativeExtensionMethod.GetToken,
10659
10972
  request: nativeRequest
10660
10973
  };
10661
- reqTimestamp = TimeUtils.nowSeconds();
10662
10974
  return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
10663
- case 2:
10975
+ case 6:
10664
10976
  response = _a.sent();
10665
10977
  validatedResponse = this.validateNativeResponse(response);
10666
10978
  return [2 /*return*/, this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
@@ -10674,6 +10986,8 @@
10674
10986
  .catch(function (error) {
10675
10987
  nativeATMeasurement.endMeasurement({
10676
10988
  success: false,
10989
+ errorCode: error.errorCode,
10990
+ subErrorCode: error.subError,
10677
10991
  isNativeBroker: true
10678
10992
  });
10679
10993
  throw error;
@@ -10682,13 +10996,61 @@
10682
10996
  });
10683
10997
  });
10684
10998
  };
10999
+ /**
11000
+ * Creates silent flow request
11001
+ * @param request
11002
+ * @param cachedAccount
11003
+ * @returns CommonSilentFlowRequest
11004
+ */
11005
+ NativeInteractionClient.prototype.createSilentCacheRequest = function (request, cachedAccount) {
11006
+ return {
11007
+ authority: request.authority,
11008
+ correlationId: this.correlationId,
11009
+ scopes: ScopeSet.fromString(request.scopes).asArray(),
11010
+ account: cachedAccount,
11011
+ forceRefresh: false,
11012
+ };
11013
+ };
11014
+ /**
11015
+ * Fetches the tokens from the cache if un-expired
11016
+ * @param nativeAccountId
11017
+ * @param request
11018
+ * @returns authenticationResult
11019
+ */
11020
+ NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
11021
+ return __awaiter$1(this, void 0, void 0, function () {
11022
+ var accountEntity, account, silentRequest, result, e_2;
11023
+ return __generator$1(this, function (_a) {
11024
+ switch (_a.label) {
11025
+ case 0:
11026
+ accountEntity = this.browserStorage.readAccountFromCacheWithNativeAccountId(nativeAccountId);
11027
+ if (!accountEntity) {
11028
+ throw ClientAuthError.createNoAccountFoundError();
11029
+ }
11030
+ account = accountEntity.getAccountInfo();
11031
+ _a.label = 1;
11032
+ case 1:
11033
+ _a.trys.push([1, 3, , 4]);
11034
+ silentRequest = this.createSilentCacheRequest(request, account);
11035
+ return [4 /*yield*/, this.silentCacheClient.acquireToken(silentRequest)];
11036
+ case 2:
11037
+ result = _a.sent();
11038
+ return [2 /*return*/, result];
11039
+ case 3:
11040
+ e_2 = _a.sent();
11041
+ throw e_2;
11042
+ case 4: return [2 /*return*/];
11043
+ }
11044
+ });
11045
+ });
11046
+ };
10685
11047
  /**
10686
11048
  * Acquires a token from native platform then redirects to the redirectUri instead of returning the response
10687
11049
  * @param request
10688
11050
  */
10689
11051
  NativeInteractionClient.prototype.acquireTokenRedirect = function (request) {
10690
11052
  return __awaiter$1(this, void 0, void 0, function () {
10691
- var nativeRequest, messageBody, response, e_1, navigationOptions, redirectUri;
11053
+ var nativeRequest, messageBody, response, e_3, navigationOptions, redirectUri;
10692
11054
  return __generator$1(this, function (_a) {
10693
11055
  switch (_a.label) {
10694
11056
  case 0:
@@ -10709,10 +11071,10 @@
10709
11071
  this.validateNativeResponse(response);
10710
11072
  return [3 /*break*/, 5];
10711
11073
  case 4:
10712
- e_1 = _a.sent();
11074
+ e_3 = _a.sent();
10713
11075
  // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
10714
- if (e_1 instanceof NativeAuthError && e_1.isFatal()) {
10715
- throw e_1;
11076
+ if (e_3 instanceof NativeAuthError && e_3.isFatal()) {
11077
+ throw e_3;
10716
11078
  }
10717
11079
  return [3 /*break*/, 5];
10718
11080
  case 5:
@@ -10736,7 +11098,7 @@
10736
11098
  */
10737
11099
  NativeInteractionClient.prototype.handleRedirectPromise = function () {
10738
11100
  return __awaiter$1(this, void 0, void 0, function () {
10739
- var cachedRequest, messageBody, reqTimestamp, response, result, e_2;
11101
+ var cachedRequest, messageBody, reqTimestamp, response, result, e_4;
10740
11102
  return __generator$1(this, function (_a) {
10741
11103
  switch (_a.label) {
10742
11104
  case 0:
@@ -10768,9 +11130,9 @@
10768
11130
  this.browserStorage.setInteractionInProgress(false);
10769
11131
  return [2 /*return*/, result];
10770
11132
  case 3:
10771
- e_2 = _a.sent();
11133
+ e_4 = _a.sent();
10772
11134
  this.browserStorage.setInteractionInProgress(false);
10773
- throw e_2;
11135
+ throw e_4;
10774
11136
  case 4: return [2 /*return*/];
10775
11137
  }
10776
11138
  });
@@ -10792,7 +11154,7 @@
10792
11154
  */
10793
11155
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
10794
11156
  return __awaiter$1(this, void 0, void 0, function () {
10795
- var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, result;
11157
+ var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
10796
11158
  var _this = this;
10797
11159
  return __generator$1(this, function (_b) {
10798
11160
  switch (_b.label) {
@@ -10808,7 +11170,7 @@
10808
11170
  authority = _b.sent();
10809
11171
  authorityPreferredCache = authority.getPreferredCache();
10810
11172
  homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
10811
- accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
11173
+ accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
10812
11174
  this.browserStorage.setAccount(accountEntity);
10813
11175
  responseScopes = response.scopes ? ScopeSet.fromString(response.scopes) : ScopeSet.fromString(request.scopes);
10814
11176
  accountProperties = response.account.properties || {};
@@ -10853,6 +11215,7 @@
10853
11215
  }
10854
11216
  _b.label = 5;
10855
11217
  case 5:
11218
+ mats = this.getMATSFromResponse(response);
10856
11219
  result = {
10857
11220
  authority: authority.canonicalAuthority,
10858
11221
  uniqueId: uid,
@@ -10862,14 +11225,24 @@
10862
11225
  idToken: response.id_token,
10863
11226
  idTokenClaims: idTokenObj.claims,
10864
11227
  accessToken: responseAccessToken,
10865
- fromCache: false,
11228
+ fromCache: mats ? this.isResponseFromCache(mats) : false,
10866
11229
  expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
10867
11230
  tokenType: responseTokenType,
10868
11231
  correlationId: this.correlationId,
10869
11232
  state: response.state,
10870
11233
  fromNativeBroker: true
10871
11234
  };
10872
- // Remove any existing cached tokens for this account
11235
+ idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
11236
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
11237
+ expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
11238
+ ? Constants.SHR_NONCE_VALIDITY
11239
+ : (typeof response.expires_in === "string"
11240
+ ? parseInt(response.expires_in, 10)
11241
+ : response.expires_in) || 0;
11242
+ tokenExpirationSeconds = reqTimestamp + expiresIn;
11243
+ accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
11244
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
11245
+ // Remove any existing cached tokens for this account in browser storage
10873
11246
  this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
10874
11247
  _this.logger.error("Error occurred while removing account context from browser storage. " + e);
10875
11248
  });
@@ -10895,13 +11268,42 @@
10895
11268
  throw NativeAuthError.createUnexpectedError("Response missing expected properties.");
10896
11269
  }
10897
11270
  };
11271
+ /**
11272
+ * Gets MATS telemetry from native response
11273
+ * @param response
11274
+ * @returns
11275
+ */
11276
+ NativeInteractionClient.prototype.getMATSFromResponse = function (response) {
11277
+ if (response.properties.MATS) {
11278
+ try {
11279
+ return JSON.parse(response.properties.MATS);
11280
+ }
11281
+ catch (e) {
11282
+ this.logger.error("NativeInteractionClient - Error parsing MATS telemetry, returning null instead");
11283
+ }
11284
+ }
11285
+ return null;
11286
+ };
11287
+ /**
11288
+ * Returns whether or not response came from native cache
11289
+ * @param response
11290
+ * @returns
11291
+ */
11292
+ NativeInteractionClient.prototype.isResponseFromCache = function (mats) {
11293
+ if (typeof mats.is_cached === "undefined") {
11294
+ this.logger.verbose("NativeInteractionClient - MATS telemetry does not contain field indicating if response was served from cache. Returning false.");
11295
+ return false;
11296
+ }
11297
+ return !!mats.is_cached;
11298
+ };
10898
11299
  /**
10899
11300
  * Translates developer provided request object into NativeRequest object
10900
11301
  * @param request
10901
11302
  */
10902
11303
  NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
10903
11304
  return __awaiter$1(this, void 0, void 0, function () {
10904
- var authority, canonicalAuthority, scopes, scopeSet, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11305
+ var authority, canonicalAuthority, scopes, scopeSet, getPrompt, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11306
+ var _this = this;
10905
11307
  return __generator$1(this, function (_a) {
10906
11308
  switch (_a.label) {
10907
11309
  case 0:
@@ -10912,18 +11314,32 @@
10912
11314
  scopes = request && request.scopes || [];
10913
11315
  scopeSet = new ScopeSet(scopes);
10914
11316
  scopeSet.appendScopes(OIDC_DEFAULT_SCOPES);
10915
- if (request.prompt) {
11317
+ getPrompt = function () {
11318
+ // If request is silent, prompt is always none
11319
+ switch (_this.apiId) {
11320
+ case exports.ApiId.ssoSilent:
11321
+ case exports.ApiId.acquireTokenSilent_silentFlow:
11322
+ _this.logger.trace("initializeNativeRequest: silent request sets prompt to none");
11323
+ return PromptValue.NONE;
11324
+ }
11325
+ // Prompt not provided, request may proceed and native broker decides if it needs to prompt
11326
+ if (!request.prompt) {
11327
+ _this.logger.trace("initializeNativeRequest: prompt was not provided");
11328
+ return undefined;
11329
+ }
11330
+ // If request is interactive, check if prompt provided is allowed to go directly to native broker
10916
11331
  switch (request.prompt) {
10917
11332
  case PromptValue.NONE:
10918
11333
  case PromptValue.CONSENT:
10919
- this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
10920
- break;
11334
+ case PromptValue.LOGIN:
11335
+ _this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
11336
+ return request.prompt;
10921
11337
  default:
10922
- this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
11338
+ _this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
10923
11339
  throw BrowserAuthError.createNativePromptParameterNotSupportedError();
10924
11340
  }
10925
- }
10926
- validatedRequest = __assign$1(__assign$1({}, request), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scopes: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), correlationId: this.correlationId, tokenType: request.authenticationScheme, windowTitleSubstring: document.title, extraParameters: __assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), extendedExpiryToken: false // Make this configurable?
11341
+ };
11342
+ validatedRequest = __assign$1(__assign$1({}, request), { accountId: this.accountId, clientId: this.config.auth.clientId, authority: canonicalAuthority.urlString, scopes: scopeSet.printScopes(), redirectUri: this.getRedirectUri(request.redirectUri), prompt: getPrompt(), correlationId: this.correlationId, tokenType: request.authenticationScheme, windowTitleSubstring: document.title, extraParameters: __assign$1(__assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), { telemetry: NativeConstants.MATS_TELEMETRY }), extendedExpiryToken: false // Make this configurable?
10927
11343
  });
10928
11344
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
10929
11345
  shrParameters = {
@@ -10940,11 +11356,7 @@
10940
11356
  validatedRequest.reqCnf = reqCnfData.reqCnfHash;
10941
11357
  validatedRequest.keyId = reqCnfData.kid;
10942
11358
  _a.label = 2;
10943
- case 2:
10944
- if (this.apiId === exports.ApiId.ssoSilent || this.apiId === exports.ApiId.acquireTokenSilent_silentFlow) {
10945
- validatedRequest.prompt = PromptValue.NONE;
10946
- }
10947
- return [2 /*return*/, validatedRequest];
11359
+ case 2: return [2 /*return*/, validatedRequest];
10948
11360
  }
10949
11361
  });
10950
11362
  });
@@ -11194,8 +11606,10 @@
11194
11606
  */
11195
11607
  var RedirectClient = /** @class */ (function (_super) {
11196
11608
  __extends$1(RedirectClient, _super);
11197
- function RedirectClient() {
11198
- return _super !== null && _super.apply(this, arguments) || this;
11609
+ function RedirectClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11610
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11611
+ _this.nativeStorage = nativeStorageImpl;
11612
+ return _this;
11199
11613
  }
11200
11614
  /**
11201
11615
  * Redirects the page to the /authorize endpoint of the IDP
@@ -11404,7 +11818,7 @@
11404
11818
  if (!this.nativeMessageHandler) {
11405
11819
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11406
11820
  }
11407
- nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, cachedRequest.correlationId);
11821
+ nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.browserStorage, cachedRequest.correlationId);
11408
11822
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
11409
11823
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, cachedRequest), { state: userRequestState, prompt: undefined // Server should handle the prompt, ideally native broker can do this part silently
11410
11824
  })).finally(function () {
@@ -11522,10 +11936,11 @@
11522
11936
  */
11523
11937
  var PopupClient = /** @class */ (function (_super) {
11524
11938
  __extends$1(PopupClient, _super);
11525
- function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
11939
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11526
11940
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11527
11941
  // Properly sets this reference for the unload event.
11528
11942
  _this.unloadWindow = _this.unloadWindow.bind(_this);
11943
+ _this.nativeStorage = nativeStorageImpl;
11529
11944
  return _this;
11530
11945
  }
11531
11946
  /**
@@ -11650,7 +12065,7 @@
11650
12065
  if (!this.nativeMessageHandler) {
11651
12066
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11652
12067
  }
11653
- nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, validRequest.correlationId);
12068
+ nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.nativeStorage, validRequest.correlationId);
11654
12069
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state_1).userRequestState;
11655
12070
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, validRequest), { state: userRequestState, prompt: undefined // Server should handle the prompt, ideally native broker can do this part silently
11656
12071
  })).finally(function () {
@@ -12086,6 +12501,7 @@
12086
12501
  azureCloudInstance: exports.AzureCloudInstance.None,
12087
12502
  tenant: Constants.EMPTY_STRING
12088
12503
  },
12504
+ skipAuthorityMetadataCache: false,
12089
12505
  };
12090
12506
  // Default cache options for browser
12091
12507
  var DEFAULT_CACHE_OPTIONS = {
@@ -12277,9 +12693,10 @@
12277
12693
  */
12278
12694
  var SilentIframeClient = /** @class */ (function (_super) {
12279
12695
  __extends$1(SilentIframeClient, _super);
12280
- function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeMessageHandler, correlationId) {
12696
+ function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
12281
12697
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
12282
12698
  _this.apiId = apiId;
12699
+ _this.nativeStorage = nativeStorageImpl;
12283
12700
  return _this;
12284
12701
  }
12285
12702
  /**
@@ -12333,6 +12750,8 @@
12333
12750
  serverTelemetryManager.cacheFailedRequest(e_1);
12334
12751
  this.browserStorage.cleanRequestByState(silentRequest.state);
12335
12752
  acquireTokenMeasurement.endMeasurement({
12753
+ errorCode: e_1 instanceof AuthError && e_1.errorCode || undefined,
12754
+ subErrorCode: e_1 instanceof AuthError && e_1.subError || undefined,
12336
12755
  success: false
12337
12756
  });
12338
12757
  throw e_1;
@@ -12380,7 +12799,7 @@
12380
12799
  if (!this.nativeMessageHandler) {
12381
12800
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
12382
12801
  }
12383
- nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.apiId, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.correlationId);
12802
+ 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);
12384
12803
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
12385
12804
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
12386
12805
  _this.browserStorage.cleanRequestByState(state);
@@ -12395,97 +12814,6 @@
12395
12814
  return SilentIframeClient;
12396
12815
  }(StandardInteractionClient));
12397
12816
 
12398
- /*
12399
- * Copyright (c) Microsoft Corporation. All rights reserved.
12400
- * Licensed under the MIT License.
12401
- */
12402
- var SilentCacheClient = /** @class */ (function (_super) {
12403
- __extends$1(SilentCacheClient, _super);
12404
- function SilentCacheClient() {
12405
- return _super !== null && _super.apply(this, arguments) || this;
12406
- }
12407
- /**
12408
- * Returns unexpired tokens from the cache, if available
12409
- * @param silentRequest
12410
- */
12411
- SilentCacheClient.prototype.acquireToken = function (silentRequest) {
12412
- return __awaiter$1(this, void 0, void 0, function () {
12413
- var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
12414
- return __generator$1(this, function (_a) {
12415
- switch (_a.label) {
12416
- case 0:
12417
- acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
12418
- serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12419
- return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12420
- case 1:
12421
- silentAuthClient = _a.sent();
12422
- this.logger.verbose("Silent auth client created");
12423
- _a.label = 2;
12424
- case 2:
12425
- _a.trys.push([2, 4, , 5]);
12426
- return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
12427
- case 3:
12428
- cachedToken = _a.sent();
12429
- acquireTokenMeasurement.endMeasurement({
12430
- success: true,
12431
- fromCache: true
12432
- });
12433
- return [2 /*return*/, cachedToken];
12434
- case 4:
12435
- error_1 = _a.sent();
12436
- if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
12437
- this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
12438
- }
12439
- acquireTokenMeasurement.endMeasurement({
12440
- success: false
12441
- });
12442
- throw error_1;
12443
- case 5: return [2 /*return*/];
12444
- }
12445
- });
12446
- });
12447
- };
12448
- /**
12449
- * Currently Unsupported
12450
- */
12451
- SilentCacheClient.prototype.logout = function () {
12452
- // Synchronous so we must reject
12453
- return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
12454
- };
12455
- /**
12456
- * Creates an Silent Flow Client with the given authority, or the default authority.
12457
- * @param serverTelemetryManager
12458
- * @param authorityUrl
12459
- */
12460
- SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
12461
- return __awaiter$1(this, void 0, void 0, function () {
12462
- var clientConfig;
12463
- return __generator$1(this, function (_a) {
12464
- switch (_a.label) {
12465
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12466
- case 1:
12467
- clientConfig = _a.sent();
12468
- return [2 /*return*/, new SilentFlowClient(clientConfig)];
12469
- }
12470
- });
12471
- });
12472
- };
12473
- SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
12474
- return __awaiter$1(this, void 0, void 0, function () {
12475
- var _a;
12476
- return __generator$1(this, function (_b) {
12477
- switch (_b.label) {
12478
- case 0:
12479
- _a = [__assign$1({}, request)];
12480
- return [4 /*yield*/, this.initializeBaseRequest(request)];
12481
- case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
12482
- }
12483
- });
12484
- });
12485
- };
12486
- return SilentCacheClient;
12487
- }(StandardInteractionClient));
12488
-
12489
12817
  /*
12490
12818
  * Copyright (c) Microsoft Corporation. All rights reserved.
12491
12819
  * Licensed under the MIT License.
@@ -12531,6 +12859,8 @@
12531
12859
  }
12532
12860
  serverTelemetryManager.cacheFailedRequest(e);
12533
12861
  acquireTokenMeasurement.endMeasurement({
12862
+ errorCode: e.errorCode,
12863
+ subErrorCode: e.subError,
12534
12864
  success: false
12535
12865
  });
12536
12866
  throw e;
@@ -14174,6 +14504,7 @@
14174
14504
  knownAuthorities: this.config.auth.knownAuthorities,
14175
14505
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
14176
14506
  authorityMetadata: this.config.auth.authorityMetadata,
14507
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
14177
14508
  };
14178
14509
  var authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
14179
14510
  // "clientInfo" from options takes precedence over "clientInfo" in response
@@ -14207,8 +14538,8 @@
14207
14538
  var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken, this.config.auth.clientId, tenantId);
14208
14539
  var idAuthToken = new AuthToken(idToken, this.cryptoObj);
14209
14540
  var accountEntity = options.clientInfo ?
14210
- AccountEntity.createAccount(options.clientInfo, homeAccountId, idAuthToken, undefined, undefined, undefined, undefined, environment) :
14211
- AccountEntity.createGenericAccount(homeAccountId, idAuthToken, undefined, undefined, undefined, undefined, environment);
14541
+ AccountEntity.createAccount(options.clientInfo, homeAccountId, idAuthToken, undefined, undefined, undefined, environment) :
14542
+ AccountEntity.createGenericAccount(homeAccountId, idAuthToken, undefined, undefined, undefined, environment);
14212
14543
  if (this.isBrowserEnvironment) {
14213
14544
  this.logger.verbose("TokenCache - loading id token");
14214
14545
  this.storage.setAccount(accountEntity);
@@ -14500,6 +14831,13 @@
14500
14831
  this.browserStorage = this.isBrowserEnvironment ?
14501
14832
  new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger) :
14502
14833
  DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
14834
+ // initialize in memory storage for native flows
14835
+ var nativeCacheOptions = {
14836
+ cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
14837
+ storeAuthStateInCookie: false,
14838
+ secureCookies: false
14839
+ };
14840
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
14503
14841
  // Initialize the token cache
14504
14842
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
14505
14843
  }
@@ -14566,7 +14904,7 @@
14566
14904
  redirectResponse = void 0;
14567
14905
  if (request && NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) && this.nativeExtensionProvider && !hash) {
14568
14906
  this.logger.trace("handleRedirectPromise - acquiring token from native platform");
14569
- nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, request.correlationId);
14907
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, this.nativeInternalStorage, request.correlationId);
14570
14908
  redirectResponse = nativeClient.handleRedirectPromise();
14571
14909
  }
14572
14910
  else {
@@ -14638,13 +14976,19 @@
14638
14976
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
14639
14977
  }
14640
14978
  if (this.nativeExtensionProvider && this.canUseNative(request)) {
14641
- nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenRedirect, this.performanceClient, this.nativeExtensionProvider, this.getNativeAccountId(request), request.correlationId);
14979
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenRedirect, this.performanceClient, this.nativeExtensionProvider, this.getNativeAccountId(request), this.nativeInternalStorage, request.correlationId);
14642
14980
  result = nativeClient.acquireTokenRedirect(request).catch(function (e) {
14643
14981
  if (e instanceof NativeAuthError && e.isFatal()) {
14644
14982
  _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
14645
14983
  var redirectClient = _this.createRedirectClient(request.correlationId);
14646
14984
  return redirectClient.acquireToken(request);
14647
14985
  }
14986
+ else if (e instanceof InteractionRequiredAuthError) {
14987
+ _this.logger.verbose("acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow");
14988
+ var redirectClient = _this.createRedirectClient(request.correlationId);
14989
+ return redirectClient.acquireToken(request);
14990
+ }
14991
+ _this.browserStorage.setInteractionInProgress(false);
14648
14992
  throw e;
14649
14993
  });
14650
14994
  }
@@ -14700,7 +15044,9 @@
14700
15044
  _this.browserStorage.setInteractionInProgress(false);
14701
15045
  atPopupMeasurement.endMeasurement({
14702
15046
  success: true,
14703
- isNativeBroker: true
15047
+ isNativeBroker: true,
15048
+ accessTokenSize: response.accessToken.length,
15049
+ idTokenSize: response.idToken.length,
14704
15050
  });
14705
15051
  atPopupMeasurement.flushMeasurement();
14706
15052
  return response;
@@ -14710,6 +15056,12 @@
14710
15056
  var popupClient = _this.createPopupClient(request.correlationId);
14711
15057
  return popupClient.acquireToken(request);
14712
15058
  }
15059
+ else if (e instanceof InteractionRequiredAuthError) {
15060
+ _this.logger.verbose("acquireTokenPopup - Resolving interaction required error thrown by native broker by falling back to web flow");
15061
+ var popupClient = _this.createPopupClient(request.correlationId);
15062
+ return popupClient.acquireToken(request);
15063
+ }
15064
+ _this.browserStorage.setInteractionInProgress(false);
14713
15065
  throw e;
14714
15066
  });
14715
15067
  }
@@ -14718,7 +15070,9 @@
14718
15070
  result = popupClient.acquireToken(request);
14719
15071
  }
14720
15072
  return result.then(function (result) {
14721
- // If logged in, emit acquire token events
15073
+ /*
15074
+ * If logged in, emit acquire token events
15075
+ */
14722
15076
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
14723
15077
  if (isLoggingIn) {
14724
15078
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_SUCCESS, exports.InteractionType.Popup, result);
@@ -14727,7 +15081,9 @@
14727
15081
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
14728
15082
  }
14729
15083
  atPopupMeasurement.endMeasurement({
14730
- success: true
15084
+ success: true,
15085
+ accessTokenSize: result.accessToken.length,
15086
+ idTokenSize: result.idToken.length,
14731
15087
  });
14732
15088
  atPopupMeasurement.flushMeasurement();
14733
15089
  return result;
@@ -14739,6 +15095,8 @@
14739
15095
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_FAILURE, exports.InteractionType.Popup, null, e);
14740
15096
  }
14741
15097
  atPopupMeasurement.endMeasurement({
15098
+ errorCode: e.errorCode,
15099
+ subErrorCode: e.subError,
14742
15100
  success: false
14743
15101
  });
14744
15102
  atPopupMeasurement.flushMeasurement();
@@ -14792,13 +15150,18 @@
14792
15150
  return [2 /*return*/, result.then(function (response) {
14793
15151
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
14794
15152
  ssoSilentMeasurement.endMeasurement({
14795
- success: true
15153
+ success: true,
15154
+ isNativeBroker: response.fromNativeBroker,
15155
+ accessTokenSize: response.accessToken.length,
15156
+ idTokenSize: response.idToken.length
14796
15157
  });
14797
15158
  ssoSilentMeasurement.flushMeasurement();
14798
15159
  return response;
14799
15160
  }).catch(function (e) {
14800
15161
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
14801
15162
  ssoSilentMeasurement.endMeasurement({
15163
+ errorCode: e.errorCode,
15164
+ subErrorCode: e.subError,
14802
15165
  success: false
14803
15166
  });
14804
15167
  ssoSilentMeasurement.flushMeasurement();
@@ -14838,7 +15201,10 @@
14838
15201
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
14839
15202
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
14840
15203
  atbcMeasurement.endMeasurement({
14841
- success: true
15204
+ success: true,
15205
+ accessTokenSize: result.accessToken.length,
15206
+ idTokenSize: result.idToken.length,
15207
+ isNativeBroker: result.fromNativeBroker
14842
15208
  });
14843
15209
  atbcMeasurement.flushMeasurement();
14844
15210
  return result;
@@ -14847,6 +15213,8 @@
14847
15213
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
14848
15214
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
14849
15215
  atbcMeasurement.endMeasurement({
15216
+ errorCode: error.errorCode,
15217
+ subErrorCode: error.subError,
14850
15218
  success: false
14851
15219
  });
14852
15220
  atbcMeasurement.flushMeasurement();
@@ -14884,6 +15252,8 @@
14884
15252
  catch (e) {
14885
15253
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
14886
15254
  atbcMeasurement.endMeasurement({
15255
+ errorCode: e instanceof AuthError && e.errorCode || undefined,
15256
+ subErrorCode: e instanceof AuthError && e.subError || undefined,
14887
15257
  success: false
14888
15258
  });
14889
15259
  throw e;
@@ -14938,7 +15308,9 @@
14938
15308
  .then(function (result) {
14939
15309
  atbrtMeasurement.endMeasurement({
14940
15310
  success: true,
14941
- fromCache: result.fromCache
15311
+ fromCache: result.fromCache,
15312
+ accessTokenSize: result.accessToken.length,
15313
+ idTokenSize: result.idToken.length,
14942
15314
  });
14943
15315
  return result;
14944
15316
  })
@@ -14953,12 +15325,16 @@
14953
15325
  .then(function (result) {
14954
15326
  atbrtMeasurement.endMeasurement({
14955
15327
  success: true,
14956
- fromCache: result.fromCache
15328
+ fromCache: result.fromCache,
15329
+ accessTokenSize: result.accessToken.length,
15330
+ idTokenSize: result.idToken.length,
14957
15331
  });
14958
15332
  return result;
14959
15333
  })
14960
15334
  .catch(function (error) {
14961
15335
  atbrtMeasurement.endMeasurement({
15336
+ errorCode: error.errorCode,
15337
+ subErrorCode: error.subError,
14962
15338
  success: false
14963
15339
  });
14964
15340
  throw error;
@@ -15108,9 +15484,13 @@
15108
15484
  // #region Helpers
15109
15485
  /**
15110
15486
  * Helper to validate app environment before making an auth request
15111
- * * @param interactionType
15487
+ *
15488
+ * @protected
15489
+ * @param {InteractionType} interactionType What kind of interaction is being used
15490
+ * @param {boolean} [setInteractionInProgress=true] Whether to set interaction in progress temp cache flag
15112
15491
  */
15113
- ClientApplication.prototype.preflightBrowserEnvironmentCheck = function (interactionType) {
15492
+ ClientApplication.prototype.preflightBrowserEnvironmentCheck = function (interactionType, setInteractionInProgress) {
15493
+ if (setInteractionInProgress === void 0) { setInteractionInProgress = true; }
15114
15494
  this.logger.verbose("preflightBrowserEnvironmentCheck started");
15115
15495
  // Block request if not in browser environment
15116
15496
  BrowserUtils.blockNonBrowserEnvironment(this.isBrowserEnvironment);
@@ -15129,20 +15509,23 @@
15129
15509
  throw BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError();
15130
15510
  }
15131
15511
  if (interactionType === exports.InteractionType.Redirect || interactionType === exports.InteractionType.Popup) {
15132
- this.preflightInteractiveRequest();
15512
+ this.preflightInteractiveRequest(setInteractionInProgress);
15133
15513
  }
15134
15514
  };
15135
15515
  /**
15136
- * Helper to validate app environment before making a request.
15137
- * @param request
15138
- * @param interactionType
15516
+ * Preflight check for interactive requests
15517
+ *
15518
+ * @protected
15519
+ * @param {boolean} setInteractionInProgress Whether to set interaction in progress temp cache flag
15139
15520
  */
15140
- ClientApplication.prototype.preflightInteractiveRequest = function () {
15521
+ ClientApplication.prototype.preflightInteractiveRequest = function (setInteractionInProgress) {
15141
15522
  this.logger.verbose("preflightInteractiveRequest called, validating app environment");
15142
15523
  // block the reload if it occurred inside a hidden iframe
15143
15524
  BrowserUtils.blockReloadInHiddenIframes();
15144
15525
  // Set interaction in progress temporary cache or throw if alread set.
15145
- this.browserStorage.setInteractionInProgress(true);
15526
+ if (setInteractionInProgress) {
15527
+ this.browserStorage.setInteractionInProgress(true);
15528
+ }
15146
15529
  };
15147
15530
  /**
15148
15531
  * Acquire a token from native device (e.g. WAM)
@@ -15156,7 +15539,7 @@
15156
15539
  if (!this.nativeExtensionProvider) {
15157
15540
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
15158
15541
  }
15159
- nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, apiId, this.performanceClient, this.nativeExtensionProvider, accountId || this.getNativeAccountId(request), request.correlationId);
15542
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, apiId, this.performanceClient, this.nativeExtensionProvider, accountId || this.getNativeAccountId(request), this.nativeInternalStorage, request.correlationId);
15160
15543
  return [2 /*return*/, nativeClient.acquireToken(request)];
15161
15544
  });
15162
15545
  });
@@ -15175,6 +15558,7 @@
15175
15558
  switch (request.prompt) {
15176
15559
  case PromptValue.NONE:
15177
15560
  case PromptValue.CONSENT:
15561
+ case PromptValue.LOGIN:
15178
15562
  this.logger.trace("canUseNative: prompt is compatible with native flow");
15179
15563
  break;
15180
15564
  default:
@@ -15202,21 +15586,21 @@
15202
15586
  * @param correlationId
15203
15587
  */
15204
15588
  ClientApplication.prototype.createPopupClient = function (correlationId) {
15205
- return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15589
+ return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15206
15590
  };
15207
15591
  /**
15208
- * Returns new instance of the Popup Interaction Client
15592
+ * Returns new instance of the Redirect Interaction Client
15209
15593
  * @param correlationId
15210
15594
  */
15211
15595
  ClientApplication.prototype.createRedirectClient = function (correlationId) {
15212
- return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15596
+ return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15213
15597
  };
15214
15598
  /**
15215
15599
  * Returns new instance of the Silent Iframe Interaction Client
15216
15600
  * @param correlationId
15217
15601
  */
15218
15602
  ClientApplication.prototype.createSilentIframeClient = function (correlationId) {
15219
- return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, this.nativeExtensionProvider, correlationId);
15603
+ return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15220
15604
  };
15221
15605
  /**
15222
15606
  * Returns new instance of the Silent Cache Interaction Client
@@ -15451,7 +15835,10 @@
15451
15835
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15452
15836
  atsMeasurement.endMeasurement({
15453
15837
  success: true,
15454
- fromCache: result.fromCache
15838
+ fromCache: result.fromCache,
15839
+ accessTokenSize: result.accessToken.length,
15840
+ idTokenSize: result.idToken.length,
15841
+ isNativeBroker: result.fromNativeBroker
15455
15842
  });
15456
15843
  atsMeasurement.flushMeasurement();
15457
15844
  return result;
@@ -15527,12 +15914,17 @@
15527
15914
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
15528
15915
  astsAsyncMeasurement.endMeasurement({
15529
15916
  success: true,
15530
- fromCache: response.fromCache
15917
+ fromCache: response.fromCache,
15918
+ accessTokenSize: response.accessToken.length,
15919
+ idTokenSize: response.idToken.length,
15920
+ isNativeBroker: response.fromNativeBroker
15531
15921
  });
15532
15922
  return response;
15533
15923
  }).catch(function (tokenRenewalError) {
15534
15924
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
15535
15925
  astsAsyncMeasurement.endMeasurement({
15926
+ errorCode: tokenRenewalError.errorCode,
15927
+ subErrorCode: tokenRenewalError.subError,
15536
15928
  success: false
15537
15929
  });
15538
15930
  throw tokenRenewalError;