@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
package/dist/index.cjs.js CHANGED
@@ -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
  'use strict';
4
4
 
@@ -105,7 +105,7 @@ function __spread() {
105
105
  return ar;
106
106
  }
107
107
 
108
- /*! @azure/msal-common v6.4.0 2022-06-06 */
108
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
109
109
  /*! *****************************************************************************
110
110
  Copyright (c) Microsoft Corporation.
111
111
 
@@ -192,7 +192,7 @@ function __spreadArrays() {
192
192
  return r;
193
193
  }
194
194
 
195
- /*! @azure/msal-common v6.4.0 2022-06-06 */
195
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
196
196
 
197
197
  /*
198
198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -242,7 +242,8 @@ var Constants = {
242
242
  REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
243
243
  KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
244
244
  TOKEN_RESPONSE_TYPE: "token",
245
- ID_TOKEN_RESPONSE_TYPE: "id_token"
245
+ ID_TOKEN_RESPONSE_TYPE: "id_token",
246
+ SHR_NONCE_VALIDITY: 240,
246
247
  };
247
248
  var OIDC_DEFAULT_SCOPES = [
248
249
  Constants.OPENID_SCOPE,
@@ -274,6 +275,7 @@ var PersistentCacheKeys;
274
275
  PersistentCacheKeys["ERROR"] = "error";
275
276
  PersistentCacheKeys["ERROR_DESC"] = "error.description";
276
277
  PersistentCacheKeys["ACTIVE_ACCOUNT"] = "active-account";
278
+ PersistentCacheKeys["ACTIVE_ACCOUNT_FILTERS"] = "active-account-filters"; // new cache entry for active_account for a more robust version for browser
277
279
  })(PersistentCacheKeys || (PersistentCacheKeys = {}));
278
280
  /**
279
281
  * String constants related to AAD Authority
@@ -476,6 +478,7 @@ var AuthorityMetadataSource;
476
478
  AuthorityMetadataSource["CONFIG"] = "config";
477
479
  AuthorityMetadataSource["CACHE"] = "cache";
478
480
  AuthorityMetadataSource["NETWORK"] = "network";
481
+ AuthorityMetadataSource["HARDCODED_VALUES"] = "hardcoded_values";
479
482
  })(AuthorityMetadataSource || (AuthorityMetadataSource = {}));
480
483
  var SERVER_TELEM_CONSTANTS = {
481
484
  SCHEMA_VERSION: 5,
@@ -566,7 +569,7 @@ var JsonTypes;
566
569
  JsonTypes["Jwk"] = "JWK";
567
570
  })(JsonTypes || (JsonTypes = {}));
568
571
 
569
- /*! @azure/msal-common v6.4.0 2022-06-06 */
572
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
570
573
 
571
574
  /*
572
575
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -610,7 +613,7 @@ var AuthError = /** @class */ (function (_super) {
610
613
  return AuthError;
611
614
  }(Error));
612
615
 
613
- /*! @azure/msal-common v6.4.0 2022-06-06 */
616
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
614
617
 
615
618
  /*
616
619
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -685,7 +688,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
685
688
  }
686
689
  };
687
690
 
688
- /*! @azure/msal-common v6.4.0 2022-06-06 */
691
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
689
692
 
690
693
  /*
691
694
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1157,7 +1160,7 @@ var ClientAuthError = /** @class */ (function (_super) {
1157
1160
  return ClientAuthError;
1158
1161
  }(AuthError));
1159
1162
 
1160
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1163
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1161
1164
 
1162
1165
  /*
1163
1166
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1282,7 +1285,7 @@ var StringUtils = /** @class */ (function () {
1282
1285
  return StringUtils;
1283
1286
  }());
1284
1287
 
1285
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1288
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1286
1289
 
1287
1290
  /*
1288
1291
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1462,12 +1465,12 @@ var Logger = /** @class */ (function () {
1462
1465
  return Logger;
1463
1466
  }());
1464
1467
 
1465
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1468
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1466
1469
  /* eslint-disable header/header */
1467
1470
  var name$1 = "@azure/msal-common";
1468
- var version$1 = "6.4.0";
1471
+ var version$1 = "7.2.0";
1469
1472
 
1470
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1473
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1471
1474
  /*
1472
1475
  * Copyright (c) Microsoft Corporation. All rights reserved.
1473
1476
  * Licensed under the MIT License.
@@ -1488,7 +1491,7 @@ exports.AzureCloudInstance = void 0;
1488
1491
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1489
1492
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1490
1493
 
1491
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1494
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1492
1495
 
1493
1496
  /*
1494
1497
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1511,9 +1514,9 @@ exports.AzureCloudInstance = void 0;
1511
1514
  * familyId: Family ID identifier, usually only used for refresh tokens
1512
1515
  * realm: Full tenant or organizational identifier that the account belongs to
1513
1516
  * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
1514
- * oboAssertion: access token passed in as part of OBO request
1515
1517
  * tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
1516
1518
  * requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
1519
+ * userAssertionHash: Matches the SHA 256 hash of the obo_assertion for the OBO flow
1517
1520
  * }
1518
1521
  */
