@azure/msal-browser 2.18.0 → 2.19.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 (131) hide show
  1. package/CHANGELOG.json +1613 -1548
  2. package/CHANGELOG.md +510 -491
  3. package/LICENSE +21 -21
  4. package/README.md +1 -1
  5. package/dist/_virtual/_tslib.js +1 -1
  6. package/dist/app/ClientApplication.d.ts +4 -0
  7. package/dist/app/ClientApplication.d.ts.map +1 -1
  8. package/dist/app/ClientApplication.js +9 -3
  9. package/dist/app/ClientApplication.js.map +1 -1
  10. package/dist/app/IPublicClientApplication.d.ts +2 -0
  11. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  12. package/dist/app/IPublicClientApplication.js +4 -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 +5 -3
  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.map +1 -1
  22. package/dist/cache/BrowserCacheManager.js +1 -1
  23. package/dist/cache/BrowserCacheManager.js.map +1 -1
  24. package/dist/cache/BrowserStorage.d.ts +1 -1
  25. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  26. package/dist/cache/BrowserStorage.js +1 -1
  27. package/dist/cache/BrowserStorage.js.map +1 -1
  28. package/dist/cache/DatabaseStorage.d.ts +25 -6
  29. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  30. package/dist/cache/DatabaseStorage.js +127 -81
  31. package/dist/cache/DatabaseStorage.js.map +1 -1
  32. package/dist/cache/IAsyncMemoryStorage.d.ts +28 -0
  33. package/dist/cache/IAsyncMemoryStorage.d.ts.map +1 -0
  34. package/dist/cache/IWindowStorage.d.ts +3 -3
  35. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  36. package/dist/cache/MemoryStorage.d.ts +3 -3
  37. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  38. package/dist/cache/MemoryStorage.js +1 -1
  39. package/dist/cache/MemoryStorage.js.map +1 -1
  40. package/dist/cache/TokenCache.js +1 -1
  41. package/dist/cache/TokenCache.js.map +1 -1
  42. package/dist/config/Configuration.js +1 -1
  43. package/dist/config/Configuration.js.map +1 -1
  44. package/dist/crypto/BrowserCrypto.d.ts +3 -1
  45. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  46. package/dist/crypto/BrowserCrypto.js +3 -2
  47. package/dist/crypto/BrowserCrypto.js.map +1 -1
  48. package/dist/crypto/CryptoOps.d.ts +11 -5
  49. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  50. package/dist/crypto/CryptoOps.js +37 -13
  51. package/dist/crypto/CryptoOps.js.map +1 -1
  52. package/dist/crypto/GuidGenerator.js +1 -1
  53. package/dist/crypto/GuidGenerator.js.map +1 -1
  54. package/dist/crypto/PkceGenerator.js +1 -1
  55. package/dist/crypto/PkceGenerator.js.map +1 -1
  56. package/dist/crypto/SignedHttpRequest.d.ts +6 -2
  57. package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
  58. package/dist/crypto/SignedHttpRequest.js +11 -5
  59. package/dist/crypto/SignedHttpRequest.js.map +1 -1
  60. package/dist/encode/Base64Decode.js +1 -1
  61. package/dist/encode/Base64Decode.js.map +1 -1
  62. package/dist/encode/Base64Encode.js +1 -1
  63. package/dist/encode/Base64Encode.js.map +1 -1
  64. package/dist/error/BrowserAuthError.d.ts +8 -0
  65. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  66. package/dist/error/BrowserAuthError.js +12 -2
  67. package/dist/error/BrowserAuthError.js.map +1 -1
  68. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  69. package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
  70. package/dist/event/EventHandler.js +1 -1
  71. package/dist/event/EventHandler.js.map +1 -1
  72. package/dist/event/EventMessage.js +1 -1
  73. package/dist/event/EventMessage.js.map +1 -1
  74. package/dist/event/EventType.js +1 -1
  75. package/dist/event/EventType.js.map +1 -1
  76. package/dist/index.cjs.js +722 -242
  77. package/dist/index.cjs.js.map +1 -1
  78. package/dist/index.d.ts +3 -3
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +2 -2
  81. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  82. package/dist/interaction_client/BaseInteractionClient.js +10 -2
  83. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  84. package/dist/interaction_client/PopupClient.js +1 -1
  85. package/dist/interaction_client/PopupClient.js.map +1 -1
  86. package/dist/interaction_client/RedirectClient.js +2 -2
  87. package/dist/interaction_client/RedirectClient.js.map +1 -1
  88. package/dist/interaction_client/SilentCacheClient.js +1 -1
  89. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  90. package/dist/interaction_client/SilentIframeClient.js +1 -1
  91. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  92. package/dist/interaction_client/SilentRefreshClient.js +1 -1
  93. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  94. package/dist/interaction_client/StandardInteractionClient.js +1 -1
  95. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  96. package/dist/interaction_handler/InteractionHandler.js +1 -1
  97. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  98. package/dist/interaction_handler/PopupHandler.js +1 -1
  99. package/dist/interaction_handler/PopupHandler.js.map +1 -1
  100. package/dist/interaction_handler/RedirectHandler.js +1 -1
  101. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  102. package/dist/interaction_handler/SilentHandler.js +1 -1
  103. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  104. package/dist/navigation/NavigationClient.js +1 -1
  105. package/dist/navigation/NavigationClient.js.map +1 -1
  106. package/dist/network/FetchClient.js +1 -1
  107. package/dist/network/FetchClient.js.map +1 -1
  108. package/dist/network/XhrClient.js +1 -1
  109. package/dist/network/XhrClient.js.map +1 -1
  110. package/dist/packageMetadata.d.ts +1 -1
  111. package/dist/packageMetadata.js +2 -2
  112. package/dist/packageMetadata.js.map +1 -1
  113. package/dist/request/RedirectRequest.d.ts.map +1 -1
  114. package/dist/utils/BrowserConstants.d.ts +3 -0
  115. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  116. package/dist/utils/BrowserConstants.js +7 -3
  117. package/dist/utils/BrowserConstants.js.map +1 -1
  118. package/dist/utils/BrowserProtocolUtils.js +1 -1
  119. package/dist/utils/BrowserProtocolUtils.js.map +1 -1
  120. package/dist/utils/BrowserStringUtils.js +1 -1
  121. package/dist/utils/BrowserStringUtils.js.map +1 -1
  122. package/dist/utils/BrowserUtils.js +1 -1
  123. package/dist/utils/BrowserUtils.js.map +1 -1
  124. package/dist/utils/MathUtils.js +1 -1
  125. package/dist/utils/MathUtils.js.map +1 -1
  126. package/dist/utils/PopupUtils.js +1 -1
  127. package/dist/utils/PopupUtils.js.map +1 -1
  128. package/lib/msal-browser.js +722 -242
  129. package/lib/msal-browser.js.map +1 -1
  130. package/lib/msal-browser.min.js +31 -31
  131. package/package.json +95 -94
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v2.18.0 2021-10-05 */
1
+ /*! @azure/msal-browser v2.19.0 2021-11-02 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -105,7 +105,7 @@ function __spread() {
105
105
  return ar;
106
106
  }
107
107
 
108
- /*! @azure/msal-common v5.0.1 2021-10-05 */
108
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
109
109
  /*! *****************************************************************************
110
110
  Copyright (c) Microsoft Corporation.
111
111
 
@@ -192,7 +192,7 @@ function __spreadArrays() {
192
192
  return r;
193
193
  }
194
194
 
195
- /*! @azure/msal-common v5.0.1 2021-10-05 */
195
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
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.
@@ -484,8 +486,9 @@ var SERVER_TELEM_CONSTANTS = {
484
486
  */
485
487
  exports.AuthenticationScheme = void 0;
486
488
  (function (AuthenticationScheme) {
487
- AuthenticationScheme["POP"] = "pop";
488
489
  AuthenticationScheme["BEARER"] = "Bearer";
490
+ AuthenticationScheme["POP"] = "pop";
491
+ AuthenticationScheme["SSH"] = "ssh-cert";
489
492
  })(exports.AuthenticationScheme || (exports.AuthenticationScheme = {}));
490
493
  /**
491
494
  * Constants related to throttling
@@ -550,7 +553,7 @@ var CacheOutcome;
550
553
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
551
554
  })(CacheOutcome || (CacheOutcome = {}));
552
555
 
553
- /*! @azure/msal-common v5.0.1 2021-10-05 */
556
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
554
557
 
555
558
  /*
556
559
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -594,7 +597,7 @@ var AuthError = /** @class */ (function (_super) {
594
597
  return AuthError;
595
598
  }(Error));
596
599
 
597
- /*! @azure/msal-common v5.0.1 2021-10-05 */
600
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
598
601
 
599
602
  /*
600
603
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -660,7 +663,7 @@ var DEFAULT_CRYPTO_IMPLEMENTATION = {
660
663
  }
661
664
  };
662
665
 
663
- /*! @azure/msal-common v5.0.1 2021-10-05 */
666
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
664
667
 
665
668
  /*
666
669
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -846,6 +849,10 @@ var ClientAuthErrorMessage = {
846
849
  bindingKeyNotRemovedError: {
847
850
  code: "binding_key_not_removed",
848
851
  desc: "Could not remove the credential's binding key from storage."
852
+ },
853
+ logoutNotSupported: {
854
+ code: "end_session_endpoint_not_supported",
855
+ desc: "Provided authority does not support logout."
849
856
  }
850
857
  };
851
858
  /**
@@ -1109,10 +1116,16 @@ var ClientAuthError = /** @class */ (function (_super) {
1109
1116
  ClientAuthError.createBindingKeyNotRemovedError = function () {
1110
1117
  return new ClientAuthError(ClientAuthErrorMessage.bindingKeyNotRemovedError.code, ClientAuthErrorMessage.bindingKeyNotRemovedError.desc);
1111
1118
  };
1119
+ /**
1120
+ * Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
1121
+ */
1122
+ ClientAuthError.createLogoutNotSupportedError = function () {
1123
+ return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
1124
+ };
1112
1125
  return ClientAuthError;
1113
1126
  }(AuthError));
1114
1127
 
1115
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1128
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1116
1129
 
1117
1130
  /*
1118
1131
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1237,7 +1250,7 @@ var StringUtils = /** @class */ (function () {
1237
1250
  return StringUtils;
1238
1251
  }());
1239
1252
 
1240
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1253
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1241
1254
 
1242
1255
  /*
1243
1256
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1417,12 +1430,12 @@ var Logger = /** @class */ (function () {
1417
1430
  return Logger;
1418
1431
  }());
1419
1432
 
1420
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1433
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1421
1434
  /* eslint-disable header/header */
1422
1435
  var name$1 = "@azure/msal-common";
1423
- var version$1 = "5.0.1";
1436
+ var version$1 = "5.1.0";
1424
1437
 
1425
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1438
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1426
1439
 
1427
1440
  /*
1428
1441
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1524,8 +1537,8 @@ var CredentialEntity = /** @class */ (function () {
1524
1537
  this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
1525
1538
  this.generateTargetForCacheKey(target)
1526
1539
  ];
1527
- // PoP Tokens include scheme in cache key
1528
- if (tokenType === exports.AuthenticationScheme.POP) {
1540
+ // PoP Tokens and SSH certs include scheme in cache key
1541
+ if (tokenType && tokenType !== exports.AuthenticationScheme.BEARER) {
1529
1542
  credentialKey.push(tokenType.toLowerCase());
1530
1543
  }
1531
1544
  return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
@@ -1566,7 +1579,7 @@ var CredentialEntity = /** @class */ (function () {
1566
1579
  return CredentialEntity;
1567
1580
  }());
1568
1581
 
1569
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1582
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1570
1583
 
1571
1584
  /*
1572
1585
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1638,15 +1651,31 @@ var ClientConfigurationErrorMessage = {
1638
1651
  },
1639
1652
  invalidCloudDiscoveryMetadata: {
1640
1653
  code: "invalid_cloud_discovery_metadata",
1641
- desc: "Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields"
1654
+ desc: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields"
1642
1655
  },
1643
1656
  invalidAuthorityMetadata: {
1644
1657
  code: "invalid_authority_metadata",
1645
- desc: "Invalid authorityMetadata provided. Must by a JSON object containing authorization_endpoint, token_endpoint, end_session_endpoint, issuer fields."
1658
+ desc: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields."
1646
1659
  },
1647
1660
  untrustedAuthority: {
1648
1661
  code: "untrusted_authority",
1649
1662
  desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."
1663
+ },
1664
+ missingSshJwk: {
1665
+ code: "missing_ssh_jwk",
1666
+ desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."
1667
+ },
1668
+ missingSshKid: {
1669
+ code: "missing_ssh_kid",
1670
+ desc: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme."
1671
+ },
1672
+ missingNonceAuthenticationHeader: {
1673
+ code: "missing_nonce_authentication_header",
1674
+ 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."
1675
+ },
1676
+ invalidAuthenticationHeader: {
1677
+ code: "invalid_authentication_header",
1678
+ desc: "Invalid authentication header provided"
1650
1679
  }
1651
1680
  };
1652
1681
  /**
@@ -1768,10 +1797,34 @@ var ClientConfigurationError = /** @class */ (function (_super) {
1768
1797
  ClientConfigurationError.createUntrustedAuthorityError = function () {
1769
1798
  return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);
1770
1799
  };
1800
+ /*
1801
+ * Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
1802
+ */
1803
+ ClientConfigurationError.createMissingSshJwkError = function () {
1804
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshJwk.code, ClientConfigurationErrorMessage.missingSshJwk.desc);
1805
+ };
1806
+ /**
1807
+ * Throws an error when the authentication scheme is set to SSH but the SSH public key ID is omitted from the request
1808
+ */
1809
+ ClientConfigurationError.createMissingSshKidError = function () {
1810
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshKid.code, ClientConfigurationErrorMessage.missingSshKid.desc);
1811
+ };
1812
+ /**
1813
+ * Throws error when provided headers don't contain a header that a server nonce can be extracted from
1814
+ */
1815
+ ClientConfigurationError.createMissingNonceAuthenticationHeadersError = function () {
1816
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.code, ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.desc);
1817
+ };
1818
+ /**
1819
+ * Throws error when a provided header is invalid in any way
1820
+ */
1821
+ ClientConfigurationError.createInvalidAuthenticationHeaderError = function (invalidHeaderName, details) {
1822
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc + ". Invalid header: " + invalidHeaderName + ". Details: " + details);
1823
+ };
1771
1824
  return ClientConfigurationError;
