@azure/msal-browser 2.17.0 → 2.21.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 (168) hide show
  1. package/CHANGELOG.json +203 -0
  2. package/{changelog.md → CHANGELOG.md} +506 -445
  3. package/LICENSE +21 -21
  4. package/README.md +14 -6
  5. package/dist/_virtual/_tslib.js +1 -1
  6. package/dist/app/ClientApplication.d.ts +31 -0
  7. package/dist/app/ClientApplication.d.ts.map +1 -1
  8. package/dist/app/ClientApplication.js +96 -3
  9. package/dist/app/ClientApplication.js.map +1 -1
  10. package/dist/app/IPublicClientApplication.d.ts +6 -0
  11. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  12. package/dist/app/IPublicClientApplication.js +13 -1
  13. package/dist/app/IPublicClientApplication.js.map +1 -1
  14. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  15. package/dist/app/PublicClientApplication.js +31 -24
  16. package/dist/app/PublicClientApplication.js.map +1 -1
  17. package/dist/cache/AsyncMemoryStorage.d.ts +46 -0
  18. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -0
  19. package/dist/cache/AsyncMemoryStorage.js +195 -0
  20. package/dist/cache/AsyncMemoryStorage.js.map +1 -0
  21. package/dist/cache/BrowserCacheManager.d.ts +9 -1
  22. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  23. package/dist/cache/BrowserCacheManager.js +55 -2
  24. package/dist/cache/BrowserCacheManager.js.map +1 -1
  25. package/dist/cache/BrowserStorage.d.ts +1 -1
  26. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  27. package/dist/cache/BrowserStorage.js +1 -1
  28. package/dist/cache/BrowserStorage.js.map +1 -1
  29. package/dist/cache/DatabaseStorage.d.ts +25 -6
  30. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  31. package/dist/cache/DatabaseStorage.js +127 -81
  32. package/dist/cache/DatabaseStorage.js.map +1 -1
  33. package/dist/cache/IAsyncMemoryStorage.d.ts +28 -0
  34. package/dist/cache/IAsyncMemoryStorage.d.ts.map +1 -0
  35. package/dist/cache/IWindowStorage.d.ts +3 -3
  36. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  37. package/dist/cache/MemoryStorage.d.ts +3 -3
  38. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  39. package/dist/cache/MemoryStorage.js +1 -1
  40. package/dist/cache/MemoryStorage.js.map +1 -1
  41. package/dist/cache/TokenCache.js +1 -1
  42. package/dist/cache/TokenCache.js.map +1 -1
  43. package/dist/config/Configuration.js +1 -1
  44. package/dist/config/Configuration.js.map +1 -1
  45. package/dist/crypto/BrowserCrypto.d.ts +3 -1
  46. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  47. package/dist/crypto/BrowserCrypto.js +3 -2
  48. package/dist/crypto/BrowserCrypto.js.map +1 -1
  49. package/dist/crypto/CryptoOps.d.ts +16 -5
  50. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  51. package/dist/crypto/CryptoOps.js +58 -17
  52. package/dist/crypto/CryptoOps.js.map +1 -1
  53. package/dist/crypto/GuidGenerator.js +1 -1
  54. package/dist/crypto/GuidGenerator.js.map +1 -1
  55. package/dist/crypto/PkceGenerator.js +1 -1
  56. package/dist/crypto/PkceGenerator.js.map +1 -1
  57. package/dist/crypto/SignedHttpRequest.d.ts +6 -2
  58. package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
  59. package/dist/crypto/SignedHttpRequest.js +11 -5
  60. package/dist/crypto/SignedHttpRequest.js.map +1 -1
  61. package/dist/encode/Base64Decode.js +1 -1
  62. package/dist/encode/Base64Decode.js.map +1 -1
  63. package/dist/encode/Base64Encode.js +1 -1
  64. package/dist/encode/Base64Encode.js.map +1 -1
  65. package/dist/error/BrowserAuthError.d.ts +16 -8
  66. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  67. package/dist/error/BrowserAuthError.js +22 -12
  68. package/dist/error/BrowserAuthError.js.map +1 -1
  69. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  70. package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
  71. package/dist/event/EventHandler.d.ts +13 -0
  72. package/dist/event/EventHandler.d.ts.map +1 -1
  73. package/dist/event/EventHandler.js +66 -1
  74. package/dist/event/EventHandler.js.map +1 -1
  75. package/dist/event/EventMessage.d.ts +2 -2
  76. package/dist/event/EventMessage.d.ts.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 +5 -0
  80. package/dist/event/EventType.d.ts.map +1 -1
  81. package/dist/event/EventType.js +6 -1
  82. package/dist/event/EventType.js.map +1 -1
  83. package/dist/index.cjs.js +1465 -520
  84. package/dist/index.cjs.js.map +1 -1
  85. package/dist/index.d.ts +5 -3
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +3 -2
  88. package/dist/index.js.map +1 -1
  89. package/dist/interaction_client/BaseInteractionClient.d.ts +21 -1
  90. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  91. package/dist/interaction_client/BaseInteractionClient.js +77 -3
  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.map +1 -1
  98. package/dist/interaction_client/PopupClient.js +47 -37
  99. package/dist/interaction_client/PopupClient.js.map +1 -1
  100. package/dist/interaction_client/RedirectClient.js +16 -15
  101. package/dist/interaction_client/RedirectClient.js.map +1 -1
  102. package/dist/interaction_client/SilentAuthCodeClient.d.ts +22 -0
  103. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -0
  104. package/dist/interaction_client/SilentAuthCodeClient.js +82 -0
  105. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -0
  106. package/dist/interaction_client/SilentCacheClient.d.ts +1 -1
  107. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  108. package/dist/interaction_client/SilentCacheClient.js +12 -2
  109. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  110. package/dist/interaction_client/SilentIframeClient.js +15 -13
  111. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  112. package/dist/interaction_client/SilentRefreshClient.js +10 -7
  113. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  114. package/dist/interaction_client/StandardInteractionClient.d.ts +3 -23
  115. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  116. package/dist/interaction_client/StandardInteractionClient.js +51 -105
  117. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  118. package/dist/interaction_handler/InteractionHandler.d.ts +11 -2
  119. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  120. package/dist/interaction_handler/InteractionHandler.js +36 -10
  121. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  122. package/dist/interaction_handler/PopupHandler.js +1 -1
  123. package/dist/interaction_handler/PopupHandler.js.map +1 -1
  124. package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
  125. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  126. package/dist/interaction_handler/RedirectHandler.js +2 -2
  127. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  128. package/dist/interaction_handler/SilentHandler.js +1 -1
  129. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  130. package/dist/navigation/NavigationClient.js +1 -1
  131. package/dist/navigation/NavigationClient.js.map +1 -1
  132. package/dist/network/FetchClient.js +1 -1
  133. package/dist/network/FetchClient.js.map +1 -1
  134. package/dist/network/XhrClient.js +1 -1
  135. package/dist/network/XhrClient.js.map +1 -1
  136. package/dist/packageMetadata.d.ts +1 -1
  137. package/dist/packageMetadata.js +2 -2
  138. package/dist/packageMetadata.js.map +1 -1
  139. package/dist/request/AuthorizationCodeRequest.d.ts +8 -0
  140. package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -0
  141. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  142. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  143. package/dist/request/PopupRequest.d.ts +1 -1
  144. package/dist/request/PopupRequest.d.ts.map +1 -1
  145. package/dist/request/RedirectRequest.d.ts +1 -1
  146. package/dist/request/RedirectRequest.d.ts.map +1 -1
  147. package/dist/request/SilentRequest.d.ts +1 -1
  148. package/dist/request/SilentRequest.d.ts.map +1 -1
  149. package/dist/request/SsoSilentRequest.d.ts +1 -1
  150. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  151. package/dist/utils/BrowserConstants.d.ts +4 -0
  152. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  153. package/dist/utils/BrowserConstants.js +8 -3
  154. package/dist/utils/BrowserConstants.js.map +1 -1
  155. package/dist/utils/BrowserProtocolUtils.js +1 -1
  156. package/dist/utils/BrowserProtocolUtils.js.map +1 -1
  157. package/dist/utils/BrowserStringUtils.js +1 -1
  158. package/dist/utils/BrowserStringUtils.js.map +1 -1
  159. package/dist/utils/BrowserUtils.js +1 -1
  160. package/dist/utils/BrowserUtils.js.map +1 -1
  161. package/dist/utils/MathUtils.js +1 -1
  162. package/dist/utils/MathUtils.js.map +1 -1
  163. package/dist/utils/PopupUtils.js +1 -1
  164. package/dist/utils/PopupUtils.js.map +1 -1
  165. package/lib/msal-browser.js +1465 -520
  166. package/lib/msal-browser.js.map +1 -1
  167. package/lib/msal-browser.min.js +30 -30
  168. package/package.json +9 -2
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.17.0 2021-09-08 */
1
+ /*! @azure/msal-browser v2.21.0 2022-01-04 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -105,7 +105,7 @@ function __spread() {
105
105
  return ar;
106
106
  }
107
107
 
108
- /*! @azure/msal-common v5.0.0 2021-09-08 */
108
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
109
109
  /*! *****************************************************************************
110
110
  Copyright (c) Microsoft Corporation.
111
111
 
@@ -192,7 +192,7 @@ function __spreadArrays() {
192
192
  return r;
193
193
  }
194
194
 
195
- /*! @azure/msal-common v5.0.0 2021-09-08 */
195
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
196
196
 
197
197
  /*
198
198
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -257,6 +257,8 @@ var HeaderNames;
257
257
  HeaderNames["CONTENT_TYPE"] = "Content-Type";
258
258
  HeaderNames["RETRY_AFTER"] = "Retry-After";
259
259
  HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
260
+ HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
261
+ HeaderNames["AuthenticationInfo"] = "Authentication-Info";
260
262
  })(HeaderNames || (HeaderNames = {}));
261
263
  /**
262
264
  * Persistent cache keys MSAL which stay while user is logged in.
@@ -327,6 +329,7 @@ var AADServerParamKeys;
327
329
  AADServerParamKeys["ON_BEHALF_OF"] = "on_behalf_of";
328
330
  AADServerParamKeys["FOCI"] = "foci";
329
331
  AADServerParamKeys["CCS_HEADER"] = "X-AnchorMailbox";
332
+ AADServerParamKeys["RETURN_SPA_CODE"] = "return_spa_code";
330
333
  })(AADServerParamKeys || (AADServerParamKeys = {}));
331
334
  /**
332
335
  * Claims request keys
@@ -484,8 +487,9 @@ var SERVER_TELEM_CONSTANTS = {
484
487
  */
485
488
  exports.AuthenticationScheme = void 0;
486
489
  (function (AuthenticationScheme) {
487
- AuthenticationScheme["POP"] = "pop";
488
490
  AuthenticationScheme["BEARER"] = "Bearer";
491
+ AuthenticationScheme["POP"] = "pop";
492
+ AuthenticationScheme["SSH"] = "ssh-cert";
489
493
  })(exports.AuthenticationScheme || (exports.AuthenticationScheme = {}));
490
494
  /**
491
495
  * Constants related to throttling
@@ -550,7 +554,7 @@ var CacheOutcome;
550
554
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
551
555
  })(CacheOutcome || (CacheOutcome = {}));
552
556
 
553
- /*! @azure/msal-common v5.0.0 2021-09-08 */
557
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
554
558
 
555
559
  /*
556
560
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -594,7 +598,7 @@ var AuthError = /** @class */ (function (_super) {
594
598
  return AuthError;
595
599
  }(Error));
596
600
 
597
- /*! @azure/msal-common v5.0.0 2021-09-08 */
601
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
598
602
 
599
603
  /*
600
604
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -657,10 +661,19 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
657
661
  throw AuthError.createUnexpectedError(notImplErr);
658
662
  });
659
663
  });
664
+ },
665
+ hashString: function () {
666
+ return __awaiter(this, void 0, void 0, function () {
667
+ var notImplErr;
668
+ return __generator(this, function (_a) {
669
+ notImplErr = "Crypto interface - hashString() has not been implemented";
670
+ throw AuthError.createUnexpectedError(notImplErr);
671
+ });
672
+ });
660
673
  }
661
674
  };
662
675
 
663
- /*! @azure/msal-common v5.0.0 2021-09-08 */
676
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
664
677
 