1519
1522
  var CredentialEntity = /** @class */ (function () {
@@ -1647,7 +1650,7 @@ var CredentialEntity = /** @class */ (function () {
1647
1650
  return CredentialEntity;
1648
1651
  }());
1649
1652
 
1650
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1653
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1651
1654
 
1652
1655
  /*
1653
1656
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1902,7 +1905,7 @@ var ClientConfigurationError = /** @class */ (function (_super) {
1902
1905
  return ClientConfigurationError;
1903
1906
  }(ClientAuthError));
1904
1907
 
1905
- /*! @azure/msal-common v6.4.0 2022-06-06 */
1908
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
1906
1909
 
1907
1910
  /*
1908
1911
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2086,7 +2089,7 @@ var ScopeSet = /** @class */ (function () {
2086
2089
  return ScopeSet;
2087
2090
  }());
2088
2091
 
2089
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2092
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2090
2093
 
2091
2094
  /*
2092
2095
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2124,7 +2127,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2124
2127
  };
2125
2128
  }
2126
2129
 
2127
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2130
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2128
2131
  /*
2129
2132
  * Copyright (c) Microsoft Corporation. All rights reserved.
2130
2133
  * Licensed under the MIT License.
@@ -2138,7 +2141,7 @@ var AuthorityType;
2138
2141
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2139
2142
  })(AuthorityType || (AuthorityType = {}));
2140
2143
 
2141
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2144
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2142
2145
 
2143
2146
  /*
2144
2147
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2163,7 +2166,6 @@ var AuthorityType;
2163
2166
  * clientInfo: Full base64 encoded client info received from ESTS
2164
2167
  * lastModificationTime: last time this entity was modified in the cache
2165
2168
  * lastModificationApp:
2166
- * oboAssertion: access token passed in as part of OBO request
2167
2169
  * idTokenClaims: Object containing claims parsed from ID token
2168
2170
  * nativeAccountId: Account identifier on the native device
2169
2171
  * }
@@ -2242,7 +2244,7 @@ var AccountEntity = /** @class */ (function () {
2242
2244
  * @param idToken
2243
2245
  * @param policy
2244
2246
  */
2245
- AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
2247
+ AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
2246
2248
  var _a, _b, _c, _d, _e, _f;
2247
2249
  var account = new AccountEntity();
2248
2250
  account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
@@ -2256,7 +2258,6 @@ var AccountEntity = /** @class */ (function () {
2256
2258
  account.environment = env;
2257
2259
  // non AAD scenarios can have empty realm
2258
2260
  account.realm = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.tid) || Constants.EMPTY_STRING;
2259
- account.oboAssertion = oboAssertion;
2260
2261
  if (idToken) {
2261
2262
  account.idTokenClaims = idToken.claims;
2262
2263
  // How do you account for MSA CID here?
@@ -2277,14 +2278,13 @@ var AccountEntity = /** @class */ (function () {
2277
2278
  * @param authority
2278
2279
  * @param idToken
2279
2280
  */
2280
- AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment) {
2281
+ AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment) {
2281
2282
  var _a, _b, _c, _d;
2282
2283
  var account = new AccountEntity();
2283
2284
  account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
2284
2285
  account.homeAccountId = homeAccountId;
2285
2286
  // non AAD scenarios can have empty realm
2286
2287
  account.realm = Constants.EMPTY_STRING;
2287
- account.oboAssertion = oboAssertion;
2288
2288
  var env = environment || authority && authority.getPreferredCache();
2289
2289
  if (!env) {
2290
2290
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -2376,7 +2376,7 @@ var AccountEntity = /** @class */ (function () {
2376
2376
  return AccountEntity;
2377
2377
  }());
2378
2378
 
2379
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2379
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2380
2380
 
2381
2381
  /*
2382
2382
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2414,7 +2414,7 @@ var AuthToken = /** @class */ (function () {
2414
2414
  return AuthToken;
2415
2415
  }());
2416
2416
 
2417
- /*! @azure/msal-common v6.4.0 2022-06-06 */
2417
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
2418
2418
 
2419
2419
  /*
2420
2420
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2536,7 +2536,7 @@ var CacheManager = /** @class */ (function () {
2536
2536
  * @param realm
2537
2537
  */
2538
2538
  CacheManager.prototype.getAccountsFilteredBy = function (accountFilter) {
2539
- return this.getAccountsFilteredByInternal(accountFilter ? accountFilter.homeAccountId : Constants.EMPTY_STRING, accountFilter ? accountFilter.environment : Constants.EMPTY_STRING, accountFilter ? accountFilter.realm : Constants.EMPTY_STRING);
2539
+ 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);
2540
2540
  };
2541
2541
  /**
2542
2542
  * retrieve accounts matching all provided filters; if no filter is set, get all accounts
@@ -2545,7 +2545,7 @@ var CacheManager = /** @class */ (function () {
2545
2545
  * @param environment
2546
2546
  * @param realm
2547
2547
  */
2548
- CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm) {
2548
+ CacheManager.prototype.getAccountsFilteredByInternal = function (homeAccountId, environment, realm, nativeAccountId) {
2549
2549
  var _this = this;
2550
2550
  var allCacheKeys = this.getKeys();
2551
2551
  var matchingAccounts = {};
@@ -2563,6 +2563,9 @@ var CacheManager = /** @class */ (function () {
2563
2563
  if (!!realm && !_this.matchRealm(entity, realm)) {
2564
2564
  return;
2565
2565
  }
2566
+ if (!!nativeAccountId && !_this.matchNativeAccountId(entity, nativeAccountId)) {
2567
+ return;
2568
+ }
2566
2569
  matchingAccounts[cacheKey] = entity;
2567
2570
  });
2568
2571
  return matchingAccounts;
@@ -2577,7 +2580,7 @@ var CacheManager = /** @class */ (function () {
2577
2580
  * @param target
2578
2581
  */
2579
2582
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
2580
- 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);
2583
+ 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);
2581
2584
  };
2582
2585
  /**
2583
2586
  * Support function to help match credentials
@@ -2587,10 +2590,10 @@ var CacheManager = /** @class */ (function () {
2587
2590
  * @param clientId
2588
2591
  * @param realm
2589
2592
  * @param target
2590
- * @param oboAssertion
2593
+ * @param userAssertionHash
2591
2594
  * @param tokenType
2592
2595
  */
2593
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId, requestedClaimsHash) {
2596
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, userAssertionHash, tokenType, keyId, requestedClaimsHash) {
2594
2597
  var _this = this;
2595
2598
  var allCacheKeys = this.getKeys();
2596
2599
  var matchingCredentials = {
@@ -2609,7 +2612,7 @@ var CacheManager = /** @class */ (function () {
2609
2612
  if (!entity) {
2610
2613
  return;
2611
2614
  }
2612
- if (!!oboAssertion && !_this.matchOboAssertion(entity, oboAssertion)) {
2615
+ if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
2613
2616
  return;
2614
2617
  }
2615
2618
  if (!!homeAccountId && !_this.matchHomeAccountId(entity, homeAccountId)) {
@@ -2891,6 +2894,26 @@ var CacheManager = /** @class */ (function () {
2891
2894
  var accountKey = AccountEntity.generateAccountCacheKey(account);
2892
2895
  return this.getAccount(accountKey);
2893
2896
  };
2897
+ /**
2898
+ * Retrieve AccountEntity from cache
2899
+ * @param nativeAccountId
2900
+ * @returns AccountEntity or Null
2901
+ */
2902
+ CacheManager.prototype.readAccountFromCacheWithNativeAccountId = function (nativeAccountId) {
2903
+ // fetch account from memory
2904
+ var accountFilter = {
2905
+ nativeAccountId: nativeAccountId
2906
+ };
2907
+ var accountCache = this.getAccountsFilteredBy(accountFilter);
2908
+ var accounts = Object.keys(accountCache).map(function (key) { return accountCache[key]; });
2909
+ if (accounts.length < 1) {
2910
+ return null;
2911
+ }
2912
+ else if (accounts.length > 1) {
2913
+ throw ClientAuthError.createMultipleMatchingAccountsInCacheError();
2914
+ }
2915
+ return accountCache[0];
2916
+ };
2894
2917
  /**
2895
2918
  * Retrieve IdTokenEntity from cache
2896
2919
  * @param clientId
@@ -2940,7 +2963,7 @@ var CacheManager = /** @class */ (function () {
2940
2963
  target: scopes.printScopesLowerCase(),
2941
2964
  tokenType: authScheme,
2942
2965
  keyId: request.sshKid,
2943
- requestedClaimsHash: request.requestedClaimsHash
2966
+ requestedClaimsHash: request.requestedClaimsHash,
2944
2967
  };
2945
2968
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
2946
2969
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -2966,7 +2989,7 @@ var CacheManager = /** @class */ (function () {
2966
2989
  environment: account.environment,
2967
2990
  credentialType: CredentialType.REFRESH_TOKEN,
2968
2991
  clientId: clientId,
2969
- familyId: id
2992
+ familyId: id,
2970
2993
  };
2971
2994
  var credentialCache = this.getCredentialsFilteredBy(refreshTokenFilter);
2972
2995
  var refreshTokens = Object.keys(credentialCache.refreshTokens).map(function (key) { return credentialCache.refreshTokens[key]; });
@@ -3018,8 +3041,8 @@ var CacheManager = /** @class */ (function () {
3018
3041
  * @param value
3019
3042
  * @param oboAssertion
3020
3043
  */
3021
- CacheManager.prototype.matchOboAssertion = function (entity, oboAssertion) {
3022
- return !!(entity.oboAssertion && oboAssertion === entity.oboAssertion);
3044
+ CacheManager.prototype.matchUserAssertionHash = function (entity, userAssertionHash) {
3045
+ return !!(entity.userAssertionHash && userAssertionHash === entity.userAssertionHash);
3023
3046
  };
3024
3047
  /**
3025
3048
  * helper to match environment
@@ -3065,6 +3088,15 @@ var CacheManager = /** @class */ (function () {
3065
3088
  CacheManager.prototype.matchRealm = function (entity, realm) {
3066
3089
  return !!(entity.realm && realm === entity.realm);
3067
3090
  };
3091
+ /**
3092
+ * helper to match nativeAccountId
3093
+ * @param entity
3094
+ * @param nativeAccountId
3095
+ * @returns boolean indicating the match result
3096
+ */
3097
+ CacheManager.prototype.matchNativeAccountId = function (entity, nativeAccountId) {
3098
+ return !!(entity.nativeAccountId && nativeAccountId === entity.nativeAccountId);
3099
+ };
3068
3100
  /**
3069
3101
  * Returns true if the target scopes are a subset of the current entity's scopes, false otherwise.
3070
3102
  * @param entity
@@ -3256,7 +3288,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3256
3288
  return DefaultStorageClass;
3257
3289
  }(CacheManager));
3258
3290
 
3259
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3291
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3260
3292
 
3261
3293
  /*
3262
3294
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3339,7 +3371,7 @@ function buildClientConfiguration(_a) {
3339
3371
  telemetry: __assign(__assign({}, DEFAULT_TELEMETRY_OPTIONS), telemetry),
3340
3372
  serverTelemetryManager: serverTelemetryManager || null,
3341
3373
  persistencePlugin: persistencePlugin || null,
3342
- serializableCache: serializableCache || null
3374
+ serializableCache: serializableCache || null,
3343
3375
  };
3344
3376
  }
3345
3377
  /**
@@ -3347,10 +3379,10 @@ function buildClientConfiguration(_a) {
3347
3379
  * @param authOptions
3348
3380
  */
3349
3381
  function buildAuthOptions(authOptions) {
3350
- return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3382
+ return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3351
3383
  }
3352
3384
 
3353
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3385
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3354
3386
 
3355
3387
  /*
3356
3388
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3370,7 +3402,7 @@ var ServerError = /** @class */ (function (_super) {
3370
3402
  return ServerError;
3371
3403
  }(AuthError));
3372
3404
 
3373
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3405
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3374
3406
 
3375
3407
  /*
3376
3408
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3466,7 +3498,7 @@ var ThrottlingUtils = /** @class */ (function () {
3466
3498
  return ThrottlingUtils;
3467
3499
  }());
3468
3500
 
3469
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3501
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3470
3502
 
3471
3503
  /*
3472
3504
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3515,7 +3547,7 @@ var NetworkManager = /** @class */ (function () {
3515
3547
  return NetworkManager;
3516
3548
  }());
3517
3549
 
3518
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3550
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3519
3551
  /*
3520
3552
  * Copyright (c) Microsoft Corporation. All rights reserved.
3521
3553
  * Licensed under the MIT License.
@@ -3526,7 +3558,7 @@ var CcsCredentialType;
3526
3558
  CcsCredentialType["UPN"] = "UPN";
3527
3559
  })(CcsCredentialType || (CcsCredentialType = {}));
3528
3560
 
3529
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3561
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3530
3562
 
3531
3563
  /*
3532
3564
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3615,7 +3647,7 @@ var BaseClient = /** @class */ (function () {
3615
3647
  return BaseClient;
3616
3648
  }());
3617
3649
 
3618
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3650
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3619
3651
 
3620
3652
  /*
3621
3653
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3701,7 +3733,7 @@ var RequestValidator = /** @class */ (function () {
3701
3733
  return RequestValidator;
3702
3734
  }());
3703
3735
 
3704
- /*! @azure/msal-common v6.4.0 2022-06-06 */
3736
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
3705
3737
 
3706
3738
  /*
3707
3739
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3935,14 +3967,18 @@ var RequestParameterBuilder = /** @class */ (function () {
3935
3967
  * @param clientAssertion
3936
3968
  */
3937
3969
  RequestParameterBuilder.prototype.addClientAssertion = function (clientAssertion) {
3938
- this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
3970
+ if (!StringUtils.isEmpty(clientAssertion)) {
3971
+ this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
3972
+ }
3939
3973
  };
3940
3974
  /**
3941
3975
  * add clientAssertionType for confidential client flows
3942
3976
  * @param clientAssertionType
3943
3977
  */
3944
3978
  RequestParameterBuilder.prototype.addClientAssertionType = function (clientAssertionType) {
3945
- this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
3979
+ if (!StringUtils.isEmpty(clientAssertionType)) {
3980
+ this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
3981
+ }
3946
3982
  };
3947
3983
  /**
3948
3984
  * add OBO assertion for confidential client flows
@@ -4075,7 +4111,7 @@ var RequestParameterBuilder = /** @class */ (function () {
4075
4111
  return RequestParameterBuilder;
4076
4112
  }());
4077
4113
 
4078
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4114
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4079
4115
 
4080
4116
  /*
4081
4117
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4110,7 +4146,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
4110
4146
  * @param clientId
4111
4147
  * @param authority
4112
4148
  */
4113
- IdTokenEntity.createIdTokenEntity = function (homeAccountId, environment, idToken, clientId, tenantId, oboAssertion) {
4149
+ IdTokenEntity.createIdTokenEntity = function (homeAccountId, environment, idToken, clientId, tenantId) {
4114
4150
  var idTokenEntity = new IdTokenEntity();
4115
4151
  idTokenEntity.credentialType = CredentialType.ID_TOKEN;
4116
4152
  idTokenEntity.homeAccountId = homeAccountId;
@@ -4118,7 +4154,6 @@ var IdTokenEntity = /** @class */ (function (_super) {
4118
4154
  idTokenEntity.clientId = clientId;
4119
4155
  idTokenEntity.secret = idToken;
4120
4156
  idTokenEntity.realm = tenantId;
4121
- idTokenEntity.oboAssertion = oboAssertion;
4122
4157
  return idTokenEntity;
4123
4158
  };
4124
4159
  /**
@@ -4140,7 +4175,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
4140
4175
  return IdTokenEntity;
4141
4176
  }(CredentialEntity));
4142
4177
 
4143
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4178
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4144
4179
  /*
4145
4180
  * Copyright (c) Microsoft Corporation. All rights reserved.
4146
4181
  * Licensed under the MIT License.
@@ -4190,7 +4225,7 @@ var TimeUtils = /** @class */ (function () {
4190
4225
  return TimeUtils;
4191
4226
  }());
4192
4227
 
4193
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4228
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4194
4229
 
4195
4230
  /*
4196
4231
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4236,7 +4271,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4236
4271
  * @param expiresOn
4237
4272
  * @param extExpiresOn
4238
4273
  */
4239
- AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId, requestedClaims, requestedClaimsHash) {
4274
+ AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, userAssertionHash, keyId, requestedClaims, requestedClaimsHash) {
4240
4275
  var _a, _b;
4241
4276
  var atEntity = new AccessTokenEntity();
4242
4277
  atEntity.homeAccountId = homeAccountId;
@@ -4257,7 +4292,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4257
4292
  atEntity.clientId = clientId;
4258
4293
  atEntity.realm = tenantId;
4259
4294
  atEntity.target = scopes;
4260
- atEntity.oboAssertion = oboAssertion;
4295
+ atEntity.userAssertionHash = userAssertionHash;
4261
4296
  atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
4262
4297
  if (requestedClaims) {
4263
4298
  atEntity.requestedClaims = requestedClaims;
@@ -4304,7 +4339,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4304
4339
  return AccessTokenEntity;
4305
4340
  }(CredentialEntity));
4306
4341
 
4307
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4342
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4308
4343
 
4309
4344
  /*
4310
4345
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4341,14 +4376,14 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4341
4376
  * @param clientId
4342
4377
  * @param authority
4343
4378
  */
4344
- RefreshTokenEntity.createRefreshTokenEntity = function (homeAccountId, environment, refreshToken, clientId, familyId, oboAssertion) {
4379
+ RefreshTokenEntity.createRefreshTokenEntity = function (homeAccountId, environment, refreshToken, clientId, familyId, userAssertionHash) {
4345
4380
  var rtEntity = new RefreshTokenEntity();
4346
4381
  rtEntity.clientId = clientId;
4347
4382
  rtEntity.credentialType = CredentialType.REFRESH_TOKEN;
4348
4383
  rtEntity.environment = environment;
4349
4384
  rtEntity.homeAccountId = homeAccountId;
4350
4385
  rtEntity.secret = refreshToken;
4351
- rtEntity.oboAssertion = oboAssertion;
4386
+ rtEntity.userAssertionHash = userAssertionHash;
4352
4387
  if (familyId)
4353
4388
  rtEntity.familyId = familyId;
4354
4389
  return rtEntity;
@@ -4371,7 +4406,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4371
4406
  return RefreshTokenEntity;
4372
4407
  }(CredentialEntity));
4373
4408
 
4374
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4409
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4375
4410
 
4376
4411
  /*
4377
4412
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4399,6 +4434,10 @@ var InteractionRequiredAuthErrorMessage = {
4399
4434
  noTokensFoundError: {
4400
4435
  code: "no_tokens_found",
4401
4436
  desc: "No refresh token found in the cache. Please sign-in."
4437
+ },
4438
+ native_account_unavailable: {
4439
+ code: "native_account_unavailable",
4440
+ 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."
4402
4441
  }
4403
4442
  };
4404
4443
  /**
@@ -4432,10 +4471,17 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
4432
4471
  InteractionRequiredAuthError.createNoTokensFoundError = function () {
4433
4472
  return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);
4434
4473
  };
4474
+ /**
4475
+ * Creates an error thrown when the native broker returns ACCOUNT_UNAVAILABLE status, indicating that the account was removed and interactive sign-in is required
4476
+ * @returns
4477
+ */
4478
+ InteractionRequiredAuthError.createNativeAccountUnavailableError = function () {
4479
+ return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.native_account_unavailable.code, InteractionRequiredAuthErrorMessage.native_account_unavailable.desc);
4480
+ };
4435
4481
  return InteractionRequiredAuthError;
4436
4482
  }(AuthError));
4437
4483
 
4438
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4484
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4439
4485
  /*
4440
4486
  * Copyright (c) Microsoft Corporation. All rights reserved.
4441
4487
  * Licensed under the MIT License.
@@ -4451,7 +4497,7 @@ var CacheRecord = /** @class */ (function () {
4451
4497
  return CacheRecord;
4452
4498
  }());
4453
4499
 
4454
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4500
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4455
4501
 
4456
4502
  /*
4457
4503
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4522,7 +4568,7 @@ var ProtocolUtils = /** @class */ (function () {
4522
4568
  return ProtocolUtils;
4523
4569
  }());
4524
4570
 
4525
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4571
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4526
4572
 
4527
4573
  /*
4528
4574
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4723,7 +4769,7 @@ var UrlString = /** @class */ (function () {
4723
4769
  return UrlString;
4724
4770
  }());
4725
4771
 
4726
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4772
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4727
4773
 
4728
4774
  /*
4729
4775
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4824,7 +4870,7 @@ var PopTokenGenerator = /** @class */ (function () {
4824
4870
  return PopTokenGenerator;
4825
4871
  }());
4826
4872
 
4827
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4873
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4828
4874
 
4829
4875
  /*
4830
4876
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4894,7 +4940,7 @@ var AppMetadataEntity = /** @class */ (function () {
4894
4940
  return AppMetadataEntity;
4895
4941
  }());
4896
4942
 
4897
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4943
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4898
4944
  /*
4899
4945
  * Copyright (c) Microsoft Corporation. All rights reserved.
4900
4946
  * Licensed under the MIT License.
@@ -4930,7 +4976,7 @@ var AppMetadataEntity = /** @class */ (function () {
4930
4976
  return TokenCacheContext;
4931
4977
  }());
4932
4978
 
4933
- /*! @azure/msal-common v6.4.0 2022-06-06 */
4979
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
4934
4980
 
4935
4981
  /*
4936
4982
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4991,7 +5037,7 @@ var ResponseHandler = /** @class */ (function () {
4991
5037
  * @param serverTokenResponse
4992
5038
  * @param authority
4993
5039
  */
4994
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, oboAssertion, handlingRefreshTokenResponse) {
5040
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
4995
5041
  return __awaiter(this, void 0, void 0, function () {
4996
5042
  var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
4997
5043
  return __generator(this, function (_a) {
@@ -5013,7 +5059,7 @@ var ResponseHandler = /** @class */ (function () {
5013
5059
  }
5014
5060
  // Add keyId from request to serverTokenResponse if defined
5015
5061
  serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
5016
- cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload);
5062
+ cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload);
5017
5063
  _a.label = 1;
5018
5064
  case 1:
5019
5065
  _a.trys.push([1, , 5, 8]);
@@ -5028,14 +5074,15 @@ var ResponseHandler = /** @class */ (function () {
5028
5074
  /*
5029
5075
  * When saving a refreshed tokens to the cache, it is expected that the account that was used is present in the cache.
5030
5076
  * If not present, we should return null, as it's the case that another application called removeAccount in between
5031
- * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal.
5077
+ * the calls to getAllAccounts and acquireTokenSilent. We should not overwrite that removal, unless explicitly flagged by
5078
+ * the developer, as in the case of refresh token flow used in ADAL Node to MSAL Node migration.
5032
5079
  */
5033
- if (handlingRefreshTokenResponse && cacheRecord.account) {
5080
+ if (handlingRefreshTokenResponse && !forceCacheRefreshTokenResponse && cacheRecord.account) {
5034
5081
  key = cacheRecord.account.generateAccountKey();
5035
5082
  account = this.cacheStorage.getAccount(key);
5036
5083
  if (!account) {
5037
5084
  this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
5038
- return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
5085
+ return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
5039
5086
  }
5040
5087
  }
5041
5088
  return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
@@ -5061,7 +5108,7 @@ var ResponseHandler = /** @class */ (function () {
5061
5108
  * @param idTokenObj
5062
5109
  * @param authority
5063
5110
  */
5064
- ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload) {
5111
+ ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload) {
5065
5112
  var env = authority.getPreferredCache();
5066
5113
  if (StringUtils.isEmpty(env)) {
5067
5114
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -5070,8 +5117,8 @@ var ResponseHandler = /** @class */ (function () {
5070
5117
  var cachedIdToken;
5071
5118
  var cachedAccount;
5072
5119
  if (!StringUtils.isEmpty(serverTokenResponse.id_token) && !!idTokenObj) {
5073
- cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING, oboAssertion);
5074
- cachedAccount = this.generateAccountEntity(serverTokenResponse, idTokenObj, authority, oboAssertion, authCodePayload);
5120
+ cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
5121
+ cachedAccount = this.generateAccountEntity(serverTokenResponse, idTokenObj, authority, authCodePayload);
5075
5122
  }
5076
5123
  // AccessToken
5077
5124
  var cachedAccessToken = null;
@@ -5089,12 +5136,12 @@ var ResponseHandler = /** @class */ (function () {
5089
5136
  var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
5090
5137
  var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
5091
5138
  // non AAD scenarios can have empty realm
5092
- 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);
5139
+ 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);
5093
5140
  }
5094
5141
  // refreshToken
5095
5142
  var cachedRefreshToken = null;
5096
5143
  if (!StringUtils.isEmpty(serverTokenResponse.refresh_token)) {
5097
- cachedRefreshToken = RefreshTokenEntity.createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token || Constants.EMPTY_STRING, this.clientId, serverTokenResponse.foci, oboAssertion);
5144
+ cachedRefreshToken = RefreshTokenEntity.createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token || Constants.EMPTY_STRING, this.clientId, serverTokenResponse.foci, userAssertionHash);
5098
5145
  }
5099
5146
  // appMetadata
5100
5147
  var cachedAppMetadata = null;
@@ -5109,22 +5156,22 @@ var ResponseHandler = /** @class */ (function () {
5109
5156
  * @param idToken
5110
5157
  * @param authority
5111
5158
  */
5112
- ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, oboAssertion, authCodePayload) {
5159
+ ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, authCodePayload) {
5113
5160
  var authorityType = authority.authorityType;
5114
5161
  var cloudGraphHostName = authCodePayload ? authCodePayload.cloud_graph_host_name : Constants.EMPTY_STRING;
5115
5162
  var msGraphhost = authCodePayload ? authCodePayload.msgraph_host : Constants.EMPTY_STRING;
5116
5163
  // ADFS does not require client_info in the response
5117
5164
  if (authorityType === AuthorityType.Adfs) {
5118
5165
  this.logger.verbose("Authority type is ADFS, creating ADFS account");
5119
- return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost);
5166
+ return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
5120
5167
  }
5121
5168
  // This fallback applies to B2C as well as they fall under an AAD account type.
5122
5169
  if (StringUtils.isEmpty(serverTokenResponse.client_info) && authority.protocolMode === "AAD") {
5123
5170
  throw ClientAuthError.createClientInfoEmptyError();
5124
5171
  }
5125
5172
  return serverTokenResponse.client_info ?
5126
- AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost) :
5127
- AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost);
5173
+ AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost) :
5174
+ AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
5128
5175
  };
5129
5176
  /**
5130
5177
  * Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
@@ -5200,7 +5247,7 @@ var ResponseHandler = /** @class */ (function () {
5200
5247
  return ResponseHandler;
5201
5248
  }());
5202
5249
 
5203
- /*! @azure/msal-common v6.4.0 2022-06-06 */
5250
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5204
5251
 
5205
5252
  /*
5206
5253
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5301,7 +5348,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5301
5348
  throw ClientConfigurationError.createEmptyLogoutRequestError();
5302
5349
  }
5303
5350
  var queryString = this.createLogoutUrlQueryString(logoutRequest);
5304
- // Construct logout URI.
5351
+ // Construct logout URI
5305
5352
  return UrlString.appendQueryString(this.authority.endSessionEndpoint, queryString);
5306
5353
  };
5307
5354
  /**
@@ -5404,8 +5451,8 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5404
5451
  if (this.config.clientCredentials.clientSecret) {
5405
5452
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
5406
5453
  }
5407
- clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
5408
- if (clientAssertion) {
5454
+ if (this.config.clientCredentials.clientAssertion) {
5455
+ clientAssertion = this.config.clientCredentials.clientAssertion;
5409
5456
  parameterBuilder.addClientAssertion(clientAssertion.assertion);
5410
5457
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
5411
5458
  }
@@ -5635,7 +5682,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5635
5682
  return AuthorizationCodeClient;
5636
5683
  }(BaseClient));
5637
5684
 
5638
- /*! @azure/msal-common v6.4.0 2022-06-06 */
5685
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5639
5686
 
5640
5687
  /*
5641
5688
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5661,7 +5708,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5661
5708
  response = _a.sent();
5662
5709
  responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
5663
5710
  responseHandler.validateTokenResponse(response.body);
5664
- return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true)];
5711
+ return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)];
5665
5712
  }
5666
5713
  });
5667
5714
  });
@@ -5797,8 +5844,8 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5797
5844
  if (this.config.clientCredentials.clientSecret) {
5798
5845
  parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
5799
5846
  }
5800
- clientAssertion = request.clientAssertion || this.config.clientCredentials.clientAssertion;
5801
- if (clientAssertion) {
5847
+ if (this.config.clientCredentials.clientAssertion) {
5848
+ clientAssertion = this.config.clientCredentials.clientAssertion;
5802
5849
  parameterBuilder.addClientAssertion(clientAssertion.assertion);
5803
5850
  parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
5804
5851
  }
@@ -5848,7 +5895,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5848
5895
  return RefreshTokenClient;
5849
5896
  }(BaseClient));
5850
5897
 
5851
- /*! @azure/msal-common v6.4.0 2022-06-06 */
5898
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5852
5899
 
5853
5900
  /*
5854
5901
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5964,7 +6011,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
5964
6011
  return SilentFlowClient;
5965
6012
  }(BaseClient));
5966
6013
 
5967
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6014
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5968
6015
  /*
5969
6016
  * Copyright (c) Microsoft Corporation. All rights reserved.
5970
6017
  * Licensed under the MIT License.
@@ -5972,10 +6019,20 @@ var SilentFlowClient = /** @class */ (function (_super) {
5972
6019
  function isOpenIdConfigResponse(response) {
5973
6020
  return (response.hasOwnProperty("authorization_endpoint") &&
5974
6021
  response.hasOwnProperty("token_endpoint") &&
5975
- response.hasOwnProperty("issuer"));
6022
+ response.hasOwnProperty("issuer") &&
6023
+ response.hasOwnProperty("jwks_uri"));
5976
6024
  }
5977
6025
 
5978
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6026
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6027
+ /*
6028
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6029
+ * Licensed under the MIT License.
6030
+ */
6031
+ 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"] }] } } };
6032
+ var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6033
+ var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6034
+
6035
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5979
6036
  /*
5980
6037
  * Copyright (c) Microsoft Corporation. All rights reserved.
5981
6038
  * Licensed under the MIT License.
@@ -5989,7 +6046,7 @@ exports.ProtocolMode = void 0;
5989
6046
  ProtocolMode["OIDC"] = "OIDC";
5990
6047
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5991
6048
 
5992
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6049
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
5993
6050
 
5994
6051
  /*
5995
6052
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6021,6 +6078,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
6021
6078
  this.end_session_endpoint = metadata.end_session_endpoint;
6022
6079
  this.issuer = metadata.issuer;
6023
6080
  this.endpointsFromNetwork = fromNetwork;
6081
+ this.jwks_uri = metadata.jwks_uri;
6024
6082
  };
6025
6083
  /**
6026
6084
  * Save the authority that was used to create this cache entry
@@ -6059,12 +6117,13 @@ var AuthorityMetadataEntity = /** @class */ (function () {
6059
6117
  entity.hasOwnProperty("issuer") &&
6060
6118
  entity.hasOwnProperty("aliasesFromNetwork") &&
6061
6119
  entity.hasOwnProperty("endpointsFromNetwork") &&
6062
- entity.hasOwnProperty("expiresAt"));
6120
+ entity.hasOwnProperty("expiresAt") &&
6121
+ entity.hasOwnProperty("jwks_uri"));
6063
6122
  };
6064
6123
  return AuthorityMetadataEntity;
6065
6124
  }());
6066
6125
 
6067
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6126
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6068
6127
  /*
6069
6128
  * Copyright (c) Microsoft Corporation. All rights reserved.
6070
6129
  * Licensed under the MIT License.
@@ -6074,7 +6133,7 @@ function isCloudInstanceDiscoveryResponse(response) {
6074
6133
  response.hasOwnProperty("metadata"));
6075
6134
  }
6076
6135
 
6077
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6136
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6078
6137
 
6079
6138
  /*
6080
6139
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6196,7 +6255,7 @@ var RegionDiscovery = /** @class */ (function () {
6196
6255
  return RegionDiscovery;
6197
6256
  }());
6198
6257
 
6199
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6258
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6200
6259
 
6201
6260
  /*
6202
6261
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6381,6 +6440,22 @@ var Authority = /** @class */ (function () {
6381
6440
  enumerable: false,
6382
6441
  configurable: true
6383
6442
  });
6443
+ Object.defineProperty(Authority.prototype, "jwksUri", {
6444
+ /**
6445
+ * Jwks_uri for token signing keys
6446
+ */
6447
+ get: function () {
6448
+ if (this.discoveryComplete()) {
6449
+ var endpoint = this.replacePath(this.metadata.jwks_uri);
6450
+ return this.replaceTenant(endpoint);
6451
+ }
6452
+ else {
6453
+ throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
6454
+ }
6455
+ },
6456
+ enumerable: false,
6457
+ configurable: true
6458
+ });
6384
6459
  /**
6385
6460
  * Replaces tenant in url path with current tenant. Defaults to common.
6386
6461
  * @param urlString
@@ -6464,11 +6539,11 @@ var Authority = /** @class */ (function () {
6464
6539
  * @param metadataEntity
6465
6540
  */
6466
6541
  Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
6467
- var _a;
6542
+ var _a, _b;
6468
6543
  return __awaiter(this, void 0, void 0, function () {
6469
- var metadata, autodetectedRegionName, azureRegion;
6470
- return __generator(this, function (_b) {
6471
- switch (_b.label) {
6544
+ var metadata, harcodedMetadata;
6545
+ return __generator(this, function (_c) {
6546
+ switch (_c.label) {
6472
6547
  case 0:
6473
6548
  metadata = this.getEndpointMetadataFromConfig();
6474
6549
  if (metadata) {
@@ -6479,41 +6554,30 @@ var Authority = /** @class */ (function () {
6479
6554
  // No need to update
6480
6555
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6481
6556
  }
6557
+ harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
6482
6558
  return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
6483
6559
  case 1:
6484
- metadata = _b.sent();
6560
+ metadata = _c.sent();
6485
6561
  if (!metadata) return [3 /*break*/, 4];
6486
6562
  if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
6487
- return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6563
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
6488
6564
  case 2:
6489
- autodetectedRegionName = _b.sent();
6490
- azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
6491
- ? autodetectedRegionName
6492
- : this.authorityOptions.azureRegionConfiguration.azureRegion;
6493
- if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
6494
- this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
6495
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
6496
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
6497
- }
6498
- else {
6499
- if (autodetectedRegionName) {
6500
- this.regionDiscoveryMetadata.region_outcome = (this.authorityOptions.azureRegionConfiguration.azureRegion === autodetectedRegionName) ?
6501
- RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
6502
- RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
6503
- }
6504
- else {
6505
- this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
6506
- }
6507
- }
6508
- if (azureRegion) {
6509
- this.regionDiscoveryMetadata.region_used = azureRegion;
6510
- metadata = Authority.replaceWithRegionalInformation(metadata, azureRegion);
6511
- }
6512
- _b.label = 3;
6565
+ metadata = _c.sent();
6566
+ _c.label = 3;
6513
6567
  case 3:
6514
6568
  metadataEntity.updateEndpointMetadata(metadata, true);
6515
6569
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6516
- case 4: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
6570
+ case 4:
6571
+ if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
6572
+ if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
6573
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
6574
+ case 5:
6575
+ harcodedMetadata = _c.sent();
6576
+ _c.label = 6;
6577
+ case 6:
6578
+ metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
6579
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
6580
+ case 7: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
6517
6581
  }
6518
6582
  });
6519
6583
  });
@@ -6544,6 +6608,8 @@ var Authority = /** @class */ (function () {
6544
6608
  };
6545
6609
  /**
6546
6610
  * Gets OAuth endpoints from the given OpenID configuration endpoint.
6611
+ *
6612
+ * @param hasHardcodedMetadata boolean
6547
6613
  */
6548
6614
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
6549
6615
  return __awaiter(this, void 0, void 0, function () {
@@ -6570,6 +6636,54 @@ var Authority = /** @class */ (function () {
6570
6636
  });
6571
6637
  });
6572
6638
  };
6639
+ /**
6640
+ * Get OAuth endpoints for common authorities.
6641
+ */
6642
+ Authority.prototype.getEndpointMetadataFromHardcodedValues = function () {
6643
+ if (this.canonicalAuthority in EndpointMetadata) {
6644
+ return EndpointMetadata[this.canonicalAuthority];
6645
+ }
6646
+ return null;
6647
+ };
6648
+ /**
6649
+ * Update the retrieved metadata with regional information.
6650
+ */
6651
+ Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
6652
+ var _a, _b, _c, _d, _e;
6653
+ return __awaiter(this, void 0, void 0, function () {
6654
+ var autodetectedRegionName, azureRegion;
6655
+ return __generator(this, function (_f) {
6656
+ switch (_f.label) {
6657
+ case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6658
+ case 1:
6659
+ autodetectedRegionName = _f.sent();
6660
+ azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
6661
+ ? autodetectedRegionName
6662
+ : (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
6663
+ if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
6664
+ this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
6665
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
6666
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
6667
+ }
6668
+ else {
6669
+ if (autodetectedRegionName) {
6670
+ this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
6671
+ RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
6672
+ RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
6673
+ }
6674
+ else {
6675
+ this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
6676
+ }
6677
+ }
6678
+ if (azureRegion) {
6679
+ this.regionDiscoveryMetadata.region_used = azureRegion;
6680
+ return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, azureRegion)];
6681
+ }
6682
+ return [2 /*return*/, metadata];
6683
+ }
6684
+ });
6685
+ });
6686
+ };
6573
6687
  /**
6574
6688
  * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
6575
6689
  * @param cachedMetadata
@@ -6577,7 +6691,7 @@ var Authority = /** @class */ (function () {
6577
6691
  */
6578
6692
  Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
6579
6693
  return __awaiter(this, void 0, void 0, function () {
6580
- var metadata;
6694
+ var metadata, harcodedMetadata;
6581
6695
  return __generator(this, function (_a) {
6582
6696
  switch (_a.label) {
6583
6697
  case 0:
@@ -6591,6 +6705,7 @@ var Authority = /** @class */ (function () {
6591
6705
  // No need to update
6592
6706
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6593
6707
  }
6708
+ harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
6594
6709
  return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
6595
6710
  case 1:
6596
6711
  metadata = _a.sent();
@@ -6598,6 +6713,10 @@ var Authority = /** @class */ (function () {
6598
6713
  metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
6599
6714
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6600
6715
  }
6716
+ if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
6717
+ metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
6718
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
6719
+ }
6601
6720
  else {
6602
6721
  // Metadata could not be obtained from config, cache or network
6603
6722
  throw ClientConfigurationError.createUntrustedAuthorityError();
@@ -6631,7 +6750,8 @@ var Authority = /** @class */ (function () {
6631
6750
  };
6632
6751
  /**
6633
6752
  * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
6634
- * @param networkInterface
6753
+ *
6754
+ * @param hasHardcodedMetadata boolean
6635
6755
  */
6636
6756
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
6637
6757
  return __awaiter(this, void 0, void 0, function () {
@@ -6651,7 +6771,9 @@ var Authority = /** @class */ (function () {
6651
6771
  return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
6652
6772
  case 2:
6653
6773
  response = _a.sent();
6654
- metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];
6774
+ metadata = isCloudInstanceDiscoveryResponse(response.body)
6775
+ ? response.body.metadata
6776
+ : [];
6655
6777
  if (metadata.length === 0) {
6656
6778
  // If no metadata is returned, authority is untrusted
6657
6779
  return [2 /*return*/, null];
@@ -6671,6 +6793,15 @@ var Authority = /** @class */ (function () {
6671
6793
  });
6672
6794
  });
6673
6795
  };
6796
+ /**
6797
+ * Get cloud discovery metadata for common authorities
6798
+ */
6799
+ Authority.prototype.getCloudDiscoveryMetadataFromHarcodedValues = function () {
6800
+ if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
6801
+ return InstanceDiscoveryMetadata[this.canonicalAuthority];
6802
+ }
6803
+ return null;
6804
+ };
6674
6805
  /**
6675
6806
  * Helper function to determine if this host is included in the knownAuthorities config option
6676
6807
  */
@@ -6786,7 +6917,7 @@ var Authority = /** @class */ (function () {
6786
6917
  return Authority;
6787
6918
  }());
6788
6919
 
6789
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6920
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6790
6921
 
6791
6922
  /*
6792
6923
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6847,7 +6978,7 @@ var AuthorityFactory = /** @class */ (function () {
6847
6978
  return AuthorityFactory;
6848
6979
  }());
6849
6980
 
6850
- /*! @azure/msal-common v6.4.0 2022-06-06 */
6981
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6851
6982
 
6852
6983
  /*
6853
6984
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6878,7 +7009,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
6878
7009
  return ServerTelemetryEntity;
6879
7010
  }());
6880
7011
 
6881
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7012
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6882
7013
 
6883
7014
  /*
6884
7015
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6906,7 +7037,7 @@ var ThrottlingEntity = /** @class */ (function () {
6906
7037
  return ThrottlingEntity;
6907
7038
  }());
6908
7039
 
6909
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7040
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6910
7041
 
6911
7042
  /*
6912
7043
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6923,7 +7054,7 @@ var StubbedNetworkModule = {
6923
7054
  }
6924
7055
  };
6925
7056
 
6926
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7057
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6927
7058
 
6928
7059
  /*
6929
7060
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6968,7 +7099,7 @@ var JoseHeaderError = /** @class */ (function (_super) {
6968
7099
  return JoseHeaderError;
6969
7100
  }(AuthError));
6970
7101
 
6971
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7102
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
6972
7103
 
6973
7104
  /*
6974
7105
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7008,7 +7139,7 @@ var JoseHeader = /** @class */ (function () {
7008
7139
  return JoseHeader;
7009
7140
  }());
7010
7141
 
7011
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7142
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7012
7143
 
7013
7144
  /*
7014
7145
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7067,7 +7198,7 @@ var AuthenticationHeaderParser = /** @class */ (function () {
7067
7198
  return AuthenticationHeaderParser;
7068
7199
  }());
7069
7200
 
7070
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7201
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7071
7202
 
7072
7203
  /*
7073
7204
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7229,7 +7360,7 @@ var ServerTelemetryManager = /** @class */ (function () {
7229
7360
  return ServerTelemetryManager;
7230
7361
  }());
7231
7362
 
7232
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7363
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7233
7364
  /*
7234
7365
  * Copyright (c) Microsoft Corporation. All rights reserved.
7235
7366
  * Licensed under the MIT License.
@@ -7312,6 +7443,19 @@ exports.PerformanceEvents = void 0;
7312
7443
  * Used to acquire a token from Native component when native brokering is enabled.
7313
7444
  */
7314
7445
  PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
7446
+ /**
7447
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
7448
+ */
7449
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
7450
+ /**
7451
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
7452
+ */
7453
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
7454
+ /**
7455
+ * acquireToken API in BrokerClientApplication.
7456
+ * Used to acquire a token on behalf of the embedded application (PW-Broker).
7457
+ */
7458
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
7315
7459
  })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
7316
7460
  /**
7317
7461
  * State of the performance event.
@@ -7326,7 +7470,7 @@ var PerformanceEventStatus;
7326
7470
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7327
7471
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7328
7472
 
7329
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7473
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7330
7474
 
7331
7475
  /*
7332
7476
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7384,7 +7528,7 @@ var PerformanceClient = /** @class */ (function () {
7384
7528
  clientId: this.clientId,
7385
7529
  name: measureName,
7386
7530
  startTimeMs: Date.now(),
7387
- correlationId: eventCorrelationId
7531
+ correlationId: eventCorrelationId,
7388
7532
  };
7389
7533
  // Store in progress events so they can be discarded if not ended properly
7390
7534
  this.cacheEventByCorrelationId(inProgressEvent);
@@ -7529,6 +7673,12 @@ var PerformanceClient = /** @class */ (function () {
7529
7673
  else {
7530
7674
  _this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
7531
7675
  }
7676
+ if (current.accessTokenSize) {
7677
+ previous.accessTokenSize = current.accessTokenSize;
7678
+ }
7679
+ if (current.idTokenSize) {
7680
+ previous.idTokenSize = current.idTokenSize;
7681
+ }
7532
7682
  }
7533
7683
  return previous;
7534
7684
  }, topLevelEvent);
@@ -7596,7 +7746,7 @@ var PerformanceClient = /** @class */ (function () {
7596
7746
  return PerformanceClient;
7597
7747
  }());
7598
7748
 
7599
- /*! @azure/msal-common v6.4.0 2022-06-06 */
7749
+ /*! @azure/msal-common v7.2.0 2022-07-18 */
7600
7750
 
7601
7751
  /*
7602
7752
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7698,7 +7848,7 @@ var BrowserAuthErrorMessage = {
7698
7848
  },
7699
7849
  redirectInIframeError: {
7700
7850
  code: "redirect_in_iframe",
7701
- 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."
7851
+ 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."
7702
7852
  },
7703
7853
  blockTokenRequestsInHiddenIframeError: {
7704
7854
  code: "block_iframe_reload",
@@ -7923,7 +8073,7 @@ var BrowserAuthError = /** @class */ (function (_super) {
7923
8073
  return new BrowserAuthError(BrowserAuthErrorMessage.monitorIframeTimeoutError.code, BrowserAuthErrorMessage.monitorIframeTimeoutError.desc);
7924
8074
  };
7925
8075
  /**
7926
- * Creates an error thrown when navigateWindow is called inside an iframe.
8076
+ * Creates an error thrown when navigateWindow is called inside an iframe or brokered applications.
7927
8077
  * @param windowParentCheck
7928
8078
  */
7929
8079
  BrowserAuthError.createRedirectInIframeError = function (windowParentCheck) {
@@ -8142,7 +8292,8 @@ var BrowserConstants = {
8142
8292
  };
8143
8293
  var NativeConstants = {
8144
8294
  CHANNEL_ID: "53ee284d-920a-4b59-9d30-a60315b26836",
8145
- PREFERRED_EXTENSION_ID: "ppnbnpeolgkicgegkbkbjmhlideopiji"
8295
+ PREFERRED_EXTENSION_ID: "ppnbnpeolgkicgegkbkbjmhlideopiji",
8296
+ MATS_TELEMETRY: "MATS"
8146
8297
  };
8147
8298
  var NativeExtensionMethod;
8148
8299
  (function (NativeExtensionMethod) {
@@ -8815,26 +8966,57 @@ var BrowserCacheManager = /** @class */ (function (_super) {
8815
8966
  * Gets the active account
8816
8967
  */
8817
8968
  BrowserCacheManager.prototype.getActiveAccount = function () {
8818
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8819
- var activeAccountId = this.browserStorage.getItem(activeAccountIdKey);
8820
- if (!activeAccountId) {
8969
+ var activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
8970
+ var activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
8971
+ if (!activeAccountValueFilters) {
8972
+ // if new active account cache type isn't found, it's an old version, so look for that instead
8973
+ this.logger.trace("No active account filters cache schema found, looking for legacy schema");
8974
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8975
+ var activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
8976
+ if (!activeAccountValueLocal) {
8977
+ this.logger.trace("No active account found");
8978
+ return null;
8979
+ }
8980
+ var activeAccount = this.getAccountInfoByFilter({ localAccountId: activeAccountValueLocal })[0] || null;
8981
+ if (activeAccount) {
8982
+ this.logger.trace("Legacy active account cache schema found");
8983
+ this.logger.trace("Adding active account filters cache schema");
8984
+ this.setActiveAccount(activeAccount);
8985
+ return activeAccount;
8986
+ }
8821
8987
  return null;
8822
8988
  }
8823
- return this.getAccountInfoByFilter({ localAccountId: activeAccountId })[0] || null;
8989
+ var activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters);
8990
+ if (activeAccountValueObj) {
8991
+ this.logger.trace("Active account filters schema found");
8992
+ return this.getAccountInfoByFilter({
8993
+ homeAccountId: activeAccountValueObj.homeAccountId,
8994
+ localAccountId: activeAccountValueObj.localAccountId
8995
+ })[0] || null;
8996
+ }
8997
+ this.logger.trace("No active account found");
8998
+ return null;
8824
8999
  };
8825
9000
  /**
8826
9001
  * Sets the active account's localAccountId in cache
8827
9002
  * @param account
8828
9003
  */
8829
9004
  BrowserCacheManager.prototype.setActiveAccount = function (account) {
8830
- var activeAccountIdKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
9005
+ var activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);
9006
+ var activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);
8831
9007
  if (account) {
8832
9008
  this.logger.verbose("setActiveAccount: Active account set");
8833
- this.browserStorage.setItem(activeAccountIdKey, account.localAccountId);
9009
+ var activeAccountValue = {
9010
+ homeAccountId: account.homeAccountId,
9011
+ localAccountId: account.localAccountId
9012
+ };
9013
+ this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));
9014
+ this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);
8834
9015
  }
8835
9016
  else {
8836
9017
  this.logger.verbose("setActiveAccount: No account passed, active account not set");
8837
- this.browserStorage.removeItem(activeAccountIdKey);
9018
+ this.browserStorage.removeItem(activeAccountKey);
9019
+ this.browserStorage.removeItem(activeAccountKeyLocal);
8838
9020
  }
8839
9021
  };
8840
9022
  /**
@@ -9020,7 +9202,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9020
9202
  * @param expires
9021
9203
  */
9022
9204
  BrowserCacheManager.prototype.setItemCookie = function (cookieName, cookieValue, expires) {
9023
- var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;";
9205
+ var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;SameSite=Lax;";
9024
9206
  if (expires) {
9025
9207
  var expireTime = this.getCookieExpirationTime(expires);
9026
9208
  cookieStr += "expires=" + expireTime + ";";
@@ -9392,7 +9574,7 @@ var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
9392
9574
 
9393
9575
  /* eslint-disable header/header */
9394
9576
  var name = "@azure/msal-browser";
9395
- var version = "2.25.0";
9577
+ var version = "2.28.0";
9396
9578
 
9397
9579
  /*
9398
9580
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10173,6 +10355,7 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10173
10355
  knownAuthorities: this.config.auth.knownAuthorities,
10174
10356
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10175
10357
  authorityMetadata: this.config.auth.authorityMetadata,
10358
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache
10176
10359
  };
10177
10360
  userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
10178
10361
  builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
@@ -10186,6 +10369,8 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10186
10369
  })
10187
10370
  .catch(function (error) {
10188
10371
  getAuthorityMeasurement.endMeasurement({
10372
+ errorCode: error.errorCode,
10373
+ subErrorCode: error.subError,
10189
10374
  success: false
10190
10375
  });
10191
10376
  throw error;
@@ -10561,6 +10746,7 @@ var NativeStatusCode;
10561
10746
  NativeStatusCode["TRANSIENT_ERROR"] = "TRANSIENT_ERROR";
10562
10747
  NativeStatusCode["PERSISTENT_ERROR"] = "PERSISTENT_ERROR";
10563
10748
  NativeStatusCode["DISABLED"] = "DISABLED";
10749
+ NativeStatusCode["ACCOUNT_UNAVAILABLE"] = "ACCOUNT_UNAVAILABLE";
10564
10750
  })(NativeStatusCode || (NativeStatusCode = {}));
10565
10751
  var NativeAuthErrorMessage = {
10566
10752
  extensionError: {
@@ -10569,6 +10755,10 @@ var NativeAuthErrorMessage = {
10569
10755
  userSwitch: {
10570
10756
  code: "user_switch",
10571
10757
  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."
10758
+ },
10759
+ tokensNotFoundInCache: {
10760
+ code: "tokens_not_found_in_internal_memory_cache",
10761
+ desc: "Tokens not cached in MSAL JS internal memory, please make the WAM request"
10572
10762
  }
10573
10763
  };
10574
10764
  var NativeAuthError = /** @class */ (function (_super) {
@@ -10604,6 +10794,8 @@ var NativeAuthError = /** @class */ (function (_super) {
10604
10794
  NativeAuthError.createError = function (code, description, ext) {
10605
10795
  if (ext && ext.status) {
10606
10796
  switch (ext.status) {
10797
+ case NativeStatusCode.ACCOUNT_UNAVAILABLE:
10798
+ return InteractionRequiredAuthError.createNativeAccountUnavailableError();
10607
10799
  case NativeStatusCode.USER_INTERACTION_REQUIRED:
10608
10800
  return new InteractionRequiredAuthError(code, description);
10609
10801
  case NativeStatusCode.USER_CANCEL:
@@ -10621,20 +10813,122 @@ var NativeAuthError = /** @class */ (function (_super) {
10621
10813
  NativeAuthError.createUserSwitchError = function () {
10622
10814
  return new NativeAuthError(NativeAuthErrorMessage.userSwitch.code, NativeAuthErrorMessage.userSwitch.desc);
10623
10815
  };
10816
+ /**
10817
+ * Creates a tokens not found error when the internal cache look up fails
10818
+ * @returns NativeAuthError: tokensNotFoundInCache
10819
+ */
10820
+ NativeAuthError.createTokensNotFoundInCacheError = function () {
10821
+ return new NativeAuthError(NativeAuthErrorMessage.tokensNotFoundInCache.code, NativeAuthErrorMessage.tokensNotFoundInCache.desc);
10822
+ };
10624
10823
  return NativeAuthError;
10625
10824
  }(AuthError));
10626
10825
 
10826
+ /*
10827
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10828
+ * Licensed under the MIT License.
10829
+ */
10830
+ var SilentCacheClient = /** @class */ (function (_super) {
10831
+ __extends$1(SilentCacheClient, _super);
10832
+ function SilentCacheClient() {
10833
+ return _super !== null && _super.apply(this, arguments) || this;
10834
+ }
10835
+ /**
10836
+ * Returns unexpired tokens from the cache, if available
10837
+ * @param silentRequest
10838
+ */
10839
+ SilentCacheClient.prototype.acquireToken = function (silentRequest) {
10840
+ return __awaiter$1(this, void 0, void 0, function () {
10841
+ var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
10842
+ return __generator$1(this, function (_a) {
10843
+ switch (_a.label) {
10844
+ case 0:
10845
+ acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
10846
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
10847
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
10848
+ case 1:
10849
+ silentAuthClient = _a.sent();
10850
+ this.logger.verbose("Silent auth client created");
10851
+ _a.label = 2;
10852
+ case 2:
10853
+ _a.trys.push([2, 4, , 5]);
10854
+ return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
10855
+ case 3:
10856
+ cachedToken = _a.sent();
10857
+ acquireTokenMeasurement.endMeasurement({
10858
+ success: true,
10859
+ fromCache: true
10860
+ });
10861
+ return [2 /*return*/, cachedToken];
10862
+ case 4:
10863
+ error_1 = _a.sent();
10864
+ if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
10865
+ this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
10866
+ }
10867
+ acquireTokenMeasurement.endMeasurement({
10868
+ errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
10869
+ subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
10870
+ success: false
10871
+ });
10872
+ throw error_1;
10873
+ case 5: return [2 /*return*/];
10874
+ }
10875
+ });
10876
+ });
10877
+ };
10878
+ /**
10879
+ * Currently Unsupported
10880
+ */
10881
+ SilentCacheClient.prototype.logout = function () {
10882
+ // Synchronous so we must reject
10883
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
10884
+ };
10885
+ /**
10886
+ * Creates an Silent Flow Client with the given authority, or the default authority.
10887
+ * @param serverTelemetryManager
10888
+ * @param authorityUrl
10889
+ */
10890
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
10891
+ return __awaiter$1(this, void 0, void 0, function () {
10892
+ var clientConfig;
10893
+ return __generator$1(this, function (_a) {
10894
+ switch (_a.label) {
10895
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
10896
+ case 1:
10897
+ clientConfig = _a.sent();
10898
+ return [2 /*return*/, new SilentFlowClient(clientConfig)];
10899
+ }
10900
+ });
10901
+ });
10902
+ };
10903
+ SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
10904
+ return __awaiter$1(this, void 0, void 0, function () {
10905
+ var _a;
10906
+ return __generator$1(this, function (_b) {
10907
+ switch (_b.label) {
10908
+ case 0:
10909
+ _a = [__assign$1({}, request)];
10910
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
10911
+ 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 }])];
10912
+ }
10913
+ });
10914
+ });
10915
+ };
10916
+ return SilentCacheClient;
10917
+ }(StandardInteractionClient));
10918
+
10627
10919
  /*
10628
10920
  * Copyright (c) Microsoft Corporation. All rights reserved.
10629
10921
  * Licensed under the MIT License.
10630
10922
  */
10631
10923
  var NativeInteractionClient = /** @class */ (function (_super) {
10632
10924
  __extends$1(NativeInteractionClient, _super);
10633
- function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, correlationId) {
10925
+ function NativeInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId) {
10634
10926
  var _this = _super.call(this, config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId) || this;
10635
10927
  _this.apiId = apiId;
10636
10928
  _this.accountId = accountId;
10637
10929
  _this.nativeMessageHandler = provider;
10930
+ _this.nativeStorageManager = nativeStorageImpl;
10931
+ _this.silentCacheClient = new SilentCacheClient(config, _this.nativeStorageManager, browserCrypto, logger, eventHandler, navigationClient, performanceClient, provider, correlationId);
10638
10932
  return _this;
10639
10933
  }
10640
10934
  /**
@@ -10643,22 +10937,40 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10643
10937
  */
10644
10938
  NativeInteractionClient.prototype.acquireToken = function (request) {
10645
10939
  return __awaiter$1(this, void 0, void 0, function () {
10646
- var nativeATMeasurement, nativeRequest, messageBody, reqTimestamp, response, validatedResponse;
10940
+ var nativeATMeasurement, reqTimestamp, nativeRequest, result, messageBody, response, validatedResponse;
10647
10941
  return __generator$1(this, function (_a) {
10648
10942
  switch (_a.label) {
10649
10943
  case 0:
10650
10944
  this.logger.trace("NativeInteractionClient - acquireToken called.");
10651
10945
  nativeATMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.NativeInteractionClientAcquireToken, request.correlationId);
10946
+ reqTimestamp = TimeUtils.nowSeconds();
10652
10947
  return [4 /*yield*/, this.initializeNativeRequest(request)];
10653
10948
  case 1:
10654
10949
  nativeRequest = _a.sent();
10950
+ _a.label = 2;
10951
+ case 2:
10952
+ _a.trys.push([2, 4, , 5]);
10953
+ return [4 /*yield*/, this.acquireTokensFromCache(this.accountId, nativeRequest)];
10954
+ case 3:
10955
+ result = _a.sent();
10956
+ nativeATMeasurement.endMeasurement({
10957
+ success: true,
10958
+ isNativeBroker: true,
10959
+ fromCache: true
10960
+ });
10961
+ return [2 /*return*/, result];
10962
+ case 4:
10963
+ _a.sent();
10964
+ // continue with a native call for any and all errors
10965
+ this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call");
10966
+ return [3 /*break*/, 5];
10967
+ case 5:
10655
10968
  messageBody = {
10656
10969
  method: NativeExtensionMethod.GetToken,
10657
10970
  request: nativeRequest
10658
10971
  };
10659
- reqTimestamp = TimeUtils.nowSeconds();
10660
10972
  return [4 /*yield*/, this.nativeMessageHandler.sendMessage(messageBody)];
10661
- case 2:
10973
+ case 6:
10662
10974
  response = _a.sent();
10663
10975
  validatedResponse = this.validateNativeResponse(response);
10664
10976
  return [2 /*return*/, this.handleNativeResponse(validatedResponse, nativeRequest, reqTimestamp)
@@ -10672,6 +10984,8 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10672
10984
  .catch(function (error) {
10673
10985
  nativeATMeasurement.endMeasurement({
10674
10986
  success: false,
10987
+ errorCode: error.errorCode,
10988
+ subErrorCode: error.subError,
10675
10989
  isNativeBroker: true
10676
10990
  });
10677
10991
  throw error;
@@ -10680,13 +10994,61 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10680
10994
  });
10681
10995
  });
10682
10996
  };
10997
+ /**
10998
+ * Creates silent flow request
10999
+ * @param request
11000
+ * @param cachedAccount
11001
+ * @returns CommonSilentFlowRequest
11002
+ */
11003
+ NativeInteractionClient.prototype.createSilentCacheRequest = function (request, cachedAccount) {
11004
+ return {
11005
+ authority: request.authority,
11006
+ correlationId: this.correlationId,
11007
+ scopes: ScopeSet.fromString(request.scopes).asArray(),
11008
+ account: cachedAccount,
11009
+ forceRefresh: false,
11010
+ };
11011
+ };
11012
+ /**
11013
+ * Fetches the tokens from the cache if un-expired
11014
+ * @param nativeAccountId
11015
+ * @param request
11016
+ * @returns authenticationResult
11017
+ */
11018
+ NativeInteractionClient.prototype.acquireTokensFromCache = function (nativeAccountId, request) {
11019
+ return __awaiter$1(this, void 0, void 0, function () {
11020
+ var accountEntity, account, silentRequest, result, e_2;
11021
+ return __generator$1(this, function (_a) {
11022
+ switch (_a.label) {
11023
+ case 0:
11024
+ accountEntity = this.browserStorage.readAccountFromCacheWithNativeAccountId(nativeAccountId);
11025
+ if (!accountEntity) {
11026
+ throw ClientAuthError.createNoAccountFoundError();
11027
+ }
11028
+ account = accountEntity.getAccountInfo();
11029
+ _a.label = 1;
11030
+ case 1:
11031
+ _a.trys.push([1, 3, , 4]);
11032
+ silentRequest = this.createSilentCacheRequest(request, account);
11033
+ return [4 /*yield*/, this.silentCacheClient.acquireToken(silentRequest)];
11034
+ case 2:
11035
+ result = _a.sent();
11036
+ return [2 /*return*/, result];
11037
+ case 3:
11038
+ e_2 = _a.sent();
11039
+ throw e_2;
11040
+ case 4: return [2 /*return*/];
11041
+ }
11042
+ });
11043
+ });
11044
+ };
10683
11045
  /**
10684
11046
  * Acquires a token from native platform then redirects to the redirectUri instead of returning the response
10685
11047
  * @param request
10686
11048
  */
10687
11049
  NativeInteractionClient.prototype.acquireTokenRedirect = function (request) {
10688
11050
  return __awaiter$1(this, void 0, void 0, function () {
10689
- var nativeRequest, messageBody, response, e_1, navigationOptions, redirectUri;
11051
+ var nativeRequest, messageBody, response, e_3, navigationOptions, redirectUri;
10690
11052
  return __generator$1(this, function (_a) {
10691
11053
  switch (_a.label) {
10692
11054
  case 0:
@@ -10707,10 +11069,10 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10707
11069
  this.validateNativeResponse(response);
10708
11070
  return [3 /*break*/, 5];
10709
11071
  case 4:
10710
- e_1 = _a.sent();
11072
+ e_3 = _a.sent();
10711
11073
  // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
10712
- if (e_1 instanceof NativeAuthError && e_1.isFatal()) {
10713
- throw e_1;
11074
+ if (e_3 instanceof NativeAuthError && e_3.isFatal()) {
11075
+ throw e_3;
10714
11076
  }
10715
11077
  return [3 /*break*/, 5];
10716
11078
  case 5:
@@ -10734,7 +11096,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10734
11096
  */
10735
11097
  NativeInteractionClient.prototype.handleRedirectPromise = function () {
10736
11098
  return __awaiter$1(this, void 0, void 0, function () {
10737
- var cachedRequest, messageBody, reqTimestamp, response, result, e_2;
11099
+ var cachedRequest, messageBody, reqTimestamp, response, result, e_4;
10738
11100
  return __generator$1(this, function (_a) {
10739
11101
  switch (_a.label) {
10740
11102
  case 0:
@@ -10766,9 +11128,9 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10766
11128
  this.browserStorage.setInteractionInProgress(false);
10767
11129
  return [2 /*return*/, result];
10768
11130
  case 3:
10769
- e_2 = _a.sent();
11131
+ e_4 = _a.sent();
10770
11132
  this.browserStorage.setInteractionInProgress(false);
10771
- throw e_2;
11133
+ throw e_4;
10772
11134
  case 4: return [2 /*return*/];
10773
11135
  }
10774
11136
  });
@@ -10790,7 +11152,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10790
11152
  */
10791
11153
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
10792
11154
  return __awaiter$1(this, void 0, void 0, function () {
10793
- var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, result;
11155
+ var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result, idTokenEntity, expiresIn, tokenExpirationSeconds, accessTokenEntity;
10794
11156
  var _this = this;
10795
11157
  return __generator$1(this, function (_b) {
10796
11158
  switch (_b.label) {
@@ -10806,7 +11168,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10806
11168
  authority = _b.sent();
10807
11169
  authorityPreferredCache = authority.getPreferredCache();
10808
11170
  homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
10809
- accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
11171
+ accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
10810
11172
  this.browserStorage.setAccount(accountEntity);
10811
11173
  responseScopes = response.scopes ? ScopeSet.fromString(response.scopes) : ScopeSet.fromString(request.scopes);
10812
11174
  accountProperties = response.account.properties || {};
@@ -10851,6 +11213,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10851
11213
  }
10852
11214
  _b.label = 5;
10853
11215
  case 5:
11216
+ mats = this.getMATSFromResponse(response);
10854
11217
  result = {
10855
11218
  authority: authority.canonicalAuthority,
10856
11219
  uniqueId: uid,
@@ -10860,14 +11223,24 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10860
11223
  idToken: response.id_token,
10861
11224
  idTokenClaims: idTokenObj.claims,
10862
11225
  accessToken: responseAccessToken,
10863
- fromCache: false,
11226
+ fromCache: mats ? this.isResponseFromCache(mats) : false,
10864
11227
  expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
10865
11228
  tokenType: responseTokenType,
10866
11229
  correlationId: this.correlationId,
10867
11230
  state: response.state,
10868
11231
  fromNativeBroker: true
10869
11232
  };
10870
- // Remove any existing cached tokens for this account
11233
+ idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountIdentifier, request.authority, response.id_token || Constants.EMPTY_STRING, request.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
11234
+ this.nativeStorageManager.setIdTokenCredential(idTokenEntity);
11235
+ expiresIn = (responseTokenType === exports.AuthenticationScheme.POP)
11236
+ ? Constants.SHR_NONCE_VALIDITY
11237
+ : (typeof response.expires_in === "string"
11238
+ ? parseInt(response.expires_in, 10)
11239
+ : response.expires_in) || 0;
11240
+ tokenExpirationSeconds = reqTimestamp + expiresIn;
11241
+ accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountIdentifier, request.authority, responseAccessToken, request.clientId, tid, responseScopes.printScopes(), tokenExpirationSeconds, 0, this.browserCrypto);
11242
+ this.nativeStorageManager.setAccessTokenCredential(accessTokenEntity);
11243
+ // Remove any existing cached tokens for this account in browser storage
10871
11244
  this.browserStorage.removeAccountContext(accountEntity).catch(function (e) {
10872
11245
  _this.logger.error("Error occurred while removing account context from browser storage. " + e);
10873
11246
  });
@@ -10893,13 +11266,42 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10893
11266
  throw NativeAuthError.createUnexpectedError("Response missing expected properties.");
10894
11267
  }
10895
11268
  };
11269
+ /**
11270
+ * Gets MATS telemetry from native response
11271
+ * @param response
11272
+ * @returns
11273
+ */
11274
+ NativeInteractionClient.prototype.getMATSFromResponse = function (response) {
11275
+ if (response.properties.MATS) {
11276
+ try {
11277
+ return JSON.parse(response.properties.MATS);
11278
+ }
11279
+ catch (e) {
11280
+ this.logger.error("NativeInteractionClient - Error parsing MATS telemetry, returning null instead");
11281
+ }
11282
+ }
11283
+ return null;
11284
+ };
11285
+ /**
11286
+ * Returns whether or not response came from native cache
11287
+ * @param response
11288
+ * @returns
11289
+ */
11290
+ NativeInteractionClient.prototype.isResponseFromCache = function (mats) {
11291
+ if (typeof mats.is_cached === "undefined") {
11292
+ this.logger.verbose("NativeInteractionClient - MATS telemetry does not contain field indicating if response was served from cache. Returning false.");
11293
+ return false;
11294
+ }
11295
+ return !!mats.is_cached;
11296
+ };
10896
11297
  /**
10897
11298
  * Translates developer provided request object into NativeRequest object
10898
11299
  * @param request
10899
11300
  */
10900
11301
  NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
10901
11302
  return __awaiter$1(this, void 0, void 0, function () {
10902
- var authority, canonicalAuthority, scopes, scopeSet, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11303
+ var authority, canonicalAuthority, scopes, scopeSet, getPrompt, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11304
+ var _this = this;
10903
11305
  return __generator$1(this, function (_a) {
10904
11306
  switch (_a.label) {
10905
11307
  case 0:
@@ -10910,18 +11312,32 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10910
11312
  scopes = request && request.scopes || [];
10911
11313
  scopeSet = new ScopeSet(scopes);
10912
11314
  scopeSet.appendScopes(OIDC_DEFAULT_SCOPES);
10913
- if (request.prompt) {
11315
+ getPrompt = function () {
11316
+ // If request is silent, prompt is always none
11317
+ switch (_this.apiId) {
11318
+ case exports.ApiId.ssoSilent:
11319
+ case exports.ApiId.acquireTokenSilent_silentFlow:
11320
+ _this.logger.trace("initializeNativeRequest: silent request sets prompt to none");
11321
+ return PromptValue.NONE;
11322
+ }
11323
+ // Prompt not provided, request may proceed and native broker decides if it needs to prompt
11324
+ if (!request.prompt) {
11325
+ _this.logger.trace("initializeNativeRequest: prompt was not provided");
11326
+ return undefined;
11327
+ }
11328
+ // If request is interactive, check if prompt provided is allowed to go directly to native broker
10914
11329
  switch (request.prompt) {
10915
11330
  case PromptValue.NONE:
10916
11331
  case PromptValue.CONSENT:
10917
- this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
10918
- break;
11332
+ case PromptValue.LOGIN:
11333
+ _this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
11334
+ return request.prompt;
10919
11335
  default:
10920
- this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
11336
+ _this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
10921
11337
  throw BrowserAuthError.createNativePromptParameterNotSupportedError();
10922
11338
  }
10923
- }
10924
- 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?
11339
+ };
11340
+ 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?
10925
11341
  });
10926
11342
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
10927
11343
  shrParameters = {
@@ -10938,11 +11354,7 @@ var NativeInteractionClient = /** @class */ (function (_super) {
10938
11354
  validatedRequest.reqCnf = reqCnfData.reqCnfHash;
10939
11355
  validatedRequest.keyId = reqCnfData.kid;
10940
11356
  _a.label = 2;
10941
- case 2:
10942
- if (this.apiId === exports.ApiId.ssoSilent || this.apiId === exports.ApiId.acquireTokenSilent_silentFlow) {
10943
- validatedRequest.prompt = PromptValue.NONE;
10944
- }
10945
- return [2 /*return*/, validatedRequest];
11357
+ case 2: return [2 /*return*/, validatedRequest];
10946
11358
  }
10947
11359
  });
10948
11360
  });
@@ -11192,8 +11604,10 @@ var NativeMessageHandler = /** @class */ (function () {
11192
11604
  */
11193
11605
  var RedirectClient = /** @class */ (function (_super) {
11194
11606
  __extends$1(RedirectClient, _super);
11195
- function RedirectClient() {
11196
- return _super !== null && _super.apply(this, arguments) || this;
11607
+ function RedirectClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11608
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11609
+ _this.nativeStorage = nativeStorageImpl;
11610
+ return _this;
11197
11611
  }
11198
11612
  /**
11199
11613
  * Redirects the page to the /authorize endpoint of the IDP
@@ -11402,7 +11816,7 @@ var RedirectClient = /** @class */ (function (_super) {
11402
11816
  if (!this.nativeMessageHandler) {
11403
11817
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11404
11818
  }
11405
- 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);
11819
+ 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);
11406
11820
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
11407
11821
  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
11408
11822
  })).finally(function () {
@@ -11520,10 +11934,11 @@ var RedirectClient = /** @class */ (function (_super) {
11520
11934
  */
11521
11935
  var PopupClient = /** @class */ (function (_super) {
11522
11936
  __extends$1(PopupClient, _super);
11523
- function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
11937
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
11524
11938
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11525
11939
  // Properly sets this reference for the unload event.
11526
11940
  _this.unloadWindow = _this.unloadWindow.bind(_this);
11941
+ _this.nativeStorage = nativeStorageImpl;
11527
11942
  return _this;
11528
11943
  }
11529
11944
  /**
@@ -11648,7 +12063,7 @@ var PopupClient = /** @class */ (function (_super) {
11648
12063
  if (!this.nativeMessageHandler) {
11649
12064
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
11650
12065
  }
11651
- 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);
12066
+ 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);
11652
12067
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state_1).userRequestState;
11653
12068
  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
11654
12069
  })).finally(function () {
@@ -12084,6 +12499,7 @@ function buildConfiguration(_a, isBrowserEnvironment) {
12084
12499
  azureCloudInstance: exports.AzureCloudInstance.None,
12085
12500
  tenant: Constants.EMPTY_STRING
12086
12501
  },
12502
+ skipAuthorityMetadataCache: false,
12087
12503
  };
12088
12504
  // Default cache options for browser
12089
12505
  var DEFAULT_CACHE_OPTIONS = {
@@ -12275,9 +12691,10 @@ var SilentHandler = /** @class */ (function (_super) {
12275
12691
  */
12276
12692
  var SilentIframeClient = /** @class */ (function (_super) {
12277
12693
  __extends$1(SilentIframeClient, _super);
12278
- function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeMessageHandler, correlationId) {
12694
+ function SilentIframeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
12279
12695
  var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
12280
12696
  _this.apiId = apiId;
12697
+ _this.nativeStorage = nativeStorageImpl;
12281
12698
  return _this;
12282
12699
  }
12283
12700
  /**
@@ -12331,6 +12748,8 @@ var SilentIframeClient = /** @class */ (function (_super) {
12331
12748
  serverTelemetryManager.cacheFailedRequest(e_1);
12332
12749
  this.browserStorage.cleanRequestByState(silentRequest.state);
12333
12750
  acquireTokenMeasurement.endMeasurement({
12751
+ errorCode: e_1 instanceof AuthError && e_1.errorCode || undefined,
12752
+ subErrorCode: e_1 instanceof AuthError && e_1.subError || undefined,
12334
12753
  success: false
12335
12754
  });
12336
12755
  throw e_1;
@@ -12378,7 +12797,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
12378
12797
  if (!this.nativeMessageHandler) {
12379
12798
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
12380
12799
  }
12381
- 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);
12800
+ 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);
12382
12801
  userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state).userRequestState;
12383
12802
  return [2 /*return*/, nativeInteractionClient.acquireToken(__assign$1(__assign$1({}, silentRequest), { state: userRequestState, prompt: PromptValue.NONE })).finally(function () {
12384
12803
  _this.browserStorage.cleanRequestByState(state);
@@ -12393,97 +12812,6 @@ var SilentIframeClient = /** @class */ (function (_super) {
12393
12812
  return SilentIframeClient;
12394
12813
  }(StandardInteractionClient));
12395
12814
 
12396
- /*
12397
- * Copyright (c) Microsoft Corporation. All rights reserved.
12398
- * Licensed under the MIT License.
12399
- */
12400
- var SilentCacheClient = /** @class */ (function (_super) {
12401
- __extends$1(SilentCacheClient, _super);
12402
- function SilentCacheClient() {
12403
- return _super !== null && _super.apply(this, arguments) || this;
12404
- }
12405
- /**
12406
- * Returns unexpired tokens from the cache, if available
12407
- * @param silentRequest
12408
- */
12409
- SilentCacheClient.prototype.acquireToken = function (silentRequest) {
12410
- return __awaiter$1(this, void 0, void 0, function () {
12411
- var acquireTokenMeasurement, serverTelemetryManager, silentAuthClient, cachedToken, error_1;
12412
- return __generator$1(this, function (_a) {
12413
- switch (_a.label) {
12414
- case 0:
12415
- acquireTokenMeasurement = this.performanceClient.startMeasurement(exports.PerformanceEvents.SilentCacheClientAcquireToken, silentRequest.correlationId);
12416
- serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12417
- return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12418
- case 1:
12419
- silentAuthClient = _a.sent();
12420
- this.logger.verbose("Silent auth client created");
12421
- _a.label = 2;
12422
- case 2:
12423
- _a.trys.push([2, 4, , 5]);
12424
- return [4 /*yield*/, silentAuthClient.acquireCachedToken(silentRequest)];
12425
- case 3:
12426
- cachedToken = _a.sent();
12427
- acquireTokenMeasurement.endMeasurement({
12428
- success: true,
12429
- fromCache: true
12430
- });
12431
- return [2 /*return*/, cachedToken];
12432
- case 4:
12433
- error_1 = _a.sent();
12434
- if (error_1 instanceof BrowserAuthError && error_1.errorCode === BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code) {
12435
- this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
12436
- }
12437
- acquireTokenMeasurement.endMeasurement({
12438
- success: false
12439
- });
12440
- throw error_1;
12441
- case 5: return [2 /*return*/];
12442
- }
12443
- });
12444
- });
12445
- };
12446
- /**
12447
- * Currently Unsupported
12448
- */
12449
- SilentCacheClient.prototype.logout = function () {
12450
- // Synchronous so we must reject
12451
- return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
12452
- };
12453
- /**
12454
- * Creates an Silent Flow Client with the given authority, or the default authority.
12455
- * @param serverTelemetryManager
12456
- * @param authorityUrl
12457
- */
12458
- SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
12459
- return __awaiter$1(this, void 0, void 0, function () {
12460
- var clientConfig;
12461
- return __generator$1(this, function (_a) {
12462
- switch (_a.label) {
12463
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12464
- case 1:
12465
- clientConfig = _a.sent();
12466
- return [2 /*return*/, new SilentFlowClient(clientConfig)];
12467
- }
12468
- });
12469
- });
12470
- };
12471
- SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
12472
- return __awaiter$1(this, void 0, void 0, function () {
12473
- var _a;
12474
- return __generator$1(this, function (_b) {
12475
- switch (_b.label) {
12476
- case 0:
12477
- _a = [__assign$1({}, request)];
12478
- return [4 /*yield*/, this.initializeBaseRequest(request)];
12479
- 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 }])];
12480
- }
12481
- });
12482
- });
12483
- };
12484
- return SilentCacheClient;
12485
- }(StandardInteractionClient));
12486
-
12487
12815
  /*
12488
12816
  * Copyright (c) Microsoft Corporation. All rights reserved.
12489
12817
  * Licensed under the MIT License.
@@ -12529,6 +12857,8 @@ var SilentRefreshClient = /** @class */ (function (_super) {
12529
12857
  }
12530
12858
  serverTelemetryManager.cacheFailedRequest(e);
12531
12859
  acquireTokenMeasurement.endMeasurement({
12860
+ errorCode: e.errorCode,
12861
+ subErrorCode: e.subError,
12532
12862
  success: false
12533
12863
  });
12534
12864
  throw e;
@@ -14172,6 +14502,7 @@ var TokenCache = /** @class */ (function () {
14172
14502
  knownAuthorities: this.config.auth.knownAuthorities,
14173
14503
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
14174
14504
  authorityMetadata: this.config.auth.authorityMetadata,
14505
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
14175
14506
  };
14176
14507
  var authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
14177
14508
  // "clientInfo" from options takes precedence over "clientInfo" in response
@@ -14205,8 +14536,8 @@ var TokenCache = /** @class */ (function () {
14205
14536
  var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken, this.config.auth.clientId, tenantId);
14206
14537
  var idAuthToken = new AuthToken(idToken, this.cryptoObj);
14207
14538
  var accountEntity = options.clientInfo ?
14208
- AccountEntity.createAccount(options.clientInfo, homeAccountId, idAuthToken, undefined, undefined, undefined, undefined, environment) :
14209
- AccountEntity.createGenericAccount(homeAccountId, idAuthToken, undefined, undefined, undefined, undefined, environment);
14539
+ AccountEntity.createAccount(options.clientInfo, homeAccountId, idAuthToken, undefined, undefined, undefined, environment) :
14540
+ AccountEntity.createGenericAccount(homeAccountId, idAuthToken, undefined, undefined, undefined, environment);
14210
14541
  if (this.isBrowserEnvironment) {
14211
14542
  this.logger.verbose("TokenCache - loading id token");
14212
14543
  this.storage.setAccount(accountEntity);
@@ -14498,6 +14829,13 @@ var ClientApplication = /** @class */ (function () {
14498
14829
  this.browserStorage = this.isBrowserEnvironment ?
14499
14830
  new BrowserCacheManager(this.config.auth.clientId, this.config.cache, this.browserCrypto, this.logger) :
14500
14831
  DEFAULT_BROWSER_CACHE_MANAGER(this.config.auth.clientId, this.logger);
14832
+ // initialize in memory storage for native flows
14833
+ var nativeCacheOptions = {
14834
+ cacheLocation: exports.BrowserCacheLocation.MemoryStorage,
14835
+ storeAuthStateInCookie: false,
14836
+ secureCookies: false
14837
+ };
14838
+ this.nativeInternalStorage = new BrowserCacheManager(this.config.auth.clientId, nativeCacheOptions, this.browserCrypto, this.logger);
14501
14839
  // Initialize the token cache
14502
14840
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
14503
14841
  }
@@ -14564,7 +14902,7 @@ var ClientApplication = /** @class */ (function () {
14564
14902
  redirectResponse = void 0;
14565
14903
  if (request && NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) && this.nativeExtensionProvider && !hash) {
14566
14904
  this.logger.trace("handleRedirectPromise - acquiring token from native platform");
14567
- 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);
14905
+ 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);
14568
14906
  redirectResponse = nativeClient.handleRedirectPromise();
14569
14907
  }
14570
14908
  else {
@@ -14636,13 +14974,19 @@ var ClientApplication = /** @class */ (function () {
14636
14974
  this.eventHandler.emitEvent(exports.EventType.LOGIN_START, exports.InteractionType.Redirect, request);
14637
14975
  }
14638
14976
  if (this.nativeExtensionProvider && this.canUseNative(request)) {
14639
- 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);
14977
+ 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);
14640
14978
  result = nativeClient.acquireTokenRedirect(request).catch(function (e) {
14641
14979
  if (e instanceof NativeAuthError && e.isFatal()) {
14642
14980
  _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
14643
14981
  var redirectClient = _this.createRedirectClient(request.correlationId);
14644
14982
  return redirectClient.acquireToken(request);
14645
14983
  }
14984
+ else if (e instanceof InteractionRequiredAuthError) {
14985
+ _this.logger.verbose("acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow");
14986
+ var redirectClient = _this.createRedirectClient(request.correlationId);
14987
+ return redirectClient.acquireToken(request);
14988
+ }
14989
+ _this.browserStorage.setInteractionInProgress(false);
14646
14990
  throw e;
14647
14991
  });
14648
14992
  }
@@ -14698,7 +15042,9 @@ var ClientApplication = /** @class */ (function () {
14698
15042
  _this.browserStorage.setInteractionInProgress(false);
14699
15043
  atPopupMeasurement.endMeasurement({
14700
15044
  success: true,
14701
- isNativeBroker: true
15045
+ isNativeBroker: true,
15046
+ accessTokenSize: response.accessToken.length,
15047
+ idTokenSize: response.idToken.length,
14702
15048
  });
14703
15049
  atPopupMeasurement.flushMeasurement();
14704
15050
  return response;
@@ -14708,6 +15054,12 @@ var ClientApplication = /** @class */ (function () {
14708
15054
  var popupClient = _this.createPopupClient(request.correlationId);
14709
15055
  return popupClient.acquireToken(request);
14710
15056
  }
15057
+ else if (e instanceof InteractionRequiredAuthError) {
15058
+ _this.logger.verbose("acquireTokenPopup - Resolving interaction required error thrown by native broker by falling back to web flow");
15059
+ var popupClient = _this.createPopupClient(request.correlationId);
15060
+ return popupClient.acquireToken(request);
15061
+ }
15062
+ _this.browserStorage.setInteractionInProgress(false);
14711
15063
  throw e;
14712
15064
  });
14713
15065
  }
@@ -14716,7 +15068,9 @@ var ClientApplication = /** @class */ (function () {
14716
15068
  result = popupClient.acquireToken(request);
14717
15069
  }
14718
15070
  return result.then(function (result) {
14719
- // If logged in, emit acquire token events
15071
+ /*
15072
+ * If logged in, emit acquire token events
15073
+ */
14720
15074
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
14721
15075
  if (isLoggingIn) {
14722
15076
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_SUCCESS, exports.InteractionType.Popup, result);
@@ -14725,7 +15079,9 @@ var ClientApplication = /** @class */ (function () {
14725
15079
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Popup, result);
14726
15080
  }
14727
15081
  atPopupMeasurement.endMeasurement({
14728
- success: true
15082
+ success: true,
15083
+ accessTokenSize: result.accessToken.length,
15084
+ idTokenSize: result.idToken.length,
14729
15085
  });
14730
15086
  atPopupMeasurement.flushMeasurement();
14731
15087
  return result;
@@ -14737,6 +15093,8 @@ var ClientApplication = /** @class */ (function () {
14737
15093
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_FAILURE, exports.InteractionType.Popup, null, e);
14738
15094
  }
14739
15095
  atPopupMeasurement.endMeasurement({
15096
+ errorCode: e.errorCode,
15097
+ subErrorCode: e.subError,
14740
15098
  success: false
14741
15099
  });
14742
15100
  atPopupMeasurement.flushMeasurement();
@@ -14790,13 +15148,18 @@ var ClientApplication = /** @class */ (function () {
14790
15148
  return [2 /*return*/, result.then(function (response) {
14791
15149
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
14792
15150
  ssoSilentMeasurement.endMeasurement({
14793
- success: true
15151
+ success: true,
15152
+ isNativeBroker: response.fromNativeBroker,
15153
+ accessTokenSize: response.accessToken.length,
15154
+ idTokenSize: response.idToken.length
14794
15155
  });
14795
15156
  ssoSilentMeasurement.flushMeasurement();
14796
15157
  return response;
14797
15158
  }).catch(function (e) {
14798
15159
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
14799
15160
  ssoSilentMeasurement.endMeasurement({
15161
+ errorCode: e.errorCode,
15162
+ subErrorCode: e.subError,
14800
15163
  success: false
14801
15164
  });
14802
15165
  ssoSilentMeasurement.flushMeasurement();
@@ -14836,7 +15199,10 @@ var ClientApplication = /** @class */ (function () {
14836
15199
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
14837
15200
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
14838
15201
  atbcMeasurement.endMeasurement({
14839
- success: true
15202
+ success: true,
15203
+ accessTokenSize: result.accessToken.length,
15204
+ idTokenSize: result.idToken.length,
15205
+ isNativeBroker: result.fromNativeBroker
14840
15206
  });
14841
15207
  atbcMeasurement.flushMeasurement();
14842
15208
  return result;
@@ -14845,6 +15211,8 @@ var ClientApplication = /** @class */ (function () {
14845
15211
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
14846
15212
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
14847
15213
  atbcMeasurement.endMeasurement({
15214
+ errorCode: error.errorCode,
15215
+ subErrorCode: error.subError,
14848
15216
  success: false
14849
15217
  });
14850
15218
  atbcMeasurement.flushMeasurement();
@@ -14882,6 +15250,8 @@ var ClientApplication = /** @class */ (function () {
14882
15250
  catch (e) {
14883
15251
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
14884
15252
  atbcMeasurement.endMeasurement({
15253
+ errorCode: e instanceof AuthError && e.errorCode || undefined,
15254
+ subErrorCode: e instanceof AuthError && e.subError || undefined,
14885
15255
  success: false
14886
15256
  });
14887
15257
  throw e;
@@ -14936,7 +15306,9 @@ var ClientApplication = /** @class */ (function () {
14936
15306
  .then(function (result) {
14937
15307
  atbrtMeasurement.endMeasurement({
14938
15308
  success: true,
14939
- fromCache: result.fromCache
15309
+ fromCache: result.fromCache,
15310
+ accessTokenSize: result.accessToken.length,
15311
+ idTokenSize: result.idToken.length,
14940
15312
  });
14941
15313
  return result;
14942
15314
  })
@@ -14951,12 +15323,16 @@ var ClientApplication = /** @class */ (function () {
14951
15323
  .then(function (result) {
14952
15324
  atbrtMeasurement.endMeasurement({
14953
15325
  success: true,
14954
- fromCache: result.fromCache
15326
+ fromCache: result.fromCache,
15327
+ accessTokenSize: result.accessToken.length,
15328
+ idTokenSize: result.idToken.length,
14955
15329
  });
14956
15330
  return result;
14957
15331
  })
14958
15332
  .catch(function (error) {
14959
15333
  atbrtMeasurement.endMeasurement({
15334
+ errorCode: error.errorCode,
15335
+ subErrorCode: error.subError,
14960
15336
  success: false
14961
15337
  });
14962
15338
  throw error;
@@ -15106,9 +15482,13 @@ var ClientApplication = /** @class */ (function () {
15106
15482
  // #region Helpers
15107
15483
  /**
15108
15484
  * Helper to validate app environment before making an auth request
15109
- * * @param interactionType
15485
+ *
15486
+ * @protected
15487
+ * @param {InteractionType} interactionType What kind of interaction is being used
15488
+ * @param {boolean} [setInteractionInProgress=true] Whether to set interaction in progress temp cache flag
15110
15489
  */
15111
- ClientApplication.prototype.preflightBrowserEnvironmentCheck = function (interactionType) {
15490
+ ClientApplication.prototype.preflightBrowserEnvironmentCheck = function (interactionType, setInteractionInProgress) {
15491
+ if (setInteractionInProgress === void 0) { setInteractionInProgress = true; }
15112
15492
  this.logger.verbose("preflightBrowserEnvironmentCheck started");
15113
15493
  // Block request if not in browser environment
15114
15494
  BrowserUtils.blockNonBrowserEnvironment(this.isBrowserEnvironment);
@@ -15127,20 +15507,23 @@ var ClientApplication = /** @class */ (function () {
15127
15507
  throw BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError();
15128
15508
  }
15129
15509
  if (interactionType === exports.InteractionType.Redirect || interactionType === exports.InteractionType.Popup) {
15130
- this.preflightInteractiveRequest();
15510
+ this.preflightInteractiveRequest(setInteractionInProgress);
15131
15511
  }
15132
15512
  };
15133
15513
  /**
15134
- * Helper to validate app environment before making a request.
15135
- * @param request
15136
- * @param interactionType
15514
+ * Preflight check for interactive requests
15515
+ *
15516
+ * @protected
15517
+ * @param {boolean} setInteractionInProgress Whether to set interaction in progress temp cache flag
15137
15518
  */
15138
- ClientApplication.prototype.preflightInteractiveRequest = function () {
15519
+ ClientApplication.prototype.preflightInteractiveRequest = function (setInteractionInProgress) {
15139
15520
  this.logger.verbose("preflightInteractiveRequest called, validating app environment");
15140
15521
  // block the reload if it occurred inside a hidden iframe
15141
15522
  BrowserUtils.blockReloadInHiddenIframes();
15142
15523
  // Set interaction in progress temporary cache or throw if alread set.
15143
- this.browserStorage.setInteractionInProgress(true);
15524
+ if (setInteractionInProgress) {
15525
+ this.browserStorage.setInteractionInProgress(true);
15526
+ }
15144
15527
  };
15145
15528
  /**
15146
15529
  * Acquire a token from native device (e.g. WAM)
@@ -15154,7 +15537,7 @@ var ClientApplication = /** @class */ (function () {
15154
15537
  if (!this.nativeExtensionProvider) {
15155
15538
  throw BrowserAuthError.createNativeConnectionNotEstablishedError();
15156
15539
  }
15157
- 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);
15540
+ 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);
15158
15541
  return [2 /*return*/, nativeClient.acquireToken(request)];
15159
15542
  });
15160
15543
  });
@@ -15173,6 +15556,7 @@ var ClientApplication = /** @class */ (function () {
15173
15556
  switch (request.prompt) {
15174
15557
  case PromptValue.NONE:
15175
15558
  case PromptValue.CONSENT:
15559
+ case PromptValue.LOGIN:
15176
15560
  this.logger.trace("canUseNative: prompt is compatible with native flow");
15177
15561
  break;
15178
15562
  default:
@@ -15200,21 +15584,21 @@ var ClientApplication = /** @class */ (function () {
15200
15584
  * @param correlationId
15201
15585
  */
15202
15586
  ClientApplication.prototype.createPopupClient = function (correlationId) {
15203
- return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15587
+ return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15204
15588
  };
15205
15589
  /**
15206
- * Returns new instance of the Popup Interaction Client
15590
+ * Returns new instance of the Redirect Interaction Client
15207
15591
  * @param correlationId
15208
15592
  */
15209
15593
  ClientApplication.prototype.createRedirectClient = function (correlationId) {
15210
- return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15594
+ return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeInternalStorage, this.nativeExtensionProvider, correlationId);
15211
15595
  };
15212
15596
  /**
15213
15597
  * Returns new instance of the Silent Iframe Interaction Client
15214
15598
  * @param correlationId
15215
15599
  */
15216
15600
  ClientApplication.prototype.createSilentIframeClient = function (correlationId) {
15217
- return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.ssoSilent, this.performanceClient, this.nativeExtensionProvider, correlationId);
15601
+ 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);
15218
15602
  };
15219
15603
  /**
15220
15604
  * Returns new instance of the Silent Cache Interaction Client
@@ -15449,7 +15833,10 @@ var PublicClientApplication = /** @class */ (function (_super) {
15449
15833
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15450
15834
  atsMeasurement.endMeasurement({
15451
15835
  success: true,
15452
- fromCache: result.fromCache
15836
+ fromCache: result.fromCache,
15837
+ accessTokenSize: result.accessToken.length,
15838
+ idTokenSize: result.idToken.length,
15839
+ isNativeBroker: result.fromNativeBroker
15453
15840
  });
15454
15841
  atsMeasurement.flushMeasurement();
15455
15842
  return result;
@@ -15525,12 +15912,17 @@ var PublicClientApplication = /** @class */ (function (_super) {
15525
15912
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
15526
15913
  astsAsyncMeasurement.endMeasurement({
15527
15914
  success: true,
15528
- fromCache: response.fromCache
15915
+ fromCache: response.fromCache,
15916
+ accessTokenSize: response.accessToken.length,
15917
+ idTokenSize: response.idToken.length,
15918
+ isNativeBroker: response.fromNativeBroker
15529
15919
  });
15530
15920
  return response;
15531
15921
  }).catch(function (tokenRenewalError) {
15532
15922
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
15533
15923
  astsAsyncMeasurement.endMeasurement({
15924
+ errorCode: tokenRenewalError.errorCode,
15925
+ subErrorCode: tokenRenewalError.subError,
15534
15926
  success: false
15535
15927
  });
15536
15928
  throw tokenRenewalError;