@azure/msal-browser 2.24.0 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +11 -7
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +46 -14
  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 +9 -3
  10. package/dist/app/PublicClientApplication.js.map +1 -1
  11. package/dist/broker/nativeBroker/NativeMessageHandler.js +1 -1
  12. package/dist/broker/nativeBroker/NativeRequest.d.ts +3 -3
  13. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
  14. package/dist/broker/nativeBroker/NativeResponse.d.ts +26 -1
  15. package/dist/broker/nativeBroker/NativeResponse.d.ts.map +1 -1
  16. package/dist/cache/AsyncMemoryStorage.js +1 -1
  17. package/dist/cache/BrowserCacheManager.js +2 -2
  18. package/dist/cache/BrowserCacheManager.js.map +1 -1
  19. package/dist/cache/BrowserStorage.js +1 -1
  20. package/dist/cache/DatabaseStorage.js +1 -1
  21. package/dist/cache/MemoryStorage.js +1 -1
  22. package/dist/cache/TokenCache.d.ts +1 -0
  23. package/dist/cache/TokenCache.d.ts.map +1 -1
  24. package/dist/cache/TokenCache.js +5 -4
  25. package/dist/cache/TokenCache.js.map +1 -1
  26. package/dist/config/Configuration.d.ts +4 -0
  27. package/dist/config/Configuration.d.ts.map +1 -1
  28. package/dist/config/Configuration.js +2 -1
  29. package/dist/config/Configuration.js.map +1 -1
  30. package/dist/crypto/BrowserCrypto.js +1 -1
  31. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  32. package/dist/crypto/CryptoOps.js +7 -10
  33. package/dist/crypto/CryptoOps.js.map +1 -1
  34. package/dist/crypto/GuidGenerator.js +1 -1
  35. package/dist/crypto/PkceGenerator.js +1 -1
  36. package/dist/crypto/SignedHttpRequest.js +1 -1
  37. package/dist/encode/Base64Decode.js +1 -1
  38. package/dist/encode/Base64Encode.js +1 -1
  39. package/dist/error/BrowserAuthError.d.ts +1 -1
  40. package/dist/error/BrowserAuthError.js +5 -5
  41. package/dist/error/BrowserAuthError.js.map +1 -1
  42. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  43. package/dist/error/NativeAuthError.d.ts +3 -1
  44. package/dist/error/NativeAuthError.d.ts.map +1 -1
  45. package/dist/error/NativeAuthError.js +6 -2
  46. package/dist/error/NativeAuthError.js.map +1 -1
  47. package/dist/event/EventHandler.js +1 -1
  48. package/dist/event/EventMessage.js +1 -1
  49. package/dist/event/EventType.js +1 -1
  50. package/dist/index.cjs.js +841 -549
  51. package/dist/index.cjs.js.map +1 -1
  52. package/dist/index.js +1 -1
  53. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  54. package/dist/interaction_client/BaseInteractionClient.js +3 -2
  55. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  56. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  57. package/dist/interaction_client/NativeInteractionClient.d.ts +12 -0
  58. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  59. package/dist/interaction_client/NativeInteractionClient.js +76 -31
  60. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  61. package/dist/interaction_client/PopupClient.d.ts +75 -2
  62. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  63. package/dist/interaction_client/PopupClient.js +281 -41
  64. package/dist/interaction_client/PopupClient.js.map +1 -1
  65. package/dist/interaction_client/RedirectClient.js +1 -1
  66. package/dist/interaction_client/SilentAuthCodeClient.js +1 -1
  67. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  68. package/dist/interaction_client/SilentCacheClient.js +4 -2
  69. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  70. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  71. package/dist/interaction_client/SilentIframeClient.js +3 -1
  72. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  73. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  74. package/dist/interaction_client/SilentRefreshClient.js +3 -1
  75. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  76. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  77. package/dist/interaction_client/StandardInteractionClient.js +4 -1
  78. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  79. package/dist/interaction_handler/InteractionHandler.d.ts +3 -8
  80. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  81. package/dist/interaction_handler/InteractionHandler.js +5 -5
  82. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  83. package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
  84. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  85. package/dist/interaction_handler/RedirectHandler.js +12 -12
  86. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  87. package/dist/interaction_handler/SilentHandler.d.ts +1 -1
  88. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  89. package/dist/interaction_handler/SilentHandler.js +5 -5
  90. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  91. package/dist/internals.d.ts +0 -1
  92. package/dist/internals.d.ts.map +1 -1
  93. package/dist/internals.js +1 -2
  94. package/dist/internals.js.map +1 -1
  95. package/dist/navigation/NavigationClient.js +1 -1
  96. package/dist/network/FetchClient.js +1 -1
  97. package/dist/network/XhrClient.js +1 -1
  98. package/dist/packageMetadata.d.ts +1 -1
  99. package/dist/packageMetadata.js +2 -2
  100. package/dist/packageMetadata.js.map +1 -1
  101. package/dist/request/EndSessionPopupRequest.d.ts +1 -1
  102. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  103. package/dist/request/PopupRequest.d.ts +1 -1
  104. package/dist/request/PopupRequest.d.ts.map +1 -1
  105. package/dist/request/PopupWindowAttributes.d.ts +16 -0
  106. package/dist/request/PopupWindowAttributes.d.ts.map +1 -0
  107. package/dist/request/SsoSilentRequest.d.ts +1 -1
  108. package/dist/telemetry/BrowserPerformanceClient.js +1 -1
  109. package/dist/telemetry/BrowserPerformanceMeasurement.js +1 -1
  110. package/dist/utils/BrowserConstants.d.ts +1 -0
  111. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  112. package/dist/utils/BrowserConstants.js +3 -2
  113. package/dist/utils/BrowserConstants.js.map +1 -1
  114. package/dist/utils/BrowserProtocolUtils.js +1 -1
  115. package/dist/utils/BrowserStringUtils.js +1 -1
  116. package/dist/utils/BrowserUtils.js +1 -1
  117. package/dist/utils/MathUtils.js +1 -1
  118. package/lib/msal-browser.js +841 -549
  119. package/lib/msal-browser.js.map +1 -1
  120. package/lib/msal-browser.min.js +43 -41
  121. package/package.json +2 -2
  122. package/dist/interaction_handler/PopupHandler.d.ts +0 -29
  123. package/dist/interaction_handler/PopupHandler.d.ts.map +0 -1
  124. package/dist/interaction_handler/PopupHandler.js +0 -69
  125. package/dist/interaction_handler/PopupHandler.js.map +0 -1
  126. package/dist/utils/PopupUtils.d.ts +0 -73
  127. package/dist/utils/PopupUtils.d.ts.map +0 -1
  128. package/dist/utils/PopupUtils.js +0 -185
  129. package/dist/utils/PopupUtils.js.map +0 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.24.0 2022-05-02 */
1
+ /*! @azure/msal-browser v2.27.0 2022-07-05 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -107,7 +107,7 @@
107
107
  return ar;
108
108
  }
109
109
 
110
- /*! @azure/msal-common v6.3.0 2022-05-02 */
110
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
111
111
  /*! *****************************************************************************
112
112
  Copyright (c) Microsoft Corporation.
113
113
 
@@ -194,7 +194,7 @@
194
194
  return r;
195
195
  }
196
196
 
197
- /*! @azure/msal-common v6.3.0 2022-05-02 */
197
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -478,6 +478,7 @@
478
478
  AuthorityMetadataSource["CONFIG"] = "config";
479
479
  AuthorityMetadataSource["CACHE"] = "cache";
480
480
  AuthorityMetadataSource["NETWORK"] = "network";
481
+ AuthorityMetadataSource["HARDCODED_VALUES"] = "hardcoded_values";
481
482
  })(AuthorityMetadataSource || (AuthorityMetadataSource = {}));
482
483
  var SERVER_TELEM_CONSTANTS = {
483
484
  SCHEMA_VERSION: 5,
@@ -561,9 +562,14 @@
561
562
  CacheOutcome["NO_CACHED_ACCESS_TOKEN"] = "2";
562
563
  CacheOutcome["CACHED_ACCESS_TOKEN_EXPIRED"] = "3";
563
564
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
564
- })(CacheOutcome || (CacheOutcome = {}));
565
+ })(CacheOutcome || (CacheOutcome = {}));
566
+ var JsonTypes;
567
+ (function (JsonTypes) {
568
+ JsonTypes["Jwt"] = "JWT";
569
+ JsonTypes["Jwk"] = "JWK";
570
+ })(JsonTypes || (JsonTypes = {}));
565
571
 
566
- /*! @azure/msal-common v6.3.0 2022-05-02 */
572
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
567
573
 
568
574
  /*
569
575
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -607,7 +613,7 @@
607
613
  return AuthError;
608
614
  }(Error));
609
615
 
610
- /*! @azure/msal-common v6.3.0 2022-05-02 */
616
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
611
617
 
612
618
  /*
613
619
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -682,7 +688,7 @@
682
688
  }
683
689
  };
684
690
 
685
- /*! @azure/msal-common v6.3.0 2022-05-02 */
691
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
686
692
 
687
693
  /*
688
694
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -872,6 +878,10 @@
872
878
  logoutNotSupported: {
873
879
  code: "end_session_endpoint_not_supported",
874
880
  desc: "Provided authority does not support logout."
881
+ },
882
+ keyIdMissing: {
883
+ code: "key_id_missing",
884
+ desc: "A keyId value is missing from the requested bound token's cache record and is required to match the token to it's stored binding key."
875
885
  }
876
886
  };
877
887
  /**
@@ -1141,10 +1151,16 @@
1141
1151
  ClientAuthError.createLogoutNotSupportedError = function () {
1142
1152
  return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
1143
1153
  };
1154
+ /**
1155
+ * Create an error when kid attribute is missing from a PoP token's cache record
1156
+ */
1157
+ ClientAuthError.createKeyIdMissingError = function () {
1158
+ return new ClientAuthError(ClientAuthErrorMessage.keyIdMissing.code, ClientAuthErrorMessage.keyIdMissing.desc);
1159
+ };
1144
1160
  return ClientAuthError;
1145
1161
  }(AuthError));
1146
1162
 
1147
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1163
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
1148
1164
 
1149
1165
  /*
1150
1166
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1269,7 +1285,7 @@
1269
1285
  return StringUtils;
1270
1286
  }());
1271
1287
 
1272
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1288
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
1273
1289
 
1274
1290
  /*
1275
1291
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1449,12 +1465,12 @@
1449
1465
  return Logger;
1450
1466
  }());
1451
1467
 
1452
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1468
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
1453
1469
  /* eslint-disable header/header */
1454
1470
  var name$1 = "@azure/msal-common";
1455
- var version$1 = "6.3.0";
1471
+ var version$1 = "7.1.0";
1456
1472
 
1457
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1473
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
1458
1474
  /*
1459
1475
  * Copyright (c) Microsoft Corporation. All rights reserved.
1460
1476
  * Licensed under the MIT License.
@@ -1475,7 +1491,7 @@
1475
1491
  AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1476
1492
  })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1477
1493
 
1478
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1494
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
1479
1495
 
1480
1496
  /*
1481
1497
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1498,9 +1514,9 @@
1498
1514
  * familyId: Family ID identifier, usually only used for refresh tokens
1499
1515
  * realm: Full tenant or organizational identifier that the account belongs to
1500
1516
  * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
1501
- * oboAssertion: access token passed in as part of OBO request
1502
1517
  * tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
1503
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
1504
1520
  * }
1505
1521
  */
1506
1522
  var CredentialEntity = /** @class */ (function () {
@@ -1634,7 +1650,7 @@
1634
1650
  return CredentialEntity;
1635
1651
  }());
1636
1652
 
1637
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1653
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
1638
1654
 
1639
1655
  /*
1640
1656
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1889,7 +1905,7 @@
1889
1905
  return ClientConfigurationError;
1890
1906
  }(ClientAuthError));
1891
1907
 
1892
- /*! @azure/msal-common v6.3.0 2022-05-02 */
1908
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
1893
1909
 
1894
1910
  /*
1895
1911
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2073,7 +2089,7 @@
2073
2089
  return ScopeSet;
2074
2090
  }());
2075
2091
 
2076
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2092
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2077
2093
 
2078
2094
  /*
2079
2095
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2111,7 +2127,7 @@
2111
2127
  };
2112
2128
  }
2113
2129
 
2114
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2130
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2115
2131
  /*
2116
2132
  * Copyright (c) Microsoft Corporation. All rights reserved.
2117
2133
  * Licensed under the MIT License.
@@ -2125,7 +2141,7 @@
2125
2141
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2126
2142
  })(AuthorityType || (AuthorityType = {}));
2127
2143
 
2128
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2144
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2129
2145
 
2130
2146
  /*
2131
2147
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2150,7 +2166,6 @@
2150
2166
  * clientInfo: Full base64 encoded client info received from ESTS
2151
2167
  * lastModificationTime: last time this entity was modified in the cache
2152
2168
  * lastModificationApp:
2153
- * oboAssertion: access token passed in as part of OBO request
2154
2169
  * idTokenClaims: Object containing claims parsed from ID token
2155
2170
  * nativeAccountId: Account identifier on the native device
2156
2171
  * }
@@ -2229,7 +2244,7 @@
2229
2244
  * @param idToken
2230
2245
  * @param policy
2231
2246
  */
2232
- AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
2247
+ AccountEntity.createAccount = function (clientInfo, homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment, nativeAccountId) {
2233
2248
  var _a, _b, _c, _d, _e, _f;
2234
2249
  var account = new AccountEntity();
2235
2250
  account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
@@ -2243,7 +2258,6 @@
2243
2258
  account.environment = env;
2244
2259
  // non AAD scenarios can have empty realm
2245
2260
  account.realm = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.tid) || Constants.EMPTY_STRING;
2246
- account.oboAssertion = oboAssertion;
2247
2261
  if (idToken) {
2248
2262
  account.idTokenClaims = idToken.claims;
2249
2263
  // How do you account for MSA CID here?
@@ -2264,14 +2278,13 @@
2264
2278
  * @param authority
2265
2279
  * @param idToken
2266
2280
  */
2267
- AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, oboAssertion, cloudGraphHostName, msGraphHost, environment) {
2281
+ AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment) {
2268
2282
  var _a, _b, _c, _d;
2269
2283
  var account = new AccountEntity();
2270
2284
  account.authorityType = (authority && authority.authorityType === AuthorityType.Adfs) ? CacheAccountType.ADFS_ACCOUNT_TYPE : CacheAccountType.GENERIC_ACCOUNT_TYPE;
2271
2285
  account.homeAccountId = homeAccountId;
2272
2286
  // non AAD scenarios can have empty realm
2273
2287
  account.realm = Constants.EMPTY_STRING;
2274
- account.oboAssertion = oboAssertion;
2275
2288
  var env = environment || authority && authority.getPreferredCache();
2276
2289
  if (!env) {
2277
2290
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -2363,7 +2376,7 @@
2363
2376
  return AccountEntity;
2364
2377
  }());
2365
2378
 
2366
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2379
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2367
2380
 
2368
2381
  /*
2369
2382
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2401,7 +2414,7 @@
2401
2414
  return AuthToken;
2402
2415
  }());
2403
2416
 
2404
- /*! @azure/msal-common v6.3.0 2022-05-02 */
2417
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
2405
2418
 
2406
2419
  /*
2407
2420
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2564,7 +2577,7 @@
2564
2577
  * @param target
2565
2578
  */
2566
2579
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
2567
- 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);
2580
+ 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);
2568
2581
  };
2569
2582
  /**
2570
2583
  * Support function to help match credentials
@@ -2574,10 +2587,10 @@
2574
2587
  * @param clientId
2575
2588
  * @param realm
2576
2589
  * @param target
2577
- * @param oboAssertion
2590
+ * @param userAssertionHash
2578
2591
  * @param tokenType
2579
2592
  */
