@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
@@ -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
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -107,7 +107,7 @@
107
107
  return ar;
108
108
  }
109
109
 
110
- /*! @azure/msal-common v5.0.1 2021-10-05 */
110
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
111
111
  /*! *****************************************************************************
112
112
  Copyright (c) Microsoft Corporation.
113
113
 
@@ -194,7 +194,7 @@
194
194
  return r;
195
195
  }
196
196
 
197
- /*! @azure/msal-common v5.0.1 2021-10-05 */
197
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
198
198
 
199
199
  /*
200
200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -259,6 +259,8 @@
259
259
  HeaderNames["CONTENT_TYPE"] = "Content-Type";
260
260
  HeaderNames["RETRY_AFTER"] = "Retry-After";
261
261
  HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
262
+ HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
263
+ HeaderNames["AuthenticationInfo"] = "Authentication-Info";
262
264
  })(HeaderNames || (HeaderNames = {}));
263
265
  /**
264
266
  * Persistent cache keys MSAL which stay while user is logged in.
@@ -486,8 +488,9 @@
486
488
  */
487
489
  exports.AuthenticationScheme = void 0;
488
490
  (function (AuthenticationScheme) {
489
- AuthenticationScheme["POP"] = "pop";
490
491
  AuthenticationScheme["BEARER"] = "Bearer";
492
+ AuthenticationScheme["POP"] = "pop";
493
+ AuthenticationScheme["SSH"] = "ssh-cert";
491
494
  })(exports.AuthenticationScheme || (exports.AuthenticationScheme = {}));
492
495
  /**
493
496
  * Constants related to throttling
@@ -552,7 +555,7 @@
552
555
  CacheOutcome["REFRESH_CACHED_ACCESS_TOKEN"] = "4";
553
556
  })(CacheOutcome || (CacheOutcome = {}));
554
557
 
555
- /*! @azure/msal-common v5.0.1 2021-10-05 */
558
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
556
559
 
557
560
  /*
558
561
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -596,7 +599,7 @@
596
599
  return AuthError;
597
600
  }(Error));
598
601
 
599
- /*! @azure/msal-common v5.0.1 2021-10-05 */
602
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
600
603
 
601
604
  /*
602
605
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -662,7 +665,7 @@
662
665
  }
663
666
  };
664
667
 
665
- /*! @azure/msal-common v5.0.1 2021-10-05 */
668
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
666
669
 
667
670
  /*
668
671
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -848,6 +851,10 @@
848
851
  bindingKeyNotRemovedError: {
849
852
  code: "binding_key_not_removed",
850
853
  desc: "Could not remove the credential's binding key from storage."
854
+ },
855
+ logoutNotSupported: {
856
+ code: "end_session_endpoint_not_supported",
857
+ desc: "Provided authority does not support logout."
851
858
  }
852
859
  };
853
860
  /**
@@ -1111,10 +1118,16 @@
1111
1118
  ClientAuthError.createBindingKeyNotRemovedError = function () {
1112
1119
  return new ClientAuthError(ClientAuthErrorMessage.bindingKeyNotRemovedError.code, ClientAuthErrorMessage.bindingKeyNotRemovedError.desc);
1113
1120
  };
1121
+ /**
1122
+ * Thrown when logout is attempted for an authority that doesnt have an end_session_endpoint
1123
+ */
1124
+ ClientAuthError.createLogoutNotSupportedError = function () {
1125
+ return new ClientAuthError(ClientAuthErrorMessage.logoutNotSupported.code, ClientAuthErrorMessage.logoutNotSupported.desc);
1126
+ };
1114
1127
  return ClientAuthError;
1115
1128
  }(AuthError));
1116
1129
 
1117
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1130
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1118
1131
 
1119
1132
  /*
1120
1133
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1239,7 +1252,7 @@
1239
1252
  return StringUtils;
1240
1253
  }());
1241
1254
 
1242
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1255
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1243
1256
 
1244
1257
  /*
1245
1258
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1419,12 +1432,12 @@
1419
1432
  return Logger;
1420
1433
  }());
1421
1434
 
1422
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1435
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1423
1436
  /* eslint-disable header/header */
1424
1437
  var name$1 = "@azure/msal-common";
1425
- var version$1 = "5.0.1";
1438
+ var version$1 = "5.1.0";
1426
1439
 
1427
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1440
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1428
1441
 
1429
1442
  /*
1430
1443
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1526,8 +1539,8 @@
1526
1539
  this.generateCredentialIdForCacheKey(credentialType, clientId, realm, familyId),
1527
1540
  this.generateTargetForCacheKey(target)
1528
1541
  ];
1529
- // PoP Tokens include scheme in cache key
1530
- if (tokenType === exports.AuthenticationScheme.POP) {
1542
+ // PoP Tokens and SSH certs include scheme in cache key
1543
+ if (tokenType && tokenType !== exports.AuthenticationScheme.BEARER) {
1531
1544
  credentialKey.push(tokenType.toLowerCase());
1532
1545
  }
1533
1546
  return credentialKey.join(Separators.CACHE_KEY_SEPARATOR).toLowerCase();
@@ -1568,7 +1581,7 @@
1568
1581
  return CredentialEntity;
1569
1582
  }());
1570
1583
 
1571
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1584
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1572
1585
 
1573
1586
  /*
1574
1587
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1640,15 +1653,31 @@
1640
1653
  },
1641
1654
  invalidCloudDiscoveryMetadata: {
1642
1655
  code: "invalid_cloud_discovery_metadata",
1643
- desc: "Invalid cloudDiscoveryMetadata provided. Must be a JSON object containing tenant_discovery_endpoint and metadata fields"
1656
+ desc: "Invalid cloudDiscoveryMetadata provided. Must be a stringified JSON object containing tenant_discovery_endpoint and metadata fields"
1644
1657
  },
1645
1658
  invalidAuthorityMetadata: {
1646
1659
  code: "invalid_authority_metadata",
1647
- desc: "Invalid authorityMetadata provided. Must by a JSON object containing authorization_endpoint, token_endpoint, end_session_endpoint, issuer fields."
1660
+ desc: "Invalid authorityMetadata provided. Must by a stringified JSON object containing authorization_endpoint, token_endpoint, issuer fields."
1648
1661
  },
1649
1662
  untrustedAuthority: {
1650
1663
  code: "untrusted_authority",
1651
1664
  desc: "The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter."
1665
+ },
1666
+ missingSshJwk: {
1667
+ code: "missing_ssh_jwk",
1668
+ desc: "Missing sshJwk in SSH certificate request. A stringified JSON Web Key is required when using the SSH authentication scheme."
1669
+ },
1670
+ missingSshKid: {
1671
+ code: "missing_ssh_kid",
1672
+ desc: "Missing sshKid in SSH certificate request. A string that uniquely identifies the public SSH key is required when using the SSH authentication scheme."
1673
+ },
1674
+ missingNonceAuthenticationHeader: {
1675
+ code: "missing_nonce_authentication_header",
1676
+ 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."
1677
+ },
1678
+ invalidAuthenticationHeader: {
1679
+ code: "invalid_authentication_header",
1680
+ desc: "Invalid authentication header provided"
1652
1681
  }
1653
1682
  };
1654
1683
  /**
@@ -1770,10 +1799,34 @@
1770
1799
  ClientConfigurationError.createUntrustedAuthorityError = function () {
1771
1800
  return new ClientConfigurationError(ClientConfigurationErrorMessage.untrustedAuthority.code, ClientConfigurationErrorMessage.untrustedAuthority.desc);
1772
1801
  };
1802
+ /*
1803
+ * Throws an error when the authentication scheme is set to SSH but the SSH public key is omitted from the request
1804
+ */
1805
+ ClientConfigurationError.createMissingSshJwkError = function () {
1806
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshJwk.code, ClientConfigurationErrorMessage.missingSshJwk.desc);
1807
+ };
1808
+ /**
1809
+ * Throws an error when the authentication scheme is set to SSH but the SSH public key ID is omitted from the request
1810
+ */
1811
+ ClientConfigurationError.createMissingSshKidError = function () {
1812
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingSshKid.code, ClientConfigurationErrorMessage.missingSshKid.desc);
1813
+ };
1814
+ /**
1815
+ * Throws error when provided headers don't contain a header that a server nonce can be extracted from
1816
+ */
1817
+ ClientConfigurationError.createMissingNonceAuthenticationHeadersError = function () {
1818
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.code, ClientConfigurationErrorMessage.missingNonceAuthenticationHeader.desc);
1819
+ };
1820
+ /**
1821
+ * Throws error when a provided header is invalid in any way
1822
+ */
1823
+ ClientConfigurationError.createInvalidAuthenticationHeaderError = function (invalidHeaderName, details) {
1824
+ return new ClientConfigurationError(ClientConfigurationErrorMessage.invalidAuthenticationHeader.code, ClientConfigurationErrorMessage.invalidAuthenticationHeader.desc + ". Invalid header: " + invalidHeaderName + ". Details: " + details);
1825
+ };
1773
1826
  return ClientConfigurationError;
1774
1827
  }(ClientAuthError));
1775
1828
 
1776
- /*! @azure/msal-common v5.0.1 2021-10-05 */
1829
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1777
1830
 
1778
1831
  /*
1779
1832
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1957,7 +2010,7 @@
1957
2010
  return ScopeSet;
1958
2011
  }());
1959
2012
 
1960
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2013
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1961
2014
 
1962
2015
  /*
1963
2016
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1995,7 +2048,7 @@
1995
2048
  };
1996
2049
  }
1997
2050
 
1998
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2051
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
1999
2052
  /*
2000
2053
  * Copyright (c) Microsoft Corporation. All rights reserved.
2001
2054
  * Licensed under the MIT License.
@@ -2009,7 +2062,7 @@
2009
2062
  AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
2010
2063
  })(AuthorityType || (AuthorityType = {}));
2011
2064
 
2012
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2065
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
2013
2066
 
2014
2067
  /*
2015
2068
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2243,7 +2296,7 @@
2243
2296
  return AccountEntity;
2244
2297
  }());
2245
2298
 
2246
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2299
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
2247
2300
 
2248
2301
  /*
2249
2302
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2281,7 +2334,7 @@
2281
2334
  return AuthToken;
2282
2335
  }());
2283
2336
 
2284
- /*! @azure/msal-common v5.0.1 2021-10-05 */
2337
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
2285
2338
 