665
678
  /*
666
679
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -846,6 +859,10 @@ var ClientAuthErrorMessage = {
846
859
  bindingKeyNotRemovedError: {
847
860
  code: "binding_key_not_removed",
848
861
  desc: "Could not remove the credential's binding key from storage."
862
+ },
863
+ logoutNotSupported: {
864
+ code: "end_session_endpoint_not_supported",
865
+ desc: "Provided authority does not support logout."
849
866
  }
850
867
  };
851
868
  /**
@@ -945,12 +962,6 @@ var ClientAuthError = /** @class */ (function (_super) {
945
962
  ClientAuthError.createNonceNotFoundError = function (missingNonce) {
946
963
  return new ClientAuthError(ClientAuthErrorMessage.nonceNotFoundError.code, ClientAuthErrorMessage.nonceNotFoundError.desc + ": " + missingNonce);
947
964
  };
948
- /**
949
- * Creates an error thrown when the authorization code required for a token request is null or empty.
950
- */
951
- ClientAuthError.createNoTokensFoundError = function () {
952
- return new ClientAuthError(ClientAuthErrorMessage.noTokensFoundError.code, ClientAuthErrorMessage.noTokensFoundError.desc);
953
- };
954
965
  /**
955
966
  * Throws error when multiple tokens are in cache.
956
967
  */
@@ -1115,10 +1126,16 @@ var ClientAuthError = /** @class */ (function (_super) {
1115
1126
  ClientAuthError.createBindingKeyNotRemovedError = function () {
1116
1127
  return new ClientAuthError(ClientAuthErrorMessage.bindingKeyNotRemovedError.code, ClientAuthErrorMessage.bindingKeyNotRemovedError.desc);
1117
1128
  };
1129
+ /**
1130
+ * Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
1131
+ */
1132
+ ClientAuthError.createLogoutNotSupportedError = function () {
1133
+ return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
1134
+ };
1118
1135
  return ClientAuthError;
1119
1136
  }(AuthError));
1120
1137
 
1121
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1138
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
1122
1139
 
1123
1140
  /*
1124
1141
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1243,7 +1260,7 @@ var StringUtils = /** @class */ (function () {
1243
1260
  return StringUtils;
1244
1261
  }());
1245
1262
 
1246
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1263
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
1247
1264
 
1248
1265
  /*
1249
1266
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1423,12 +1440,12 @@ var Logger = /** @class */ (function () {
1423
1440
  return Logger;
1424
1441
  }());
1425
1442
 
1426
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1443
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
1427
1444
  /* eslint-disable header/header */
1428
1445
  var name$1 = "@azure/msal-common";
1429
- var version$1 = "5.0.0";
1446
+ var version$1 = "6.0.0";
1430
1447
 
1431
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1448
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
1432
1449
 
1433
1450
  /*
1434
1451
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1439,7 +1456,7 @@ var version$1 = "5.0.0";
1439
1456
  *
1440
1457
  * Key:Value Schema:
1441
1458
  *
1442
- * Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<scheme>
1459
+ * Key: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<requestedClaims*>-<scheme*>
1443
1460
  *
1444
1461
  * Value Schema:
1445
1462
  * {
@@ -1453,6 +1470,7 @@ var version$1 = "5.0.0";
1453
1470
  * target: Permissions that are included in the token, or for refresh tokens, the resource identifier.
1454
1471
  * oboAssertion: access token passed in as part of OBO request
1455
1472
  * tokenType: Matches the authentication scheme for which the token was issued (i.e. Bearer or pop)
1473
+ * requestedClaimsHash: Matches the SHA 256 hash of the claims object included in the token request
1456
1474
  * }
1457
1475
  */
1458
1476
  var CredentialEntity = /** @class */ (function () {
@@ -1480,7 +1498,7 @@ var CredentialEntity = /** @class */ (function () {
1480
1498
  * generates credential key
1481
1499
  */
1482
1500
  CredentialEntity.prototype.generateCredentialKey = function () {
1483
- return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType);
1501
+ return CredentialEntity.generateCredentialCacheKey(this.homeAccountId, this.environment, this.credentialType, this.clientId, this.realm, this.target, this.familyId, this.tokenType, this.requestedClaimsHash);
1484
1502
  };
1485
1503
  /**
1486
1504
  * returns the type of the cache (in this case credential)
@@ -1524,16 +1542,14 @@ var CredentialEntity = /** @class */ (function () {
1524
1542
  * generates credential key
1525
1543
  * <home_account_id*>-\<environment>-<credential_type>-<client_id>-<realm\*>-<target\*>-<scheme\*>
1526
1544
  */
1527
- CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType) {
1545
+ CredentialEntity.generateCredentialCacheKey = function (homeAccountId, environment, credentialType, clientId, realm, target, familyId, tokenType, requestedClaimsHash) {
1528
1546
  var credentialKey = [
1529
1547
  this.generateAccountIdForCacheKey(homeAccountId, environment),
1530
1548
  this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
1531
- this.generateTargetForCacheKey(target)
1549
+ this.generateTargetForCacheKey(target),
1550
+ this.generateClaimsHashForCacheKey(requestedClaimsHash),
1551
+ this.generateSchemeForCacheKey(tokenType)
1532
1552
  ];
1533
- // PoP Tokens include scheme in cache key
1534
- if (tokenType === exports.AuthenticationScheme.POP) {
1535
- credentialKey.push(tokenType.toLowerCase());
1536
- }
1537
1553
  return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
1538
1554
  };
1539
1555
  /**
@@ -1569,10 +1585,26 @@ var CredentialEntity = /** @class */ (function () {
1569
1585
  CredentialEntity.generateTargetForCacheKey = function (scopes) {
1570
1586
  return (scopes || "").toLowerCase();
1571
1587
  };
1588
+ /**
1589
+ * Generate requested claims key component as per schema: <requestedClaims>
1590
+ */
1591
+ CredentialEntity.generateClaimsHashForCacheKey = function (requestedClaimsHash) {
1592
+ return (requestedClaimsHash || "").toLowerCase();
1593
+ };
1594
+ /**
1595
+ * Generate scheme key componenet as per schema: <scheme>
1596
+ */
1597
+ CredentialEntity.generateSchemeForCacheKey = function (tokenType) {
1598
+ /*
1599
+ * PoP Tokens and SSH certs include scheme in cache key
1600
+ * Cast to lowercase to handle "bearer" from ADFS
1601
+ */
1602
+ return (tokenType && tokenType.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? tokenType.toLowerCase() : "";
1603
+ };
1572
1604
  return CredentialEntity;
1573
1605
  }());
1574
1606
 
1575
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1607
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
1576
1608
 
1577
1609
  /*
1578
1610
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1644,15 +1676,31 @@ var ClientConfigurationErrorMessage = {
1644
1676
  },
1645
1677
  invalidCloudDiscoveryMetadata: {
1646
1678
  code: "invalid_cloud_discovery_metadata",
1647
- desc: "Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields"
1679
+ desc: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields"
1648
1680
  },
1649
1681
  invalidAuthorityMetadata: {
1650
1682
  code: "invalid_authority_metadata",
1651
- desc: "Invalid authorityMetadata provided. Must by a JSON object containing authorization_endpoint, token_endpoint, end_session_endpoint, issuer fields."
1683
+ desc: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields."
1652
1684
  },
1653
1685
  untrustedAuthority: {
1654
1686
  code: "untrusted_authority",
1655
1687
  desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."
1688
+ },
1689
+ missingSshJwk: {
1690
+ code: "missing_ssh_jwk",
1691
+ desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."
1692
+ },
1693
+ missingSshKid: {
1694
+ code: "missing_ssh_kid",
1695
+ desc: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme."
1696
+ },
1697
+ missingNonceAuthenticationHeader: {
1698
+ code: "missing_nonce_authentication_header",
1699
+ 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."
1700
+ },
1701
+ invalidAuthenticationHeader: {
1702
+ code: "invalid_authentication_header",
1703
+ desc: "Invalid authentication header provided"
1656
1704
  }
1657
1705
  };
1658
1706
  /**
@@ -1774,10 +1822,34 @@ var ClientConfigurationError = /** @class */ (function (_super) {
1774
1822
  ClientConfigurationError.createUntrustedAuthorityError = function () {
1775
1823
  return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);
1776
1824
  };
1825
+ /*
1826
+ * Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
1827
+ */
1828
+ ClientConfigurationError.createMissingSshJwkError = function () {
1829
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshJwk.code, ClientConfigurationErrorMessage.missingSshJwk.desc);
1830
+ };
1831
+ /**
1832
+ * Throws an error when the authentication scheme is set to SSH but the SSH public key ID is omitted from the request
1833
+ */
1834
+ ClientConfigurationError.createMissingSshKidError = function () {
1835
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshKid.code, ClientConfigurationErrorMessage.missingSshKid.desc);
1836
+ };
1837
+ /**
1838
+ * Throws error when provided headers don't contain a header that a server nonce can be extracted from
1839
+ */
1840
+ ClientConfigurationError.createMissingNonceAuthenticationHeadersError = function () {
1841
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.code, ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.desc);
1842
+ };
1843
+ /**
1844
+ * Throws error when a provided header is invalid in any way
1845
+ */
1846
+ ClientConfigurationError.createInvalidAuthenticationHeaderError = function (invalidHeaderName, details) {
1847
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc + ". Invalid header: " + invalidHeaderName + ". Details: " + details);
1848
+ };
1777
1849
  return ClientConfigurationError;
1778
1850
  }(ClientAuthError));
1779
1851
 
1780
- /*! @azure/msal-common v5.0.0 2021-09-08 */
1852
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
1781
1853
 
1782
1854
  /*
1783
1855
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1961,7 +2033,7 @@ var ScopeSet = /** @class */ (function () {
1961
2033
  return ScopeSet;
1962
2034
  }());
1963
2035
 
1964
- /*! @azure/msal-common v5.0.0 2021-09-08 */
2036
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
1965
2037
 
1966
2038
  /*
1967
2039
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1999,7 +2071,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
1999
2071
  };
2000
2072
  }
2001
2073
 
2002
- /*! @azure/msal-common v5.0.0 2021-09-08 */
2074
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2003
2075
  /*
2004
2076
  * Copyright (c) Microsoft Corporation. All rights reserved.
2005
2077
  * Licensed under the MIT License.
@@ -2013,7 +2085,7 @@ var AuthorityType;
2013
2085
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2014
2086
  })(AuthorityType || (AuthorityType = {}));
2015
2087
 
2016
- /*! @azure/msal-common v5.0.0 2021-09-08 */
2088
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2017
2089
 
2018
2090
  /*
2019
2091
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2247,7 +2319,7 @@ var AccountEntity = /** @class */ (function () {
2247
2319
  return AccountEntity;
2248
2320
  }());
2249
2321
 
2250
- /*! @azure/msal-common v5.0.0 2021-09-08 */
2322
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2251
2323
 
2252
2324
  /*
2253
2325
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2285,7 +2357,7 @@ var AuthToken = /** @class */ (function () {
2285
2357
  return AuthToken;
2286
2358
  }());
2287
2359
 
2288
- /*! @azure/msal-common v5.0.0 2021-09-08 */
2360
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
2289
2361
 
2290
2362
  /*
2291
2363
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2375,7 +2447,8 @@ var CacheManager = /** @class */ (function () {
2375
2447
  environment: credential.environment,
2376
2448
  homeAccountId: credential.homeAccountId,
2377
2449
  realm: credential.realm,
2378
- tokenType: credential.tokenType
2450
+ tokenType: credential.tokenType,
2451
+ requestedClaimsHash: credential.requestedClaimsHash
2379
2452
  });
2380
2453
  currentScopes = ScopeSet.fromString(credential.target);
2381
2454
  currentAccessTokens = Object.keys(currentTokenCache.accessTokens).map(function (key) { return currentTokenCache.accessTokens[key]; });
@@ -2447,7 +2520,7 @@ var CacheManager = /** @class */ (function () {
2447
2520
  * @param target
2448
2521
  */
2449
2522
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
2450
- return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType);
2523
+ 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);
2451
2524
  };
2452
2525
  /**
2453
2526
  * Support function to help match credentials
@@ -2460,7 +2533,7 @@ var CacheManager = /** @class */ (function () {
2460
2533
  * @param oboAssertion
2461
2534
  * @param tokenType
2462
2535
  */
2463
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType) {
2536
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId, requestedClaimsHash) {
2464
2537
  var _this = this;
2465
2538
  var allCacheKeys = this.getKeys();
2466
2539
  var matchingCredentials = {
@@ -2507,27 +2580,37 @@ var CacheManager = /** @class */ (function () {
2507
2580
  if (!!target && !_this.matchTarget(entity, target)) {
2508
2581
  return;
2509
2582
  }
2583
+ // If request OR cached entity has requested Claims Hash, check if they match
2584
+ if (requestedClaimsHash || entity.requestedClaimsHash) {
2585
+ // Don't match if either is undefined or they are different
2586
+ if (entity.requestedClaimsHash !== requestedClaimsHash) {
2587
+ return;
2588
+ }
2589
+ }
2590
+ // Access Token with Auth Scheme specific matching
2510
2591
  if (credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
2511
2592
  if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
2512
2593
  return;
2513
2594
  }
2514
- // This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
2515
- if (cacheKey.indexOf(exports.AuthenticationScheme.POP) === -1) {
2516
- // AccessToken_With_AuthScheme that doesn't have pop in the key is outdated
2517
- _this.removeItem(cacheKey, CacheSchemaType.CREDENTIAL);
2518
- return;
2595
+ // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
2596
+ if (tokenType === exports.AuthenticationScheme.SSH) {
2597
+ if (keyId && !_this.matchKeyId(entity, keyId)) {
2598
+ return;
2599
+ }
2519
2600
  }
2520
2601
  }
2602
+ // At this point, the entity matches the request, update cache key if key schema has changed
2603
+ var updatedCacheKey = _this.updateCredentialCacheKey(cacheKey, entity);
2521
2604
  switch (credType) {
2522
2605
  case CredentialType.ID_TOKEN:
2523
- matchingCredentials.idTokens[cacheKey] = entity;
2606
+ matchingCredentials.idTokens[updatedCacheKey] = entity;
2524
2607
  break;
2525
2608
  case CredentialType.ACCESS_TOKEN:
2526
2609
  case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
2527
- matchingCredentials.accessTokens[cacheKey] = entity;
2610
+ matchingCredentials.accessTokens[updatedCacheKey] = entity;
2528
2611
  break;
2529
2612
  case CredentialType.REFRESH_TOKEN:
2530
- matchingCredentials.refreshTokens[cacheKey] = entity;
2613
+ matchingCredentials.refreshTokens[updatedCacheKey] = entity;
2531
2614
  break;
2532
2615
  }
2533
2616
  });
@@ -2686,6 +2769,7 @@ var CacheManager = /** @class */ (function () {
2686
2769
  case 0:
2687
2770
  key = credential.generateCredentialKey();
2688
2771
  if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
2772
+ if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
2689
2773
  accessTokenWithAuthSchemeEntity = credential;
2690
2774
  kid = accessTokenWithAuthSchemeEntity.keyId;
2691
2775
  if (!kid) return [3 /*break*/, 4];
@@ -2725,10 +2809,10 @@ var CacheManager = /** @class */ (function () {
2725
2809
  * @param environment
2726
2810
  * @param authScheme
2727
2811
  */
2728
- CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme) {
2812
+ CacheManager.prototype.readCacheRecord = function (account, clientId, request, environment) {
2729
2813
  var cachedAccount = this.readAccountFromCache(account);
2730
2814
  var cachedIdToken = this.readIdTokenFromCache(clientId, account);
2731
- var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme);
2815
+ var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, request);
2732
2816
  var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
2733
2817
  var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
2734
2818
  if (cachedAccount && cachedIdToken) {
@@ -2782,9 +2866,14 @@ var CacheManager = /** @class */ (function () {
2782
2866
  * @param scopes
2783
2867
  * @param authScheme
2784
2868
  */
2785
- CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme) {
2786
- // Distinguish between Bearer and PoP token cache types
2787
- var credentialType = (authScheme === exports.AuthenticationScheme.POP) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
2869
+ CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, request) {
2870
+ var scopes = new ScopeSet(request.scopes || []);
2871
+ var authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
2872
+ /*
2873
+ * Distinguish between Bearer and PoP/SSH token cache types
2874
+ * Cast to lowercase to handle "bearer" from ADFS
2875
+ */
2876
+ var credentialType = (authScheme && authScheme.toLowerCase() !== exports.AuthenticationScheme.BEARER.toLowerCase()) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
2788
2877
  var accessTokenFilter = {
2789
2878
  homeAccountId: account.homeAccountId,
2790
2879
  environment: account.environment,
@@ -2792,7 +2881,9 @@ var CacheManager = /** @class */ (function () {
2792
2881
  clientId: clientId,
2793
2882
  realm: account.tenantId,
2794
2883
  target: scopes.printScopesLowerCase(),
2795
- tokenType: authScheme
2884
+ tokenType: authScheme,
2885
+ keyId: request.sshKid,
2886
+ requestedClaimsHash: request.requestedClaimsHash
2796
2887
  };
2797
2888
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
2798
2889
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -2945,6 +3036,14 @@ var CacheManager = /** @class */ (function () {
2945
3036
  CacheManager.prototype.matchTokenType = function (entity, tokenType) {
2946
3037
  return !!(entity.tokenType && entity.tokenType === tokenType);
2947
3038
  };
3039
+ /**
3040
+ * Returns true if the credential's keyId matches the one in the request, false otherwise
3041
+ * @param entity
3042
+ * @param tokenType
3043
+ */
3044
+ CacheManager.prototype.matchKeyId = function (entity, keyId) {
3045
+ return !!(entity.keyId && entity.keyId === keyId);
3046
+ };
2948
3047
  /**
2949
3048
  * returns if a given cache entity is of the type appmetadata
2950
3049
  * @param key
@@ -3093,10 +3192,14 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3093
3192
  });
3094
3193
  });
3095
3194
  };
3195
+ DefaultStorageClass.prototype.updateCredentialCacheKey = function () {
3196
+ var notImplErr = "Storage interface - updateCredentialCacheKey() has not been implemented for the cacheStorage interface.";
3197
+ throw AuthError.createUnexpectedError(notImplErr);
3198
+ };
3096
3199
  return DefaultStorageClass;
3097
3200
  }(CacheManager));
3098
3201
 
3099
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3202
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3100
3203
 
3101
3204
  /*
3102
3205
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3178,7 +3281,7 @@ function buildAuthOptions(authOptions) {
3178
3281
  return __assign({ clientCapabilities: [] }, authOptions);
3179
3282
  }
3180
3283
 
3181
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3284
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3182
3285
 
3183
3286
  /*
3184
3287
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3198,7 +3301,7 @@ var ServerError = /** @class */ (function (_super) {
3198
3301
  return ServerError;
3199
3302
  }(AuthError));
3200
3303
 
3201
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3304
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3202
3305
 
3203
3306
  /*
3204
3307
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3281,10 +3384,12 @@ var ThrottlingUtils = /** @class */ (function () {
3281
3384
  authority: request.authority,
3282
3385
  scopes: request.scopes,
3283
3386
  homeAccountIdentifier: homeAccountIdentifier,
3387
+ claims: request.claims,
3284
3388
  authenticationScheme: request.authenticationScheme,
3285
3389
  resourceRequestMethod: request.resourceRequestMethod,
3286
3390
  resourceRequestUri: request.resourceRequestUri,
3287
- shrClaims: request.shrClaims
3391
+ shrClaims: request.shrClaims,
3392
+ sshKid: request.sshKid
3288
3393
  };
3289
3394
  var key = this.generateThrottlingStorageKey(thumbprint);
3290
3395
  return cacheManager.removeItem(key, CacheSchemaType.THROTTLING);
@@ -3292,7 +3397,7 @@ var ThrottlingUtils = /** @class */ (function () {
3292
3397
  return ThrottlingUtils;
3293
3398
  }());
3294
3399
 
3295
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3400
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3296
3401
 
3297
3402
  /*
3298
3403
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3341,7 +3446,7 @@ var NetworkManager = /** @class */ (function () {
3341
3446
  return NetworkManager;
3342
3447
  }());
3343
3448
 
3344
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3449
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3345
3450
  /*
3346
3451
  * Copyright (c) Microsoft Corporation. All rights reserved.
3347
3452
  * Licensed under the MIT License.
@@ -3352,7 +3457,7 @@ var CcsCredentialType;
3352
3457
  CcsCredentialType["UPN"] = "UPN";
3353
3458
  })(CcsCredentialType || (CcsCredentialType = {}));
3354
3459
 
3355
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3460
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3356
3461
 
3357
3462
  /*
3358
3463
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3441,7 +3546,7 @@ var BaseClient = /** @class */ (function () {
3441
3546
  return BaseClient;
3442
3547
  }());
3443
3548
 
3444
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3549
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3445
3550
 
3446
3551
  /*
3447
3552
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3527,7 +3632,7 @@ var RequestValidator = /** @class */ (function () {
3527
3632
  return RequestValidator;
3528
3633
  }());
3529
3634
 
3530
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3635
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3531
3636
 
3532
3637
  /*
3533
3638
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3831,6 +3936,15 @@ var RequestParameterBuilder = /** @class */ (function () {
3831
3936
  this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
3832
3937
  }
3833
3938
  };
3939
+ /**
3940
+ * add SSH JWK and key ID to query params
3941
+ */
3942
+ RequestParameterBuilder.prototype.addSshJwk = function (sshJwkString) {
3943
+ if (!StringUtils.isEmpty(sshJwkString)) {
3944
+ this.parameters.set(AADServerParamKeys.TOKEN_TYPE, exports.AuthenticationScheme.SSH);
3945
+ this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(sshJwkString));
3946
+ }
3947
+ };
3834
3948
  /**
3835
3949
  * add server telemetry fields
3836
3950
  * @param serverTelemetryManager
@@ -3858,7 +3972,7 @@ var RequestParameterBuilder = /** @class */ (function () {
3858
3972
  return RequestParameterBuilder;
3859
3973
  }());
3860
3974
 
3861
- /*! @azure/msal-common v5.0.0 2021-09-08 */
3975
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3862
3976
 
3863
3977
  /*
3864
3978
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3923,7 +4037,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
3923
4037
  return IdTokenEntity;
3924
4038
  }(CredentialEntity));
3925
4039
 
3926
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4040
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3927
4041
  /*
3928
4042
  * Copyright (c) Microsoft Corporation. All rights reserved.
3929
4043
  * Licensed under the MIT License.
@@ -3973,7 +4087,7 @@ var TimeUtils = /** @class */ (function () {
3973
4087
  return TimeUtils;
3974
4088
  }());
3975
4089
 
3976
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4090
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
3977
4091
 
3978
4092
  /*
3979
4093
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4019,8 +4133,8 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4019
4133
  * @param expiresOn
4020
4134
  * @param extExpiresOn
4021
4135
  */
4022
- AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion) {
4023
- var _a;
4136
+ AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId, requestedClaims, requestedClaimsHash) {
4137
+ var _a, _b;
4024
4138
  var atEntity = new AccessTokenEntity();
4025
4139
  atEntity.homeAccountId = homeAccountId;
4026
4140
  atEntity.credentialType = CredentialType.ACCESS_TOKEN;
@@ -4042,15 +4156,28 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4042
4156
  atEntity.target = scopes;
4043
4157
  atEntity.oboAssertion = oboAssertion;
4044
4158
  atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
4045
- // Create Access Token With AuthScheme instead of regular access token
4046
- if (atEntity.tokenType === exports.AuthenticationScheme.POP) {
4159
+ if (requestedClaims) {
4160
+ atEntity.requestedClaims = requestedClaims;
4161
+ atEntity.requestedClaimsHash = requestedClaimsHash;
4162
+ }
4163
+ /*
4164
+ * Create Access Token With Auth Scheme instead of regular access token
4165
+ * Cast to lower to handle "bearer" from ADFS
4166
+ */
4167
+ if (((_a = atEntity.tokenType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== exports.AuthenticationScheme.BEARER.toLowerCase()) {
4047
4168
  atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
4048
- // Make sure keyId is present and add it to credential
4049
- var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
4050
- if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4051
- throw ClientAuthError.createTokenClaimsRequiredError();
4169
+ switch (atEntity.tokenType) {
4170
+ case exports.AuthenticationScheme.POP:
4171
+ // Make sure keyId is present and add it to credential
4172
+ var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
4173
+ if (!((_b = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _b === void 0 ? void 0 : _b.kid)) {
4174
+ throw ClientAuthError.createTokenClaimsRequiredError();
4175
+ }
4176
+ atEntity.keyId = tokenClaims.cnf.kid;
4177
+ break;
4178
+ case exports.AuthenticationScheme.SSH:
4179
+ atEntity.keyId = keyId;
4052
4180
  }
4053
- atEntity.keyId = tokenClaims.cnf.kid;
4054
4181
  }
4055
4182
  return atEntity;
4056
4183
  };
@@ -4074,7 +4201,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4074
4201
  return AccessTokenEntity;
4075
4202
  }(CredentialEntity));
4076
4203
 
4077
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4204
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4078
4205
 
4079
4206
  /*
4080
4207
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4141,16 +4268,16 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4141
4268
  return RefreshTokenEntity;
4142
4269
  }(CredentialEntity));
4143
4270
 
4144
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4271
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4145
4272
 
4146
4273
  /*
4147
4274
  * Copyright (c) Microsoft Corporation. All rights reserved.
4148
4275
  * Licensed under the MIT License.
4149
4276
  */
4150
4277
  /**
4151
- * InteractionRequiredAuthErrorMessage class containing string constants used by error codes and messages.
4278
+ * InteractionRequiredServerErrorMessage contains string constants used by error codes and messages returned by the server indicating interaction is required
4152
4279
  */
4153
- var InteractionRequiredAuthErrorMessage = [
4280
+ var InteractionRequiredServerErrorMessage = [
4154
4281
  "interaction_required",
4155
4282
  "consent_required",
4156
4283
  "login_required"
@@ -4163,7 +4290,16 @@ var InteractionRequiredAuthSubErrorMessage = [
4163
4290
  "consent_required"
4164
4291
  ];
4165
4292
  /**
4166
- * Error thrown when user interaction is required at the auth server.
4293
+ * Interaction required errors defined by the SDK
4294
+ */
4295
+ var InteractionRequiredAuthErrorMessage = {
4296
+ noTokensFoundError: {
4297
+ code: "no_tokens_found",
4298
+ desc: "No refresh token found in the cache. Please sign-in."
4299
+ }
4300
+ };
4301
+ /**
4302
+ * Error thrown when user interaction is required.
4167
4303
  */
4168
4304
  var InteractionRequiredAuthError = /** @class */ (function (_super) {
4169
4305
  __extends(InteractionRequiredAuthError, _super);
@@ -4173,18 +4309,30 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
4173
4309
  Object.setPrototypeOf(_this, InteractionRequiredAuthError.prototype);
4174
4310
  return _this;
4175
4311
  }
4312
+ /**
4313
+ * Helper function used to determine if an error thrown by the server requires interaction to resolve
4314
+ * @param errorCode
4315
+ * @param errorString
4316
+ * @param subError
4317
+ */
4176
4318
  InteractionRequiredAuthError.isInteractionRequiredError = function (errorCode, errorString, subError) {
4177
- var isInteractionRequiredErrorCode = !!errorCode && InteractionRequiredAuthErrorMessage.indexOf(errorCode) > -1;
4319
+ var isInteractionRequiredErrorCode = !!errorCode && InteractionRequiredServerErrorMessage.indexOf(errorCode) > -1;
4178
4320
  var isInteractionRequiredSubError = !!subError && InteractionRequiredAuthSubErrorMessage.indexOf(subError) > -1;
4179
- var isInteractionRequiredErrorDesc = !!errorString && InteractionRequiredAuthErrorMessage.some(function (irErrorCode) {
4321
+ var isInteractionRequiredErrorDesc = !!errorString && InteractionRequiredServerErrorMessage.some(function (irErrorCode) {
4180
4322
  return errorString.indexOf(irErrorCode) > -1;
4181
4323
  });
4182
4324
  return isInteractionRequiredErrorCode || isInteractionRequiredErrorDesc || isInteractionRequiredSubError;
4183
4325
  };
4326
+ /**
4327
+ * Creates an error thrown when the authorization code required for a token request is null or empty.
4328
+ */
4329
+ InteractionRequiredAuthError.createNoTokensFoundError = function () {
4330
+ return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);
4331
+ };
4184
4332
  return InteractionRequiredAuthError;
4185
- }(ServerError));
4333
+ }(AuthError));
4186
4334
 
4187
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4335
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4188
4336
  /*
4189
4337
  * Copyright (c) Microsoft Corporation. All rights reserved.
4190
4338
  * Licensed under the MIT License.
@@ -4200,7 +4348,7 @@ var CacheRecord = /** @class */ (function () {
4200
4348
  return CacheRecord;
4201
4349
  }());
4202
4350
 
4203
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4351
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4204
4352
 
4205
4353
  /*
4206
4354
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4271,7 +4419,7 @@ var ProtocolUtils = /** @class */ (function () {
4271
4419
  return ProtocolUtils;
4272
4420
  }());
4273
4421
 
4274
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4422
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4275
4423
 
4276
4424
  /*
4277
4425
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4472,7 +4620,7 @@ var UrlString = /** @class */ (function () {
4472
4620
  return UrlString;
4473
4621
  }());
4474
4622
 
4475
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4623
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4476
4624
 
4477
4625
  /*
4478
4626
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4531,14 +4679,14 @@ var PopTokenGenerator = /** @class */ (function () {
4531
4679
  };
4532
4680
  PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
4533
4681
  return __awaiter(this, void 0, void 0, function () {
4534
- var resourceRequestMethod, resourceRequestUri, shrClaims, resourceUrlString, resourceUrlComponents;
4682
+ var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
4535
4683
  return __generator(this, function (_a) {
4536
4684
  switch (_a.label) {
4537
4685
  case 0:
4538
- resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims;
4686
+ resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4539
4687
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4540
4688
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4541
- 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)];
4689
+ 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)];
4542
4690
  case 1: return [2 /*return*/, _a.sent()];
4543
4691
  }
4544
4692
  });
@@ -4547,7 +4695,7 @@ var PopTokenGenerator = /** @class */ (function () {
4547
4695
  return PopTokenGenerator;
4548
4696
  }());
4549
4697
 
4550
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4698
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4551
4699
 
4552
4700
  /*
4553
4701
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4617,7 +4765,7 @@ var AppMetadataEntity = /** @class */ (function () {
4617
4765
  return AppMetadataEntity;
4618
4766
  }());
4619
4767
 
4620
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4768
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4621
4769
  /*
4622
4770
  * Copyright (c) Microsoft Corporation. All rights reserved.
4623
4771
  * Licensed under the MIT License.
@@ -4653,7 +4801,7 @@ var AppMetadataEntity = /** @class */ (function () {
4653
4801
  return TokenCacheContext;
4654
4802
  }());
4655
4803
 
4656
- /*! @azure/msal-common v5.0.0 2021-09-08 */
4804
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4657
4805
 
4658
4806
  /*
4659
4807
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4734,7 +4882,9 @@ var ResponseHandler = /** @class */ (function () {
4734
4882
  if (!!authCodePayload && !!authCodePayload.state) {
4735
4883
  requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, authCodePayload.state);
4736
4884
  }
4737
- cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, idTokenObj, request.scopes, oboAssertion, authCodePayload);
4885
+ // Add keyId from request to serverTokenResponse if defined
4886
+ serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
4887
+ cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload);
4738
4888
  _a.label = 1;
4739
4889
  case 1:
4740
4890
  _a.trys.push([1, , 5, 8]);
@@ -4771,7 +4921,7 @@ var ResponseHandler = /** @class */ (function () {
4771
4921
  _a.sent();
4772
4922
  _a.label = 7;
4773
4923
  case 7: return [7 /*endfinally*/];
4774
- case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj)];
4924
+ case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
4775
4925
  }
4776
4926
  });
4777
4927
  });
@@ -4782,7 +4932,7 @@ var ResponseHandler = /** @class */ (function () {
4782
4932
  * @param idTokenObj
4783
4933
  * @param authority
4784
4934
  */
4785
- ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, idTokenObj, requestScopes, oboAssertion, authCodePayload) {
4935
+ ResponseHandler.prototype.generateCacheRecord = function (serverTokenResponse, authority, reqTimestamp, request, idTokenObj, oboAssertion, authCodePayload) {
4786
4936
  var env = authority.getPreferredCache();
4787
4937
  if (StringUtils.isEmpty(env)) {
4788
4938
  throw ClientAuthError.createInvalidCacheEnvironmentError();
@@ -4798,7 +4948,7 @@ var ResponseHandler = /** @class */ (function () {
4798
4948
  var cachedAccessToken = null;
4799
4949
  if (!StringUtils.isEmpty(serverTokenResponse.access_token)) {
4800
4950
  // If scopes not returned in server response, use request scopes
4801
- var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(requestScopes || []);
4951
+ var responseScopes = serverTokenResponse.scope ? ScopeSet.fromString(serverTokenResponse.scope) : new ScopeSet(request.scopes || []);
4802
4952
  /*
4803
4953
  * Use timestamp calculated before request
4804
4954
  * Server may return timestamps as strings, parse to numbers if so.
@@ -4810,7 +4960,7 @@ var ResponseHandler = /** @class */ (function () {
4810
4960
  var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
4811
4961
  var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
4812
4962
  // non AAD scenarios can have empty realm
4813
- 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);
4963
+ 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);
4814
4964
  }
4815
4965
  // refreshToken
4816
4966
  var cachedRefreshToken = null;
@@ -4857,7 +5007,7 @@ var ResponseHandler = /** @class */ (function () {
4857
5007
  * @param fromTokenCache
4858
5008
  * @param stateString
4859
5009
  */
4860
- ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState) {
5010
+ ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
4861
5011
  var _a, _b, _c;
4862
5012
  return __awaiter(this, void 0, void 0, function () {
4863
5013
  var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, uid, tid;
@@ -4906,7 +5056,8 @@ var ResponseHandler = /** @class */ (function () {
4906
5056
  tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
4907
5057
  state: requestState ? requestState.userRequestState : Constants.EMPTY_STRING,
4908
5058
  cloudGraphHostName: ((_b = cacheRecord.account) === null || _b === void 0 ? void 0 : _b.cloudGraphHostName) || Constants.EMPTY_STRING,
4909
- msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING
5059
+ msGraphHost: ((_c = cacheRecord.account) === null || _c === void 0 ? void 0 : _c.msGraphHost) || Constants.EMPTY_STRING,
5060
+ code: code
4910
5061
  }];
4911
5062
  }
4912
5063
  });
@@ -4915,7 +5066,7 @@ var ResponseHandler = /** @class */ (function () {
4915
5066
  return ResponseHandler;
4916
5067
  }());
4917
5068
 
4918
- /*! @azure/msal-common v5.0.0 2021-09-08 */
5069
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
4919
5070
 
4920
5071
  /*
4921
5072
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4927,7 +5078,10 @@ var ResponseHandler = /** @class */ (function () {
4927
5078
  var AuthorizationCodeClient = /** @class */ (function (_super) {
4928
5079
  __extends(AuthorizationCodeClient, _super);
4929
5080
  function AuthorizationCodeClient(configuration) {
4930
- return _super.call(this, configuration) || this;
5081
+ var _this = _super.call(this, configuration) || this;
5082
+ // Flag to indicate if client is for hybrid spa auth code redemption
5083
+ _this.includeRedirectUri = true;
5084
+ return _this;
4931
5085
  }
4932
5086
  /**
4933
5087
  * Creates the URL of the authorization request letting the user input credentials and consent to the
@@ -5027,10 +5181,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5027
5181
  clientId: this.config.authOptions.clientId,
5028
5182
  authority: authority.canonicalAuthority,
5029
5183
  scopes: request.scopes,
5184
+ claims: request.claims,
5030
5185
  authenticationScheme: request.authenticationScheme,
5031
5186
  resourceRequestMethod: request.resourceRequestMethod,
5032
5187
  resourceRequestUri: request.resourceRequestUri,
5033
- shrClaims: request.shrClaims
5188
+ shrClaims: request.shrClaims,
5189
+ sshKid: request.sshKid
5034
5190
  };
5035
5191
  return [4 /*yield*/, this.createTokenRequestBody(request)];
5036
5192
  case 1:
@@ -5074,13 +5230,24 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5074
5230
  AuthorizationCodeClient.prototype.createTokenRequestBody = function (request) {
5075
5231
  return __awaiter(this, void 0, void 0, function () {
5076
5232
  var parameterBuilder, clientAssertion, popTokenGenerator, cnfString, correlationId, ccsCred, clientInfo, clientInfo;
5077
- return __generator(this, function (_a) {
5078
- switch (_a.label) {
5233
+ var _a;
5234
+ return __generator(this, function (_b) {
5235
+ switch (_b.label) {
5079
5236
  case 0:
5080
5237
  parameterBuilder = new RequestParameterBuilder();
5081
5238
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5082
- // validate the redirectUri (to be a non null value)
5083
- parameterBuilder.addRedirectUri(request.redirectUri);
5239
+ /*
5240
+ * For hybrid spa flow, there will be a code but no verifier
5241
+ * In this scenario, don't include redirect uri as auth code will not be bound to redirect URI
5242
+ */
5243
+ if (!this.includeRedirectUri) {
5244
+ // Just validate
5245
+ RequestValidator.validateRedirectUri(request.redirectUri);
5246
+ }
5247
+ else {
5248
+ // Validate and include redirect uri
5249
+ parameterBuilder.addRedirectUri(request.redirectUri);
5250
+ }
5084
5251
  // Add scope array, parameter builder will add default scopes and dedupe
5085
5252
  parameterBuilder.addScopes(request.scopes);
5086
5253
  // add code: user set, not validated
@@ -5109,10 +5276,20 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5109
5276
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5110
5277
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5111
5278
  case 1:
5112
- cnfString = _a.sent();
5279
+ cnfString = _b.sent();
5113
5280
  parameterBuilder.addPopToken(cnfString);
5114
- _a.label = 2;
5281
+ return [3 /*break*/, 3];
5115
5282
  case 2:
5283
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
5284
+ if (request.sshJwk) {
5285
+ parameterBuilder.addSshJwk(request.sshJwk);
5286
+ }
5287
+ else {
5288
+ throw ClientConfigurationError.createMissingSshJwkError();
5289
+ }
5290
+ }
5291
+ _b.label = 3;
5292
+ case 3:
5116
5293
  correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5117
5294
  parameterBuilder.addCorrelationId(correlationId);
5118
5295
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
@@ -5151,6 +5328,15 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5151
5328
  break;
5152
5329
  }
5153
5330
  }
5331
+ if (request.tokenBodyParameters) {
5332
+ parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
5333
+ }
5334
+ // Add hybrid spa parameters if not already provided
5335
+ if (request.enableSpaAuthorizationCode && (!request.tokenBodyParameters || !request.tokenBodyParameters[AADServerParamKeys.RETURN_SPA_CODE])) {
5336
+ parameterBuilder.addExtraQueryParameters((_a = {},
5337
+ _a[AADServerParamKeys.RETURN_SPA_CODE] = "1",
5338
+ _a));
5339
+ }
5154
5340
  return [2 /*return*/, parameterBuilder.createQueryString()];
5155
5341
  }
5156
5342
  });
@@ -5288,7 +5474,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5288
5474
  return AuthorizationCodeClient;
5289
5475
  }(BaseClient));
5290
5476
 
5291
- /*! @azure/msal-common v5.0.0 2021-09-08 */
5477
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
5292
5478
 
5293
5479
  /*
5294
5480
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5342,7 +5528,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5342
5528
  return [2 /*return*/, this.acquireTokenWithCachedRefreshToken(request, true)];
5343
5529
  }
5344
5530
  catch (e) {
5345
- noFamilyRTInCache = e instanceof ClientAuthError && e.errorCode === ClientAuthErrorMessage.noTokensFoundError.code;
5531
+ noFamilyRTInCache = e instanceof InteractionRequiredAuthError && e.errorCode === InteractionRequiredAuthErrorMessage.noTokensFoundError.code;
5346
5532
  clientMismatchErrorWithFamilyRT = e instanceof ServerError && e.errorCode === Errors.INVALID_GRANT_ERROR && e.subError === Errors.CLIENT_MISMATCH_ERROR;
5347
5533
  // if family Refresh Token (FRT) cache acquisition fails or if client_mismatch error is seen with FRT, reattempt with application Refresh Token (ART)
5348
5534
  if (noFamilyRTInCache || clientMismatchErrorWithFamilyRT) {
@@ -5370,7 +5556,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5370
5556
  refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
5371
5557
  // no refresh Token
5372
5558
  if (!refreshToken) {
5373
- throw ClientAuthError.createNoTokensFoundError();
5559
+ throw InteractionRequiredAuthError.createNoTokensFoundError();
5374
5560
  }
5375
5561
  refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || exports.AuthenticationScheme.BEARER, ccsCredential: {
5376
5562
  credential: request.account.homeAccountId,
@@ -5399,10 +5585,12 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5399
5585
  clientId: this.config.authOptions.clientId,
5400
5586
  authority: authority.canonicalAuthority,
5401
5587
  scopes: request.scopes,
5588
+ claims: request.claims,
5402
5589
  authenticationScheme: request.authenticationScheme,
5403
5590
  resourceRequestMethod: request.resourceRequestMethod,
5404
5591
  resourceRequestUri: request.resourceRequestUri,
5405
- shrClaims: request.shrClaims
5592
+ shrClaims: request.shrClaims,
5593
+ sshKid: request.sshKid
5406
5594
  };
5407
5595
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
5408
5596
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
@@ -5427,9 +5615,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5427
5615
  */
5428
5616
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
5429
5617
  return __awaiter(this, void 0, void 0, function () {
5430
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, _a, _b, clientInfo;
5431
- return __generator(this, function (_c) {
5432
- switch (_c.label) {
5618
+ var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
5619
+ return __generator(this, function (_a) {
5620
+ switch (_a.label) {
5433
5621
  case 0:
5434
5622
  parameterBuilder = new RequestParameterBuilder();
5435
5623
  parameterBuilder.addClientId(this.config.authOptions.clientId);
@@ -5454,12 +5642,22 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5454
5642
  }
5455
5643
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5456
5644
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5457
- _b = (_a = parameterBuilder).addPopToken;
5458
5645
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5459
5646
  case 1:
5460
- _b.apply(_a, [_c.sent()]);
5461
- _c.label = 2;
5647
+ cnfString = _a.sent();
5648
+ parameterBuilder.addPopToken(cnfString);
5649
+ return [3 /*break*/, 3];
5462
5650
  case 2:
5651
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
5652
+ if (request.sshJwk) {
5653
+ parameterBuilder.addSshJwk(request.sshJwk);
5654
+ }
5655
+ else {
5656
+ throw ClientConfigurationError.createMissingSshJwkError();
5657
+ }
5658
+ }
5659
+ _a.label = 3;
5660
+ case 3:
5463
5661
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
5464
5662
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
5465
5663
  }
@@ -5487,7 +5685,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5487
5685
  return RefreshTokenClient;
5488
5686
  }(BaseClient));
5489
5687
 
5490
- /*! @azure/msal-common v5.0.0 2021-09-08 */
5688
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
5491
5689
 
5492
5690
  /*
5493
5691
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5533,7 +5731,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
5533
5731
  SilentFlowClient.prototype.acquireCachedToken = function (request) {
5534
5732
  var _a, _b, _c, _d;
5535
5733
  return __awaiter(this, void 0, void 0, function () {
5536
- var requestScopes, environment, authScheme, cacheRecord;
5734
+ var environment, cacheRecord;
5537
5735
  return __generator(this, function (_e) {
5538
5736
  switch (_e.label) {
5539
5737
  case 0:
@@ -5541,37 +5739,35 @@ var SilentFlowClient = /** @class */ (function (_super) {
5541
5739
  if (!request) {
5542
5740
  throw ClientConfigurationError.createEmptyTokenRequestError();
5543
5741
  }
5544
- // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
5545
- if (!request.account) {
5546
- throw ClientAuthError.createNoAccountInSilentRequestError();
5547
- }
5548
- requestScopes = new ScopeSet(request.scopes || []);
5549
- environment = request.authority || this.authority.getPreferredCache();
5550
- authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
5551
- cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
5552
5742
  if (request.forceRefresh) {
5553
5743
  // Must refresh due to present force_refresh flag.
5554
5744
  (_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
5745
+ this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
5555
5746
  throw ClientAuthError.createRefreshRequiredError();
5556
5747
  }
5557
- else if (!cacheRecord.accessToken) {
5748
+ // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
5749
+ if (!request.account) {
5750
+ throw ClientAuthError.createNoAccountInSilentRequestError();
5751
+ }
5752
+ environment = request.authority || this.authority.getPreferredCache();
5753
+ cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, request, environment);
5754
+ if (!cacheRecord.accessToken) {
5558
5755
  // Must refresh due to non-existent access_token.
5559
5756
  (_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
5757
+ this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
5560
5758
  throw ClientAuthError.createRefreshRequiredError();
5561
5759
  }
5562
5760
  else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
5563
5761
  TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
5564
5762
  // Must refresh due to expired access_token.
5565
5763
  (_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
5764
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
5566
5765
  throw ClientAuthError.createRefreshRequiredError();
5567
5766
  }
5568
5767
  else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
5569
5768
  // Must refresh due to the refresh_in value.
5570
5769
  (_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
5571
- throw ClientAuthError.createRefreshRequiredError();
5572
- }
5573
- else if (!StringUtils.isEmptyObj(request.claims)) {
5574
- // Must refresh due to request parameters.
5770
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
5575
5771
  throw ClientAuthError.createRefreshRequiredError();
5576
5772
  }
5577
5773
  if (this.config.serverTelemetryManager) {
@@ -5605,7 +5801,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
5605
5801
  return SilentFlowClient;
5606
5802
  }(BaseClient));
5607
5803
 
5608
- /*! @azure/msal-common v5.0.0 2021-09-08 */
5804
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
5609
5805
  /*
5610
5806
  * Copyright (c) Microsoft Corporation. All rights reserved.
5611
5807
  * Licensed under the MIT License.
@@ -5613,11 +5809,10 @@ var SilentFlowClient = /** @class */ (function (_super) {
5613
5809
  function isOpenIdConfigResponse(response) {
5614
5810
  return (response.hasOwnProperty("authorization_endpoint") &&
5615
5811
  response.hasOwnProperty("token_endpoint") &&
5616
- response.hasOwnProperty("end_session_endpoint") &&
5617
5812
  response.hasOwnProperty("issuer"));
5618
5813
  }
5619
5814
 
5620
- /*! @azure/msal-common v5.0.0 2021-09-08 */
5815
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
5621
5816
  /*
5622
5817
  * Copyright (c) Microsoft Corporation. All rights reserved.
5623
5818
  * Licensed under the MIT License.
@@ -5631,7 +5826,7 @@ exports.ProtocolMode = void 0;
5631
5826
  ProtocolMode["OIDC"] = "OIDC";
5632
5827
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5633
5828
 
5634
- /*! @azure/msal-common v5.0.0 2021-09-08 */
5829
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
5635
5830
 
5636
5831
  /*
5637
5832
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5698,7 +5893,6 @@ var AuthorityMetadataEntity = /** @class */ (function () {
5698
5893
  entity.hasOwnProperty("canonical_authority") &&
5699
5894
  entity.hasOwnProperty("authorization_endpoint") &&
5700
5895
  entity.hasOwnProperty("token_endpoint") &&
5701
- entity.hasOwnProperty("end_session_endpoint") &&
5702
5896
  entity.hasOwnProperty("issuer") &&
5703
5897
  entity.hasOwnProperty("aliasesFromNetwork") &&
5704
5898
  entity.hasOwnProperty("endpointsFromNetwork") &&
@@ -5707,7 +5901,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
5707
5901
  return AuthorityMetadataEntity;
5708
5902
  }());
5709
5903
 
5710
- /*! @azure/msal-common v5.0.0 2021-09-08 */
5904
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
5711
5905
  /*
5712
5906
  * Copyright (c) Microsoft Corporation. All rights reserved.
5713
5907
  * Licensed under the MIT License.
@@ -5717,7 +5911,7 @@ function isCloudInstanceDiscoveryResponse(response) {
5717
5911
  response.hasOwnProperty("metadata"));
5718
5912
  }
5719
5913
 
5720
- /*! @azure/msal-common v5.0.0 2021-09-08 */
5914
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
5721
5915
 
5722
5916
  /*
5723
5917
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5831,7 +6025,7 @@ var RegionDiscovery = /** @class */ (function () {
5831
6025
  return RegionDiscovery;
5832
6026
  }());
5833
6027
 
5834
- /*! @azure/msal-common v5.0.0 2021-09-08 */
6028
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
5835
6029
 
5836
6030
  /*
5837
6031
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5985,6 +6179,10 @@ var Authority = /** @class */ (function () {
5985
6179
  */
5986
6180
  get: function () {
5987
6181
  if (this.discoveryComplete()) {
6182
+ // ROPC policies may not have end_session_endpoint set
6183
+ if (!this.metadata.end_session_endpoint) {
6184
+ throw ClientAuthError.createLogoutNotSupportedError();
6185
+ }
5988
6186
  var endpoint = this.replacePath(this.metadata.end_session_endpoint);
5989
6187
  return this.replaceTenant(endpoint);
5990
6188
  }
@@ -6385,13 +6583,15 @@ var Authority = /** @class */ (function () {
6385
6583
  metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
6386
6584
  // TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
6387
6585
  metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, "allowestsrnonmsi=true");
6388
- metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
6586
+ if (metadata.end_session_endpoint) {
6587
+ metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
6588
+ }
6389
6589
  return metadata;
6390
6590
  };
6391
6591
  return Authority;
6392
6592
  }());
6393
6593
 
6394
- /*! @azure/msal-common v5.0.0 2021-09-08 */
6594
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
6395
6595
 
6396
6596
  /*
6397
6597
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6452,7 +6652,7 @@ var AuthorityFactory = /** @class */ (function () {
6452
6652
  return AuthorityFactory;
6453
6653
  }());
6454
6654
 
6455
- /*! @azure/msal-common v5.0.0 2021-09-08 */
6655
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
6456
6656
 
6457
6657
  /*
6458
6658
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6483,7 +6683,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
6483
6683
  return ServerTelemetryEntity;
6484
6684
  }());
6485
6685
 
6486
- /*! @azure/msal-common v5.0.0 2021-09-08 */
6686
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
6487
6687
 
6488
6688
  /*
6489
6689
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6511,7 +6711,7 @@ var ThrottlingEntity = /** @class */ (function () {
6511
6711
  return ThrottlingEntity;
6512
6712
  }());
6513
6713
 
6514
- /*! @azure/msal-common v5.0.0 2021-09-08 */
6714
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
6515
6715
 
6516
6716
  /*
6517
6717
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6528,7 +6728,66 @@ var StubbedNetworkModule = {
6528
6728
  }
6529
6729
  };
6530
6730
 
6531
- /*! @azure/msal-common v5.0.0 2021-09-08 */
6731
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
6732
+
6733
+ /*
6734
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6735
+ * Licensed under the MIT License.
6736
+ */
6737
+ /**
6738
+ * This is a helper class that parses supported HTTP response authentication headers to extract and return
6739
+ * header challenge values that can be used outside the basic authorization flows.
6740
+ */
6741
+ var AuthenticationHeaderParser = /** @class */ (function () {
6742
+ function AuthenticationHeaderParser(headers) {
6743
+ this.headers = headers;
6744
+ }
6745
+ /**
6746
+ * This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
6747
+ * @returns
6748
+ */
6749
+ AuthenticationHeaderParser.prototype.getShrNonce = function () {
6750
+ // Attempt to parse nonce from Authentiacation-Info
6751
+ var authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
6752
+ if (authenticationInfo) {
6753
+ var authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
6754
+ if (authenticationInfoChallenges.nextnonce) {
6755
+ return authenticationInfoChallenges.nextnonce;
6756
+ }
6757
+ throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
6758
+ }
6759
+ // Attempt to parse nonce from WWW-Authenticate
6760
+ var wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
6761
+ if (wwwAuthenticate) {
6762
+ var wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
6763
+ if (wwwAuthenticateChallenges.nonce) {
6764
+ return wwwAuthenticateChallenges.nonce;
6765
+ }
6766
+ throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
6767
+ }
6768
+ // If neither header is present, throw missing headers error
6769
+ throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
6770
+ };
6771
+ /**
6772
+ * Parses an HTTP header's challenge set into a key/value map.
6773
+ * @param header
6774
+ * @returns
6775
+ */
6776
+ AuthenticationHeaderParser.prototype.parseChallenges = function (header) {
6777
+ var schemeSeparator = header.indexOf(" ");
6778
+ var challenges = header.substr(schemeSeparator + 1).split(",");
6779
+ var challengeMap = {};
6780
+ challenges.forEach(function (challenge) {
6781
+ var _a = challenge.split("="), key = _a[0], value = _a[1];
6782
+ // Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
6783
+ challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
6784
+ });
6785
+ return challengeMap;
6786
+ };
6787
+ return AuthenticationHeaderParser;
6788
+ }());
6789
+
6790
+ /*! @azure/msal-common v6.0.0 2022-01-04 */
6532
6791
 
6533
6792
  /*
6534
6793
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6781,6 +7040,7 @@ exports.ApiId = void 0;
6781
7040
  ApiId[ApiId["ssoSilent"] = 863] = "ssoSilent";
6782
7041
  ApiId[ApiId["acquireTokenSilent_authCode"] = 864] = "acquireTokenSilent_authCode";
6783
7042
  ApiId[ApiId["handleRedirectPromise"] = 865] = "handleRedirectPromise";
7043
+ ApiId[ApiId["acquireTokenByCode"] = 866] = "acquireTokenByCode";
6784
7044
  ApiId[ApiId["acquireTokenSilent_silentFlow"] = 61] = "acquireTokenSilent_silentFlow";
6785
7045
  ApiId[ApiId["logout"] = 961] = "logout";
6786
7046
  ApiId[ApiId["logoutPopup"] = 962] = "logoutPopup";
@@ -6841,7 +7101,11 @@ exports.WrapperSKU = void 0;
6841
7101
  (function (WrapperSKU) {
6842
7102
  WrapperSKU["React"] = "@azure/msal-react";
6843
7103
  WrapperSKU["Angular"] = "@azure/msal-angular";
6844
- })(exports.WrapperSKU || (exports.WrapperSKU = {}));
7104
+ })(exports.WrapperSKU || (exports.WrapperSKU = {}));
7105
+ // DatabaseStorage Constants
7106
+ var DB_NAME = "msal.db";
7107
+ var DB_VERSION = 1;
7108
+ var DB_TABLE_NAME = DB_NAME + ".keys";
6845
7109
 
6846
7110
  /*
6847
7111
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7303,10 +7567,6 @@ var BrowserAuthErrorMessage = {
7303
7567
  code: "iframe_closed_prematurely",
7304
7568
  desc: "The iframe being monitored was closed prematurely."
7305
7569
  },
7306
- silentSSOInsufficientInfoError: {
7307
- code: "silent_sso_error",
7308
- desc: "Silent SSO could not be completed - insufficient information was provided. Please provide either a loginHint or sid."
7309
- },
7310
7570
  silentLogoutUnsupportedError: {
7311
7571
  code: "silent_logout_unsupported",
7312
7572
  desc: "Silent logout not supported. Please call logoutRedirect or logoutPopup instead."
@@ -7321,7 +7581,7 @@ var BrowserAuthErrorMessage = {
7321
7581
  },
7322
7582
  noTokenRequestCacheError: {
7323
7583
  code: "no_token_request_cache_error",
7324
- desc: "No token request in found in cache."
7584
+ desc: "No token request found in cache."
7325
7585
  },
7326
7586
  unableToParseTokenRequestCacheError: {
7327
7587
  code: "unable_to_parse_token_request_cache_error",
@@ -7370,6 +7630,14 @@ var BrowserAuthErrorMessage = {
7370
7630
  signingKeyNotFoundInStorage: {
7371
7631
  code: "crypto_key_not_found",
7372
7632
  desc: "Cryptographic Key or Keypair not found in browser storage."
7633
+ },
7634
+ authCodeRequired: {
7635
+ code: "auth_code_required",
7636
+ desc: "An authorization code must be provided (as the `code` property on the request) to this flow."
7637
+ },
7638
+ databaseUnavailable: {
7639
+ code: "database_unavailable",
7640
+ 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."
7373
7641
  }
7374
7642
  };
7375
7643
  /**
@@ -7507,12 +7775,6 @@ var BrowserAuthError = /** @class */ (function (_super) {
7507
7775
  BrowserAuthError.createIframeClosedPrematurelyError = function () {
7508
7776
  return new BrowserAuthError(BrowserAuthErrorMessage.iframeClosedPrematurelyError.code, BrowserAuthErrorMessage.iframeClosedPrematurelyError.desc);
7509
7777
  };
7510
- /**
7511
- * Creates an error thrown when the login_hint, sid or account object is not provided in the ssoSilent API.
7512
- */
7513
- BrowserAuthError.createSilentSSOInsufficientInfoError = function () {
7514
- return new BrowserAuthError(BrowserAuthErrorMessage.silentSSOInsufficientInfoError.code, BrowserAuthErrorMessage.silentSSOInsufficientInfoError.desc);
7515
- };
7516
7778
  /**
7517
7779
  * Creates an error thrown when the logout API is called on any of the silent interaction clients
7518
7780
  */
@@ -7609,6 +7871,18 @@ var BrowserAuthError = /** @class */ (function (_super) {
7609
7871
  BrowserAuthError.createSigningKeyNotFoundInStorageError = function (keyId) {
7610
7872
  return new BrowserAuthError(BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code, BrowserAuthErrorMessage.signingKeyNotFoundInStorage.desc + " | No match found for KeyId: " + keyId);
7611
7873
  };
7874
+ /**
7875
+ * Create an error when an authorization code is required but not provided
7876
+ */
7877
+ BrowserAuthError.createAuthCodeRequiredError = function () {
7878
+ return new BrowserAuthError(BrowserAuthErrorMessage.authCodeRequired.code, BrowserAuthErrorMessage.authCodeRequired.desc);
7879
+ };
7880
+ /**
7881
+ * Create an error when IndexedDB is unavailable
7882
+ */
7883
+ BrowserAuthError.createDatabaseUnavailableError = function () {
7884
+ return new BrowserAuthError(BrowserAuthErrorMessage.databaseUnavailable.code, BrowserAuthErrorMessage.databaseUnavailable.desc);
7885
+ };
7612
7886
  return BrowserAuthError;
7613
7887
  }(AuthError));
7614
7888
 
@@ -7711,7 +7985,8 @@ var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
7711
7985
  * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
7712
7986
  */
7713
7987
  var BrowserCrypto = /** @class */ (function () {
7714
- function BrowserCrypto() {
7988
+ function BrowserCrypto(logger) {
7989
+ this.logger = logger;
7715
7990
  if (!(this.hasCryptoAPI())) {
7716
7991
  throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto or msCrypto object not available.");
7717
7992
  }
@@ -7970,10 +8245,10 @@ var BrowserCrypto = /** @class */ (function () {
7970
8245
  * Storage wrapper for IndexedDB storage in browsers: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
7971
8246
  */
7972
8247
  var DatabaseStorage = /** @class */ (function () {
7973
- function DatabaseStorage(dbName, tableName, version) {
7974
- this.dbName = dbName;
7975
- this.tableName = tableName;
7976
- this.version = version;
8248
+ function DatabaseStorage() {
8249
+ this.dbName = DB_NAME;
8250
+ this.version = DB_VERSION;
8251
+ this.tableName = DB_TABLE_NAME;
7977
8252
  this.dbOpen = false;
7978
8253
  }
7979
8254
  /**
@@ -7984,7 +8259,6 @@ var DatabaseStorage = /** @class */ (function () {
7984
8259
  var _this = this;
7985
8260
  return __generator$1(this, function (_a) {
7986
8261
  return [2 /*return*/, new Promise(function (resolve, reject) {
7987
- // TODO: Add timeouts?
7988
8262
  var openDB = window.indexedDB.open(_this.dbName, _this.version);
7989
8263
  openDB.addEventListener("upgradeneeded", function (e) {
7990
8264
  var event = e;
@@ -7996,40 +8270,53 @@ var DatabaseStorage = /** @class */ (function () {
7996
8270
  _this.dbOpen = true;
7997
8271
  resolve();
7998
8272
  });
7999
- openDB.addEventListener("error", function (error) { return reject(error); });
8273
+ openDB.addEventListener("error", function () { return reject(BrowserAuthError.createDatabaseUnavailableError()); });
8000
8274
  })];
8001
8275
  });
8002
8276
  });
8003
8277
  };
8004
8278
  /**
8005
- * Retrieves item from IndexedDB instance.
8006
- * @param key
8279
+ * Opens database if it's not already open
8007
8280
  */
8008
- DatabaseStorage.prototype.get = function (key) {
8281
+ DatabaseStorage.prototype.validateDbIsOpen = function () {
8009
8282
  return __awaiter$1(this, void 0, void 0, function () {
8010
- var _this = this;
8011
8283
  return __generator$1(this, function (_a) {
8012
8284
  switch (_a.label) {
8013
8285
  case 0:
8014
8286
  if (!!this.dbOpen) return [3 /*break*/, 2];
8015
8287
  return [4 /*yield*/, this.open()];
8288
+ case 1: return [2 /*return*/, _a.sent()];
8289
+ case 2: return [2 /*return*/];
8290
+ }
8291
+ });
8292
+ });
8293
+ };
8294
+ /**
8295
+ * Retrieves item from IndexedDB instance.
8296
+ * @param key
8297
+ */
8298
+ DatabaseStorage.prototype.getItem = function (key) {
8299
+ return __awaiter$1(this, void 0, void 0, function () {
8300
+ var _this = this;
8301
+ return __generator$1(this, function (_a) {
8302
+ switch (_a.label) {
8303
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8016
8304
  case 1:
8017
8305
  _a.sent();
8018
- _a.label = 2;
8019
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8020
- // TODO: Add timeouts?
8021
- if (!_this.db) {
8022
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8023
- }
8024
- var transaction = _this.db.transaction([_this.tableName], "readonly");
8025
- var objectStore = transaction.objectStore(_this.tableName);
8026
- var dbGet = objectStore.get(key);
8027
- dbGet.addEventListener("success", function (e) {
8028
- var event = e;
8029
- resolve(event.target.result);
8030
- });
8031
- dbGet.addEventListener("error", function (e) { return reject(e); });
8032
- })];
8306
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8307
+ // TODO: Add timeouts?
8308
+ if (!_this.db) {
8309
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8310
+ }
8311
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8312
+ var objectStore = transaction.objectStore(_this.tableName);
8313
+ var dbGet = objectStore.get(key);
8314
+ dbGet.addEventListener("success", function (e) {
8315
+ var event = e;
8316
+ resolve(event.target.result);
8317
+ });
8318
+ dbGet.addEventListener("error", function (e) { return reject(e); });
8319
+ })];
8033
8320
  }
8034
8321
  });
8035
8322
  });
@@ -8039,31 +8326,25 @@ var DatabaseStorage = /** @class */ (function () {
8039
8326
  * @param key
8040
8327
  * @param payload
8041
8328
  */
8042
- DatabaseStorage.prototype.put = function (key, payload) {
8329
+ DatabaseStorage.prototype.setItem = function (key, payload) {
8043
8330
  return __awaiter$1(this, void 0, void 0, function () {
8044
8331
  var _this = this;
8045
8332
  return __generator$1(this, function (_a) {
8046
8333
  switch (_a.label) {
8047
- case 0:
8048
- if (!!this.dbOpen) return [3 /*break*/, 2];
8049
- return [4 /*yield*/, this.open()];
8334
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8050
8335
  case 1:
8051
8336
  _a.sent();
8052
- _a.label = 2;
8053
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8054
- // TODO: Add timeouts?
8055
- if (!_this.db) {
8056
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8057
- }
8058
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8059
- var objectStore = transaction.objectStore(_this.tableName);
8060
- var dbPut = objectStore.put(payload, key);
8061
- dbPut.addEventListener("success", function (e) {
8062
- var event = e;
8063
- resolve(event.target.result);
8064
- });
8065
- dbPut.addEventListener("error", function (e) { return reject(e); });
8066
- })];
8337
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8338
+ // TODO: Add timeouts?
8339
+ if (!_this.db) {
8340
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8341
+ }
8342
+ var transaction = _this.db.transaction([_this.tableName], "readwrite");
8343
+ var objectStore = transaction.objectStore(_this.tableName);
8344
+ var dbPut = objectStore.put(payload, key);
8345
+ dbPut.addEventListener("success", function () { return resolve(); });
8346
+ dbPut.addEventListener("error", function (e) { return reject(e); });
8347
+ })];
8067
8348
  }
8068
8349
  });
8069
8350
  });
@@ -8072,62 +8353,101 @@ var DatabaseStorage = /** @class */ (function () {
8072
8353
  * Removes item from IndexedDB under given key
8073
8354
  * @param key
8074
8355
  */
8075
- DatabaseStorage.prototype.delete = function (key) {
8356
+ DatabaseStorage.prototype.removeItem = function (key) {
8076
8357
  return __awaiter$1(this, void 0, void 0, function () {
8077
8358
  var _this = this;
8078
8359
  return __generator$1(this, function (_a) {
8079
8360
  switch (_a.label) {
8080
- case 0:
8081
- if (!!this.dbOpen) return [3 /*break*/, 2];
8082
- return [4 /*yield*/, this.open()];
8361
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8083
8362
  case 1:
8084
8363
  _a.sent();
8085
- _a.label = 2;
8086
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8087
- if (!_this.db) {
8088
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8089
- }
8090
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8091
- var objectStore = transaction.objectStore(_this.tableName);
8092
- var dbDelete = objectStore.delete(key);
8093
- dbDelete.addEventListener("success", function (e) {
8094
- var event = e;
8095
- resolve(event.target.result === undefined);
8096
- });
8097
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8098
- })];
8364
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8365
+ if (!_this.db) {
8366
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8367
+ }
8368
+ var transaction = _this.db.transaction([_this.tableName], "readwrite");
8369
+ var objectStore = transaction.objectStore(_this.tableName);
8370
+ var dbDelete = objectStore.delete(key);
8371
+ dbDelete.addEventListener("success", function () { return resolve(); });
8372
+ dbDelete.addEventListener("error", function (e) { return reject(e); });
8373
+ })];
8099
8374
  }
8100
8375
  });
8101
8376
  });
8102
8377
  };
8103
- DatabaseStorage.prototype.clear = function () {
8378
+ /**
8379
+ * Get all the keys from the storage object as an iterable array of strings.
8380
+ */
8381
+ DatabaseStorage.prototype.getKeys = function () {
8104
8382
  return __awaiter$1(this, void 0, void 0, function () {
8105
8383
  var _this = this;
8106
8384
  return __generator$1(this, function (_a) {
8107
8385
  switch (_a.label) {
8108
- case 0:
8109
- if (!!this.dbOpen) return [3 /*break*/, 2];
8110
- return [4 /*yield*/, this.open()];
8386
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8111
8387
  case 1:
8112
8388
  _a.sent();
8113
- _a.label = 2;
8114
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8115
- if (!_this.db) {
8116
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8117
- }
8118
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8119
- var objectStore = transaction.objectStore(_this.tableName);
8120
- var dbDelete = objectStore.clear();
8121
- dbDelete.addEventListener("success", function (e) {
8122
- var event = e;
8123
- resolve(event.target.result === undefined);
8124
- });
8125
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8126
- })];
8389
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8390
+ if (!_this.db) {
8391
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8392
+ }
8393
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8394
+ var objectStore = transaction.objectStore(_this.tableName);
8395
+ var dbGetKeys = objectStore.getAllKeys();
8396
+ dbGetKeys.addEventListener("success", function (e) {
8397
+ var event = e;
8398
+ resolve(event.target.result);
8399
+ });
8400
+ dbGetKeys.addEventListener("error", function (e) { return reject(e); });
8401
+ })];
8402
+ }
8403
+ });
8404
+ });
8405
+ };
8406
+ /**
8407
+ *
8408
+ * Checks whether there is an object under the search key in the object store
8409
+ */
8410
+ DatabaseStorage.prototype.containsKey = function (key) {
8411
+ return __awaiter$1(this, void 0, void 0, function () {
8412
+ var _this = this;
8413
+ return __generator$1(this, function (_a) {
8414
+ switch (_a.label) {
8415
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8416
+ case 1:
8417
+ _a.sent();
8418
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8419
+ if (!_this.db) {
8420
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8421
+ }
8422
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8423
+ var objectStore = transaction.objectStore(_this.tableName);
8424
+ var dbContainsKey = objectStore.count(key);
8425
+ dbContainsKey.addEventListener("success", function (e) {
8426
+ var event = e;
8427
+ resolve(event.target.result === 1);
8428
+ });
8429
+ dbContainsKey.addEventListener("error", function (e) { return reject(e); });
8430
+ })];
8127
8431
  }
8128
8432
  });
8129
8433
  });
8130
8434
  };
8435
+ /**
8436
+ * Deletes the MSAL database. The database is deleted rather than cleared to make it possible
8437
+ * for client applications to downgrade to a previous MSAL version without worrying about forward compatibility issues
8438
+ * with IndexedDB database versions.
8439
+ */
8440
+ DatabaseStorage.prototype.deleteDatabase = function () {
8441
+ return __awaiter$1(this, void 0, void 0, function () {
8442
+ return __generator$1(this, function (_a) {
8443
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8444
+ var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
8445
+ deleteDbRequest.addEventListener("success", function () { return resolve(true); });
8446
+ deleteDbRequest.addEventListener("error", function () { return reject(false); });
8447
+ })];
8448
+ });
8449
+ });
8450
+ };
8131
8451
  return DatabaseStorage;
8132
8452
  }());
8133
8453
 
@@ -8135,31 +8455,254 @@ var DatabaseStorage = /** @class */ (function () {
8135
8455
  * Copyright (c) Microsoft Corporation. All rights reserved.
8136
8456
  * Licensed under the MIT License.
8137
8457
  */
8138
- /**
8139
- * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
8140
- * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
8141
- */
8142
- var CryptoOps = /** @class */ (function () {
8143
- function CryptoOps() {
8144
- // Browser crypto needs to be validated first before any other classes can be set.
8145
- this.browserCrypto = new BrowserCrypto();
8146
- this.b64Encode = new Base64Encode();
8147
- this.b64Decode = new Base64Decode();
8148
- this.guidGenerator = new GuidGenerator(this.browserCrypto);
8149
- this.pkceGenerator = new PkceGenerator(this.browserCrypto);
8150
- this.cache = new DatabaseStorage(CryptoOps.DB_NAME, CryptoOps.TABLE_NAME, CryptoOps.DB_VERSION);
8458
+ var MemoryStorage = /** @class */ (function () {
8459
+ function MemoryStorage() {
8460
+ this.cache = new Map();
8151
8461
  }
8152
- /**
8153
- * Creates a new random GUID - used to populate state and nonce.
8154
- * @returns string (GUID)
8155
- */
8156
- CryptoOps.prototype.createNewGuid = function () {
8157
- return this.guidGenerator.generateGuid();
8462
+ MemoryStorage.prototype.getItem = function (key) {
8463
+ return this.cache.get(key) || null;
8158
8464
  };
8159
- /**
8160
- * Encodes input string to base64.
8161
- * @param input
8162
- */
8465
+ MemoryStorage.prototype.setItem = function (key, value) {
8466
+ this.cache.set(key, value);
8467
+ };
8468
+ MemoryStorage.prototype.removeItem = function (key) {
8469
+ this.cache.delete(key);
8470
+ };
8471
+ MemoryStorage.prototype.getKeys = function () {
8472
+ var cacheKeys = [];
8473
+ this.cache.forEach(function (value, key) {
8474
+ cacheKeys.push(key);
8475
+ });
8476
+ return cacheKeys;
8477
+ };
8478
+ MemoryStorage.prototype.containsKey = function (key) {
8479
+ return this.cache.has(key);
8480
+ };
8481
+ MemoryStorage.prototype.clear = function () {
8482
+ this.cache.clear();
8483
+ };
8484
+ return MemoryStorage;
8485
+ }());
8486
+
8487
+ /*
8488
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8489
+ * Licensed under the MIT License.
8490
+ */
8491
+ /**
8492
+ * This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper,
8493
+ * backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
8494
+ */
8495
+ var AsyncMemoryStorage = /** @class */ (function () {
8496
+ function AsyncMemoryStorage(logger) {
8497
+ this.inMemoryCache = new MemoryStorage();
8498
+ this.indexedDBCache = new DatabaseStorage();
8499
+ this.logger = logger;
8500
+ }
8501
+ AsyncMemoryStorage.prototype.handleDatabaseAccessError = function (error) {
8502
+ if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {
8503
+ this.logger.error("Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.");
8504
+ }
8505
+ };
8506
+ /**
8507
+ * Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
8508
+ * storage object if item isn't found in-memory.
8509
+ * @param key
8510
+ */
8511
+ AsyncMemoryStorage.prototype.getItem = function (key) {
8512
+ return __awaiter$1(this, void 0, void 0, function () {
8513
+ var item, e_1;
8514
+ return __generator$1(this, function (_a) {
8515
+ switch (_a.label) {
8516
+ case 0:
8517
+ item = this.inMemoryCache.getItem(key);
8518
+ if (!!item) return [3 /*break*/, 4];
8519
+ _a.label = 1;
8520
+ case 1:
8521
+ _a.trys.push([1, 3, , 4]);
8522
+ this.logger.verbose("Queried item not found in in-memory cache, now querying persistent storage.");
8523
+ return [4 /*yield*/, this.indexedDBCache.getItem(key)];
8524
+ case 2: return [2 /*return*/, _a.sent()];
8525
+ case 3:
8526
+ e_1 = _a.sent();
8527
+ this.handleDatabaseAccessError(e_1);
8528
+ return [3 /*break*/, 4];
8529
+ case 4: return [2 /*return*/, item];
8530
+ }
8531
+ });
8532
+ });
8533
+ };
8534
+ /**
8535
+ * Sets the item in the in-memory cache and then tries to set it in the asynchronous
8536
+ * storage object with the given key.
8537
+ * @param key
8538
+ * @param value
8539
+ */
8540
+ AsyncMemoryStorage.prototype.setItem = function (key, value) {
8541
+ return __awaiter$1(this, void 0, void 0, function () {
8542
+ var e_2;
8543
+ return __generator$1(this, function (_a) {
8544
+ switch (_a.label) {
8545
+ case 0:
8546
+ this.inMemoryCache.setItem(key, value);
8547
+ _a.label = 1;
8548
+ case 1:
8549
+ _a.trys.push([1, 3, , 4]);
8550
+ return [4 /*yield*/, this.indexedDBCache.setItem(key, value)];
8551
+ case 2:
8552
+ _a.sent();
8553
+ return [3 /*break*/, 4];
8554
+ case 3:
8555
+ e_2 = _a.sent();
8556
+ this.handleDatabaseAccessError(e_2);
8557
+ return [3 /*break*/, 4];
8558
+ case 4: return [2 /*return*/];
8559
+ }
8560
+ });
8561
+ });
8562
+ };
8563
+ /**
8564
+ * Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.
8565
+ * @param key
8566
+ */
8567
+ AsyncMemoryStorage.prototype.removeItem = function (key) {
8568
+ return __awaiter$1(this, void 0, void 0, function () {
8569
+ var e_3;
8570
+ return __generator$1(this, function (_a) {
8571
+ switch (_a.label) {
8572
+ case 0:
8573
+ this.inMemoryCache.removeItem(key);
8574
+ _a.label = 1;
8575
+ case 1:
8576
+ _a.trys.push([1, 3, , 4]);
8577
+ return [4 /*yield*/, this.indexedDBCache.removeItem(key)];
8578
+ case 2:
8579
+ _a.sent();
8580
+ return [3 /*break*/, 4];
8581
+ case 3:
8582
+ e_3 = _a.sent();
8583
+ this.handleDatabaseAccessError(e_3);
8584
+ return [3 /*break*/, 4];
8585
+ case 4: return [2 /*return*/];
8586
+ }
8587
+ });
8588
+ });
8589
+ };
8590
+ /**
8591
+ * 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
8592
+ * asynchronous storage object.
8593
+ */
8594
+ AsyncMemoryStorage.prototype.getKeys = function () {
8595
+ return __awaiter$1(this, void 0, void 0, function () {
8596
+ var cacheKeys, e_4;
8597
+ return __generator$1(this, function (_a) {
8598
+ switch (_a.label) {
8599
+ case 0:
8600
+ cacheKeys = this.inMemoryCache.getKeys();
8601
+ if (!(cacheKeys.length === 0)) return [3 /*break*/, 4];
8602
+ _a.label = 1;
8603
+ case 1:
8604
+ _a.trys.push([1, 3, , 4]);
8605
+ this.logger.verbose("In-memory cache is empty, now querying persistent storage.");
8606
+ return [4 /*yield*/, this.indexedDBCache.getKeys()];
8607
+ case 2: return [2 /*return*/, _a.sent()];
8608
+ case 3:
8609
+ e_4 = _a.sent();
8610
+ this.handleDatabaseAccessError(e_4);
8611
+ return [3 /*break*/, 4];
8612
+ case 4: return [2 /*return*/, cacheKeys];
8613
+ }
8614
+ });
8615
+ });
8616
+ };
8617
+ /**
8618
+ * Returns true or false if the given key is present in the cache.
8619
+ * @param key
8620
+ */
8621
+ AsyncMemoryStorage.prototype.containsKey = function (key) {
8622
+ return __awaiter$1(this, void 0, void 0, function () {
8623
+ var containsKey, e_5;
8624
+ return __generator$1(this, function (_a) {
8625
+ switch (_a.label) {
8626
+ case 0:
8627
+ containsKey = this.inMemoryCache.containsKey(key);
8628
+ if (!!containsKey) return [3 /*break*/, 4];
8629
+ _a.label = 1;
8630
+ case 1:
8631
+ _a.trys.push([1, 3, , 4]);
8632
+ this.logger.verbose("Key not found in in-memory cache, now querying persistent storage.");
8633
+ return [4 /*yield*/, this.indexedDBCache.containsKey(key)];
8634
+ case 2: return [2 /*return*/, _a.sent()];
8635
+ case 3:
8636
+ e_5 = _a.sent();
8637
+ this.handleDatabaseAccessError(e_5);
8638
+ return [3 /*break*/, 4];
8639
+ case 4: return [2 /*return*/, containsKey];
8640
+ }
8641
+ });
8642
+ });
8643
+ };
8644
+ /**
8645
+ * Clears in-memory Map and tries to delete the IndexedDB database.
8646
+ */
8647
+ AsyncMemoryStorage.prototype.clear = function () {
8648
+ return __awaiter$1(this, void 0, void 0, function () {
8649
+ var e_6;
8650
+ return __generator$1(this, function (_a) {
8651
+ switch (_a.label) {
8652
+ case 0:
8653
+ this.inMemoryCache.clear();
8654
+ _a.label = 1;
8655
+ case 1:
8656
+ _a.trys.push([1, 3, , 4]);
8657
+ return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
8658
+ case 2:
8659
+ _a.sent();
8660
+ return [3 /*break*/, 4];
8661
+ case 3:
8662
+ e_6 = _a.sent();
8663
+ this.handleDatabaseAccessError(e_6);
8664
+ return [3 /*break*/, 4];
8665
+ case 4: return [2 /*return*/];
8666
+ }
8667
+ });
8668
+ });
8669
+ };
8670
+ return AsyncMemoryStorage;
8671
+ }());
8672
+
8673
+ /*
8674
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8675
+ * Licensed under the MIT License.
8676
+ */
8677
+ /**
8678
+ * This class implements MSAL's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
8679
+ * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
8680
+ */
8681
+ var CryptoOps = /** @class */ (function () {
8682
+ function CryptoOps(logger) {
8683
+ this.logger = logger;
8684
+ // Browser crypto needs to be validated first before any other classes can be set.
8685
+ this.browserCrypto = new BrowserCrypto(this.logger);
8686
+ this.b64Encode = new Base64Encode();
8687
+ this.b64Decode = new Base64Decode();
8688
+ this.guidGenerator = new GuidGenerator(this.browserCrypto);
8689
+ this.pkceGenerator = new PkceGenerator(this.browserCrypto);
8690
+ this.cache = {
8691
+ asymmetricKeys: new AsyncMemoryStorage(this.logger),
8692
+ symmetricKeys: new AsyncMemoryStorage(this.logger)
8693
+ };
8694
+ }
8695
+ /**
8696
+ * Creates a new random GUID - used to populate state and nonce.
8697
+ * @returns string (GUID)
8698
+ */
8699
+ CryptoOps.prototype.createNewGuid = function () {
8700
+ return this.guidGenerator.generateGuid();
8701
+ };
8702
+ /**
8703
+ * Encodes input string to base64.
8704
+ * @param input
8705
+ */
8163
8706
  CryptoOps.prototype.base64Encode = function (input) {
8164
8707
  return this.b64Encode.encode(input);
8165
8708
  };
@@ -8186,7 +8729,7 @@ var CryptoOps = /** @class */ (function () {
8186
8729
  */
8187
8730
  CryptoOps.prototype.getPublicKeyThumbprint = function (request) {
8188
8731
  return __awaiter$1(this, void 0, void 0, function () {
8189
- var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkBuffer, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
8732
+ var keyPair, publicKeyJwk, pubKeyThumprintObj, publicJwkString, publicJwkHash, privateKeyJwk, unextractablePrivateKey;
8190
8733
  return __generator$1(this, function (_a) {
8191
8734
  switch (_a.label) {
8192
8735
  case 0: return [4 /*yield*/, this.browserCrypto.generateKeyPair(CryptoOps.EXTRACTABLE, CryptoOps.POP_KEY_USAGES)];
@@ -8201,10 +8744,9 @@ var CryptoOps = /** @class */ (function () {
8201
8744
  n: publicKeyJwk.n
8202
8745
  };
8203
8746
  publicJwkString = BrowserCrypto.getJwkString(pubKeyThumprintObj);
8204
- return [4 /*yield*/, this.browserCrypto.sha256Digest(publicJwkString)];
8747
+ return [4 /*yield*/, this.hashString(publicJwkString)];
8205
8748
  case 3:
8206
- publicJwkBuffer = _a.sent();
8207
- publicJwkHash = this.b64Encode.urlEncodeArr(new Uint8Array(publicJwkBuffer));
8749
+ publicJwkHash = _a.sent();
8208
8750
  return [4 /*yield*/, this.browserCrypto.exportJwk(keyPair.privateKey)];
8209
8751
  case 4:
8210
8752
  privateKeyJwk = _a.sent();
@@ -8212,7 +8754,7 @@ var CryptoOps = /** @class */ (function () {
8212
8754
  case 5:
8213
8755
  unextractablePrivateKey = _a.sent();
8214
8756
  // Store Keypair data in keystore
8215
- return [4 /*yield*/, this.cache.put(publicJwkHash, {
8757
+ return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
8216
8758
  privateKey: unextractablePrivateKey,
8217
8759
  publicKey: keyPair.publicKey,
8218
8760
  requestMethod: request.resourceRequestMethod,
@@ -8232,8 +8774,17 @@ var CryptoOps = /** @class */ (function () {
8232
8774
  */
8233
8775
  CryptoOps.prototype.removeTokenBindingKey = function (kid) {
8234
8776
  return __awaiter$1(this, void 0, void 0, function () {
8777
+ var keyFound;
8235
8778
  return __generator$1(this, function (_a) {
8236
- return [2 /*return*/, this.cache.delete(kid)];
8779
+ switch (_a.label) {
8780
+ case 0: return [4 /*yield*/, this.cache.asymmetricKeys.removeItem(kid)];
8781
+ case 1:
8782
+ _a.sent();
8783
+ return [4 /*yield*/, this.cache.asymmetricKeys.containsKey(kid)];
8784
+ case 2:
8785
+ keyFound = _a.sent();
8786
+ return [2 /*return*/, !keyFound];
8787
+ }
8237
8788
  });
8238
8789
  });
8239
8790
  };
@@ -8242,8 +8793,22 @@ var CryptoOps = /** @class */ (function () {
8242
8793
  */
8243
8794
  CryptoOps.prototype.clearKeystore = function () {
8244
8795
  return __awaiter$1(this, void 0, void 0, function () {
8245
- return __generator$1(this, function (_a) {
8246
- return [2 /*return*/, this.cache.clear()];
8796
+ var dataStoreNames, databaseStorage, _a;
8797
+ return __generator$1(this, function (_b) {
8798
+ switch (_b.label) {
8799
+ case 0:
8800
+ dataStoreNames = Object.keys(this.cache);
8801
+ databaseStorage = this.cache[dataStoreNames[0]];
8802
+ if (!databaseStorage) return [3 /*break*/, 2];
8803
+ return [4 /*yield*/, databaseStorage.deleteDatabase()];
8804
+ case 1:
8805
+ _a = _b.sent();
8806
+ return [3 /*break*/, 3];
8807
+ case 2:
8808
+ _a = false;
8809
+ _b.label = 3;
8810
+ case 3: return [2 /*return*/, _a];
8811
+ }
8247
8812
  });
8248
8813
  });
8249
8814
  };
@@ -8257,7 +8822,7 @@ var CryptoOps = /** @class */ (function () {
8257
8822
  var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
8258
8823
  return __generator$1(this, function (_a) {
8259
8824
  switch (_a.label) {
8260
- case 0: return [4 /*yield*/, this.cache.get(kid)];
8825
+ case 0: return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
8261
8826
  case 1:
8262
8827
  cachedKeyPair = _a.sent();
8263
8828
  if (!cachedKeyPair) {
@@ -8288,11 +8853,26 @@ var CryptoOps = /** @class */ (function () {
8288
8853
  });
8289
8854
  });
8290
8855
  };
8856
+ /**
8857
+ * Returns the SHA-256 hash of an input string
8858
+ * @param plainText
8859
+ */
8860
+ CryptoOps.prototype.hashString = function (plainText) {
8861
+ return __awaiter$1(this, void 0, void 0, function () {
8862
+ var hashBuffer, hashBytes;
8863
+ return __generator$1(this, function (_a) {
8864
+ switch (_a.label) {
8865
+ case 0: return [4 /*yield*/, this.browserCrypto.sha256Digest(plainText)];
8866
+ case 1:
8867
+ hashBuffer = _a.sent();
8868
+ hashBytes = new Uint8Array(hashBuffer);
8869
+ return [2 /*return*/, this.b64Encode.urlEncodeArr(hashBytes)];
8870
+ }
8871
+ });
8872
+ });
8873
+ };
8291
8874
  CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
8292
8875
  CryptoOps.EXTRACTABLE = true;
8293
- CryptoOps.DB_VERSION = 1;
8294
- CryptoOps.DB_NAME = "msal.db";
8295
- CryptoOps.TABLE_NAME = CryptoOps.DB_NAME + ".keys";
8296
8876
  return CryptoOps;
8297
8877
  }());
8298
8878
 
@@ -8422,39 +9002,6 @@ var BrowserStorage = /** @class */ (function () {
8422
9002
  return BrowserStorage;
8423
9003
  }());
8424
9004
 
8425
- /*
8426
- * Copyright (c) Microsoft Corporation. All rights reserved.
8427
- * Licensed under the MIT License.
8428
- */
8429
- var MemoryStorage = /** @class */ (function () {
8430
- function MemoryStorage() {
8431
- this.cache = new Map();
8432
- }
8433
- MemoryStorage.prototype.getItem = function (key) {
8434
- return this.cache.get(key) || null;
8435
- };
8436
- MemoryStorage.prototype.setItem = function (key, value) {
8437
- this.cache.set(key, value);
8438
- };
8439
- MemoryStorage.prototype.removeItem = function (key) {
8440
- this.cache.delete(key);
8441
- };
8442
- MemoryStorage.prototype.getKeys = function () {
8443
- var cacheKeys = [];
8444
- this.cache.forEach(function (value, key) {
8445
- cacheKeys.push(key);
8446
- });
8447
- return cacheKeys;
8448
- };
8449
- MemoryStorage.prototype.containsKey = function (key) {
8450
- return this.cache.has(key);
8451
- };
8452
- MemoryStorage.prototype.clear = function () {
8453
- this.cache.clear();
8454
- };
8455
- return MemoryStorage;
8456
- }());
8457
-
8458
9005
  /*
8459
9006
  * Copyright (c) Microsoft Corporation. All rights reserved.
8460
9007
  * Licensed under the MIT License.
@@ -9245,6 +9792,7 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9245
9792
  }
9246
9793
  });
9247
9794
  this.clearMsalCookies();
9795
+ this.setInteractionInProgress(false);
9248
9796
  };
9249
9797
  BrowserCacheManager.prototype.cacheCodeRequest = function (authCodeRequest, browserCrypto) {
9250
9798
  this.logger.trace("BrowserCacheManager.cacheCodeRequest called");
@@ -9302,6 +9850,58 @@ var BrowserCacheManager = /** @class */ (function (_super) {
9302
9850
  this.removeItem(key);
9303
9851
  }
9304
9852
  };
9853
+ /**
9854
+ * Returns username retrieved from ADAL or MSAL v1 idToken
9855
+ */
9856
+ BrowserCacheManager.prototype.getLegacyLoginHint = function () {
9857
+ // Only check for adal/msal token if no SSO params are being used
9858
+ var adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
9859
+ if (adalIdTokenString) {
9860
+ this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
9861
+ this.logger.verbose("Cached ADAL id token retrieved.");
9862
+ }
9863
+ // Check for cached MSAL v1 id token
9864
+ var msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
9865
+ if (msalIdTokenString) {
9866
+ this.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
9867
+ this.logger.verbose("Cached MSAL.js v1 id token retrieved");
9868
+ }
9869
+ var cachedIdTokenString = msalIdTokenString || adalIdTokenString;
9870
+ if (cachedIdTokenString) {
9871
+ var cachedIdToken = new AuthToken(cachedIdTokenString, this.cryptoImpl);
9872
+ if (cachedIdToken.claims && cachedIdToken.claims.preferred_username) {
9873
+ this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
9874
+ return cachedIdToken.claims.preferred_username;
9875
+ }
9876
+ else if (cachedIdToken.claims && cachedIdToken.claims.upn) {
9877
+ this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
9878
+ return cachedIdToken.claims.upn;
9879
+ }
9880
+ else {
9881
+ this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO.");
9882
+ }
9883
+ }
9884
+ return null;
9885
+ };
9886
+ /**
9887
+ * Updates a credential's cache key if the current cache key is outdated
9888
+ */
9889
+ BrowserCacheManager.prototype.updateCredentialCacheKey = function (currentCacheKey, credential) {
9890
+ var updatedCacheKey = credential.generateCredentialKey();
9891
+ if (currentCacheKey !== updatedCacheKey) {
9892
+ var cacheItem = this.getItem(currentCacheKey);
9893
+ if (cacheItem) {
9894
+ this.removeItem(currentCacheKey);
9895
+ this.setItem(updatedCacheKey, cacheItem);
9896
+ this.logger.verbose("Updated an outdated " + credential.credentialType + " cache key");
9897
+ return updatedCacheKey;
9898
+ }
9899
+ else {
9900
+ this.logger.error("Attempted to update an outdated " + credential.credentialType + " cache key but no item matching the outdated key was found in storage");
9901
+ }
9902
+ }
9903
+ return currentCacheKey;
9904
+ };
9305
9905
  return BrowserCacheManager;
9306
9906
  }(CacheManager));
9307
9907
  var DEFAULT_BROWSER_CACHE_MANAGER = function (clientId, logger) {
@@ -9802,7 +10402,7 @@ function buildConfiguration(_a, isBrowserEnvironment) {
9802
10402
 
9803
10403
  /* eslint-disable header/header */
9804
10404
  var name = "@azure/msal-browser";
9805
- var version = "2.17.0";
10405
+ var version = "2.21.0";
9806
10406
 
9807
10407
  /*
9808
10408
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9810,6 +10410,8 @@ var version = "2.17.0";
9810
10410
  */
9811
10411
  exports.EventType = void 0;
9812
10412
  (function (EventType) {
10413
+ EventType["ACCOUNT_ADDED"] = "msal:accountAdded";
10414
+ EventType["ACCOUNT_REMOVED"] = "msal:accountRemoved";
9813
10415
  EventType["LOGIN_START"] = "msal:loginStart";
9814
10416
  EventType["LOGIN_SUCCESS"] = "msal:loginSuccess";
9815
10417
  EventType["LOGIN_FAILURE"] = "msal:loginFailure";
@@ -9820,6 +10422,9 @@ exports.EventType = void 0;
9820
10422
  EventType["SSO_SILENT_START"] = "msal:ssoSilentStart";
9821
10423
  EventType["SSO_SILENT_SUCCESS"] = "msal:ssoSilentSuccess";
9822
10424
  EventType["SSO_SILENT_FAILURE"] = "msal:ssoSilentFailure";
10425
+ EventType["ACQUIRE_TOKEN_BY_CODE_START"] = "msal:acquireTokenByCodeStart";
10426
+ EventType["ACQUIRE_TOKEN_BY_CODE_SUCCESS"] = "msal:acquireTokenByCodeSuccess";
10427
+ EventType["ACQUIRE_TOKEN_BY_CODE_FAILURE"] = "msal:acquireTokenByCodeFailure";
9823
10428
  EventType["HANDLE_REDIRECT_START"] = "msal:handleRedirectStart";
9824
10429
  EventType["HANDLE_REDIRECT_END"] = "msal:handleRedirectEnd";
9825
10430
  EventType["POPUP_OPENED"] = "msal:popupOpened";
@@ -9838,6 +10443,8 @@ var EventHandler = /** @class */ (function () {
9838
10443
  this.eventCallbacks = new Map();
9839
10444
  this.logger = logger;
9840
10445
  this.browserCrypto = browserCrypto;
10446
+ this.listeningToStorageEvents = false;
10447
+ this.handleAccountCacheChange = this.handleAccountCacheChange.bind(this);
9841
10448
  }
9842
10449
  /**
9843
10450
  * Adds event callbacks to array
@@ -9860,6 +10467,38 @@ var EventHandler = /** @class */ (function () {
9860
10467
  this.eventCallbacks.delete(callbackId);
9861
10468
  this.logger.verbose("Event callback " + callbackId + " removed.");
9862
10469
  };
10470
+ /**
10471
+ * Adds event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
10472
+ */
10473
+ EventHandler.prototype.enableAccountStorageEvents = function () {
10474
+ if (typeof window === "undefined") {
10475
+ return;
10476
+ }
10477
+ if (!this.listeningToStorageEvents) {
10478
+ this.logger.verbose("Adding account storage listener.");
10479
+ this.listeningToStorageEvents = true;
10480
+ window.addEventListener("storage", this.handleAccountCacheChange);
10481
+ }
10482
+ else {
10483
+ this.logger.verbose("Account storage listener already registered.");
10484
+ }
10485
+ };
10486
+ /**
10487
+ * Removes event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
10488
+ */
10489
+ EventHandler.prototype.disableAccountStorageEvents = function () {
10490
+ if (typeof window === "undefined") {
10491
+ return;
10492
+ }
10493
+ if (this.listeningToStorageEvents) {
10494
+ this.logger.verbose("Removing account storage listener.");
10495
+ window.removeEventListener("storage", this.handleAccountCacheChange);
10496
+ this.listeningToStorageEvents = false;
10497
+ }
10498
+ else {
10499
+ this.logger.verbose("No account storage listener registered.");
10500
+ }
10501
+ };
9863
10502
  /**
9864
10503
  * Emits events by calling callback with event message
9865
10504
  * @param eventType
@@ -9884,6 +10523,34 @@ var EventHandler = /** @class */ (function () {
9884
10523
  });
9885
10524
  }
9886
10525
  };
10526
+ /**
10527
+ * Emit account added/removed events when cached accounts are changed in a different tab or frame
10528
+ */
10529
+ EventHandler.prototype.handleAccountCacheChange = function (e) {
10530
+ try {
10531
+ var cacheValue = e.newValue || e.oldValue;
10532
+ if (!cacheValue) {
10533
+ return;
10534
+ }
10535
+ var parsedValue = JSON.parse(cacheValue);
10536
+ if (typeof parsedValue !== "object" || !AccountEntity.isAccountEntity(parsedValue)) {
10537
+ return;
10538
+ }
10539
+ var accountEntity = CacheManager.toObject(new AccountEntity(), parsedValue);
10540
+ var accountInfo = accountEntity.getAccountInfo();
10541
+ if (!e.oldValue && e.newValue) {
10542
+ this.logger.info("Account was added to cache in a different window");
10543
+ this.emitEvent(exports.EventType.ACCOUNT_ADDED, undefined, accountInfo);
10544
+ }
10545
+ else if (!e.newValue && e.oldValue) {
10546
+ this.logger.info("Account was removed from cache in a different window");
10547
+ this.emitEvent(exports.EventType.ACCOUNT_REMOVED, undefined, accountInfo);
10548
+ }
10549
+ }
10550
+ catch (e) {
10551
+ return;
10552
+ }
10553
+ };
9887
10554
  return EventHandler;
9888
10555
  }());
9889
10556
 
@@ -9947,6 +10614,79 @@ var BaseInteractionClient = /** @class */ (function () {
9947
10614
  });
9948
10615
  });
9949
10616
  };
10617
+ /**
10618
+ * Initializer function for all request APIs
10619
+ * @param request
10620
+ */
10621
+ BaseInteractionClient.prototype.initializeBaseRequest = function (request) {
10622
+ return __awaiter$1(this, void 0, void 0, function () {
10623
+ var authority, scopes, _a, validatedRequest;
10624
+ return __generator$1(this, function (_b) {
10625
+ switch (_b.label) {
10626
+ case 0:
10627
+ this.logger.verbose("Initializing BaseAuthRequest");
10628
+ authority = request.authority || this.config.auth.authority;
10629
+ scopes = __spread(((request && request.scopes) || []));
10630
+ // Set authenticationScheme to BEARER if not explicitly set in the request
10631
+ if (!request.authenticationScheme) {
10632
+ request.authenticationScheme = exports.AuthenticationScheme.BEARER;
10633
+ this.logger.verbose("Authentication Scheme wasn't explicitly set in request, defaulting to \"Bearer\" request");
10634
+ }
10635
+ else {
10636
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
10637
+ if (!request.sshJwk) {
10638
+ throw ClientConfigurationError.createMissingSshJwkError();
10639
+ }
10640
+ if (!request.sshKid) {
10641
+ throw ClientConfigurationError.createMissingSshKidError();
10642
+ }
10643
+ }
10644
+ this.logger.verbose("Authentication Scheme set to \"" + request.authenticationScheme + "\" as configured in Auth request");
10645
+ }
10646
+ if (!(request.claims && !StringUtils.isEmpty(request.claims))) return [3 /*break*/, 2];
10647
+ _a = request;
10648
+ return [4 /*yield*/, this.browserCrypto.hashString(request.claims)];
10649
+ case 1:
10650
+ _a.requestedClaimsHash = _b.sent();
10651
+ _b.label = 2;
10652
+ case 2:
10653
+ validatedRequest = __assign$1(__assign$1({}, request), { correlationId: this.correlationId, authority: authority,
10654
+ scopes: scopes });
10655
+ return [2 /*return*/, validatedRequest];
10656
+ }
10657
+ });
10658
+ });
10659
+ };
10660
+ /**
10661
+ *
10662
+ * Use to get the redirect uri configured in MSAL or null.
10663
+ * @param requestRedirectUri
10664
+ * @returns Redirect URL
10665
+ *
10666
+ */
10667
+ BaseInteractionClient.prototype.getRedirectUri = function (requestRedirectUri) {
10668
+ this.logger.verbose("getRedirectUri called");
10669
+ var redirectUri = requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();
10670
+ return UrlString.getAbsoluteUrl(redirectUri, BrowserUtils.getCurrentUri());
10671
+ };
10672
+ /**
10673
+ *
10674
+ * @param apiId
10675
+ * @param correlationId
10676
+ * @param forceRefresh
10677
+ */
10678
+ BaseInteractionClient.prototype.initializeServerTelemetryManager = function (apiId, forceRefresh) {
10679
+ this.logger.verbose("initializeServerTelemetryManager called");
10680
+ var telemetryPayload = {
10681
+ clientId: this.config.auth.clientId,
10682
+ correlationId: this.correlationId,
10683
+ apiId: apiId,
10684
+ forceRefresh: forceRefresh || false,
10685
+ wrapperSKU: this.browserStorage.getWrapperMetadata()[0],
10686
+ wrapperVer: this.browserStorage.getWrapperMetadata()[1]
10687
+ };
10688
+ return new ServerTelemetryManager(telemetryPayload, this.browserStorage);
10689
+ };
9950
10690
  return BaseInteractionClient;
9951
10691
  }());
9952
10692
 
@@ -10139,122 +10879,68 @@ var StandardInteractionClient = /** @class */ (function (_super) {
10139
10879
  });
10140
10880
  });
10141
10881
  };
10142
- /**
10143
- *
10144
- * @param apiId
10145
- * @param correlationId
10146
- * @param forceRefresh
10147
- */
10148
- StandardInteractionClient.prototype.initializeServerTelemetryManager = function (apiId, forceRefresh) {
10149
- this.logger.verbose("initializeServerTelemetryManager called");
10150
- var telemetryPayload = {
10151
- clientId: this.config.auth.clientId,
10152
- correlationId: this.correlationId,
10153
- apiId: apiId,
10154
- forceRefresh: forceRefresh || false,
10155
- wrapperSKU: this.browserStorage.getWrapperMetadata()[0],
10156
- wrapperVer: this.browserStorage.getWrapperMetadata()[1]
10157
- };
10158
- return new ServerTelemetryManager(telemetryPayload, this.browserStorage);
10159
- };
10160
10882
  /**
10161
10883
  * Helper to validate app environment before making a request.
10162
10884
  * @param request
10163
10885
  * @param interactionType
10164
10886
  */
10165
10887
  StandardInteractionClient.prototype.preflightInteractiveRequest = function (request, interactionType) {
10166
- this.logger.verbose("preflightInteractiveRequest called, validating app environment", request === null || request === void 0 ? void 0 : request.correlationId);
10167
- // block the reload if it occurred inside a hidden iframe
10168
- BrowserUtils.blockReloadInHiddenIframes();
10169
- // Check if interaction is in progress. Throw error if true.
10170
- if (this.browserStorage.isInteractionInProgress(false)) {
10171
- throw BrowserAuthError.createInteractionInProgressError();
10172
- }
10173
- return this.initializeAuthorizationRequest(request, interactionType);
10174
- };
10175
- /**
10176
- * Helper to initialize required request parameters for interactive APIs and ssoSilent()
10177
- * @param request
10178
- * @param interactionType
10179
- */
10180
- StandardInteractionClient.prototype.initializeAuthorizationRequest = function (request, interactionType) {
10181
- this.logger.verbose("initializeAuthorizationRequest called");
10182
- var redirectUri = this.getRedirectUri(request.redirectUri);
10183
- var browserState = {
10184
- interactionType: interactionType
10185
- };
10186
- var state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || "", browserState);
10187
- var validatedRequest = __assign$1(__assign$1({}, this.initializeBaseRequest(request)), { redirectUri: redirectUri, state: state, nonce: request.nonce || this.browserCrypto.createNewGuid(), responseMode: ResponseMode.FRAGMENT });
10188
- var account = request.account || this.browserStorage.getActiveAccount();
10189
- if (account) {
10190
- this.logger.verbose("Setting validated request account");
10191
- this.logger.verbosePii("Setting validated request account: " + account);
10192
- validatedRequest.account = account;
10193
- }
10194
- // Check for ADAL/MSAL v1 SSO
10195
- if (StringUtils.isEmpty(validatedRequest.loginHint) && !account) {
10196
- // Only check for adal/msal token if no SSO params are being used
10197
- var adalIdTokenString = this.browserStorage.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);
10198
- if (adalIdTokenString) {
10199
- this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
10200
- this.logger.verbose("Cached ADAL id token retrieved.");
10201
- }
10202
- // Check for cached MSAL v1 id token
10203
- var msalIdTokenString = this.browserStorage.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);
10204
- if (msalIdTokenString) {
10205
- this.browserStorage.removeItem(this.browserStorage.generateCacheKey(PersistentCacheKeys.ID_TOKEN));
10206
- this.logger.verbose("Cached MSAL.js v1 id token retrieved");
10207
- }
10208
- var cachedIdTokenString = msalIdTokenString || adalIdTokenString;
10209
- if (cachedIdTokenString) {
10210
- var cachedIdToken = new AuthToken(cachedIdTokenString, this.browserCrypto);
10211
- if (cachedIdToken.claims && cachedIdToken.claims.preferred_username) {
10212
- this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint");
10213
- validatedRequest.loginHint = cachedIdToken.claims.preferred_username;
10214
- }
10215
- else if (cachedIdToken.claims && cachedIdToken.claims.upn) {
10216
- this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint");
10217
- validatedRequest.loginHint = cachedIdToken.claims.upn;
10218
- }
10219
- else {
10220
- this.logger.verbose("No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO.");
10888
+ return __awaiter$1(this, void 0, void 0, function () {
10889
+ return __generator$1(this, function (_a) {
10890
+ switch (_a.label) {
10891
+ case 0:
10892
+ this.logger.verbose("preflightInteractiveRequest called, validating app environment", request === null || request === void 0 ? void 0 : request.correlationId);
10893
+ // block the reload if it occurred inside a hidden iframe
10894
+ BrowserUtils.blockReloadInHiddenIframes();
10895
+ // Check if interaction is in progress. Throw error if true.
10896
+ if (this.browserStorage.isInteractionInProgress(false)) {
10897
+ throw BrowserAuthError.createInteractionInProgressError();
10898
+ }
10899
+ return [4 /*yield*/, this.initializeAuthorizationRequest(request, interactionType)];
10900
+ case 1: return [2 /*return*/, _a.sent()];
10221
10901
  }
10222
- }
10223
- }
10224
- this.browserStorage.updateCacheEntries(validatedRequest.state, validatedRequest.nonce, validatedRequest.authority, validatedRequest.loginHint || "", validatedRequest.account || null);
10225
- return validatedRequest;
10226
- };
10227
- /**
10228
- * Initializer function for all request APIs
10229
- * @param request
10230
- */
10231
- StandardInteractionClient.prototype.initializeBaseRequest = function (request) {
10232
- this.logger.verbose("Initializing BaseAuthRequest");
10233
- var authority = request.authority || this.config.auth.authority;
10234
- var scopes = __spread(((request && request.scopes) || []));
10235
- // Set authenticationScheme to BEARER if not explicitly set in the request
10236
- if (!request.authenticationScheme) {
10237
- request.authenticationScheme = exports.AuthenticationScheme.BEARER;
10238
- this.logger.verbose("Authentication Scheme wasn't explicitly set in request, defaulting to \"Bearer\" request");
10239
- }
10240
- else {
10241
- this.logger.verbose("Authentication Scheme set to \"" + request.authenticationScheme + "\" as configured in Auth request");
10242
- }
10243
- var validatedRequest = __assign$1(__assign$1({}, request), { correlationId: this.correlationId, authority: authority,
10244
- scopes: scopes });
10245
- return validatedRequest;
10902
+ });
10903
+ });
10246
10904
  };
10247
10905
  /**
10248
- *
10249
- * Use to get the redirect uri configured in MSAL or null.
10250
- * @param requestRedirectUri
10251
- * @returns Redirect URL
10252
- *
10906
+ * Helper to initialize required request parameters for interactive APIs and ssoSilent()
10907
+ * @param request
10908
+ * @param interactionType
10253
10909
  */
10254
- StandardInteractionClient.prototype.getRedirectUri = function (requestRedirectUri) {
10255
- this.logger.verbose("getRedirectUri called");
10256
- var redirectUri = requestRedirectUri || this.config.auth.redirectUri || BrowserUtils.getCurrentUri();
10257
- return UrlString.getAbsoluteUrl(redirectUri, BrowserUtils.getCurrentUri());
10910
+ StandardInteractionClient.prototype.initializeAuthorizationRequest = function (request, interactionType) {
10911
+ return __awaiter$1(this, void 0, void 0, function () {
10912
+ var redirectUri, browserState, state, validatedRequest, _a, account, legacyLoginHint;
10913
+ return __generator$1(this, function (_b) {
10914
+ switch (_b.label) {
10915
+ case 0:
10916
+ this.logger.verbose("initializeAuthorizationRequest called");
10917
+ redirectUri = this.getRedirectUri(request.redirectUri);
10918
+ browserState = {
10919
+ interactionType: interactionType
10920
+ };
10921
+ state = ProtocolUtils.setRequestState(this.browserCrypto, (request && request.state) || "", browserState);
10922
+ _a = [{}];
10923
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
10924
+ case 1:
10925
+ 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 }]);
10926
+ account = request.account || this.browserStorage.getActiveAccount();
10927
+ if (account) {
10928
+ this.logger.verbose("Setting validated request account");
10929
+ this.logger.verbosePii("Setting validated request account: " + account);
10930
+ validatedRequest.account = account;
10931
+ }
10932
+ // Check for ADAL/MSAL v1 SSO
10933
+ if (StringUtils.isEmpty(validatedRequest.loginHint) && !account) {
10934
+ legacyLoginHint = this.browserStorage.getLegacyLoginHint();
10935
+ if (legacyLoginHint) {
10936
+ validatedRequest.loginHint = legacyLoginHint;
10937
+ }
10938
+ }
10939
+ this.browserStorage.updateCacheEntries(validatedRequest.state, validatedRequest.nonce, validatedRequest.authority, validatedRequest.loginHint || "", validatedRequest.account || null);
10940
+ return [2 /*return*/, validatedRequest];
10941
+ }
10942
+ });
10943
+ });
10258
10944
  };
10259
10945
  return StandardInteractionClient;
10260
10946
  }(BaseInteractionClient));
@@ -10454,23 +11140,46 @@ var InteractionHandler = /** @class */ (function () {
10454
11140
  * Function to handle response parameters from hash.
10455
11141
  * @param locationHash
10456
11142
  */
10457
- InteractionHandler.prototype.handleCodeResponse = function (locationHash, state, authority, networkModule) {
11143
+ InteractionHandler.prototype.handleCodeResponseFromHash = function (locationHash, state, authority, networkModule) {
10458
11144
  return __awaiter$1(this, void 0, void 0, function () {
10459
- var stateKey, requestState, authCodeResponse, nonceKey, cachedNonce, cachedCcsCred, tokenResponse;
11145
+ var stateKey, requestState, authCodeResponse;
11146
+ return __generator$1(this, function (_a) {
11147
+ this.browserRequestLogger.verbose("InteractionHandler.handleCodeResponse called");
11148
+ // Check that location hash isn't empty.
11149
+ if (StringUtils.isEmpty(locationHash)) {
11150
+ throw BrowserAuthError.createEmptyHashError(locationHash);
11151
+ }
11152
+ stateKey = this.browserStorage.generateStateKey(state);
11153
+ requestState = this.browserStorage.getTemporaryCache(stateKey);
11154
+ if (!requestState) {
11155
+ throw ClientAuthError.createStateNotFoundError("Cached State");
11156
+ }
11157
+ authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);
11158
+ return [2 /*return*/, this.handleCodeResponseFromServer(authCodeResponse, state, authority, networkModule)];
11159
+ });
11160
+ });
11161
+ };
11162
+ /**
11163
+ * Process auth code response from AAD
11164
+ * @param authCodeResponse
11165
+ * @param state
11166
+ * @param authority
11167
+ * @param networkModule
11168
+ * @returns
11169
+ */
11170
+ InteractionHandler.prototype.handleCodeResponseFromServer = function (authCodeResponse, state, authority, networkModule, validateNonce) {
11171
+ if (validateNonce === void 0) { validateNonce = true; }
11172
+ return __awaiter$1(this, void 0, void 0, function () {
11173
+ var stateKey, requestState, nonceKey, cachedNonce, cachedCcsCred, tokenResponse;
10460
11174
  return __generator$1(this, function (_a) {
10461
11175
  switch (_a.label) {
10462
11176
  case 0:
10463
- this.browserRequestLogger.verbose("InteractionHandler.handleCodeResponse called");
10464
- // Check that location hash isn't empty.
10465
- if (StringUtils.isEmpty(locationHash)) {
10466
- throw BrowserAuthError.createEmptyHashError(locationHash);
10467
- }
11177
+ this.browserRequestLogger.trace("InteractionHandler.handleCodeResponseFromServer called");
10468
11178
  stateKey = this.browserStorage.generateStateKey(state);
10469
11179
  requestState = this.browserStorage.getTemporaryCache(stateKey);
10470
11180
  if (!requestState) {
10471
11181
  throw ClientAuthError.createStateNotFoundError("Cached State");
10472
11182
  }
10473
- authCodeResponse = this.authModule.handleFragmentResponse(locationHash, requestState);
10474
11183
  nonceKey = this.browserStorage.generateNonceKey(requestState);
10475
11184
  cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);
10476
11185
  // Assign code to request
@@ -10481,7 +11190,10 @@ var InteractionHandler = /** @class */ (function () {
10481
11190
  _a.sent();
10482
11191
  _a.label = 2;
10483
11192
  case 2:
10484
- authCodeResponse.nonce = cachedNonce || undefined;
11193
+ // Nonce validation not needed when redirect not involved (e.g. hybrid spa, renewing token via rt)
11194
+ if (validateNonce) {
11195
+ authCodeResponse.nonce = cachedNonce || undefined;
11196
+ }
10485
11197
  authCodeResponse.state = requestState;
10486
11198
  // Add CCS parameters if available
10487
11199
  if (authCodeResponse.client_info) {
@@ -10618,26 +11330,36 @@ var PopupClient = /** @class */ (function (_super) {
10618
11330
  * @param request
10619
11331
  */
10620
11332
  PopupClient.prototype.acquireToken = function (request) {
10621
- try {
10622
- var validRequest = this.preflightInteractiveRequest(request, exports.InteractionType.Popup);
10623
- var popupName = PopupUtils.generatePopupName(this.config.auth.clientId, validRequest);
10624
- var popupWindowAttributes = request.popupWindowAttributes || {};
10625
- // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
10626
- if (this.config.system.asyncPopups) {
10627
- this.logger.verbose("asyncPopups set to true, acquiring token");
10628
- // Passes on popup position and dimensions if in request
10629
- return this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes);
10630
- }
10631
- else {
10632
- // asyncPopups flag is set to false. Opens popup before acquiring token.
10633
- this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
10634
- var popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
10635
- return this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes, popup);
10636
- }
10637
- }
10638
- catch (e) {
10639
- return Promise.reject(e);
10640
- }
11333
+ return __awaiter$1(this, void 0, void 0, function () {
11334
+ var validRequest, popupName, popupWindowAttributes, popup, e_1;
11335
+ return __generator$1(this, function (_a) {
11336
+ switch (_a.label) {
11337
+ case 0:
11338
+ _a.trys.push([0, 2, , 3]);
11339
+ return [4 /*yield*/, this.preflightInteractiveRequest(request, exports.InteractionType.Popup)];
11340
+ case 1:
11341
+ validRequest = _a.sent();
11342
+ popupName = PopupUtils.generatePopupName(this.config.auth.clientId, validRequest);
11343
+ popupWindowAttributes = request.popupWindowAttributes || {};
11344
+ // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
11345
+ if (this.config.system.asyncPopups) {
11346
+ this.logger.verbose("asyncPopups set to true, acquiring token");
11347
+ // Passes on popup position and dimensions if in request
11348
+ return [2 /*return*/, this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes)];
11349
+ }
11350
+ else {
11351
+ // asyncPopups flag is set to false. Opens popup before acquiring token.
11352
+ this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
11353
+ popup = PopupUtils.openSizedPopup("about:blank", popupName, popupWindowAttributes, this.logger);
11354
+ return [2 /*return*/, this.acquireTokenPopupAsync(validRequest, popupName, popupWindowAttributes, popup)];
11355
+ }
11356
+ case 2:
11357
+ e_1 = _a.sent();
11358
+ return [2 /*return*/, Promise.reject(e_1)];
11359
+ case 3: return [2 /*return*/];
11360
+ }
11361
+ });
11362
+ });
10641
11363
  };
10642
11364
  /**
10643
11365
  * Clears local cache for the current user then opens a popup window prompting the user to sign-out of the server
@@ -10680,7 +11402,7 @@ var PopupClient = /** @class */ (function (_super) {
10680
11402
  */
10681
11403
  PopupClient.prototype.acquireTokenPopupAsync = function (validRequest, popupName, popupWindowAttributes, popup) {
10682
11404
  return __awaiter$1(this, void 0, void 0, function () {
10683
- var serverTelemetryManager, authCodeRequest, authClient, navigateUrl, interactionHandler, popupParameters, popupWindow, hash, state, result, e_1;
11405
+ var serverTelemetryManager, authCodeRequest, authClient, navigateUrl, interactionHandler, popupParameters, popupWindow, hash, state, result, e_2;
10684
11406
  return __generator$1(this, function (_a) {
10685
11407
  switch (_a.label) {
10686
11408
  case 0:
@@ -10713,22 +11435,22 @@ var PopupClient = /** @class */ (function (_super) {
10713
11435
  state = this.validateAndExtractStateFromHash(hash, exports.InteractionType.Popup, validRequest.correlationId);
10714
11436
  // Remove throttle if it exists
10715
11437
  ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest);
10716
- return [4 /*yield*/, interactionHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient)];
11438
+ return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
10717
11439
  case 6:
10718
11440
  result = _a.sent();
10719
11441
  return [2 /*return*/, result];
10720
11442
  case 7:
10721
- e_1 = _a.sent();
11443
+ e_2 = _a.sent();
10722
11444
  if (popup) {
10723
11445
  // Close the synchronous popup if an error is thrown before the window unload event is registered
10724
11446
  popup.close();
10725
11447
  }
10726
- if (e_1 instanceof AuthError) {
10727
- e_1.setCorrelationId(this.correlationId);
11448
+ if (e_2 instanceof AuthError) {
11449
+ e_2.setCorrelationId(this.correlationId);
10728
11450
  }
10729
- serverTelemetryManager.cacheFailedRequest(e_1);
11451
+ serverTelemetryManager.cacheFailedRequest(e_2);
10730
11452
  this.browserStorage.cleanRequestByState(validRequest.state);
10731
- throw e_1;
11453
+ throw e_2;
10732
11454
  case 8: return [2 /*return*/];
10733
11455
  }
10734
11456
  });
@@ -10745,7 +11467,7 @@ var PopupClient = /** @class */ (function (_super) {
10745
11467
  */
10746
11468
  PopupClient.prototype.logoutPopupAsync = function (validRequest, popupName, popupWindowAttributes, requestAuthority, popup, mainWindowRedirectUri) {
10747
11469
  return __awaiter$1(this, void 0, void 0, function () {
10748
- var serverTelemetryManager, authClient, logoutUri, popupUtils, popupWindow, e_2, navigationOptions, absoluteUrl, e_3;
11470
+ var serverTelemetryManager, authClient, logoutUri, popupUtils, popupWindow, e_3, navigationOptions, absoluteUrl, e_4;
10749
11471
  return __generator$1(this, function (_a) {
10750
11472
  switch (_a.label) {
10751
11473
  case 0:
@@ -10781,8 +11503,8 @@ var PopupClient = /** @class */ (function (_super) {
10781
11503
  this.logger.verbose("Popup successfully redirected to postLogoutRedirectUri");
10782
11504
  return [3 /*break*/, 7];
10783
11505
  case 6:
10784
- e_2 = _a.sent();
10785
- this.logger.verbose("Error occurred while monitoring popup for same origin. Session on server may remain active. Error: " + e_2);
11506
+ e_3 = _a.sent();
11507
+ this.logger.verbose("Error occurred while monitoring popup for same origin. Session on server may remain active. Error: " + e_3);
10786
11508
  return [3 /*break*/, 7];
10787
11509
  case 7:
10788
11510
  popupUtils.cleanPopup(popupWindow);
@@ -10802,19 +11524,19 @@ var PopupClient = /** @class */ (function (_super) {
10802
11524
  }
10803
11525
  return [3 /*break*/, 9];
10804
11526
  case 8:
10805
- e_3 = _a.sent();
11527
+ e_4 = _a.sent();
10806
11528
  if (popup) {
10807
11529
  // Close the synchronous popup if an error is thrown before the window unload event is registered
10808
11530
  popup.close();
10809
11531
  }
10810
- if (e_3 instanceof AuthError) {
10811
- e_3.setCorrelationId(this.correlationId);
11532
+ if (e_4 instanceof AuthError) {
11533
+ e_4.setCorrelationId(this.correlationId);
10812
11534
  }
10813
11535
  this.browserStorage.setInteractionInProgress(false);
10814
- this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_3);
11536
+ this.eventHandler.emitEvent(exports.EventType.LOGOUT_FAILURE, exports.InteractionType.Popup, null, e_4);
10815
11537
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
10816
- serverTelemetryManager.cacheFailedRequest(e_3);
10817
- throw e_3;
11538
+ serverTelemetryManager.cacheFailedRequest(e_4);
11539
+ throw e_4;
10818
11540
  case 9:
10819
11541
  this.eventHandler.emitEvent(exports.EventType.LOGOUT_END, exports.InteractionType.Popup);
10820
11542
  return [2 /*return*/];
@@ -10897,7 +11619,7 @@ var RedirectHandler = /** @class */ (function (_super) {
10897
11619
  * Handle authorization code response in the window.
10898
11620
  * @param hash
10899
11621
  */
10900
- RedirectHandler.prototype.handleCodeResponse = function (locationHash, state, authority, networkModule, clientId) {
11622
+ RedirectHandler.prototype.handleCodeResponseFromHash = function (locationHash, state, authority, networkModule, clientId) {
10901
11623
  return __awaiter$1(this, void 0, void 0, function () {
10902
11624
  var stateKey, requestState, authCodeResponse, nonceKey, cachedNonce, cachedCcsCred, tokenResponse;
10903
11625
  return __generator$1(this, function (_a) {
@@ -10972,22 +11694,23 @@ var RedirectClient = /** @class */ (function (_super) {
10972
11694
  var validRequest, serverTelemetryManager, authCodeRequest, authClient, interactionHandler, navigateUrl, redirectStartPage, e_1;
10973
11695
  return __generator$1(this, function (_a) {
10974
11696
  switch (_a.label) {
10975
- case 0:
10976
- validRequest = this.preflightInteractiveRequest(request, exports.InteractionType.Redirect);
10977
- serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenRedirect);
10978
- _a.label = 1;
11697
+ case 0: return [4 /*yield*/, this.preflightInteractiveRequest(request, exports.InteractionType.Redirect)];
10979
11698
  case 1:
10980
- _a.trys.push([1, 6, , 7]);
10981
- return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
11699
+ validRequest = _a.sent();
11700
+ serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenRedirect);
11701
+ _a.label = 2;
10982
11702
  case 2:
11703
+ _a.trys.push([2, 7, , 8]);
11704
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
11705
+ case 3:
10983
11706
  authCodeRequest = _a.sent();
10984
11707
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority)];
10985
- case 3:
11708
+ case 4:
10986
11709
  authClient = _a.sent();
10987
11710
  this.logger.verbose("Auth code client created");
10988
11711
  interactionHandler = new RedirectHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.browserCrypto);
10989
11712
  return [4 /*yield*/, authClient.getAuthCodeUrl(validRequest)];
10990
- case 4:
11713
+ case 5:
10991
11714
  navigateUrl = _a.sent();
10992
11715
  redirectStartPage = this.getRedirectStartPage(request.redirectStartPage);
10993
11716
  this.logger.verbosePii("Redirect start page: " + redirectStartPage);
@@ -10997,10 +11720,10 @@ var RedirectClient = /** @class */ (function (_super) {
10997
11720
  redirectStartPage: redirectStartPage,
10998
11721
  onRedirectNavigate: request.onRedirectNavigate
10999
11722
  })];
11000
- case 5:
11723
+ case 6:
11001
11724
  // Show the UI once the url has been created. Response will come back in the hash, which will be handled in the handleRedirectCallback function.
11002
11725
  return [2 /*return*/, _a.sent()];
11003
- case 6:
11726
+ case 7:
11004
11727
  e_1 = _a.sent();
11005
11728
  if (e_1 instanceof AuthError) {
11006
11729
  e_1.setCorrelationId(this.correlationId);
@@ -11008,7 +11731,7 @@ var RedirectClient = /** @class */ (function (_super) {
11008
11731
  serverTelemetryManager.cacheFailedRequest(e_1);
11009
11732
  this.browserStorage.cleanRequestByState(validRequest.state);
11010
11733
  throw e_1;
11011
- case 7: return [2 /*return*/];
11734
+ case 8: return [2 /*return*/];
11012
11735
  }
11013
11736
  });
11014
11737
  });
@@ -11070,7 +11793,7 @@ var RedirectClient = /** @class */ (function (_super) {
11070
11793
  this.logger.verbose("NavigateToLoginRequestUrl set to false, handling hash");
11071
11794
  return [2 /*return*/, this.handleHash(responseHash, state, serverTelemetryManager)];
11072
11795
  case 4:
11073
- if (!!BrowserUtils.isInIframe()) return [3 /*break*/, 9];
11796
+ if (!(!BrowserUtils.isInIframe() || this.config.system.allowRedirectInIframe)) return [3 /*break*/, 9];
11074
11797
  /*
11075
11798
  * Returned from authority using redirect - need to perform navigation before processing response
11076
11799
  * Cache the hash to be retrieved after the next redirect
@@ -11158,7 +11881,7 @@ var RedirectClient = /** @class */ (function (_super) {
11158
11881
  authClient = _a.sent();
11159
11882
  this.logger.verbose("Auth code client created");
11160
11883
  interactionHandler = new RedirectHandler(authClient, this.browserStorage, cachedRequest, this.logger, this.browserCrypto);
11161
- return [4 /*yield*/, interactionHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient, this.config.auth.clientId)];
11884
+ return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient, this.config.auth.clientId)];
11162
11885
  case 2: return [2 /*return*/, _a.sent()];
11163
11886
  }
11164
11887
  });
@@ -11418,30 +12141,32 @@ var SilentIframeClient = /** @class */ (function (_super) {
11418
12141
  this.logger.verbose("acquireTokenByIframe called");
11419
12142
  // Check that we have some SSO data
11420
12143
  if (StringUtils.isEmpty(request.loginHint) && StringUtils.isEmpty(request.sid) && (!request.account || StringUtils.isEmpty(request.account.username))) {
11421
- throw BrowserAuthError.createSilentSSOInsufficientInfoError();
12144
+ this.logger.warning("No user hint provided. The authorization server may need more information to complete this request.");
11422
12145
  }
11423
12146
  // Check that prompt is set to none, throw error if it is set to anything else.
11424
12147
  if (request.prompt && request.prompt !== PromptValue.NONE) {
11425
12148
  throw BrowserAuthError.createSilentPromptValueError(request.prompt);
11426
12149
  }
11427
- silentRequest = this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent);
11428
- serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
11429
- _a.label = 1;
12150
+ return [4 /*yield*/, this.initializeAuthorizationRequest(__assign$1(__assign$1({}, request), { prompt: PromptValue.NONE }), exports.InteractionType.Silent)];
11430
12151
  case 1:
11431
- _a.trys.push([1, 6, , 7]);
11432
- return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
12152
+ silentRequest = _a.sent();
12153
+ serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
12154
+ _a.label = 2;
11433
12155
  case 2:
12156
+ _a.trys.push([2, 7, , 8]);
12157
+ return [4 /*yield*/, this.initializeAuthorizationCodeRequest(silentRequest)];
12158
+ case 3:
11434
12159
  authCodeRequest = _a.sent();
11435
12160
  return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, silentRequest.authority)];
11436
- case 3:
12161
+ case 4:
11437
12162
  authClient = _a.sent();
11438
12163
  this.logger.verbose("Auth code client created");
11439
12164
  return [4 /*yield*/, authClient.getAuthCodeUrl(silentRequest)];
11440
- case 4:
12165
+ case 5:
11441
12166
  navigateUrl = _a.sent();
11442
12167
  return [4 /*yield*/, this.silentTokenHelper(navigateUrl, authCodeRequest, authClient, this.logger)];
11443
- case 5: return [2 /*return*/, _a.sent()];
11444
- case 6:
12168
+ case 6: return [2 /*return*/, _a.sent()];
12169
+ case 7:
11445
12170
  e_1 = _a.sent();
11446
12171
  if (e_1 instanceof AuthError) {
11447
12172
  e_1.setCorrelationId(this.correlationId);
@@ -11449,7 +12174,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
11449
12174
  serverTelemetryManager.cacheFailedRequest(e_1);
11450
12175
  this.browserStorage.cleanRequestByState(silentRequest.state);
11451
12176
  throw e_1;
11452
- case 7: return [2 /*return*/];
12177
+ case 8: return [2 /*return*/];
11453
12178
  }
11454
12179
  });
11455
12180
  });
@@ -11482,7 +12207,7 @@ var SilentIframeClient = /** @class */ (function (_super) {
11482
12207
  hash = _a.sent();
11483
12208
  state = this.validateAndExtractStateFromHash(hash, exports.InteractionType.Silent, authCodeRequest.correlationId);
11484
12209
  // Handle response from hash string
11485
- return [2 /*return*/, silentHandler.handleCodeResponse(hash, state, authClient.authority, this.networkClient)];
12210
+ return [2 /*return*/, silentHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient)];
11486
12211
  }
11487
12212
  });
11488
12213
  });
@@ -11505,16 +12230,19 @@ var SilentRefreshClient = /** @class */ (function (_super) {
11505
12230
  */
11506
12231
  SilentRefreshClient.prototype.acquireToken = function (request) {
11507
12232
  return __awaiter$1(this, void 0, void 0, function () {
11508
- var silentRequest, serverTelemetryManager, refreshTokenClient;
12233
+ var silentRequest, _a, serverTelemetryManager, refreshTokenClient;
11509
12234
  var _this = this;
11510
- return __generator$1(this, function (_a) {
11511
- switch (_a.label) {
12235
+ return __generator$1(this, function (_b) {
12236
+ switch (_b.label) {
11512
12237
  case 0:
11513
- silentRequest = __assign$1(__assign$1({}, request), this.initializeBaseRequest(request));
12238
+ _a = [__assign$1({}, request)];
12239
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
12240
+ case 1:
12241
+ silentRequest = __assign$1.apply(void 0, _a.concat([_b.sent()]));
11514
12242
  serverTelemetryManager = this.initializeServerTelemetryManager(exports.ApiId.acquireTokenSilent_silentFlow);
11515
12243
  return [4 /*yield*/, this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority)];
11516
- case 1:
11517
- refreshTokenClient = _a.sent();
12244
+ case 2:
12245
+ refreshTokenClient = _b.sent();
11518
12246
  this.logger.verbose("Refresh token client created");
11519
12247
  // Send request to renew token. Auth module will throw errors if token cannot be renewed.
11520
12248
  return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(silentRequest).catch(function (e) {
@@ -11673,6 +12401,90 @@ var TokenCache = /** @class */ (function () {
11673
12401
  return TokenCache;
11674
12402
  }());
11675
12403
 
12404
+ /*
12405
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12406
+ * Licensed under the MIT License.
12407
+ */
12408
+ var HybridSpaAuthorizationCodeClient = /** @class */ (function (_super) {
12409
+ __extends$1(HybridSpaAuthorizationCodeClient, _super);
12410
+ function HybridSpaAuthorizationCodeClient(config) {
12411
+ var _this = _super.call(this, config) || this;
12412
+ _this.includeRedirectUri = false;
12413
+ return _this;
12414
+ }
12415
+ return HybridSpaAuthorizationCodeClient;
12416
+ }(AuthorizationCodeClient));
12417
+
12418
+ /*
12419
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12420
+ * Licensed under the MIT License.
12421
+ */
12422
+ var SilentAuthCodeClient = /** @class */ (function (_super) {
12423
+ __extends$1(SilentAuthCodeClient, _super);
12424
+ function SilentAuthCodeClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, apiId, correlationId) {
12425
+ var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, correlationId) || this;
12426
+ _this.apiId = apiId;
12427
+ return _this;
12428
+ }
12429
+ /**
12430
+ * Acquires a token silently by redeeming an authorization code against the /token endpoint
12431
+ * @param request
12432
+ */
12433
+ SilentAuthCodeClient.prototype.acquireToken = function (request) {
12434
+ return __awaiter$1(this, void 0, void 0, function () {
12435
+ var silentRequest, serverTelemetryManager, authCodeRequest, clientConfig, authClient, silentHandler, e_1;
12436
+ return __generator$1(this, function (_a) {
12437
+ switch (_a.label) {
12438
+ case 0:
12439
+ this.logger.trace("SilentAuthCodeClient.acquireToken called");
12440
+ // Auth code payload is required
12441
+ if (!request.code) {
12442
+ throw BrowserAuthError.createAuthCodeRequiredError();
12443
+ }
12444
+ return [4 /*yield*/, this.initializeAuthorizationRequest(request, exports.InteractionType.Silent)];
12445
+ case 1:
12446
+ silentRequest = _a.sent();
12447
+ serverTelemetryManager = this.initializeServerTelemetryManager(this.apiId);
12448
+ _a.label = 2;
12449
+ case 2:
12450
+ _a.trys.push([2, 4, , 5]);
12451
+ authCodeRequest = __assign$1(__assign$1({}, silentRequest), { code: request.code });
12452
+ return [4 /*yield*/, this.getClientConfiguration(serverTelemetryManager, silentRequest.authority)];
12453
+ case 3:
12454
+ clientConfig = _a.sent();
12455
+ authClient = new HybridSpaAuthorizationCodeClient(clientConfig);
12456
+ this.logger.verbose("Auth code client created");
12457
+ silentHandler = new SilentHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.config.system.navigateFrameWait);
12458
+ // Handle auth code parameters from request
12459
+ return [2 /*return*/, silentHandler.handleCodeResponseFromServer({
12460
+ code: request.code,
12461
+ msgraph_host: request.msGraphHost,
12462
+ cloud_graph_host_name: request.cloudGraphHostName,
12463
+ cloud_instance_host_name: request.cloudInstanceHostName
12464
+ }, silentRequest.state, authClient.authority, this.networkClient, false)];
12465
+ case 4:
12466
+ e_1 = _a.sent();
12467
+ if (e_1 instanceof AuthError) {
12468
+ e_1.setCorrelationId(this.correlationId);
12469
+ }
12470
+ serverTelemetryManager.cacheFailedRequest(e_1);
12471
+ this.browserStorage.cleanRequestByState(silentRequest.state);
12472
+ throw e_1;
12473
+ case 5: return [2 /*return*/];
12474
+ }
12475
+ });
12476
+ });
12477
+ };
12478
+ /**
12479
+ * Currently Unsupported
12480
+ */
12481
+ SilentAuthCodeClient.prototype.logout = function () {
12482
+ // Synchronous so we must reject
12483
+ return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());
12484
+ };
12485
+ return SilentAuthCodeClient;
12486
+ }(StandardInteractionClient));
12487
+
11676
12488
  /*
11677
12489
  * Copyright (c) Microsoft Corporation. All rights reserved.
11678
12490
  * Licensed under the MIT License.
@@ -11716,8 +12528,10 @@ var ClientApplication = /** @class */ (function () {
11716
12528
  this.navigationClient = this.config.system.navigationClient;
11717
12529
  // Initialize redirectResponse Map
11718
12530
  this.redirectResponse = new Map();
12531
+ // Initial hybrid spa map
12532
+ this.hybridAuthCodeResponses = new Map();
11719
12533
  // Initialize the crypto class.
11720
- this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps() : DEFAULT_CRYPTO_IMPLEMENTATION;
12534
+ this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger) : DEFAULT_CRYPTO_IMPLEMENTATION;
11721
12535
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
11722
12536
  // Initialize the browser storage class.
11723
12537
  this.browserStorage = this.isBrowserEnvironment ?
@@ -11920,6 +12734,77 @@ var ClientApplication = /** @class */ (function () {
11920
12734
  });
11921
12735
  });
11922
12736
  };
12737
+ /**
12738
+ * This function redeems an authorization code (passed as code) from the eSTS token endpoint.
12739
+ * This authorization code should be acquired server-side using a confidential client to acquire a spa_code.
12740
+ * This API is not indended for normal authorization code acquisition and redemption.
12741
+ *
12742
+ * Redemption of this authorization code will not require PKCE, as it was acquired by a confidential client.
12743
+ *
12744
+ * @param request {@link AuthorizationCodeRequest}
12745
+ * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
12746
+ */
12747
+ ClientApplication.prototype.acquireTokenByCode = function (request) {
12748
+ return __awaiter$1(this, void 0, void 0, function () {
12749
+ var response;
12750
+ var _this = this;
12751
+ return __generator$1(this, function (_a) {
12752
+ this.preflightBrowserEnvironmentCheck(exports.InteractionType.Silent);
12753
+ this.logger.trace("acquireTokenByCode called", request.correlationId);
12754
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_START, exports.InteractionType.Silent, request);
12755
+ try {
12756
+ if (!request.code) {
12757
+ throw BrowserAuthError.createAuthCodeRequiredError();
12758
+ }
12759
+ response = this.hybridAuthCodeResponses.get(request.code);
12760
+ if (!response) {
12761
+ this.logger.verbose("Initiating new acquireTokenByCode request", request.correlationId);
12762
+ response = this.acquireTokenByCodeAsync(request)
12763
+ .then(function (result) {
12764
+ _this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, exports.InteractionType.Silent, result);
12765
+ _this.hybridAuthCodeResponses.delete(request.code);
12766
+ return result;
12767
+ })
12768
+ .catch(function (error) {
12769
+ _this.hybridAuthCodeResponses.delete(request.code);
12770
+ throw error;
12771
+ });
12772
+ this.hybridAuthCodeResponses.set(request.code, response);
12773
+ }
12774
+ else {
12775
+ this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
12776
+ }
12777
+ return [2 /*return*/, response];
12778
+ }
12779
+ catch (e) {
12780
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, exports.InteractionType.Silent, null, e);
12781
+ throw e;
12782
+ }
12783
+ return [2 /*return*/];
12784
+ });
12785
+ });
12786
+ };
12787
+ /**
12788
+ * Creates a SilentAuthCodeClient to redeem an authorization code.
12789
+ * @param request
12790
+ * @returns Result of the operation to redeem the authorization code
12791
+ */
12792
+ ClientApplication.prototype.acquireTokenByCodeAsync = function (request) {
12793
+ return __awaiter$1(this, void 0, void 0, function () {
12794
+ var silentAuthCodeClient, silentTokenResult;
12795
+ return __generator$1(this, function (_a) {
12796
+ switch (_a.label) {
12797
+ case 0:
12798
+ this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
12799
+ silentAuthCodeClient = new SilentAuthCodeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, exports.ApiId.acquireTokenByCode, request.correlationId);
12800
+ return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)];
12801
+ case 1:
12802
+ silentTokenResult = _a.sent();
12803
+ return [2 /*return*/, silentTokenResult];
12804
+ }
12805
+ });
12806
+ });
12807
+ };
11923
12808
  /**
11924
12809
  * Use this function to obtain a token before every call to the API / resource provider
11925
12810
  *
@@ -11946,7 +12831,7 @@ var ClientApplication = /** @class */ (function () {
11946
12831
  var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
11947
12832
  if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
11948
12833
  _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
11949
- var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode);
12834
+ var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode, request.correlationId);
11950
12835
  return silentIframeClient.acquireToken(request);
11951
12836
  }
11952
12837
  throw e;
@@ -12119,6 +13004,18 @@ var ClientApplication = /** @class */ (function () {
12119
13004
  ClientApplication.prototype.removeEventCallback = function (callbackId) {
12120
13005
  this.eventHandler.removeEventCallback(callbackId);
12121
13006
  };
13007
+ /**
13008
+ * Adds event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
13009
+ */
13010
+ ClientApplication.prototype.enableAccountStorageEvents = function () {
13011
+ this.eventHandler.enableAccountStorageEvents();
13012
+ };
13013
+ /**
13014
+ * Removes event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
13015
+ */
13016
+ ClientApplication.prototype.disableAccountStorageEvents = function () {
13017
+ this.eventHandler.disableAccountStorageEvents();
13018
+ };
12122
13019
  /**
12123
13020
  * Gets the token cache for the application.
12124
13021
  */
@@ -12154,6 +13051,12 @@ var ClientApplication = /** @class */ (function () {
12154
13051
  ClientApplication.prototype.setNavigationClient = function (navigationClient) {
12155
13052
  this.navigationClient = navigationClient;
12156
13053
  };
13054
+ /**
13055
+ * Returns the configuration object
13056
+ */
13057
+ ClientApplication.prototype.getConfiguration = function () {
13058
+ return this.config;
13059
+ };
12157
13060
  return ClientApplication;
12158
13061
  }());
12159
13062
 
@@ -12226,7 +13129,17 @@ var SilentCacheClient = /** @class */ (function (_super) {
12226
13129
  });
12227
13130
  };
12228
13131
  SilentCacheClient.prototype.initializeSilentRequest = function (request, account) {
12229
- return __assign$1(__assign$1(__assign$1({}, request), this.initializeBaseRequest(request)), { account: account, forceRefresh: request.forceRefresh || false });
13132
+ return __awaiter$1(this, void 0, void 0, function () {
13133
+ var _a;
13134
+ return __generator$1(this, function (_b) {
13135
+ switch (_b.label) {
13136
+ case 0:
13137
+ _a = [__assign$1({}, request)];
13138
+ return [4 /*yield*/, this.initializeBaseRequest(request)];
13139
+ 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 }])];
13140
+ }
13141
+ });
13142
+ });
12230
13143
  };
12231
13144
  return SilentCacheClient;
12232
13145
  }(StandardInteractionClient));
@@ -12317,10 +13230,12 @@ var PublicClientApplication = /** @class */ (function (_super) {
12317
13230
  authority: request.authority || "",
12318
13231
  scopes: request.scopes,
12319
13232
  homeAccountIdentifier: account.homeAccountId,
13233
+ claims: request.claims,
12320
13234
  authenticationScheme: request.authenticationScheme,
12321
13235
  resourceRequestMethod: request.resourceRequestMethod,
12322
13236
  resourceRequestUri: request.resourceRequestUri,
12323
- shrClaims: request.shrClaims
13237
+ shrClaims: request.shrClaims,
13238
+ sshKid: request.sshKid
12324
13239
  };
12325
13240
  silentRequestKey = JSON.stringify(thumbprint);
12326
13241
  cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
@@ -12356,28 +13271,33 @@ var PublicClientApplication = /** @class */ (function (_super) {
12356
13271
  var silentCacheClient, silentRequest;
12357
13272
  var _this = this;
12358
13273
  return __generator$1(this, function (_a) {
12359
- silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient);
12360
- silentRequest = silentCacheClient.initializeSilentRequest(request, account);
12361
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
12362
- return [2 /*return*/, silentCacheClient.acquireToken(silentRequest).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
12363
- var tokenRenewalResult, tokenRenewalError_1;
12364
- return __generator$1(this, function (_a) {
12365
- switch (_a.label) {
12366
- case 0:
12367
- _a.trys.push([0, 2, , 3]);
12368
- return [4 /*yield*/, this.acquireTokenByRefreshToken(silentRequest)];
12369
- case 1:
12370
- tokenRenewalResult = _a.sent();
12371
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, tokenRenewalResult);
12372
- return [2 /*return*/, tokenRenewalResult];
12373
- case 2:
12374
- tokenRenewalError_1 = _a.sent();
12375
- this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError_1);
12376
- throw tokenRenewalError_1;
12377
- case 3: return [2 /*return*/];
12378
- }
12379
- });
12380
- }); })];
13274
+ switch (_a.label) {
13275
+ case 0:
13276
+ silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
13277
+ return [4 /*yield*/, silentCacheClient.initializeSilentRequest(request, account)];
13278
+ case 1:
13279
+ silentRequest = _a.sent();
13280
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
13281
+ return [2 /*return*/, silentCacheClient.acquireToken(silentRequest).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
13282
+ var tokenRenewalResult, tokenRenewalError_1;
13283
+ return __generator$1(this, function (_a) {
13284
+ switch (_a.label) {
13285
+ case 0:
13286
+ _a.trys.push([0, 2, , 3]);
13287
+ return [4 /*yield*/, this.acquireTokenByRefreshToken(silentRequest)];
13288
+ case 1:
13289
+ tokenRenewalResult = _a.sent();
13290
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_SUCCESS, exports.InteractionType.Silent, tokenRenewalResult);
13291
+ return [2 /*return*/, tokenRenewalResult];
13292
+ case 2:
13293
+ tokenRenewalError_1 = _a.sent();
13294
+ this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_FAILURE, exports.InteractionType.Silent, null, tokenRenewalError_1);
13295
+ throw tokenRenewalError_1;
13296
+ case 3: return [2 /*return*/];
13297
+ }
13298
+ });
13299
+ }); })];
13300
+ }
12381
13301
  });
12382
13302
  });
12383
13303
  };
@@ -12398,6 +13318,9 @@ var stubbedPublicClientApplication = {
12398
13318
  acquireTokenSilent: function () {
12399
13319
  return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
12400
13320
  },
13321
+ acquireTokenByCode: function () {
13322
+ return Promise.reject(BrowserConfigurationAuthError.createStubPcaInstanceCalledError());
13323
+ },
12401
13324
  getAllAccounts: function () {
12402
13325
  return [];
12403
13326
  },
@@ -12437,6 +13360,12 @@ var stubbedPublicClientApplication = {
12437
13360
  removeEventCallback: function () {
12438
13361
  return;
12439
13362
  },
13363
+ enableAccountStorageEvents: function () {
13364
+ return;
13365
+ },
13366
+ disableAccountStorageEvents: function () {
13367
+ return;
13368
+ },
12440
13369
  getTokenCache: function () {
12441
13370
  throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
12442
13371
  },
@@ -12457,6 +13386,9 @@ var stubbedPublicClientApplication = {
12457
13386
  },
12458
13387
  setNavigationClient: function () {
12459
13388
  return;
13389
+ },
13390
+ getConfiguration: function () {
13391
+ throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
12460
13392
  }
12461
13393
  };
12462
13394
 
@@ -12529,8 +13461,10 @@ var EventMessageUtils = /** @class */ (function () {
12529
13461
  * Licensed under the MIT License.
12530
13462
  */
12531
13463
  var SignedHttpRequest = /** @class */ (function () {
12532
- function SignedHttpRequest(shrParameters) {
12533
- this.cryptoOps = new CryptoOps();
13464
+ function SignedHttpRequest(shrParameters, shrOptions) {
13465
+ var loggerOptions = (shrOptions && shrOptions.loggerOptions) || {};
13466
+ this.logger = new Logger(loggerOptions, name, version);
13467
+ this.cryptoOps = new CryptoOps(this.logger);
12534
13468
  this.popTokenGenerator = new PopTokenGenerator(this.cryptoOps);
12535
13469
  this.shrParameters = shrParameters;
12536
13470
  }
@@ -12573,7 +13507,10 @@ var SignedHttpRequest = /** @class */ (function () {
12573
13507
  SignedHttpRequest.prototype.removeKeys = function (publicKeyThumbprint) {
12574
13508
  return __awaiter$1(this, void 0, void 0, function () {
12575
13509
  return __generator$1(this, function (_a) {
12576
- return [2 /*return*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
13510
+ switch (_a.label) {
13511
+ case 0: return [4 /*yield*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
13512
+ case 1: return [2 /*return*/, _a.sent()];
13513
+ }
12577
13514
  });
12578
13515
  });
12579
13516
  };
@@ -12583,18 +13520,26 @@ var SignedHttpRequest = /** @class */ (function () {
12583
13520
  exports.AccountEntity = AccountEntity;
12584
13521
  exports.AuthError = AuthError;
12585
13522
  exports.AuthErrorMessage = AuthErrorMessage;
13523
+ exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
12586
13524
  exports.BrowserAuthError = BrowserAuthError;
12587
13525
  exports.BrowserAuthErrorMessage = BrowserAuthErrorMessage;
12588
13526
  exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;
12589
13527
  exports.BrowserConfigurationAuthErrorMessage = BrowserConfigurationAuthErrorMessage;
12590
13528
  exports.BrowserUtils = BrowserUtils;
13529
+ exports.ClientAuthError = ClientAuthError;
13530
+ exports.ClientAuthErrorMessage = ClientAuthErrorMessage;
13531
+ exports.ClientConfigurationError = ClientConfigurationError;
13532
+ exports.ClientConfigurationErrorMessage = ClientConfigurationErrorMessage;
12591
13533
  exports.EventMessageUtils = EventMessageUtils;
12592
13534
  exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
13535
+ exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
12593
13536
  exports.Logger = Logger;
12594
13537
  exports.NavigationClient = NavigationClient;
12595
13538
  exports.PublicClientApplication = PublicClientApplication;
13539
+ exports.ServerError = ServerError;
12596
13540
  exports.SignedHttpRequest = SignedHttpRequest;
12597
13541
  exports.StringUtils = StringUtils;
12598
13542
  exports.UrlString = UrlString;
12599
13543
  exports.stubbedPublicClientApplication = stubbedPublicClientApplication;
13544
+ exports.version = version;
12600
13545
  //# sourceMappingURL=index.cjs.js.map