2580
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId, requestedClaimsHash) {
2593
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, userAssertionHash, tokenType, keyId, requestedClaimsHash) {
2581
2594
  var _this = this;
2582
2595
  var allCacheKeys = this.getKeys();
2583
2596
  var matchingCredentials = {
@@ -2596,7 +2609,7 @@
2596
2609
  if (!entity) {
2597
2610
  return;
2598
2611
  }
2599
- if (!!oboAssertion && !_this.matchOboAssertion(entity, oboAssertion)) {
2612
+ if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
2600
2613
  return;
2601
2614
  }
2602
2615
  if (!!homeAccountId && !_this.matchHomeAccountId(entity, homeAccountId)) {
@@ -2927,7 +2940,7 @@
2927
2940
  target: scopes.printScopesLowerCase(),
2928
2941
  tokenType: authScheme,
2929
2942
  keyId: request.sshKid,
2930
- requestedClaimsHash: request.requestedClaimsHash
2943
+ requestedClaimsHash: request.requestedClaimsHash,
2931
2944
  };
2932
2945
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
2933
2946
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -2953,7 +2966,7 @@
2953
2966
  environment: account.environment,
2954
2967
  credentialType: CredentialType.REFRESH_TOKEN,
2955
2968
  clientId: clientId,
2956
- familyId: id
2969
+ familyId: id,
2957
2970
  };
2958
2971
  var credentialCache = this.getCredentialsFilteredBy(refreshTokenFilter);
2959
2972
  var refreshTokens = Object.keys(credentialCache.refreshTokens).map(function (key) { return credentialCache.refreshTokens[key]; });
@@ -3005,8 +3018,8 @@
3005
3018
  * @param value
3006
3019
  * @param oboAssertion
3007
3020
  */
3008
- CacheManager.prototype.matchOboAssertion = function (entity, oboAssertion) {
3009
- return !!(entity.oboAssertion && oboAssertion === entity.oboAssertion);
3021
+ CacheManager.prototype.matchUserAssertionHash = function (entity, userAssertionHash) {
3022
+ return !!(entity.userAssertionHash && userAssertionHash === entity.userAssertionHash);
3010
3023
  };
3011
3024
  /**
3012
3025
  * helper to match environment
@@ -3243,7 +3256,7 @@
3243
3256
  return DefaultStorageClass;
3244
3257
  }(CacheManager));
3245
3258
 
3246
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3259
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
3247
3260
 
3248
3261
  /*
3249
3262
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3334,10 +3347,10 @@
3334
3347
  * @param authOptions
3335
3348
  */
3336
3349
  function buildAuthOptions(authOptions) {
3337
- return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3350
+ return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS, skipAuthorityMetadataCache: false }, authOptions);
3338
3351
  }
3339
3352
 
3340
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3353
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
3341
3354
 
3342
3355
  /*
3343
3356
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3357,7 +3370,7 @@
3357
3370
  return ServerError;
3358
3371
  }(AuthError));
3359
3372
 
3360
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3373
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
3361
3374
 
3362
3375
  /*
3363
3376
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3453,7 +3466,7 @@
3453
3466
  return ThrottlingUtils;
3454
3467
  }());
3455
3468
 
3456
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3469
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
3457
3470
 
3458
3471
  /*
3459
3472
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3502,7 +3515,7 @@
3502
3515
  return NetworkManager;
3503
3516
  }());
3504
3517
 
3505
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3518
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
3506
3519
  /*
3507
3520
  * Copyright (c) Microsoft Corporation. All rights reserved.
3508
3521
  * Licensed under the MIT License.
@@ -3513,7 +3526,7 @@
3513
3526
  CcsCredentialType["UPN"] = "UPN";
3514
3527
  })(CcsCredentialType || (CcsCredentialType = {}));
3515
3528
 
3516
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3529
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
3517
3530
 
3518
3531
  /*
3519
3532
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3602,7 +3615,7 @@
3602
3615
  return BaseClient;
3603
3616
  }());
3604
3617
 
3605
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3618
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
3606
3619
 
3607
3620
  /*
3608
3621
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3688,7 +3701,7 @@
3688
3701
  return RequestValidator;
3689
3702
  }());
3690
3703
 
3691
- /*! @azure/msal-common v6.3.0 2022-05-02 */
3704
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
3692
3705
 
3693
3706
  /*
3694
3707
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3922,14 +3935,18 @@
3922
3935
  * @param clientAssertion
3923
3936
  */
3924
3937
  RequestParameterBuilder.prototype.addClientAssertion = function (clientAssertion) {
3925
- this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
3938
+ if (!StringUtils.isEmpty(clientAssertion)) {
3939
+ this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
3940
+ }
3926
3941
  };
3927
3942
  /**
3928
3943
  * add clientAssertionType for confidential client flows
3929
3944
  * @param clientAssertionType
3930
3945
  */
3931
3946
  RequestParameterBuilder.prototype.addClientAssertionType = function (clientAssertionType) {
3932
- this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
3947
+ if (!StringUtils.isEmpty(clientAssertionType)) {
3948
+ this.parameters.set(AADServerParamKeys.CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
3949
+ }
3933
3950
  };
3934
3951
  /**
3935
3952
  * add OBO assertion for confidential client flows
@@ -4001,14 +4018,14 @@
4001
4018
  * @param username
4002
4019
  */
4003
4020
  RequestParameterBuilder.prototype.addUsername = function (username) {
4004
- this.parameters.set(PasswordGrantConstants.username, username);
4021
+ this.parameters.set(PasswordGrantConstants.username, encodeURIComponent(username));
4005
4022
  };
4006
4023
  /**
4007
4024
  * adds `password` for Password Grant flow
4008
4025
  * @param password
4009
4026
  */
4010
4027
  RequestParameterBuilder.prototype.addPassword = function (password) {
4011
- this.parameters.set(PasswordGrantConstants.password, password);
4028
+ this.parameters.set(PasswordGrantConstants.password, encodeURIComponent(password));
4012
4029
  };
4013
4030
  /**
4014
4031
  * add pop_jwk to query params
@@ -4062,7 +4079,7 @@
4062
4079
  return RequestParameterBuilder;
4063
4080
  }());
4064
4081
 
4065
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4082
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4066
4083
 
4067
4084
  /*
4068
4085
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4097,7 +4114,7 @@
4097
4114
  * @param clientId
4098
4115
  * @param authority
4099
4116
  */
4100
- IdTokenEntity.createIdTokenEntity = function (homeAccountId, environment, idToken, clientId, tenantId, oboAssertion) {
4117
+ IdTokenEntity.createIdTokenEntity = function (homeAccountId, environment, idToken, clientId, tenantId) {
4101
4118
  var idTokenEntity = new IdTokenEntity();
4102
4119
  idTokenEntity.credentialType = CredentialType.ID_TOKEN;
4103
4120
  idTokenEntity.homeAccountId = homeAccountId;
@@ -4105,7 +4122,6 @@
4105
4122
  idTokenEntity.clientId = clientId;
4106
4123
  idTokenEntity.secret = idToken;
4107
4124
  idTokenEntity.realm = tenantId;
4108
- idTokenEntity.oboAssertion = oboAssertion;
4109
4125
  return idTokenEntity;
4110
4126
  };
4111
4127
  /**
@@ -4127,7 +4143,7 @@
4127
4143
  return IdTokenEntity;
4128
4144
  }(CredentialEntity));
4129
4145
 
4130
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4146
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4131
4147
  /*
4132
4148
  * Copyright (c) Microsoft Corporation. All rights reserved.
4133
4149
  * Licensed under the MIT License.
@@ -4177,7 +4193,7 @@
4177
4193
  return TimeUtils;
4178
4194
  }());
4179
4195
 
4180
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4196
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4181
4197
 
4182
4198
  /*
4183
4199
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4223,7 +4239,7 @@
4223
4239
  * @param expiresOn
4224
4240
  * @param extExpiresOn
4225
4241
  */
4226
- AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId, requestedClaims, requestedClaimsHash) {
4242
+ AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, userAssertionHash, keyId, requestedClaims, requestedClaimsHash) {
4227
4243
  var _a, _b;
4228
4244
  var atEntity = new AccessTokenEntity();
4229
4245
  atEntity.homeAccountId = homeAccountId;
@@ -4244,7 +4260,7 @@
4244
4260
  atEntity.clientId = clientId;
4245
4261
  atEntity.realm = tenantId;
4246
4262
  atEntity.target = scopes;
4247
- atEntity.oboAssertion = oboAssertion;
4263
+ atEntity.userAssertionHash = userAssertionHash;
4248
4264
  atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
4249
4265
  if (requestedClaims) {
4250
4266
  atEntity.requestedClaims = requestedClaims;
@@ -4291,7 +4307,7 @@
4291
4307
  return AccessTokenEntity;
4292
4308
  }(CredentialEntity));
4293
4309
 
4294
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4310
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4295
4311
 
4296
4312
  /*
4297
4313
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4328,14 +4344,14 @@
4328
4344
  * @param clientId
4329
4345
  * @param authority
4330
4346
  */
4331
- RefreshTokenEntity.createRefreshTokenEntity = function (homeAccountId, environment, refreshToken, clientId, familyId, oboAssertion) {
4347
+ RefreshTokenEntity.createRefreshTokenEntity = function (homeAccountId, environment, refreshToken, clientId, familyId, userAssertionHash) {
4332
4348
  var rtEntity = new RefreshTokenEntity();
4333
4349
  rtEntity.clientId = clientId;
4334
4350
  rtEntity.credentialType = CredentialType.REFRESH_TOKEN;
4335
4351
  rtEntity.environment = environment;
4336
4352
  rtEntity.homeAccountId = homeAccountId;
4337
4353
  rtEntity.secret = refreshToken;
4338
- rtEntity.oboAssertion = oboAssertion;
4354
+ rtEntity.userAssertionHash = userAssertionHash;
4339
4355
  if (familyId)
4340
4356
  rtEntity.familyId = familyId;
4341
4357
  return rtEntity;
@@ -4358,7 +4374,7 @@
4358
4374
  return RefreshTokenEntity;
4359
4375
  }(CredentialEntity));
4360
4376
 
4361
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4377
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4362
4378
 
4363
4379
  /*
4364
4380
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4386,6 +4402,10 @@
4386
4402
  noTokensFoundError: {
4387
4403
  code: "no_tokens_found",
4388
4404
  desc: "No refresh token found in the cache. Please sign-in."
4405
+ },
4406
+ native_account_unavailable: {
4407
+ code: "native_account_unavailable",
4408
+ 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."
4389
4409
  }
4390
4410
  };
4391
4411
  /**
@@ -4419,10 +4439,17 @@
4419
4439
  InteractionRequiredAuthError.createNoTokensFoundError = function () {
4420
4440
  return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);
4421
4441
  };
4442
+ /**
4443
+ * Creates an error thrown when the native broker returns ACCOUNT_UNAVAILABLE status, indicating that the account was removed and interactive sign-in is required
4444
+ * @returns
4445
+ */
4446
+ InteractionRequiredAuthError.createNativeAccountUnavailableError = function () {
4447
+ return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.native_account_unavailable.code, InteractionRequiredAuthErrorMessage.native_account_unavailable.desc);
4448
+ };
4422
4449
  return InteractionRequiredAuthError;
4423
4450
  }(AuthError));
4424
4451
 
4425
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4452
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4426
4453
  /*
4427
4454
  * Copyright (c) Microsoft Corporation. All rights reserved.
4428
4455
  * Licensed under the MIT License.
@@ -4438,7 +4465,7 @@
4438
4465
  return CacheRecord;
4439
4466
  }());
4440
4467
 
4441
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4468
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4442
4469
 
4443
4470
  /*
4444
4471
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4509,7 +4536,7 @@
4509
4536
  return ProtocolUtils;
4510
4537
  }());
4511
4538
 
4512
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4539
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4513
4540
 
4514
4541
  /*
4515
4542
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4710,7 +4737,7 @@
4710
4737
  return UrlString;
4711
4738
  }());
4712
4739
 
4713
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4740
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4714
4741
 
4715
4742
  /*
4716
4743
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4727,34 +4754,30 @@
4727
4754
  }
4728
4755
  /**
4729
4756
  * Generates the req_cnf validated at the RP in the POP protocol for SHR parameters
4757
+ * and returns an object containing the keyid, the full req_cnf string and the req_cnf string hash
4730
4758
  * @param request
4731
4759
  * @returns
4732
4760
  */
4733
4761
  PopTokenGenerator.prototype.generateCnf = function (request) {
4734
4762
  return __awaiter(this, void 0, void 0, function () {
4735
- var reqCnf;
4736
- return __generator(this, function (_a) {
4737
- switch (_a.label) {
4763
+ var reqCnf, reqCnfString, _a;
4764
+ return __generator(this, function (_b) {
4765
+ switch (_b.label) {
4738
4766
  case 0: return [4 /*yield*/, this.generateKid(request)];
4739
4767
  case 1:
4740
- reqCnf = _a.sent();
4741
- return [2 /*return*/, this.cryptoUtils.base64Encode(JSON.stringify(reqCnf))];
4768
+ reqCnf = _b.sent();
4769
+ reqCnfString = this.cryptoUtils.base64Encode(JSON.stringify(reqCnf));
4770
+ _a = {
4771
+ kid: reqCnf.kid,
4772
+ reqCnfString: reqCnfString
4773
+ };
4774
+ return [4 /*yield*/, this.cryptoUtils.hashString(reqCnfString)];
4775
+ case 2: return [2 /*return*/, (_a.reqCnfHash = _b.sent(),
4776
+ _a)];
4742
4777
  }
4743
4778
  });
4744
4779
  });
4745
4780
  };
4746
- /**
4747
- * Generates the hash of the req_cnf
4748
- * @param cnf
4749
- * @returns
4750
- */
4751
- PopTokenGenerator.prototype.generateCnfHash = function (cnf) {
4752
- return __awaiter(this, void 0, void 0, function () {
4753
- return __generator(this, function (_a) {
4754
- return [2 /*return*/, this.cryptoUtils.hashString(cnf)];
4755
- });
4756
- });
4757
- };
4758
4781
  /**
4759
4782
  * Generates key_id for a SHR token request
4760
4783
  * @param request
@@ -4782,16 +4805,10 @@
4782
4805
  * @param request
4783
4806
  * @returns
4784
4807
  */
4785
- PopTokenGenerator.prototype.signPopToken = function (accessToken, request) {
4786
- var _a;
4808
+ PopTokenGenerator.prototype.signPopToken = function (accessToken, keyId, request) {
4787
4809
  return __awaiter(this, void 0, void 0, function () {
4788
- var tokenClaims;
4789
- return __generator(this, function (_b) {
4790
- tokenClaims = AuthToken.extractTokenClaims(accessToken, this.cryptoUtils);
4791
- if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4792
- throw ClientAuthError.createTokenClaimsRequiredError();
4793
- }
4794
- return [2 /*return*/, this.signPayload(accessToken, tokenClaims.cnf.kid, request)];
4810
+ return __generator(this, function (_a) {
4811
+ return [2 /*return*/, this.signPayload(accessToken, keyId, request)];
4795
4812
  });
4796
4813
  });
4797
4814
  };
@@ -4803,7 +4820,7 @@
4803
4820
  * @param claims
4804
4821
  * @returns
4805
4822
  */
4806
- PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
4823
+ PopTokenGenerator.prototype.signPayload = function (payload, keyId, request, claims) {
4807
4824
  return __awaiter(this, void 0, void 0, function () {
4808
4825
  var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
4809
4826
  return __generator(this, function (_a) {
@@ -4812,7 +4829,7 @@
4812
4829
  resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4813
4830
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4814
4831
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4815
- return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid, request.correlationId)];
4832
+ return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), keyId, request.correlationId)];
4816
4833
  case 1: return [2 /*return*/, _a.sent()];
4817
4834
  }
4818
4835
  });
@@ -4821,7 +4838,7 @@
4821
4838
  return PopTokenGenerator;
4822
4839
  }());
4823
4840
 
4824
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4841
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4825
4842
 
4826
4843
  /*
4827
4844
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4891,7 +4908,7 @@
4891
4908
  return AppMetadataEntity;
4892
4909
  }());
4893
4910
 
4894
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4911
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4895
4912
  /*
4896
4913
  * Copyright (c) Microsoft Corporation. All rights reserved.
4897
4914
  * Licensed under the MIT License.
@@ -4927,7 +4944,7 @@
4927
4944
  return TokenCacheContext;
4928
4945
  }());
4929
4946
 
4930
- /*! @azure/msal-common v6.3.0 2022-05-02 */
4947
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
4931
4948
 
4932
4949
  /*
4933
4950
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4988,7 +5005,7 @@
4988
5005
  * @param serverTokenResponse
4989
5006
  * @param authority
4990
5007
  */