2286
2339
  /*
2287
2340
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2443,7 +2496,7 @@
2443
2496
  * @param target
2444
2497
  */
2445
2498
  CacheManager.prototype.getCredentialsFilteredBy = function (filter) {
2446
- return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType);
2499
+ return this.getCredentialsFilteredByInternal(filter.homeAccountId, filter.environment, filter.credentialType, filter.clientId, filter.familyId, filter.realm, filter.target, filter.oboAssertion, filter.tokenType, filter.keyId);
2447
2500
  };
2448
2501
  /**
2449
2502
  * Support function to help match credentials
@@ -2456,7 +2509,7 @@
2456
2509
  * @param oboAssertion
2457
2510
  * @param tokenType
2458
2511
  */
2459
- CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType) {
2512
+ CacheManager.prototype.getCredentialsFilteredByInternal = function (homeAccountId, environment, credentialType, clientId, familyId, realm, target, oboAssertion, tokenType, keyId) {
2460
2513
  var _this = this;
2461
2514
  var allCacheKeys = this.getKeys();
2462
2515
  var matchingCredentials = {
@@ -2503,15 +2556,26 @@
2503
2556
  if (!!target && !_this.matchTarget(entity, target)) {
2504
2557
  return;
2505
2558
  }
2559
+ // Access Token with Auth Scheme specific matching
2506
2560
  if (credentialType === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME) {
2507
2561
  if (!!tokenType && !_this.matchTokenType(entity, tokenType)) {
2508
2562
  return;
2509
2563
  }
2510
- // This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
2511
- if (cacheKey.indexOf(exports.AuthenticationScheme.POP) === -1) {
2512
- // AccessToken_With_AuthScheme that doesn't have pop in the key is outdated
2513
- _this.removeItem(cacheKey, CacheSchemaType.CREDENTIAL);
2514
- return;
2564
+ switch (tokenType) {
2565
+ case exports.AuthenticationScheme.POP:
2566
+ // This check avoids matching outdated POP tokens that don't have the <-scheme> in the cache key
2567
+ if (cacheKey.indexOf(exports.AuthenticationScheme.POP) === -1) {
2568
+ // AccessToken_With_AuthScheme that doesn't have "-pop" in the key is outdated and needs to be removed
2569
+ _this.removeItem(cacheKey, CacheSchemaType.CREDENTIAL);
2570
+ return;
2571
+ }
2572
+ break;
2573
+ case exports.AuthenticationScheme.SSH:
2574
+ // KeyId (sshKid) in request must match cached SSH certificate keyId because SSH cert is bound to a specific key
2575
+ if (keyId && !_this.matchKeyId(entity, keyId)) {
2576
+ return;
2577
+ }
2578
+ break;
2515
2579
  }
2516
2580
  }
2517
2581
  switch (credType) {
@@ -2682,6 +2746,7 @@
2682
2746
  case 0:
2683
2747
  key = credential.generateCredentialKey();
2684
2748
  if (!(credential.credentialType.toLowerCase() === CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase())) return [3 /*break*/, 4];
2749
+ if (!(credential.tokenType === exports.AuthenticationScheme.POP)) return [3 /*break*/, 4];
2685
2750
  accessTokenWithAuthSchemeEntity = credential;
2686
2751
  kid = accessTokenWithAuthSchemeEntity.keyId;
2687
2752
  if (!kid) return [3 /*break*/, 4];
@@ -2721,10 +2786,10 @@
2721
2786
  * @param environment
2722
2787
  * @param authScheme
2723
2788
  */
2724
- CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme) {
2789
+ CacheManager.prototype.readCacheRecord = function (account, clientId, scopes, environment, authScheme, keyId) {
2725
2790
  var cachedAccount = this.readAccountFromCache(account);
2726
2791
  var cachedIdToken = this.readIdTokenFromCache(clientId, account);
2727
- var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme);
2792
+ var cachedAccessToken = this.readAccessTokenFromCache(clientId, account, scopes, authScheme, keyId);
2728
2793
  var cachedRefreshToken = this.readRefreshTokenFromCache(clientId, account, false);
2729
2794
  var cachedAppMetadata = this.readAppMetadataFromCache(environment, clientId);
2730
2795
  if (cachedAccount && cachedIdToken) {
@@ -2778,9 +2843,9 @@
2778
2843
  * @param scopes
2779
2844
  * @param authScheme
2780
2845
  */
2781
- CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme) {
2782
- // Distinguish between Bearer and PoP token cache types
2783
- var credentialType = (authScheme === exports.AuthenticationScheme.POP) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
2846
+ CacheManager.prototype.readAccessTokenFromCache = function (clientId, account, scopes, authScheme, keyId) {
2847
+ // Distinguish between Bearer and PoP/SSH token cache types
2848
+ var credentialType = (authScheme && authScheme !== exports.AuthenticationScheme.BEARER) ? CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME : CredentialType.ACCESS_TOKEN;
2784
2849
  var accessTokenFilter = {
2785
2850
  homeAccountId: account.homeAccountId,
2786
2851
  environment: account.environment,
@@ -2788,7 +2853,8 @@
2788
2853
  clientId: clientId,
2789
2854
  realm: account.tenantId,
2790
2855
  target: scopes.printScopesLowerCase(),
2791
- tokenType: authScheme
2856
+ tokenType: authScheme,
2857
+ keyId: keyId
2792
2858
  };
2793
2859
  var credentialCache = this.getCredentialsFilteredBy(accessTokenFilter);
2794
2860
  var accessTokens = Object.keys(credentialCache.accessTokens).map(function (key) { return credentialCache.accessTokens[key]; });
@@ -2941,6 +3007,14 @@
2941
3007
  CacheManager.prototype.matchTokenType = function (entity, tokenType) {
2942
3008
  return !!(entity.tokenType && entity.tokenType === tokenType);
2943
3009
  };
3010
+ /**
3011
+ * Returns true if the credential's keyId matches the one in the request, false otherwise
3012
+ * @param entity
3013
+ * @param tokenType
3014
+ */
3015
+ CacheManager.prototype.matchKeyId = function (entity, keyId) {
3016
+ return !!(entity.keyId && entity.keyId === keyId);
3017
+ };
2944
3018
  /**
2945
3019
  * returns if a given cache entity is of the type appmetadata
2946
3020
  * @param key
@@ -3092,7 +3166,7 @@
3092
3166
  return DefaultStorageClass;
3093
3167
  }(CacheManager));
3094
3168
 
3095
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3169
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3096
3170
 
3097
3171
  /*
3098
3172
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3174,7 +3248,7 @@
3174
3248
  return __assign({ clientCapabilities: [] }, authOptions);
3175
3249
  }
3176
3250
 
3177
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3251
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3178
3252
 
3179
3253
  /*
3180
3254
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3194,7 +3268,7 @@
3194
3268
  return ServerError;
3195
3269
  }(AuthError));
3196
3270
 
3197
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3271
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3198
3272
 
3199
3273
  /*
3200
3274
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3280,7 +3354,9 @@
3280
3354
  authenticationScheme: request.authenticationScheme,
3281
3355
  resourceRequestMethod: request.resourceRequestMethod,
3282
3356
  resourceRequestUri: request.resourceRequestUri,
3283
- shrClaims: request.shrClaims
3357
+ shrClaims: request.shrClaims,
3358
+ sshJwk: request.sshJwk,
3359
+ sshKid: request.sshKid
3284
3360
  };
3285
3361
  var key = this.generateThrottlingStorageKey(thumbprint);
3286
3362
  return cacheManager.removeItem(key, CacheSchemaType.THROTTLING);
@@ -3288,7 +3364,7 @@
3288
3364
  return ThrottlingUtils;
3289
3365
  }());
3290
3366
 
3291
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3367
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3292
3368
 
3293
3369
  /*
3294
3370
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3337,7 +3413,7 @@
3337
3413
  return NetworkManager;
3338
3414
  }());
3339
3415
 
3340
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3416
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3341
3417
  /*
3342
3418
  * Copyright (c) Microsoft Corporation. All rights reserved.
3343
3419
  * Licensed under the MIT License.
@@ -3348,7 +3424,7 @@
3348
3424
  CcsCredentialType["UPN"] = "UPN";
3349
3425
  })(CcsCredentialType || (CcsCredentialType = {}));
3350
3426
 
3351
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3427
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3352
3428
 
3353
3429
  /*
3354
3430
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3437,7 +3513,7 @@
3437
3513
  return BaseClient;
3438
3514
  }());
3439
3515
 
3440
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3516
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3441
3517
 
3442
3518
  /*
3443
3519
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3523,7 +3599,7 @@
3523
3599
  return RequestValidator;
3524
3600
  }());
3525
3601
 
3526
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3602
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3527
3603
 
3528
3604
  /*
3529
3605
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3827,6 +3903,15 @@
3827
3903
  this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(cnfString));
3828
3904
  }
3829
3905
  };
3906
+ /**
3907
+ * add SSH JWK and key ID to query params
3908
+ */
3909
+ RequestParameterBuilder.prototype.addSshJwk = function (sshJwkString) {
3910
+ if (!StringUtils.isEmpty(sshJwkString)) {
3911
+ this.parameters.set(AADServerParamKeys.TOKEN_TYPE, exports.AuthenticationScheme.SSH);
3912
+ this.parameters.set(AADServerParamKeys.REQ_CNF, encodeURIComponent(sshJwkString));
3913
+ }
3914
+ };
3830
3915
  /**
3831
3916
  * add server telemetry fields
3832
3917
  * @param serverTelemetryManager
@@ -3854,7 +3939,7 @@
3854
3939
  return RequestParameterBuilder;
3855
3940
  }());
3856
3941
 
3857
- /*! @azure/msal-common v5.0.1 2021-10-05 */
3942
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3858
3943
 
3859
3944
  /*
3860
3945
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3919,7 +4004,7 @@
3919
4004
  return IdTokenEntity;
3920
4005
  }(CredentialEntity));
3921
4006
 
3922
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4007
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3923
4008
  /*
3924
4009
  * Copyright (c) Microsoft Corporation. All rights reserved.
3925
4010
  * Licensed under the MIT License.
@@ -3969,7 +4054,7 @@
3969
4054
  return TimeUtils;
3970
4055
  }());
3971
4056
 
3972
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4057
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
3973
4058
 
3974
4059
  /*
3975
4060
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4015,7 +4100,7 @@
4015
4100
  * @param expiresOn
4016
4101
  * @param extExpiresOn
4017
4102
  */
4018
- AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion) {
4103
+ AccessTokenEntity.createAccessTokenEntity = function (homeAccountId, environment, accessToken, clientId, tenantId, scopes, expiresOn, extExpiresOn, cryptoUtils, refreshOn, tokenType, oboAssertion, keyId) {
4019
4104
  var _a;
4020
4105
  var atEntity = new AccessTokenEntity();
4021
4106
  atEntity.homeAccountId = homeAccountId;
@@ -4038,15 +4123,21 @@
4038
4123
  atEntity.target = scopes;
4039
4124
  atEntity.oboAssertion = oboAssertion;
4040
4125
  atEntity.tokenType = StringUtils.isEmpty(tokenType) ? exports.AuthenticationScheme.BEARER : tokenType;
4041
- // Create Access Token With AuthScheme instead of regular access token
4042
- if (atEntity.tokenType === exports.AuthenticationScheme.POP) {
4126
+ // Create Access Token With Auth Scheme instead of regular access token
4127
+ if (atEntity.tokenType !== exports.AuthenticationScheme.BEARER) {
4043
4128
  atEntity.credentialType = CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME;
4044
- // Make sure keyId is present and add it to credential
4045
- var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
4046
- if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4047
- throw ClientAuthError.createTokenClaimsRequiredError();
4129
+ switch (atEntity.tokenType) {
4130
+ case exports.AuthenticationScheme.POP:
4131
+ // Make sure keyId is present and add it to credential
4132
+ var tokenClaims = AuthToken.extractTokenClaims(accessToken, cryptoUtils);
4133
+ if (!((_a = tokenClaims === null || tokenClaims === void 0 ? void 0 : tokenClaims.cnf) === null || _a === void 0 ? void 0 : _a.kid)) {
4134
+ throw ClientAuthError.createTokenClaimsRequiredError();
4135
+ }
4136
+ atEntity.keyId = tokenClaims.cnf.kid;
4137
+ break;
4138
+ case exports.AuthenticationScheme.SSH:
4139
+ atEntity.keyId = keyId;
4048
4140
  }
4049
- atEntity.keyId = tokenClaims.cnf.kid;
4050
4141
  }
4051
4142
  return atEntity;
4052
4143
  };
@@ -4070,7 +4161,7 @@
4070
4161
  return AccessTokenEntity;
4071
4162
  }(CredentialEntity));
4072
4163
 
4073
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4164
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4074
4165
 
4075
4166
  /*
4076
4167
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4137,7 +4228,7 @@
4137
4228
  return RefreshTokenEntity;
4138
4229
  }(CredentialEntity));
4139
4230
 
4140
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4231
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4141
4232
 
4142
4233
  /*
4143
4234
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4201,7 +4292,7 @@
4201
4292
  return InteractionRequiredAuthError;
4202
4293
  }(AuthError));
4203
4294
 
4204
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4295
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4205
4296
  /*
4206
4297
  * Copyright (c) Microsoft Corporation. All rights reserved.
4207
4298
  * Licensed under the MIT License.
@@ -4217,7 +4308,7 @@
4217
4308
  return CacheRecord;
4218
4309
  }());
4219
4310
 
4220
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4311
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4221
4312
 
4222
4313
  /*
4223
4314
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4288,7 +4379,7 @@
4288
4379
  return ProtocolUtils;
4289
4380
  }());
4290
4381
 
4291
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4382
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4292
4383
 
4293
4384
  /*
4294
4385
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4489,7 +4580,7 @@
4489
4580
  return UrlString;
4490
4581
  }());
4491
4582
 
4492
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4583
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4493
4584
 
4494
4585
  /*
4495
4586
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4548,14 +4639,14 @@
4548
4639
  };
4549
4640
  PopTokenGenerator.prototype.signPayload = function (payload, kid, request, claims) {
4550
4641
  return __awaiter(this, void 0, void 0, function () {
4551
- var resourceRequestMethod, resourceRequestUri, shrClaims, resourceUrlString, resourceUrlComponents;
4642
+ var resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, resourceUrlString, resourceUrlComponents;
4552
4643
  return __generator(this, function (_a) {
4553
4644
  switch (_a.label) {
4554
4645
  case 0:
4555
- resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims;
4646
+ resourceRequestMethod = request.resourceRequestMethod, resourceRequestUri = request.resourceRequestUri, shrClaims = request.shrClaims, shrNonce = request.shrNonce;
4556
4647
  resourceUrlString = (resourceRequestUri) ? new UrlString(resourceRequestUri) : undefined;
4557
4648
  resourceUrlComponents = resourceUrlString === null || resourceUrlString === void 0 ? void 0 : resourceUrlString.getUrlComponents();
4558
- return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
4649
+ return [4 /*yield*/, this.cryptoUtils.signJwt(__assign({ at: payload, ts: TimeUtils.nowSeconds(), m: resourceRequestMethod === null || resourceRequestMethod === void 0 ? void 0 : resourceRequestMethod.toUpperCase(), u: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.HostNameAndPort, nonce: shrNonce || this.cryptoUtils.createNewGuid(), p: resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.AbsolutePath, q: (resourceUrlComponents === null || resourceUrlComponents === void 0 ? void 0 : resourceUrlComponents.QueryString) ? [[], resourceUrlComponents.QueryString] : undefined, client_claims: shrClaims || undefined }, claims), kid)];
4559
4650
  case 1: return [2 /*return*/, _a.sent()];
4560
4651
  }
4561
4652
  });
@@ -4564,7 +4655,7 @@
4564
4655
  return PopTokenGenerator;
4565
4656
  }());