1772
1825
  }(ClientAuthError));
1773
1826
 
1774
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1827
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1775
1828
 
1776
1829
  /*
1777
1830
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1955,7 +2008,7 @@ var ScopeSet = /** @class */ (function () {
1955
2008
  return ScopeSet;
1956
2009
  }());
1957
2010
 
1958
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2011
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1959
2012
 
1960
2013
  /*
1961
2014
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1993,7 +2046,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
1993
2046
  };
1994
2047
  }
1995
2048
 
1996
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2049
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1997
2050
  /*
1998
2051
  * Copyright (c) Microsoft Corporation. All rights reserved.
1999
2052
  * Licensed under the MIT License.
@@ -2007,7 +2060,7 @@ var AuthorityType;
2007
2060
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2008
2061
  })(AuthorityType || (AuthorityType = {}));
2009
2062
 
2010
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2063
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
2011
2064
 
2012
2065
  /*
2013
2066
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2241,7 +2294,7 @@ var AccountEntity = /** @class */ (function () {
2241
2294
  return AccountEntity;
2242
2295
  }());
2243
2296
 
2244
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2297
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
2245
2298
 
2246
2299
  /*
2247
2300
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2279,7 +2332,7 @@ var AuthToken = /** @class */ (function () {
2279
2332
  return AuthToken;
2280
2333
  }());
2281
2334
 
2282
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2335
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
2283
2336
 
2284
2337
  /*
2285
2338
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2441,7 +2494,7 @@ var CacheManager = /** @class */ (function () {
2441
2494
  * @param target
2442
2495
  */
2443
2496
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
2444
- return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType);
2497
+ return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType, filter.keyId);
2445
2498
  };