4991
- ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, oboAssertion, handlingRefreshTokenResponse) {
5008
+ ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse) {
4992
5009
  return __awaiter(this, void 0, void 0, function () {
4993
5010
  var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
4994
5011
  return __generator(this, function (_a) {
@@ -5010,7 +5027,7 @@
5010
5027
  }
5011
5028
  // Add keyId from request to serverTokenResponse if defined
5012
5029
  serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
5013
- cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload);
5030
+ cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload);
5014
5031
  _a.label = 1;
5015
5032
  case 1:
5016
5033
  _a.trys.push([1, , 5, 8]);
@@ -5058,7 +5075,7 @@
5058
5075
  * @param idTokenObj
5059
5076
  * @param authority
5060
5077
  */
5061
- ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload) {
5078
+ ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, userAssertionHash, authCodePayload) {
5062
5079
  var env = authority.getPreferredCache();
5063
5080
  if (StringUtils.isEmpty(env)) {
5064
5081
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -5067,8 +5084,8 @@
5067
5084
  var cachedIdToken;
5068
5085
  var cachedAccount;
5069
5086
  if (!StringUtils.isEmpty(serverTokenResponse.id_token) && !!idTokenObj) {
5070
- cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING, oboAssertion);
5071
- cachedAccount = this.generateAccountEntity(serverTokenResponse, idTokenObj, authority, oboAssertion, authCodePayload);
5087
+ cachedIdToken = IdTokenEntity.createIdTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.id_token || Constants.EMPTY_STRING, this.clientId, idTokenObj.claims.tid || Constants.EMPTY_STRING);
5088
+ cachedAccount = this.generateAccountEntity(serverTokenResponse, idTokenObj, authority, authCodePayload);
5072
5089
  }
5073
5090
  // AccessToken
5074
5091
  var cachedAccessToken = null;
@@ -5086,12 +5103,12 @@
5086
5103
  var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
5087
5104
  var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
5088
5105
  // non AAD scenarios can have empty realm
5089
- 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);
5106
+ 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);
5090
5107
  }
5091
5108
  // refreshToken
5092
5109
  var cachedRefreshToken = null;
5093
5110
  if (!StringUtils.isEmpty(serverTokenResponse.refresh_token)) {
5094
- cachedRefreshToken = RefreshTokenEntity.createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token || Constants.EMPTY_STRING, this.clientId, serverTokenResponse.foci, oboAssertion);
5111
+ cachedRefreshToken = RefreshTokenEntity.createRefreshTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.refresh_token || Constants.EMPTY_STRING, this.clientId, serverTokenResponse.foci, userAssertionHash);
5095
5112
  }
5096
5113
  // appMetadata
5097
5114
  var cachedAppMetadata = null;
@@ -5106,22 +5123,22 @@
5106
5123
  * @param idToken
5107
5124
  * @param authority
5108
5125
  */
5109
- ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, oboAssertion, authCodePayload) {
5126
+ ResponseHandler.prototype.generateAccountEntity = function (serverTokenResponse, idToken, authority, authCodePayload) {
5110
5127
  var authorityType = authority.authorityType;
5111
5128
  var cloudGraphHostName = authCodePayload ? authCodePayload.cloud_graph_host_name : Constants.EMPTY_STRING;
5112
5129
  var msGraphhost = authCodePayload ? authCodePayload.msgraph_host : Constants.EMPTY_STRING;
5113
5130
  // ADFS does not require client_info in the response
5114
5131
  if (authorityType === AuthorityType.Adfs) {
5115
5132
  this.logger.verbose("Authority type is ADFS, creating ADFS account");
5116
- return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost);
5133
+ return AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
5117
5134
  }
5118
5135
  // This fallback applies to B2C as well as they fall under an AAD account type.
5119
5136
  if (StringUtils.isEmpty(serverTokenResponse.client_info) && authority.protocolMode === "AAD") {
5120
5137
  throw ClientAuthError.createClientInfoEmptyError();
5121
5138
  }
5122
5139
  return serverTokenResponse.client_info ?
5123
- AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost) :
5124
- AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, oboAssertion, cloudGraphHostName, msGraphhost);
5140
+ AccountEntity.createAccount(serverTokenResponse.client_info, this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost) :
5141
+ AccountEntity.createGenericAccount(this.homeAccountIdentifier, idToken, authority, cloudGraphHostName, msGraphhost);
5125
5142
  };
5126
5143
  /**
5127
5144
  * Creates an @AuthenticationResult from @CacheRecord , @IdToken , and a boolean that states whether or not the result is from cache.
@@ -5136,9 +5153,9 @@
5136
5153
  ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
5137
5154
  var _a, _b, _c;
5138
5155
  return __awaiter(this, void 0, void 0, function () {
5139
- var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
5140
- return __generator(this, function (_d) {
5141
- switch (_d.label) {
5156
+ var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
5157
+ return __generator(this, function (_e) {
5158
+ switch (_e.label) {
5142
5159
  case 0:
5143
5160
  accessToken = Constants.EMPTY_STRING;
5144
5161
  responseScopes = [];
@@ -5147,18 +5164,22 @@
5147
5164
  if (!cacheRecord.accessToken) return [3 /*break*/, 4];