4566
4657
 
4567
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4658
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4568
4659
 
4569
4660
  /*
4570
4661
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4634,7 +4725,7 @@
4634
4725
  return AppMetadataEntity;
4635
4726
  }());
4636
4727
 
4637
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4728
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4638
4729
  /*
4639
4730
  * Copyright (c) Microsoft Corporation. All rights reserved.
4640
4731
  * Licensed under the MIT License.
@@ -4670,7 +4761,7 @@
4670
4761
  return TokenCacheContext;
4671
4762
  }());
4672
4763
 
4673
- /*! @azure/msal-common v5.0.1 2021-10-05 */
4764
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4674
4765
 
4675
4766
  /*
4676
4767
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4751,6 +4842,8 @@
4751
4842
  if (!!authCodePayload && !!authCodePayload.state) {
4752
4843
  requestStateObj = ProtocolUtils.parseRequestState(this.cryptoObj, authCodePayload.state);
4753
4844
  }
4845
+ // Add keyId from request to serverTokenResponse if defined
4846
+ serverTokenResponse.key_id = serverTokenResponse.key_id || request.sshKid || undefined;
4754
4847
  cacheRecord = this.generateCacheRecord(serverTokenResponse, authority, reqTimestamp, idTokenObj, request.scopes, oboAssertion, authCodePayload);
4755
4848
  _a.label = 1;
4756
4849
  case 1:
@@ -4827,7 +4920,7 @@
4827
4920
  var extendedTokenExpirationSeconds = tokenExpirationSeconds + extExpiresIn;
4828
4921
  var refreshOnSeconds = refreshIn && refreshIn > 0 ? reqTimestamp + refreshIn : undefined;
4829
4922
  // non AAD scenarios can have empty realm
4830
- cachedAccessToken = AccessTokenEntity.createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token || Constants.EMPTY_STRING, this.clientId, idTokenObj ? idTokenObj.claims.tid || Constants.EMPTY_STRING : authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj, refreshOnSeconds, serverTokenResponse.token_type, oboAssertion);
4923
+ 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);
4831
4924
  }
4832
4925
  // refreshToken
4833
4926
  var cachedRefreshToken = null;
@@ -4932,7 +5025,7 @@
4932
5025
  return ResponseHandler;
4933
5026
  }());
4934
5027
 
4935
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5028
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
4936
5029
 
4937
5030
  /*
4938
5031
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5047,7 +5140,9 @@
5047
5140
  authenticationScheme: request.authenticationScheme,
5048
5141
  resourceRequestMethod: request.resourceRequestMethod,
5049
5142
  resourceRequestUri: request.resourceRequestUri,
5050
- shrClaims: request.shrClaims
5143
+ shrClaims: request.shrClaims,
5144
+ sshJwk: request.sshJwk,
5145
+ sshKid: request.sshKid
5051
5146
  };
5052
5147
  return [4 /*yield*/, this.createTokenRequestBody(request)];
5053
5148
  case 1:
@@ -5128,8 +5223,18 @@
5128
5223
  case 1:
5129
5224
  cnfString = _a.sent();
5130
5225
  parameterBuilder.addPopToken(cnfString);
5131
- _a.label = 2;
5226
+ return [3 /*break*/, 3];
5132
5227
  case 2:
5228
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
5229
+ if (request.sshJwk) {
5230
+ parameterBuilder.addSshJwk(request.sshJwk);
5231
+ }
5232
+ else {
5233
+ throw ClientConfigurationError.createMissingSshJwkError();
5234
+ }
5235
+ }
5236
+ _a.label = 3;
5237
+ case 3:
5133
5238
  correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5134
5239
  parameterBuilder.addCorrelationId(correlationId);
5135
5240
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
@@ -5305,7 +5410,7 @@
5305
5410
  return AuthorizationCodeClient;
5306
5411
  }(BaseClient));
5307
5412
 
5308
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5413
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5309
5414
 
