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