2446
2499
  /**
2447
2500
  * Support function to help match credentials
@@ -2454,7 +2507,7 @@ var CacheManager = /** @class */ (function () {
2454
2507
  * @param oboAssertion
2455
2508
  * @param tokenType
2456
2509
  */
2457
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType) {
2510
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId) {
2458
2511
  var _this = this;
2459
2512
  var allCacheKeys = this.getKeys();
2460
2513
  var matchingCredentials = {
@@ -2501,15 +2554,26 @@ var CacheManager = /** @class */ (function () {
2501
2554
  if (!!target && !_this.matchTarget(entity, target)) {
2502
2555
  return;
2503
2556
  }
2557
+ // Access Token with Auth Scheme specific matching
2504
2558
  if (credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
2505
2559
  if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
2506
2560
  return;
2507
2561
  }
2508
- // This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
2509
- if (cacheKey.indexOf(exports.AuthenticationScheme.POP) === -1) {
2510
- // AccessToken_With_AuthScheme that doesn't have pop in the key is outdated
2511
- _this.removeItem(cacheKey, CacheSchemaType.CREDENTIAL);
2512
- return;
2562
+ switch (tokenType) {
2563
+ case exports.AuthenticationScheme.POP:
2564
+ // This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
2565
+ if (cacheKey.indexOf(exports.AuthenticationScheme.POP) === -1) {
2566
+ // AccessToken_With_AuthScheme that doesn't have "-pop" in the key is outdated and needs to be removed
2567
+ _this.removeItem(cacheKey, CacheSchemaType.CREDENTIAL);
2568
+ return;
2569
+ }
2570
+ break;
2571
+ case exports.AuthenticationScheme.SSH:
2572
+ // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
2573
+ if (keyId && !_this.matchKeyId(entity, keyId)) {
2574
+ return;
2575
+ }
2576
+ break;
2513
2577
  }
2514
2578
  }
2515
2579
  switch (credType) {
@@ -2680,6 +2744,7 @@ var CacheManager = /** @class */ (function () {
2680
2744
  case 0:
2681
2745
  key = credential.generateCredentialKey();
2682
2746
  if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
2747
+ if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
2683
2748
  accessTokenWithAuthSchemeEntity = credential;
2684
2749
  kid = accessTokenWithAuthSchemeEntity.keyId;
2685
2750
  if (!kid) return [3 /*break*/, 4];
@@ -2719,10 +2784,10 @@ var CacheManager = /** @class */ (function () {
2719
2784
  * @param environment
2720
2785
  * @param authScheme
2721
2786
  */
2722
- CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme) {
2787
+ CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme, keyId) {
2723
2788
  var cachedAccount = this.readAccountFromCache(account);
2724
2789
  var cachedIdToken = this.readIdTokenFromCache(clientId, account);
2725
- var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme);
2790
+ var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme, keyId);
2726
2791
  var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
2727
2792
  var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
2728
2793
  if (cachedAccount && cachedIdToken) {
@@ -2776,9 +2841,9 @@ var CacheManager = /** @class */ (function () {
2776
2841
  * @param scopes
2777
2842
  * @param authScheme
2778
2843
  */
2779
- CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme) {
2780
- // Distinguish between Bearer and PoP token cache types
2781
- var credentialType = (authScheme === exports.AuthenticationScheme.POP) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
2844
+ CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme, keyId) {
2845
+ // Distinguish between Bearer and PoP/SSH token cache types
2846
+ var credentialType = (authScheme && authScheme !== exports.AuthenticationScheme.BEARER) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
2782
2847
  var accessTokenFilter = {
2783
2848
  homeAccountId: account.homeAccountId,
2784
2849
  environment: account.environment,
@@ -2786,7 +2851,8 @@ var CacheManager = /** @class */ (function () {
2786
2851
  clientId: clientId,
2787
2852
  realm: account.tenantId,
2788
2853
  target: scopes.printScopesLowerCase(),
2789
- tokenType: authScheme
2854
+ tokenType: authScheme,
2855
+ keyId: keyId
2790
2856
  };
2791
2857
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
2792
2858
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -2939,6 +3005,14 @@ var CacheManager = /** @class */ (function () {
2939
3005
  CacheManager.prototype.matchTokenType = function (entity, tokenType) {
2940
3006
  return !!(entity.tokenType && entity.tokenType === tokenType);
2941
3007
  };
3008
+ /**
3009
+ * Returns true if the credential's keyId matches the one in the request, false otherwise
3010
+ * @param entity
3011
+ * @param tokenType
3012
+ */
3013
+ CacheManager.prototype.matchKeyId = function (entity, keyId) {
3014
+ return !!(entity.keyId && entity.keyId === keyId);
3015
+ };
2942
3016
  /**
2943
3017
  * returns if a given cache entity is of the type appmetadata
2944
3018
  * @param key
@@ -3090,7 +3164,7 @@ var DefaultStorageClass = /** @class */ (function (_super) {
3090
3164
  return DefaultStorageClass;
3091
3165
  }(CacheManager));
3092
3166
 
3093
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3167
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3094
3168
 
3095
3169
  /*
3096
3170
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3172,7 +3246,7 @@ function buildAuthOptions(authOptions) {
3172
3246
  return __assign({ clientCapabilities: [] }, authOptions);
3173
3247
  }
3174
3248
 
3175
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3249
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3176
3250
 
3177
3251
  /*
3178
3252
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3192,7 +3266,7 @@ var ServerError = /** @class */ (function (_super) {
3192
3266
  return ServerError;
3193
3267
  }(AuthError));
3194
3268
 
3195
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3269
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3196
3270
 
3197
3271
  /*
3198
3272
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3278,7 +3352,9 @@ var ThrottlingUtils = /** @class */ (function () {
3278
3352
  authenticationScheme: request.authenticationScheme,
3279
3353
  resourceRequestMethod: request.resourceRequestMethod,
3280
3354
  resourceRequestUri: request.resourceRequestUri,
3281
- shrClaims: request.shrClaims
3355
+ shrClaims: request.shrClaims,
3356
+ sshJwk: request.sshJwk,
3357
+ sshKid: request.sshKid
3282
3358
  };
3283
3359
  var key = this.generateThrottlingStorageKey(thumbprint);
3284
3360
  return cacheManager.removeItem(key, CacheSchemaType.THROTTLING);
@@ -3286,7 +3362,7 @@ var ThrottlingUtils = /** @class */ (function () {
3286
3362
  return ThrottlingUtils;
3287
3363
  }());
3288
3364
 
3289
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3365
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3290
3366
 
3291
3367
  /*
3292
3368
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3335,7 +3411,7 @@ var NetworkManager = /** @class */ (function () {
3335
3411
  return NetworkManager;
3336
3412
  }());
3337
3413
 
3338
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3414
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3339
3415
  /*
3340
3416
  * Copyright (c) Microsoft Corporation. All rights reserved.
3341
3417
  * Licensed under the MIT License.
@@ -3346,7 +3422,7 @@ var CcsCredentialType;
3346
3422
  CcsCredentialType["UPN"] = "UPN";
3347
3423
  })(CcsCredentialType || (CcsCredentialType = {}));
3348
3424
 
3349
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3425
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3350
3426
 
3351
3427
  /*
3352
3428
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3435,7 +3511,7 @@ var BaseClient = /** @class */ (function () {
3435
3511
  return BaseClient;
3436
3512
  }());
3437
3513
 
3438
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3514
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3439
3515
 
3440
3516
  /*
3441
3517
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3521,7 +3597,7 @@ var RequestValidator = /** @class */ (function () {
3521
3597
  return RequestValidator;
3522
3598
  }());
3523
3599
 
3524
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3600
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3525
3601
 
3526
3602
  /*
3527
3603
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3825,6 +3901,15 @@ var RequestParameterBuilder = /** @class */ (function () {
3825
3901
  this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
3826
3902
  }
3827
3903
  };
3904
+ /**
3905
+ * add SSH JWK and key ID to query params
3906
+ */
3907
+ RequestParameterBuilder.prototype.addSshJwk = function (sshJwkString) {
3908
+ if (!StringUtils.isEmpty(sshJwkString)) {
3909
+ this.parameters.set(AADServerParamKeys.TOKEN_TYPE, exports.AuthenticationScheme.SSH);
3910
+ this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(sshJwkString));
3911
+ }
3912
+ };
3828
3913
  /**
3829
3914
  * add server telemetry fields
3830
3915
  * @param serverTelemetryManager
@@ -3852,7 +3937,7 @@ var RequestParameterBuilder = /** @class */ (function () {
3852
3937
  return RequestParameterBuilder;
3853
3938
  }());
3854
3939
 
3855
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3940
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3856
3941
 
3857
3942
  /*
3858
3943
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3917,7 +4002,7 @@ var IdTokenEntity = /** @class */ (function (_super) {
3917
4002
  return IdTokenEntity;
3918
4003
  }(CredentialEntity));
3919
4004
 
3920
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4005
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3921
4006
  /*
3922
4007
  * Copyright (c) Microsoft Corporation. All rights reserved.
3923
4008
  * Licensed under the MIT License.
@@ -3967,7 +4052,7 @@ var TimeUtils = /** @class */ (function () {
3967
4052
  return TimeUtils;
3968
4053
  }());
3969
4054
 
3970
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4055
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3971
4056
 
3972
4057
  /*
3973
4058
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4013,7 +4098,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4013
4098
  * @param expiresOn
4014
4099
  * @param extExpiresOn
4015
4100
  */
4016
- AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion) {
4101
+ AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId) {
4017
4102
  var _a;
4018
4103
  var atEntity = new AccessTokenEntity();
4019
4104
  atEntity.homeAccountId = homeAccountId;
@@ -4036,15 +4121,21 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4036
4121
  atEntity.target = scopes;
4037
4122
  atEntity.oboAssertion = oboAssertion;
4038
4123
  atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
4039
- // Create Access Token With AuthScheme instead of regular access token
4040
- if (atEntity.tokenType === exports.AuthenticationScheme.POP) {
4124
+ // Create Access Token With Auth Scheme instead of regular access token
4125
+ if (atEntity.tokenType !== exports.AuthenticationScheme.BEARER) {
4041
4126
  atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
4042
- // Make sure keyId is present and add it to credential
4043
- var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
4044
- if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4045
- throw ClientAuthError.createTokenClaimsRequiredError();
4127
+ switch (atEntity.tokenType) {
4128
+ case exports.AuthenticationScheme.POP:
4129
+ // Make sure keyId is present and add it to credential
4130
+ var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
4131
+ if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4132
+ throw ClientAuthError.createTokenClaimsRequiredError();
4133
+ }
4134
+ atEntity.keyId = tokenClaims.cnf.kid;
4135
+ break;
4136
+ case exports.AuthenticationScheme.SSH:
4137
+ atEntity.keyId = keyId;
4046
4138
  }
4047
- atEntity.keyId = tokenClaims.cnf.kid;
4048
4139
  }
4049
4140
  return atEntity;
4050
4141
  };
@@ -4068,7 +4159,7 @@ var AccessTokenEntity = /** @class */ (function (_super) {
4068
4159
  return AccessTokenEntity;
4069
4160
  }(CredentialEntity));
4070
4161
 
4071
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4162
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4072
4163
 
4073
4164
  /*
4074
4165
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4135,7 +4226,7 @@ var RefreshTokenEntity = /** @class */ (function (_super) {
4135
4226
  return RefreshTokenEntity;
4136
4227
  }(CredentialEntity));
4137
4228
 
4138
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4229
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4139
4230
 
4140
4231
  /*
4141
4232
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4199,7 +4290,7 @@ var InteractionRequiredAuthError = /** @class */ (function (_super) {
4199
4290
  return InteractionRequiredAuthError;
4200
4291
  }(AuthError));
4201
4292
 
4202
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4293
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4203
4294
  /*
4204
4295
  * Copyright (c) Microsoft Corporation. All rights reserved.
4205
4296
  * Licensed under the MIT License.
@@ -4215,7 +4306,7 @@ var CacheRecord = /** @class */ (function () {
4215
4306
  return CacheRecord;
4216
4307
  }());
4217
4308
 
4218
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4309
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4219
4310
 
4220
4311
  /*
4221
4312
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4286,7 +4377,7 @@ var ProtocolUtils = /** @class */ (function () {
4286
4377
  return ProtocolUtils;
4287
4378
  }());
4288
4379
 
4289
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4380
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4290
4381
 
4291
4382
  /*
4292
4383
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4487,7 +4578,7 @@ var UrlString = /** @class */ (function () {
4487
4578
  return UrlString;
4488
4579
  }());
4489
4580
 
4490
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4581
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4491
4582
 
4492
4583
  /*
4493
4584
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4546,14 +4637,14 @@ var PopTokenGenerator = /** @class */ (function () {
4546
4637
  };
4547
4638
  PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
4548
4639
  return __awaiter(this, void 0, void 0, function () {
4549
- var resourceRequestMethod, resourceRequestUri, shrClaims, resourceUrlString, resourceUrlComponents;
4640
+ var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
4550
4641
  return __generator(this, function (_a) {
4551
4642
  switch (_a.label) {
4552
4643
  case 0:
4553
- resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims;
4644
+ resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4554
4645
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4555
4646
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4556
- return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
4647
+ return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
4557
4648
  case 1: return [2 /*return*/, _a.sent()];
4558
4649
  }
4559
4650
  });
@@ -4562,7 +4653,7 @@ var PopTokenGenerator = /** @class */ (function () {
4562
4653
  return PopTokenGenerator;
4563
4654
  }());
4564
4655
 
4565
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4656
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4566
4657
 
4567
4658
  /*
4568
4659
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4632,7 +4723,7 @@ var AppMetadataEntity = /** @class */ (function () {
4632
4723
  return AppMetadataEntity;
4633
4724
  }());
4634
4725
 
4635
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4726
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4636
4727
  /*
4637
4728
  * Copyright (c) Microsoft Corporation. All rights reserved.
4638
4729
  * Licensed under the MIT License.
@@ -4668,7 +4759,7 @@ var AppMetadataEntity = /** @class */ (function () {
4668
4759
  return TokenCacheContext;
4669
4760
  }());
4670
4761
 
4671
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4762
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4672
4763
 
4673
4764
  /*
4674
4765
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4749,6 +4840,8 @@ var ResponseHandler = /** @class */ (function () {
4749
4840
  if (!!authCodePayload && !!authCodePayload.state) {
4750
4841
  requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, authCodePayload.state);
4751
4842
  }
4843
+ // Add keyId from request to serverTokenResponse if defined
4844
+ serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
4752
4845
  cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, idTokenObj, request.scopes, oboAssertion, authCodePayload);
4753
4846
  _a.label = 1;
4754
4847
  case 1:
@@ -4825,7 +4918,7 @@ var ResponseHandler = /** @class */ (function () {
4825
4918
  var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
4826
4919
  var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
4827
4920
  // non AAD scenarios can have empty realm
4828
- cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, oboAssertion);
4921
+ 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);
4829
4922
  }
4830
4923
  // refreshToken
4831
4924
  var cachedRefreshToken = null;
@@ -4930,7 +5023,7 @@ var ResponseHandler = /** @class */ (function () {
4930
5023
  return ResponseHandler;
4931
5024
  }());
4932
5025
 
4933
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5026
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4934
5027
 
4935
5028
  /*
4936
5029
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5045,7 +5138,9 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5045
5138
  authenticationScheme: request.authenticationScheme,
5046
5139
  resourceRequestMethod: request.resourceRequestMethod,
5047
5140
  resourceRequestUri: request.resourceRequestUri,
5048
- shrClaims: request.shrClaims
5141
+ shrClaims: request.shrClaims,
5142
+ sshJwk: request.sshJwk,
5143
+ sshKid: request.sshKid
5049
5144
  };
5050
5145
  return [4 /*yield*/, this.createTokenRequestBody(request)];
5051
5146
  case 1:
@@ -5126,8 +5221,18 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5126
5221
  case 1:
5127
5222
  cnfString = _a.sent();
5128
5223
  parameterBuilder.addPopToken(cnfString);
5129
- _a.label = 2;
5224
+ return [3 /*break*/, 3];
5130
5225
  case 2:
5226
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
5227
+ if (request.sshJwk) {
5228
+ parameterBuilder.addSshJwk(request.sshJwk);
5229
+ }
5230
+ else {
5231
+ throw ClientConfigurationError.createMissingSshJwkError();
5232
+ }
5233
+ }
5234
+ _a.label = 3;
5235
+ case 3:
5131
5236
  correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5132
5237
  parameterBuilder.addCorrelationId(correlationId);
5133
5238
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
@@ -5303,7 +5408,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5303
5408
  return AuthorizationCodeClient;
5304
5409
  }(BaseClient));
5305
5410
 
5306
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5411
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5307
5412
 
5308
5413
  /*
5309
5414
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5417,7 +5522,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5417
5522
  authenticationScheme: request.authenticationScheme,
5418
5523
  resourceRequestMethod: request.resourceRequestMethod,
5419
5524
  resourceRequestUri: request.resourceRequestUri,
5420
- shrClaims: request.shrClaims
5525
+ shrClaims: request.shrClaims,
5526
+ sshJwk: request.sshJwk,
5527
+ sshKid: request.sshKid
5421
5528
  };
5422
5529
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
5423
5530
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
@@ -5442,9 +5549,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5442
5549
  */
5443
5550
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
5444
5551
  return __awaiter(this, void 0, void 0, function () {
5445
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, _a, _b, clientInfo;
5446
- return __generator(this, function (_c) {
5447
- switch (_c.label) {
5552
+ var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
5553
+ return __generator(this, function (_a) {
5554
+ switch (_a.label) {
5448
5555
  case 0:
5449
5556
  parameterBuilder = new RequestParameterBuilder();
5450
5557
  parameterBuilder.addClientId(this.config.authOptions.clientId);
@@ -5469,12 +5576,22 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5469
5576
  }
5470
5577
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5471
5578
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5472
- _b = (_a = parameterBuilder).addPopToken;
5473
5579
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5474
5580
  case 1:
5475
- _b.apply(_a, [_c.sent()]);
5476
- _c.label = 2;
5581
+ cnfString = _a.sent();
5582
+ parameterBuilder.addPopToken(cnfString);
5583
+ return [3 /*break*/, 3];
5477
5584
  case 2:
5585
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
5586
+ if (request.sshJwk) {
5587
+ parameterBuilder.addSshJwk(request.sshJwk);
5588
+ }
5589
+ else {
5590
+ throw ClientConfigurationError.createMissingSshJwkError();
5591
+ }
5592
+ }
5593
+ _a.label = 3;
5594
+ case 3:
5478
5595
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
5479
5596
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
5480
5597
  }
@@ -5502,7 +5619,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5502
5619
  return RefreshTokenClient;
5503
5620
  }(BaseClient));
5504
5621
 
5505
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5622
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5506
5623
 
5507
5624
  /*
5508
5625
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5556,6 +5673,17 @@ var SilentFlowClient = /** @class */ (function (_super) {
5556
5673
  if (!request) {
5557
5674
  throw ClientConfigurationError.createEmptyTokenRequestError();
5558
5675
  }
5676
+ if (request.forceRefresh) {
5677
+ // Must refresh due to present force_refresh flag.
5678
+ (_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
5679
+ this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
5680
+ throw ClientAuthError.createRefreshRequiredError();
5681
+ }
5682
+ else if (!StringUtils.isEmptyObj(request.claims)) {
5683
+ // Must refresh due to request parameters.
5684
+ this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because claims are requested.");
5685
+ throw ClientAuthError.createRefreshRequiredError();
5686
+ }
5559
5687
  // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
5560
5688
  if (!request.account) {
5561
5689
  throw ClientAuthError.createNoAccountInSilentRequestError();
@@ -5563,30 +5691,24 @@ var SilentFlowClient = /** @class */ (function (_super) {
5563
5691
  requestScopes = new ScopeSet(request.scopes || []);
5564
5692
  environment = request.authority || this.authority.getPreferredCache();
5565
5693
  authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
5566
- cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
5567
- if (request.forceRefresh) {
5568
- // Must refresh due to present force_refresh flag.
5569
- (_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
5570
- throw ClientAuthError.createRefreshRequiredError();
5571
- }
5572
- else if (!cacheRecord.accessToken) {
5694
+ cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme, request.sshKid);
5695
+ if (!cacheRecord.accessToken) {
5573
5696
  // Must refresh due to non-existent access_token.
5574
5697
  (_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
5698
+ this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
5575
5699
  throw ClientAuthError.createRefreshRequiredError();
5576
5700
  }
5577
5701
  else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
5578
5702
  TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
5579
5703
  // Must refresh due to expired access_token.
5580
5704
  (_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
5705
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
5581
5706
  throw ClientAuthError.createRefreshRequiredError();
5582
5707
  }
5583
5708
  else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
5584
5709
  // Must refresh due to the refresh_in value.
5585
5710
  (_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
5586
- throw ClientAuthError.createRefreshRequiredError();
5587
- }
5588
- else if (!StringUtils.isEmptyObj(request.claims)) {
5589
- // Must refresh due to request parameters.
5711
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
5590
5712
  throw ClientAuthError.createRefreshRequiredError();
5591
5713
  }
5592
5714
  if (this.config.serverTelemetryManager) {
@@ -5620,7 +5742,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
5620
5742
  return SilentFlowClient;
5621
5743
  }(BaseClient));
5622
5744
 
5623
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5745
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5624
5746
  /*
5625
5747
  * Copyright (c) Microsoft Corporation. All rights reserved.
5626
5748
  * Licensed under the MIT License.
@@ -5628,11 +5750,10 @@ var SilentFlowClient = /** @class */ (function (_super) {
5628
5750
  function isOpenIdConfigResponse(response) {
5629
5751
  return (response.hasOwnProperty("authorization_endpoint") &&
5630
5752
  response.hasOwnProperty("token_endpoint") &&
5631
- response.hasOwnProperty("end_session_endpoint") &&
5632
5753
  response.hasOwnProperty("issuer"));
5633
5754
  }
5634
5755
 
5635
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5756
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5636
5757
  /*
5637
5758
  * Copyright (c) Microsoft Corporation. All rights reserved.
5638
5759
  * Licensed under the MIT License.
@@ -5646,7 +5767,7 @@ exports.ProtocolMode = void 0;
5646
5767
  ProtocolMode["OIDC"] = "OIDC";
5647
5768
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5648
5769
 
5649
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5770
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5650
5771
 
5651
5772
  /*
5652
5773
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5713,7 +5834,6 @@ var AuthorityMetadataEntity = /** @class */ (function () {
5713
5834
  entity.hasOwnProperty("canonical_authority") &&
5714
5835
  entity.hasOwnProperty("authorization_endpoint") &&
5715
5836
  entity.hasOwnProperty("token_endpoint") &&
5716
- entity.hasOwnProperty("end_session_endpoint") &&
5717
5837
  entity.hasOwnProperty("issuer") &&
5718
5838
  entity.hasOwnProperty("aliasesFromNetwork") &&
5719
5839
  entity.hasOwnProperty("endpointsFromNetwork") &&
@@ -5722,7 +5842,7 @@ var AuthorityMetadataEntity = /** @class */ (function () {
5722
5842
  return AuthorityMetadataEntity;
5723
5843
  }());
5724
5844
 
5725
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5845
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5726
5846
  /*
5727
5847
  * Copyright (c) Microsoft Corporation. All rights reserved.
5728
5848
  * Licensed under the MIT License.
@@ -5732,7 +5852,7 @@ function isCloudInstanceDiscoveryResponse(response) {
5732
5852
  response.hasOwnProperty("metadata"));
5733
5853
  }
5734
5854
 
5735
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5855
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5736
5856
 
5737
5857
  /*
5738
5858
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5846,7 +5966,7 @@ var RegionDiscovery = /** @class */ (function () {
5846
5966
  return RegionDiscovery;
5847
5967
  }());
5848
5968
 
5849
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5969
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5850
5970
 
5851
5971
  /*
5852
5972
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6000,6 +6120,10 @@ var Authority = /** @class */ (function () {
6000
6120
  */
6001
6121
  get: function () {
6002
6122
  if (this.discoveryComplete()) {
6123
+ // ROPC policies may not have end_session_endpoint set
6124
+ if (!this.metadata.end_session_endpoint) {
6125
+ throw ClientAuthError.createLogoutNotSupportedError();
6126
+ }
6003
6127
  var endpoint = this.replacePath(this.metadata.end_session_endpoint);
6004
6128
  return this.replaceTenant(endpoint);
6005
6129
  }
@@ -6400,13 +6524,15 @@ var Authority = /** @class */ (function () {
6400
6524
  metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
6401
6525
  // TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
6402
6526
  metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, "allowestsrnonmsi=true");
6403
- metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
6527
+ if (metadata.end_session_endpoint) {
6528
+ metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
6529
+ }
6404
6530
  return metadata;
6405
6531
  };
6406
6532
  return Authority;
6407
6533
  }());
6408
6534
 
6409
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6535
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6410
6536
 
6411
6537
  /*
6412
6538
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6467,7 +6593,7 @@ var AuthorityFactory = /** @class */ (function () {
6467
6593
  return AuthorityFactory;
6468
6594
  }());
6469
6595
 
6470
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6596
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6471
6597
 
6472
6598
  /*
6473
6599
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6498,7 +6624,7 @@ var ServerTelemetryEntity = /** @class */ (function () {
6498
6624
  return ServerTelemetryEntity;
6499
6625
  }());
6500
6626
 
6501
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6627
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6502
6628
 
6503
6629
  /*
6504
6630
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6526,7 +6652,7 @@ var ThrottlingEntity = /** @class */ (function () {
6526
6652
  return ThrottlingEntity;
6527
6653
  }());
6528
6654
 
6529
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6655
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6530
6656
 
6531
6657
  /*
6532
6658
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6543,7 +6669,66 @@ var StubbedNetworkModule = {
6543
6669
  }
6544
6670
  };
6545
6671
 
6546
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6672
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6673
+
6674
+ /*
6675
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6676
+ * Licensed under the MIT License.
6677
+ */
6678
+ /**
6679
+ * This is a helper class that parses supported HTTP response authentication headers to extract and return
6680
+ * header challenge values that can be used outside the basic authorization flows.
6681
+ */
6682
+ var AuthenticationHeaderParser = /** @class */ (function () {
6683
+ function AuthenticationHeaderParser(headers) {
6684
+ this.headers = headers;
6685
+ }
6686
+ /**
6687
+ * This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
6688
+ * @returns
6689
+ */
6690
+ AuthenticationHeaderParser.prototype.getShrNonce = function () {
6691
+ // Attempt to parse nonce from Authentiacation-Info
6692
+ var authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
6693
+ if (authenticationInfo) {
6694
+ var authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
6695
+ if (authenticationInfoChallenges.nextnonce) {
6696
+ return authenticationInfoChallenges.nextnonce;
6697
+ }
6698
+ throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
6699
+ }
6700
+ // Attempt to parse nonce from WWW-Authenticate
6701
+ var wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
6702
+ if (wwwAuthenticate) {
6703
+ var wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
6704
+ if (wwwAuthenticateChallenges.nonce) {
6705
+ return wwwAuthenticateChallenges.nonce;
6706
+ }
6707
+ throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
6708
+ }
6709
+ // If neither header is present, throw missing headers error
6710
+ throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
6711
+ };
6712
+ /**
6713
+ * Parses an HTTP header's challenge set into a key/value map.
6714
+ * @param header
6715
+ * @returns
6716
+ */
6717
+ AuthenticationHeaderParser.prototype.parseChallenges = function (header) {
6718
+ var schemeSeparator = header.indexOf(" ");
6719
+ var challenges = header.substr(schemeSeparator + 1).split(",");
6720
+ var challengeMap = {};
6721
+ challenges.forEach(function (challenge) {
6722
+ var _a = challenge.split("="), key = _a[0], value = _a[1];
6723
+ // Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
6724
+ challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
6725
+ });
6726
+ return challengeMap;
6727
+ };
6728
+ return AuthenticationHeaderParser;
6729
+ }());
6730
+
6731
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6547
6732
 
6548
6733
  /*
6549
6734
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6856,7 +7041,11 @@ exports.WrapperSKU = void 0;
6856
7041
  (function (WrapperSKU) {
6857
7042
  WrapperSKU["React"] = "@azure/msal-react";
6858
7043
  WrapperSKU["Angular"] = "@azure/msal-angular";
6859
- })(exports.WrapperSKU || (exports.WrapperSKU = {}));
7044
+ })(exports.WrapperSKU || (exports.WrapperSKU = {}));
7045
+ // DatabaseStorage Constants
7046
+ var DB_NAME = "msal.db";
7047
+ var DB_VERSION = 1;
7048
+ var DB_TABLE_NAME = DB_NAME + ".keys";
6860
7049
 
6861
7050
  /*
6862
7051
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7332,7 +7521,7 @@ var BrowserAuthErrorMessage = {
7332
7521
  },
7333
7522
  noTokenRequestCacheError: {
7334
7523
  code: "no_token_request_cache_error",
7335
- desc: "No token request in found in cache."
7524
+ desc: "No token request found in cache."
7336
7525
  },
7337
7526
  unableToParseTokenRequestCacheError: {
7338
7527
  code: "unable_to_parse_token_request_cache_error",
@@ -7381,6 +7570,10 @@ var BrowserAuthErrorMessage = {
7381
7570
  signingKeyNotFoundInStorage: {
7382
7571
  code: "crypto_key_not_found",
7383
7572
  desc: "Cryptographic Key or Keypair not found in browser storage."
7573
+ },
7574
+ databaseUnavailable: {
7575
+ code: "database_unavailable",
7576
+ desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
7384
7577
  }
7385
7578
  };
7386
7579
  /**
@@ -7614,6 +7807,12 @@ var BrowserAuthError = /** @class */ (function (_super) {
7614
7807
  BrowserAuthError.createSigningKeyNotFoundInStorageError = function (keyId) {
7615
7808
  return new BrowserAuthError(BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code, BrowserAuthErrorMessage.signingKeyNotFoundInStorage.desc + " | No match found for KeyId: " + keyId);
7616
7809
  };
7810
+ /**
7811
+ * Create an error when IndexedDB is unavailable
7812
+ */
7813
+ BrowserAuthError.createDatabaseUnavailableError = function () {
7814
+ return new BrowserAuthError(BrowserAuthErrorMessage.databaseUnavailable.code, BrowserAuthErrorMessage.databaseUnavailable.desc);
7815
+ };
7617
7816
  return BrowserAuthError;
7618
7817
  }(AuthError));
7619
7818
 
@@ -7716,7 +7915,8 @@ var PUBLIC_EXPONENT = new Uint8Array([0x01, 0x00, 0x01]);
7716
7915
  * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
7717
7916
  */
7718
7917
  var BrowserCrypto = /** @class */ (function () {
7719
- function BrowserCrypto() {
7918
+ function BrowserCrypto(logger) {
7919
+ this.logger = logger;
7720
7920
  if (!(this.hasCryptoAPI())) {
7721
7921
  throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto or msCrypto object not available.");
7722
7922
  }
@@ -7975,10 +8175,10 @@ var BrowserCrypto = /** @class */ (function () {
7975
8175
  * Storage wrapper for IndexedDB storage in browsers: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
7976
8176
  */
7977
8177
  var DatabaseStorage = /** @class */ (function () {
7978
- function DatabaseStorage(dbName, tableName, version) {
7979
- this.dbName = dbName;
7980
- this.tableName = tableName;
7981
- this.version = version;
8178
+ function DatabaseStorage() {
8179
+ this.dbName = DB_NAME;
8180
+ this.version = DB_VERSION;
8181
+ this.tableName = DB_TABLE_NAME;
7982
8182
  this.dbOpen = false;
7983
8183
  }
7984
8184
  /**
@@ -7989,7 +8189,6 @@ var DatabaseStorage = /** @class */ (function () {
7989
8189
  var _this = this;
7990
8190
  return __generator$1(this, function (_a) {
7991
8191
  return [2 /*return*/, new Promise(function (resolve, reject) {
7992
- // TODO: Add timeouts?
7993
8192
  var openDB = window.indexedDB.open(_this.dbName, _this.version);
7994
8193
  openDB.addEventListener("upgradeneeded", function (e) {
7995
8194
  var event = e;
@@ -8001,40 +8200,53 @@ var DatabaseStorage = /** @class */ (function () {
8001
8200
  _this.dbOpen = true;
8002
8201
  resolve();
8003
8202
  });
8004
- openDB.addEventListener("error", function (error) { return reject(error); });
8203
+ openDB.addEventListener("error", function () { return reject(BrowserAuthError.createDatabaseUnavailableError()); });
8005
8204
  })];
8006
8205
  });
8007
8206
  });
8008
8207
  };
8009
8208
  /**
8010
- * Retrieves item from IndexedDB instance.
8011
- * @param key
8209
+ * Opens database if it's not already open
8012
8210
  */
8013
- DatabaseStorage.prototype.get = function (key) {
8211
+ DatabaseStorage.prototype.validateDbIsOpen = function () {
8014
8212
  return __awaiter$1(this, void 0, void 0, function () {
8015
- var _this = this;
8016
8213
  return __generator$1(this, function (_a) {
8017
8214
  switch (_a.label) {
8018
8215
  case 0:
8019
8216
  if (!!this.dbOpen) return [3 /*break*/, 2];
8020
8217
  return [4 /*yield*/, this.open()];
8218
+ case 1: return [2 /*return*/, _a.sent()];
8219
+ case 2: return [2 /*return*/];
8220
+ }
8221
+ });
8222
+ });
8223
+ };
8224
+ /**
8225
+ * Retrieves item from IndexedDB instance.
8226
+ * @param key
8227
+ */
8228
+ DatabaseStorage.prototype.getItem = function (key) {
8229
+ return __awaiter$1(this, void 0, void 0, function () {
8230
+ var _this = this;
8231
+ return __generator$1(this, function (_a) {
8232
+ switch (_a.label) {
8233
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8021
8234
  case 1:
8022
8235
  _a.sent();
8023
- _a.label = 2;
8024
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8025
- // TODO: Add timeouts?
8026
- if (!_this.db) {
8027
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8028
- }
8029
- var transaction = _this.db.transaction([_this.tableName], "readonly");
8030
- var objectStore = transaction.objectStore(_this.tableName);
8031
- var dbGet = objectStore.get(key);
8032
- dbGet.addEventListener("success", function (e) {
8033
- var event = e;
8034
- resolve(event.target.result);
8035
- });
8036
- dbGet.addEventListener("error", function (e) { return reject(e); });
8037
- })];
8236
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8237
+ // TODO: Add timeouts?
8238
+ if (!_this.db) {
8239
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8240
+ }
8241
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8242
+ var objectStore = transaction.objectStore(_this.tableName);
8243
+ var dbGet = objectStore.get(key);
8244
+ dbGet.addEventListener("success", function (e) {
8245
+ var event = e;
8246
+ resolve(event.target.result);
8247
+ });
8248
+ dbGet.addEventListener("error", function (e) { return reject(e); });
8249
+ })];
8038
8250
  }
8039
8251
  });
8040
8252
  });
@@ -8044,31 +8256,25 @@ var DatabaseStorage = /** @class */ (function () {
8044
8256
  * @param key
8045
8257
  * @param payload
8046
8258
  */
8047
- DatabaseStorage.prototype.put = function (key, payload) {
8259
+ DatabaseStorage.prototype.setItem = function (key, payload) {
8048
8260
  return __awaiter$1(this, void 0, void 0, function () {
8049
8261
  var _this = this;
8050
8262
  return __generator$1(this, function (_a) {
8051
8263
  switch (_a.label) {
8052
- case 0:
8053
- if (!!this.dbOpen) return [3 /*break*/, 2];
8054
- return [4 /*yield*/, this.open()];
8264
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8055
8265
  case 1:
8056
8266
  _a.sent();
8057
- _a.label = 2;
8058
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8059
- // TODO: Add timeouts?
8060
- if (!_this.db) {
8061
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8062
- }
8063
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8064
- var objectStore = transaction.objectStore(_this.tableName);
8065
- var dbPut = objectStore.put(payload, key);
8066
- dbPut.addEventListener("success", function (e) {
8067
- var event = e;
8068
- resolve(event.target.result);
8069
- });
8070
- dbPut.addEventListener("error", function (e) { return reject(e); });
8071
- })];
8267
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8268
+ // TODO: Add timeouts?
8269
+ if (!_this.db) {
8270
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8271
+ }
8272
+ var transaction = _this.db.transaction([_this.tableName], "readwrite");
8273
+ var objectStore = transaction.objectStore(_this.tableName);
8274
+ var dbPut = objectStore.put(payload, key);
8275
+ dbPut.addEventListener("success", function () { return resolve(); });
8276
+ dbPut.addEventListener("error", function (e) { return reject(e); });
8277
+ })];
8072
8278
  }
8073
8279
  });
8074
8280
  });
@@ -8077,65 +8283,323 @@ var DatabaseStorage = /** @class */ (function () {
8077
8283
  * Removes item from IndexedDB under given key
8078
8284
  * @param key
8079
8285
  */
8080
- DatabaseStorage.prototype.delete = function (key) {
8286
+ DatabaseStorage.prototype.removeItem = function (key) {
8081
8287
  return __awaiter$1(this, void 0, void 0, function () {
8082
8288
  var _this = this;
8083
8289
  return __generator$1(this, function (_a) {
8084
8290
  switch (_a.label) {
8085
- case 0:
8086
- if (!!this.dbOpen) return [3 /*break*/, 2];
8087
- return [4 /*yield*/, this.open()];
8291
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8088
8292
  case 1:
8089
8293
  _a.sent();
8090
- _a.label = 2;
8091
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8092
- if (!_this.db) {
8093
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8094
- }
8095
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8096
- var objectStore = transaction.objectStore(_this.tableName);
8097
- var dbDelete = objectStore.delete(key);
8098
- dbDelete.addEventListener("success", function (e) {
8099
- var event = e;
8100
- resolve(event.target.result === undefined);
8101
- });
8102
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8103
- })];
8294
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8295
+ if (!_this.db) {
8296
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8297
+ }
8298
+ var transaction = _this.db.transaction([_this.tableName], "readwrite");
8299
+ var objectStore = transaction.objectStore(_this.tableName);
8300
+ var dbDelete = objectStore.delete(key);
8301
+ dbDelete.addEventListener("success", function () { return resolve(); });
8302
+ dbDelete.addEventListener("error", function (e) { return reject(e); });
8303
+ })];
8104
8304
  }
8105
8305
  });
8106
8306
  });
8107
8307
  };
8108
- DatabaseStorage.prototype.clear = function () {
8308
+ /**
8309
+ * Get all the keys from the storage object as an iterable array of strings.
8310
+ */
8311
+ DatabaseStorage.prototype.getKeys = function () {
8109
8312
  return __awaiter$1(this, void 0, void 0, function () {
8110
8313
  var _this = this;
8111
8314
  return __generator$1(this, function (_a) {
8112
8315
  switch (_a.label) {
8113
- case 0:
8114
- if (!!this.dbOpen) return [3 /*break*/, 2];
8115
- return [4 /*yield*/, this.open()];
8316
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8116
8317
  case 1:
8117
8318
  _a.sent();
8118
- _a.label = 2;
8119
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8120
- if (!_this.db) {
8121
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8122
- }
8123
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8124
- var objectStore = transaction.objectStore(_this.tableName);
8125
- var dbDelete = objectStore.clear();
8126
- dbDelete.addEventListener("success", function (e) {
8127
- var event = e;
8128
- resolve(event.target.result === undefined);
8129
- });
8130
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8131
- })];
8319
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8320
+ if (!_this.db) {
8321
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8322
+ }
8323
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8324
+ var objectStore = transaction.objectStore(_this.tableName);
8325
+ var dbGetKeys = objectStore.getAllKeys();
8326
+ dbGetKeys.addEventListener("success", function (e) {
8327
+ var event = e;
8328
+ resolve(event.target.result);
8329
+ });
8330
+ dbGetKeys.addEventListener("error", function (e) { return reject(e); });
8331
+ })];
8132
8332
  }
8133
8333
  });
8134
8334
  });
8135
8335
  };
8336
+ /**
8337
+ *
8338
+ * Checks whether there is an object under the search key in the object store
8339
+ */
8340
+ DatabaseStorage.prototype.containsKey = function (key) {
8341
+ return __awaiter$1(this, void 0, void 0, function () {
8342
+ var _this = this;
8343
+ return __generator$1(this, function (_a) {
8344
+ switch (_a.label) {
8345
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8346
+ case 1:
8347
+ _a.sent();
8348
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8349
+ if (!_this.db) {
8350
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8351
+ }
8352
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8353
+ var objectStore = transaction.objectStore(_this.tableName);
8354
+ var dbContainsKey = objectStore.count(key);
8355
+ dbContainsKey.addEventListener("success", function (e) {
8356
+ var event = e;
8357
+ resolve(event.target.result === 1);
8358
+ });
8359
+ dbContainsKey.addEventListener("error", function (e) { return reject(e); });
8360
+ })];
8361
+ }
8362
+ });
8363
+ });
8364
+ };
8365
+ /**
8366
+ * Deletes the MSAL database. The database is deleted rather than cleared to make it possible
8367
+ * for client applications to downgrade to a previous MSAL version without worrying about forward compatibility issues
8368
+ * with IndexedDB database versions.
8369
+ */
8370
+ DatabaseStorage.prototype.deleteDatabase = function () {
8371
+ return __awaiter$1(this, void 0, void 0, function () {
8372
+ return __generator$1(this, function (_a) {
8373
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8374
+ var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
8375
+ deleteDbRequest.addEventListener("success", function () { return resolve(true); });
8376
+ deleteDbRequest.addEventListener("error", function () { return reject(false); });
8377
+ })];
8378
+ });
8379
+ });
8380
+ };
8136
8381
  return DatabaseStorage;
8137
8382
  }());
8138
8383
 
8384
+ /*
8385
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8386
+ * Licensed under the MIT License.
8387
+ */
8388
+ var MemoryStorage = /** @class */ (function () {
8389
+ function MemoryStorage() {
8390
+ this.cache = new Map();
8391
+ }
8392
+ MemoryStorage.prototype.getItem = function (key) {
8393
+ return this.cache.get(key) || null;
8394
+ };
8395
+ MemoryStorage.prototype.setItem = function (key, value) {
8396
+ this.cache.set(key, value);
8397
+ };
8398
+ MemoryStorage.prototype.removeItem = function (key) {
8399
+ this.cache.delete(key);
8400
+ };
8401
+ MemoryStorage.prototype.getKeys = function () {
8402
+ var cacheKeys = [];
8403
+ this.cache.forEach(function (value, key) {
8404
+ cacheKeys.push(key);
8405
+ });
8406
+ return cacheKeys;
8407
+ };
8408
+ MemoryStorage.prototype.containsKey = function (key) {
8409
+ return this.cache.has(key);
8410
+ };
8411
+ MemoryStorage.prototype.clear = function () {
8412
+ this.cache.clear();
8413
+ };
8414
+ return MemoryStorage;
8415
+ }());
8416
+
8417
+ /*
8418
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8419
+ * Licensed under the MIT License.
8420
+ */
8421
+ /**
8422
+ * This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper,
8423
+ * backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
8424
+ */
8425
+ var AsyncMemoryStorage = /** @class */ (function () {
8426
+ function AsyncMemoryStorage(logger) {
8427
+ this.inMemoryCache = new MemoryStorage();
8428
+ this.indexedDBCache = new DatabaseStorage();
8429
+ this.logger = logger;
8430
+ }
8431
+ AsyncMemoryStorage.prototype.handleDatabaseAccessError = function (error) {
8432
+ if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {
8433
+ this.logger.error("Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.");
8434
+ }
8435
+ };
8436
+ /**
8437
+ * Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
8438
+ * storage object if item isn't found in-memory.
8439
+ * @param key
8440
+ */
8441
+ AsyncMemoryStorage.prototype.getItem = function (key) {
8442
+ return __awaiter$1(this, void 0, void 0, function () {
8443
+ var item, e_1;
8444
+ return __generator$1(this, function (_a) {
8445
+ switch (_a.label) {
8446
+ case 0:
8447
+ item = this.inMemoryCache.getItem(key);
8448
+ if (!!item) return [3 /*break*/, 4];
8449
+ _a.label = 1;
8450
+ case 1:
8451
+ _a.trys.push([1, 3, , 4]);
8452
+ this.logger.verbose("Queried item not found in in-memory cache, now querying persistent storage.");
8453
+ return [4 /*yield*/, this.indexedDBCache.getItem(key)];
8454
+ case 2: return [2 /*return*/, _a.sent()];
8455
+ case 3:
8456
+ e_1 = _a.sent();
8457
+ this.handleDatabaseAccessError(e_1);
8458
+ return [3 /*break*/, 4];
8459
+ case 4: return [2 /*return*/, item];
8460
+ }
8461
+ });
8462
+ });
8463
+ };
8464
+ /**
8465
+ * Sets the item in the in-memory cache and then tries to set it in the asynchronous
8466
+ * storage object with the given key.
8467
+ * @param key
8468
+ * @param value
8469
+ */
8470
+ AsyncMemoryStorage.prototype.setItem = function (key, value) {
8471
+ return __awaiter$1(this, void 0, void 0, function () {
8472
+ var e_2;
8473
+ return __generator$1(this, function (_a) {
8474
+ switch (_a.label) {
8475
+ case 0:
8476
+ this.inMemoryCache.setItem(key, value);
8477
+ _a.label = 1;
8478
+ case 1:
8479
+ _a.trys.push([1, 3, , 4]);
8480
+ return [4 /*yield*/, this.indexedDBCache.setItem(key, value)];
8481
+ case 2:
8482
+ _a.sent();
8483
+ return [3 /*break*/, 4];
8484
+ case 3:
8485
+ e_2 = _a.sent();
8486
+ this.handleDatabaseAccessError(e_2);
8487
+ return [3 /*break*/, 4];
8488
+ case 4: return [2 /*return*/];
8489
+ }
8490
+ });
8491
+ });
8492
+ };
8493
+ /**
8494
+ * Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.
8495
+ * @param key
8496
+ */
8497
+ AsyncMemoryStorage.prototype.removeItem = function (key) {
8498
+ return __awaiter$1(this, void 0, void 0, function () {
8499
+ var e_3;
8500
+ return __generator$1(this, function (_a) {
8501
+ switch (_a.label) {
8502
+ case 0:
8503
+ this.inMemoryCache.removeItem(key);
8504
+ _a.label = 1;
8505
+ case 1:
8506
+ _a.trys.push([1, 3, , 4]);
8507
+ return [4 /*yield*/, this.indexedDBCache.removeItem(key)];
8508
+ case 2:
8509
+ _a.sent();
8510
+ return [3 /*break*/, 4];
8511
+ case 3:
8512
+ e_3 = _a.sent();
8513
+ this.handleDatabaseAccessError(e_3);
8514
+ return [3 /*break*/, 4];
8515
+ case 4: return [2 /*return*/];
8516
+ }
8517
+ });
8518
+ });
8519
+ };
8520
+ /**
8521
+ * 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
8522
+ * asynchronous storage object.
8523
+ */
8524
+ AsyncMemoryStorage.prototype.getKeys = function () {
8525
+ return __awaiter$1(this, void 0, void 0, function () {
8526
+ var cacheKeys, e_4;
8527
+ return __generator$1(this, function (_a) {
8528
+ switch (_a.label) {
8529
+ case 0:
8530
+ cacheKeys = this.inMemoryCache.getKeys();
8531
+ if (!(cacheKeys.length === 0)) return [3 /*break*/, 4];
8532
+ _a.label = 1;
8533
+ case 1:
8534
+ _a.trys.push([1, 3, , 4]);
8535
+ this.logger.verbose("In-memory cache is empty, now querying persistent storage.");
8536
+ return [4 /*yield*/, this.indexedDBCache.getKeys()];
8537
+ case 2: return [2 /*return*/, _a.sent()];
8538
+ case 3:
8539
+ e_4 = _a.sent();
8540
+ this.handleDatabaseAccessError(e_4);
8541
+ return [3 /*break*/, 4];
8542
+ case 4: return [2 /*return*/, cacheKeys];
8543
+ }
8544
+ });
8545
+ });
8546
+ };
8547
+ /**
8548
+ * Returns true or false if the given key is present in the cache.
8549
+ * @param key
8550
+ */
8551
+ AsyncMemoryStorage.prototype.containsKey = function (key) {
8552
+ return __awaiter$1(this, void 0, void 0, function () {
8553
+ var containsKey, e_5;
8554
+ return __generator$1(this, function (_a) {
8555
+ switch (_a.label) {
8556
+ case 0:
8557
+ containsKey = this.inMemoryCache.containsKey(key);
8558
+ if (!!containsKey) return [3 /*break*/, 4];
8559
+ _a.label = 1;
8560
+ case 1:
8561
+ _a.trys.push([1, 3, , 4]);
8562
+ this.logger.verbose("Key not found in in-memory cache, now querying persistent storage.");
8563
+ return [4 /*yield*/, this.indexedDBCache.containsKey(key)];
8564
+ case 2: return [2 /*return*/, _a.sent()];
8565
+ case 3:
8566
+ e_5 = _a.sent();
8567
+ this.handleDatabaseAccessError(e_5);
8568
+ return [3 /*break*/, 4];
8569
+ case 4: return [2 /*return*/, containsKey];
8570
+ }
8571
+ });
8572
+ });
8573
+ };
8574
+ /**
8575
+ * Clears in-memory Map and tries to delete the IndexedDB database.
8576
+ */
8577
+ AsyncMemoryStorage.prototype.clear = function () {
8578
+ return __awaiter$1(this, void 0, void 0, function () {
8579
+ var e_6;
8580
+ return __generator$1(this, function (_a) {
8581
+ switch (_a.label) {
8582
+ case 0:
8583
+ this.inMemoryCache.clear();
8584
+ _a.label = 1;
8585
+ case 1:
8586
+ _a.trys.push([1, 3, , 4]);
8587
+ return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
8588
+ case 2:
8589
+ _a.sent();
8590
+ return [3 /*break*/, 4];
8591
+ case 3:
8592
+ e_6 = _a.sent();
8593
+ this.handleDatabaseAccessError(e_6);
8594
+ return [3 /*break*/, 4];
8595
+ case 4: return [2 /*return*/];
8596
+ }
8597
+ });
8598
+ });
8599
+ };
8600
+ return AsyncMemoryStorage;
8601
+ }());
8602
+
8139
8603
  /*
8140
8604
  * Copyright (c) Microsoft Corporation. All rights reserved.
8141
8605
  * Licensed under the MIT License.
@@ -8145,14 +8609,18 @@ var DatabaseStorage = /** @class */ (function () {
8145
8609
  * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
8146
8610
  */
8147
8611
  var CryptoOps = /** @class */ (function () {
8148
- function CryptoOps() {
8612
+ function CryptoOps(logger) {
8613
+ this.logger = logger;
8149
8614
  // Browser crypto needs to be validated first before any other classes can be set.
8150
- this.browserCrypto = new BrowserCrypto();
8615
+ this.browserCrypto = new BrowserCrypto(this.logger);
8151
8616
  this.b64Encode = new Base64Encode();
8152
8617
  this.b64Decode = new Base64Decode();
8153
8618
  this.guidGenerator = new GuidGenerator(this.browserCrypto);
8154
8619
  this.pkceGenerator = new PkceGenerator(this.browserCrypto);
8155
- this.cache = new DatabaseStorage(CryptoOps.DB_NAME, CryptoOps.TABLE_NAME, CryptoOps.DB_VERSION);
8620
+ this.cache = {
8621
+ asymmetricKeys: new AsyncMemoryStorage(this.logger),
8622
+ symmetricKeys: new AsyncMemoryStorage(this.logger)
8623
+ };
8156
8624
  }
8157
8625
  /**
8158
8626
  * Creates a new random GUID - used to populate state and nonce.
@@ -8217,7 +8685,7 @@ var CryptoOps = /** @class */ (function () {
8217
8685
  case 5:
8218
8686
  unextractablePrivateKey = _a.sent();
8219
8687
  // Store Keypair data in keystore
8220
- return [4 /*yield*/, this.cache.put(publicJwkHash, {
8688
+ return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
8221
8689
  privateKey: unextractablePrivateKey,
8222
8690
  publicKey: keyPair.publicKey,
8223
8691
  requestMethod: request.resourceRequestMethod,
@@ -8237,8 +8705,17 @@ var CryptoOps = /** @class */ (function () {
8237
8705
  */
8238
8706
  CryptoOps.prototype.removeTokenBindingKey = function (kid) {
8239
8707
  return __awaiter$1(this, void 0, void 0, function () {
8708
+ var keyFound;
8240
8709
  return __generator$1(this, function (_a) {
8241
- return [2 /*return*/, this.cache.delete(kid)];
8710
+ switch (_a.label) {
8711
+ case 0: return [4 /*yield*/, this.cache.asymmetricKeys.removeItem(kid)];
8712
+ case 1:
8713
+ _a.sent();
8714
+ return [4 /*yield*/, this.cache.asymmetricKeys.containsKey(kid)];
8715
+ case 2:
8716
+ keyFound = _a.sent();
8717
+ return [2 /*return*/, !keyFound];
8718
+ }
8242
8719
  });
8243
8720
  });
8244
8721
  };
@@ -8247,8 +8724,22 @@ var CryptoOps = /** @class */ (function () {
8247
8724
  */
8248
8725
  CryptoOps.prototype.clearKeystore = function () {
8249
8726
  return __awaiter$1(this, void 0, void 0, function () {
8250
- return __generator$1(this, function (_a) {
8251
- return [2 /*return*/, this.cache.clear()];
8727
+ var dataStoreNames, databaseStorage, _a;
8728
+ return __generator$1(this, function (_b) {
8729
+ switch (_b.label) {
8730
+ case 0:
8731
+ dataStoreNames = Object.keys(this.cache);
8732
+ databaseStorage = this.cache[dataStoreNames[0]];
8733
+ if (!databaseStorage) return [3 /*break*/, 2];
8734
+ return [4 /*yield*/, databaseStorage.deleteDatabase()];
8735
+ case 1:
8736
+ _a = _b.sent();
8737
+ return [3 /*break*/, 3];
8738
+ case 2:
8739
+ _a = false;
8740
+ _b.label = 3;
8741
+ case 3: return [2 /*return*/, _a];
8742
+ }
8252
8743
  });
8253
8744
  });
8254
8745
  };
@@ -8262,7 +8753,7 @@ var CryptoOps = /** @class */ (function () {
8262
8753
  var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
8263
8754
  return __generator$1(this, function (_a) {
8264
8755
  switch (_a.label) {
8265
- case 0: return [4 /*yield*/, this.cache.get(kid)];
8756
+ case 0: return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
8266
8757
  case 1:
8267
8758
  cachedKeyPair = _a.sent();
8268
8759
  if (!cachedKeyPair) {
@@ -8295,9 +8786,6 @@ var CryptoOps = /** @class */ (function () {
8295
8786
  };
8296
8787
  CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
8297
8788
  CryptoOps.EXTRACTABLE = true;
8298
- CryptoOps.DB_VERSION = 1;
8299
- CryptoOps.DB_NAME = "msal.db";
8300
- CryptoOps.TABLE_NAME = CryptoOps.DB_NAME + ".keys";
8301
8789
  return CryptoOps;
8302
8790
  }());
8303
8791
 
@@ -8427,39 +8915,6 @@ var BrowserStorage = /** @class */ (function () {
8427
8915
  return BrowserStorage;
8428
8916
  }());
8429
8917
 
8430
- /*
8431
- * Copyright (c) Microsoft Corporation. All rights reserved.
8432
- * Licensed under the MIT License.
8433
- */
8434
- var MemoryStorage = /** @class */ (function () {
8435
- function MemoryStorage() {
8436
- this.cache = new Map();
8437
- }
8438
- MemoryStorage.prototype.getItem = function (key) {
8439
- return this.cache.get(key) || null;
8440
- };
8441
- MemoryStorage.prototype.setItem = function (key, value) {
8442
- this.cache.set(key, value);
8443
- };
8444
- MemoryStorage.prototype.removeItem = function (key) {
8445
- this.cache.delete(key);
8446
- };
8447
- MemoryStorage.prototype.getKeys = function () {
8448
- var cacheKeys = [];
8449
- this.cache.forEach(function (value, key) {
8450
- cacheKeys.push(key);
8451
- });
8452
- return cacheKeys;
8453
- };
8454
- MemoryStorage.prototype.containsKey = function (key) {
8455
- return this.cache.has(key);
8456
- };
8457
- MemoryStorage.prototype.clear = function () {
8458
- this.cache.clear();
8459
- };
8460
- return MemoryStorage;
8461
- }());
8462
-
8463
8918
  /*
8464
8919
  * Copyright (c) Microsoft Corporation. All rights reserved.
8465
8920
  * Licensed under the MIT License.
@@ -9840,7 +10295,7 @@ function buildConfiguration(_a, isBrowserEnvironment) {
9840
10295
 
9841
10296
  /* eslint-disable header/header */
9842
10297
  var name = "@azure/msal-browser";
9843
- var version = "2.18.0";
10298
+ var version = "2.19.0";
9844
10299
 
9845
10300
  /*
9846
10301
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10063,6 +10518,14 @@ var BaseInteractionClient = /** @class */ (function () {
10063
10518
  this.logger.verbose("Authentication Scheme wasn't explicitly set in request, defaulting to \"Bearer\" request");
10064
10519
  }
10065
10520
  else {
10521
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
10522
+ if (!request.sshJwk) {
10523
+ throw ClientConfigurationError.createMissingSshJwkError();
10524
+ }
10525
+ if (!request.sshKid) {
10526
+ throw ClientConfigurationError.createMissingSshKidError();
10527
+ }
10528
+ }
10066
10529
  this.logger.verbose("Authentication Scheme set to \"" + request.authenticationScheme + "\" as configured in Auth request");
10067
10530
  }
10068
10531
  var validatedRequest = __assign$1(__assign$1({}, request), { correlationId: this.correlationId, authority: authority,
@@ -11149,7 +11612,7 @@ var RedirectClient = /** @class */ (function (_super) {
11149
11612
  this.logger.verbose("NavigateToLoginRequestUrl set to false, handling hash");
11150
11613
  return [2 /*return*/, this.handleHash(responseHash, state, serverTelemetryManager)];
11151
11614
  case 4:
11152
- if (!!BrowserUtils.isInIframe()) return [3 /*break*/, 9];
11615
+ if (!(!BrowserUtils.isInIframe() || this.config.system.allowRedirectInIframe)) return [3 /*break*/, 9];
11153
11616
  /*
11154
11617
  * Returned from authority using redirect - need to perform navigation before processing response
11155
11618
  * Cache the hash to be retrieved after the next redirect
@@ -11796,7 +12259,7 @@ var ClientApplication = /** @class */ (function () {
11796
12259
  // Initialize redirectResponse Map
11797
12260
  this.redirectResponse = new Map();
11798
12261
  // Initialize the crypto class.
11799
- this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps() : DEFAULT_CRYPTO_IMPLEMENTATION;
12262
+ this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger) : DEFAULT_CRYPTO_IMPLEMENTATION;
11800
12263
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
11801
12264
  // Initialize the browser storage class.
11802
12265
  this.browserStorage = this.isBrowserEnvironment ?
@@ -12025,7 +12488,7 @@ var ClientApplication = /** @class */ (function () {
12025
12488
  var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
12026
12489
  if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
12027
12490
  _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
12028
- var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode);
12491
+ var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode, request.correlationId);
12029
12492
  return silentIframeClient.acquireToken(request);
12030
12493
  }
12031
12494
  throw e;
@@ -12245,6 +12708,12 @@ var ClientApplication = /** @class */ (function () {
12245
12708
  ClientApplication.prototype.setNavigationClient = function (navigationClient) {
12246
12709
  this.navigationClient = navigationClient;
12247
12710
  };
12711
+ /**
12712
+ * Returns the configuration object
12713
+ */
12714
+ ClientApplication.prototype.getConfiguration = function () {
12715
+ return this.config;
12716
+ };
12248
12717
  return ClientApplication;
12249
12718
  }());
12250
12719
 
@@ -12411,7 +12880,9 @@ var PublicClientApplication = /** @class */ (function (_super) {
12411
12880
  authenticationScheme: request.authenticationScheme,
12412
12881
  resourceRequestMethod: request.resourceRequestMethod,
12413
12882
  resourceRequestUri: request.resourceRequestUri,
12414
- shrClaims: request.shrClaims
12883
+ shrClaims: request.shrClaims,
12884
+ sshJwk: request.sshJwk,
12885
+ sshKid: request.sshKid
12415
12886
  };
12416
12887
  silentRequestKey = JSON.stringify(thumbprint);
12417
12888
  cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
@@ -12447,7 +12918,7 @@ var PublicClientApplication = /** @class */ (function (_super) {
12447
12918
  var silentCacheClient, silentRequest;
12448
12919
  var _this = this;
12449
12920
  return __generator$1(this, function (_a) {
12450
- silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient);
12921
+ silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
12451
12922
  silentRequest = silentCacheClient.initializeSilentRequest(request, account);
12452
12923
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
12453
12924
  return [2 /*return*/, silentCacheClient.acquireToken(silentRequest).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
@@ -12554,6 +13025,9 @@ var stubbedPublicClientApplication = {
12554
13025
  },
12555
13026
  setNavigationClient: function () {
12556
13027
  return;
13028
+ },
13029
+ getConfiguration: function () {
13030
+ throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
12557
13031
  }
12558
13032
  };
12559
13033
 
@@ -12626,8 +13100,10 @@ var EventMessageUtils = /** @class */ (function () {
12626
13100
  * Licensed under the MIT License.
12627
13101
  */
12628
13102
  var SignedHttpRequest = /** @class */ (function () {
12629
- function SignedHttpRequest(shrParameters) {
12630
- this.cryptoOps = new CryptoOps();
13103
+ function SignedHttpRequest(shrParameters, shrOptions) {
13104
+ var loggerOptions = (shrOptions && shrOptions.loggerOptions) || {};
13105
+ this.logger = new Logger(loggerOptions, name, version);
13106
+ this.cryptoOps = new CryptoOps(this.logger);
12631
13107
  this.popTokenGenerator = new PopTokenGenerator(this.cryptoOps);
12632
13108
  this.shrParameters = shrParameters;
12633
13109
  }
@@ -12670,7 +13146,10 @@ var SignedHttpRequest = /** @class */ (function () {
12670
13146
  SignedHttpRequest.prototype.removeKeys = function (publicKeyThumbprint) {
12671
13147
  return __awaiter$1(this, void 0, void 0, function () {
12672
13148
  return __generator$1(this, function (_a) {
12673
- return [2 /*return*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
13149
+ switch (_a.label) {
13150
+ case 0: return [4 /*yield*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
13151
+ case 1: return [2 /*return*/, _a.sent()];
13152
+ }
12674
13153
  });
12675
13154
  });
12676
13155
  };
@@ -12680,6 +13159,7 @@ var SignedHttpRequest = /** @class */ (function () {
12680
13159
  exports.AccountEntity = AccountEntity;
12681
13160
  exports.AuthError = AuthError;
12682
13161
  exports.AuthErrorMessage = AuthErrorMessage;
13162
+ exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
12683
13163
  exports.BrowserAuthError = BrowserAuthError;
12684
13164
  exports.BrowserAuthErrorMessage = BrowserAuthErrorMessage;
12685
13165
  exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;