5310
5415
  /*
5311
5416
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5419,7 +5524,9 @@
5419
5524
  authenticationScheme: request.authenticationScheme,
5420
5525
  resourceRequestMethod: request.resourceRequestMethod,
5421
5526
  resourceRequestUri: request.resourceRequestUri,
5422
- shrClaims: request.shrClaims
5527
+ shrClaims: request.shrClaims,
5528
+ sshJwk: request.sshJwk,
5529
+ sshKid: request.sshKid
5423
5530
  };
5424
5531
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
5425
5532
  return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
@@ -5444,9 +5551,9 @@
5444
5551
  */
5445
5552
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
5446
5553
  return __awaiter(this, void 0, void 0, function () {
5447
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, _a, _b, clientInfo;
5448
- return __generator(this, function (_c) {
5449
- switch (_c.label) {
5554
+ var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, cnfString, clientInfo;
5555
+ return __generator(this, function (_a) {
5556
+ switch (_a.label) {
5450
5557
  case 0:
5451
5558
  parameterBuilder = new RequestParameterBuilder();
5452
5559
  parameterBuilder.addClientId(this.config.authOptions.clientId);
@@ -5471,12 +5578,22 @@
5471
5578
  }
5472
5579
  if (!(request.authenticationScheme === exports.AuthenticationScheme.POP)) return [3 /*break*/, 2];
5473
5580
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5474
- _b = (_a = parameterBuilder).addPopToken;
5475
5581
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5476
5582
  case 1:
5477
- _b.apply(_a, [_c.sent()]);
5478
- _c.label = 2;
5583
+ cnfString = _a.sent();
5584
+ parameterBuilder.addPopToken(cnfString);
5585
+ return [3 /*break*/, 3];
5479
5586
  case 2:
5587
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
5588
+ if (request.sshJwk) {
5589
+ parameterBuilder.addSshJwk(request.sshJwk);
5590
+ }
5591
+ else {
5592
+ throw ClientConfigurationError.createMissingSshJwkError();
5593
+ }
5594
+ }
5595
+ _a.label = 3;
5596
+ case 3:
5480
5597
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
5481
5598
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
5482
5599
  }
@@ -5504,7 +5621,7 @@
5504
5621
  return RefreshTokenClient;
5505
5622
  }(BaseClient));
5506
5623
 
5507
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5624
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5508
5625
 
5509
5626
  /*
5510
5627
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5558,6 +5675,17 @@
5558
5675
  if (!request) {
5559
5676
  throw ClientConfigurationError.createEmptyTokenRequestError();
5560
5677
  }
5678
+ if (request.forceRefresh) {
5679
+ // Must refresh due to present force_refresh flag.
5680
+ (_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
5681
+ this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because forceRefresh is true.");
5682
+ throw ClientAuthError.createRefreshRequiredError();
5683
+ }
5684
+ else if (!StringUtils.isEmptyObj(request.claims)) {
5685
+ // Must refresh due to request parameters.
5686
+ this.logger.info("SilentFlowClient:acquireCachedToken - Skipping cache because claims are requested.");
5687
+ throw ClientAuthError.createRefreshRequiredError();
5688
+ }
5561
5689
  // We currently do not support silent flow for account === null use cases; This will be revisited for confidential flow usecases
5562
5690
  if (!request.account) {
5563
5691
  throw ClientAuthError.createNoAccountInSilentRequestError();
@@ -5565,30 +5693,24 @@
5565
5693
  requestScopes = new ScopeSet(request.scopes || []);
5566
5694
  environment = request.authority || this.authority.getPreferredCache();
5567
5695
  authScheme = request.authenticationScheme || exports.AuthenticationScheme.BEARER;
5568
- cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme);
5569
- if (request.forceRefresh) {
5570
- // Must refresh due to present force_refresh flag.
5571
- (_a = this.serverTelemetryManager) === null || _a === void 0 ? void 0 : _a.setCacheOutcome(CacheOutcome.FORCE_REFRESH);
5572
- throw ClientAuthError.createRefreshRequiredError();
5573
- }
5574
- else if (!cacheRecord.accessToken) {
5696
+ cacheRecord = this.cacheManager.readCacheRecord(request.account, this.config.authOptions.clientId, requestScopes, environment, authScheme, request.sshKid);
5697
+ if (!cacheRecord.accessToken) {
5575
5698
  // Must refresh due to non-existent access_token.
5576
5699
  (_b = this.serverTelemetryManager) === null || _b === void 0 ? void 0 : _b.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN);
5700
+ this.logger.info("SilentFlowClient:acquireCachedToken - No access token found in cache for the given properties.");
5577
5701
  throw ClientAuthError.createRefreshRequiredError();
5578
5702
  }
5579
5703
  else if (TimeUtils.wasClockTurnedBack(cacheRecord.accessToken.cachedAt) ||
5580
5704
  TimeUtils.isTokenExpired(cacheRecord.accessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
5581
5705
  // Must refresh due to expired access_token.
5582
5706
  (_c = this.serverTelemetryManager) === null || _c === void 0 ? void 0 : _c.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED);
5707
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token is expired or will expire within " + this.config.systemOptions.tokenRenewalOffsetSeconds + " seconds.");
5583
5708
  throw ClientAuthError.createRefreshRequiredError();
5584
5709
  }
5585
5710
  else if (cacheRecord.accessToken.refreshOn && TimeUtils.isTokenExpired(cacheRecord.accessToken.refreshOn, 0)) {
5586
5711
  // Must refresh due to the refresh_in value.
5587
5712
  (_d = this.serverTelemetryManager) === null || _d === void 0 ? void 0 : _d.setCacheOutcome(CacheOutcome.REFRESH_CACHED_ACCESS_TOKEN);
5588
- throw ClientAuthError.createRefreshRequiredError();
5589
- }
5590
- else if (!StringUtils.isEmptyObj(request.claims)) {
5591
- // Must refresh due to request parameters.
5713
+ this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'.");
5592
5714
  throw ClientAuthError.createRefreshRequiredError();
5593
5715
  }
5594
5716
  if (this.config.serverTelemetryManager) {
@@ -5622,7 +5744,7 @@
5622
5744
  return SilentFlowClient;
5623
5745
  }(BaseClient));
5624
5746
 
5625
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5747
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5626
5748
  /*
5627
5749
  * Copyright (c) Microsoft Corporation. All rights reserved.
5628
5750
  * Licensed under the MIT License.
@@ -5630,11 +5752,10 @@
5630
5752
  function isOpenIdConfigResponse(response) {
5631
5753
  return (response.hasOwnProperty("authorization_endpoint") &&
5632
5754
  response.hasOwnProperty("token_endpoint") &&
5633
- response.hasOwnProperty("end_session_endpoint") &&
5634
5755
  response.hasOwnProperty("issuer"));
5635
5756
  }
5636
5757
 
5637
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5758
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5638
5759
  /*
5639
5760
  * Copyright (c) Microsoft Corporation. All rights reserved.
5640
5761
  * Licensed under the MIT License.
@@ -5648,7 +5769,7 @@
5648
5769
  ProtocolMode["OIDC"] = "OIDC";
5649
5770
  })(exports.ProtocolMode || (exports.ProtocolMode = {}));
5650
5771
 
5651
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5772
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5652
5773
 
5653
5774
  /*
5654
5775
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5715,7 +5836,6 @@
5715
5836
  entity.hasOwnProperty("canonical_authority") &&
5716
5837
  entity.hasOwnProperty("authorization_endpoint") &&
5717
5838
  entity.hasOwnProperty("token_endpoint") &&
5718
- entity.hasOwnProperty("end_session_endpoint") &&
5719
5839
  entity.hasOwnProperty("issuer") &&
5720
5840
  entity.hasOwnProperty("aliasesFromNetwork") &&
5721
5841
  entity.hasOwnProperty("endpointsFromNetwork") &&
@@ -5724,7 +5844,7 @@
5724
5844
  return AuthorityMetadataEntity;
5725
5845
  }());
5726
5846
 
5727
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5847
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5728
5848
  /*
5729
5849
  * Copyright (c) Microsoft Corporation. All rights reserved.
5730
5850
  * Licensed under the MIT License.
@@ -5734,7 +5854,7 @@
5734
5854
  response.hasOwnProperty("metadata"));
5735
5855
  }
5736
5856
 
5737
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5857
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5738
5858
 
5739
5859
  /*
5740
5860
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5848,7 +5968,7 @@
5848
5968
  return RegionDiscovery;
5849
5969
  }());
5850
5970
 
5851
- /*! @azure/msal-common v5.0.1 2021-10-05 */
5971
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
5852
5972
 
5853
5973
  /*
5854
5974
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6002,6 +6122,10 @@
6002
6122
  */
6003
6123
  get: function () {
6004
6124
  if (this.discoveryComplete()) {
6125
+ // ROPC policies may not have end_session_endpoint set
6126
+ if (!this.metadata.end_session_endpoint) {
6127
+ throw ClientAuthError.createLogoutNotSupportedError();
6128
+ }
6005
6129
  var endpoint = this.replacePath(this.metadata.end_session_endpoint);
6006
6130
  return this.replaceTenant(endpoint);
6007
6131
  }
@@ -6402,13 +6526,15 @@
6402
6526
  metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
6403
6527
  // TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
6404
6528
  metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, "allowestsrnonmsi=true");
6405
- metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
6529
+ if (metadata.end_session_endpoint) {
6530
+ metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
6531
+ }
6406
6532
  return metadata;
6407
6533
  };
6408
6534
  return Authority;
6409
6535
  }());
6410
6536
 
6411
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6537
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6412
6538
 