5148
5165
  if (!(cacheRecord.accessToken.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5149
5166
  popTokenGenerator = new PopTokenGenerator(cryptoObj);
5150
- return [4 /*yield*/, popTokenGenerator.signPopToken(cacheRecord.accessToken.secret, request)];
5167
+ _d = cacheRecord.accessToken, secret = _d.secret, keyId = _d.keyId;
5168
+ if (!keyId) {
5169
+ throw ClientAuthError.createKeyIdMissingError();
5170
+ }
5171
+ return [4 /*yield*/, popTokenGenerator.signPopToken(secret, keyId, request)];
5151
5172
  case 1:
5152
- accessToken = _d.sent();
5173
+ accessToken = _e.sent();
5153
5174
  return [3 /*break*/, 3];
5154
5175
  case 2:
5155
5176
  accessToken = cacheRecord.accessToken.secret;
5156
- _d.label = 3;
5177
+ _e.label = 3;
5157
5178
  case 3:
5158
5179
  responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
5159
5180
  expiresOn = new Date(Number(cacheRecord.accessToken.expiresOn) * 1000);
5160
5181
  extExpiresOn = new Date(Number(cacheRecord.accessToken.extendedExpiresOn) * 1000);
5161
- _d.label = 4;
5182
+ _e.label = 4;
5162
5183
  case 4:
5163
5184
  if (cacheRecord.appMetadata) {
5164
5185
  familyId = cacheRecord.appMetadata.familyId === THE_FAMILY_ID ? THE_FAMILY_ID : Constants.EMPTY_STRING;
@@ -5193,7 +5214,7 @@
5193
5214
  return ResponseHandler;
5194
5215
  }());
5195
5216
 
5196
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5217
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
5197
5218
 
5198
5219
  /*
5199
5220
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5360,7 +5381,7 @@
5360
5381
  */
5361
5382
  AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
5362
5383
  return __awaiter(this, void 0, void 0, function () {
5363
- var parameterBuilder, clientAssertion, popTokenGenerator, cnfString, correlationId, ccsCred, clientInfo, clientInfo;
5384
+ var parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, correlationId, ccsCred, clientInfo, clientInfo;
5364
5385
  var _a;
5365
5386
  return __generator(this, function (_b) {
5366
5387
  switch (_b.label) {
@@ -5408,8 +5429,9 @@
5408
5429
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5409
5430
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5410
5431
  case 1:
5411
- cnfString = _b.sent();
5412
- parameterBuilder.addPopToken(cnfString);
5432
+ reqCnfData = _b.sent();
5433
+ // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5434
+ parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5413
5435
  return [3 /*break*/, 3];
5414
5436
  case 2:
5415
5437
  if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
@@ -5480,7 +5502,7 @@
5480
5502
  */
5481
5503
  AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
5482
5504
  return __awaiter(this, void 0, void 0, function () {
5483
- var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, cnf, cnfHash;
5505
+ var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5484
5506
  return __generator(this, function (_a) {
5485
5507
  switch (_a.label) {
5486
5508
  case 0:
@@ -5572,20 +5594,17 @@
5572
5594
  if (request.extraQueryParameters) {
5573
5595
  parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
5574
5596
  }
5575
- if (!request.nativeBroker) return [3 /*break*/, 3];
5597
+ if (!request.nativeBroker) return [3 /*break*/, 2];
5576
5598
  // signal ests that this is a WAM call
5577
5599
  parameterBuilder.addNativeBroker();
5578
- if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 3];
5600
+ if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5579
5601
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5580
5602
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5581
5603
  case 1:
5582
- cnf = _a.sent();
5583
- return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
5584
- case 2:
5585
- cnfHash = _a.sent();
5586
- parameterBuilder.addPopToken(cnfHash);
5587
- _a.label = 3;
5588
- case 3: return [2 /*return*/, parameterBuilder.createQueryString()];
5604
+ reqCnfData = _a.sent();
5605
+ parameterBuilder.addPopToken(reqCnfData.reqCnfHash);
5606
+ _a.label = 2;
5607
+ case 2: return [2 /*return*/, parameterBuilder.createQueryString()];
5589
5608
  }
5590
5609
  });
5591
5610
  });
@@ -5630,7 +5649,7 @@
5630
5649
  return AuthorizationCodeClient;
5631
5650
  }(BaseClient));
5632
5651
 
5633
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5652
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
5634
5653
 
5635
5654
  /*
5636
5655
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5771,7 +5790,7 @@
5771
5790
  */
5772
5791
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
5773
5792
  return __awaiter(this, void 0, void 0, function () {
5774
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
5793
+ var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
5775
5794
  return __generator(this, function (_a) {
5776
5795
  switch (_a.label) {
5777
5796
  case 0:
@@ -5801,8 +5820,9 @@
5801
5820
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5802
5821
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5803
5822
  case 1:
5804
- cnfString = _a.sent();
5805
- parameterBuilder.addPopToken(cnfString);
5823
+ reqCnfData = _a.sent();
5824
+ // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5825
+ parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5806
5826
  return [3 /*break*/, 3];
5807
5827
  case 2:
5808
5828
  if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
@@ -5842,7 +5862,7 @@
5842
5862
  return RefreshTokenClient;
5843
5863
  }(BaseClient));
5844
5864
 
5845
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5865
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
5846
5866
 
5847
5867
  /*
5848
5868
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5958,7 +5978,7 @@
5958
5978
  return SilentFlowClient;
5959
5979
  }(BaseClient));
5960
5980
 
5961
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5981
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
5962
5982
  /*
5963
5983
  * Copyright (c) Microsoft Corporation. All rights reserved.
5964
5984
  * Licensed under the MIT License.
@@ -5966,10 +5986,20 @@
5966
5986
  function isOpenIdConfigResponse(response) {
5967
5987
  return (response.hasOwnProperty("authorization_endpoint") &&
5968
5988
  response.hasOwnProperty("token_endpoint") &&
5969
- response.hasOwnProperty("issuer"));
5989
+ response.hasOwnProperty("issuer") &&
5990
+ response.hasOwnProperty("jwks_uri"));
5970
5991
  }
5971
5992
 
5972
- /*! @azure/msal-common v6.3.0 2022-05-02 */
5993
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
5994
+ /*
5995
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5996
+ * Licensed under the MIT License.
5997
+ */
5998
+ 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"] }] } } };
5999
+ var EndpointMetadata = rawMetdataJSON.endpointMetadata;
6000
+ var InstanceDiscoveryMetadata = rawMetdataJSON.instanceDiscoveryMetadata;
6001
+
6002
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
5973
6003
  /*
5974
6004
  * Copyright (c) Microsoft Corporation. All rights reserved.
5975
6005
  * Licensed under the MIT License.
@@ -5983,7 +6013,7 @@
5983
6013
  ProtocolMode["OIDC"] = "OIDC";
5984
6014
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5985
6015
 
5986
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6016
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
5987
6017
 
5988
6018
  /*
5989
6019
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6015,6 +6045,7 @@
6015
6045
  this.end_session_endpoint = metadata.end_session_endpoint;
6016
6046
  this.issuer = metadata.issuer;
6017
6047
  this.endpointsFromNetwork = fromNetwork;
6048
+ this.jwks_uri = metadata.jwks_uri;
6018
6049
  };
6019
6050
  /**
6020
6051
  * Save the authority that was used to create this cache entry
@@ -6053,12 +6084,13 @@
6053
6084
  entity.hasOwnProperty("issuer") &&
6054
6085
  entity.hasOwnProperty("aliasesFromNetwork") &&
6055
6086
  entity.hasOwnProperty("endpointsFromNetwork") &&
6056
- entity.hasOwnProperty("expiresAt"));
6087
+ entity.hasOwnProperty("expiresAt") &&
6088
+ entity.hasOwnProperty("jwks_uri"));
6057
6089
  };
6058
6090
  return AuthorityMetadataEntity;
6059
6091
  }());
6060
6092
 
6061
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6093
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6062
6094
  /*
6063
6095
  * Copyright (c) Microsoft Corporation. All rights reserved.
6064
6096
  * Licensed under the MIT License.
@@ -6068,7 +6100,7 @@
6068
6100
  response.hasOwnProperty("metadata"));
6069
6101
  }
6070
6102
 
6071
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6103
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6072
6104
 
6073
6105
  /*
6074
6106
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6190,7 +6222,7 @@
6190
6222
  return RegionDiscovery;
6191
6223
  }());
6192
6224
 
6193
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6225
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6194
6226
 
6195
6227
  /*
6196
6228
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6375,6 +6407,22 @@
6375
6407
  enumerable: false,
6376
6408
  configurable: true
6377
6409
  });
6410
+ Object.defineProperty(Authority.prototype, "jwksUri", {
6411
+ /**
6412
+ * Jwks_uri for token signing keys
6413
+ */
6414
+ get: function () {
6415
+ if (this.discoveryComplete()) {
6416
+ var endpoint = this.replacePath(this.metadata.jwks_uri);
6417
+ return this.replaceTenant(endpoint);
6418
+ }
6419
+ else {
6420
+ throw ClientAuthError.createEndpointDiscoveryIncompleteError("Discovery incomplete.");
6421
+ }
6422
+ },
6423
+ enumerable: false,
6424
+ configurable: true
6425
+ });
6378
6426
  /**
6379
6427
  * Replaces tenant in url path with current tenant. Defaults to common.
6380
6428
  * @param urlString
@@ -6458,11 +6506,11 @@
6458
6506
  * @param metadataEntity
6459
6507
  */
6460
6508
  Authority.prototype.updateEndpointMetadata = function (metadataEntity) {
6461
- var _a;
6509
+ var _a, _b;
6462
6510
  return __awaiter(this, void 0, void 0, function () {
6463
- var metadata, autodetectedRegionName, azureRegion;
6464
- return __generator(this, function (_b) {
6465
- switch (_b.label) {
6511
+ var metadata, harcodedMetadata;
6512
+ return __generator(this, function (_c) {
6513
+ switch (_c.label) {
6466
6514
  case 0:
6467
6515
  metadata = this.getEndpointMetadataFromConfig();
6468
6516
  if (metadata) {
@@ -6473,41 +6521,30 @@
6473
6521
  // No need to update
6474
6522
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6475
6523
  }
6524
+ harcodedMetadata = this.getEndpointMetadataFromHardcodedValues();
6476
6525
  return [4 /*yield*/, this.getEndpointMetadataFromNetwork()];
6477
6526
  case 1:
6478
- metadata = _b.sent();
6527
+ metadata = _c.sent();
6479
6528
  if (!metadata) return [3 /*break*/, 4];
6480
6529
  if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
6481
- return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6530
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(metadata)];
6482
6531
  case 2:
6483
- autodetectedRegionName = _b.sent();
6484
- azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
6485
- ? autodetectedRegionName
6486
- : this.authorityOptions.azureRegionConfiguration.azureRegion;
6487
- if (this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
6488
- this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
6489
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
6490
- RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
6491
- }
6492
- else {
6493
- if (autodetectedRegionName) {
6494
- this.regionDiscoveryMetadata.region_outcome = (this.authorityOptions.azureRegionConfiguration.azureRegion === autodetectedRegionName) ?
6495
- RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
6496
- RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
6497
- }
6498
- else {
6499
- this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
6500
- }
6501
- }
6502
- if (azureRegion) {
6503
- this.regionDiscoveryMetadata.region_used = azureRegion;
6504
- metadata = Authority.replaceWithRegionalInformation(metadata, azureRegion);
6505
- }
6506
- _b.label = 3;
6532
+ metadata = _c.sent();
6533
+ _c.label = 3;
6507
6534
  case 3:
6508
6535
  metadataEntity.updateEndpointMetadata(metadata, true);
6509
6536
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6510
- case 4: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
6537
+ case 4:
6538
+ if (!(harcodedMetadata && !this.authorityOptions.skipAuthorityMetadataCache)) return [3 /*break*/, 7];
6539
+ if (!((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion)) return [3 /*break*/, 6];
6540
+ return [4 /*yield*/, this.updateMetadataWithRegionalInformation(harcodedMetadata)];
6541
+ case 5:
6542
+ harcodedMetadata = _c.sent();
6543
+ _c.label = 6;
6544
+ case 6:
6545
+ metadataEntity.updateEndpointMetadata(harcodedMetadata, false);
6546
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
6547
+ case 7: throw ClientAuthError.createUnableToGetOpenidConfigError(this.defaultOpenIdConfigurationEndpoint);
6511
6548
  }
6512
6549
  });
6513
6550
  });
@@ -6538,6 +6575,8 @@
6538
6575
  };
6539
6576
  /**
6540
6577
  * Gets OAuth endpoints from the given OpenID configuration endpoint.
6578
+ *
6579
+ * @param hasHardcodedMetadata boolean
6541
6580
  */
6542
6581
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
6543
6582
  return __awaiter(this, void 0, void 0, function () {
@@ -6564,6 +6603,54 @@
6564
6603
  });
6565
6604
  });
6566
6605
  };
6606
+ /**
6607
+ * Get OAuth endpoints for common authorities.
6608
+ */
6609
+ Authority.prototype.getEndpointMetadataFromHardcodedValues = function () {
6610
+ if (this.canonicalAuthority in EndpointMetadata) {
6611
+ return EndpointMetadata[this.canonicalAuthority];
6612
+ }
6613
+ return null;
6614
+ };
6615
+ /**
6616
+ * Update the retrieved metadata with regional information.
6617
+ */
6618
+ Authority.prototype.updateMetadataWithRegionalInformation = function (metadata) {
6619
+ var _a, _b, _c, _d, _e;
6620
+ return __awaiter(this, void 0, void 0, function () {
6621
+ var autodetectedRegionName, azureRegion;
6622
+ return __generator(this, function (_f) {
6623
+ switch (_f.label) {
6624
+ case 0: return [4 /*yield*/, this.regionDiscovery.detectRegion((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6625
+ case 1:
6626
+ autodetectedRegionName = _f.sent();
6627
+ azureRegion = ((_b = this.authorityOptions.azureRegionConfiguration) === null || _b === void 0 ? void 0 : _b.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
6628
+ ? autodetectedRegionName
6629
+ : (_c = this.authorityOptions.azureRegionConfiguration) === null || _c === void 0 ? void 0 : _c.azureRegion;
6630
+ if (((_d = this.authorityOptions.azureRegionConfiguration) === null || _d === void 0 ? void 0 : _d.azureRegion) === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG) {
6631
+ this.regionDiscoveryMetadata.region_outcome = autodetectedRegionName ?
6632
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_SUCCESSFUL :
6633
+ RegionDiscoveryOutcomes.AUTO_DETECTION_REQUESTED_FAILED;
6634
+ }
6635
+ else {
6636
+ if (autodetectedRegionName) {
6637
+ this.regionDiscoveryMetadata.region_outcome = (((_e = this.authorityOptions.azureRegionConfiguration) === null || _e === void 0 ? void 0 : _e.azureRegion) === autodetectedRegionName) ?
6638
+ RegionDiscoveryOutcomes.CONFIGURED_MATCHES_DETECTED :
6639
+ RegionDiscoveryOutcomes.CONFIGURED_NOT_DETECTED;
6640
+ }
6641
+ else {
6642
+ this.regionDiscoveryMetadata.region_outcome = RegionDiscoveryOutcomes.CONFIGURED_NO_AUTO_DETECTION;
6643
+ }
6644
+ }
6645
+ if (azureRegion) {
6646
+ this.regionDiscoveryMetadata.region_used = azureRegion;
6647
+ return [2 /*return*/, Authority.replaceWithRegionalInformation(metadata, azureRegion)];
6648
+ }
6649
+ return [2 /*return*/, metadata];
6650
+ }
6651
+ });
6652
+ });
6653
+ };
6567
6654
  /**
6568
6655
  * Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
6569
6656
  * @param cachedMetadata
@@ -6571,7 +6658,7 @@
6571
6658
  */
6572
6659
  Authority.prototype.updateCloudDiscoveryMetadata = function (metadataEntity) {
6573
6660
  return __awaiter(this, void 0, void 0, function () {
6574
- var metadata;
6661
+ var metadata, harcodedMetadata;
6575
6662
  return __generator(this, function (_a) {
6576
6663
  switch (_a.label) {
6577
6664
  case 0:
@@ -6585,6 +6672,7 @@
6585
6672
  // No need to update
6586
6673
  return [2 /*return*/, AuthorityMetadataSource.CACHE];
6587
6674
  }
6675
+ harcodedMetadata = this.getCloudDiscoveryMetadataFromHarcodedValues();
6588
6676
  return [4 /*yield*/, this.getCloudDiscoveryMetadataFromNetwork()];
6589
6677
  case 1:
6590
6678
  metadata = _a.sent();
@@ -6592,6 +6680,10 @@
6592
6680
  metadataEntity.updateCloudDiscoveryMetadata(metadata, true);
6593
6681
  return [2 /*return*/, AuthorityMetadataSource.NETWORK];
6594
6682
  }
6683
+ if (harcodedMetadata && !this.options.skipAuthorityMetadataCache) {
6684
+ metadataEntity.updateCloudDiscoveryMetadata(harcodedMetadata, false);
6685
+ return [2 /*return*/, AuthorityMetadataSource.HARDCODED_VALUES];
6686
+ }
6595
6687
  else {
6596
6688
  // Metadata could not be obtained from config, cache or network
6597
6689
  throw ClientConfigurationError.createUntrustedAuthorityError();
@@ -6625,7 +6717,8 @@
6625
6717
  };
6626
6718
  /**
6627
6719
  * Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
6628
- * @param networkInterface
6720
+ *
6721
+ * @param hasHardcodedMetadata boolean
6629
6722
  */
6630
6723
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
6631
6724
  return __awaiter(this, void 0, void 0, function () {
@@ -6645,7 +6738,9 @@
6645
6738
  return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
6646
6739
  case 2:
6647
6740
  response = _a.sent();
6648
- metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];
6741
+ metadata = isCloudInstanceDiscoveryResponse(response.body)
6742
+ ? response.body.metadata
6743
+ : [];
6649
6744
  if (metadata.length === 0) {
6650
6745
  // If no metadata is returned, authority is untrusted
6651
6746
  return [2 /*return*/, null];
@@ -6665,6 +6760,15 @@
6665
6760
  });
6666
6761
  });
6667
6762
  };
6763
+ /**
6764
+ * Get cloud discovery metadata for common authorities
6765
+ */
6766
+ Authority.prototype.getCloudDiscoveryMetadataFromHarcodedValues = function () {
6767
+ if (this.canonicalAuthority in InstanceDiscoveryMetadata) {
6768
+ return InstanceDiscoveryMetadata[this.canonicalAuthority];
6769
+ }
6770
+ return null;
6771
+ };
6668
6772
  /**
6669
6773
  * Helper function to determine if this host is included in the knownAuthorities config option
6670
6774
  */
@@ -6780,7 +6884,7 @@
6780
6884
  return Authority;
6781
6885
  }());
6782
6886
 
6783
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6887
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6784
6888
 
6785
6889
  /*
6786
6890
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6841,7 +6945,7 @@
6841
6945
  return AuthorityFactory;
6842
6946
  }());
6843
6947
 
6844
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6948
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6845
6949
 
6846
6950
  /*
6847
6951
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6872,7 +6976,7 @@
6872
6976
  return ServerTelemetryEntity;
6873
6977
  }());
6874
6978
 
6875
- /*! @azure/msal-common v6.3.0 2022-05-02 */
6979
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6876
6980
 
6877
6981
  /*
6878
6982
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6900,7 +7004,7 @@
6900
7004
  return ThrottlingEntity;
6901
7005
  }());
6902
7006
 
6903
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7007
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6904
7008
 
6905
7009
  /*
6906
7010
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6917,7 +7021,92 @@
6917
7021
  }
6918
7022
  };
6919
7023
 
6920
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7024
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
7025
+
7026
+ /*
7027
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7028
+ * Licensed under the MIT License.
7029
+ */
7030
+ /**
7031
+ * ClientAuthErrorMessage class containing string constants used by error codes and messages.
7032
+ */
7033
+ var JoseHeaderErrorMessage = {
7034
+ missingKidError: {
7035
+ code: "missing_kid_error",
7036
+ desc: "The JOSE Header for the requested JWT, JWS or JWK object requires a keyId to be configured as the 'kid' header claim. No 'kid' value was provided."
7037
+ },
7038
+ missingAlgError: {
7039
+ code: "missing_alg_error",
7040
+ desc: "The JOSE Header for the requested JWT, JWS or JWK object requires an algorithm to be specified as the 'alg' header claim. No 'alg' value was provided."
7041
+ },
7042
+ };
7043
+ /**
7044
+ * Error thrown when there is an error in the client code running on the browser.
7045
+ */
7046
+ var JoseHeaderError = /** @class */ (function (_super) {
7047
+ __extends(JoseHeaderError, _super);
7048
+ function JoseHeaderError(errorCode, errorMessage) {
7049
+ var _this = _super.call(this, errorCode, errorMessage) || this;
7050
+ _this.name = "JoseHeaderError";
7051
+ Object.setPrototypeOf(_this, JoseHeaderError.prototype);
7052
+ return _this;
7053
+ }
7054
+ /**
7055
+ * Creates an error thrown when keyId isn't set on JOSE header.
7056
+ */
7057
+ JoseHeaderError.createMissingKidError = function () {
7058
+ return new JoseHeaderError(JoseHeaderErrorMessage.missingKidError.code, JoseHeaderErrorMessage.missingKidError.desc);
7059
+ };
7060
+ /**
7061
+ * Creates an error thrown when algorithm isn't set on JOSE header.
7062
+ */
7063
+ JoseHeaderError.createMissingAlgError = function () {
7064
+ return new JoseHeaderError(JoseHeaderErrorMessage.missingAlgError.code, JoseHeaderErrorMessage.missingAlgError.desc);
7065
+ };
7066
+ return JoseHeaderError;
7067
+ }(AuthError));
7068
+
7069
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
7070
+
7071
+ /*
7072
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7073
+ * Licensed under the MIT License.
7074
+ */
7075
+ var JoseHeader = /** @class */ (function () {
7076
+ function JoseHeader(options) {
7077
+ this.typ = options.typ;
7078
+ this.alg = options.alg;
7079
+ this.kid = options.kid;
7080
+ }
7081
+ /**
7082
+ * Builds SignedHttpRequest formatted JOSE Header from the
7083
+ * JOSE Header options provided or previously set on the object and returns
7084
+ * the stringified header object.
7085
+ * Throws if keyId or algorithm aren't provided since they are required for Access Token Binding.
7086
+ * @param shrHeaderOptions
7087
+ * @returns
7088
+ */
7089
+ JoseHeader.getShrHeaderString = function (shrHeaderOptions) {
7090
+ // KeyID is required on the SHR header
7091
+ if (!shrHeaderOptions.kid) {
7092
+ throw JoseHeaderError.createMissingKidError();
7093
+ }
7094
+ // Alg is required on the SHR header
7095
+ if (!shrHeaderOptions.alg) {
7096
+ throw JoseHeaderError.createMissingAlgError();
7097
+ }
7098
+ var shrHeader = new JoseHeader({
7099
+ // Access Token PoP headers must have type JWT, but the type header can be overriden for special cases
7100
+ typ: shrHeaderOptions.typ || JsonTypes.Jwt,
7101
+ kid: shrHeaderOptions.kid,
7102
+ alg: shrHeaderOptions.alg
7103
+ });
7104
+ return JSON.stringify(shrHeader);
7105
+ };
7106
+ return JoseHeader;
7107
+ }());
7108
+
7109
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6921
7110
 
6922
7111
  /*
6923
7112
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6976,7 +7165,7 @@
6976
7165
  return AuthenticationHeaderParser;
6977
7166
  }());
6978
7167
 
6979
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7168
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
6980
7169
 
6981
7170
  /*
6982
7171
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7138,7 +7327,7 @@
7138
7327
  return ServerTelemetryManager;
7139
7328
  }());
7140
7329
 
7141
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7330
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
7142
7331
  /*
7143
7332
  * Copyright (c) Microsoft Corporation. All rights reserved.
7144
7333
  * Licensed under the MIT License.
@@ -7235,7 +7424,7 @@
7235
7424
  PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
7236
7425
  })(PerformanceEventStatus || (PerformanceEventStatus = {}));
7237
7426
 
7238
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7427
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
7239
7428
 
7240
7429
  /*
7241
7430
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7505,7 +7694,7 @@
7505
7694
  return PerformanceClient;
7506
7695
  }());
7507
7696
 
7508
- /*! @azure/msal-common v6.3.0 2022-05-02 */
7697
+ /*! @azure/msal-common v7.1.0 2022-07-05 */
7509
7698
 
7510
7699
  /*
7511
7700
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7563,7 +7752,7 @@
7563
7752
  },
7564
7753
  hashEmptyError: {
7565
7754
  code: "hash_empty_error",
7566
- desc: "Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash."
7755
+ desc: "Hash value cannot be processed because it is empty. Please verify that your redirectUri is not clearing the hash. For more visit: aka.ms/msaljs/browser-errors."
7567
7756
  },
7568
7757
  hashDoesNotContainStateError: {
7569
7758
  code: "no_state_in_hash",
@@ -7571,7 +7760,7 @@
7571
7760
  },
7572
7761
  hashDoesNotContainKnownPropertiesError: {
7573
7762
  code: "hash_does_not_contain_known_properties",
7574
- desc: "Hash does not contain known properites. Please verify that your redirectUri is not changing the hash."
7763
+ desc: "Hash does not contain known properites. Please verify that your redirectUri is not changing the hash. For more visit: aka.ms/msaljs/browser-errors."
7575
7764
  },
7576
7765
  unableToParseStateError: {
7577
7766
  code: "unable_to_parse_state",
@@ -7607,7 +7796,7 @@
7607
7796
  },
7608
7797
  redirectInIframeError: {
7609
7798
  code: "redirect_in_iframe",
7610
- 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."
7799
+ 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."
7611
7800
  },
7612
7801
  blockTokenRequestsInHiddenIframeError: {
7613
7802
  code: "block_iframe_reload",
@@ -7832,7 +8021,7 @@
7832
8021
  return new BrowserAuthError(BrowserAuthErrorMessage.monitorIframeTimeoutError.code, BrowserAuthErrorMessage.monitorIframeTimeoutError.desc);
7833
8022
  };
7834
8023
  /**
7835
- * Creates an error thrown when navigateWindow is called inside an iframe.
8024
+ * Creates an error thrown when navigateWindow is called inside an iframe or brokered applications.
7836
8025
  * @param windowParentCheck
7837
8026
  */
7838
8027
  BrowserAuthError.createRedirectInIframeError = function (windowParentCheck) {
@@ -8051,7 +8240,8 @@
8051
8240
  };
8052
8241
  var NativeConstants = {
8053
8242
  CHANNEL_ID: "53ee284d-920a-4b59-9d30-a60315b26836",
8054
- PREFERRED_EXTENSION_ID: "ppnbnpeolgkicgegkbkbjmhlideopiji"
8243
+ PREFERRED_EXTENSION_ID: "ppnbnpeolgkicgegkbkbjmhlideopiji",
8244
+ MATS_TELEMETRY: "MATS"
8055
8245
  };
8056
8246
  var NativeExtensionMethod;
8057
8247
  (function (NativeExtensionMethod) {
@@ -8929,7 +9119,7 @@
8929
9119
  * @param expires
8930
9120
  */
8931
9121
  BrowserCacheManager.prototype.setItemCookie = function (cookieName, cookieValue, expires) {
8932
- var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;";
9122
+ var cookieStr = encodeURIComponent(cookieName) + "=" + encodeURIComponent(cookieValue) + ";path=/;SameSite=Lax;";
8933
9123
  if (expires) {
8934
9124
  var expireTime = this.getCookieExpirationTime(expires);
8935
9125
  cookieStr += "expires=" + expireTime + ";";
@@ -9301,7 +9491,7 @@
9301
9491
 
9302
9492
  /* eslint-disable header/header */
9303
9493
  var name = "@azure/msal-browser";
9304
- var version = "2.24.0";
9494
+ var version = "2.27.0";
9305
9495
 
9306
9496
  /*
9307
9497
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9850,7 +10040,8 @@
9850
10040
  protocolMode: this.config.auth.protocolMode,
9851
10041
  knownAuthorities: this.config.auth.knownAuthorities,
9852
10042
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
9853
- authorityMetadata: this.config.auth.authorityMetadata
10043
+ authorityMetadata: this.config.auth.authorityMetadata,
10044
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
9854
10045
  };
9855
10046
  if (!requestAuthority) return [3 /*break*/, 2];
9856
10047
  this.logger.verbose("Creating discovered authority with request authority");
@@ -10082,6 +10273,7 @@
10082
10273
  knownAuthorities: this.config.auth.knownAuthorities,
10083
10274
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10084
10275
  authorityMetadata: this.config.auth.authorityMetadata,
10276
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache
10085
10277
  };
10086
10278
  userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
10087
10279
  builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
@@ -10095,6 +10287,8 @@
10095
10287
  })
10096
10288
  .catch(function (error) {
10097
10289
  getAuthorityMeasurement.endMeasurement({
10290
+ errorCode: error.errorCode,
10291
+ subErrorCode: error.subError,
10098
10292
  success: false
10099
10293
  });
10100
10294
  throw error;
@@ -10154,11 +10348,11 @@
10154
10348
  * Abstract class which defines operations for a browser interaction handling class.
10155
10349
  */
10156
10350
  var InteractionHandler = /** @class */ (function () {
10157
- function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) {
10351
+ function InteractionHandler(authCodeModule, storageImpl, authCodeRequest, logger) {
10158
10352
  this.authModule = authCodeModule;
10159
10353
  this.browserStorage = storageImpl;
10160
10354
  this.authCodeRequest = authCodeRequest;
10161
- this.browserRequestLogger = browserRequestLogger;
10355
+ this.logger = logger;
10162
10356
  }
10163
10357
  /**
10164
10358
  * Function to handle response parameters from hash.
@@ -10168,7 +10362,7 @@
10168
10362
  return __awaiter$1(this, void 0, void 0, function () {
10169
10363
  var stateKey, requestState, authCodeResponse;
10170
10364
  return __generator$1(this, function (_a) {
10171
- this.browserRequestLogger.verbose("InteractionHandler.handleCodeResponse called");
10365
+ this.logger.verbose("InteractionHandler.handleCodeResponse called");
10172
10366
  // Check that location hash isn't empty.
10173
10367
  if (StringUtils.isEmpty(locationHash)) {
10174
10368
  throw BrowserAuthError.createEmptyHashError(locationHash);
@@ -10209,7 +10403,7 @@
10209
10403
  return __generator$1(this, function (_a) {
10210
10404
  switch (_a.label) {
10211
10405
  case 0:
10212
- this.browserRequestLogger.trace("InteractionHandler.handleCodeResponseFromServer called");
10406
+ this.logger.trace("InteractionHandler.handleCodeResponseFromServer called");
10213
10407
  stateKey = this.browserStorage.generateStateKey(state);
10214
10408
  requestState = this.browserStorage.getTemporaryCache(stateKey);
10215
10409
  if (!requestState) {
@@ -10297,8 +10491,8 @@
10297
10491
  */
10298
10492
  var RedirectHandler = /** @class */ (function (_super) {
10299
10493
  __extends$1(RedirectHandler, _super);
10300
- function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger, browserCrypto) {
10301
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
10494
+ function RedirectHandler(authCodeModule, storageImpl, authCodeRequest, logger, browserCrypto) {
10495
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
10302
10496
  _this.browserCrypto = browserCrypto;
10303
10497
  return _this;
10304
10498
  }
@@ -10312,38 +10506,38 @@
10312
10506
  return __generator$1(this, function (_a) {
10313
10507
  switch (_a.label) {
10314
10508
  case 0:
10315
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest called");
10509
+ this.logger.verbose("RedirectHandler.initiateAuthRequest called");
10316
10510
  if (!!StringUtils.isEmpty(requestUrl)) return [3 /*break*/, 7];
10317
10511
  // Cache start page, returns to this page after redirectUri if navigateToLoginRequestUrl is true
10318
10512
  if (params.redirectStartPage) {
10319
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page");
10513
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page");
10320
10514
  this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, params.redirectStartPage, true);
10321
10515
  }
10322
10516
  // Set interaction status in the library.
10323
10517
  this.browserStorage.setTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, this.authCodeRequest.correlationId, true);
10324
10518
  this.browserStorage.cacheCodeRequest(this.authCodeRequest, this.browserCrypto);
10325
- this.browserRequestLogger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: " + requestUrl);
10519
+ this.logger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: " + requestUrl);
10326
10520
  navigationOptions = {
10327
10521
  apiId: exports.ApiId.acquireTokenRedirect,
10328
10522
  timeout: params.redirectTimeout,
10329
10523
  noHistory: false
10330
10524
  };
10331
10525
  if (!(typeof params.onRedirectNavigate === "function")) return [3 /*break*/, 4];
10332
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: Invoking onRedirectNavigate callback");
10526
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: Invoking onRedirectNavigate callback");
10333
10527
  navigate = params.onRedirectNavigate(requestUrl);
10334
10528
  if (!(navigate !== false)) return [3 /*break*/, 2];
10335
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate did not return false, navigating");
10529
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate did not return false, navigating");
10336
10530
  return [4 /*yield*/, params.navigationClient.navigateExternal(requestUrl, navigationOptions)];
10337
10531
  case 1:
10338
10532
  _a.sent();
10339
10533
  return [2 /*return*/];
10340
10534
  case 2:
10341
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate returned false, stopping navigation");
10535
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: onRedirectNavigate returned false, stopping navigation");
10342
10536
  return [2 /*return*/];
10343
10537
  case 3: return [3 /*break*/, 6];
10344
10538
  case 4:
10345
10539
  // Navigate window to request URL
10346
- this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: Navigating window to navigate url");
10540
+ this.logger.verbose("RedirectHandler.initiateAuthRequest: Navigating window to navigate url");
10347
10541
  return [4 /*yield*/, params.navigationClient.navigateExternal(requestUrl, navigationOptions)];
10348
10542
  case 5:
10349
10543
  _a.sent();
@@ -10351,7 +10545,7 @@
10351
10545
  case 6: return [3 /*break*/, 8];
10352
10546
  case 7:
10353
10547
  // Throw error if request URL is empty.
10354
- this.browserRequestLogger.info("RedirectHandler.initiateAuthRequest: Navigate url is empty");
10548
+ this.logger.info("RedirectHandler.initiateAuthRequest: Navigate url is empty");
10355
10549
  throw BrowserAuthError.createEmptyNavigationUriError();
10356
10550
  case 8: return [2 /*return*/];
10357
10551
  }
@@ -10368,7 +10562,7 @@
10368
10562
  return __generator$1(this, function (_a) {
10369
10563
  switch (_a.label) {
10370
10564
  case 0:
10371
- this.browserRequestLogger.verbose("RedirectHandler.handleCodeResponse called");
10565
+ this.logger.verbose("RedirectHandler.handleCodeResponse called");
10372
10566
  // Check that location hash isn't empty.
10373
10567
  if (StringUtils.isEmpty(locationHash)) {
10374
10568
  throw BrowserAuthError.createEmptyHashError(locationHash);
@@ -10469,6 +10663,8 @@
10469
10663
  NativeStatusCode["NO_NETWORK"] = "NO_NETWORK";
10470
10664
  NativeStatusCode["TRANSIENT_ERROR"] = "TRANSIENT_ERROR";
10471
10665
  NativeStatusCode["PERSISTENT_ERROR"] = "PERSISTENT_ERROR";
10666
+ NativeStatusCode["DISABLED"] = "DISABLED";
10667
+ NativeStatusCode["ACCOUNT_UNAVAILABLE"] = "ACCOUNT_UNAVAILABLE";
10472
10668
  })(NativeStatusCode || (NativeStatusCode = {}));
10473
10669
  var NativeAuthErrorMessage = {
10474
10670
  extensionError: {
@@ -10492,7 +10688,7 @@
10492
10688
  * These errors should result in a fallback to the 'standard' browser based auth flow.
10493
10689
  */
10494
10690
  NativeAuthError.prototype.isFatal = function () {
10495
- if (this.ext && this.ext.status && this.ext.status === NativeStatusCode.PERSISTENT_ERROR) {
10691
+ if (this.ext && this.ext.status && (this.ext.status === NativeStatusCode.PERSISTENT_ERROR || this.ext.status === NativeStatusCode.DISABLED)) {
10496
10692
  return true;
10497
10693
  }
10498
10694
  switch (this.errorCode) {
@@ -10512,6 +10708,8 @@
10512
10708
  NativeAuthError.createError = function (code, description, ext) {
10513
10709
  if (ext && ext.status) {
10514
10710
  switch (ext.status) {
10711
+ case NativeStatusCode.ACCOUNT_UNAVAILABLE:
10712
+ return InteractionRequiredAuthError.createNativeAccountUnavailableError();
10515
10713
  case NativeStatusCode.USER_INTERACTION_REQUIRED:
10516
10714
  return new InteractionRequiredAuthError(code, description);
10517
10715
  case NativeStatusCode.USER_CANCEL:
@@ -10580,6 +10778,8 @@
10580
10778
  .catch(function (error) {
10581
10779
  nativeATMeasurement.endMeasurement({
10582
10780
  success: false,
10781
+ errorCode: error.errorCode,
10782
+ subErrorCode: error.subError,
10583
10783
  isNativeBroker: true
10584
10784
  });
10585
10785
  throw error;
@@ -10698,7 +10898,7 @@
10698
10898
  */
10699
10899
  NativeInteractionClient.prototype.handleNativeResponse = function (response, request, reqTimestamp) {
10700
10900
  return __awaiter$1(this, void 0, void 0, function () {
10701
- var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, result;
10901
+ var idTokenObj, authority, authorityPreferredCache, homeAccountIdentifier, accountEntity, responseScopes, accountProperties, uid, tid, responseAccessToken, responseTokenType, _a, popTokenGenerator, shrParameters, mats, result;
10702
10902
  var _this = this;
10703
10903
  return __generator$1(this, function (_b) {
10704
10904
  switch (_b.label) {
@@ -10714,14 +10914,14 @@
10714
10914
  authority = _b.sent();
10715
10915
  authorityPreferredCache = authority.getPreferredCache();
10716
10916
  homeAccountIdentifier = AccountEntity.generateHomeAccountId(response.client_info || Constants.EMPTY_STRING, AuthorityType.Default, this.logger, this.browserCrypto, idTokenObj);
10717
- accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
10917
+ accountEntity = AccountEntity.createAccount(response.client_info, homeAccountIdentifier, idTokenObj, undefined, undefined, undefined, authorityPreferredCache, response.account.id);
10718
10918
  this.browserStorage.setAccount(accountEntity);
10719
10919
  responseScopes = response.scopes ? ScopeSet.fromString(response.scopes) : ScopeSet.fromString(request.scopes);
10720
10920
  accountProperties = response.account.properties || {};
10721
10921
  uid = accountProperties["UID"] || idTokenObj.claims.oid || idTokenObj.claims.sub || Constants.EMPTY_STRING;
10722
10922
  tid = accountProperties["TenantId"] || idTokenObj.claims.tid || Constants.EMPTY_STRING;
10723
10923
  responseTokenType = exports.AuthenticationScheme.BEARER;
10724
- _a = request.token_type;
10924
+ _a = request.tokenType;
10725
10925
  switch (_a) {
10726
10926
  case exports.AuthenticationScheme.POP: return [3 /*break*/, 2];
10727
10927
  }
@@ -10742,7 +10942,14 @@
10742
10942
  shrClaims: request.shrClaims,
10743
10943
  shrNonce: request.shrNonce
10744
10944
  };
10745
- return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, shrParameters)];
10945
+ /**
10946
+ * KeyID must be present in the native request from when the PoP key was generated in order for
10947
+ * PopTokenGenerator to query the full key for signing
10948
+ */
10949
+ if (!request.keyId) {
10950
+ throw ClientAuthError.createKeyIdMissingError();
10951
+ }
10952
+ return [4 /*yield*/, popTokenGenerator.signPopToken(response.access_token, request.keyId, shrParameters)];
10746
10953
  case 3:
10747
10954
  responseAccessToken = _b.sent();
10748
10955
  return [3 /*break*/, 5];
@@ -10752,6 +10959,7 @@
10752
10959
  }
10753
10960
  _b.label = 5;
10754
10961
  case 5:
10962
+ mats = this.getMATSFromResponse(response);
10755
10963
  result = {
10756
10964
  authority: authority.canonicalAuthority,
10757
10965
  uniqueId: uid,
@@ -10761,7 +10969,7 @@
10761
10969
  idToken: response.id_token,
10762
10970
  idTokenClaims: idTokenObj.claims,
10763
10971
  accessToken: responseAccessToken,
10764
- fromCache: false,
10972
+ fromCache: mats ? this.isResponseFromCache(mats) : false,
10765
10973
  expiresOn: new Date(Number(reqTimestamp + response.expires_in) * 1000),
10766
10974
  tokenType: responseTokenType,
10767
10975
  correlationId: this.correlationId,
@@ -10794,15 +11002,44 @@
10794
11002
  throw NativeAuthError.createUnexpectedError("Response missing expected properties.");
10795
11003
  }
10796
11004
  };
11005
+ /**
11006
+ * Gets MATS telemetry from native response
11007
+ * @param response
11008
+ * @returns
11009
+ */
11010
+ NativeInteractionClient.prototype.getMATSFromResponse = function (response) {
11011
+ if (response.properties.MATS) {
11012
+ try {
11013
+ return JSON.parse(response.properties.MATS);
11014
+ }
11015
+ catch (e) {
11016
+ this.logger.error("NativeInteractionClient - Error parsing MATS telemetry, returning null instead");
11017
+ }
11018
+ }
11019
+ return null;
11020
+ };
11021
+ /**
11022
+ * Returns whether or not response came from native cache
11023
+ * @param response
11024
+ * @returns
11025
+ */
11026
+ NativeInteractionClient.prototype.isResponseFromCache = function (mats) {
11027
+ if (typeof mats.is_cached === "undefined") {
11028
+ this.logger.verbose("NativeInteractionClient - MATS telemetry does not contain field indicating if response was served from cache. Returning false.");
11029
+ return false;
11030
+ }
11031
+ return !!mats.is_cached;
11032
+ };
10797
11033
  /**
10798
11034
  * Translates developer provided request object into NativeRequest object
10799
11035
  * @param request
10800
11036
  */
10801
11037
  NativeInteractionClient.prototype.initializeNativeRequest = function (request) {
10802
11038
  return __awaiter$1(this, void 0, void 0, function () {
10803
- var authority, canonicalAuthority, scopes, scopeSet, instanceAware, validatedRequest, shrParameters, popTokenGenerator, cnf, _a;
10804
- return __generator$1(this, function (_b) {
10805
- switch (_b.label) {
11039
+ var authority, canonicalAuthority, scopes, scopeSet, getPrompt, validatedRequest, shrParameters, popTokenGenerator, reqCnfData;
11040
+ var _this = this;
11041
+ return __generator$1(this, function (_a) {
11042
+ switch (_a.label) {
10806
11043
  case 0:
10807
11044
  this.logger.trace("NativeInteractionClient - initializeNativeRequest called");
10808
11045
  authority = request.authority || this.config.auth.authority;
@@ -10811,21 +11048,34 @@
10811
11048
  scopes = request && request.scopes || [];
10812
11049
  scopeSet = new ScopeSet(scopes);
10813
11050
  scopeSet.appendScopes(OIDC_DEFAULT_SCOPES);
10814
- if (request.prompt) {
11051
+ getPrompt = function () {
11052
+ // If request is silent, prompt is always none
11053
+ switch (_this.apiId) {
11054
+ case exports.ApiId.ssoSilent:
11055
+ case exports.ApiId.acquireTokenSilent_silentFlow:
11056
+ _this.logger.trace("initializeNativeRequest: silent request sets prompt to none");
11057
+ return PromptValue.NONE;
11058
+ }
11059
+ // Prompt not provided, request may proceed and native broker decides if it needs to prompt
11060
+ if (!request.prompt) {
11061
+ _this.logger.trace("initializeNativeRequest: prompt was not provided");
11062
+ return undefined;
11063
+ }
11064
+ // If request is interactive, check if prompt provided is allowed to go directly to native broker
10815
11065
  switch (request.prompt) {
10816
11066
  case PromptValue.NONE:
10817
11067
  case PromptValue.CONSENT:
10818
- this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
10819
- break;
11068
+ case PromptValue.LOGIN:
11069
+ _this.logger.trace("initializeNativeRequest: prompt is compatible with native flow");
11070
+ return request.prompt;
10820
11071
  default:
10821
- this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
11072
+ _this.logger.trace("initializeNativeRequest: prompt = " + request.prompt + " is not compatible with native flow");
10822
11073
  throw BrowserAuthError.createNativePromptParameterNotSupportedError();
10823
11074
  }
10824
- }
10825
- instanceAware = !!(request.extraQueryParameters && request.extraQueryParameters.instance_aware);
10826
- 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, instance_aware: instanceAware, token_type: request.authenticationScheme, windowTitleSubstring: document.title, extraParameters: __assign$1(__assign$1({}, request.extraQueryParameters), request.tokenQueryParameters), extendedExpiryToken: false // Make this configurable?
11075
+ };
11076
+ 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?
10827
11077
  });
10828
- if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 3];
11078
+ if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
10829
11079
  shrParameters = {
10830
11080
  resourceRequestUri: request.resourceRequestUri,
10831
11081
  resourceRequestMethod: request.resourceRequestMethod,
@@ -10835,19 +11085,12 @@
10835
11085
  popTokenGenerator = new PopTokenGenerator(this.browserCrypto);
10836
11086
  return [4 /*yield*/, popTokenGenerator.generateCnf(shrParameters)];
10837
11087
  case 1:
10838
- cnf = _b.sent();
10839
- // to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
10840
- _a = validatedRequest;
10841
- return [4 /*yield*/, popTokenGenerator.generateCnfHash(cnf)];
10842
- case 2:
11088
+ reqCnfData = _a.sent();
10843
11089
  // to reduce the URL length, it is recommended to send the hash of the req_cnf instead of the whole string
10844
- _a.req_cnf = _b.sent();
10845
- _b.label = 3;
10846
- case 3:
10847
- if (this.apiId === exports.ApiId.ssoSilent || this.apiId === exports.ApiId.acquireTokenSilent_silentFlow) {
10848
- validatedRequest.prompt = PromptValue.NONE;
10849
- }
10850
- return [2 /*return*/, validatedRequest];
11090
+ validatedRequest.reqCnf = reqCnfData.reqCnfHash;
11091
+ validatedRequest.keyId = reqCnfData.kid;
11092
+ _a.label = 2;
11093
+ case 2: return [2 /*return*/, validatedRequest];
10851
11094
  }
10852
11095
  });
10853
11096
  });
@@ -11423,269 +11666,37 @@
11423
11666
  * Copyright (c) Microsoft Corporation. All rights reserved.
11424
11667
  * Licensed under the MIT License.
11425
11668
  */
11426
- var PopupUtils = /** @class */ (function () {
11427
- function PopupUtils(storageImpl, logger) {
11428
- this.browserStorage = storageImpl;
11429
- this.logger = logger;
11669
+ var PopupClient = /** @class */ (function (_super) {
11670
+ __extends$1(PopupClient, _super);
11671
+ function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) {
11672
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
11430
11673
  // Properly sets this reference for the unload event.
11431
- this.unloadWindow = this.unloadWindow.bind(this);
11674
+ _this.unloadWindow = _this.unloadWindow.bind(_this);
11675
+ return _this;
11432
11676
  }
11433
11677
  /**
11434
- * @hidden
11435
- *
11436
- * Configures popup window for login.
11437
- *
11438
- * @param urlNavigate
11439
- * @param title
11440
- * @param popUpWidth
11441
- * @param popUpHeight
11442
- * @param popupWindowAttributes
11443
- * @ignore
11444
- * @hidden
11678
+ * Acquires tokens by opening a popup window to the /authorize endpoint of the authority
11679
+ * @param request
11445
11680
  */
11446
- PopupUtils.prototype.openPopup = function (urlNavigate, popupParams) {
11681
+ PopupClient.prototype.acquireToken = function (request) {
11447
11682
  try {
11448
- var popupWindow = void 0;
11449
- // Popup window passed in, setting url to navigate to
11450
- if (popupParams.popup) {
11451
- popupWindow = popupParams.popup;
11452
- this.logger.verbosePii("Navigating popup window to: " + urlNavigate);
11453
- popupWindow.location.assign(urlNavigate);
11454
- }
11455
- else if (typeof popupParams.popup === "undefined") {
11456
- // Popup will be undefined if it was not passed in
11457
- this.logger.verbosePii("Opening popup window to: " + urlNavigate);
11458
- popupWindow = PopupUtils.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes, this.logger);
11459
- }
11460
- // Popup will be null if popups are blocked
11461
- if (!popupWindow) {
11462
- throw BrowserAuthError.createEmptyWindowCreatedError();
11683
+ var popupName = this.generatePopupName(request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority);
11684
+ var popupWindowAttributes = request.popupWindowAttributes || {};
11685
+ // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
11686
+ if (this.config.system.asyncPopups) {
11687
+ this.logger.verbose("asyncPopups set to true, acquiring token");
11688
+ // Passes on popup position and dimensions if in request
11689
+ return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes);
11463
11690
  }
11464
- if (popupWindow.focus) {
11465
- popupWindow.focus();
11691
+ else {
11692
+ // asyncPopups flag is set to false. Opens popup before acquiring token.
11693
+ this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
11694
+ var popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
11695
+ return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
11466
11696
  }
11467
- this.currentWindow = popupWindow;
11468
- window.addEventListener("beforeunload", this.unloadWindow);
11469
- return popupWindow;
11470
11697
  }
11471
11698
  catch (e) {
11472
- this.logger.error("error opening popup " + e.message);
11473
- this.browserStorage.setInteractionInProgress(false);
11474
- throw BrowserAuthError.createPopupWindowError(e.toString());
11475
- }
11476
- };
11477
- /**
11478
- * Helper function to set popup window dimensions and position
11479
- * @param urlNavigate
11480
- * @param popupName
11481
- * @param popupWindowAttributes
11482
- * @returns
11483
- */
11484
- PopupUtils.openSizedPopup = function (urlNavigate, popupName, popupWindowAttributes, logger) {
11485
- var _a, _b, _c, _d;
11486
- /**
11487
- * adding winLeft and winTop to account for dual monitor
11488
- * using screenLeft and screenTop for IE8 and earlier
11489
- */
11490
- var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
11491
- var winTop = window.screenTop ? window.screenTop : window.screenY;
11492
- /**
11493
- * window.innerWidth displays browser window"s height and width excluding toolbars
11494
- * using document.documentElement.clientWidth for IE8 and earlier
11495
- */
11496
- var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
11497
- var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
11498
- var width = (_a = popupWindowAttributes.popupSize) === null || _a === void 0 ? void 0 : _a.width;
11499
- var height = (_b = popupWindowAttributes.popupSize) === null || _b === void 0 ? void 0 : _b.height;
11500
- var top = (_c = popupWindowAttributes.popupPosition) === null || _c === void 0 ? void 0 : _c.top;
11501
- var left = (_d = popupWindowAttributes.popupPosition) === null || _d === void 0 ? void 0 : _d.left;
11502
- if (!width || width < 0 || width > winWidth) {
11503
- logger.verbose("Default popup window width used. Window width not configured or invalid.");
11504
- width = BrowserConstants.POPUP_WIDTH;
11505
- }
11506
- if (!height || height < 0 || height > winHeight) {
11507
- logger.verbose("Default popup window height used. Window height not configured or invalid.");
11508
- height = BrowserConstants.POPUP_HEIGHT;
11509
- }
11510
- if (!top || top < 0 || top > winHeight) {
11511
- logger.verbose("Default popup window top position used. Window top not configured or invalid.");
11512
- top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);
11513
- }
11514
- if (!left || left < 0 || left > winWidth) {
11515
- logger.verbose("Default popup window left position used. Window left not configured or invalid.");
11516
- left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);
11517
- }
11518
- return window.open(urlNavigate, popupName, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", scrollbars=yes");
11519
- };
11520
- /**
11521
- * Event callback to unload main window.
11522
- */
11523
- PopupUtils.prototype.unloadWindow = function (e) {
11524
- this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Popup);
11525
- if (this.currentWindow) {
11526
- this.currentWindow.close();
11527
- }
11528
- // Guarantees browser unload will happen, so no other errors will be thrown.
11529
- e.preventDefault();
11530
- };
11531
- /**
11532
- * Closes popup, removes any state vars created during popup calls.
11533
- * @param popupWindow
11534
- */
11535
- PopupUtils.prototype.cleanPopup = function (popupWindow) {
11536
- if (popupWindow) {
11537
- // Close window.
11538
- popupWindow.close();
11539
- }
11540
- // Remove window unload function
11541
- window.removeEventListener("beforeunload", this.unloadWindow);
11542
- // Interaction is completed - remove interaction status.
11543
- this.browserStorage.setInteractionInProgress(false);
11544
- };
11545
- /**
11546
- * Monitors a window until it loads a url with the same origin.
11547
- * @param popupWindow - window that is being monitored
11548
- */
11549
- PopupUtils.prototype.monitorPopupForSameOrigin = function (popupWindow) {
11550
- var _this = this;
11551
- return new Promise(function (resolve, reject) {
11552
- var intervalId = setInterval(function () {
11553
- if (popupWindow.closed) {
11554
- // Window is closed
11555
- _this.cleanPopup();
11556
- clearInterval(intervalId);
11557
- reject(BrowserAuthError.createUserCancelledError());
11558
- return;
11559
- }
11560
- var href = Constants.EMPTY_STRING;
11561
- try {
11562
- /*
11563
- * Will throw if cross origin,
11564
- * which should be caught and ignored
11565
- * since we need the interval to keep running while on STS UI.
11566
- */
11567
- href = popupWindow.location.href;
11568
- }
11569
- catch (e) { }
11570
- // Don't process blank pages or cross domain
11571
- if (StringUtils.isEmpty(href) || href === "about:blank") {
11572
- return;
11573
- }
11574
- clearInterval(intervalId);
11575
- resolve();
11576
- }, BrowserConstants.POLL_INTERVAL_MS);
11577
- });
11578
- };
11579
- /**
11580
- * Generates the name for the popup based on the client id and request
11581
- * @param clientId
11582
- * @param request
11583
- */
11584
- PopupUtils.generatePopupName = function (clientId, scopes, authority, correlationId) {
11585
- return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + scopes.join("-") + "." + authority + "." + correlationId;
11586
- };
11587
- /**
11588
- * Generates the name for the popup based on the client id and request for logouts
11589
- * @param clientId
11590
- * @param request
11591
- */
11592
- PopupUtils.generateLogoutPopupName = function (clientId, request) {
11593
- var homeAccountId = request.account && request.account.homeAccountId;
11594
- return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + homeAccountId + "." + request.correlationId;
11595
- };
11596
- return PopupUtils;
11597
- }());
11598
-
11599
- /*
11600
- * Copyright (c) Microsoft Corporation. All rights reserved.
11601
- * Licensed under the MIT License.
11602
- */
11603
- /**
11604
- * This class implements the interaction handler base class for browsers. It is written specifically for handling
11605
- * popup window scenarios. It includes functions for monitoring the popup window for a hash.
11606
- */
11607
- var PopupHandler = /** @class */ (function (_super) {
11608
- __extends$1(PopupHandler, _super);
11609
- function PopupHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) {
11610
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
11611
- // Properly sets this reference for the unload event.
11612
- _this.popupUtils = new PopupUtils(storageImpl, browserRequestLogger);
11613
- return _this;
11614
- }
11615
- /**
11616
- * Opens a popup window with given request Url.
11617
- * @param requestUrl
11618
- */
11619
- PopupHandler.prototype.initiateAuthRequest = function (requestUrl, params) {
11620
- // Check that request url is not empty.
11621
- if (!StringUtils.isEmpty(requestUrl)) {
11622
- this.browserRequestLogger.infoPii("Navigate to: " + requestUrl);
11623
- // Open the popup window to requestUrl.
11624
- return this.popupUtils.openPopup(requestUrl, params);
11625
- }
11626
- else {
11627
- // Throw error if request URL is empty.
11628
- this.browserRequestLogger.error("Navigate url is empty");
11629
- throw BrowserAuthError.createEmptyNavigationUriError();
11630
- }
11631
- };
11632
- /**
11633
- * Monitors a window until it loads a url with a known hash, or hits a specified timeout.
11634
- * @param popupWindow - window that is being monitored
11635
- * @param timeout - milliseconds until timeout
11636
- */
11637
- PopupHandler.prototype.monitorPopupForHash = function (popupWindow) {
11638
- var _this = this;
11639
- return this.popupUtils.monitorPopupForSameOrigin(popupWindow).then(function () {
11640
- var contentHash = popupWindow.location.hash;
11641
- BrowserUtils.clearHash(popupWindow);
11642
- _this.popupUtils.cleanPopup(popupWindow);
11643
- if (!contentHash) {
11644
- throw BrowserAuthError.createEmptyHashError(popupWindow.location.href);
11645
- }
11646
- if (UrlString.hashContainsKnownProperties(contentHash)) {
11647
- return contentHash;
11648
- }
11649
- else {
11650
- throw BrowserAuthError.createHashDoesNotContainKnownPropertiesError();
11651
- }
11652
- });
11653
- };
11654
- return PopupHandler;
11655
- }(InteractionHandler));
11656
-
11657
- /*
11658
- * Copyright (c) Microsoft Corporation. All rights reserved.
11659
- * Licensed under the MIT License.
11660
- */
11661
- var PopupClient = /** @class */ (function (_super) {
11662
- __extends$1(PopupClient, _super);
11663
- function PopupClient() {
11664
- return _super !== null && _super.apply(this, arguments) || this;
11665
- }
11666
- /**
11667
- * Acquires tokens by opening a popup window to the /authorize endpoint of the authority
11668
- * @param request
11669
- */
11670
- PopupClient.prototype.acquireToken = function (request) {
11671
- try {
11672
- var popupName = PopupUtils.generatePopupName(this.config.auth.clientId, request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority, this.correlationId);
11673
- var popupWindowAttributes = request.popupWindowAttributes || {};
11674
- // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
11675
- if (this.config.system.asyncPopups) {
11676
- this.logger.verbose("asyncPopups set to true, acquiring token");
11677
- // Passes on popup position and dimensions if in request
11678
- return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes);
11679
- }
11680
- else {
11681
- // asyncPopups flag is set to false. Opens popup before acquiring token.
11682
- this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
11683
- var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11684
- return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
11685
- }
11686
- }
11687
- catch (e) {
11688
- return Promise.reject(e);
11699
+ return Promise.reject(e);
11689
11700
  }
11690
11701
  };
11691
11702
  /**
@@ -11696,7 +11707,7 @@
11696
11707
  try {
11697
11708
  this.logger.verbose("logoutPopup called");
11698
11709
  var validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
11699
- var popupName = PopupUtils.generateLogoutPopupName(this.config.auth.clientId, validLogoutRequest);
11710
+ var popupName = this.generateLogoutPopupName(validLogoutRequest);
11700
11711
  var authority = logoutRequest && logoutRequest.authority;
11701
11712
  var mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
11702
11713
  var popupWindowAttributes = (logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.popupWindowAttributes) || {};
@@ -11709,7 +11720,7 @@
11709
11720
  else {
11710
11721
  // asyncPopups flag is set to false. Opens popup before logging out.
11711
11722
  this.logger.verbose("asyncPopup set to false, opening popup");
11712
- var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11723
+ var popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
11713
11724
  return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, popup, mainWindowRedirectUri);
11714
11725
  }
11715
11726
  }
@@ -11758,15 +11769,15 @@
11758
11769
  return [4 /*yield*/, authClient.getAuthCodeUrl(__assign$1(__assign$1({}, validRequest), { nativeBroker: isNativeBroker }))];
11759
11770
  case 5:
11760
11771
  navigateUrl = _a.sent();
11761
- interactionHandler = new PopupHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
11772
+ interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
11762
11773
  popupParameters = {
11763
11774
  popup: popup,
11764
11775
  popupName: popupName,
11765
11776
  popupWindowAttributes: popupWindowAttributes
11766
11777
  };
11767
- popupWindow = interactionHandler.initiateAuthRequest(navigateUrl, popupParameters);
11778
+ popupWindow = this.initiateAuthRequest(navigateUrl, popupParameters);
11768
11779
  this.eventHandler.emitEvent(exports.EventType.POPUP_OPENED, exports.InteractionType.Popup, { popupWindow: popupWindow }, null);
11769
- return [4 /*yield*/, interactionHandler.monitorPopupForHash(popupWindow)];
11780
+ return [4 /*yield*/, this.monitorPopupForHash(popupWindow)];
11770
11781
  case 6:
11771
11782
  hash = _a.sent();
11772
11783
  serverParams = UrlString.getDeserializedHash(hash);
@@ -11824,7 +11835,7 @@
11824
11835
  */
11825
11836
  PopupClient.prototype.logoutPopupAsync = function (validRequest, popupName, popupWindowAttributes, requestAuthority, popup, mainWindowRedirectUri) {
11826
11837
  return __awaiter$1(this, void 0, void 0, function () {
11827
- var serverTelemetryManager, authClient, logoutUri, popupUtils, popupWindow, e_2, navigationOptions, absoluteUrl, e_3;
11838
+ var serverTelemetryManager, authClient, logoutUri, popupWindow, navigationOptions, absoluteUrl, e_2;
11828
11839
  return __generator$1(this, function (_a) {
11829
11840
  switch (_a.label) {
11830
11841
  case 0:
@@ -11833,7 +11844,7 @@
11833
11844
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.logoutPopup);
11834
11845
  _a.label = 1;
11835
11846
  case 1:
11836
- _a.trys.push([1, 8, , 9]);
11847
+ _a.trys.push([1, 5, , 6]);
11837
11848
  // Clear cache on logout
11838
11849
  return [4 /*yield*/, this.clearCacheOnLogout(validRequest.account)];
11839
11850
  case 2:
@@ -11845,25 +11856,11 @@
11845
11856
  this.logger.verbose("Auth code client created");
11846
11857
  logoutUri = authClient.getLogoutUri(validRequest);
11847
11858
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_SUCCESS, exports.InteractionType.Popup, validRequest);
11848
- popupUtils = new PopupUtils(this.browserStorage, this.logger);
11849
- popupWindow = popupUtils.openPopup(logoutUri, { popupName: popupName, popupWindowAttributes: popupWindowAttributes, popup: popup });
11859
+ popupWindow = this.openPopup(logoutUri, { popupName: popupName, popupWindowAttributes: popupWindowAttributes, popup: popup });
11850
11860
  this.eventHandler.emitEvent(exports.EventType.POPUP_OPENED, exports.InteractionType.Popup, { popupWindow: popupWindow }, null);
11851
- _a.label = 4;
11861
+ return [4 /*yield*/, this.waitForLogoutPopup(popupWindow)];
11852
11862
  case 4:
11853
- _a.trys.push([4, 6, , 7]);
11854
- // Don't care if this throws an error (User Cancelled)
11855
- return [4 /*yield*/, popupUtils.monitorPopupForSameOrigin(popupWindow)];
11856
- case 5:
11857
- // Don't care if this throws an error (User Cancelled)
11858
11863
  _a.sent();
11859
- this.logger.verbose("Popup successfully redirected to postLogoutRedirectUri");
11860
- return [3 /*break*/, 7];
11861
- case 6:
11862
- e_2 = _a.sent();
11863
- this.logger.verbose("Error occurred while monitoring popup for same origin. Session on server may remain active. Error: " + e_2);
11864
- return [3 /*break*/, 7];
11865
- case 7:
11866
- popupUtils.cleanPopup(popupWindow);
11867
11864
  if (mainWindowRedirectUri) {
11868
11865
  navigationOptions = {
11869
11866
  apiId: exports.ApiId.logoutPopup,
@@ -11878,28 +11875,280 @@
11878
11875
  else {
11879
11876
  this.logger.verbose("No main window navigation requested");
11880
11877
  }
11881
- return [3 /*break*/, 9];
11882
- case 8:
11883
- e_3 = _a.sent();
11878
+ return [3 /*break*/, 6];
11879
+ case 5:
11880
+ e_2 = _a.sent();
11884
11881
  if (popup) {
11885
11882
  // Close the synchronous popup if an error is thrown before the window unload event is registered
11886
11883
  popup.close();
11887
11884
  }
11888
- if (e_3 instanceof AuthError) {
11889
- e_3.setCorrelationId(this.correlationId);
11885
+ if (e_2 instanceof AuthError) {
11886
+ e_2.setCorrelationId(this.correlationId);
11890
11887
  }
11891
11888
  this.browserStorage.setInteractionInProgress(false);
11892
- this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_3);
11889
+ this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_2);
11893
11890
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
11894
- serverTelemetryManager.cacheFailedRequest(e_3);
11895
- throw e_3;
11896
- case 9:
11891
+ serverTelemetryManager.cacheFailedRequest(e_2);
11892
+ throw e_2;
11893
+ case 6:
11897
11894
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
11898
11895
  return [2 /*return*/];
11899
11896
  }
11900
11897
  });
11901
11898
  });
11902
11899
  };
11900
+ /**
11901
+ * Opens a popup window with given request Url.
11902
+ * @param requestUrl
11903
+ */
11904
+ PopupClient.prototype.initiateAuthRequest = function (requestUrl, params) {
11905
+ // Check that request url is not empty.
11906
+ if (!StringUtils.isEmpty(requestUrl)) {
11907
+ this.logger.infoPii("Navigate to: " + requestUrl);
11908
+ // Open the popup window to requestUrl.
11909
+ return this.openPopup(requestUrl, params);
11910
+ }
11911
+ else {
11912
+ // Throw error if request URL is empty.
11913
+ this.logger.error("Navigate url is empty");
11914
+ throw BrowserAuthError.createEmptyNavigationUriError();
11915
+ }
11916
+ };
11917
+ /**
11918
+ * Monitors a window until it loads a url with the same origin.
11919
+ * @param popupWindow - window that is being monitored
11920
+ * @param timeout - timeout for processing hash once popup is redirected back to application
11921
+ */
11922
+ PopupClient.prototype.monitorPopupForHash = function (popupWindow) {
11923
+ var _this = this;
11924
+ return new Promise(function (resolve, reject) {
11925
+ /*
11926
+ * Polling for popups needs to be tick-based,
11927
+ * since a non-trivial amount of time can be spent on interaction (which should not count against the timeout).
11928
+ */
11929
+ var maxTicks = _this.config.system.windowHashTimeout / BrowserConstants.POLL_INTERVAL_MS;
11930
+ var ticks = 0;
11931
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - polling started");
11932
+ var intervalId = setInterval(function () {
11933
+ // Window is closed
11934
+ if (popupWindow.closed) {
11935
+ _this.logger.error("PopupHandler.monitorPopupForHash - window closed");
11936
+ _this.cleanPopup();
11937
+ clearInterval(intervalId);
11938
+ reject(BrowserAuthError.createUserCancelledError());
11939
+ return;
11940
+ }
11941
+ var href = Constants.EMPTY_STRING;
11942
+ var hash = Constants.EMPTY_STRING;
11943
+ try {
11944
+ /*
11945
+ * Will throw if cross origin,
11946
+ * which should be caught and ignored
11947
+ * since we need the interval to keep running while on STS UI.
11948
+ */
11949
+ href = popupWindow.location.href;
11950
+ hash = popupWindow.location.hash;
11951
+ }
11952
+ catch (e) { }
11953
+ // Don't process blank pages or cross domain
11954
+ if (StringUtils.isEmpty(href) || href === "about:blank") {
11955
+ return;
11956
+ }
11957
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - popup window is on same origin as caller");
11958
+ /*
11959
+ * Only run clock when we are on same domain for popups
11960
+ * as popup operations can take a long time.
11961
+ */
11962
+ ticks++;
11963
+ if (hash) {
11964
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
11965
+ clearInterval(intervalId);
11966
+ _this.cleanPopup(popupWindow);
11967
+ if (UrlString.hashContainsKnownProperties(hash)) {
11968
+ _this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
11969
+ resolve(hash);
11970
+ }
11971
+ else {
11972
+ _this.logger.error("PopupHandler.monitorPopupForHash - found hash in url but it does not contain known properties. Check that your router is not changing the hash prematurely.");
11973
+ _this.logger.errorPii("PopupHandler.monitorPopupForHash - hash found: " + hash);
11974
+ reject(BrowserAuthError.createHashDoesNotContainKnownPropertiesError());
11975
+ }
11976
+ }
11977
+ else if (ticks > maxTicks) {
11978
+ _this.logger.error("PopupHandler.monitorPopupForHash - unable to find hash in url, timing out");
11979
+ clearInterval(intervalId);
11980
+ reject(BrowserAuthError.createMonitorPopupTimeoutError());
11981
+ }
11982
+ }, BrowserConstants.POLL_INTERVAL_MS);
11983
+ });
11984
+ };
11985
+ /**
11986
+ * Waits for user interaction in logout popup window
11987
+ * @param popupWindow
11988
+ * @returns
11989
+ */
11990
+ PopupClient.prototype.waitForLogoutPopup = function (popupWindow) {
11991
+ var _this = this;
11992
+ return new Promise(function (resolve) {
11993
+ _this.logger.verbose("PopupHandler.waitForLogoutPopup - polling started");
11994
+ var intervalId = setInterval(function () {
11995
+ // Window is closed
11996
+ if (popupWindow.closed) {
11997
+ _this.logger.error("PopupHandler.waitForLogoutPopup - window closed");
11998
+ _this.cleanPopup();
11999
+ clearInterval(intervalId);
12000
+ resolve();
12001
+ }
12002
+ var href = Constants.EMPTY_STRING;
12003
+ try {
12004
+ /*
12005
+ * Will throw if cross origin,
12006
+ * which should be caught and ignored
12007
+ * since we need the interval to keep running while on STS UI.
12008
+ */
12009
+ href = popupWindow.location.href;
12010
+ }
12011
+ catch (e) { }
12012
+ // Don't process blank pages or cross domain
12013
+ if (StringUtils.isEmpty(href) || href === "about:blank") {
12014
+ return;
12015
+ }
12016
+ _this.logger.verbose("PopupHandler.waitForLogoutPopup - popup window is on same origin as caller, closing.");
12017
+ clearInterval(intervalId);
12018
+ _this.cleanPopup(popupWindow);
12019
+ resolve();
12020
+ }, BrowserConstants.POLL_INTERVAL_MS);
12021
+ });
12022
+ };
12023
+ /**
12024
+ * @hidden
12025
+ *
12026
+ * Configures popup window for login.
12027
+ *
12028
+ * @param urlNavigate
12029
+ * @param title
12030
+ * @param popUpWidth
12031
+ * @param popUpHeight
12032
+ * @param popupWindowAttributes
12033
+ * @ignore
12034
+ * @hidden
12035
+ */
12036
+ PopupClient.prototype.openPopup = function (urlNavigate, popupParams) {
12037
+ try {
12038
+ var popupWindow = void 0;
12039
+ // Popup window passed in, setting url to navigate to
12040
+ if (popupParams.popup) {
12041
+ popupWindow = popupParams.popup;
12042
+ this.logger.verbosePii("Navigating popup window to: " + urlNavigate);
12043
+ popupWindow.location.assign(urlNavigate);
12044
+ }
12045
+ else if (typeof popupParams.popup === "undefined") {
12046
+ // Popup will be undefined if it was not passed in
12047
+ this.logger.verbosePii("Opening popup window to: " + urlNavigate);
12048
+ popupWindow = this.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes);
12049
+ }
12050
+ // Popup will be null if popups are blocked
12051
+ if (!popupWindow) {
12052
+ throw BrowserAuthError.createEmptyWindowCreatedError();
12053
+ }
12054
+ if (popupWindow.focus) {
12055
+ popupWindow.focus();
12056
+ }
12057
+ this.currentWindow = popupWindow;
12058
+ window.addEventListener("beforeunload", this.unloadWindow);
12059
+ return popupWindow;
12060
+ }
12061
+ catch (e) {
12062
+ this.logger.error("error opening popup " + e.message);
12063
+ this.browserStorage.setInteractionInProgress(false);
12064
+ throw BrowserAuthError.createPopupWindowError(e.toString());
12065
+ }
12066
+ };
12067
+ /**
12068
+ * Helper function to set popup window dimensions and position
12069
+ * @param urlNavigate
12070
+ * @param popupName
12071
+ * @param popupWindowAttributes
12072
+ * @returns
12073
+ */
12074
+ PopupClient.prototype.openSizedPopup = function (urlNavigate, popupName, popupWindowAttributes) {
12075
+ var _a, _b, _c, _d;
12076
+ /**
12077
+ * adding winLeft and winTop to account for dual monitor
12078
+ * using screenLeft and screenTop for IE8 and earlier
12079
+ */
12080
+ var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
12081
+ var winTop = window.screenTop ? window.screenTop : window.screenY;
12082
+ /**
12083
+ * window.innerWidth displays browser window"s height and width excluding toolbars
12084
+ * using document.documentElement.clientWidth for IE8 and earlier
12085
+ */
12086
+ var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
12087
+ var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
12088
+ var width = (_a = popupWindowAttributes.popupSize) === null || _a === void 0 ? void 0 : _a.width;
12089
+ var height = (_b = popupWindowAttributes.popupSize) === null || _b === void 0 ? void 0 : _b.height;
12090
+ var top = (_c = popupWindowAttributes.popupPosition) === null || _c === void 0 ? void 0 : _c.top;
12091
+ var left = (_d = popupWindowAttributes.popupPosition) === null || _d === void 0 ? void 0 : _d.left;
12092
+ if (!width || width < 0 || width > winWidth) {
12093
+ this.logger.verbose("Default popup window width used. Window width not configured or invalid.");
12094
+ width = BrowserConstants.POPUP_WIDTH;
12095
+ }
12096
+ if (!height || height < 0 || height > winHeight) {
12097
+ this.logger.verbose("Default popup window height used. Window height not configured or invalid.");
12098
+ height = BrowserConstants.POPUP_HEIGHT;
12099
+ }
12100
+ if (!top || top < 0 || top > winHeight) {
12101
+ this.logger.verbose("Default popup window top position used. Window top not configured or invalid.");
12102
+ top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);
12103
+ }
12104
+ if (!left || left < 0 || left > winWidth) {
12105
+ this.logger.verbose("Default popup window left position used. Window left not configured or invalid.");
12106
+ left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);
12107
+ }
12108
+ return window.open(urlNavigate, popupName, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", scrollbars=yes");
12109
+ };
12110
+ /**
12111
+ * Event callback to unload main window.
12112
+ */
12113
+ PopupClient.prototype.unloadWindow = function (e) {
12114
+ this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Popup);
12115
+ if (this.currentWindow) {
12116
+ this.currentWindow.close();
12117
+ }
12118
+ // Guarantees browser unload will happen, so no other errors will be thrown.
12119
+ e.preventDefault();
12120
+ };
12121
+ /**
12122
+ * Closes popup, removes any state vars created during popup calls.
12123
+ * @param popupWindow
12124
+ */
12125
+ PopupClient.prototype.cleanPopup = function (popupWindow) {
12126
+ if (popupWindow) {
12127
+ // Close window.
12128
+ popupWindow.close();
12129
+ }
12130
+ // Remove window unload function
12131
+ window.removeEventListener("beforeunload", this.unloadWindow);
12132
+ // Interaction is completed - remove interaction status.
12133
+ this.browserStorage.setInteractionInProgress(false);
12134
+ };
12135
+ /**
12136
+ * Generates the name for the popup based on the client id and request
12137
+ * @param clientId
12138
+ * @param request
12139
+ */
12140
+ PopupClient.prototype.generatePopupName = function (scopes, authority) {
12141
+ return BrowserConstants.POPUP_NAME_PREFIX + "." + this.config.auth.clientId + "." + scopes.join("-") + "." + authority + "." + this.correlationId;
12142
+ };
12143
+ /**
12144
+ * Generates the name for the popup based on the client id and request for logouts
12145
+ * @param clientId
12146
+ * @param request
12147
+ */
12148
+ PopupClient.prototype.generateLogoutPopupName = function (request) {
12149
+ var homeAccountId = request.account && request.account.homeAccountId;
12150
+ return BrowserConstants.POPUP_NAME_PREFIX + "." + this.config.auth.clientId + "." + homeAccountId + "." + this.correlationId;
12151
+ };
11903
12152
  return PopupClient;
11904
12153
  }(StandardInteractionClient));
11905
12154
 
@@ -11983,6 +12232,7 @@
11983
12232
  azureCloudInstance: exports.AzureCloudInstance.None,
11984
12233
  tenant: Constants.EMPTY_STRING
11985
12234
  },
12235
+ skipAuthorityMetadataCache: false,
11986
12236
  };
11987
12237
  // Default cache options for browser
11988
12238
  var DEFAULT_CACHE_OPTIONS = {
@@ -12022,8 +12272,8 @@
12022
12272
  */
12023
12273
  var SilentHandler = /** @class */ (function (_super) {
12024
12274
  __extends$1(SilentHandler, _super);
12025
- function SilentHandler(authCodeModule, storageImpl, authCodeRequest, browserRequestLogger, navigateFrameWait) {
12026
- var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, browserRequestLogger) || this;
12275
+ function SilentHandler(authCodeModule, storageImpl, authCodeRequest, logger, navigateFrameWait) {
12276
+ var _this = _super.call(this, authCodeModule, storageImpl, authCodeRequest, logger) || this;
12027
12277
  _this.navigateFrameWait = navigateFrameWait;
12028
12278
  return _this;
12029
12279
  }
@@ -12040,7 +12290,7 @@
12040
12290
  case 0:
12041
12291
  if (StringUtils.isEmpty(requestUrl)) {
12042
12292
  // Throw error if request URL is empty.
12043
- this.browserRequestLogger.info("Navigate url is empty");
12293
+ this.logger.info("Navigate url is empty");
12044
12294
  throw BrowserAuthError.createEmptyNavigationUriError();
12045
12295
  }
12046
12296
  if (!this.navigateFrameWait) return [3 /*break*/, 2];
@@ -12065,7 +12315,7 @@
12065
12315
  var _this = this;
12066
12316
  return new Promise(function (resolve, reject) {
12067
12317
  if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
12068
- _this.browserRequestLogger.warning("system.loadFrameTimeout or system.iframeHashTimeout set to lower (" + timeout + "ms) than the default (" + DEFAULT_IFRAME_TIMEOUT_MS + "ms). This may result in timeouts.");
12318
+ _this.logger.warning("system.loadFrameTimeout or system.iframeHashTimeout set to lower (" + timeout + "ms) than the default (" + DEFAULT_IFRAME_TIMEOUT_MS + "ms). This may result in timeouts.");
12069
12319
  }
12070
12320
  /*
12071
12321
  * Polling for iframes can be purely timing based,
@@ -12230,6 +12480,8 @@
12230
12480
  serverTelemetryManager.cacheFailedRequest(e_1);
12231
12481
  this.browserStorage.cleanRequestByState(silentRequest.state);
12232
12482
  acquireTokenMeasurement.endMeasurement({
12483
+ errorCode: e_1 instanceof AuthError && e_1.errorCode || undefined,
12484
+ subErrorCode: e_1 instanceof AuthError && e_1.subError || undefined,
12233
12485
  success: false
12234
12486
  });
12235
12487
  throw e_1;
@@ -12334,6 +12586,8 @@
12334
12586
  this.logger.verbose("Signing keypair for bound access token not found. Refreshing bound access token and generating a new crypto keypair.");
12335
12587
  }
12336
12588
  acquireTokenMeasurement.endMeasurement({
12589
+ errorCode: error_1 instanceof AuthError && error_1.errorCode || undefined,
12590
+ subErrorCode: error_1 instanceof AuthError && error_1.subError || undefined,
12337
12591
  success: false
12338
12592
  });
12339
12593
  throw error_1;
@@ -12428,6 +12682,8 @@
12428
12682
  }
12429
12683
  serverTelemetryManager.cacheFailedRequest(e);
12430
12684
  acquireTokenMeasurement.endMeasurement({
12685
+ errorCode: e.errorCode,
12686
+ subErrorCode: e.subError,
12431
12687
  success: false
12432
12688
  });
12433
12689
  throw e;
@@ -12602,8 +12858,7 @@
12602
12858
  EventHandler: EventHandler,
12603
12859
  NativeMessageHandler: NativeMessageHandler,
12604
12860
  BrowserConstants: BrowserConstants,
12605
- get TemporaryCacheKeys () { return TemporaryCacheKeys; },
12606
- PopupUtils: PopupUtils
12861
+ get TemporaryCacheKeys () { return TemporaryCacheKeys; }
12607
12862
  });
12608
12863
 
12609
12864
  /*
@@ -13971,7 +14226,7 @@
13971
14226
  CryptoOps.prototype.signJwt = function (payload, kid, correlationId) {
13972
14227
  var _a;
13973
14228
  return __awaiter$1(this, void 0, void 0, function () {
13974
- var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
14229
+ var signJwtMeasurement, cachedKeyPair, publicKeyJwk, publicKeyJwkString, encodedKeyIdThumbprint, shrHeader, encodedShrHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature, signedJwt;
13975
14230
  return __generator$1(this, function (_b) {
13976
14231
  switch (_b.label) {
13977
14232
  case 0:
@@ -13986,17 +14241,15 @@
13986
14241
  case 2:
13987
14242
  publicKeyJwk = _b.sent();
13988
14243
  publicKeyJwkString = BrowserCrypto.getJwkString(publicKeyJwk);
13989
- header = {
13990
- alg: publicKeyJwk.alg,
13991
- type: KEY_FORMAT_JWK
13992
- };
13993
- encodedHeader = this.b64Encode.urlEncode(JSON.stringify(header));
14244
+ encodedKeyIdThumbprint = this.b64Encode.urlEncode(JSON.stringify({ kid: kid }));
14245
+ shrHeader = JoseHeader.getShrHeaderString({ kid: encodedKeyIdThumbprint, alg: publicKeyJwk.alg });
14246
+ encodedShrHeader = this.b64Encode.urlEncode(shrHeader);
13994
14247
  // Generate payload
13995
14248
  payload.cnf = {
13996
14249
  jwk: JSON.parse(publicKeyJwkString)
13997
14250
  };
13998
14251
  encodedPayload = this.b64Encode.urlEncode(JSON.stringify(payload));
13999
- tokenString = encodedHeader + "." + encodedPayload;
14252
+ tokenString = encodedShrHeader + "." + encodedPayload;
14000
14253
  tokenBuffer = BrowserStringUtils.stringToArrayBuffer(tokenString);
14001
14254
  return [4 /*yield*/, this.browserCrypto.sign(cachedKeyPair.privateKey, tokenBuffer)];
14002
14255
  case 3:
@@ -14074,6 +14327,7 @@
14074
14327
  knownAuthorities: this.config.auth.knownAuthorities,
14075
14328
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
14076
14329
  authorityMetadata: this.config.auth.authorityMetadata,
14330
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache,
14077
14331
  };
14078
14332
  var authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
14079
14333
  // "clientInfo" from options takes precedence over "clientInfo" in response
@@ -14107,8 +14361,8 @@
14107
14361
  var idTokenEntity = IdTokenEntity.createIdTokenEntity(homeAccountId, environment, idToken, this.config.auth.clientId, tenantId);
14108
14362
  var idAuthToken = new AuthToken(idToken, this.cryptoObj);
14109
14363
  var accountEntity = options.clientInfo ?
14110
- AccountEntity.createAccount(options.clientInfo, homeAccountId, idAuthToken, undefined, undefined, undefined, undefined, environment) :
14111
- AccountEntity.createGenericAccount(homeAccountId, idAuthToken, undefined, undefined, undefined, undefined, environment);
14364
+ AccountEntity.createAccount(options.clientInfo, homeAccountId, idAuthToken, undefined, undefined, undefined, environment) :
14365
+ AccountEntity.createGenericAccount(homeAccountId, idAuthToken, undefined, undefined, undefined, environment);
14112
14366
  if (this.isBrowserEnvironment) {
14113
14367
  this.logger.verbose("TokenCache - loading id token");
14114
14368
  this.storage.setAccount(accountEntity);
@@ -14140,7 +14394,7 @@
14140
14394
  throw BrowserAuthError.createUnableToLoadTokenError("Please provide an extendedExpiresOn value in the options.");
14141
14395
  }
14142
14396
  var scopes = new ScopeSet(request.scopes).printScopes();
14143
- var expiresOn = response.expires_in;
14397
+ var expiresOn = options.expiresOn || (response.expires_in + new Date().getTime() / 1000);
14144
14398
  var extendedExpiresOn = options.extendedExpiresOn;
14145
14399
  var accessTokenEntity = AccessTokenEntity.createAccessTokenEntity(homeAccountId, environment, response.access_token, this.config.auth.clientId, tenantId, scopes, expiresOn, extendedExpiresOn, this.cryptoObj);
14146
14400
  if (this.isBrowserEnvironment) {
@@ -14414,7 +14668,7 @@
14414
14668
  case 0:
14415
14669
  this.logger.trace("initialize called");
14416
14670
  if (this.initialized) {
14417
- this.logger.warning("initialize has already been called. This function only needs to be run once.");
14671
+ this.logger.info("initialize has already been called, exiting early.");
14418
14672
  return [2 /*return*/];
14419
14673
  }
14420
14674
  this.eventHandler.emitEvent(exports.EventType.INITIALIZE_START);
@@ -14545,6 +14799,12 @@
14545
14799
  var redirectClient = _this.createRedirectClient(request.correlationId);
14546
14800
  return redirectClient.acquireToken(request);
14547
14801
  }
14802
+ else if (e instanceof InteractionRequiredAuthError) {
14803
+ _this.logger.verbose("acquireTokenRedirect - Resolving interaction required error thrown by native broker by falling back to web flow");
14804
+ var redirectClient = _this.createRedirectClient(request.correlationId);
14805
+ return redirectClient.acquireToken(request);
14806
+ }
14807
+ _this.browserStorage.setInteractionInProgress(false);
14548
14808
  throw e;
14549
14809
  });
14550
14810
  }
@@ -14610,6 +14870,12 @@
14610
14870
  var popupClient = _this.createPopupClient(request.correlationId);
14611
14871
  return popupClient.acquireToken(request);
14612
14872
  }
14873
+ else if (e instanceof InteractionRequiredAuthError) {
14874
+ _this.logger.verbose("acquireTokenPopup - Resolving interaction required error thrown by native broker by falling back to web flow");
14875
+ var popupClient = _this.createPopupClient(request.correlationId);
14876
+ return popupClient.acquireToken(request);
14877
+ }
14878
+ _this.browserStorage.setInteractionInProgress(false);
14613
14879
  throw e;
14614
14880
  });
14615
14881
  }
@@ -14639,6 +14905,8 @@
14639
14905
  _this.eventHandler.emitEvent(exports.EventType.LOGIN_FAILURE, exports.InteractionType.Popup, null, e);
14640
14906
  }
14641
14907
  atPopupMeasurement.endMeasurement({
14908
+ errorCode: e.errorCode,
14909
+ subErrorCode: e.subError,
14642
14910
  success: false
14643
14911
  });
14644
14912
  atPopupMeasurement.flushMeasurement();
@@ -14692,13 +14960,16 @@
14692
14960
  return [2 /*return*/, result.then(function (response) {
14693
14961
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_SUCCESS, exports.InteractionType.Silent, response);
14694
14962
  ssoSilentMeasurement.endMeasurement({
14695
- success: true
14963
+ success: true,
14964
+ isNativeBroker: response.fromNativeBroker
14696
14965
  });
14697
14966
  ssoSilentMeasurement.flushMeasurement();
14698
14967
  return response;
14699
14968
  }).catch(function (e) {
14700
14969
  _this.eventHandler.emitEvent(exports.EventType.SSO_SILENT_FAILURE, exports.InteractionType.Silent, null, e);
14701
14970
  ssoSilentMeasurement.endMeasurement({
14971
+ errorCode: e.errorCode,
14972
+ subErrorCode: e.subError,
14702
14973
  success: false
14703
14974
  });
14704
14975
  ssoSilentMeasurement.flushMeasurement();
@@ -14738,7 +15009,8 @@
14738
15009
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
14739
15010
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
14740
15011
  atbcMeasurement.endMeasurement({
14741
- success: true
15012
+ success: true,
15013
+ isNativeBroker: result.fromNativeBroker
14742
15014
  });
14743
15015
  atbcMeasurement.flushMeasurement();
14744
15016
  return result;
@@ -14747,6 +15019,8 @@
14747
15019
  _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
14748
15020
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, error);
14749
15021
  atbcMeasurement.endMeasurement({
15022
+ errorCode: error.errorCode,
15023
+ subErrorCode: error.subError,
14750
15024
  success: false
14751
15025
  });
14752
15026
  atbcMeasurement.flushMeasurement();
@@ -14784,6 +15058,8 @@
14784
15058
  catch (e) {
14785
15059
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
14786
15060
  atbcMeasurement.endMeasurement({
15061
+ errorCode: e instanceof AuthError && e.errorCode || undefined,
15062
+ subErrorCode: e instanceof AuthError && e.subError || undefined,
14787
15063
  success: false
14788
15064
  });
14789
15065
  throw e;
@@ -14859,6 +15135,8 @@
14859
15135
  })
14860
15136
  .catch(function (error) {
14861
15137
  atbrtMeasurement.endMeasurement({
15138
+ errorCode: error.errorCode,
15139
+ subErrorCode: error.subError,
14862
15140
  success: false
14863
15141
  });
14864
15142
  throw error;
@@ -15008,9 +15286,13 @@
15008
15286
  // #region Helpers
15009
15287
  /**
15010
15288
  * Helper to validate app environment before making an auth request
15011
- * * @param interactionType
15289
+ *
15290
+ * @protected
15291
+ * @param {InteractionType} interactionType What kind of interaction is being used
15292
+ * @param {boolean} [setInteractionInProgress=true] Whether to set interaction in progress temp cache flag
15012
15293
  */
15013
- ClientApplication.prototype.preflightBrowserEnvironmentCheck = function (interactionType) {
15294
+ ClientApplication.prototype.preflightBrowserEnvironmentCheck = function (interactionType, setInteractionInProgress) {
15295
+ if (setInteractionInProgress === void 0) { setInteractionInProgress = true; }
15014
15296
  this.logger.verbose("preflightBrowserEnvironmentCheck started");
15015
15297
  // Block request if not in browser environment
15016
15298
  BrowserUtils.blockNonBrowserEnvironment(this.isBrowserEnvironment);
@@ -15029,20 +15311,23 @@
15029
15311
  throw BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError();
15030
15312
  }
15031
15313
  if (interactionType === exports.InteractionType.Redirect || interactionType === exports.InteractionType.Popup) {
15032
- this.preflightInteractiveRequest();
15314
+ this.preflightInteractiveRequest(setInteractionInProgress);
15033
15315
  }
15034
15316
  };
15035
15317
  /**
15036
- * Helper to validate app environment before making a request.
15037
- * @param request
15038
- * @param interactionType
15318
+ * Preflight check for interactive requests
15319
+ *
15320
+ * @protected
15321
+ * @param {boolean} setInteractionInProgress Whether to set interaction in progress temp cache flag
15039
15322
  */
15040
- ClientApplication.prototype.preflightInteractiveRequest = function () {
15323
+ ClientApplication.prototype.preflightInteractiveRequest = function (setInteractionInProgress) {
15041
15324
  this.logger.verbose("preflightInteractiveRequest called, validating app environment");
15042
15325
  // block the reload if it occurred inside a hidden iframe
15043
15326
  BrowserUtils.blockReloadInHiddenIframes();
15044
15327
  // Set interaction in progress temporary cache or throw if alread set.
15045
- this.browserStorage.setInteractionInProgress(true);
15328
+ if (setInteractionInProgress) {
15329
+ this.browserStorage.setInteractionInProgress(true);
15330
+ }
15046
15331
  };
15047
15332
  /**
15048
15333
  * Acquire a token from native device (e.g. WAM)
@@ -15075,6 +15360,7 @@
15075
15360
  switch (request.prompt) {
15076
15361
  case PromptValue.NONE:
15077
15362
  case PromptValue.CONSENT:
15363
+ case PromptValue.LOGIN:
15078
15364
  this.logger.trace("canUseNative: prompt is compatible with native flow");
15079
15365
  break;
15080
15366
  default:
@@ -15105,7 +15391,7 @@
15105
15391
  return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
15106
15392
  };
15107
15393
  /**
15108
- * Returns new instance of the Popup Interaction Client
15394
+ * Returns new instance of the Redirect Interaction Client
15109
15395
  * @param correlationId
15110
15396
  */
15111
15397
  ClientApplication.prototype.createRedirectClient = function (correlationId) {
@@ -15351,7 +15637,8 @@
15351
15637
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15352
15638
  atsMeasurement.endMeasurement({
15353
15639
  success: true,
15354
- fromCache: result.fromCache
15640
+ fromCache: result.fromCache,
15641
+ isNativeBroker: result.fromNativeBroker
15355
15642
  });
15356
15643
  atsMeasurement.flushMeasurement();
15357
15644
  return result;
@@ -15359,6 +15646,8 @@
15359
15646
  .catch(function (error) {
15360
15647
  _this.activeSilentTokenRequests.delete(silentRequestKey);
15361
15648
  atsMeasurement.endMeasurement({
15649
+ errorCode: error.errorCode,
15650
+ subErrorCode: error.subError,
15362
15651
  success: false
15363
15652
  });
15364
15653
  atsMeasurement.flushMeasurement();
@@ -15427,12 +15716,15 @@
15427
15716
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, response);
15428
15717
  astsAsyncMeasurement.endMeasurement({
15429
15718
  success: true,
15430
- fromCache: response.fromCache
15719
+ fromCache: response.fromCache,
15720
+ isNativeBroker: response.fromNativeBroker
15431
15721
  });
15432
15722
  return response;
15433
15723
  }).catch(function (tokenRenewalError) {
15434
15724
  _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError);
15435
15725
  astsAsyncMeasurement.endMeasurement({
15726
+ errorCode: tokenRenewalError.errorCode,
15727
+ subErrorCode: tokenRenewalError.subError,
15436
15728
  success: false
15437
15729
  });
15438
15730
  throw tokenRenewalError;