@azure/msal-browser 2.18.0 → 2.22.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 (182) hide show
  1. package/CHANGELOG.json +1758 -1548
  2. package/CHANGELOG.md +553 -491
  3. package/LICENSE +21 -21
  4. package/README.md +5 -3
  5. package/dist/_virtual/_tslib.js +1 -1
  6. package/dist/app/ClientApplication.d.ts +30 -1
  7. package/dist/app/ClientApplication.d.ts.map +1 -1
  8. package/dist/app/ClientApplication.js +101 -5
  9. package/dist/app/ClientApplication.js.map +1 -1
  10. package/dist/app/IPublicClientApplication.d.ts +4 -0
  11. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  12. package/dist/app/IPublicClientApplication.js +7 -1
  13. package/dist/app/IPublicClientApplication.js.map +1 -1
  14. package/dist/app/PublicClientApplication.d.ts +2 -2
  15. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  16. package/dist/app/PublicClientApplication.js +31 -24
  17. package/dist/app/PublicClientApplication.js.map +1 -1
  18. package/dist/cache/AsyncMemoryStorage.d.ts +46 -0
  19. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -0
  20. package/dist/cache/AsyncMemoryStorage.js +195 -0
  21. package/dist/cache/AsyncMemoryStorage.js.map +1 -0
  22. package/dist/cache/BrowserCacheManager.d.ts +19 -13
  23. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  24. package/dist/cache/BrowserCacheManager.js +31 -7
  25. package/dist/cache/BrowserCacheManager.js.map +1 -1
  26. package/dist/cache/BrowserStorage.d.ts +1 -1
  27. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  28. package/dist/cache/BrowserStorage.js +1 -1
  29. package/dist/cache/BrowserStorage.js.map +1 -1
  30. package/dist/cache/DatabaseStorage.d.ts +25 -6
  31. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  32. package/dist/cache/DatabaseStorage.js +127 -81
  33. package/dist/cache/DatabaseStorage.js.map +1 -1
  34. package/dist/cache/IAsyncMemoryStorage.d.ts +28 -0
  35. package/dist/cache/IAsyncMemoryStorage.d.ts.map +1 -0
  36. package/dist/cache/IWindowStorage.d.ts +3 -3
  37. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  38. package/dist/cache/MemoryStorage.d.ts +3 -3
  39. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  40. package/dist/cache/MemoryStorage.js +1 -1
  41. package/dist/cache/MemoryStorage.js.map +1 -1
  42. package/dist/cache/TokenCache.d.ts.map +1 -1
  43. package/dist/cache/TokenCache.js +4 -3
  44. package/dist/cache/TokenCache.js.map +1 -1
  45. package/dist/config/Configuration.d.ts +10 -9
  46. package/dist/config/Configuration.d.ts.map +1 -1
  47. package/dist/config/Configuration.js +7 -3
  48. package/dist/config/Configuration.js.map +1 -1
  49. package/dist/crypto/BrowserCrypto.d.ts +3 -1
  50. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  51. package/dist/crypto/BrowserCrypto.js +3 -2
  52. package/dist/crypto/BrowserCrypto.js.map +1 -1
  53. package/dist/crypto/CryptoOps.d.ts +16 -5
  54. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  55. package/dist/crypto/CryptoOps.js +58 -17
  56. package/dist/crypto/CryptoOps.js.map +1 -1
  57. package/dist/crypto/GuidGenerator.js +1 -1
  58. package/dist/crypto/GuidGenerator.js.map +1 -1
  59. package/dist/crypto/PkceGenerator.js +1 -1
  60. package/dist/crypto/PkceGenerator.js.map +1 -1
  61. package/dist/crypto/SignedHttpRequest.d.ts +6 -2
  62. package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
  63. package/dist/crypto/SignedHttpRequest.js +11 -5
  64. package/dist/crypto/SignedHttpRequest.js.map +1 -1
  65. package/dist/encode/Base64Decode.js +1 -1
  66. package/dist/encode/Base64Decode.js.map +1 -1
  67. package/dist/encode/Base64Encode.js +1 -1
  68. package/dist/encode/Base64Encode.js.map +1 -1
  69. package/dist/error/BrowserAuthError.d.ts +16 -0
  70. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  71. package/dist/error/BrowserAuthError.js +22 -2
  72. package/dist/error/BrowserAuthError.js.map +1 -1
  73. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  74. package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
  75. package/dist/event/EventHandler.js +1 -1
  76. package/dist/event/EventHandler.js.map +1 -1
  77. package/dist/event/EventMessage.js +1 -1
  78. package/dist/event/EventMessage.js.map +1 -1
  79. package/dist/event/EventType.d.ts +3 -0
  80. package/dist/event/EventType.d.ts.map +1 -1
  81. package/dist/event/EventType.js +4 -1
  82. package/dist/event/EventType.js.map +1 -1
  83. package/dist/index.cjs.js +1473 -511
  84. package/dist/index.cjs.js.map +1 -1
  85. package/dist/index.d.ts +16 -3
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +14 -3
  88. package/dist/index.js.map +1 -1
  89. package/dist/interaction_client/BaseInteractionClient.d.ts +2 -2
  90. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  91. package/dist/interaction_client/BaseInteractionClient.js +40 -17
  92. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  93. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts +5 -0
  94. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts.map +1 -0
  95. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +21 -0
  96. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js.map +1 -0
  97. package/dist/interaction_client/PopupClient.d.ts +4 -3
  98. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  99. package/dist/interaction_client/PopupClient.js +23 -21
  100. package/dist/interaction_client/PopupClient.js.map +1 -1
  101. package/dist/interaction_client/RedirectClient.d.ts +3 -3
  102. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  103. package/dist/interaction_client/RedirectClient.js +22 -20
  104. package/dist/interaction_client/RedirectClient.js.map +1 -1
  105. package/dist/interaction_client/SilentAuthCodeClient.d.ts +22 -0
  106. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -0
  107. package/dist/interaction_client/SilentAuthCodeClient.js +83 -0
  108. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -0
  109. package/dist/interaction_client/SilentCacheClient.d.ts +3 -3
  110. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  111. package/dist/interaction_client/SilentCacheClient.js +15 -5
  112. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  113. package/dist/interaction_client/SilentIframeClient.d.ts +3 -3
  114. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  115. package/dist/interaction_client/SilentIframeClient.js +16 -13
  116. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  117. package/dist/interaction_client/SilentRefreshClient.d.ts +2 -2
  118. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  119. package/dist/interaction_client/SilentRefreshClient.js +13 -10
  120. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  121. package/dist/interaction_client/StandardInteractionClient.d.ts +11 -11
  122. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  123. package/dist/interaction_client/StandardInteractionClient.js +90 -57
  124. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  125. package/dist/interaction_handler/InteractionHandler.d.ts +11 -2
  126. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  127. package/dist/interaction_handler/InteractionHandler.js +36 -10
  128. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  129. package/dist/interaction_handler/PopupHandler.d.ts.map +1 -1
  130. package/dist/interaction_handler/PopupHandler.js +1 -3
  131. package/dist/interaction_handler/PopupHandler.js.map +1 -1
  132. package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
  133. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  134. package/dist/interaction_handler/RedirectHandler.js +2 -3
  135. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  136. package/dist/interaction_handler/SilentHandler.js +1 -1
  137. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  138. package/dist/navigation/NavigationClient.js +1 -1
  139. package/dist/navigation/NavigationClient.js.map +1 -1
  140. package/dist/network/FetchClient.js +1 -1
  141. package/dist/network/FetchClient.js.map +1 -1
  142. package/dist/network/XhrClient.js +1 -1
  143. package/dist/network/XhrClient.js.map +1 -1
  144. package/dist/packageMetadata.d.ts +1 -1
  145. package/dist/packageMetadata.js +2 -2
  146. package/dist/packageMetadata.js.map +1 -1
  147. package/dist/request/AuthorizationCodeRequest.d.ts +8 -0
  148. package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -0
  149. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  150. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  151. package/dist/request/EndSessionPopupRequest.d.ts +1 -0
  152. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  153. package/dist/request/EndSessionRequest.d.ts +1 -0
  154. package/dist/request/EndSessionRequest.d.ts.map +1 -1
  155. package/dist/request/PopupRequest.d.ts +1 -1
  156. package/dist/request/PopupRequest.d.ts.map +1 -1
  157. package/dist/request/RedirectRequest.d.ts +1 -1
  158. package/dist/request/RedirectRequest.d.ts.map +1 -1
  159. package/dist/request/SilentRequest.d.ts +1 -1
  160. package/dist/request/SilentRequest.d.ts.map +1 -1
  161. package/dist/request/SsoSilentRequest.d.ts +1 -1
  162. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  163. package/dist/utils/BrowserConstants.d.ts +6 -1
  164. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  165. package/dist/utils/BrowserConstants.js +9 -3
  166. package/dist/utils/BrowserConstants.js.map +1 -1
  167. package/dist/utils/BrowserProtocolUtils.js +1 -1
  168. package/dist/utils/BrowserProtocolUtils.js.map +1 -1
  169. package/dist/utils/BrowserStringUtils.js +1 -1
  170. package/dist/utils/BrowserStringUtils.js.map +1 -1
  171. package/dist/utils/BrowserUtils.js +1 -1
  172. package/dist/utils/BrowserUtils.js.map +1 -1
  173. package/dist/utils/MathUtils.js +1 -1
  174. package/dist/utils/MathUtils.js.map +1 -1
  175. package/dist/utils/PopupUtils.d.ts +1 -2
  176. package/dist/utils/PopupUtils.d.ts.map +1 -1
  177. package/dist/utils/PopupUtils.js +3 -3
  178. package/dist/utils/PopupUtils.js.map +1 -1
  179. package/lib/msal-browser.js +1473 -511
  180. package/lib/msal-browser.js.map +1 -1
  181. package/lib/msal-browser.min.js +36 -31
  182. package/package.json +96 -94
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.18.0 2021-10-05 */
1
+ /*! @azure/msal-browser v2.22.0 2022-02-08 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -105,7 +105,7 @@ function __spread() {
105
105
  return ar;
106
106
  }
107
107
 
108
- /*! @azure/msal-common v5.0.1 2021-10-05 */
108
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
109
109
  /*! *****************************************************************************
110
110
  Copyright (c) Microsoft Corporation.
111
111
 
@@ -192,7 +192,7 @@ function __spreadArrays() {
192
192
  return r;
193
193
  }
194
194
 
195
- /*! @azure/msal-common v5.0.1 2021-10-05 */
195
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
196
196
 
197
197
  /*
198
198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -206,6 +206,7 @@ var Constants = {
206
206
  // default authority
207
207
  DEFAULT_AUTHORITY: "https://login.microsoftonline.com/common/",
208
208
  DEFAULT_AUTHORITY_HOST: "login.microsoftonline.com",
209
+ DEFAULT_COMMON_TENANT: "common",
209
210
  // ADFS String
210
211
  ADFS: "adfs",
211
212
  // Default AAD Instance Discovery Endpoint
@@ -257,6 +258,8 @@ var HeaderNames;
257
258
  HeaderNames["CONTENT_TYPE"] = "Content-Type";
258
259
  HeaderNames["RETRY_AFTER"] = "Retry-After";
259
260
  HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
261
+ HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
262
+ HeaderNames["AuthenticationInfo"] = "Authentication-Info";
260
263
  })(HeaderNames || (HeaderNames = {}));
261
264
  /**
262
265
  * Persistent cache keys MSAL which stay while user is logged in.
@@ -327,6 +330,8 @@ var AADServerParamKeys;
327
330
  AADServerParamKeys["ON_BEHALF_OF"] = "on_behalf_of";
328
331
  AADServerParamKeys["FOCI"] = "foci";
329
332
  AADServerParamKeys["CCS_HEADER"] = "X-AnchorMailbox";
333
+ AADServerParamKeys["RETURN_SPA_CODE"] = "return_spa_code";
334
+ AADServerParamKeys["LOGOUT_HINT"] = "logout_hint";
330
335
  })(AADServerParamKeys || (AADServerParamKeys = {}));
331
336
  /**
332
337
  * Claims request keys
@@ -484,8 +489,9 @@ var SERVER_TELEM_CONSTANTS = {
484
489
  */
485
490
  exports.AuthenticationScheme = void 0;
486
491
  (function (AuthenticationScheme) {
487
- AuthenticationScheme["POP"] = "pop";
488
492
  AuthenticationScheme["BEARER"] = "Bearer";
493
+ AuthenticationScheme["POP"] = "pop";
494
+ AuthenticationScheme["SSH"] = "ssh-cert";
489
495
  })(exports.AuthenticationScheme || (exports.AuthenticationScheme = {}));
490
496
  /**
491
497
  * Constants related to throttling
@@ -550,7 +556,7 @@ var CacheOutcome;
550
556
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
551
557
  })(CacheOutcome || (CacheOutcome = {}));
552
558
 
553
- /*! @azure/msal-common v5.0.1 2021-10-05 */
559
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
554
560
 
555
561
  /*
556
562
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -594,7 +600,7 @@ var AuthError = /** @class */ (function (_super) {
594
600
  return AuthError;
595
601
  }(Error));
596
602
 
597
- /*! @azure/msal-common v5.0.1 2021-10-05 */
603
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
598
604
 
599
605
  /*
600
606
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -657,10 +663,19 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
657
663
  throw AuthError.createUnexpectedError(notImplErr);
658
664
  });
659
665
  });
666
+ },
667
+ hashString: function () {
668
+ return __awaiter(this, void 0, void 0, function () {
669
+ var notImplErr;
670
+ return __generator(this, function (_a) {
671
+ notImplErr = "Crypto interface - hashString() has not been implemented";
672
+ throw AuthError.createUnexpectedError(notImplErr);
673
+ });
674
+ });
660
675
  }
661
676
  };
662
677
 
663
- /*! @azure/msal-common v5.0.1 2021-10-05 */
678
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
664
679
 
665
680
  /*
666
681
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -846,6 +861,10 @@ var ClientAuthErrorMessage = {
846
861
  bindingKeyNotRemovedError: {
847
862
  code: "binding_key_not_removed",
848
863
  desc: "Could not remove the credential's binding key from storage."
864
+ },
865
+ logoutNotSupported: {
866
+ code: "end_session_endpoint_not_supported",
867
+ desc: "Provided authority does not support logout."
849
868
  }
850
869
  };
851
870
  /**
@@ -1109,10 +1128,16 @@ var ClientAuthError = /** @class */ (function (_super) {
1109
1128
  ClientAuthError.createBindingKeyNotRemovedError = function () {
1110
1129
  return new ClientAuthError(ClientAuthErrorMessage.bindingKeyNotRemovedError.code, ClientAuthErrorMessage.bindingKeyNotRemovedError.desc);
1111
1130
  };
1131
+ /**
1132
+ * Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
1133
+ */
1134
+ ClientAuthError.createLogoutNotSupportedError = function () {
1135
+ return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
1136
+ };
1112
1137
  return ClientAuthError;
1113
1138
  }(AuthError));
1114
1139
 
1115
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1140
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1116
1141
 
1117
1142
  /*
1118
1143
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1237,7 +1262,7 @@ var StringUtils = /** @class */ (function () {
1237
1262
  return StringUtils;
1238
1263
  }());
1239
1264
 
1240
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1265
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1241
1266
 
1242
1267
  /*
1243
1268
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1417,12 +1442,31 @@ var Logger = /** @class */ (function () {
1417
1442
  return Logger;
1418
1443
  }());
1419
1444
 
1420
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1445
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1421
1446
  /* eslint-disable header/header */
1422
1447
  var name$1 = "@azure/msal-common";
1423
- var version$1 = "5.0.1";
1448
+ var version$1 = "6.1.0";
1424
1449
 
1425
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1450
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1451
+ /*
1452
+ * Copyright (c) Microsoft Corporation. All rights reserved.
1453
+ * Licensed under the MIT License.
1454
+ */
1455
+ exports.AzureCloudInstance = void 0;
1456
+ (function (AzureCloudInstance) {
1457
+ // AzureCloudInstance is not specified.
1458
+ AzureCloudInstance[AzureCloudInstance["None"] = 0] = "None";
1459
+ // Microsoft Azure public cloud
1460
+ AzureCloudInstance["AzurePublic"] = "https://login.microsoftonline.com";
1461
+ // Microsoft Chinese national cloud
1462
+ AzureCloudInstance["AzureChina"] = "https://login.chinacloudapi.cn";
1463
+ // Microsoft German national cloud ("Black Forest")
1464
+ AzureCloudInstance["AzureGermany"] = "https://login.microsoftonline.de";
1465
+ // US Government cloud
1466
+ AzureCloudInstance["AzureUsGovernment"] = "https://login.microsoftonline.us";
1467
+ })(exports.AzureCloudInstance || (exports.AzureCloudInstance = {}));
1468
+
1469
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1426
1470
 
1427
1471
  /*
1428
1472
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1433,7 +1477,7 @@ var version$1 = "5.0.1";
1433
1477
  *
1434
1478
  * Key:Value Schema:
1435
1479
  *
1436
- * Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<scheme>
1480
+ * Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
1437
1481
  *
1438
1482
  * Value Schema:
1439
1483
  * {
@@ -1447,6 +1491,7 @@ var version$1 = "5.0.1";
1447
1491
  * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
1448
1492
  * oboAssertion: access token passed in as part of OBO request
1449
1493
  * tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
1494
+ * requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
1450
1495
  * }
1451
1496
  */
1452
1497
  var CredentialEntity = /** @class */ (function () {
@@ -1474,7 +1519,7 @@ var CredentialEntity = /** @class */ (function () {
1474
1519
  * generates credential key
1475
1520
  */
1476
1521
  CredentialEntity.prototype.generateCredentialKey = function () {
1477
- return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType);
1522
+ return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
1478
1523
  };
1479
1524
  /**
1480
1525
  * returns the type of the cache (in this case credential)
@@ -1518,16 +1563,14 @@ var CredentialEntity = /** @class */ (function () {
1518
1563
  * generates credential key
1519
1564
  * <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
1520
1565
  */
1521
- CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType) {
1566
+ CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
1522
1567
  var credentialKey = [
1523
1568
  this.generateAccountIdForCacheKey(homeAccountId, environment),
1524
1569
  this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
1525
- this.generateTargetForCacheKey(target)
1570
+ this.generateTargetForCacheKey(target),
1571
+ this.generateClaimsHashForCacheKey(requestedClaimsHash),
1572
+ this.generateSchemeForCacheKey(tokenType)
1526
1573
  ];
1527
- // PoP Tokens include scheme in cache key
1528
- if (tokenType === exports.AuthenticationScheme.POP) {
1529
- credentialKey.push(tokenType.toLowerCase());
1530
- }
1531
1574
  return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
1532
1575
  };
1533
1576
  /**
@@ -1563,10 +1606,26 @@ var CredentialEntity = /** @class */ (function () {
1563
1606
  CredentialEntity.generateTargetForCacheKey = function (scopes) {
1564
1607
  return (scopes || "").toLowerCase();
1565
1608
  };
1609
+ /**
1610
+ * Generate requested claims key component as per schema: <requestedClaims>
1611
+ */
1612
+ CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
1613
+ return (requestedClaimsHash || "").toLowerCase();
1614
+ };
1615
+ /**
1616
+ * Generate scheme key componenet as per schema: <scheme>
1617
+ */
1618
+ CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
1619
+ /*
1620
+ * PoP Tokens and SSH certs include scheme in cache key
1621
+ * Cast to lowercase to handle "bearer" from ADFS
1622
+ */
1623
+ return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : "";
1624
+ };
1566
1625
  return CredentialEntity;
1567
1626
  }());
1568
1627
 
1569
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1628
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1570
1629
 
1571
1630
  /*
1572
1631
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1638,15 +1697,35 @@ var ClientConfigurationErrorMessage = {
1638
1697
  },
1639
1698
  invalidCloudDiscoveryMetadata: {
1640
1699
  code: "invalid_cloud_discovery_metadata",
1641
- desc: "Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields"
1700
+ desc: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields"
1642
1701
  },
1643
1702
  invalidAuthorityMetadata: {
1644
1703
  code: "invalid_authority_metadata",
1645
- desc: "Invalid authorityMetadata provided. Must by a JSON object containing authorization_endpoint, token_endpoint, end_session_endpoint, issuer fields."
1704
+ desc: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields."
1646
1705
  },
1647
1706
  untrustedAuthority: {
1648
1707
  code: "untrusted_authority",
1649
1708
  desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."
1709
+ },
1710
+ invalidAzureCloudInstance: {
1711
+ code: "invalid_azure_cloud_instance",
1712
+ desc: "Invalid AzureCloudInstance provided. Please refer MSAL JS docs: aks.ms/msaljs/azure_cloud_instance for valid values"
1713
+ },
1714
+ missingSshJwk: {
1715
+ code: "missing_ssh_jwk",
1716
+ desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."
1717
+ },
1718
+ missingSshKid: {
1719
+ code: "missing_ssh_kid",
1720
+ desc: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme."
1721
+ },
1722
+ missingNonceAuthenticationHeader: {
1723
+ code: "missing_nonce_authentication_header",
1724
+ desc: "Unable to find an authentication header containing server nonce. Either the Authentication-Info or WWW-Authenticate headers must be present in order to obtain a server nonce."
1725
+ },
1726
+ invalidAuthenticationHeader: {
1727
+ code: "invalid_authentication_header",
1728
+ desc: "Invalid authentication header provided"
1650
1729
  }
1651
1730
  };
1652
1731
  /**
@@ -1768,10 +1847,40 @@ var ClientConfigurationError = /** @class */ (function (_super) {
1768
1847
  ClientConfigurationError.createUntrustedAuthorityError = function () {
1769
1848
  return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);
1770
1849
  };
1850
+ /**
1851
+ * Throws error when the AzureCloudInstance is set to an invalid value
1852
+ */
1853
+ ClientConfigurationError.createInvalidAzureCloudInstanceError = function () {
1854
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAzureCloudInstance.code, ClientConfigurationErrorMessage.invalidAzureCloudInstance.desc);
1855
+ };
1856
+ /**
1857
+ * Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
1858
+ */
1859
+ ClientConfigurationError.createMissingSshJwkError = function () {
1860
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshJwk.code, ClientConfigurationErrorMessage.missingSshJwk.desc);
1861
+ };
1862
+ /**
1863
+ * Throws an error when the authentication scheme is set to SSH but the SSH public key ID is omitted from the request
1864
+ */
1865
+ ClientConfigurationError.createMissingSshKidError = function () {
1866
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshKid.code, ClientConfigurationErrorMessage.missingSshKid.desc);
1867
+ };
1868
+ /**
1869
+ * Throws error when provided headers don't contain a header that a server nonce can be extracted from
1870
+ */
1871
+ ClientConfigurationError.createMissingNonceAuthenticationHeadersError = function () {
1872
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.code, ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.desc);
1873
+ };
1874
+ /**
1875
+ * Throws error when a provided header is invalid in any way
1876
+ */
1877
+ ClientConfigurationError.createInvalidAuthenticationHeaderError = function (invalidHeaderName, details) {
1878
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc + ". Invalid header: " + invalidHeaderName + ". Details: " + details);
1879
+ };
1771
1880
  return ClientConfigurationError;