6413
6539
  /*
6414
6540
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6469,7 +6595,7 @@
6469
6595
  return AuthorityFactory;
6470
6596
  }());
6471
6597
 
6472
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6598
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6473
6599
 
6474
6600
  /*
6475
6601
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6500,7 +6626,7 @@
6500
6626
  return ServerTelemetryEntity;
6501
6627
  }());
6502
6628
 
6503
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6629
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6504
6630
 
6505
6631
  /*
6506
6632
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6528,7 +6654,7 @@
6528
6654
  return ThrottlingEntity;
6529
6655
  }());
6530
6656
 
6531
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6657
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6532
6658
 
6533
6659
  /*
6534
6660
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6545,7 +6671,66 @@
6545
6671
  }
6546
6672
  };
6547
6673
 
6548
- /*! @azure/msal-common v5.0.1 2021-10-05 */
6674
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6675
+
6676
+ /*
6677
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6678
+ * Licensed under the MIT License.
6679
+ */
6680
+ /**
6681
+ * This is a helper class that parses supported HTTP response authentication headers to extract and return
6682
+ * header challenge values that can be used outside the basic authorization flows.
6683
+ */
6684
+ var AuthenticationHeaderParser = /** @class */ (function () {
6685
+ function AuthenticationHeaderParser(headers) {
6686
+ this.headers = headers;
6687
+ }
6688
+ /**
6689
+ * This method parses the SHR nonce value out of either the Authentication-Info or WWW-Authenticate authentication headers.
6690
+ * @returns
6691
+ */
6692
+ AuthenticationHeaderParser.prototype.getShrNonce = function () {
6693
+ // Attempt to parse nonce from Authentiacation-Info
6694
+ var authenticationInfo = this.headers[HeaderNames.AuthenticationInfo];
6695
+ if (authenticationInfo) {
6696
+ var authenticationInfoChallenges = this.parseChallenges(authenticationInfo);
6697
+ if (authenticationInfoChallenges.nextnonce) {
6698
+ return authenticationInfoChallenges.nextnonce;
6699
+ }
6700
+ throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.AuthenticationInfo, "nextnonce challenge is missing.");
6701
+ }
6702
+ // Attempt to parse nonce from WWW-Authenticate
6703
+ var wwwAuthenticate = this.headers[HeaderNames.WWWAuthenticate];
6704
+ if (wwwAuthenticate) {
6705
+ var wwwAuthenticateChallenges = this.parseChallenges(wwwAuthenticate);
6706
+ if (wwwAuthenticateChallenges.nonce) {
6707
+ return wwwAuthenticateChallenges.nonce;
6708
+ }
6709
+ throw ClientConfigurationError.createInvalidAuthenticationHeaderError(HeaderNames.WWWAuthenticate, "nonce challenge is missing.");
6710
+ }
6711
+ // If neither header is present, throw missing headers error
6712
+ throw ClientConfigurationError.createMissingNonceAuthenticationHeadersError();
6713
+ };
6714
+ /**
6715
+ * Parses an HTTP header's challenge set into a key/value map.
6716
+ * @param header
6717
+ * @returns
6718
+ */
6719
+ AuthenticationHeaderParser.prototype.parseChallenges = function (header) {
6720
+ var schemeSeparator = header.indexOf(" ");
6721
+ var challenges = header.substr(schemeSeparator + 1).split(",");
6722
+ var challengeMap = {};
6723
+ challenges.forEach(function (challenge) {
6724
+ var _a = challenge.split("="), key = _a[0], value = _a[1];
6725
+ // Remove escaped quotation marks (', ") from challenge string to keep only the challenge value
6726
+ challengeMap[key] = unescape(value.replace(/['"]+/g, ""));
6727
+ });
6728
+ return challengeMap;
6729
+ };
6730
+ return AuthenticationHeaderParser;
6731
+ }());
6732
+
6733
+ /*! @azure/msal-common v5.1.0 2021-11-02 */
6549
6734
 
6550
6735
  /*
6551
6736
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6858,7 +7043,11 @@
6858
7043
  (function (WrapperSKU) {
6859
7044
  WrapperSKU["React"] = "@azure/msal-react";
6860
7045
  WrapperSKU["Angular"] = "@azure/msal-angular";
6861
- })(exports.WrapperSKU || (exports.WrapperSKU = {}));
7046
+ })(exports.WrapperSKU || (exports.WrapperSKU = {}));
7047
+ // DatabaseStorage Constants
7048
+ var DB_NAME = "msal.db";
7049
+ var DB_VERSION = 1;
7050
+ var DB_TABLE_NAME = DB_NAME + ".keys";
6862
7051
 
6863
7052
  /*
6864
7053
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7334,7 +7523,7 @@
7334
7523
  },
7335
7524
  noTokenRequestCacheError: {
7336
7525
  code: "no_token_request_cache_error",
7337
- desc: "No token request in found in cache."
7526
+ desc: "No token request found in cache."
7338
7527
  },
7339
7528
  unableToParseTokenRequestCacheError: {
7340
7529
  code: "unable_to_parse_token_request_cache_error",
@@ -7383,6 +7572,10 @@
7383
7572
  signingKeyNotFoundInStorage: {
7384
7573
  code: "crypto_key_not_found",
7385
7574
  desc: "Cryptographic Key or Keypair not found in browser storage."
7575
+ },
7576
+ databaseUnavailable: {
7577
+ code: "database_unavailable",
7578
+ desc: "IndexedDB, which is required for persistent cryptographic key storage, is unavailable. This may be caused by browser privacy features which block persistent storage in third-party contexts."
7386
7579
  }
7387
7580
  };
7388
7581
  /**
@@ -7616,6 +7809,12 @@
7616
7809
  BrowserAuthError.createSigningKeyNotFoundInStorageError = function (keyId) {
7617
7810
  return new BrowserAuthError(BrowserAuthErrorMessage.signingKeyNotFoundInStorage.code, BrowserAuthErrorMessage.signingKeyNotFoundInStorage.desc + " | No match found for KeyId: " + keyId);
7618
7811
  };
7812
+ /**
7813
+ * Create an error when IndexedDB is unavailable
7814
+ */
7815
+ BrowserAuthError.createDatabaseUnavailableError = function () {
7816
+ return new BrowserAuthError(BrowserAuthErrorMessage.databaseUnavailable.code, BrowserAuthErrorMessage.databaseUnavailable.desc);
7817
+ };
7619
7818
  return BrowserAuthError;
7620
7819
  }(AuthError));
7621
7820
 
@@ -7718,7 +7917,8 @@
7718
7917
  * hashing and encoding. It also has helper functions to validate the availability of specific APIs.
7719
7918
  */
7720
7919
  var BrowserCrypto = /** @class */ (function () {
7721
- function BrowserCrypto() {
7920
+ function BrowserCrypto(logger) {
7921
+ this.logger = logger;
7722
7922
  if (!(this.hasCryptoAPI())) {
7723
7923
  throw BrowserAuthError.createCryptoNotAvailableError("Browser crypto or msCrypto object not available.");
7724
7924
  }
@@ -7977,10 +8177,10 @@
7977
8177
  * Storage wrapper for IndexedDB storage in browsers: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
7978
8178
  */
7979
8179
  var DatabaseStorage = /** @class */ (function () {
7980
- function DatabaseStorage(dbName, tableName, version) {
7981
- this.dbName = dbName;
7982
- this.tableName = tableName;
7983
- this.version = version;
8180
+ function DatabaseStorage() {
8181
+ this.dbName = DB_NAME;
8182
+ this.version = DB_VERSION;
8183
+ this.tableName = DB_TABLE_NAME;
7984
8184
  this.dbOpen = false;
7985
8185
  }
7986
8186
  /**
@@ -7991,7 +8191,6 @@
7991
8191
  var _this = this;
7992
8192
  return __generator$1(this, function (_a) {
7993
8193
  return [2 /*return*/, new Promise(function (resolve, reject) {
7994
- // TODO: Add timeouts?
7995
8194
  var openDB = window.indexedDB.open(_this.dbName, _this.version);
7996
8195
  openDB.addEventListener("upgradeneeded", function (e) {
7997
8196
  var event = e;
@@ -8003,40 +8202,53 @@
8003
8202
  _this.dbOpen = true;
8004
8203
  resolve();
8005
8204
  });
8006
- openDB.addEventListener("error", function (error) { return reject(error); });
8205
+ openDB.addEventListener("error", function () { return reject(BrowserAuthError.createDatabaseUnavailableError()); });
8007
8206
  })];
8008
8207
  });
8009
8208
  });
8010
8209
  };
8011
8210
  /**
8012
- * Retrieves item from IndexedDB instance.
8013
- * @param key
8211
+ * Opens database if it's not already open
8014
8212
  */
8015
- DatabaseStorage.prototype.get = function (key) {
8213
+ DatabaseStorage.prototype.validateDbIsOpen = function () {
8016
8214
  return __awaiter$1(this, void 0, void 0, function () {
8017
- var _this = this;
8018
8215
  return __generator$1(this, function (_a) {
8019
8216
  switch (_a.label) {
8020
8217
  case 0:
8021
8218
  if (!!this.dbOpen) return [3 /*break*/, 2];
8022
8219
  return [4 /*yield*/, this.open()];
8220
+ case 1: return [2 /*return*/, _a.sent()];
8221
+ case 2: return [2 /*return*/];
8222
+ }
8223
+ });
8224
+ });
8225
+ };
8226
+ /**
8227
+ * Retrieves item from IndexedDB instance.
8228
+ * @param key
8229
+ */
8230
+ DatabaseStorage.prototype.getItem = function (key) {
8231
+ return __awaiter$1(this, void 0, void 0, function () {
8232
+ var _this = this;
8233
+ return __generator$1(this, function (_a) {
8234
+ switch (_a.label) {
8235
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8023
8236
  case 1:
8024
8237
  _a.sent();
8025
- _a.label = 2;
8026
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8027
- // TODO: Add timeouts?
8028
- if (!_this.db) {
8029
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8030
- }
8031
- var transaction = _this.db.transaction([_this.tableName], "readonly");
8032
- var objectStore = transaction.objectStore(_this.tableName);
8033
- var dbGet = objectStore.get(key);
8034
- dbGet.addEventListener("success", function (e) {
8035
- var event = e;
8036
- resolve(event.target.result);
8037
- });
8038
- dbGet.addEventListener("error", function (e) { return reject(e); });
8039
- })];
8238
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8239
+ // TODO: Add timeouts?
8240
+ if (!_this.db) {
8241
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8242
+ }
8243
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8244
+ var objectStore = transaction.objectStore(_this.tableName);
8245
+ var dbGet = objectStore.get(key);
8246
+ dbGet.addEventListener("success", function (e) {
8247
+ var event = e;
8248
+ resolve(event.target.result);
8249
+ });
8250
+ dbGet.addEventListener("error", function (e) { return reject(e); });
8251
+ })];
8040
8252
  }
8041
8253
  });
8042
8254
  });
@@ -8046,31 +8258,25 @@
8046
8258
  * @param key
8047
8259
  * @param payload
8048
8260
  */
8049
- DatabaseStorage.prototype.put = function (key, payload) {
8261
+ DatabaseStorage.prototype.setItem = function (key, payload) {
8050
8262
  return __awaiter$1(this, void 0, void 0, function () {
8051
8263
  var _this = this;
8052
8264
  return __generator$1(this, function (_a) {
8053
8265
  switch (_a.label) {
8054
- case 0:
8055
- if (!!this.dbOpen) return [3 /*break*/, 2];
8056
- return [4 /*yield*/, this.open()];
8266
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8057
8267
  case 1:
8058
8268
  _a.sent();
8059
- _a.label = 2;
8060
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8061
- // TODO: Add timeouts?
8062
- if (!_this.db) {
8063
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8064
- }
8065
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8066
- var objectStore = transaction.objectStore(_this.tableName);
8067
- var dbPut = objectStore.put(payload, key);
8068
- dbPut.addEventListener("success", function (e) {
8069
- var event = e;
8070
- resolve(event.target.result);
8071
- });
8072
- dbPut.addEventListener("error", function (e) { return reject(e); });
8073
- })];
8269
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8270
+ // TODO: Add timeouts?
8271
+ if (!_this.db) {
8272
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8273
+ }
8274
+ var transaction = _this.db.transaction([_this.tableName], "readwrite");
8275
+ var objectStore = transaction.objectStore(_this.tableName);
8276
+ var dbPut = objectStore.put(payload, key);
8277
+ dbPut.addEventListener("success", function () { return resolve(); });
8278
+ dbPut.addEventListener("error", function (e) { return reject(e); });
8279
+ })];
8074
8280
  }
8075
8281
  });
8076
8282
  });
@@ -8079,65 +8285,323 @@
8079
8285
  * Removes item from IndexedDB under given key
8080
8286
  * @param key
8081
8287
  */
8082
- DatabaseStorage.prototype.delete = function (key) {
8288
+ DatabaseStorage.prototype.removeItem = function (key) {
8083
8289
  return __awaiter$1(this, void 0, void 0, function () {
8084
8290
  var _this = this;
8085
8291
  return __generator$1(this, function (_a) {
8086
8292
  switch (_a.label) {
8087
- case 0:
8088
- if (!!this.dbOpen) return [3 /*break*/, 2];
8089
- return [4 /*yield*/, this.open()];
8293
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8090
8294
  case 1:
8091
8295
  _a.sent();
8092
- _a.label = 2;
8093
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8094
- if (!_this.db) {
8095
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8096
- }
8097
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8098
- var objectStore = transaction.objectStore(_this.tableName);
8099
- var dbDelete = objectStore.delete(key);
8100
- dbDelete.addEventListener("success", function (e) {
8101
- var event = e;
8102
- resolve(event.target.result === undefined);
8103
- });
8104
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8105
- })];
8296
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8297
+ if (!_this.db) {
8298
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8299
+ }
8300
+ var transaction = _this.db.transaction([_this.tableName], "readwrite");
8301
+ var objectStore = transaction.objectStore(_this.tableName);
8302
+ var dbDelete = objectStore.delete(key);
8303
+ dbDelete.addEventListener("success", function () { return resolve(); });
8304
+ dbDelete.addEventListener("error", function (e) { return reject(e); });
8305
+ })];
8106
8306
  }
8107
8307
  });
8108
8308
  });
8109
8309
  };
8110
- DatabaseStorage.prototype.clear = function () {
8310
+ /**
8311
+ * Get all the keys from the storage object as an iterable array of strings.
8312
+ */
8313
+ DatabaseStorage.prototype.getKeys = function () {
8111
8314
  return __awaiter$1(this, void 0, void 0, function () {
8112
8315
  var _this = this;
8113
8316
  return __generator$1(this, function (_a) {
8114
8317
  switch (_a.label) {
8115
- case 0:
8116
- if (!!this.dbOpen) return [3 /*break*/, 2];
8117
- return [4 /*yield*/, this.open()];
8318
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8118
8319
  case 1:
8119
8320
  _a.sent();
8120
- _a.label = 2;
8121
- case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
8122
- if (!_this.db) {
8123
- return reject(BrowserAuthError.createDatabaseNotOpenError());
8124
- }
8125
- var transaction = _this.db.transaction([_this.tableName], "readwrite");
8126
- var objectStore = transaction.objectStore(_this.tableName);
8127
- var dbDelete = objectStore.clear();
8128
- dbDelete.addEventListener("success", function (e) {
8129
- var event = e;
8130
- resolve(event.target.result === undefined);
8131
- });
8132
- dbDelete.addEventListener("error", function (e) { return reject(e); });
8133
- })];
8321
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8322
+ if (!_this.db) {
8323
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8324
+ }
8325
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8326
+ var objectStore = transaction.objectStore(_this.tableName);
8327
+ var dbGetKeys = objectStore.getAllKeys();
8328
+ dbGetKeys.addEventListener("success", function (e) {
8329
+ var event = e;
8330
+ resolve(event.target.result);
8331
+ });
8332
+ dbGetKeys.addEventListener("error", function (e) { return reject(e); });
8333
+ })];
8134
8334
  }
8135
8335
  });
8136
8336
  });
8137
8337
  };
8338
+ /**
8339
+ *
8340
+ * Checks whether there is an object under the search key in the object store
8341
+ */
8342
+ DatabaseStorage.prototype.containsKey = function (key) {
8343
+ return __awaiter$1(this, void 0, void 0, function () {
8344
+ var _this = this;
8345
+ return __generator$1(this, function (_a) {
8346
+ switch (_a.label) {
8347
+ case 0: return [4 /*yield*/, this.validateDbIsOpen()];
8348
+ case 1:
8349
+ _a.sent();
8350
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8351
+ if (!_this.db) {
8352
+ return reject(BrowserAuthError.createDatabaseNotOpenError());
8353
+ }
8354
+ var transaction = _this.db.transaction([_this.tableName], "readonly");
8355
+ var objectStore = transaction.objectStore(_this.tableName);
8356
+ var dbContainsKey = objectStore.count(key);
8357
+ dbContainsKey.addEventListener("success", function (e) {
8358
+ var event = e;
8359
+ resolve(event.target.result === 1);
8360
+ });
8361
+ dbContainsKey.addEventListener("error", function (e) { return reject(e); });
8362
+ })];
8363
+ }
8364
+ });
8365
+ });
8366
+ };
8367
+ /**
8368
+ * Deletes the MSAL database. The database is deleted rather than cleared to make it possible
8369
+ * for client applications to downgrade to a previous MSAL version without worrying about forward compatibility issues
8370
+ * with IndexedDB database versions.
8371
+ */
8372
+ DatabaseStorage.prototype.deleteDatabase = function () {
8373
+ return __awaiter$1(this, void 0, void 0, function () {
8374
+ return __generator$1(this, function (_a) {
8375
+ return [2 /*return*/, new Promise(function (resolve, reject) {
8376
+ var deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
8377
+ deleteDbRequest.addEventListener("success", function () { return resolve(true); });
8378
+ deleteDbRequest.addEventListener("error", function () { return reject(false); });
8379
+ })];
8380
+ });
8381
+ });
8382
+ };
8138
8383
  return DatabaseStorage;
8139
8384
  }());
8140
8385
 