1772
1881
  }(ClientAuthError));
1773
1882
 
1774
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1883
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1775
1884
 
1776
1885
  /*
1777
1886
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1955,7 +2064,7 @@ var ScopeSet = /** @class */ (function () {
1955
2064
  return ScopeSet;
1956
2065
  }());
1957
2066
 
1958
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2067
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1959
2068
 
1960
2069
  /*
1961
2070
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1993,7 +2102,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
1993
2102
  };
1994
2103
  }
1995
2104
 
1996
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2105
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
1997
2106
  /*
1998
2107
  * Copyright (c) Microsoft Corporation. All rights reserved.
1999
2108
  * Licensed under the MIT License.
@@ -2007,7 +2116,7 @@ var AuthorityType;
2007
2116
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2008
2117
  })(AuthorityType || (AuthorityType = {}));
2009
2118
 
2010
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2119
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
2011
2120
 
2012
2121
  /*
2013
2122
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2241,7 +2350,7 @@ var AccountEntity = /** @class */ (function () {
2241
2350
  return AccountEntity;
2242
2351
  }());
2243
2352
 
2244
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2353
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
2245
2354
 
2246
2355
  /*
2247
2356
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2279,7 +2388,7 @@ var AuthToken = /** @class */ (function () {
2279
2388
  return AuthToken;
2280
2389
  }());
2281
2390
 
2282
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2391
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
2283
2392
 
2284
2393
  /*
2285
2394
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2369,7 +2478,8 @@ var CacheManager = /** @class */ (function () {
2369
2478
  environment: credential.environment,
2370
2479
  homeAccountId: credential.homeAccountId,
2371
2480
  realm: credential.realm,
2372
- tokenType: credential.tokenType
2481
+ tokenType: credential.tokenType,
2482
+ requestedClaimsHash: credential.requestedClaimsHash
2373
2483
  });
2374
2484
  currentScopes = ScopeSet.fromString(credential.target);
2375
2485
  currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
@@ -2441,7 +2551,7 @@ var CacheManager = /** @class */ (function () {
2441
2551
  * @param target
2442
2552
  */
2443
2553
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
2444
- return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType);
2554
+ 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);
2445
2555
  };