8386
+ /*
8387
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8388
+ * Licensed under the MIT License.
8389
+ */
8390
+ var MemoryStorage = /** @class */ (function () {
8391
+ function MemoryStorage() {
8392
+ this.cache = new Map();
8393
+ }
8394
+ MemoryStorage.prototype.getItem = function (key) {
8395
+ return this.cache.get(key) || null;
8396
+ };
8397
+ MemoryStorage.prototype.setItem = function (key, value) {
8398
+ this.cache.set(key, value);
8399
+ };
8400
+ MemoryStorage.prototype.removeItem = function (key) {
8401
+ this.cache.delete(key);
8402
+ };
8403
+ MemoryStorage.prototype.getKeys = function () {
8404
+ var cacheKeys = [];
8405
+ this.cache.forEach(function (value, key) {
8406
+ cacheKeys.push(key);
8407
+ });
8408
+ return cacheKeys;
8409
+ };
8410
+ MemoryStorage.prototype.containsKey = function (key) {
8411
+ return this.cache.has(key);
8412
+ };
8413
+ MemoryStorage.prototype.clear = function () {
8414
+ this.cache.clear();
8415
+ };
8416
+ return MemoryStorage;
8417
+ }());
8418
+
8419
+ /*
8420
+ * Copyright (c) Microsoft Corporation. All rights reserved.
8421
+ * Licensed under the MIT License.
8422
+ */
8423
+ /**
8424
+ * This class allows MSAL to store artifacts asynchronously using the DatabaseStorage IndexedDB wrapper,
8425
+ * backed up with the more volatile MemoryStorage object for cases in which IndexedDB may be unavailable.
8426
+ */
8427
+ var AsyncMemoryStorage = /** @class */ (function () {
8428
+ function AsyncMemoryStorage(logger) {
8429
+ this.inMemoryCache = new MemoryStorage();
8430
+ this.indexedDBCache = new DatabaseStorage();
8431
+ this.logger = logger;
8432
+ }
8433
+ AsyncMemoryStorage.prototype.handleDatabaseAccessError = function (error) {
8434
+ if (error instanceof BrowserAuthError && error.errorCode === BrowserAuthErrorMessage.databaseUnavailable.code) {
8435
+ this.logger.error("Could not access persistent storage. This may be caused by browser privacy features which block persistent storage in third-party contexts.");
8436
+ }
8437
+ };
8438
+ /**
8439
+ * Get the item matching the given key. Tries in-memory cache first, then in the asynchronous
8440
+ * storage object if item isn't found in-memory.
8441
+ * @param key
8442
+ */
8443
+ AsyncMemoryStorage.prototype.getItem = function (key) {
8444
+ return __awaiter$1(this, void 0, void 0, function () {
8445
+ var item, e_1;
8446
+ return __generator$1(this, function (_a) {
8447
+ switch (_a.label) {
8448
+ case 0:
8449
+ item = this.inMemoryCache.getItem(key);
8450
+ if (!!item) return [3 /*break*/, 4];
8451
+ _a.label = 1;
8452
+ case 1:
8453
+ _a.trys.push([1, 3, , 4]);
8454
+ this.logger.verbose("Queried item not found in in-memory cache, now querying persistent storage.");
8455
+ return [4 /*yield*/, this.indexedDBCache.getItem(key)];
8456
+ case 2: return [2 /*return*/, _a.sent()];
8457
+ case 3:
8458
+ e_1 = _a.sent();
8459
+ this.handleDatabaseAccessError(e_1);
8460
+ return [3 /*break*/, 4];
8461
+ case 4: return [2 /*return*/, item];
8462
+ }
8463
+ });
8464
+ });
8465
+ };
8466
+ /**
8467
+ * Sets the item in the in-memory cache and then tries to set it in the asynchronous
8468
+ * storage object with the given key.
8469
+ * @param key
8470
+ * @param value
8471
+ */
8472
+ AsyncMemoryStorage.prototype.setItem = function (key, value) {
8473
+ return __awaiter$1(this, void 0, void 0, function () {
8474
+ var e_2;
8475
+ return __generator$1(this, function (_a) {
8476
+ switch (_a.label) {
8477
+ case 0:
8478
+ this.inMemoryCache.setItem(key, value);
8479
+ _a.label = 1;
8480
+ case 1:
8481
+ _a.trys.push([1, 3, , 4]);
8482
+ return [4 /*yield*/, this.indexedDBCache.setItem(key, value)];
8483
+ case 2:
8484
+ _a.sent();
8485
+ return [3 /*break*/, 4];
8486
+ case 3:
8487
+ e_2 = _a.sent();
8488
+ this.handleDatabaseAccessError(e_2);
8489
+ return [3 /*break*/, 4];
8490
+ case 4: return [2 /*return*/];
8491
+ }
8492
+ });
8493
+ });
8494
+ };
8495
+ /**
8496
+ * Removes the item matching the key from the in-memory cache, then tries to remove it from the asynchronous storage object.
8497
+ * @param key
8498
+ */
8499
+ AsyncMemoryStorage.prototype.removeItem = function (key) {
8500
+ return __awaiter$1(this, void 0, void 0, function () {
8501
+ var e_3;
8502
+ return __generator$1(this, function (_a) {
8503
+ switch (_a.label) {
8504
+ case 0:
8505
+ this.inMemoryCache.removeItem(key);
8506
+ _a.label = 1;
8507
+ case 1:
8508
+ _a.trys.push([1, 3, , 4]);
8509
+ return [4 /*yield*/, this.indexedDBCache.removeItem(key)];
8510
+ case 2:
8511
+ _a.sent();
8512
+ return [3 /*break*/, 4];
8513
+ case 3:
8514
+ e_3 = _a.sent();
8515
+ this.handleDatabaseAccessError(e_3);
8516
+ return [3 /*break*/, 4];
8517
+ case 4: return [2 /*return*/];
8518
+ }
8519
+ });
8520
+ });
8521
+ };
8522
+ /**
8523
+ * 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
8524
+ * asynchronous storage object.
8525
+ */
8526
+ AsyncMemoryStorage.prototype.getKeys = function () {
8527
+ return __awaiter$1(this, void 0, void 0, function () {
8528
+ var cacheKeys, e_4;
8529
+ return __generator$1(this, function (_a) {
8530
+ switch (_a.label) {
8531
+ case 0:
8532
+ cacheKeys = this.inMemoryCache.getKeys();
8533
+ if (!(cacheKeys.length === 0)) return [3 /*break*/, 4];
8534
+ _a.label = 1;
8535
+ case 1:
8536
+ _a.trys.push([1, 3, , 4]);
8537
+ this.logger.verbose("In-memory cache is empty, now querying persistent storage.");
8538
+ return [4 /*yield*/, this.indexedDBCache.getKeys()];
8539
+ case 2: return [2 /*return*/, _a.sent()];
8540
+ case 3:
8541
+ e_4 = _a.sent();
8542
+ this.handleDatabaseAccessError(e_4);
8543
+ return [3 /*break*/, 4];
8544
+ case 4: return [2 /*return*/, cacheKeys];
8545
+ }
8546
+ });
8547
+ });
8548
+ };
8549
+ /**
8550
+ * Returns true or false if the given key is present in the cache.
8551
+ * @param key
8552
+ */
8553
+ AsyncMemoryStorage.prototype.containsKey = function (key) {
8554
+ return __awaiter$1(this, void 0, void 0, function () {
8555
+ var containsKey, e_5;
8556
+ return __generator$1(this, function (_a) {
8557
+ switch (_a.label) {
8558
+ case 0:
8559
+ containsKey = this.inMemoryCache.containsKey(key);
8560
+ if (!!containsKey) return [3 /*break*/, 4];
8561
+ _a.label = 1;
8562
+ case 1:
8563
+ _a.trys.push([1, 3, , 4]);
8564
+ this.logger.verbose("Key not found in in-memory cache, now querying persistent storage.");
8565
+ return [4 /*yield*/, this.indexedDBCache.containsKey(key)];
8566
+ case 2: return [2 /*return*/, _a.sent()];
8567
+ case 3:
8568
+ e_5 = _a.sent();
8569
+ this.handleDatabaseAccessError(e_5);
8570
+ return [3 /*break*/, 4];
8571
+ case 4: return [2 /*return*/, containsKey];
8572
+ }
8573
+ });
8574
+ });
8575
+ };
8576
+ /**
8577
+ * Clears in-memory Map and tries to delete the IndexedDB database.
8578
+ */
8579
+ AsyncMemoryStorage.prototype.clear = function () {
8580
+ return __awaiter$1(this, void 0, void 0, function () {
8581
+ var e_6;
8582
+ return __generator$1(this, function (_a) {
8583
+ switch (_a.label) {
8584
+ case 0:
8585
+ this.inMemoryCache.clear();
8586
+ _a.label = 1;
8587
+ case 1:
8588
+ _a.trys.push([1, 3, , 4]);
8589
+ return [4 /*yield*/, this.indexedDBCache.deleteDatabase()];
8590
+ case 2:
8591
+ _a.sent();
8592
+ return [3 /*break*/, 4];
8593
+ case 3:
8594
+ e_6 = _a.sent();
8595
+ this.handleDatabaseAccessError(e_6);
8596
+ return [3 /*break*/, 4];
8597
+ case 4: return [2 /*return*/];
8598
+ }
8599
+ });
8600
+ });
8601
+ };
8602
+ return AsyncMemoryStorage;
8603
+ }());
8604
+
8141
8605
  /*
8142
8606
  * Copyright (c) Microsoft Corporation. All rights reserved.
8143
8607
  * Licensed under the MIT License.
@@ -8147,14 +8611,18 @@
8147
8611
  * implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
8148
8612
  */