2446
2556
  /**
2447
2557
  * Support function to help match credentials
@@ -2454,7 +2564,7 @@ var CacheManager = /** @class */ (function () {
2454
2564
  * @param oboAssertion
2455
2565
  * @param tokenType
2456
2566
  */
2457
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType) {
2567
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId, requestedClaimsHash) {
2458
2568
  var _this = this;
2459
2569
  var allCacheKeys = this.getKeys();
2460
2570
  var matchingCredentials = {
@@ -2501,27 +2611,37 @@ var CacheManager = /** @class */ (function () {
2501
2611
  if (!!target && !_this.matchTarget(entity, target)) {
2502
2612
  return;
2503
2613
  }
2614
+ // If request OR cached entity has requested Claims Hash, check if they match
2615
+ if (requestedClaimsHash || entity.requestedClaimsHash) {
2616
+ // Don't match if either is undefined or they are different
2617
+ if (entity.requestedClaimsHash !== requestedClaimsHash) {
2618
+ return;
2619
+ }
2620
+ }
2621
+ // Access Token with Auth Scheme specific matching
2504
2622
  if (credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
2505
2623
  if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
2506
2624
  return;
2507
2625
  }
2508
- // This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
2509
- if (cacheKey.indexOf(exports.AuthenticationScheme.POP) === -1) {
2510
- // AccessToken_With_AuthScheme that doesn't have pop in the key is outdated
2511
- _this.removeItem(cacheKey, CacheSchemaType.CREDENTIAL);
2512
- return;
2626
+ // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
2627
+ if (tokenType === exports.AuthenticationScheme.SSH) {
2628
+ if (keyId && !_this.matchKeyId(entity, keyId)) {
2629
+ return;
2630
+ }
2513
2631
  }
2514
2632
  }
2633
+ // At this point, the entity matches the request, update cache key if key schema has changed
2634
+ var updatedCacheKey = _this.updateCredentialCacheKey(cacheKey, entity);
2515
2635
  switch (credType) {
2516
2636
  case CredentialType.ID_TOKEN:
2517
- matchingCredentials.idTokens[cacheKey] = entity;
2637
+ matchingCredentials.idTokens[updatedCacheKey] = entity;
2518
2638
  break;
2519
2639
  case CredentialType.ACCESS_TOKEN:
2520
2640
  case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
2521
- matchingCredentials.accessTokens[cacheKey] = entity;
2641
+ matchingCredentials.accessTokens[updatedCacheKey] = entity;
2522
2642
  break;
2523
2643
  case CredentialType.REFRESH_TOKEN:
2524
- matchingCredentials.refreshTokens[cacheKey] = entity;
2644
+ matchingCredentials.refreshTokens[updatedCacheKey] = entity;
2525
2645
  break;
2526
2646
  }
2527
2647
  });
@@ -2680,6 +2800,7 @@ var CacheManager = /** @class */ (function () {
2680
2800
  case 0:
2681
2801
  key = credential.generateCredentialKey();
2682
2802
  if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
2803
+ if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
2683
2804
  accessTokenWithAuthSchemeEntity = credential;
2684
2805
  kid = accessTokenWithAuthSchemeEntity.keyId;
2685
2806
  if (!kid) return [3 /*break*/, 4];
@@ -2719,10 +2840,10 @@ var CacheManager = /** @class */ (function () {
2719
2840
  * @param environment
2720
2841
  * @param authScheme
2721
2842
  */
2722
- CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme) {
2843
+ CacheManager.prototype.readCacheRecord = function (account, clientId, request, environment) {
2723
2844
  var cachedAccount = this.readAccountFromCache(account);
2724
2845
  var cachedIdToken = this.readIdTokenFromCache(clientId, account);
2725
- var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme);
2846
+ var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, request);
2726
2847
  var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
2727
2848
  var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
2728
2849
  if (cachedAccount && cachedIdToken) {
@@ -2776,9 +2897,14 @@ var CacheManager = /** @class */ (function () {
2776
2897
  * @param scopes
2777
2898
  * @param authScheme
2778
2899
  */
2779
- CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme) {
2780
- // Distinguish between Bearer and PoP token cache types
2781
- var credentialType = (authScheme === exports.AuthenticationScheme.POP) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
2900
+ CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, request) {
2901
+ var scopes = new ScopeSet(request.scopes || []);
2902
+ var authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
2903
+ /*
2904
+ * Distinguish between Bearer and PoP/SSH token cache types
2905
+ * Cast to lowercase to handle "bearer" from ADFS
2906
+ */
2907
+ var credentialType = (authScheme && authScheme.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
2782
2908
  var accessTokenFilter = {
2783
2909
  homeAccountId: account.homeAccountId,
2784
2910
  environment: account.environment,
@@ -2786,7 +2912,9 @@ var CacheManager = /** @class */ (function () {
2786
2912
  clientId: clientId,
2787
2913
  realm: account.tenantId,
2788
2914
  target: scopes.printScopesLowerCase(),
2789
- tokenType: authScheme
2915
+ tokenType: authScheme,
2916
+ keyId: request.sshKid,
2917
+ requestedClaimsHash: request.requestedClaimsHash
2790
2918
  };
2791
2919
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
2792
2920
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -2939,6 +3067,14 @@ var CacheManager = /** @class */ (function () {
2939
3067
  CacheManager.prototype.matchTokenType = function (entity, tokenType) {
2940
3068
  return !!(entity.tokenType && entity.tokenType === tokenType);
2941
3069
  };
3070
+ /**
3071
+ * Returns true if the credential's keyId matches the one in the request, false otherwise
3072
+ * @param entity
3073
+ * @param tokenType
3074
+ */
3075
+ CacheManager.prototype.matchKeyId = function (entity, keyId) {
3076
+ return !!(entity.keyId && entity.keyId === keyId);
3077
+ };
2942
3078
  /**
2943
3079
  * returns if a given cache entity is of the type appmetadata
2944
3080
  * @param key
@@ -3087,10 +3223,14 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3087
3223
  });
3088
3224
  });
3089
3225
  };
3226
+ DefaultStorageClass.prototype.updateCredentialCacheKey = function () {
3227
+ var notImplErr = "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
3228
+ throw AuthError.createUnexpectedError(notImplErr);
3229
+ };
3090
3230
  return DefaultStorageClass;
3091
3231
  }(CacheManager));
3092
3232
 
3093
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3233
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3094
3234
 
3095
3235
  /*
3096
3236
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3100,7 +3240,8 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3100
3240
  var DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
3101
3241
  var DEFAULT_SYSTEM_OPTIONS = {
3102
3242
  tokenRenewalOffsetSeconds: DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
3103
- preventCorsPreflight: false
3243
+ preventCorsPreflight: false,
3244
+ proxyUrl: "",
3104
3245
  };
3105
3246
  var DEFAULT_LOGGER_IMPLEMENTATION = {
3106
3247
  loggerCallback: function () {
@@ -3140,6 +3281,10 @@ var DEFAULT_CLIENT_CREDENTIALS = {
3140
3281
  clientSecret: "",
3141
3282
  clientAssertion: undefined
3142
3283
  };
3284
+ var DEFAULT_AZURE_CLOUD_OPTIONS = {
3285
+ azureCloudInstance: exports.AzureCloudInstance.None,
3286
+ tenant: "" + Constants.DEFAULT_COMMON_TENANT
3287
+ };
3143
3288
  /**
3144
3289
  * Function that sets the default options when not explicitly configured from app developer
3145
3290
  *
@@ -3169,10 +3314,10 @@ function buildClientConfiguration(_a) {
3169
3314
  * @param authOptions
3170
3315
  */
3171
3316
  function buildAuthOptions(authOptions) {
3172
- return __assign({ clientCapabilities: [] }, authOptions);
3317
+ return __assign({ clientCapabilities: [], azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS }, authOptions);
3173
3318
  }
3174
3319
 
3175
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3320
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3176
3321
 
3177
3322
  /*
3178
3323
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3192,7 +3337,7 @@ var ServerError = /** @class */ (function (_super) {
3192
3337
  return ServerError;
3193
3338
  }(AuthError));
3194
3339
 
3195
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3340
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3196
3341
 
3197
3342
  /*
3198
3343
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3275,10 +3420,12 @@ var ThrottlingUtils = /** @class */ (function () {
3275
3420
  authority: request.authority,
3276
3421
  scopes: request.scopes,
3277
3422
  homeAccountIdentifier: homeAccountIdentifier,
3423
+ claims: request.claims,
3278
3424
  authenticationScheme: request.authenticationScheme,
3279
3425
  resourceRequestMethod: request.resourceRequestMethod,
3280
3426
  resourceRequestUri: request.resourceRequestUri,
3281
- shrClaims: request.shrClaims
3427
+ shrClaims: request.shrClaims,
3428
+ sshKid: request.sshKid
3282
3429
  };
3283
3430
  var key = this.generateThrottlingStorageKey(thumbprint);
3284
3431
  return cacheManager.removeItem(key, CacheSchemaType.THROTTLING);
@@ -3286,7 +3433,7 @@ var ThrottlingUtils = /** @class */ (function () {
3286
3433
  return ThrottlingUtils;
3287
3434
  }());
3288
3435
 
3289
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3436
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3290
3437
 
3291
3438
  /*
3292
3439
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3335,7 +3482,7 @@ var NetworkManager = /** @class */ (function () {
3335
3482
  return NetworkManager;
3336
3483
  }());
3337
3484
 
3338
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3485
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3339
3486
  /*
3340
3487
  * Copyright (c) Microsoft Corporation. All rights reserved.
3341
3488
  * Licensed under the MIT License.
@@ -3346,7 +3493,7 @@ var CcsCredentialType;
3346
3493
  CcsCredentialType["UPN"] = "UPN";
3347
3494
  })(CcsCredentialType || (CcsCredentialType = {}));
3348
3495
 
3349
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3496
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3350
3497
 
3351
3498
  /*
3352
3499
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3410,7 +3557,7 @@ var BaseClient = /** @class */ (function () {
3410
3557
  var response;
3411
3558
  return __generator(this, function (_a) {
3412
3559
  switch (_a.label) {
3413
- case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers })];
3560
+ case 0: return [4 /*yield*/, this.networkManager.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers, proxyUrl: this.config.systemOptions.proxyUrl })];
3414
3561
  case 1:
3415
3562
  response = _a.sent();
3416
3563
  if (this.config.serverTelemetryManager && response.status < 500 && response.status !== 429) {
@@ -3435,7 +3582,7 @@ var BaseClient = /** @class */ (function () {
3435
3582
  return BaseClient;
3436
3583
  }());
3437
3584
 
3438
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3585
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3439
3586
 
3440
3587
  /*
3441
3588
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3521,7 +3668,7 @@ var RequestValidator = /** @class */ (function () {
3521
3668
  return RequestValidator;
3522
3669
  }());
3523
3670
 
3524
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3671
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3525
3672
 
3526
3673
  /*
3527
3674
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3825,6 +3972,15 @@ var RequestParameterBuilder = /** @class */ (function () {
3825
3972
  this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
3826
3973
  }
3827
3974
  };
3975
+ /**
3976
+ * add SSH JWK and key ID to query params
3977
+ */
3978
+ RequestParameterBuilder.prototype.addSshJwk = function (sshJwkString) {
3979
+ if (!StringUtils.isEmpty(sshJwkString)) {
3980
+ this.parameters.set(AADServerParamKeys.TOKEN_TYPE, exports.AuthenticationScheme.SSH);
3981
+ this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(sshJwkString));
3982
+ }
3983
+ };
3828
3984
  /**
3829
3985
  * add server telemetry fields
3830
3986
  * @param serverTelemetryManager
@@ -3839,6 +3995,12 @@ var RequestParameterBuilder = /** @class */ (function () {
3839
3995
  RequestParameterBuilder.prototype.addThrottling = function () {
3840
3996
  this.parameters.set(AADServerParamKeys.X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
3841
3997
  };
3998
+ /**
3999
+ * Adds logout_hint parameter for "silent" logout which prevent server account picker
4000
+ */
4001
+ RequestParameterBuilder.prototype.addLogoutHint = function (logoutHint) {
4002
+ this.parameters.set(AADServerParamKeys.LOGOUT_HINT, encodeURIComponent(logoutHint));
4003
+ };
3842
4004
  /**
3843
4005
  * Utility to create a URL from the params map
3844
4006
  */
@@ -3852,7 +4014,7 @@ var RequestParameterBuilder = /** @class */ (function () {
3852
4014
  return RequestParameterBuilder;
3853
4015
  }());
3854
4016
 
3855
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4017
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3856
4018
 
3857
4019
  /*
3858
4020
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3917,7 +4079,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
3917
4079
  return IdTokenEntity;
3918
4080
  }(CredentialEntity));
3919
4081
 
3920
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4082
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3921
4083
  /*
3922
4084
  * Copyright (c) Microsoft Corporation. All rights reserved.
3923
4085
  * Licensed under the MIT License.
@@ -3967,7 +4129,7 @@ var TimeUtils = /** @class */ (function () {
3967
4129
  return TimeUtils;
3968
4130
  }());
3969
4131
 
3970
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4132
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
3971
4133
 
3972
4134
  /*
3973
4135
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4013,8 +4175,8 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4013
4175
  * @param expiresOn
4014
4176
  * @param extExpiresOn
4015
4177
  */
4016
- AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion) {
4017
- var _a;
4178
+ AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId, requestedClaims, requestedClaimsHash) {
4179
+ var _a, _b;
4018
4180
  var atEntity = new AccessTokenEntity();
4019
4181
  atEntity.homeAccountId = homeAccountId;
4020
4182
  atEntity.credentialType = CredentialType.ACCESS_TOKEN;
@@ -4036,15 +4198,28 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4036
4198
  atEntity.target = scopes;
4037
4199
  atEntity.oboAssertion = oboAssertion;
4038
4200
  atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
4039
- // Create Access Token With AuthScheme instead of regular access token
4040
- if (atEntity.tokenType === exports.AuthenticationScheme.POP) {
4201
+ if (requestedClaims) {
4202
+ atEntity.requestedClaims = requestedClaims;
4203
+ atEntity.requestedClaimsHash = requestedClaimsHash;
4204
+ }
4205
+ /*
4206
+ * Create Access Token With Auth Scheme instead of regular access token
4207
+ * Cast to lower to handle "bearer" from ADFS
4208
+ */
4209
+ if (((_a = atEntity.tokenType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== exports.AuthenticationScheme.BEARER.toLowerCase()) {
4041
4210
  atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
4042
- // Make sure keyId is present and add it to credential
4043
- var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
4044
- if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4045
- throw ClientAuthError.createTokenClaimsRequiredError();
4211
+ switch (atEntity.tokenType) {
4212
+ case exports.AuthenticationScheme.POP:
4213
+ // Make sure keyId is present and add it to credential
4214
+ var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
4215
+ if (!((_b = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _b === void 0 ? void 0 : _b.kid)) {
4216
+ throw ClientAuthError.createTokenClaimsRequiredError();
4217
+ }
4218
+ atEntity.keyId = tokenClaims.cnf.kid;
4219
+ break;
4220
+ case exports.AuthenticationScheme.SSH:
4221
+ atEntity.keyId = keyId;
4046
4222
  }
4047
- atEntity.keyId = tokenClaims.cnf.kid;
4048
4223
  }
4049
4224
  return atEntity;
4050
4225
  };
@@ -4068,7 +4243,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4068
4243
  return AccessTokenEntity;
4069
4244
  }(CredentialEntity));
4070
4245
 
4071
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4246
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4072
4247
 
4073
4248
  /*
4074
4249
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4135,7 +4310,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4135
4310
  return RefreshTokenEntity;
4136
4311
  }(CredentialEntity));
4137
4312
 
4138
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4313
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4139
4314
 
4140
4315
  /*
4141
4316
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4199,7 +4374,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
4199
4374
  return InteractionRequiredAuthError;
4200
4375
  }(AuthError));
4201
4376
 
4202
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4377
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4203
4378
  /*
4204
4379
  * Copyright (c) Microsoft Corporation. All rights reserved.
4205
4380
  * Licensed under the MIT License.
@@ -4215,7 +4390,7 @@ var CacheRecord = /** @class */ (function () {
4215
4390
  return CacheRecord;
4216
4391
  }());
4217
4392
 
4218
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4393
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4219
4394
 
4220
4395
  /*
4221
4396
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4286,7 +4461,7 @@ var ProtocolUtils = /** @class */ (function () {
4286
4461
  return ProtocolUtils;
4287
4462
  }());
4288
4463
 
4289
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4464
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4290
4465
 
4291
4466
  /*
4292
4467
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4487,7 +4662,7 @@ var UrlString = /** @class */ (function () {
4487
4662
  return UrlString;
4488
4663
  }());
4489
4664
 
4490
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4665
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4491
4666
 
4492
4667
  /*
4493
4668
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4546,14 +4721,14 @@ var PopTokenGenerator = /** @class */ (function () {
4546
4721
  };
4547
4722
  PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
4548
4723
  return __awaiter(this, void 0, void 0, function () {
4549
- var resourceRequestMethod, resourceRequestUri, shrClaims, resourceUrlString, resourceUrlComponents;
4724
+ var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
4550
4725
  return __generator(this, function (_a) {
4551
4726
  switch (_a.label) {
4552
4727
  case 0:
4553
- resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims;
4728
+ resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4554
4729
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4555
4730
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4556
- 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: 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)];
4731
+ 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)];
4557
4732
  case 1: return [2 /*return*/, _a.sent()];
4558
4733
  }
4559
4734
  });
@@ -4562,7 +4737,7 @@ var PopTokenGenerator = /** @class */ (function () {
4562
4737
  return PopTokenGenerator;
4563
4738
  }());
4564
4739
 
4565
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4740
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4566
4741
 
4567
4742
  /*
4568
4743
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4632,7 +4807,7 @@ var AppMetadataEntity = /** @class */ (function () {
4632
4807
  return AppMetadataEntity;
4633
4808
  }());
4634
4809
 
4635
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4810
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4636
4811
  /*
4637
4812
  * Copyright (c) Microsoft Corporation. All rights reserved.
4638
4813
  * Licensed under the MIT License.
@@ -4668,7 +4843,7 @@ var AppMetadataEntity = /** @class */ (function () {
4668
4843
  return TokenCacheContext;
4669
4844
  }());
4670
4845
 
4671
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4846
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4672
4847
 
4673
4848
  /*
4674
4849
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4749,7 +4924,9 @@ var ResponseHandler = /** @class */ (function () {
4749
4924
  if (!!authCodePayload && !!authCodePayload.state) {
4750
4925
  requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, authCodePayload.state);
4751
4926
  }
4752
- cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, idTokenObj, request.scopes, oboAssertion, authCodePayload);
4927
+ // Add keyId from request to serverTokenResponse if defined
4928
+ serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
4929
+ cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload);
4753
4930
  _a.label = 1;
4754
4931
  case 1:
4755
4932
  _a.trys.push([1, , 5, 8]);
@@ -4786,7 +4963,7 @@ var ResponseHandler = /** @class */ (function () {
4786
4963
  _a.sent();
4787
4964
  _a.label = 7;
4788
4965
  case 7: return [7 /*endfinally*/];
4789
- case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
4966
+ case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
4790
4967
  }
4791
4968
  });
4792
4969
  });
@@ -4797,7 +4974,7 @@ var ResponseHandler = /** @class */ (function () {
4797
4974
  * @param idTokenObj
4798
4975
  * @param authority
4799
4976
  */
4800
- ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, idTokenObj, requestScopes, oboAssertion, authCodePayload) {
4977
+ ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload) {
4801
4978
  var env = authority.getPreferredCache();
4802
4979
  if (StringUtils.isEmpty(env)) {
4803
4980
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -4813,7 +4990,7 @@ var ResponseHandler = /** @class */ (function () {
4813
4990
  var cachedAccessToken = null;
4814
4991
  if (!StringUtils.isEmpty(serverTokenResponse.access_token)) {
4815
4992
  // If scopes not returned in server response, use request scopes
4816
- var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(requestScopes || []);
4993
+ var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(request.scopes || []);
4817
4994
  /*
4818
4995
  * Use timestamp calculated before request
4819
4996
  * Server may return timestamps as strings, parse to numbers if so.
@@ -4825,7 +5002,7 @@ var ResponseHandler = /** @class */ (function () {
4825
5002
  var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
4826
5003
  var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
4827
5004
  // non AAD scenarios can have empty realm
4828
- 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);
5005
+ 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);
4829
5006
  }
4830
5007
  // refreshToken
4831
5008
  var cachedRefreshToken = null;
@@ -4872,7 +5049,7 @@ var ResponseHandler = /** @class */ (function () {
4872
5049
  * @param fromTokenCache
4873
5050
  * @param stateString
4874
5051
  */
4875
- ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState) {
5052
+ ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
4876
5053
  var _a, _b, _c;
4877
5054
  return __awaiter(this, void 0, void 0, function () {
4878
5055
  var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
@@ -4921,7 +5098,8 @@ var ResponseHandler = /** @class */ (function () {
4921
5098
  tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
4922
5099
  state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
4923
5100
  cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
4924
- msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING
5101
+ msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
5102
+ code: code
4925
5103
  }];
4926
5104
  }
4927
5105
  });
@@ -4930,7 +5108,7 @@ var ResponseHandler = /** @class */ (function () {
4930
5108
  return ResponseHandler;
4931
5109
  }());
4932
5110
 
4933
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5111
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
4934
5112
 
4935
5113
  /*
4936
5114
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4942,7 +5120,10 @@ var ResponseHandler = /** @class */ (function () {
4942
5120
  var AuthorizationCodeClient = /** @class */ (function (_super) {
4943
5121
  __extends(AuthorizationCodeClient, _super);
4944
5122
  function AuthorizationCodeClient(configuration) {
4945
- return _super.call(this, configuration) || this;
5123
+ var _this = _super.call(this, configuration) || this;
5124
+ // Flag to indicate if client is for hybrid spa auth code redemption
5125
+ _this.includeRedirectUri = true;
5126
+ return _this;
4946
5127
  }
4947
5128
  /**
4948
5129
  * Creates the URL of the authorization request letting the user input credentials and consent to the
@@ -5042,10 +5223,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5042
5223
  clientId: this.config.authOptions.clientId,
5043
5224
  authority: authority.canonicalAuthority,
5044
5225
  scopes: request.scopes,
5226
+ claims: request.claims,
5045
5227
  authenticationScheme: request.authenticationScheme,
5046
5228
  resourceRequestMethod: request.resourceRequestMethod,
5047
5229
  resourceRequestUri: request.resourceRequestUri,
5048
- shrClaims: request.shrClaims
5230
+ shrClaims: request.shrClaims,
5231
+ sshKid: request.sshKid
5049
5232
  };
5050
5233
  return [4 /*yield*/, this.createTokenRequestBody(request)];
5051
5234
  case 1:
@@ -5089,13 +5272,24 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5089
5272
  AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
5090
5273
  return __awaiter(this, void 0, void 0, function () {
5091
5274
  var parameterBuilder, clientAssertion, popTokenGenerator, cnfString, correlationId, ccsCred, clientInfo, clientInfo;
5092
- return __generator(this, function (_a) {
5093
- switch (_a.label) {
5275
+ var _a;
5276
+ return __generator(this, function (_b) {
5277
+ switch (_b.label) {
5094
5278
  case 0:
5095
5279
  parameterBuilder = new RequestParameterBuilder();
5096
5280
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5097
- // validate the redirectUri (to be a non null value)
5098
- parameterBuilder.addRedirectUri(request.redirectUri);
5281
+ /*
5282
+ * For hybrid spa flow, there will be a code but no verifier
5283
+ * In this scenario, don't include redirect uri as auth code will not be bound to redirect URI
5284
+ */
5285
+ if (!this.includeRedirectUri) {
5286
+ // Just validate
5287
+ RequestValidator.validateRedirectUri(request.redirectUri);
5288
+ }
5289
+ else {
5290
+ // Validate and include redirect uri
5291
+ parameterBuilder.addRedirectUri(request.redirectUri);
5292
+ }
5099
5293
  // Add scope array, parameter builder will add default scopes and dedupe
5100
5294
  parameterBuilder.addScopes(request.scopes);
5101
5295
  // add code: user set, not validated
@@ -5124,10 +5318,20 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5124
5318
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5125
5319
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5126
5320
  case 1:
5127
- cnfString = _a.sent();
5321
+ cnfString = _b.sent();
5128
5322
  parameterBuilder.addPopToken(cnfString);
5129
- _a.label = 2;
5323
+ return [3 /*break*/, 3];
5130
5324
  case 2:
5325
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
5326
+ if (request.sshJwk) {
5327
+ parameterBuilder.addSshJwk(request.sshJwk);
5328
+ }
5329
+ else {
5330
+ throw ClientConfigurationError.createMissingSshJwkError();
5331
+ }
5332
+ }
5333
+ _b.label = 3;
5334
+ case 3:
5131
5335
  correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5132
5336
  parameterBuilder.addCorrelationId(correlationId);
5133
5337
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
@@ -5166,6 +5370,15 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5166
5370
  break;
5167
5371
  }
5168
5372
  }
5373
+ if (request.tokenBodyParameters) {
5374
+ parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
5375
+ }
5376
+ // Add hybrid spa parameters if not already provided
5377
+ if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
5378
+ parameterBuilder.addExtraQueryParameters((_a = {},
5379
+ _a[AADServerParamKeys.RETURN_SPA_CODE] = "1",
5380
+ _a));
5381
+ }
5169
5382
  return [2 /*return*/, parameterBuilder.createQueryString()];
5170
5383
  }
5171
5384
  });
@@ -5284,6 +5497,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5284
5497
  if (request.state) {
5285
5498
  parameterBuilder.addState(request.state);
5286
5499
  }
5500
+ if (request.logoutHint) {
5501
+ parameterBuilder.addLogoutHint(request.logoutHint);
5502
+ }
5287
5503
  if (request.extraQueryParameters) {
5288
5504
  parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
5289
5505
  }
@@ -5303,7 +5519,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5303
5519
  return AuthorizationCodeClient;
5304
5520
  }(BaseClient));
5305
5521
 
5306
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5522
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
5307
5523
 
5308
5524
  /*
5309
5525
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5414,10 +5630,12 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5414
5630
  clientId: this.config.authOptions.clientId,
5415
5631
  authority: authority.canonicalAuthority,
5416
5632
  scopes: request.scopes,
5633
+ claims: request.claims,
5417
5634
  authenticationScheme: request.authenticationScheme,
5418
5635
  resourceRequestMethod: request.resourceRequestMethod,
5419
5636
  resourceRequestUri: request.resourceRequestUri,
5420
- shrClaims: request.shrClaims
5637
+ shrClaims: request.shrClaims,
5638
+ sshKid: request.sshKid
5421
5639
  };
5422
5640
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
5423
5641
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
@@ -5442,9 +5660,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5442
5660
  */
5443
5661
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
5444
5662
  return __awaiter(this, void 0, void 0, function () {
5445
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, _a, _b, clientInfo;
5446
- return __generator(this, function (_c) {
5447
- switch (_c.label) {
5663
+ var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
5664
+ return __generator(this, function (_a) {
5665
+ switch (_a.label) {
5448
5666
  case 0:
5449
5667
  parameterBuilder = new RequestParameterBuilder();
5450
5668
  parameterBuilder.addClientId(this.config.authOptions.clientId);
@@ -5469,12 +5687,22 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5469
5687
  }
5470
5688
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5471
5689
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5472
- _b = (_a = parameterBuilder).addPopToken;
5473
5690
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5474
5691
  case 1:
5475
- _b.apply(_a, [_c.sent()]);
5476
- _c.label = 2;
5692
+ cnfString = _a.sent();
5693
+ parameterBuilder.addPopToken(cnfString);
5694
+ return [3 /*break*/, 3];
5477
5695
  case 2:
5696
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
5697
+ if (request.sshJwk) {
5698
+ parameterBuilder.addSshJwk(request.sshJwk);
5699
+ }
5700
+ else {
5701
+ throw ClientConfigurationError.createMissingSshJwkError();
5702
+ }
5703
+ }
5704
+ _a.label = 3;
5705
+ case 3:
5478
5706
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
5479
5707
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
5480
5708
  }
@@ -5502,7 +5730,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5502
5730
  return RefreshTokenClient;
5503
5731
  }(BaseClient));
5504
5732
 
5505
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5733
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
5506
5734
 
5507
5735
  /*
5508
5736
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5548,7 +5776,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
5548
5776
  SilentFlowClient.prototype.acquireCachedToken = function (request) {
5549
5777
  var _a, _b, _c, _d;
5550
5778
  return __awaiter(this, void 0, void 0, function () {
5551
- var requestScopes, environment, authScheme, cacheRecord;
5779
+ var environment, cacheRecord;
5552
5780
  return __generator(this, function (_e) {
5553
5781
  switch (_e.label) {
5554
5782
  case 0:
@@ -5556,37 +5784,35 @@ var SilentFlowClient = /** @class */ (function (_super) {
5556
5784
  if (!request) {
5557
5785
  throw ClientConfigurationError.createEmptyTokenRequestError();
5558
5786
  }
5559
- // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
5560
- if (!request.account) {
5561
- throw ClientAuthError.createNoAccountInSilentRequestError();
5562
- }
5563
- requestScopes = new ScopeSet(request.scopes || []);
5564
- environment = request.authority || this.authority.getPreferredCache();
5565
- authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
5566
- cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
5567
5787
  if (request.forceRefresh) {
5568
5788
  // Must refresh due to present force_refresh flag.
5569
5789
  (_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
5790
+ this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
5570
5791
  throw ClientAuthError.createRefreshRequiredError();
5571
5792
  }
5572
- else if (!cacheRecord.accessToken) {
5793
+ // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
5794
+ if (!request.account) {
5795
+ throw ClientAuthError.createNoAccountInSilentRequestError();
5796
+ }
5797
+ environment = request.authority || this.authority.getPreferredCache();
5798
+ cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, request, environment);
5799
+ if (!cacheRecord.accessToken) {
5573
5800
  // Must refresh due to non-existent access_token.
5574
5801
  (_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
5802
+ this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
5575
5803
  throw ClientAuthError.createRefreshRequiredError();
5576
5804
  }
5577
5805
  else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
5578
5806
  TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
5579
5807
  // Must refresh due to expired access_token.
5580
5808
  (_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
5809
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
5581
5810
  throw ClientAuthError.createRefreshRequiredError();
5582
5811
  }
5583
5812
  else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
5584
5813
  // Must refresh due to the refresh_in value.
5585
5814
  (_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
5586
- throw ClientAuthError.createRefreshRequiredError();
5587
- }
5588
- else if (!StringUtils.isEmptyObj(request.claims)) {
5589
- // Must refresh due to request parameters.
5815
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
5590
5816
  throw ClientAuthError.createRefreshRequiredError();
5591
5817
  }
5592
5818
  if (this.config.serverTelemetryManager) {
@@ -5620,7 +5846,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
5620
5846
  return SilentFlowClient;
5621
5847
  }(BaseClient));
5622
5848
 
5623
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5849
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
5624
5850
  /*
5625
5851
  * Copyright (c) Microsoft Corporation. All rights reserved.
5626
5852
  * Licensed under the MIT License.
@@ -5628,11 +5854,10 @@ var SilentFlowClient = /** @class */ (function (_super) {
5628
5854
  function isOpenIdConfigResponse(response) {
5629
5855
  return (response.hasOwnProperty("authorization_endpoint") &&
5630
5856
  response.hasOwnProperty("token_endpoint") &&
5631
- response.hasOwnProperty("end_session_endpoint") &&
5632
5857
  response.hasOwnProperty("issuer"));
5633
5858
  }
5634
5859
 
5635
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5860
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
5636
5861
  /*
5637
5862
  * Copyright (c) Microsoft Corporation. All rights reserved.
5638
5863
  * Licensed under the MIT License.
@@ -5646,7 +5871,7 @@ exports.ProtocolMode = void 0;
5646
5871
  ProtocolMode["OIDC"] = "OIDC";
5647
5872
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5648
5873
 
5649
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5874
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
5650
5875
 
5651
5876
  /*
5652
5877
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5713,7 +5938,6 @@ var AuthorityMetadataEntity = /** @class */ (function () {
5713
5938
  entity.hasOwnProperty("canonical_authority") &&
5714
5939
  entity.hasOwnProperty("authorization_endpoint") &&
5715
5940
  entity.hasOwnProperty("token_endpoint") &&
5716
- entity.hasOwnProperty("end_session_endpoint") &&
5717
5941
  entity.hasOwnProperty("issuer") &&
5718
5942
  entity.hasOwnProperty("aliasesFromNetwork") &&
5719
5943
  entity.hasOwnProperty("endpointsFromNetwork") &&
@@ -5722,7 +5946,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
5722
5946
  return AuthorityMetadataEntity;
5723
5947
  }());
5724
5948
 
5725
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5949
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
5726
5950
  /*
5727
5951
  * Copyright (c) Microsoft Corporation. All rights reserved.
5728
5952
  * Licensed under the MIT License.
@@ -5732,7 +5956,7 @@ function isCloudInstanceDiscoveryResponse(response) {
5732
5956
  response.hasOwnProperty("metadata"));
5733
5957
  }
5734
5958
 
5735
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5959
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
5736
5960
 
5737
5961
  /*
5738
5962
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5747,18 +5971,22 @@ var RegionDiscovery = /** @class */ (function () {
5747
5971
  *
5748
5972
  * @returns Promise<string | null>
5749
5973
  */
5750
- RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata) {
5974
+ RegionDiscovery.prototype.detectRegion = function (environmentRegion, regionDiscoveryMetadata, proxyUrl) {
5751
5975
  return __awaiter(this, void 0, void 0, function () {
5752
- var autodetectedRegionName, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
5976
+ var autodetectedRegionName, options, localIMDSVersionResponse, currentIMDSVersion, currentIMDSVersionResponse;
5753
5977
  return __generator(this, function (_a) {
5754
5978
  switch (_a.label) {
5755
5979
  case 0:
5756
5980
  autodetectedRegionName = environmentRegion;
5757
5981
  if (!!autodetectedRegionName) return [3 /*break*/, 8];
5982
+ options = RegionDiscovery.IMDS_OPTIONS;
5983
+ if (proxyUrl) {
5984
+ options.proxyUrl = proxyUrl;
5985
+ }
5758
5986
  _a.label = 1;
5759
5987
  case 1:
5760
5988
  _a.trys.push([1, 6, , 7]);
5761
- return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION)];
5989
+ return [4 /*yield*/, this.getRegionFromIMDS(Constants.IMDS_VERSION, options)];
5762
5990
  case 2:
5763
5991
  localIMDSVersionResponse = _a.sent();
5764
5992
  if (localIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
@@ -5766,14 +5994,14 @@ var RegionDiscovery = /** @class */ (function () {
5766
5994
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.IMDS;
5767
5995
  }
5768
5996
  if (!(localIMDSVersionResponse.status === ResponseCodes.httpBadRequest)) return [3 /*break*/, 5];
5769
- return [4 /*yield*/, this.getCurrentVersion()];
5997
+ return [4 /*yield*/, this.getCurrentVersion(options)];
5770
5998
  case 3:
5771
5999
  currentIMDSVersion = _a.sent();
5772
6000
  if (!currentIMDSVersion) {
5773
6001
  regionDiscoveryMetadata.region_source = RegionDiscoverySources.FAILED_AUTO_DETECTION;
5774
6002
  return [2 /*return*/, null];
5775
6003
  }
5776
- return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion)];
6004
+ return [4 /*yield*/, this.getRegionFromIMDS(currentIMDSVersion, options)];
5777
6005
  case 4:
5778
6006
  currentIMDSVersionResponse = _a.sent();
5779
6007
  if (currentIMDSVersionResponse.status === ResponseCodes.httpSuccess) {
@@ -5806,10 +6034,10 @@ var RegionDiscovery = /** @class */ (function () {
5806
6034
  * @param imdsEndpointUrl
5807
6035
  * @returns Promise<NetworkResponse<string>>
5808
6036
  */
5809
- RegionDiscovery.prototype.getRegionFromIMDS = function (version) {
6037
+ RegionDiscovery.prototype.getRegionFromIMDS = function (version, options) {
5810
6038
  return __awaiter(this, void 0, void 0, function () {
5811
6039
  return __generator(this, function (_a) {
5812
- return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", RegionDiscovery.IMDS_OPTIONS, Constants.IMDS_TIMEOUT)];
6040
+ return [2 /*return*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?api-version=" + version + "&format=text", options, Constants.IMDS_TIMEOUT)];
5813
6041
  });
5814
6042
  });
5815
6043
  };
@@ -5818,14 +6046,14 @@ var RegionDiscovery = /** @class */ (function () {
5818
6046
  *
5819
6047
  * @returns Promise<string | null>
5820
6048
  */
5821
- RegionDiscovery.prototype.getCurrentVersion = function () {
6049
+ RegionDiscovery.prototype.getCurrentVersion = function (options) {
5822
6050
  return __awaiter(this, void 0, void 0, function () {
5823
6051
  var response;
5824
6052
  return __generator(this, function (_a) {
5825
6053
  switch (_a.label) {
5826
6054
  case 0:
5827
6055
  _a.trys.push([0, 2, , 3]);
5828
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", RegionDiscovery.IMDS_OPTIONS)];
6056
+ return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(Constants.IMDS_ENDPOINT + "?format=json", options)];
5829
6057
  case 1:
5830
6058
  response = _a.sent();
5831
6059
  // When IMDS endpoint is called without the api version query param, bad request response comes back with latest version.
@@ -5842,11 +6070,15 @@ var RegionDiscovery = /** @class */ (function () {
5842
6070
  });
5843
6071
  };
5844
6072
  // Options for the IMDS endpoint request
5845
- RegionDiscovery.IMDS_OPTIONS = { headers: { "Metadata": "true" } };
6073
+ RegionDiscovery.IMDS_OPTIONS = {
6074
+ headers: {
6075
+ Metadata: "true",
6076
+ },
6077
+ };
5846
6078
  return RegionDiscovery;
5847
6079
  }());
5848
6080
 
5849
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6081
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
5850
6082
 
5851
6083
  /*
5852
6084
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5857,7 +6089,7 @@ var RegionDiscovery = /** @class */ (function () {
5857
6089
  * endpoint. It will store the pertinent config data in this object for use during token calls.
5858
6090
  */
5859
6091
  var Authority = /** @class */ (function () {
5860
- function Authority(authority, networkInterface, cacheManager, authorityOptions) {
6092
+ function Authority(authority, networkInterface, cacheManager, authorityOptions, proxyUrl) {
5861
6093
  this.canonicalAuthority = authority;
5862
6094
  this._canonicalAuthority.validateAsUri();
5863
6095
  this.networkInterface = networkInterface;
@@ -5865,6 +6097,7 @@ var Authority = /** @class */ (function () {
5865
6097
  this.authorityOptions = authorityOptions;
5866
6098
  this.regionDiscovery = new RegionDiscovery(networkInterface);
5867
6099
  this.regionDiscoveryMetadata = { region_used: undefined, region_source: undefined, region_outcome: undefined };
6100
+ this.proxyUrl = proxyUrl || Constants.EMPTY_STRING;
5868
6101
  }
5869
6102
  Object.defineProperty(Authority.prototype, "authorityType", {
5870
6103
  // See above for AuthorityType
@@ -6000,6 +6233,10 @@ var Authority = /** @class */ (function () {
6000
6233
  */
6001
6234
  get: function () {
6002
6235
  if (this.discoveryComplete()) {
6236
+ // ROPC policies may not have end_session_endpoint set
6237
+ if (!this.metadata.end_session_endpoint) {
6238
+ throw ClientAuthError.createLogoutNotSupportedError();
6239
+ }
6003
6240
  var endpoint = this.replacePath(this.metadata.end_session_endpoint);
6004
6241
  return this.replaceTenant(endpoint);
6005
6242
  }
@@ -6129,7 +6366,7 @@ var Authority = /** @class */ (function () {
6129
6366
  metadata = _b.sent();
6130
6367
  if (!metadata) return [3 /*break*/, 4];
6131
6368
  if (!((_a = this.authorityOptions.azureRegionConfiguration) === null || _a === void 0 ? void 0 : _a.azureRegion)) return [3 /*break*/, 3];
6132
- return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata)];
6369
+ return [4 /*yield*/, this.regionDiscovery.detectRegion(this.authorityOptions.azureRegionConfiguration.environmentRegion, this.regionDiscoveryMetadata, this.proxyUrl)];
6133
6370
  case 2:
6134
6371
  autodetectedRegionName = _b.sent();
6135
6372
  azureRegion = this.authorityOptions.azureRegionConfiguration.azureRegion === Constants.AZURE_REGION_AUTO_DISCOVER_FLAG
@@ -6192,19 +6429,25 @@ var Authority = /** @class */ (function () {
6192
6429
  */
6193
6430
  Authority.prototype.getEndpointMetadataFromNetwork = function () {
6194
6431
  return __awaiter(this, void 0, void 0, function () {
6195
- var response;
6432
+ var options, response;
6196
6433
  return __generator(this, function (_a) {
6197
6434
  switch (_a.label) {
6198
6435
  case 0:
6199
- _a.trys.push([0, 2, , 3]);
6200
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint)];
6436
+ options = {};
6437
+ if (this.proxyUrl) {
6438
+ options.proxyUrl = this.proxyUrl;
6439
+ }
6440
+ _a.label = 1;
6201
6441
  case 1:
6442
+ _a.trys.push([1, 3, , 4]);
6443
+ return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
6444
+ case 2:
6202
6445
  response = _a.sent();
6203
6446
  return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
6204
- case 2:
6447
+ case 3:
6205
6448
  _a.sent();
6206
6449
  return [2 /*return*/, null];
6207
- case 3: return [2 /*return*/];
6450
+ case 4: return [2 /*return*/];
6208
6451
  }
6209
6452
  });
6210
6453
  });
@@ -6274,16 +6517,20 @@ var Authority = /** @class */ (function () {
6274
6517
  */
6275
6518
  Authority.prototype.getCloudDiscoveryMetadataFromNetwork = function () {
6276
6519
  return __awaiter(this, void 0, void 0, function () {
6277
- var instanceDiscoveryEndpoint, match, response, metadata;
6520
+ var instanceDiscoveryEndpoint, options, match, response, metadata;
6278
6521
  return __generator(this, function (_a) {
6279
6522
  switch (_a.label) {
6280
6523
  case 0:
6281
6524
  instanceDiscoveryEndpoint = "" + Constants.AAD_INSTANCE_DISCOVERY_ENDPT + this.canonicalAuthority + "oauth2/v2.0/authorize";
6525
+ options = {};
6526
+ if (this.proxyUrl) {
6527
+ options.proxyUrl = this.proxyUrl;
6528
+ }
6282
6529
  match = null;
6283
6530
  _a.label = 1;
6284
6531
  case 1:
6285
6532
  _a.trys.push([1, 3, , 4]);
6286
- return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint)];
6533
+ return [4 /*yield*/, this.networkInterface.sendGetRequestAsync(instanceDiscoveryEndpoint, options)];
6287
6534
  case 2:
6288
6535
  response = _a.sent();
6289
6536
  metadata = isCloudInstanceDiscoveryResponse(response.body) ? response.body.metadata : [];
@@ -6298,7 +6545,7 @@ var Authority = /** @class */ (function () {
6298
6545
  return [2 /*return*/, null];
6299
6546
  case 4:
6300
6547
  if (!match) {
6301
- // Custom Domain scenario, host is trusted because Instance Discovery call succeeded
6548
+ // Custom Domain scenario, host is trusted because Instance Discovery call succeeded
6302
6549
  match = Authority.createCloudDiscoveryMetadataFromHost(this.hostnameAndPort);
6303
6550
  }
6304
6551
  return [2 /*return*/, match];
@@ -6316,6 +6563,19 @@ var Authority = /** @class */ (function () {
6316
6563
  });
6317
6564
  return matches.length > 0;
6318
6565
  };
6566
+ /**
6567
+ * helper function to populate the authority based on azureCloudOptions
6568
+ * @param authorityString
6569
+ * @param azureCloudOptions
6570
+ */
6571
+ Authority.generateAuthority = function (authorityString, azureCloudOptions) {
6572
+ var authorityAzureCloudInstance;
6573
+ if (azureCloudOptions && azureCloudOptions.azureCloudInstance !== exports.AzureCloudInstance.None) {
6574
+ var tenant = azureCloudOptions.tenant ? azureCloudOptions.tenant : Constants.DEFAULT_COMMON_TENANT;
6575
+ authorityAzureCloudInstance = azureCloudOptions.azureCloudInstance + "/" + tenant + "/";
6576
+ }
6577
+ return authorityAzureCloudInstance ? authorityAzureCloudInstance : authorityString;
6578
+ };
6319
6579
  /**
6320
6580
  * Creates cloud discovery metadata object from a given host
6321
6581
  * @param host
@@ -6400,13 +6660,15 @@ var Authority = /** @class */ (function () {
6400
6660
  metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
6401
6661
  // TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
6402
6662
  metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, "allowestsrnonmsi=true");
6403
- metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
6663
+ if (metadata.end_session_endpoint) {
6664
+ metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
6665
+ }
6404
6666
  return metadata;
6405
6667
  };
6406
6668
  return Authority;
6407
6669
  }());
6408
6670
 
6409
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6671
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
6410
6672
 
6411
6673
  /*
6412
6674
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6425,13 +6687,13 @@ var AuthorityFactory = /** @class */ (function () {
6425
6687
  * @param networkClient
6426
6688
  * @param protocolMode
6427
6689
  */
6428
- AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions) {
6690
+ AuthorityFactory.createDiscoveredInstance = function (authorityUri, networkClient, cacheManager, authorityOptions, proxyUrl) {
6429
6691
  return __awaiter(this, void 0, void 0, function () {
6430
6692
  var acquireTokenAuthority, e_1;
6431
6693
  return __generator(this, function (_a) {
6432
6694
  switch (_a.label) {
6433
6695
  case 0:
6434
- acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions);
6696
+ acquireTokenAuthority = AuthorityFactory.createInstance(authorityUri, networkClient, cacheManager, authorityOptions, proxyUrl);
6435
6697
  _a.label = 1;
6436
6698
  case 1:
6437
6699
  _a.trys.push([1, 3, , 4]);
@@ -6457,17 +6719,17 @@ var AuthorityFactory = /** @class */ (function () {
6457
6719
  * @param networkInterface
6458
6720
  * @param protocolMode
6459
6721
  */
6460
- AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions) {
6722
+ AuthorityFactory.createInstance = function (authorityUrl, networkInterface, cacheManager, authorityOptions, proxyUrl) {
6461
6723
  // Throw error if authority url is empty
6462
6724
  if (StringUtils.isEmpty(authorityUrl)) {
6463
6725
  throw ClientConfigurationError.createUrlEmptyError();
6464
6726
  }
6465
- return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions);
6727
+ return new Authority(authorityUrl, networkInterface, cacheManager, authorityOptions, proxyUrl);
6466
6728
  };
6467
6729
  return AuthorityFactory;
6468
6730
  }());
6469
6731
 
6470
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6732
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
6471
6733
 
6472
6734
  /*
6473
6735
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6498,7 +6760,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
6498
6760
  return ServerTelemetryEntity;
6499
6761
  }());
6500
6762
 
6501
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6763
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
6502
6764
 
6503
6765
  /*
6504
6766
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6526,7 +6788,7 @@ var ThrottlingEntity = /** @class */ (function () {
6526
6788
  return ThrottlingEntity;
6527
6789
  }());
6528
6790
 
6529
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6791
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
6530
6792
 
6531
6793
  /*
6532
6794
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6543,7 +6805,66 @@ var StubbedNetworkModule = {
6543
6805
  }
6544
6806
  };
6545
6807
 
6546
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6808
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
6809
+
6810
+ /*
6811
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6812
+ * Licensed under the MIT License.
6813
+ */
6814
+ /**
6815
+ * This is a helper class that parses supported HTTP response authentication headers to extract and return
6816
+ * header challenge values that can be used outside the basic authorization flows.
6817
+ */
6818
+ var AuthenticationHeaderParser = /** @class */ (function () {
6819
+ function AuthenticationHeaderParser(headers) {
6820
+ this.headers = headers;
6821
+ }
6822
+ /**
6823
+ * This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
6824
+ * @returns
6825
+ */
6826
+ AuthenticationHeaderParser.prototype.getShrNonce = function () {
6827
+ // Attempt to parse nonce from Authentiacation-Info
6828
+ var authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
6829
+ if (authenticationInfo) {
6830
+ var authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
6831
+ if (authenticationInfoChallenges.nextnonce) {
6832
+ return authenticationInfoChallenges.nextnonce;
6833
+ }
6834
+ throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
6835
+ }
6836
+ // Attempt to parse nonce from WWW-Authenticate
6837
+ var wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
6838
+ if (wwwAuthenticate) {
6839
+ var wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
6840
+ if (wwwAuthenticateChallenges.nonce) {
6841
+ return wwwAuthenticateChallenges.nonce;
6842
+ }
6843
+ throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
6844
+ }
6845
+ // If neither header is present, throw missing headers error
6846
+ throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
6847
+ };
6848
+ /**
6849
+ * Parses an HTTP header's challenge set into a key/value map.
6850
+ * @param header
6851
+ * @returns
6852
+ */
6853
+ AuthenticationHeaderParser.prototype.parseChallenges = function (header) {
6854
+ var schemeSeparator = header.indexOf(" ");
6855
+ var challenges = header.substr(schemeSeparator + 1).split(",");
6856
+ var challengeMap = {};
6857
+ challenges.forEach(function (challenge) {
6858
+ var _a = challenge.split("="), key = _a[0], value = _a[1];
6859
+ // Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
6860
+ challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
6861
+ });
6862
+ return challengeMap;
6863
+ };
6864
+ return AuthenticationHeaderParser;
6865
+ }());
6866
+
6867
+ /*! @azure/msal-common v6.1.0 2022-02-08 */
6547
6868
 
6548
6869
  /*
6549
6870
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6759,7 +7080,7 @@ var HTTP_REQUEST_TYPE;
6759
7080
  /**
6760
7081
  * Temporary cache keys for MSAL, deleted after any request.
6761
7082
  */
6762
- var TemporaryCacheKeys;
7083
+ exports.TemporaryCacheKeys = void 0;
6763
7084
  (function (TemporaryCacheKeys) {
6764
7085
  TemporaryCacheKeys["AUTHORITY"] = "authority";
6765
7086
  TemporaryCacheKeys["ACQUIRE_TOKEN_ACCOUNT"] = "acquireToken.account";
@@ -6774,7 +7095,7 @@ var TemporaryCacheKeys;
6774
7095
  TemporaryCacheKeys["INTERACTION_STATUS_KEY"] = "interaction.status";
6775
7096
  TemporaryCacheKeys["CCS_CREDENTIAL"] = "ccs.credential";
6776
7097
  TemporaryCacheKeys["CORRELATION_ID"] = "request.correlationId";
6777
- })(TemporaryCacheKeys || (TemporaryCacheKeys = {}));
7098
+ })(exports.TemporaryCacheKeys || (exports.TemporaryCacheKeys = {}));
6778
7099
  /**
6779
7100
  * Cache keys stored in-memory
6780
7101
  */
@@ -6796,6 +7117,7 @@ exports.ApiId = void 0;
6796
7117
  ApiId[ApiId["ssoSilent"] = 863] = "ssoSilent";
6797
7118
  ApiId[ApiId["acquireTokenSilent_authCode"] = 864] = "acquireTokenSilent_authCode";
6798
7119
  ApiId[ApiId["handleRedirectPromise"] = 865] = "handleRedirectPromise";
7120
+ ApiId[ApiId["acquireTokenByCode"] = 866] = "acquireTokenByCode";
6799
7121
  ApiId[ApiId["acquireTokenSilent_silentFlow"] = 61] = "acquireTokenSilent_silentFlow";
6800
7122
  ApiId[ApiId["logout"] = 961] = "logout";
6801
7123
  ApiId[ApiId["logoutPopup"] = 962] = "logoutPopup";
@@ -6808,6 +7130,7 @@ exports.InteractionType = void 0;
6808
7130
  InteractionType["Redirect"] = "redirect";
6809
7131
  InteractionType["Popup"] = "popup";
6810
7132
  InteractionType["Silent"] = "silent";
7133
+ InteractionType["None"] = "none";
6811
7134
  })(exports.InteractionType || (exports.InteractionType = {}));
6812
7135
  /**
6813
7136
  * Types of interaction currently in progress.
@@ -6856,7 +7179,11 @@ exports.WrapperSKU = void 0;
6856
7179
  (function (WrapperSKU) {
6857
7180
  WrapperSKU["React"] = "@azure/msal-react";
6858
7181
  WrapperSKU["Angular"] = "@azure/msal-angular";
6859
- })(exports.WrapperSKU || (exports.WrapperSKU = {}));
7182
+ })(exports.WrapperSKU || (exports.WrapperSKU = {}));
7183
+ // DatabaseStorage Constants
7184
+ var DB_NAME = "msal.db";
7185
+ var DB_VERSION = 1;
7186
+ var DB_TABLE_NAME = DB_NAME + ".keys";
6860
7187
 
6861
7188
  /*
6862
7189
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7332,7 +7659,7 @@ var BrowserAuthErrorMessage = {
7332
7659
  },
7333
7660
  noTokenRequestCacheError: {
7334
7661
  code: "no_token_request_cache_error",
7335
- desc: "No token request in found in cache."
7662
+ desc: "No token request found in cache."
7336
7663
  },
7337
7664
  unableToParseTokenRequestCacheError: {
7338
7665
  code: "unable_to_parse_token_request_cache_error",
@@ -7381,6 +7708,14 @@ var BrowserAuthErrorMessage = {
7381
7708
  signingKeyNotFoundInStorage: {
7382
7709
  code: "crypto_key_not_found",
7383
7710
  desc: "Cryptographic Key or Keypair not found in browser storage."
7711
+ },
7712
+ authCodeRequired: {
7713
+ code: "auth_code_required",
7714
+ desc: "An authorization code must be provided (as the `code` property on the request) to this flow."
7715
+ },
7716
+ databaseUnavailable: {
7717
+ code: "database_unavailable",
7718
+ desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
7384
7719
  }
7385
7720
  };
7386
7721
  /**
@@ -7614,6 +7949,18 @@ var BrowserAuthError = /** @class */ (function (_super) {
7614
7949
  BrowserAuthError.createSigningKeyNotFoundInStorageError = function (keyId) {
7615
7950
  return new BrowserAuthError(BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code, BrowserAuthErrorMessage.signingKeyNotFoundInStorage.desc + " | No match found for KeyId: " + keyId);
7616
7951
  };
7952
+ /**
7953
+ * Create an error when an authorization code is required but not provided
7954
+ */
7955
+ BrowserAuthError.createAuthCodeRequiredError = function () {
7956
+ return new BrowserAuthError(BrowserAuthErrorMessage.authCodeRequired.code, BrowserAuthErrorMessage.authCodeRequired.desc);
7957
+ };
7958
+ /**
7959
+ * Create an error when IndexedDB is unavailable
7960
+ */
7961
+ BrowserAuthError.createDatabaseUnavailableError = function () {
7962
+ return new BrowserAuthError(BrowserAuthErrorMessage.databaseUnavailable.code, BrowserAuthErrorMessage.databaseUnavailable.desc);
7963
+ };
7617
7964
  return BrowserAuthError;
7618
7965
  }(AuthError));
7619
7966
 
@@ -7716,7 +8063,8 @@ var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
7716
8063
  * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
7717
8064
  */
7718
8065
  var BrowserCrypto = /** @class */ (function () {
7719
- function BrowserCrypto() {
8066
+ function BrowserCrypto(logger) {
8067
+ this.logger = logger;
7720
8068
  if (!(this.hasCryptoAPI())) {
7721
8069
  throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto or msCrypto object not available.");
7722
8070
  }
@@ -7975,10 +8323,10 @@ var BrowserCrypto = /** @class */ (function () {
7975
8323
  * Storage wrapper for IndexedDB storage in browsers: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
7976
8324
  */
7977
8325
  var DatabaseStorage = /** @class */ (function () {
7978
- function DatabaseStorage(dbName, tableName, version) {
7979
- this.dbName = dbName;
7980
- this.tableName = tableName;
7981
- this.version = version;
8326
+ function DatabaseStorage() {
8327
+ this.dbName = DB_NAME;
8328
+ this.version = DB_VERSION;
8329
+ this.tableName = DB_TABLE_NAME;
7982
8330
  this.dbOpen = false;
7983
8331
  }
7984
8332
  /**
@@ -7989,7 +8337,6 @@ var DatabaseStorage = /** @class */ (function () {
7989
8337
  var _this = this;
7990
8338
  return __generator$1(this, function (_a) {
7991
8339
  return [2 /*return*/, new Promise(function (resolve, reject) {
7992
- // TODO: Add timeouts?
7993
8340
  var openDB = window.indexedDB.open(_this.dbName, _this.version);
7994
8341
  openDB.addEventListener("upgradeneeded", function (e) {
7995
8342
  var event = e;
@@ -8001,40 +8348,53 @@ var DatabaseStorage = /** @class */ (function () {
8001
8348
  _this.dbOpen = true;
8002
8349
  resolve();
8003
8350
  });
8004
- openDB.addEventListener("error", function (error) { return reject(error); });
8351
+ openDB.addEventListener("error", function () { return reject(BrowserAuthError.createDatabaseUnavailableError()); });
8005
8352
  })];
8006
8353
  });
8007
8354
  });
8008
8355
  };
8009
8356
  /**
8010
- * Retrieves item from IndexedDB instance.
8011
- * @param key
8357
+ * Opens database if it's not already open
8012
8358
  */
8013
- DatabaseStorage.prototype.get = function (key) {
8359
+ DatabaseStorage.prototype.validateDbIsOpen = function () {
8014
8360
  return __awaiter$1(this, void 0, void 0, function () {
8015
- var _this = this;
8016
8361
  return __generator$1(this, function (_a) {
8017
8362
  switch (_a.label) {
8018
8363
  case 0:
8019
8364
  if (!!this.dbOpen) return [3 /*break*/, 2];
8020
8365
  return [4 /*yield*/, this.open()];
8366
+ case 1: return [2 /*return*/, _a.sent()];
8367
+ case 2: return [2 /*return*/];
8368
+ }
8369
+ });
8370
+ });
8371
+ };
8372
+ /**
8373
+ * Retrieves item from IndexedDB instance.
8374
+ * @param key
8375
+ */
8376
+ DatabaseStorage.prototype.getItem = function (key) {
8377
+ return __awaiter$1(this, void 0, void 0, function () {
8378
+ var _this = this;
8379
+ return __generator$1(this, function (_a) {
8380
+ switch (_a.label) {
8381
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8021
8382
  case 1:
8022
8383
  _a.sent();
8023
- _a.label = 2;
8024
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8025
- // TODO: Add timeouts?
8026
- if (!_this.db) {
8027
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8028
- }
8029
- var transaction = _this.db.transaction([_this.tableName], "readonly");
8030
- var objectStore = transaction.objectStore(_this.tableName);
8031
- var dbGet = objectStore.get(key);
8032
- dbGet.addEventListener("success", function (e) {
8033
- var event = e;
8034
- resolve(event.target.result);
8035
- });
8036
- dbGet.addEventListener("error", function (e) { return reject(e); });
8037
- })];
8384
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8385
+ // TODO: Add timeouts?
8386
+ if (!_this.db) {
8387
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8388
+ }
8389
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8390
+ var objectStore = transaction.objectStore(_this.tableName);
8391
+ var dbGet = objectStore.get(key);
8392
+ dbGet.addEventListener("success", function (e) {
8393
+ var event = e;
8394
+ resolve(event.target.result);
8395
+ });
8396
+ dbGet.addEventListener("error", function (e) { return reject(e); });
8397
+ })];
8038
8398
  }
8039
8399
  });
8040
8400
  });
@@ -8044,31 +8404,25 @@ var DatabaseStorage = /** @class */ (function () {
8044
8404
  * @param key
8045
8405
  * @param payload
8046
8406
  */
8047
- DatabaseStorage.prototype.put = function (key, payload) {
8407
+ DatabaseStorage.prototype.setItem = function (key, payload) {
8048
8408
  return __awaiter$1(this, void 0, void 0, function () {
8049
8409
  var _this = this;
8050
8410
  return __generator$1(this, function (_a) {
8051
8411
  switch (_a.label) {
8052
- case 0:
8053
- if (!!this.dbOpen) return [3 /*break*/, 2];
8054
- return [4 /*yield*/, this.open()];
8412
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8055
8413
  case 1:
8056
8414
  _a.sent();
8057
- _a.label = 2;
8058
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8059
- // TODO: Add timeouts?
8060
- if (!_this.db) {
8061
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8062
- }
8063
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8064
- var objectStore = transaction.objectStore(_this.tableName);
8065
- var dbPut = objectStore.put(payload, key);
8066
- dbPut.addEventListener("success", function (e) {
8067
- var event = e;
8068
- resolve(event.target.result);
8069
- });
8070
- dbPut.addEventListener("error", function (e) { return reject(e); });
8071
- })];
8415
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8416
+ // TODO: Add timeouts?
8417
+ if (!_this.db) {
8418
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8419
+ }
8420
+ var transaction = _this.db.transaction([_this.tableName], "readwrite");
8421
+ var objectStore = transaction.objectStore(_this.tableName);
8422
+ var dbPut = objectStore.put(payload, key);
8423
+ dbPut.addEventListener("success", function () { return resolve(); });
8424
+ dbPut.addEventListener("error", function (e) { return reject(e); });
8425
+ })];
8072
8426
  }
8073
8427
  });
8074
8428
  });
@@ -8077,62 +8431,101 @@ var DatabaseStorage = /** @class */ (function () {
8077
8431
  * Removes item from IndexedDB under given key
8078
8432
  * @param key
8079
8433
  */
8080
- DatabaseStorage.prototype.delete = function (key) {
8434
+ DatabaseStorage.prototype.removeItem = function (key) {
8081
8435
  return __awaiter$1(this, void 0, void 0, function () {
8082
8436
  var _this = this;
8083
8437
  return __generator$1(this, function (_a) {
8084
8438
  switch (_a.label) {
8085
- case 0:
8086
- if (!!this.dbOpen) return [3 /*break*/, 2];
8087
- return [4 /*yield*/, this.open()];
8439
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8088
8440
  case 1:
8089
8441
  _a.sent();
8090
- _a.label = 2;
8091
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8092
- if (!_this.db) {
8093
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8094
- }
8095
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8096
- var objectStore = transaction.objectStore(_this.tableName);
8097
- var dbDelete = objectStore.delete(key);
8098
- dbDelete.addEventListener("success", function (e) {
8099
- var event = e;
8100
- resolve(event.target.result === undefined);
8101
- });
8102
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8103
- })];
8442
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8443
+ if (!_this.db) {
8444
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8445
+ }
8446
+ var transaction = _this.db.transaction([_this.tableName], "readwrite");
8447
+ var objectStore = transaction.objectStore(_this.tableName);
8448
+ var dbDelete = objectStore.delete(key);
8449
+ dbDelete.addEventListener("success", function () { return resolve(); });
8450
+ dbDelete.addEventListener("error", function (e) { return reject(e); });
8451
+ })];
8104
8452
  }
8105
8453
  });
8106
8454
  });
8107
8455
  };
8108
- DatabaseStorage.prototype.clear = function () {
8456
+ /**
8457
+ * Get all the keys from the storage object as an iterable array of strings.
8458
+ */
8459
+ DatabaseStorage.prototype.getKeys = function () {
8109
8460
  return __awaiter$1(this, void 0, void 0, function () {
8110
8461
  var _this = this;
8111
8462
  return __generator$1(this, function (_a) {
8112
8463
  switch (_a.label) {
8113
- case 0:
8114
- if (!!this.dbOpen) return [3 /*break*/, 2];
8115
- return [4 /*yield*/, this.open()];
8464
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8116
8465
  case 1:
8117
8466
  _a.sent();
8118
- _a.label = 2;
8119
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8120
- if (!_this.db) {
8121
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8122
- }
8123
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8124
- var objectStore = transaction.objectStore(_this.tableName);
8125
- var dbDelete = objectStore.clear();
8126
- dbDelete.addEventListener("success", function (e) {
8127
- var event = e;
8128
- resolve(event.target.result === undefined);
8129
- });
8130
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8131
- })];
8467
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8468
+ if (!_this.db) {
8469
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8470
+ }
8471
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8472
+ var objectStore = transaction.objectStore(_this.tableName);
8473
+ var dbGetKeys = objectStore.getAllKeys();
8474
+ dbGetKeys.addEventListener("success", function (e) {
8475
+ var event = e;
8476
+ resolve(event.target.result);
8477
+ });
8478
+ dbGetKeys.addEventListener("error", function (e) { return reject(e); });
8479
+ })];
8480
+ }
8481
+ });
8482
+ });
8483
+ };
8484
+ /**
8485
+ *
8486
+ * Checks whether there is an object under the search key in the object store
8487
+ */
8488
+ DatabaseStorage.prototype.containsKey = function (key) {
8489
+ return __awaiter$1(this, void 0, void 0, function () {
8490
+ var _this = this;
8491
+ return __generator$1(this, function (_a) {
8492
+ switch (_a.label) {
8493
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8494
+ case 1:
8495
+ _a.sent();
8496
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8497
+ if (!_this.db) {
8498
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8499
+ }
8500
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8501
+ var objectStore = transaction.objectStore(_this.tableName);
8502
+ var dbContainsKey = objectStore.count(key);
8503
+ dbContainsKey.addEventListener("success", function (e) {
8504
+ var event = e;
8505
+ resolve(event.target.result === 1);
8506
+ });
8507
+ dbContainsKey.addEventListener("error", function (e) { return reject(e); });
8508
+ })];
8132
8509
  }
8133
8510
  });
8134
8511
  });
8135
8512
  };
8513
+ /**
8514
+ * Deletes the MSAL database. The database is deleted rather than cleared to make it possible
8515
+ * for client applications to downgrade to a previous MSAL version without worrying about forward compatibility issues
8516
+ * with IndexedDB database versions.
8517
+ */
8518
+ DatabaseStorage.prototype.deleteDatabase = function () {
8519
+ return __awaiter$1(this, void 0, void 0, function () {
8520
+ return __generator$1(this, function (_a) {
8521
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8522
+ var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
8523
+ deleteDbRequest.addEventListener("success", function () { return resolve(true); });
8524
+ deleteDbRequest.addEventListener("error", function () { return reject(false); });
8525
+ })];
8526
+ });
8527
+ });
8528
+ };
8136
8529
  return DatabaseStorage;
8137
8530
  }());
8138
8531
 
@@ -8140,22 +8533,245 @@ var DatabaseStorage = /** @class */ (function () {
8140
8533
  * Copyright (c) Microsoft Corporation. All rights reserved.
8141
8534
  * Licensed under the MIT License.
8142
8535
  */
8143
- /**
8144
- * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
8145
- * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
8146
- */
8147
- var CryptoOps = /** @class */ (function () {
8148
- function CryptoOps() {
8149
- // Browser crypto needs to be validated first before any other classes can be set.
8150
- this.browserCrypto = new BrowserCrypto();
8151
- this.b64Encode = new Base64Encode();
8152
- this.b64Decode = new Base64Decode();
8153
- this.guidGenerator = new GuidGenerator(this.browserCrypto);
8154
- this.pkceGenerator = new PkceGenerator(this.browserCrypto);
8155
- this.cache = new DatabaseStorage(CryptoOps.DB_NAME, CryptoOps.TABLE_NAME, CryptoOps.DB_VERSION);
8536
+ var MemoryStorage = /** @class */ (function () {
8537
+ function MemoryStorage() {
8538
+ this.cache = new Map();
8156
8539
  }
8157
- /**
8158
- * Creates a new random GUID - used to populate state and nonce.
8540
+ MemoryStorage.prototype.getItem = function (key) {
8541
+ return this.cache.get(key) || null;
8542
+ };
8543
+ MemoryStorage.prototype.setItem = function (key, value) {
8544
+ this.cache.set(key, value);
8545
+ };
8546
+ MemoryStorage.prototype.removeItem = function (key) {
8547
+ this.cache.delete(key);
8548
+ };
8549
+ MemoryStorage.prototype.getKeys = function () {
8550
+ var cacheKeys = [];
8551
+ this.cache.forEach(function (value, key) {
8552
+ cacheKeys.push(key);
8553
+ });
8554
+ return cacheKeys;
8555
+ };
8556
+ MemoryStorage.prototype.containsKey = function (key) {
8557
+ return this.cache.has(key);
8558
+ };
8559
+ MemoryStorage.prototype.clear = function () {
8560
+ this.cache.clear();
8561
+ };
8562
+ return MemoryStorage;
8563
+ }());
8564
+
8565
+ /*
8566
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8567
+ * Licensed under the MIT License.
8568
+ */
8569
+ /**
8570
+ * This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper,
8571
+ * backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
8572
+ */
8573
+ var AsyncMemoryStorage = /** @class */ (function () {
8574
+ function AsyncMemoryStorage(logger) {
8575
+ this.inMemoryCache = new MemoryStorage();
8576
+ this.indexedDBCache = new DatabaseStorage();
8577
+ this.logger = logger;
8578
+ }
8579
+ AsyncMemoryStorage.prototype.handleDatabaseAccessError = function (error) {
8580
+ if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {
8581
+ this.logger.error("Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.");
8582
+ }
8583
+ };
8584
+ /**
8585
+ * Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
8586
+ * storage object if item isn't found in-memory.
8587
+ * @param key
8588
+ */
8589
+ AsyncMemoryStorage.prototype.getItem = function (key) {
8590
+ return __awaiter$1(this, void 0, void 0, function () {
8591
+ var item, e_1;
8592
+ return __generator$1(this, function (_a) {
8593
+ switch (_a.label) {
8594
+ case 0:
8595
+ item = this.inMemoryCache.getItem(key);
8596
+ if (!!item) return [3 /*break*/, 4];
8597
+ _a.label = 1;
8598
+ case 1:
8599
+ _a.trys.push([1, 3, , 4]);
8600
+ this.logger.verbose("Queried item not found in in-memory cache, now querying persistent storage.");
8601
+ return [4 /*yield*/, this.indexedDBCache.getItem(key)];
8602
+ case 2: return [2 /*return*/, _a.sent()];
8603
+ case 3:
8604
+ e_1 = _a.sent();
8605
+ this.handleDatabaseAccessError(e_1);
8606
+ return [3 /*break*/, 4];
8607
+ case 4: return [2 /*return*/, item];
8608
+ }
8609
+ });
8610
+ });
8611
+ };
8612
+ /**
8613
+ * Sets the item in the in-memory cache and then tries to set it in the asynchronous
8614
+ * storage object with the given key.
8615
+ * @param key
8616
+ * @param value
8617
+ */
8618
+ AsyncMemoryStorage.prototype.setItem = function (key, value) {
8619
+ return __awaiter$1(this, void 0, void 0, function () {
8620
+ var e_2;
8621
+ return __generator$1(this, function (_a) {
8622
+ switch (_a.label) {
8623
+ case 0:
8624
+ this.inMemoryCache.setItem(key, value);
8625
+ _a.label = 1;
8626
+ case 1:
8627
+ _a.trys.push([1, 3, , 4]);
8628
+ return [4 /*yield*/, this.indexedDBCache.setItem(key, value)];
8629
+ case 2:
8630
+ _a.sent();
8631
+ return [3 /*break*/, 4];
8632
+ case 3:
8633
+ e_2 = _a.sent();
8634
+ this.handleDatabaseAccessError(e_2);
8635
+ return [3 /*break*/, 4];
8636
+ case 4: return [2 /*return*/];
8637
+ }
8638
+ });
8639
+ });
8640
+ };
8641
+ /**
8642
+ * Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.
8643
+ * @param key
8644
+ */
8645
+ AsyncMemoryStorage.prototype.removeItem = function (key) {
8646
+ return __awaiter$1(this, void 0, void 0, function () {
8647
+ var e_3;
8648
+ return __generator$1(this, function (_a) {
8649
+ switch (_a.label) {
8650
+ case 0:
8651
+ this.inMemoryCache.removeItem(key);
8652
+ _a.label = 1;
8653
+ case 1:
8654
+ _a.trys.push([1, 3, , 4]);
8655
+ return [4 /*yield*/, this.indexedDBCache.removeItem(key)];
8656
+ case 2:
8657
+ _a.sent();
8658
+ return [3 /*break*/, 4];
8659
+ case 3:
8660
+ e_3 = _a.sent();
8661
+ this.handleDatabaseAccessError(e_3);
8662
+ return [3 /*break*/, 4];
8663
+ case 4: return [2 /*return*/];
8664
+ }
8665
+ });
8666
+ });
8667
+ };
8668
+ /**
8669
+ * Get all the keys from the in-memory cache as an iterable array of strings. If no keys are found, query the keys in the
8670
+ * asynchronous storage object.
8671
+ */
8672
+ AsyncMemoryStorage.prototype.getKeys = function () {
8673
+ return __awaiter$1(this, void 0, void 0, function () {
8674
+ var cacheKeys, e_4;
8675
+ return __generator$1(this, function (_a) {
8676
+ switch (_a.label) {
8677
+ case 0:
8678
+ cacheKeys = this.inMemoryCache.getKeys();
8679
+ if (!(cacheKeys.length === 0)) return [3 /*break*/, 4];
8680
+ _a.label = 1;
8681
+ case 1:
8682
+ _a.trys.push([1, 3, , 4]);
8683
+ this.logger.verbose("In-memory cache is empty, now querying persistent storage.");
8684
+ return [4 /*yield*/, this.indexedDBCache.getKeys()];
8685
+ case 2: return [2 /*return*/, _a.sent()];
8686
+ case 3:
8687
+ e_4 = _a.sent();
8688
+ this.handleDatabaseAccessError(e_4);
8689
+ return [3 /*break*/, 4];
8690
+ case 4: return [2 /*return*/, cacheKeys];
8691
+ }
8692
+ });
8693
+ });
8694
+ };
8695
+ /**
8696
+ * Returns true or false if the given key is present in the cache.
8697
+ * @param key
8698
+ */
8699
+ AsyncMemoryStorage.prototype.containsKey = function (key) {
8700
+ return __awaiter$1(this, void 0, void 0, function () {
8701
+ var containsKey, e_5;
8702
+ return __generator$1(this, function (_a) {
8703
+ switch (_a.label) {
8704
+ case 0:
8705
+ containsKey = this.inMemoryCache.containsKey(key);
8706
+ if (!!containsKey) return [3 /*break*/, 4];
8707
+ _a.label = 1;
8708
+ case 1:
8709
+ _a.trys.push([1, 3, , 4]);
8710
+ this.logger.verbose("Key not found in in-memory cache, now querying persistent storage.");
8711
+ return [4 /*yield*/, this.indexedDBCache.containsKey(key)];
8712
+ case 2: return [2 /*return*/, _a.sent()];
8713
+ case 3:
8714
+ e_5 = _a.sent();
8715
+ this.handleDatabaseAccessError(e_5);
8716
+ return [3 /*break*/, 4];
8717
+ case 4: return [2 /*return*/, containsKey];
8718
+ }
8719
+ });
8720
+ });
8721
+ };
8722
+ /**
8723
+ * Clears in-memory Map and tries to delete the IndexedDB database.
8724
+ */
8725
+ AsyncMemoryStorage.prototype.clear = function () {
8726
+ return __awaiter$1(this, void 0, void 0, function () {
8727
+ var e_6;
8728
+ return __generator$1(this, function (_a) {
8729
+ switch (_a.label) {
8730
+ case 0:
8731
+ this.inMemoryCache.clear();
8732
+ _a.label = 1;
8733
+ case 1:
8734
+ _a.trys.push([1, 3, , 4]);
8735
+ return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
8736
+ case 2:
8737
+ _a.sent();
8738
+ return [3 /*break*/, 4];
8739
+ case 3:
8740
+ e_6 = _a.sent();
8741
+ this.handleDatabaseAccessError(e_6);
8742
+ return [3 /*break*/, 4];
8743
+ case 4: return [2 /*return*/];
8744
+ }
8745
+ });
8746
+ });
8747
+ };
8748
+ return AsyncMemoryStorage;
8749
+ }());
8750
+
8751
+ /*
8752
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8753
+ * Licensed under the MIT License.
8754
+ */
8755
+ /**
8756
+ * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
8757
+ * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
8758
+ */
8759
+ var CryptoOps = /** @class */ (function () {
8760
+ function CryptoOps(logger) {
8761
+ this.logger = logger;
8762
+ // Browser crypto needs to be validated first before any other classes can be set.
8763
+ this.browserCrypto = new BrowserCrypto(this.logger);
8764
+ this.b64Encode = new Base64Encode();
8765
+ this.b64Decode = new Base64Decode();
8766
+ this.guidGenerator = new GuidGenerator(this.browserCrypto);
8767
+ this.pkceGenerator = new PkceGenerator(this.browserCrypto);
8768
+ this.cache = {
8769
+ asymmetricKeys: new AsyncMemoryStorage(this.logger),
8770
+ symmetricKeys: new AsyncMemoryStorage(this.logger)
8771
+ };
8772
+ }
8773
+ /**
8774
+ * Creates a new random GUID - used to populate state and nonce.
8159
8775
  * @returns string (GUID)
8160
8776
  */
8161
8777
  CryptoOps.prototype.createNewGuid = function () {
@@ -8191,7 +8807,7 @@ var CryptoOps = /** @class */ (function () {
8191
8807
  */
8192
8808
  CryptoOps.prototype.getPublicKeyThumbprint = function (request) {
8193
8809
  return __awaiter$1(this, void 0, void 0, function () {
8194
- var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkBuffer, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
8810
+ var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
8195
8811
  return __generator$1(this, function (_a) {
8196
8812
  switch (_a.label) {
8197
8813
  case 0: return [4 /*yield*/, this.browserCrypto.generateKeyPair(CryptoOps.EXTRACTABLE, CryptoOps.POP_KEY_USAGES)];
@@ -8206,10 +8822,9 @@ var CryptoOps = /** @class */ (function () {
8206
8822
  n: publicKeyJwk.n
8207
8823
  };
8208
8824
  publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
8209
- return [4 /*yield*/, this.browserCrypto.sha256Digest(publicJwkString)];
8825
+ return [4 /*yield*/, this.hashString(publicJwkString)];
8210
8826
  case 3:
8211
- publicJwkBuffer = _a.sent();
8212
- publicJwkHash = this.b64Encode.urlEncodeArr(new Uint8Array(publicJwkBuffer));
8827
+ publicJwkHash = _a.sent();
8213
8828
  return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.privateKey)];
8214
8829
  case 4:
8215
8830
  privateKeyJwk = _a.sent();
@@ -8217,7 +8832,7 @@ var CryptoOps = /** @class */ (function () {
8217
8832
  case 5:
8218
8833
  unextractablePrivateKey = _a.sent();
8219
8834
  // Store Keypair data in keystore
8220
- return [4 /*yield*/, this.cache.put(publicJwkHash, {
8835
+ return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
8221
8836
  privateKey: unextractablePrivateKey,
8222
8837
  publicKey: keyPair.publicKey,
8223
8838
  requestMethod: request.resourceRequestMethod,
@@ -8237,8 +8852,17 @@ var CryptoOps = /** @class */ (function () {
8237
8852
  */
8238
8853
  CryptoOps.prototype.removeTokenBindingKey = function (kid) {
8239
8854
  return __awaiter$1(this, void 0, void 0, function () {
8855
+ var keyFound;
8240
8856
  return __generator$1(this, function (_a) {
8241
- return [2 /*return*/, this.cache.delete(kid)];
8857
+ switch (_a.label) {
8858
+ case 0: return [4 /*yield*/, this.cache.asymmetricKeys.removeItem(kid)];
8859
+ case 1:
8860
+ _a.sent();
8861
+ return [4 /*yield*/, this.cache.asymmetricKeys.containsKey(kid)];
8862
+ case 2:
8863
+ keyFound = _a.sent();
8864
+ return [2 /*return*/, !keyFound];
8865
+ }
8242
8866
  });
8243
8867
  });
8244
8868
  };
@@ -8247,8 +8871,22 @@ var CryptoOps = /** @class */ (function () {
8247
8871
  */
8248
8872
  CryptoOps.prototype.clearKeystore = function () {
8249
8873
  return __awaiter$1(this, void 0, void 0, function () {
8250
- return __generator$1(this, function (_a) {
8251
- return [2 /*return*/, this.cache.clear()];
8874
+ var dataStoreNames, databaseStorage, _a;
8875
+ return __generator$1(this, function (_b) {
8876
+ switch (_b.label) {
8877
+ case 0:
8878
+ dataStoreNames = Object.keys(this.cache);
8879
+ databaseStorage = this.cache[dataStoreNames[0]];
8880
+ if (!databaseStorage) return [3 /*break*/, 2];
8881
+ return [4 /*yield*/, databaseStorage.deleteDatabase()];
8882
+ case 1:
8883
+ _a = _b.sent();
8884
+ return [3 /*break*/, 3];
8885
+ case 2:
8886
+ _a = false;
8887
+ _b.label = 3;
8888
+ case 3: return [2 /*return*/, _a];
8889
+ }
8252
8890
  });
8253
8891
  });
8254
8892
  };
@@ -8262,7 +8900,7 @@ var CryptoOps = /** @class */ (function () {
8262
8900
  var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
8263
8901
  return __generator$1(this, function (_a) {
8264
8902
  switch (_a.label) {
8265
- case 0: return [4 /*yield*/, this.cache.get(kid)];
8903
+ case 0: return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
8266
8904
  case 1:
8267
8905
  cachedKeyPair = _a.sent();
8268
8906
  if (!cachedKeyPair) {
@@ -8293,11 +8931,26 @@ var CryptoOps = /** @class */ (function () {
8293
8931
  });
8294
8932
  });
8295
8933
  };
8934
+ /**
8935
+ * Returns the SHA-256 hash of an input string
8936
+ * @param plainText
8937
+ */
8938
+ CryptoOps.prototype.hashString = function (plainText) {
8939
+ return __awaiter$1(this, void 0, void 0, function () {
8940
+ var hashBuffer, hashBytes;
8941
+ return __generator$1(this, function (_a) {
8942
+ switch (_a.label) {
8943
+ case 0: return [4 /*yield*/, this.browserCrypto.sha256Digest(plainText)];
8944
+ case 1:
8945
+ hashBuffer = _a.sent();
8946
+ hashBytes = new Uint8Array(hashBuffer);
8947
+ return [2 /*return*/, this.b64Encode.urlEncodeArr(hashBytes)];
8948
+ }
8949
+ });
8950
+ });
8951
+ };
8296
8952
  CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
8297
8953
  CryptoOps.EXTRACTABLE = true;
8298
- CryptoOps.DB_VERSION = 1;
8299
- CryptoOps.DB_NAME = "msal.db";
8300
- CryptoOps.TABLE_NAME = CryptoOps.DB_NAME + ".keys";
8301
8954
  return CryptoOps;
8302
8955
  }());
8303
8956
 
@@ -8427,39 +9080,6 @@ var BrowserStorage = /** @class */ (function () {
8427
9080
  return BrowserStorage;
8428
9081
  }());
8429
9082
 
8430
- /*
8431
- * Copyright (c) Microsoft Corporation. All rights reserved.
8432
- * Licensed under the MIT License.
8433
- */
8434
- var MemoryStorage = /** @class */ (function () {
8435
- function MemoryStorage() {
8436
- this.cache = new Map();
8437
- }
8438
- MemoryStorage.prototype.getItem = function (key) {
8439
- return this.cache.get(key) || null;
8440
- };
8441
- MemoryStorage.prototype.setItem = function (key, value) {
8442
- this.cache.set(key, value);
8443
- };
8444
- MemoryStorage.prototype.removeItem = function (key) {
8445
- this.cache.delete(key);
8446
- };
8447
- MemoryStorage.prototype.getKeys = function () {
8448
- var cacheKeys = [];
8449
- this.cache.forEach(function (value, key) {
8450
- cacheKeys.push(key);
8451
- });
8452
- return cacheKeys;
8453
- };
8454
- MemoryStorage.prototype.containsKey = function (key) {
8455
- return this.cache.has(key);
8456
- };
8457
- MemoryStorage.prototype.clear = function () {
8458
- this.cache.clear();
8459
- };
8460
- return MemoryStorage;
8461
- }());
8462
-
8463
9083
  /*
8464
9084
  * Copyright (c) Microsoft Corporation. All rights reserved.
8465
9085
  * Licensed under the MIT License.
@@ -9118,7 +9738,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9118
9738
  */
9119
9739
  BrowserCacheManager.prototype.generateAuthorityKey = function (stateString) {
9120
9740
  var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
9121
- return this.generateCacheKey(TemporaryCacheKeys.AUTHORITY + "." + stateId);
9741
+ return this.generateCacheKey(exports.TemporaryCacheKeys.AUTHORITY + "." + stateId);
9122
9742
  };
9123
9743
  /**
9124
9744
  * Create Nonce key to cache nonce
@@ -9126,7 +9746,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9126
9746
  */
9127
9747
  BrowserCacheManager.prototype.generateNonceKey = function (stateString) {
9128
9748
  var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
9129
- return this.generateCacheKey(TemporaryCacheKeys.NONCE_IDTOKEN + "." + stateId);
9749
+ return this.generateCacheKey(exports.TemporaryCacheKeys.NONCE_IDTOKEN + "." + stateId);
9130
9750
  };
9131
9751
  /**
9132
9752
  * Creates full cache key for the request state
@@ -9135,7 +9755,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9135
9755
  BrowserCacheManager.prototype.generateStateKey = function (stateString) {
9136
9756
  // Use the library state id to key temp storage for uniqueness for multiple concurrent requests
9137
9757
  var stateId = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString).libraryState.id;
9138
- return this.generateCacheKey(TemporaryCacheKeys.REQUEST_STATE + "." + stateId);
9758
+ return this.generateCacheKey(exports.TemporaryCacheKeys.REQUEST_STATE + "." + stateId);
9139
9759
  };
9140
9760
  /**
9141
9761
  * Gets the cached authority based on the cached state. Returns empty if no cached state found.
@@ -9170,14 +9790,14 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9170
9790
  credential: account.homeAccountId,
9171
9791
  type: CcsCredentialType.HOME_ACCOUNT_ID
9172
9792
  };
9173
- this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
9793
+ this.setTemporaryCache(exports.TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
9174
9794
  }
9175
9795
  else if (!StringUtils.isEmpty(loginHint)) {
9176
9796
  var ccsCredential = {
9177
9797
  credential: loginHint,
9178
9798
  type: CcsCredentialType.UPN
9179
9799
  };
9180
- this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
9800
+ this.setTemporaryCache(exports.TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);
9181
9801
  }
9182
9802
  };
9183
9803
  /**
@@ -9201,11 +9821,11 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9201
9821
  this.removeItem(this.generateNonceKey(state));
9202
9822
  this.removeItem(this.generateAuthorityKey(state));
9203
9823
  }
9204
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
9205
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));
9206
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));
9207
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID));
9208
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL));
9824
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.REQUEST_PARAMS));
9825
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.ORIGIN_URI));
9826
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.URL_HASH));
9827
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.CORRELATION_ID));
9828
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.CCS_CREDENTIAL));
9209
9829
  this.setInteractionInProgress(false);
9210
9830
  };
9211
9831
  /**
@@ -9234,7 +9854,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9234
9854
  // Loop through all keys to find state key
9235
9855
  this.getKeys().forEach(function (key) {
9236
9856
  // If this key is not the state key, move on
9237
- if (key.indexOf(TemporaryCacheKeys.REQUEST_STATE) === -1) {
9857
+ if (key.indexOf(exports.TemporaryCacheKeys.REQUEST_STATE) === -1) {
9238
9858
  return;
9239
9859
  }
9240
9860
  // Retrieve state value, return if not a valid value
@@ -9250,11 +9870,12 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9250
9870
  }
9251
9871
  });
9252
9872
  this.clearMsalCookies();
9873
+ this.setInteractionInProgress(false);
9253
9874
  };
9254
9875
  BrowserCacheManager.prototype.cacheCodeRequest = function (authCodeRequest, browserCrypto) {
9255
9876
  this.logger.trace("BrowserCacheManager.cacheCodeRequest called");
9256
9877
  var encodedValue = browserCrypto.base64Encode(JSON.stringify(authCodeRequest));
9257
- this.setTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, encodedValue, true);
9878
+ this.setTemporaryCache(exports.TemporaryCacheKeys.REQUEST_PARAMS, encodedValue, true);
9258
9879
  };
9259
9880
  /**
9260
9881
  * Gets the token exchange parameters from the cache. Throws an error if nothing is found.
@@ -9262,7 +9883,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9262
9883
  BrowserCacheManager.prototype.getCachedRequest = function (state, browserCrypto) {
9263
9884
  this.logger.trace("BrowserCacheManager.getCachedRequest called");
9264
9885
  // Get token request from cache and parse as TokenExchangeParameters.
9265
- var encodedTokenRequest = this.getTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, true);
9886
+ var encodedTokenRequest = this.getTemporaryCache(exports.TemporaryCacheKeys.REQUEST_PARAMS, true);
9266
9887
  if (!encodedTokenRequest) {
9267
9888
  throw BrowserAuthError.createNoTokenRequestCacheError();
9268
9889
  }
@@ -9270,7 +9891,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9270
9891
  if (!parsedRequest) {
9271
9892
  throw BrowserAuthError.createUnableToParseTokenRequestCacheError();
9272
9893
  }
9273
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));
9894
+ this.removeItem(this.generateCacheKey(exports.TemporaryCacheKeys.REQUEST_PARAMS));
9274
9895
  // Get cached authority and use if no authority is cached with request.
9275
9896
  if (StringUtils.isEmpty(parsedRequest.authority)) {
9276
9897
  var authorityCacheKey = this.generateAuthorityKey(state);
@@ -9292,18 +9913,22 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9292
9913
  }
9293
9914
  };
9294
9915
  BrowserCacheManager.prototype.getInteractionInProgress = function () {
9295
- var key = Constants.CACHE_PREFIX + "." + TemporaryCacheKeys.INTERACTION_STATUS_KEY;
9916
+ var key = Constants.CACHE_PREFIX + "." + exports.TemporaryCacheKeys.INTERACTION_STATUS_KEY;
9296
9917
  return this.getTemporaryCache(key, false);
9297
9918
  };
9298
9919
  BrowserCacheManager.prototype.setInteractionInProgress = function (inProgress) {
9299
- var clientId = this.getInteractionInProgress();
9300
9920
  // Ensure we don't overwrite interaction in progress for a different clientId
9301
- var key = Constants.CACHE_PREFIX + "." + TemporaryCacheKeys.INTERACTION_STATUS_KEY;
9302
- if (inProgress && !clientId) {
9303
- // No interaction is in progress
9304
- this.setTemporaryCache(key, this.clientId, false);
9921
+ var key = Constants.CACHE_PREFIX + "." + exports.TemporaryCacheKeys.INTERACTION_STATUS_KEY;
9922
+ if (inProgress) {
9923
+ if (this.getInteractionInProgress()) {
9924
+ throw BrowserAuthError.createInteractionInProgressError();
9925
+ }
9926
+ else {
9927
+ // No interaction is in progress
9928
+ this.setTemporaryCache(key, this.clientId, false);
9929
+ }
9305
9930
  }
9306
- else if (!inProgress && clientId === this.clientId) {
9931
+ else if (!inProgress && this.getInteractionInProgress() === this.clientId) {
9307
9932
  this.removeItem(key);
9308
9933
  }
9309
9934
  };
@@ -9340,6 +9965,25 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9340
9965
  }
9341
9966
  return null;
9342
9967
  };
9968
+ /**
9969
+ * Updates a credential's cache key if the current cache key is outdated
9970
+ */
9971
+ BrowserCacheManager.prototype.updateCredentialCacheKey = function (currentCacheKey, credential) {
9972
+ var updatedCacheKey = credential.generateCredentialKey();
9973
+ if (currentCacheKey !== updatedCacheKey) {
9974
+ var cacheItem = this.getItem(currentCacheKey);
9975
+ if (cacheItem) {
9976
+ this.removeItem(currentCacheKey);
9977
+ this.setItem(updatedCacheKey, cacheItem);
9978
+ this.logger.verbose("Updated an outdated " + credential.credentialType + " cache key");
9979
+ return updatedCacheKey;
9980
+ }
9981
+ else {
9982
+ this.logger.error("Attempted to update an outdated " + credential.credentialType + " cache key but no item matching the outdated key was found in storage");
9983
+ }
9984
+ }
9985
+ return currentCacheKey;
9986
+ };
9343
9987
  return BrowserCacheManager;
9344
9988
  }(CacheManager));
9345
9989
  var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
@@ -9811,7 +10455,11 @@ function buildConfiguration(_a, isBrowserEnvironment) {
9811
10455
  postLogoutRedirectUri: "",
9812
10456
  navigateToLoginRequestUrl: true,
9813
10457
  clientCapabilities: [],
9814
- protocolMode: exports.ProtocolMode.AAD
10458
+ protocolMode: exports.ProtocolMode.AAD,
10459
+ azureCloudOptions: {
10460
+ azureCloudInstance: exports.AzureCloudInstance.None,
10461
+ tenant: ""
10462
+ },
9815
10463
  };
9816
10464
  // Default cache options for browser
9817
10465
  var DEFAULT_CACHE_OPTIONS = {
@@ -9840,7 +10488,7 @@ function buildConfiguration(_a, isBrowserEnvironment) {
9840
10488
 
9841
10489
  /* eslint-disable header/header */
9842
10490
  var name = "@azure/msal-browser";
9843
- var version = "2.18.0";
10491
+ var version = "2.22.0";
9844
10492
 
9845
10493
  /*
9846
10494
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9860,6 +10508,9 @@ exports.EventType = void 0;
9860
10508
  EventType["SSO_SILENT_START"] = "msal:ssoSilentStart";
9861
10509
  EventType["SSO_SILENT_SUCCESS"] = "msal:ssoSilentSuccess";
9862
10510
  EventType["SSO_SILENT_FAILURE"] = "msal:ssoSilentFailure";
10511
+ EventType["ACQUIRE_TOKEN_BY_CODE_START"] = "msal:acquireTokenByCodeStart";
10512
+ EventType["ACQUIRE_TOKEN_BY_CODE_SUCCESS"] = "msal:acquireTokenByCodeSuccess";
10513
+ EventType["ACQUIRE_TOKEN_BY_CODE_FAILURE"] = "msal:acquireTokenByCodeFailure";
9863
10514
  EventType["HANDLE_REDIRECT_START"] = "msal:handleRedirectStart";
9864
10515
  EventType["HANDLE_REDIRECT_END"] = "msal:handleRedirectEnd";
9865
10516
  EventType["POPUP_OPENED"] = "msal:popupOpened";
@@ -10054,20 +10705,43 @@ var BaseInteractionClient = /** @class */ (function () {
10054
10705
  * @param request
10055
10706
  */
10056
10707
  BaseInteractionClient.prototype.initializeBaseRequest = function (request) {
10057
- this.logger.verbose("Initializing BaseAuthRequest");
10058
- var authority = request.authority || this.config.auth.authority;
10059
- var scopes = __spread(((request && request.scopes) || []));
10060
- // Set authenticationScheme to BEARER if not explicitly set in the request
10061
- if (!request.authenticationScheme) {
10062
- request.authenticationScheme = exports.AuthenticationScheme.BEARER;
10063
- this.logger.verbose("Authentication Scheme wasn't explicitly set in request, defaulting to \"Bearer\" request");
10064
- }
10065
- else {
10066
- this.logger.verbose("Authentication Scheme set to \"" + request.authenticationScheme + "\" as configured in Auth request");
10067
- }
10068
- var validatedRequest = __assign$1(__assign$1({}, request), { correlationId: this.correlationId, authority: authority,
10069
- scopes: scopes });
10070
- return validatedRequest;
10708
+ return __awaiter$1(this, void 0, void 0, function () {
10709
+ var authority, scopes, _a, validatedRequest;
10710
+ return __generator$1(this, function (_b) {
10711
+ switch (_b.label) {
10712
+ case 0:
10713
+ this.logger.verbose("Initializing BaseAuthRequest");
10714
+ authority = request.authority || this.config.auth.authority;
10715
+ scopes = __spread(((request && request.scopes) || []));
10716
+ // Set authenticationScheme to BEARER if not explicitly set in the request
10717
+ if (!request.authenticationScheme) {
10718
+ request.authenticationScheme = exports.AuthenticationScheme.BEARER;
10719
+ this.logger.verbose("Authentication Scheme wasn't explicitly set in request, defaulting to \"Bearer\" request");
10720
+ }
10721
+ else {
10722
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
10723
+ if (!request.sshJwk) {
10724
+ throw ClientConfigurationError.createMissingSshJwkError();
10725
+ }
10726
+ if (!request.sshKid) {
10727
+ throw ClientConfigurationError.createMissingSshKidError();
10728
+ }
10729
+ }
10730
+ this.logger.verbose("Authentication Scheme set to \"" + request.authenticationScheme + "\" as configured in Auth request");
10731
+ }
10732
+ if (!(request.claims && !StringUtils.isEmpty(request.claims))) return [3 /*break*/, 2];
10733
+ _a = request;
10734
+ return [4 /*yield*/, this.browserCrypto.hashString(request.claims)];
10735
+ case 1:
10736
+ _a.requestedClaimsHash = _b.sent();
10737
+ _b.label = 2;
10738
+ case 2:
10739
+ validatedRequest = __assign$1(__assign$1({}, request), { correlationId: this.correlationId, authority: authority,
10740
+ scopes: scopes });
10741
+ return [2 /*return*/, validatedRequest];
10742
+ }
10743
+ });
10744
+ });
10071
10745
  };
10072
10746
  /**
10073
10747
  *
@@ -10144,11 +10818,32 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10144
10818
  */
10145
10819
  StandardInteractionClient.prototype.initializeLogoutRequest = function (logoutRequest) {
10146
10820
  this.logger.verbose("initializeLogoutRequest called", logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
10147
- // Check if interaction is in progress. Throw error if true.
10148
- if (this.browserStorage.isInteractionInProgress()) {
10149
- throw BrowserAuthError.createInteractionInProgressError();
10821
+ var validLogoutRequest = __assign$1({ correlationId: this.browserCrypto.createNewGuid() }, logoutRequest);
10822
+ /**
10823
+ * Set logout_hint to be login_hint from ID Token Claims if present
10824
+ * and logoutHint attribute wasn't manually set in logout request
10825
+ */
10826
+ if (logoutRequest) {
10827
+ // If logoutHint isn't set and an account was passed in, try to extract logoutHint from ID Token Claims
10828
+ if (!logoutRequest.logoutHint) {
10829
+ if (logoutRequest.account) {
10830
+ var logoutHint = this.getLogoutHintFromIdTokenClaims(logoutRequest.account);
10831
+ if (logoutHint) {
10832
+ this.logger.verbose("Setting logoutHint to login_hint ID Token Claim value for the account provided");
10833
+ validLogoutRequest.logoutHint = logoutHint;
10834
+ }
10835
+ }
10836
+ else {
10837
+ this.logger.verbose("logoutHint was not set and account was not passed into logout request, logoutHint will not be set");
10838
+ }
10839
+ }
10840
+ else {
10841
+ this.logger.verbose("logoutHint has already been set in logoutRequest");
10842
+ }
10843
+ }
10844
+ else {
10845
+ this.logger.verbose("logoutHint will not be set since no logout request was configured");
10150
10846
  }
10151
- var validLogoutRequest = __assign$1({ correlationId: this.browserCrypto.createNewGuid() }, logoutRequest);
10152
10847
  /*
10153
10848
  * Only set redirect uri if logout request isn't provided or the set uri isn't null.
10154
10849
  * Otherwise, use passed uri, config, or current page.
@@ -10175,17 +10870,37 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10175
10870
  }
10176
10871
  return validLogoutRequest;
10177
10872
  };
10873
+ /**
10874
+ * Parses login_hint ID Token Claim out of AccountInfo object to be used as
10875
+ * logout_hint in end session request.
10876
+ * @param account
10877
+ */
10878
+ StandardInteractionClient.prototype.getLogoutHintFromIdTokenClaims = function (account) {
10879
+ var idTokenClaims = account.idTokenClaims;
10880
+ if (idTokenClaims) {
10881
+ if (idTokenClaims.login_hint) {
10882
+ return idTokenClaims.login_hint;
10883
+ }
10884
+ else {
10885
+ this.logger.verbose("The ID Token Claims tied to the provided account do not contain a login_hint claim, logoutHint will not be added to logout request");
10886
+ }
10887
+ }
10888
+ else {
10889
+ this.logger.verbose("The provided account does not contain ID Token Claims, logoutHint will not be added to logout request");
10890
+ }
10891
+ return null;
10892
+ };
10178
10893
  /**
10179
10894
  * Creates an Authorization Code Client with the given authority, or the default authority.
10180
10895
  * @param serverTelemetryManager
10181
10896
  * @param authorityUrl
10182
10897
  */
10183
- StandardInteractionClient.prototype.createAuthCodeClient = function (serverTelemetryManager, authorityUrl) {
10898
+ StandardInteractionClient.prototype.createAuthCodeClient = function (serverTelemetryManager, authorityUrl, requestAzureCloudOptions) {
10184
10899
  return __awaiter$1(this, void 0, void 0, function () {
10185
10900
  var clientConfig;
10186
10901
  return __generator$1(this, function (_a) {
10187
10902
  switch (_a.label) {
10188
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
10903
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, requestAzureCloudOptions)];
10189
10904
  case 1:
10190
10905
  clientConfig = _a.sent();
10191
10906
  return [2 /*return*/, new AuthorizationCodeClient(clientConfig)];
@@ -10199,14 +10914,14 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10199
10914
  * @param requestAuthority
10200
10915
  * @param requestCorrelationId
10201
10916
  */
10202
- StandardInteractionClient.prototype.getClientConfiguration = function (serverTelemetryManager, requestAuthority) {
10917
+ StandardInteractionClient.prototype.getClientConfiguration = function (serverTelemetryManager, requestAuthority, requestAzureCloudOptions) {
10203
10918
  return __awaiter$1(this, void 0, void 0, function () {
10204
10919
  var discoveredAuthority;
10205
10920
  return __generator$1(this, function (_a) {
10206
10921
  switch (_a.label) {
10207
10922
  case 0:
10208
10923
  this.logger.verbose("getClientConfiguration called");
10209
- return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority)];
10924
+ return [4 /*yield*/, this.getDiscoveredAuthority(requestAuthority, requestAzureCloudOptions)];
10210
10925
  case 1:
10211
10926
  discoveredAuthority = _a.sent();
10212
10927
  return [2 /*return*/, {
@@ -10266,9 +10981,9 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10266
10981
  * @param requestAuthority
10267
10982
  * @param requestCorrelationId
10268
10983
  */
10269
- StandardInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority) {
10984
+ StandardInteractionClient.prototype.getDiscoveredAuthority = function (requestAuthority, requestAzureCloudOptions) {
10270
10985
  return __awaiter$1(this, void 0, void 0, function () {
10271
- var authorityOptions;
10986
+ var authorityOptions, userAuthority, builtAuthority;
10272
10987
  return __generator$1(this, function (_a) {
10273
10988
  switch (_a.label) {
10274
10989
  case 0:
@@ -10277,63 +10992,55 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10277
10992
  protocolMode: this.config.auth.protocolMode,
10278
10993
  knownAuthorities: this.config.auth.knownAuthorities,
10279
10994
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
10280
- authorityMetadata: this.config.auth.authorityMetadata
10995
+ authorityMetadata: this.config.auth.authorityMetadata,
10281
10996
  };
10282
- if (!requestAuthority) return [3 /*break*/, 2];
10283
- this.logger.verbose("Creating discovered authority with request authority");
10284
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(requestAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
10285
- case 1: return [2 /*return*/, _a.sent()];
10286
- case 2:
10997
+ userAuthority = requestAuthority ? requestAuthority : this.config.auth.authority;
10998
+ builtAuthority = Authority.generateAuthority(userAuthority, requestAzureCloudOptions || this.config.auth.azureCloudOptions);
10287
10999
  this.logger.verbose("Creating discovered authority with configured authority");
10288
- return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(this.config.auth.authority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
10289
- case 3: return [2 /*return*/, _a.sent()];
11000
+ return [4 /*yield*/, AuthorityFactory.createDiscoveredInstance(builtAuthority, this.config.system.networkClient, this.browserStorage, authorityOptions)];
11001
+ case 1: return [2 /*return*/, _a.sent()];
10290
11002
  }
10291
11003
  });
10292
11004
  });
10293
11005
  };
10294
- /**
10295
- * Helper to validate app environment before making a request.
10296
- * @param request
10297
- * @param interactionType
10298
- */
10299
- StandardInteractionClient.prototype.preflightInteractiveRequest = function (request, interactionType) {
10300
- this.logger.verbose("preflightInteractiveRequest called, validating app environment", request === null || request === void 0 ? void 0 : request.correlationId);
10301
- // block the reload if it occurred inside a hidden iframe
10302
- BrowserUtils.blockReloadInHiddenIframes();
10303
- // Check if interaction is in progress. Throw error if true.
10304
- if (this.browserStorage.isInteractionInProgress(false)) {
10305
- throw BrowserAuthError.createInteractionInProgressError();
10306
- }
10307
- return this.initializeAuthorizationRequest(request, interactionType);
10308
- };
10309
11006
  /**
10310
11007
  * Helper to initialize required request parameters for interactive APIs and ssoSilent()
10311
11008
  * @param request
10312
11009
  * @param interactionType
10313
11010
  */
10314
11011
  StandardInteractionClient.prototype.initializeAuthorizationRequest = function (request, interactionType) {
10315
- this.logger.verbose("initializeAuthorizationRequest called");
10316
- var redirectUri = this.getRedirectUri(request.redirectUri);
10317
- var browserState = {
10318
- interactionType: interactionType
10319
- };
10320
- var state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || "", browserState);
10321
- var validatedRequest = __assign$1(__assign$1({}, this.initializeBaseRequest(request)), { redirectUri: redirectUri, state: state, nonce: request.nonce || this.browserCrypto.createNewGuid(), responseMode: ResponseMode.FRAGMENT });
10322
- var account = request.account || this.browserStorage.getActiveAccount();
10323
- if (account) {
10324
- this.logger.verbose("Setting validated request account");
10325
- this.logger.verbosePii("Setting validated request account: " + account);
10326
- validatedRequest.account = account;
10327
- }
10328
- // Check for ADAL/MSAL v1 SSO
10329
- if (StringUtils.isEmpty(validatedRequest.loginHint) && !account) {
10330
- var legacyLoginHint = this.browserStorage.getLegacyLoginHint();
10331
- if (legacyLoginHint) {
10332
- validatedRequest.loginHint = legacyLoginHint;
10333
- }
10334
- }
10335
- this.browserStorage.updateCacheEntries(validatedRequest.state, validatedRequest.nonce, validatedRequest.authority, validatedRequest.loginHint || "", validatedRequest.account || null);
10336
- return validatedRequest;
11012
+ return __awaiter$1(this, void 0, void 0, function () {
11013
+ var redirectUri, browserState, state, validatedRequest, _a, account, legacyLoginHint;
11014
+ return __generator$1(this, function (_b) {
11015
+ switch (_b.label) {
11016
+ case 0:
11017
+ this.logger.verbose("initializeAuthorizationRequest called");
11018
+ redirectUri = this.getRedirectUri(request.redirectUri);
11019
+ browserState = {
11020
+ interactionType: interactionType
11021
+ };
11022
+ state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || Constants.EMPTY_STRING, browserState);
11023
+ _a = [{}];
11024
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
11025
+ case 1:
11026
+ validatedRequest = __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { redirectUri: redirectUri, state: state, nonce: request.nonce || this.browserCrypto.createNewGuid(), responseMode: ResponseMode.FRAGMENT }]);
11027
+ account = request.account || this.browserStorage.getActiveAccount();
11028
+ if (account) {
11029
+ this.logger.verbose("Setting validated request account");
11030
+ this.logger.verbosePii("Setting validated request account: " + account);
11031
+ validatedRequest.account = account;
11032
+ }
11033
+ // Check for ADAL/MSAL v1 SSO
11034
+ if (StringUtils.isEmpty(validatedRequest.loginHint) && !account) {
11035
+ legacyLoginHint = this.browserStorage.getLegacyLoginHint();
11036
+ if (legacyLoginHint) {
11037
+ validatedRequest.loginHint = legacyLoginHint;
11038
+ }
11039
+ }
11040
+ return [2 /*return*/, validatedRequest];
11041
+ }
11042
+ });
11043
+ });
10337
11044
  };
10338
11045
  return StandardInteractionClient;
10339
11046
  }(BaseInteractionClient));
@@ -10500,8 +11207,8 @@ var PopupUtils = /** @class */ (function () {
10500
11207
  * @param clientId
10501
11208
  * @param request
10502
11209
  */
10503
- PopupUtils.generatePopupName = function (clientId, request) {
10504
- return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + request.scopes.join("-") + "." + request.authority + "." + request.correlationId;
11210
+ PopupUtils.generatePopupName = function (clientId, scopes, authority, correlationId) {
11211
+ return BrowserConstants.POPUP_NAME_PREFIX + "." + clientId + "." + scopes.join("-") + "." + authority + "." + correlationId;
10505
11212
  };
10506
11213
  /**
10507
11214
  * Generates the name for the popup based on the client id and request for logouts
@@ -10533,23 +11240,46 @@ var InteractionHandler = /** @class */ (function () {
10533
11240
  * Function to handle response parameters from hash.
10534
11241
  * @param locationHash
10535
11242
  */
10536
- InteractionHandler.prototype.handleCodeResponse = function (locationHash, state, authority, networkModule) {
11243
+ InteractionHandler.prototype.handleCodeResponseFromHash = function (locationHash, state, authority, networkModule) {
10537
11244
  return __awaiter$1(this, void 0, void 0, function () {
10538
- var stateKey, requestState, authCodeResponse, nonceKey, cachedNonce, cachedCcsCred, tokenResponse;
11245
+ var stateKey, requestState, authCodeResponse;
11246
+ return __generator$1(this, function (_a) {
11247
+ this.browserRequestLogger.verbose("InteractionHandler.handleCodeResponse called");
11248
+ // Check that location hash isn't empty.
11249
+ if (StringUtils.isEmpty(locationHash)) {
11250
+ throw BrowserAuthError.createEmptyHashError(locationHash);
11251
+ }
11252
+ stateKey = this.browserStorage.generateStateKey(state);
11253
+ requestState = this.browserStorage.getTemporaryCache(stateKey);
11254
+ if (!requestState) {
11255
+ throw ClientAuthError.createStateNotFoundError("Cached State");
11256
+ }
11257
+ authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);
11258
+ return [2 /*return*/, this.handleCodeResponseFromServer(authCodeResponse, state, authority, networkModule)];
11259
+ });
11260
+ });
11261
+ };
11262
+ /**
11263
+ * Process auth code response from AAD
11264
+ * @param authCodeResponse
11265
+ * @param state
11266
+ * @param authority
11267
+ * @param networkModule
11268
+ * @returns
11269
+ */
11270
+ InteractionHandler.prototype.handleCodeResponseFromServer = function (authCodeResponse, state, authority, networkModule, validateNonce) {
11271
+ if (validateNonce === void 0) { validateNonce = true; }
11272
+ return __awaiter$1(this, void 0, void 0, function () {
11273
+ var stateKey, requestState, nonceKey, cachedNonce, cachedCcsCred, tokenResponse;
10539
11274
  return __generator$1(this, function (_a) {
10540
11275
  switch (_a.label) {
10541
11276
  case 0:
10542
- this.browserRequestLogger.verbose("InteractionHandler.handleCodeResponse called");
10543
- // Check that location hash isn't empty.
10544
- if (StringUtils.isEmpty(locationHash)) {
10545
- throw BrowserAuthError.createEmptyHashError(locationHash);
10546
- }
11277
+ this.browserRequestLogger.trace("InteractionHandler.handleCodeResponseFromServer called");
10547
11278
  stateKey = this.browserStorage.generateStateKey(state);
10548
11279
  requestState = this.browserStorage.getTemporaryCache(stateKey);
10549
11280
  if (!requestState) {
10550
11281
  throw ClientAuthError.createStateNotFoundError("Cached State");
10551
11282
  }
10552
- authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);
10553
11283
  nonceKey = this.browserStorage.generateNonceKey(requestState);
10554
11284
  cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);
10555
11285
  // Assign code to request
@@ -10560,7 +11290,10 @@ var InteractionHandler = /** @class */ (function () {
10560
11290
  _a.sent();
10561
11291
  _a.label = 2;
10562
11292
  case 2:
10563
- authCodeResponse.nonce = cachedNonce || undefined;
11293
+ // Nonce validation not needed when redirect not involved (e.g. hybrid spa, renewing token via rt)
11294
+ if (validateNonce) {
11295
+ authCodeResponse.nonce = cachedNonce || undefined;
11296
+ }
10564
11297
  authCodeResponse.state = requestState;
10565
11298
  // Add CCS parameters if available
10566
11299
  if (authCodeResponse.client_info) {
@@ -10608,7 +11341,7 @@ var InteractionHandler = /** @class */ (function () {
10608
11341
  */
10609
11342
  InteractionHandler.prototype.checkCcsCredentials = function () {
10610
11343
  // Look up ccs credential in temp cache
10611
- var cachedCcsCred = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, true);
11344
+ var cachedCcsCred = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.CCS_CREDENTIAL, true);
10612
11345
  if (cachedCcsCred) {
10613
11346
  try {
10614
11347
  return JSON.parse(cachedCcsCred);
@@ -10646,8 +11379,6 @@ var PopupHandler = /** @class */ (function (_super) {
10646
11379
  PopupHandler.prototype.initiateAuthRequest = function (requestUrl, params) {
10647
11380
  // Check that request url is not empty.
10648
11381
  if (!StringUtils.isEmpty(requestUrl)) {
10649
- // Set interaction status in the library.
10650
- this.browserStorage.setInteractionInProgress(true);
10651
11382
  this.browserRequestLogger.infoPii("Navigate to: " + requestUrl);
10652
11383
  // Open the popup window to requestUrl.
10653
11384
  return this.popupUtils.openPopup(requestUrl, params);
@@ -10698,20 +11429,19 @@ var PopupClient = /** @class */ (function (_super) {
10698
11429
  */
10699
11430
  PopupClient.prototype.acquireToken = function (request) {
10700
11431
  try {
10701
- var validRequest = this.preflightInteractiveRequest(request, exports.InteractionType.Popup);
10702
- var popupName = PopupUtils.generatePopupName(this.config.auth.clientId, validRequest);
11432
+ var popupName = PopupUtils.generatePopupName(this.config.auth.clientId, request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority, this.correlationId);
10703
11433
  var popupWindowAttributes = request.popupWindowAttributes || {};
10704
11434
  // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
10705
11435
  if (this.config.system.asyncPopups) {
10706
11436
  this.logger.verbose("asyncPopups set to true, acquiring token");
10707
11437
  // Passes on popup position and dimensions if in request
10708
- return this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes);
11438
+ return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes);
10709
11439
  }
10710
11440
  else {
10711
11441
  // asyncPopups flag is set to false. Opens popup before acquiring token.
10712
11442
  this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
10713
11443
  var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
10714
- return this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes, popup);
11444
+ return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
10715
11445
  }
10716
11446
  }
10717
11447
  catch (e) {
@@ -10757,26 +11487,30 @@ var PopupClient = /** @class */ (function (_super) {
10757
11487
  *
10758
11488
  * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
10759
11489
  */
10760
- PopupClient.prototype.acquireTokenPopupAsync = function (validRequest, popupName, popupWindowAttributes, popup) {
11490
+ PopupClient.prototype.acquireTokenPopupAsync = function (request, popupName, popupWindowAttributes, popup) {
10761
11491
  return __awaiter$1(this, void 0, void 0, function () {
10762
- var serverTelemetryManager, authCodeRequest, authClient, navigateUrl, interactionHandler, popupParameters, popupWindow, hash, state, result, e_1;
11492
+ var serverTelemetryManager, validRequest, authCodeRequest, authClient, navigateUrl, interactionHandler, popupParameters, popupWindow, hash, state, result, e_1;
10763
11493
  return __generator$1(this, function (_a) {
10764
11494
  switch (_a.label) {
10765
11495
  case 0:
10766
11496
  this.logger.verbose("acquireTokenPopupAsync called");
10767
11497
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenPopup);
10768
- _a.label = 1;
11498
+ return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Popup)];
10769
11499
  case 1:
10770
- _a.trys.push([1, 7, , 8]);
10771
- return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
11500
+ validRequest = _a.sent();
11501
+ this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || "", validRequest.account || null);
11502
+ _a.label = 2;
10772
11503
  case 2:
10773
- authCodeRequest = _a.sent();
10774
- return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority)];
11504
+ _a.trys.push([2, 8, , 9]);
11505
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
10775
11506
  case 3:
11507
+ authCodeRequest = _a.sent();
11508
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
11509
+ case 4:
10776
11510
  authClient = _a.sent();
10777
11511
  this.logger.verbose("Auth code client created");
10778
11512
  return [4 /*yield*/, authClient.getAuthCodeUrl(validRequest)];
10779
- case 4:
11513
+ case 5:
10780
11514
  navigateUrl = _a.sent();
10781
11515
  interactionHandler = new PopupHandler(authClient, this.browserStorage, authCodeRequest, this.logger);
10782
11516
  popupParameters = {
@@ -10787,16 +11521,16 @@ var PopupClient = /** @class */ (function (_super) {
10787
11521
  popupWindow = interactionHandler.initiateAuthRequest(navigateUrl, popupParameters);
10788
11522
  this.eventHandler.emitEvent(exports.EventType.POPUP_OPENED, exports.InteractionType.Popup, { popupWindow: popupWindow }, null);
10789
11523
  return [4 /*yield*/, interactionHandler.monitorPopupForHash(popupWindow)];
10790
- case 5:
11524
+ case 6:
10791
11525
  hash = _a.sent();
10792
11526
  state = this.validateAndExtractStateFromHash(hash, exports.InteractionType.Popup, validRequest.correlationId);
10793
11527
  // Remove throttle if it exists
10794
11528
  ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest);
10795
- return [4 /*yield*/, interactionHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient)];
10796
- case 6:
11529
+ return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
11530
+ case 7:
10797
11531
  result = _a.sent();
10798
11532
  return [2 /*return*/, result];
10799
- case 7:
11533
+ case 8:
10800
11534
  e_1 = _a.sent();
10801
11535
  if (popup) {
10802
11536
  // Close the synchronous popup if an error is thrown before the window unload event is registered
@@ -10808,7 +11542,7 @@ var PopupClient = /** @class */ (function (_super) {
10808
11542
  serverTelemetryManager.cacheFailedRequest(e_1);
10809
11543
  this.browserStorage.cleanRequestByState(validRequest.state);
10810
11544
  throw e_1;
10811
- case 8: return [2 /*return*/];
11545
+ case 9: return [2 /*return*/];
10812
11546
  }
10813
11547
  });
10814
11548
  });
@@ -10839,7 +11573,6 @@ var PopupClient = /** @class */ (function (_super) {
10839
11573
  case 2:
10840
11574
  // Clear cache on logout
10841
11575
  _a.sent();
10842
- this.browserStorage.setInteractionInProgress(true);
10843
11576
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, requestAuthority)];
10844
11577
  case 3:
10845
11578
  authClient = _a.sent();
@@ -10873,7 +11606,7 @@ var PopupClient = /** @class */ (function (_super) {
10873
11606
  };
10874
11607
  absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, BrowserUtils.getCurrentUri());
10875
11608
  this.logger.verbose("Redirecting main window to url specified in the request");
10876
- this.logger.verbosePii("Redirecing main window to: " + absoluteUrl);
11609
+ this.logger.verbosePii("Redirecting main window to: " + absoluteUrl);
10877
11610
  this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);
10878
11611
  }
10879
11612
  else {
@@ -10930,11 +11663,10 @@ var RedirectHandler = /** @class */ (function (_super) {
10930
11663
  // Cache start page, returns to this page after redirectUri if navigateToLoginRequestUrl is true
10931
11664
  if (params.redirectStartPage) {
10932
11665
  this.browserRequestLogger.verbose("RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page");
10933
- this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, params.redirectStartPage, true);
11666
+ this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.ORIGIN_URI, params.redirectStartPage, true);
10934
11667
  }
10935
11668
  // Set interaction status in the library.
10936
- this.browserStorage.setInteractionInProgress(true);
10937
- this.browserStorage.setTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, this.authCodeRequest.correlationId, true);
11669
+ this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.CORRELATION_ID, this.authCodeRequest.correlationId, true);
10938
11670
  this.browserStorage.cacheCodeRequest(this.authCodeRequest, this.browserCrypto);
10939
11671
  this.browserRequestLogger.infoPii("RedirectHandler.initiateAuthRequest: Navigate to: " + requestUrl);
10940
11672
  navigationOptions = {
@@ -10976,7 +11708,7 @@ var RedirectHandler = /** @class */ (function (_super) {
10976
11708
  * Handle authorization code response in the window.
10977
11709
  * @param hash
10978
11710
  */
10979
- RedirectHandler.prototype.handleCodeResponse = function (locationHash, state, authority, networkModule, clientId) {
11711
+ RedirectHandler.prototype.handleCodeResponseFromHash = function (locationHash, state, authority, networkModule, clientId) {
10980
11712
  return __awaiter$1(this, void 0, void 0, function () {
10981
11713
  var stateKey, requestState, authCodeResponse, nonceKey, cachedNonce, cachedCcsCred, tokenResponse;
10982
11714
  return __generator$1(this, function (_a) {
@@ -11051,22 +11783,24 @@ var RedirectClient = /** @class */ (function (_super) {
11051
11783
  var validRequest, serverTelemetryManager, authCodeRequest, authClient, interactionHandler, navigateUrl, redirectStartPage, e_1;
11052
11784
  return __generator$1(this, function (_a) {
11053
11785
  switch (_a.label) {
11054
- case 0:
11055
- validRequest = this.preflightInteractiveRequest(request, exports.InteractionType.Redirect);
11056
- serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenRedirect);
11057
- _a.label = 1;
11786
+ case 0: return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Redirect)];
11058
11787
  case 1:
11059
- _a.trys.push([1, 6, , 7]);
11060
- return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
11788
+ validRequest = _a.sent();
11789
+ this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || "", validRequest.account || null);
11790
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenRedirect);
11791
+ _a.label = 2;
11061
11792
  case 2:
11062
- authCodeRequest = _a.sent();
11063
- return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority)];
11793
+ _a.trys.push([2, 7, , 8]);
11794
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
11064
11795
  case 3:
11796
+ authCodeRequest = _a.sent();
11797
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
11798
+ case 4:
11065
11799
  authClient = _a.sent();
11066
11800
  this.logger.verbose("Auth code client created");
11067
11801
  interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);
11068
11802
  return [4 /*yield*/, authClient.getAuthCodeUrl(validRequest)];
11069
- case 4:
11803
+ case 5:
11070
11804
  navigateUrl = _a.sent();
11071
11805
  redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);
11072
11806
  this.logger.verbosePii("Redirect start page: " + redirectStartPage);
@@ -11076,10 +11810,10 @@ var RedirectClient = /** @class */ (function (_super) {
11076
11810
  redirectStartPage: redirectStartPage,
11077
11811
  onRedirectNavigate: request.onRedirectNavigate
11078
11812
  })];
11079
- case 5:
11813
+ case 6:
11080
11814
  // Show the UI once the url has been created. Response will come back in the hash, which will be handled in the handleRedirectCallback function.
11081
11815
  return [2 /*return*/, _a.sent()];
11082
- case 6:
11816
+ case 7:
11083
11817
  e_1 = _a.sent();
11084
11818
  if (e_1 instanceof AuthError) {
11085
11819
  e_1.setCorrelationId(this.correlationId);
@@ -11087,7 +11821,7 @@ var RedirectClient = /** @class */ (function (_super) {
11087
11821
  serverTelemetryManager.cacheFailedRequest(e_1);
11088
11822
  this.browserStorage.cleanRequestByState(validRequest.state);
11089
11823
  throw e_1;
11090
- case 7: return [2 /*return*/];
11824
+ case 8: return [2 /*return*/];
11091
11825
  }
11092
11826
  });
11093
11827
  });
@@ -11122,7 +11856,6 @@ var RedirectClient = /** @class */ (function (_super) {
11122
11856
  state = void 0;
11123
11857
  try {
11124
11858
  state = this.validateAndExtractStateFromHash(responseHash, exports.InteractionType.Redirect);
11125
- BrowserUtils.clearHash(window);
11126
11859
  this.logger.verbose("State extracted from hash");
11127
11860
  }
11128
11861
  catch (e) {
@@ -11130,7 +11863,7 @@ var RedirectClient = /** @class */ (function (_super) {
11130
11863
  this.browserStorage.cleanRequestByInteractionType(exports.InteractionType.Redirect);
11131
11864
  return [2 /*return*/, null];
11132
11865
  }
11133
- loginRequestUrl = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, true) || "";
11866
+ loginRequestUrl = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.ORIGIN_URI, true) || "";
11134
11867
  loginRequestUrlNormalized = UrlString.removeHashFromUrl(loginRequestUrl);
11135
11868
  currentUrlNormalized = UrlString.removeHashFromUrl(window.location.href);
11136
11869
  if (!(loginRequestUrlNormalized === currentUrlNormalized && this.config.auth.navigateToLoginRequestUrl)) return [3 /*break*/, 3];
@@ -11149,12 +11882,12 @@ var RedirectClient = /** @class */ (function (_super) {
11149
11882
  this.logger.verbose("NavigateToLoginRequestUrl set to false, handling hash");
11150
11883
  return [2 /*return*/, this.handleHash(responseHash, state, serverTelemetryManager)];
11151
11884
  case 4:
11152
- if (!!BrowserUtils.isInIframe()) return [3 /*break*/, 9];
11885
+ if (!(!BrowserUtils.isInIframe() || this.config.system.allowRedirectInIframe)) return [3 /*break*/, 9];
11153
11886
  /*
11154
11887
  * Returned from authority using redirect - need to perform navigation before processing response
11155
11888
  * Cache the hash to be retrieved after the next redirect
11156
11889
  */
11157
- this.browserStorage.setTemporaryCache(TemporaryCacheKeys.URL_HASH, responseHash, true);
11890
+ this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.URL_HASH, responseHash, true);
11158
11891
  navigationOptions = {
11159
11892
  apiId: exports.ApiId.handleRedirectPromise,
11160
11893
  timeout: this.config.system.redirectNavigationTimeout,
@@ -11164,7 +11897,7 @@ var RedirectClient = /** @class */ (function (_super) {
11164
11897
  if (!(!loginRequestUrl || loginRequestUrl === "null")) return [3 /*break*/, 6];
11165
11898
  homepage = BrowserUtils.getHomepage();
11166
11899
  // Cache the homepage under ORIGIN_URI to ensure cached hash is processed on homepage
11167
- this.browserStorage.setTemporaryCache(TemporaryCacheKeys.ORIGIN_URI, homepage, true);
11900
+ this.browserStorage.setTemporaryCache(exports.TemporaryCacheKeys.ORIGIN_URI, homepage, true);
11168
11901
  this.logger.warning("Unable to get valid login request url from cache, redirecting to home page");
11169
11902
  return [4 /*yield*/, this.navigationClient.navigateInternal(homepage, navigationOptions)];
11170
11903
  case 5:
@@ -11206,12 +11939,13 @@ var RedirectClient = /** @class */ (function (_super) {
11206
11939
  this.logger.verbose("getRedirectResponseHash called");
11207
11940
  // Get current location hash from window or cache.
11208
11941
  var isResponseHash = UrlString.hashContainsKnownProperties(hash);
11209
- var cachedHash = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.URL_HASH, true);
11210
- this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH));
11211
11942
  if (isResponseHash) {
11943
+ BrowserUtils.clearHash(window);
11212
11944
  this.logger.verbose("Hash contains known properties, returning response hash");
11213
11945
  return hash;
11214
11946
  }
11947
+ var cachedHash = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.URL_HASH, true);
11948
+ this.browserStorage.removeItem(this.browserStorage.generateCacheKey(exports.TemporaryCacheKeys.URL_HASH));
11215
11949
  this.logger.verbose("Hash does not contain known properties, returning cached hash");
11216
11950
  return cachedHash;
11217
11951
  };
@@ -11237,7 +11971,7 @@ var RedirectClient = /** @class */ (function (_super) {
11237
11971
  authClient = _a.sent();
11238
11972
  this.logger.verbose("Auth code client created");
11239
11973
  interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);
11240
- return [4 /*yield*/, interactionHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient, this.config.auth.clientId)];
11974
+ return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient, this.config.auth.clientId)];
11241
11975
  case 2: return [2 /*return*/, _a.sent()];
11242
11976
  }
11243
11977
  });
@@ -11503,24 +12237,27 @@ var SilentIframeClient = /** @class */ (function (_super) {
11503
12237
  if (request.prompt && request.prompt !== PromptValue.NONE) {
11504
12238
  throw BrowserAuthError.createSilentPromptValueError(request.prompt);
11505
12239
  }
11506
- silentRequest = this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent);
11507
- serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
11508
- _a.label = 1;
12240
+ return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent)];
11509
12241
  case 1:
11510
- _a.trys.push([1, 6, , 7]);
11511
- return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
12242
+ silentRequest = _a.sent();
12243
+ this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || "", silentRequest.account || null);
12244
+ serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
12245
+ _a.label = 2;
11512
12246
  case 2:
11513
- authCodeRequest = _a.sent();
11514
- return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority)];
12247
+ _a.trys.push([2, 7, , 8]);
12248
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
11515
12249
  case 3:
12250
+ authCodeRequest = _a.sent();
12251
+ return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12252
+ case 4:
11516
12253
  authClient = _a.sent();
11517
12254
  this.logger.verbose("Auth code client created");
11518
12255
  return [4 /*yield*/, authClient.getAuthCodeUrl(silentRequest)];
11519
- case 4:
12256
+ case 5:
11520
12257
  navigateUrl = _a.sent();
11521
12258
  return [4 /*yield*/, this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger)];
11522
- case 5: return [2 /*return*/, _a.sent()];
11523
- case 6:
12259
+ case 6: return [2 /*return*/, _a.sent()];
12260
+ case 7:
11524
12261
  e_1 = _a.sent();
11525
12262
  if (e_1 instanceof AuthError) {
11526
12263
  e_1.setCorrelationId(this.correlationId);
@@ -11528,7 +12265,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
11528
12265
  serverTelemetryManager.cacheFailedRequest(e_1);
11529
12266
  this.browserStorage.cleanRequestByState(silentRequest.state);
11530
12267
  throw e_1;
11531
- case 7: return [2 /*return*/];
12268
+ case 8: return [2 /*return*/];
11532
12269
  }
11533
12270
  });
11534
12271
  });
@@ -11561,7 +12298,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
11561
12298
  hash = _a.sent();
11562
12299
  state = this.validateAndExtractStateFromHash(hash, exports.InteractionType.Silent, authCodeRequest.correlationId);
11563
12300
  // Handle response from hash string
11564
- return [2 /*return*/, silentHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient)];
12301
+ return [2 /*return*/, silentHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
11565
12302
  }
11566
12303
  });
11567
12304
  });
@@ -11584,16 +12321,19 @@ var SilentRefreshClient = /** @class */ (function (_super) {
11584
12321
  */
11585
12322
  SilentRefreshClient.prototype.acquireToken = function (request) {
11586
12323
  return __awaiter$1(this, void 0, void 0, function () {
11587
- var silentRequest, serverTelemetryManager, refreshTokenClient;
12324
+ var silentRequest, _a, serverTelemetryManager, refreshTokenClient;
11588
12325
  var _this = this;
11589
- return __generator$1(this, function (_a) {
11590
- switch (_a.label) {
12326
+ return __generator$1(this, function (_b) {
12327
+ switch (_b.label) {
11591
12328
  case 0:
11592
- silentRequest = __assign$1(__assign$1({}, request), this.initializeBaseRequest(request));
11593
- serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
11594
- return [4 /*yield*/, this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority)];
12329
+ _a = [__assign$1({}, request)];
12330
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
11595
12331
  case 1:
11596
- refreshTokenClient = _a.sent();
12332
+ silentRequest = __assign$1.apply(void 0, _a.concat([_b.sent()]));
12333
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12334
+ return [4 /*yield*/, this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12335
+ case 2:
12336
+ refreshTokenClient = _b.sent();
11597
12337
  this.logger.verbose("Refresh token client created");
11598
12338
  // Send request to renew token. Auth module will throw errors if token cannot be renewed.
11599
12339
  return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest).catch(function (e) {
@@ -11619,12 +12359,12 @@ var SilentRefreshClient = /** @class */ (function (_super) {
11619
12359
  * @param serverTelemetryManager
11620
12360
  * @param authorityUrl
11621
12361
  */
11622
- SilentRefreshClient.prototype.createRefreshTokenClient = function (serverTelemetryManager, authorityUrl) {
12362
+ SilentRefreshClient.prototype.createRefreshTokenClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
11623
12363
  return __awaiter$1(this, void 0, void 0, function () {
11624
12364
  var clientConfig;
11625
12365
  return __generator$1(this, function (_a) {
11626
12366
  switch (_a.label) {
11627
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
12367
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
11628
12368
  case 1:
11629
12369
  clientConfig = _a.sent();
11630
12370
  return [2 /*return*/, new RefreshTokenClient(clientConfig)];
@@ -11667,13 +12407,14 @@ var TokenCache = /** @class */ (function () {
11667
12407
  this.loadAccessToken(request, response, request.account.homeAccountId, request.account.environment, request.account.tenantId, options);
11668
12408
  }
11669
12409
  else if (request.authority) {
12410
+ var authorityUrl = Authority.generateAuthority(request.authority, request.azureCloudOptions);
11670
12411
  var authorityOptions = {
11671
12412
  protocolMode: this.config.auth.protocolMode,
11672
12413
  knownAuthorities: this.config.auth.knownAuthorities,
11673
12414
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
11674
- authorityMetadata: this.config.auth.authorityMetadata
12415
+ authorityMetadata: this.config.auth.authorityMetadata,
11675
12416
  };
11676
- var authority = new Authority(request.authority, this.config.system.networkClient, this.storage, authorityOptions);
12417
+ var authority = new Authority(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
11677
12418
  // "clientInfo" from options takes precedence over "clientInfo" in response
11678
12419
  if (options.clientInfo) {
11679
12420
  this.logger.trace("TokenCache - homeAccountId from options");
@@ -11752,6 +12493,91 @@ var TokenCache = /** @class */ (function () {
11752
12493
  return TokenCache;
11753
12494
  }());
11754
12495
 
12496
+ /*
12497
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12498
+ * Licensed under the MIT License.
12499
+ */
12500
+ var HybridSpaAuthorizationCodeClient = /** @class */ (function (_super) {
12501
+ __extends$1(HybridSpaAuthorizationCodeClient, _super);
12502
+ function HybridSpaAuthorizationCodeClient(config) {
12503
+ var _this = _super.call(this, config) || this;
12504
+ _this.includeRedirectUri = false;
12505
+ return _this;
12506
+ }
12507
+ return HybridSpaAuthorizationCodeClient;
12508
+ }(AuthorizationCodeClient));
12509
+
12510
+ /*
12511
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12512
+ * Licensed under the MIT License.
12513
+ */
12514
+ var SilentAuthCodeClient = /** @class */ (function (_super) {
12515
+ __extends$1(SilentAuthCodeClient, _super);
12516
+ function SilentAuthCodeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, correlationId) {
12517
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) || this;
12518
+ _this.apiId = apiId;
12519
+ return _this;
12520
+ }
12521
+ /**
12522
+ * Acquires a token silently by redeeming an authorization code against the /token endpoint
12523
+ * @param request
12524
+ */
12525
+ SilentAuthCodeClient.prototype.acquireToken = function (request) {
12526
+ return __awaiter$1(this, void 0, void 0, function () {
12527
+ var silentRequest, serverTelemetryManager, authCodeRequest, clientConfig, authClient, silentHandler, e_1;
12528
+ return __generator$1(this, function (_a) {
12529
+ switch (_a.label) {
12530
+ case 0:
12531
+ this.logger.trace("SilentAuthCodeClient.acquireToken called");
12532
+ // Auth code payload is required
12533
+ if (!request.code) {
12534
+ throw BrowserAuthError.createAuthCodeRequiredError();
12535
+ }
12536
+ return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Silent)];
12537
+ case 1:
12538
+ silentRequest = _a.sent();
12539
+ this.browserStorage.updateCacheEntries(silentRequest.state, silentRequest.nonce, silentRequest.authority, silentRequest.loginHint || "", silentRequest.account || null);
12540
+ serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
12541
+ _a.label = 2;
12542
+ case 2:
12543
+ _a.trys.push([2, 4, , 5]);
12544
+ authCodeRequest = __assign$1(__assign$1({}, silentRequest), { code: request.code });
12545
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, silentRequest.authority)];
12546
+ case 3:
12547
+ clientConfig = _a.sent();
12548
+ authClient = new HybridSpaAuthorizationCodeClient(clientConfig);
12549
+ this.logger.verbose("Auth code client created");
12550
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system.navigateFrameWait);
12551
+ // Handle auth code parameters from request
12552
+ return [2 /*return*/, silentHandler.handleCodeResponseFromServer({
12553
+ code: request.code,
12554
+ msgraph_host: request.msGraphHost,
12555
+ cloud_graph_host_name: request.cloudGraphHostName,
12556
+ cloud_instance_host_name: request.cloudInstanceHostName
12557
+ }, silentRequest.state, authClient.authority, this.networkClient, false)];
12558
+ case 4:
12559
+ e_1 = _a.sent();
12560
+ if (e_1 instanceof AuthError) {
12561
+ e_1.setCorrelationId(this.correlationId);
12562
+ }
12563
+ serverTelemetryManager.cacheFailedRequest(e_1);
12564
+ this.browserStorage.cleanRequestByState(silentRequest.state);
12565
+ throw e_1;
12566
+ case 5: return [2 /*return*/];
12567
+ }
12568
+ });
12569
+ });
12570
+ };
12571
+ /**
12572
+ * Currently Unsupported
12573
+ */
12574
+ SilentAuthCodeClient.prototype.logout = function () {
12575
+ // Synchronous so we must reject
12576
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
12577
+ };
12578
+ return SilentAuthCodeClient;
12579
+ }(StandardInteractionClient));
12580
+
11755
12581
  /*
11756
12582
  * Copyright (c) Microsoft Corporation. All rights reserved.
11757
12583
  * Licensed under the MIT License.
@@ -11795,8 +12621,10 @@ var ClientApplication = /** @class */ (function () {
11795
12621
  this.navigationClient = this.config.system.navigationClient;
11796
12622
  // Initialize redirectResponse Map
11797
12623
  this.redirectResponse = new Map();
12624
+ // Initial hybrid spa map
12625
+ this.hybridAuthCodeResponses = new Map();
11798
12626
  // Initialize the crypto class.
11799
- this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps() : DEFAULT_CRYPTO_IMPLEMENTATION;
12627
+ this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger) : DEFAULT_CRYPTO_IMPLEMENTATION;
11800
12628
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
11801
12629
  // Initialize the browser storage class.
11802
12630
  this.browserStorage = this.isBrowserEnvironment ?
@@ -11826,7 +12654,7 @@ var ClientApplication = /** @class */ (function () {
11826
12654
  if (typeof response === "undefined") {
11827
12655
  this.eventHandler.emitEvent(exports.EventType.HANDLE_REDIRECT_START, exports.InteractionType.Redirect);
11828
12656
  this.logger.verbose("handleRedirectPromise has been called for the first time, storing the promise");
11829
- correlationId = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || "";
12657
+ correlationId = this.browserStorage.getTemporaryCache(exports.TemporaryCacheKeys.CORRELATION_ID, true) || "";
11830
12658
  redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, correlationId);
11831
12659
  response = redirectClient.handleRedirectPromise(hash)
11832
12660
  .then(function (result) {
@@ -11883,8 +12711,8 @@ var ClientApplication = /** @class */ (function () {
11883
12711
  var _this = this;
11884
12712
  return __generator$1(this, function (_a) {
11885
12713
  // Preflight request
11886
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
11887
12714
  this.logger.verbose("acquireTokenRedirect called");
12715
+ this.preflightBrowserEnvironmentCheck(exports.InteractionType.Redirect);
11888
12716
  isLoggedIn = this.getAllAccounts().length > 0;
11889
12717
  if (isLoggedIn) {
11890
12718
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Redirect, request);
@@ -11918,8 +12746,8 @@ var ClientApplication = /** @class */ (function () {
11918
12746
  ClientApplication.prototype.acquireTokenPopup = function (request) {
11919
12747
  var _this = this;
11920
12748
  try {
11921
- this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
11922
12749
  this.logger.verbose("acquireTokenPopup called", request.correlationId);
12750
+ this.preflightBrowserEnvironmentCheck(exports.InteractionType.Popup);
11923
12751
  }
11924
12752
  catch (e) {
11925
12753
  // Since this function is syncronous we need to reject
@@ -11999,6 +12827,77 @@ var ClientApplication = /** @class */ (function () {
11999
12827
  });
12000
12828
  });
12001
12829
  };
12830
+ /**
12831
+ * This function redeems an authorization code (passed as code) from the eSTS token endpoint.
12832
+ * This authorization code should be acquired server-side using a confidential client to acquire a spa_code.
12833
+ * This API is not indended for normal authorization code acquisition and redemption.
12834
+ *
12835
+ * Redemption of this authorization code will not require PKCE, as it was acquired by a confidential client.
12836
+ *
12837
+ * @param request {@link AuthorizationCodeRequest}
12838
+ * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
12839
+ */
12840
+ ClientApplication.prototype.acquireTokenByCode = function (request) {
12841
+ return __awaiter$1(this, void 0, void 0, function () {
12842
+ var response;
12843
+ var _this = this;
12844
+ return __generator$1(this, function (_a) {
12845
+ this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
12846
+ this.logger.trace("acquireTokenByCode called", request.correlationId);
12847
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
12848
+ try {
12849
+ if (!request.code) {
12850
+ throw BrowserAuthError.createAuthCodeRequiredError();
12851
+ }
12852
+ response = this.hybridAuthCodeResponses.get(request.code);
12853
+ if (!response) {
12854
+ this.logger.verbose("Initiating new acquireTokenByCode request", request.correlationId);
12855
+ response = this.acquireTokenByCodeAsync(request)
12856
+ .then(function (result) {
12857
+ _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
12858
+ _this.hybridAuthCodeResponses.delete(request.code);
12859
+ return result;
12860
+ })
12861
+ .catch(function (error) {
12862
+ _this.hybridAuthCodeResponses.delete(request.code);
12863
+ throw error;
12864
+ });
12865
+ this.hybridAuthCodeResponses.set(request.code, response);
12866
+ }
12867
+ else {
12868
+ this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
12869
+ }
12870
+ return [2 /*return*/, response];
12871
+ }
12872
+ catch (e) {
12873
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
12874
+ throw e;
12875
+ }
12876
+ return [2 /*return*/];
12877
+ });
12878
+ });
12879
+ };
12880
+ /**
12881
+ * Creates a SilentAuthCodeClient to redeem an authorization code.
12882
+ * @param request
12883
+ * @returns Result of the operation to redeem the authorization code
12884
+ */
12885
+ ClientApplication.prototype.acquireTokenByCodeAsync = function (request) {
12886
+ return __awaiter$1(this, void 0, void 0, function () {
12887
+ var silentAuthCodeClient, silentTokenResult;
12888
+ return __generator$1(this, function (_a) {
12889
+ switch (_a.label) {
12890
+ case 0:
12891
+ this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
12892
+ silentAuthCodeClient = new SilentAuthCodeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenByCode, request.correlationId);
12893
+ return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)];
12894
+ case 1:
12895
+ silentTokenResult = _a.sent();
12896
+ return [2 /*return*/, silentTokenResult];
12897
+ }
12898
+ });
12899
+ });
12900
+ };
12002
12901
  /**
12003
12902
  * Use this function to obtain a token before every call to the API / resource provider
12004
12903
  *
@@ -12025,7 +12924,7 @@ var ClientApplication = /** @class */ (function () {
12025
12924
  var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
12026
12925
  if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
12027
12926
  _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
12028
- var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode);
12927
+ var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode, request.correlationId);
12029
12928
  return silentIframeClient.acquireToken(request);
12030
12929
  }
12031
12930
  throw e;
@@ -12183,6 +13082,21 @@ var ClientApplication = /** @class */ (function () {
12183
13082
  !this.config.cache.storeAuthStateInCookie) {
12184
13083
  throw BrowserConfigurationAuthError.createInMemoryRedirectUnavailableError();
12185
13084
  }
13085
+ if (interactionType === exports.InteractionType.Redirect || interactionType === exports.InteractionType.Popup) {
13086
+ this.preflightInteractiveRequest();
13087
+ }
13088
+ };
13089
+ /**
13090
+ * Helper to validate app environment before making a request.
13091
+ * @param request
13092
+ * @param interactionType
13093
+ */
13094
+ ClientApplication.prototype.preflightInteractiveRequest = function () {
13095
+ this.logger.verbose("preflightInteractiveRequest called, validating app environment");
13096
+ // block the reload if it occurred inside a hidden iframe
13097
+ BrowserUtils.blockReloadInHiddenIframes();
13098
+ // Set interaction in progress temporary cache or throw if alread set.
13099
+ this.browserStorage.setInteractionInProgress(true);
12186
13100
  };
12187
13101
  /**
12188
13102
  * Adds event callbacks to array
@@ -12245,6 +13159,12 @@ var ClientApplication = /** @class */ (function () {
12245
13159
  ClientApplication.prototype.setNavigationClient = function (navigationClient) {
12246
13160
  this.navigationClient = navigationClient;
12247
13161
  };
13162
+ /**
13163
+ * Returns the configuration object
13164
+ */
13165
+ ClientApplication.prototype.getConfiguration = function () {
13166
+ return this.config;
13167
+ };
12248
13168
  return ClientApplication;
12249
13169
  }());
12250
13170
 
@@ -12268,7 +13188,7 @@ var SilentCacheClient = /** @class */ (function (_super) {
12268
13188
  switch (_a.label) {
12269
13189
  case 0:
12270
13190
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
12271
- return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority)];
13191
+ return [4 /*yield*/, this.createSilentFlowClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions)];
12272
13192
  case 1:
12273
13193
  silentAuthClient = _a.sent();
12274
13194
  this.logger.verbose("Silent auth client created");
@@ -12303,12 +13223,12 @@ var SilentCacheClient = /** @class */ (function (_super) {
12303
13223
  * @param serverTelemetryManager
12304
13224
  * @param authorityUrl
12305
13225
  */
12306
- SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl) {
13226
+ SilentCacheClient.prototype.createSilentFlowClient = function (serverTelemetryManager, authorityUrl, azureCloudOptions) {
12307
13227
  return __awaiter$1(this, void 0, void 0, function () {
12308
13228
  var clientConfig;
12309
13229
  return __generator$1(this, function (_a) {
12310
13230
  switch (_a.label) {
12311
- case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl)];
13231
+ case 0: return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions)];
12312
13232
  case 1:
12313
13233
  clientConfig = _a.sent();
12314
13234
  return [2 /*return*/, new SilentFlowClient(clientConfig)];
@@ -12317,7 +13237,17 @@ var SilentCacheClient = /** @class */ (function (_super) {
12317
13237
  });
12318
13238
  };
12319
13239
  SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
12320
- return __assign$1(__assign$1(__assign$1({}, request), this.initializeBaseRequest(request)), { account: account, forceRefresh: request.forceRefresh || false });
13240
+ return __awaiter$1(this, void 0, void 0, function () {
13241
+ var _a;
13242
+ return __generator$1(this, function (_b) {
13243
+ switch (_b.label) {
13244
+ case 0:
13245
+ _a = [__assign$1({}, request)];
13246
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
13247
+ case 1: return [2 /*return*/, __assign$1.apply(void 0, [__assign$1.apply(void 0, _a.concat([_b.sent()])), { account: account, forceRefresh: request.forceRefresh || false }])];
13248
+ }
13249
+ });
13250
+ });
12321
13251
  };
12322
13252
  return SilentCacheClient;
12323
13253
  }(StandardInteractionClient));
@@ -12408,10 +13338,12 @@ var PublicClientApplication = /** @class */ (function (_super) {
12408
13338
  authority: request.authority || "",
12409
13339
  scopes: request.scopes,
12410
13340
  homeAccountIdentifier: account.homeAccountId,
13341
+ claims: request.claims,
12411
13342
  authenticationScheme: request.authenticationScheme,
12412
13343
  resourceRequestMethod: request.resourceRequestMethod,
12413
13344
  resourceRequestUri: request.resourceRequestUri,
12414
- shrClaims: request.shrClaims
13345
+ shrClaims: request.shrClaims,
13346
+ sshKid: request.sshKid
12415
13347
  };
12416
13348
  silentRequestKey = JSON.stringify(thumbprint);
12417
13349
  cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
@@ -12447,28 +13379,33 @@ var PublicClientApplication = /** @class */ (function (_super) {
12447
13379
  var silentCacheClient, silentRequest;
12448
13380
  var _this = this;
12449
13381
  return __generator$1(this, function (_a) {
12450
- silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient);
12451
- silentRequest = silentCacheClient.initializeSilentRequest(request, account);
12452
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
12453
- return [2 /*return*/, silentCacheClient.acquireToken(silentRequest).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
12454
- var tokenRenewalResult, tokenRenewalError_1;
12455
- return __generator$1(this, function (_a) {
12456
- switch (_a.label) {
12457
- case 0:
12458
- _a.trys.push([0, 2, , 3]);
12459
- return [4 /*yield*/, this.acquireTokenByRefreshToken(silentRequest)];
12460
- case 1:
12461
- tokenRenewalResult = _a.sent();
12462
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, tokenRenewalResult);
12463
- return [2 /*return*/, tokenRenewalResult];
12464
- case 2:
12465
- tokenRenewalError_1 = _a.sent();
12466
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError_1);
12467
- throw tokenRenewalError_1;
12468
- case 3: return [2 /*return*/];
12469
- }
12470
- });
12471
- }); })];
13382
+ switch (_a.label) {
13383
+ case 0:
13384
+ silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
13385
+ return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
13386
+ case 1:
13387
+ silentRequest = _a.sent();
13388
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
13389
+ return [2 /*return*/, silentCacheClient.acquireToken(silentRequest).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
13390
+ var tokenRenewalResult, tokenRenewalError_1;
13391
+ return __generator$1(this, function (_a) {
13392
+ switch (_a.label) {
13393
+ case 0:
13394
+ _a.trys.push([0, 2, , 3]);
13395
+ return [4 /*yield*/, this.acquireTokenByRefreshToken(silentRequest)];
13396
+ case 1:
13397
+ tokenRenewalResult = _a.sent();
13398
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, tokenRenewalResult);
13399
+ return [2 /*return*/, tokenRenewalResult];
13400
+ case 2:
13401
+ tokenRenewalError_1 = _a.sent();
13402
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError_1);
13403
+ throw tokenRenewalError_1;
13404
+ case 3: return [2 /*return*/];
13405
+ }
13406
+ });
13407
+ }); })];
13408
+ }
12472
13409
  });
12473
13410
  });
12474
13411
  };
@@ -12489,6 +13426,9 @@ var stubbedPublicClientApplication = {
12489
13426
  acquireTokenSilent: function () {
12490
13427
  return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
12491
13428
  },
13429
+ acquireTokenByCode: function () {
13430
+ return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
13431
+ },
12492
13432
  getAllAccounts: function () {
12493
13433
  return [];
12494
13434
  },
@@ -12554,6 +13494,9 @@ var stubbedPublicClientApplication = {
12554
13494
  },
12555
13495
  setNavigationClient: function () {
12556
13496
  return;
13497
+ },
13498
+ getConfiguration: function () {
13499
+ throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
12557
13500
  }
12558
13501
  };
12559
13502
 
@@ -12626,8 +13569,10 @@ var EventMessageUtils = /** @class */ (function () {
12626
13569
  * Licensed under the MIT License.
12627
13570
  */
12628
13571
  var SignedHttpRequest = /** @class */ (function () {
12629
- function SignedHttpRequest(shrParameters) {
12630
- this.cryptoOps = new CryptoOps();
13572
+ function SignedHttpRequest(shrParameters, shrOptions) {
13573
+ var loggerOptions = (shrOptions && shrOptions.loggerOptions) || {};
13574
+ this.logger = new Logger(loggerOptions, name, version);
13575
+ this.cryptoOps = new CryptoOps(this.logger);
12631
13576
  this.popTokenGenerator = new PopTokenGenerator(this.cryptoOps);
12632
13577
  this.shrParameters = shrParameters;
12633
13578
  }
@@ -12670,7 +13615,10 @@ var SignedHttpRequest = /** @class */ (function () {
12670
13615
  SignedHttpRequest.prototype.removeKeys = function (publicKeyThumbprint) {
12671
13616
  return __awaiter$1(this, void 0, void 0, function () {
12672
13617
  return __generator$1(this, function (_a) {
12673
- return [2 /*return*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
13618
+ switch (_a.label) {
13619
+ case 0: return [4 /*yield*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
13620
+ case 1: return [2 /*return*/, _a.sent()];
13621
+ }
12674
13622
  });
12675
13623
  });
12676
13624
  };
@@ -12680,23 +13628,37 @@ var SignedHttpRequest = /** @class */ (function () {
12680
13628
  exports.AccountEntity = AccountEntity;
12681
13629
  exports.AuthError = AuthError;
12682
13630
  exports.AuthErrorMessage = AuthErrorMessage;
13631
+ exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
12683
13632
  exports.BrowserAuthError = BrowserAuthError;
12684
13633
  exports.BrowserAuthErrorMessage = BrowserAuthErrorMessage;
13634
+ exports.BrowserCacheManager = BrowserCacheManager;
12685
13635
  exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;
12686
13636
  exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
13637
+ exports.BrowserConstants = BrowserConstants;
12687
13638
  exports.BrowserUtils = BrowserUtils;
12688
13639
  exports.ClientAuthError = ClientAuthError;
12689
13640
  exports.ClientAuthErrorMessage = ClientAuthErrorMessage;
12690
13641
  exports.ClientConfigurationError = ClientConfigurationError;
12691
13642
  exports.ClientConfigurationErrorMessage = ClientConfigurationErrorMessage;
13643
+ exports.DEFAULT_IFRAME_TIMEOUT_MS = DEFAULT_IFRAME_TIMEOUT_MS;
13644
+ exports.EventHandler = EventHandler;
12692
13645
  exports.EventMessageUtils = EventMessageUtils;
12693
13646
  exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
12694
13647
  exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
12695
13648
  exports.Logger = Logger;
12696
13649
  exports.NavigationClient = NavigationClient;
13650
+ exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
13651
+ exports.PopupClient = PopupClient;
13652
+ exports.PopupUtils = PopupUtils;
12697
13653
  exports.PublicClientApplication = PublicClientApplication;
13654
+ exports.RedirectClient = RedirectClient;
13655
+ exports.RedirectHandler = RedirectHandler;
12698
13656
  exports.ServerError = ServerError;
12699
13657
  exports.SignedHttpRequest = SignedHttpRequest;
13658
+ exports.SilentCacheClient = SilentCacheClient;
13659
+ exports.SilentIframeClient = SilentIframeClient;
13660
+ exports.SilentRefreshClient = SilentRefreshClient;
13661
+ exports.StandardInteractionClient = StandardInteractionClient;
12700
13662
  exports.StringUtils = StringUtils;
12701
13663
  exports.UrlString = UrlString;
12702
13664
  exports.stubbedPublicClientApplication = stubbedPublicClientApplication;