8149
8613
  var CryptoOps = /** @class */ (function () {
8150
- function CryptoOps() {
8614
+ function CryptoOps(logger) {
8615
+ this.logger = logger;
8151
8616
  // Browser crypto needs to be validated first before any other classes can be set.
8152
- this.browserCrypto = new BrowserCrypto();
8617
+ this.browserCrypto = new BrowserCrypto(this.logger);
8153
8618
  this.b64Encode = new Base64Encode();
8154
8619
  this.b64Decode = new Base64Decode();
8155
8620
  this.guidGenerator = new GuidGenerator(this.browserCrypto);
8156
8621
  this.pkceGenerator = new PkceGenerator(this.browserCrypto);
8157
- this.cache = new DatabaseStorage(CryptoOps.DB_NAME, CryptoOps.TABLE_NAME, CryptoOps.DB_VERSION);
8622
+ this.cache = {
8623
+ asymmetricKeys: new AsyncMemoryStorage(this.logger),
8624
+ symmetricKeys: new AsyncMemoryStorage(this.logger)
8625
+ };
8158
8626
  }
8159
8627
  /**
8160
8628
  * Creates a new random GUID - used to populate state and nonce.
@@ -8219,7 +8687,7 @@
8219
8687
  case 5:
8220
8688
  unextractablePrivateKey = _a.sent();
8221
8689
  // Store Keypair data in keystore
8222
- return [4 /*yield*/, this.cache.put(publicJwkHash, {
8690
+ return [4 /*yield*/, this.cache.asymmetricKeys.setItem(publicJwkHash, {
8223
8691
  privateKey: unextractablePrivateKey,
8224
8692
  publicKey: keyPair.publicKey,
8225
8693
  requestMethod: request.resourceRequestMethod,
@@ -8239,8 +8707,17 @@
8239
8707
  */
8240
8708
  CryptoOps.prototype.removeTokenBindingKey = function (kid) {
8241
8709
  return __awaiter$1(this, void 0, void 0, function () {
8710
+ var keyFound;
8242
8711
  return __generator$1(this, function (_a) {
8243
- return [2 /*return*/, this.cache.delete(kid)];
8712
+ switch (_a.label) {
8713
+ case 0: return [4 /*yield*/, this.cache.asymmetricKeys.removeItem(kid)];
8714
+ case 1:
8715
+ _a.sent();
8716
+ return [4 /*yield*/, this.cache.asymmetricKeys.containsKey(kid)];
8717
+ case 2:
8718
+ keyFound = _a.sent();
8719
+ return [2 /*return*/, !keyFound];
8720
+ }
8244
8721
  });
8245
8722
  });
8246
8723
  };
@@ -8249,8 +8726,22 @@
8249
8726
  */
8250
8727
  CryptoOps.prototype.clearKeystore = function () {
8251
8728
  return __awaiter$1(this, void 0, void 0, function () {
8252
- return __generator$1(this, function (_a) {
8253
- return [2 /*return*/, this.cache.clear()];
8729
+ var dataStoreNames, databaseStorage, _a;
8730
+ return __generator$1(this, function (_b) {
8731
+ switch (_b.label) {
8732
+ case 0:
8733
+ dataStoreNames = Object.keys(this.cache);
8734
+ databaseStorage = this.cache[dataStoreNames[0]];
8735
+ if (!databaseStorage) return [3 /*break*/, 2];
8736
+ return [4 /*yield*/, databaseStorage.deleteDatabase()];
8737
+ case 1:
8738
+ _a = _b.sent();
8739
+ return [3 /*break*/, 3];
8740
+ case 2:
8741
+ _a = false;
8742
+ _b.label = 3;
8743
+ case 3: return [2 /*return*/, _a];
8744
+ }
8254
8745
  });
8255
8746
  });
8256
8747
  };
@@ -8264,7 +8755,7 @@
8264
8755
  var cachedKeyPair, publicKeyJwk, publicKeyJwkString, header, encodedHeader, encodedPayload, tokenString, tokenBuffer, signatureBuffer, encodedSignature;
8265
8756
  return __generator$1(this, function (_a) {
8266
8757
  switch (_a.label) {
8267
- case 0: return [4 /*yield*/, this.cache.get(kid)];
8758
+ case 0: return [4 /*yield*/, this.cache.asymmetricKeys.getItem(kid)];
8268
8759
  case 1:
8269
8760
  cachedKeyPair = _a.sent();
8270
8761
  if (!cachedKeyPair) {
@@ -8297,9 +8788,6 @@
8297
8788
  };
8298
8789
  CryptoOps.POP_KEY_USAGES = ["sign", "verify"];
8299
8790
  CryptoOps.EXTRACTABLE = true;
8300
- CryptoOps.DB_VERSION = 1;
8301
- CryptoOps.DB_NAME = "msal.db";
8302
- CryptoOps.TABLE_NAME = CryptoOps.DB_NAME + ".keys";
8303
8791
  return CryptoOps;
8304
8792
  }());
8305
8793
 
@@ -8429,39 +8917,6 @@
8429
8917
  return BrowserStorage;
8430
8918
  }());
8431
8919
 
8432
- /*
8433
- * Copyright (c) Microsoft Corporation. All rights reserved.
8434
- * Licensed under the MIT License.
8435
- */
8436
- var MemoryStorage = /** @class */ (function () {
8437
- function MemoryStorage() {
8438
- this.cache = new Map();
8439
- }
8440
- MemoryStorage.prototype.getItem = function (key) {
8441
- return this.cache.get(key) || null;
8442
- };
8443
- MemoryStorage.prototype.setItem = function (key, value) {
8444
- this.cache.set(key, value);
8445
- };
8446
- MemoryStorage.prototype.removeItem = function (key) {
8447
- this.cache.delete(key);
8448
- };
8449
- MemoryStorage.prototype.getKeys = function () {
8450
- var cacheKeys = [];
8451
- this.cache.forEach(function (value, key) {
8452
- cacheKeys.push(key);
8453
- });
8454
- return cacheKeys;
8455
- };
8456
- MemoryStorage.prototype.containsKey = function (key) {
8457
- return this.cache.has(key);
8458
- };
8459
- MemoryStorage.prototype.clear = function () {
8460
- this.cache.clear();
8461
- };
8462
- return MemoryStorage;
8463
- }());
8464
-
8465
8920
  /*
8466
8921
  * Copyright (c) Microsoft Corporation. All rights reserved.
8467
8922
  * Licensed under the MIT License.
@@ -9842,7 +10297,7 @@
9842
10297
 
9843
10298
  /* eslint-disable header/header */
9844
10299
  var name = "@azure/msal-browser";
9845
- var version = "2.18.0";
10300
+ var version = "2.19.0";
9846
10301
 
9847
10302
  /*
9848
10303
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10065,6 +10520,14 @@
10065
10520
  this.logger.verbose("Authentication Scheme wasn't explicitly set in request, defaulting to \"Bearer\" request");
10066
10521
  }
10067
10522
  else {
10523
+ if (request.authenticationScheme === exports.AuthenticationScheme.SSH) {
10524
+ if (!request.sshJwk) {
10525
+ throw ClientConfigurationError.createMissingSshJwkError();
10526
+ }
10527
+ if (!request.sshKid) {
10528
+ throw ClientConfigurationError.createMissingSshKidError();
10529
+ }
10530
+ }
10068
10531
  this.logger.verbose("Authentication Scheme set to \"" + request.authenticationScheme + "\" as configured in Auth request");
10069
10532
  }
10070
10533
  var validatedRequest = __assign$1(__assign$1({}, request), { correlationId: this.correlationId, authority: authority,
@@ -11151,7 +11614,7 @@
11151
11614
  this.logger.verbose("NavigateToLoginRequestUrl set to false, handling hash");
11152
11615
  return [2 /*return*/, this.handleHash(responseHash, state, serverTelemetryManager)];
11153
11616
  case 4:
11154
- if (!!BrowserUtils.isInIframe()) return [3 /*break*/, 9];
11617
+ if (!(!BrowserUtils.isInIframe() || this.config.system.allowRedirectInIframe)) return [3 /*break*/, 9];
11155
11618
  /*
11156
11619
  * Returned from authority using redirect - need to perform navigation before processing response
11157
11620
  * Cache the hash to be retrieved after the next redirect
@@ -11798,7 +12261,7 @@
11798
12261
  // Initialize redirectResponse Map
11799
12262
  this.redirectResponse = new Map();
11800
12263
  // Initialize the crypto class.
11801
- this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps() : DEFAULT_CRYPTO_IMPLEMENTATION;
12264
+ this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger) : DEFAULT_CRYPTO_IMPLEMENTATION;
11802
12265
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
11803
12266
  // Initialize the browser storage class.
11804
12267
  this.browserStorage = this.isBrowserEnvironment ?
@@ -12027,7 +12490,7 @@
12027
12490
  var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
12028
12491
  if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
12029
12492
  _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
12030
- var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode);
12493
+ var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, exports.ApiId.acquireTokenSilent_authCode, request.correlationId);
12031
12494
  return silentIframeClient.acquireToken(request);
12032
12495
  }
12033
12496
  throw e;
@@ -12247,6 +12710,12 @@
12247
12710
  ClientApplication.prototype.setNavigationClient = function (navigationClient) {
12248
12711
  this.navigationClient = navigationClient;
12249
12712
  };
12713
+ /**
12714
+ * Returns the configuration object
12715
+ */
12716
+ ClientApplication.prototype.getConfiguration = function () {
12717
+ return this.config;
12718
+ };
12250
12719
  return ClientApplication;
12251
12720
  }());
12252
12721
 
@@ -12413,7 +12882,9 @@
12413
12882
  authenticationScheme: request.authenticationScheme,
12414
12883
  resourceRequestMethod: request.resourceRequestMethod,
12415
12884
  resourceRequestUri: request.resourceRequestUri,
12416
- shrClaims: request.shrClaims
12885
+ shrClaims: request.shrClaims,
12886
+ sshJwk: request.sshJwk,
12887
+ sshKid: request.sshKid
12417
12888
  };
12418
12889
  silentRequestKey = JSON.stringify(thumbprint);
12419
12890
  cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
@@ -12449,7 +12920,7 @@
12449
12920
  var silentCacheClient, silentRequest;
12450
12921
  var _this = this;
12451
12922
  return __generator$1(this, function (_a) {
12452
- silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient);
12923
+ silentCacheClient = new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
12453
12924
  silentRequest = silentCacheClient.initializeSilentRequest(request, account);
12454
12925
  this.eventHandler.emitEvent(exports.EventType.ACQUIRE_TOKEN_START, exports.InteractionType.Silent, request);
12455
12926
  return [2 /*return*/, silentCacheClient.acquireToken(silentRequest).catch(function () { return __awaiter$1(_this, void 0, void 0, function () {
@@ -12556,6 +13027,9 @@
12556
13027
  },
12557
13028
  setNavigationClient: function () {
12558
13029
  return;
13030
+ },
13031
+ getConfiguration: function () {
13032
+ throw BrowserConfigurationAuthError.createStubPcaInstanceCalledError();
12559
13033
  }
12560
13034
  };
12561
13035
 
@@ -12628,8 +13102,10 @@
12628
13102
  * Licensed under the MIT License.
12629
13103
  */
12630
13104
  var SignedHttpRequest = /** @class */ (function () {
12631
- function SignedHttpRequest(shrParameters) {
12632
- this.cryptoOps = new CryptoOps();
13105
+ function SignedHttpRequest(shrParameters, shrOptions) {
13106
+ var loggerOptions = (shrOptions && shrOptions.loggerOptions) || {};
13107
+ this.logger = new Logger(loggerOptions, name, version);
13108
+ this.cryptoOps = new CryptoOps(this.logger);
12633
13109
  this.popTokenGenerator = new PopTokenGenerator(this.cryptoOps);
12634
13110
  this.shrParameters = shrParameters;
12635
13111
  }
@@ -12672,7 +13148,10 @@
12672
13148
  SignedHttpRequest.prototype.removeKeys = function (publicKeyThumbprint) {
12673
13149
  return __awaiter$1(this, void 0, void 0, function () {
12674
13150
  return __generator$1(this, function (_a) {
12675
- return [2 /*return*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
13151
+ switch (_a.label) {
13152
+ case 0: return [4 /*yield*/, this.cryptoOps.removeTokenBindingKey(publicKeyThumbprint)];
13153
+ case 1: return [2 /*return*/, _a.sent()];
13154
+ }
12676
13155
  });
12677
13156
  });
12678
13157
  };
@@ -12682,6 +13161,7 @@
12682
13161
  exports.AccountEntity = AccountEntity;
12683
13162
  exports.AuthError = AuthError;
12684
13163
  exports.AuthErrorMessage = AuthErrorMessage;
13164
+ exports.AuthenticationHeaderParser = AuthenticationHeaderParser;
12685
13165
  exports.BrowserAuthError = BrowserAuthError;
12686
13166
  exports.BrowserAuthErrorMessage = BrowserAuthErrorMessage;
12687
13167
  exports.BrowserConfigurationAuthError = BrowserConfigurationAuthError;