@azure/msal-node 7.1.2 → 7.2.1

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 (63) hide show
  1. package/dist/cache/CacheHelpers.mjs +1 -1
  2. package/dist/cache/NodeStorage.mjs +1 -1
  3. package/dist/cache/TokenCache.mjs +1 -1
  4. package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
  5. package/dist/cache/serializer/Deserializer.mjs +1 -1
  6. package/dist/cache/serializer/Serializer.mjs +1 -1
  7. package/dist/client/BaseClient.mjs +1 -1
  8. package/dist/client/ClientApplication.mjs +1 -1
  9. package/dist/client/ClientAssertion.mjs +1 -1
  10. package/dist/client/ClientCredentialClient.mjs +1 -1
  11. package/dist/client/ConfidentialClientApplication.mjs +1 -1
  12. package/dist/client/DeviceCodeClient.mjs +1 -1
  13. package/dist/client/ManagedIdentityApplication.mjs +1 -1
  14. package/dist/client/ManagedIdentityClient.mjs +1 -1
  15. package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
  16. package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
  17. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +1 -1
  18. package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
  19. package/dist/client/ManagedIdentitySources/Imds.mjs +1 -1
  20. package/dist/client/ManagedIdentitySources/MachineLearning.mjs +1 -1
  21. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +1 -1
  22. package/dist/client/OnBehalfOfClient.mjs +1 -1
  23. package/dist/client/PublicClientApplication.mjs +9 -3
  24. package/dist/client/PublicClientApplication.mjs.map +1 -1
  25. package/dist/client/SilentRequestCoalescer.mjs +1 -1
  26. package/dist/client/UserFederatedIdentityCredentialClient.mjs +1 -1
  27. package/dist/client/UsernamePasswordClient.mjs +1 -1
  28. package/dist/config/Configuration.mjs +1 -1
  29. package/dist/config/ManagedIdentityId.mjs +1 -1
  30. package/dist/config/ManagedIdentityRequestParameters.mjs +1 -1
  31. package/dist/crypto/CryptoProvider.mjs +1 -1
  32. package/dist/crypto/GuidGenerator.mjs +1 -1
  33. package/dist/crypto/HashUtils.mjs +1 -1
  34. package/dist/crypto/PkceGenerator.mjs +1 -1
  35. package/dist/error/ClientAuthErrorCodes.mjs +1 -1
  36. package/dist/error/ManagedIdentityError.mjs +1 -1
  37. package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
  38. package/dist/error/NodeAuthError.mjs +1 -1
  39. package/dist/index.mjs +1 -1
  40. package/dist/internals.mjs +1 -1
  41. package/dist/network/HttpClient.mjs +1 -1
  42. package/dist/network/HttpClientWithRetries.mjs +1 -1
  43. package/dist/network/LoopbackClient.mjs +26 -4
  44. package/dist/network/LoopbackClient.mjs.map +1 -1
  45. package/dist/packageMetadata.mjs +2 -2
  46. package/dist/protocol/Authorize.mjs +1 -1
  47. package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +1 -1
  48. package/dist/retry/ExponentialRetryStrategy.mjs +1 -1
  49. package/dist/retry/ImdsRetryPolicy.mjs +1 -1
  50. package/dist/retry/LinearRetryStrategy.mjs +1 -1
  51. package/dist/utils/Constants.mjs +1 -1
  52. package/dist/utils/EncodingUtils.mjs +1 -1
  53. package/dist/utils/TimeUtils.mjs +1 -1
  54. package/lib/msal-node.cjs +205 -92
  55. package/lib/msal-node.cjs.map +1 -1
  56. package/package.json +2 -2
  57. package/src/client/PublicClientApplication.ts +18 -1
  58. package/src/network/LoopbackClient.ts +38 -0
  59. package/src/packageMetadata.ts +1 -1
  60. package/types/client/PublicClientApplication.d.ts.map +1 -1
  61. package/types/network/LoopbackClient.d.ts +6 -1
  62. package/types/network/LoopbackClient.d.ts.map +1 -1
  63. package/types/packageMetadata.d.ts +1 -1
package/lib/msal-node.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v7.1.2 2026-10-27 */
1
+ /*! @azure/msal-node v7.2.1 2026-11-06 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -151,7 +151,7 @@ class Serializer {
151
151
  }
152
152
  }
153
153
 
154
- /*! @azure/msal-common v16.15.0 2026-10-27 */
154
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
155
155
  /*
156
156
  * Copyright (c) Microsoft Corporation. All rights reserved.
157
157
  * Licensed under the MIT License.
@@ -215,7 +215,7 @@ const ATTRIBUTE_TOKENS = "attribute_tokens";
215
215
  */
216
216
  const POPUP_ORIGIN_CHECK_DONE = "pocd";
217
217
 
218
- /*! @azure/msal-common v16.15.0 2026-10-27 */
218
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
219
219
  /*
220
220
  * Copyright (c) Microsoft Corporation. All rights reserved.
221
221
  * Licensed under the MIT License.
@@ -473,7 +473,7 @@ const EncodingTypes = {
473
473
  UTF8: "utf-8",
474
474
  };
475
475
 
476
- /*! @azure/msal-common v16.15.0 2026-10-27 */
476
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
477
477
  /*
478
478
  * Copyright (c) Microsoft Corporation. All rights reserved.
479
479
  * Licensed under the MIT License.
@@ -502,7 +502,7 @@ function createAuthError(code, correlationId, additionalMessage) {
502
502
  return new AuthError(code, correlationId, additionalMessage || getDefaultErrorMessage(code));
503
503
  }
504
504
 
505
- /*! @azure/msal-common v16.15.0 2026-10-27 */
505
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
506
506
 
507
507
  /*
508
508
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -525,7 +525,7 @@ function createClientAuthError(errorCode, correlationId, additionalMessage) {
525
525
  return new ClientAuthError(errorCode, correlationId, additionalMessage);
526
526
  }
527
527
 
528
- /*! @azure/msal-common v16.15.0 2026-10-27 */
528
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
529
529
  /*
530
530
  * Copyright (c) Microsoft Corporation. All rights reserved.
531
531
  * Licensed under the MIT License.
@@ -611,7 +611,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
611
611
  userCanceled: userCanceled
612
612
  });
613
613
 
614
- /*! @azure/msal-common v16.15.0 2026-10-27 */
614
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
615
615
 
616
616
  /*
617
617
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -649,7 +649,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
649
649
  };
650
650
  }
651
651
 
652
- /*! @azure/msal-common v16.15.0 2026-10-27 */
652
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
653
653
 
654
654
  /*
655
655
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -715,7 +715,7 @@ function getJWSPayload(authToken, correlationId) {
715
715
  return matches[2];
716
716
  }
717
717
 
718
- /*! @azure/msal-common v16.15.0 2026-10-27 */
718
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
719
719
 
720
720
  /*
721
721
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -803,7 +803,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
803
803
  return updatedAccountInfo;
804
804
  }
805
805
 
806
- /*! @azure/msal-common v16.15.0 2026-10-27 */
806
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
807
807
  /*
808
808
  * Copyright (c) Microsoft Corporation. All rights reserved.
809
809
  * Licensed under the MIT License.
@@ -817,7 +817,7 @@ const AuthorityType = {
817
817
  Ciam: 3,
818
818
  };
819
819
 
820
- /*! @azure/msal-common v16.15.0 2026-10-27 */
820
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
821
821
  /*
822
822
  * Copyright (c) Microsoft Corporation. All rights reserved.
823
823
  * Licensed under the MIT License.
@@ -839,7 +839,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
839
839
  return null;
840
840
  }
841
841
 
842
- /*! @azure/msal-common v16.15.0 2026-10-27 */
842
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
843
843
  /*
844
844
  * Copyright (c) Microsoft Corporation. All rights reserved.
845
845
  * Licensed under the MIT License.
@@ -863,7 +863,7 @@ const ProtocolMode = {
863
863
  EAR: "EAR",
864
864
  };
865
865
 
866
- /*! @azure/msal-common v16.15.0 2026-10-27 */
866
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
867
867
  /**
868
868
  * Returns the AccountInfo interface for this account.
869
869
  * @internal
@@ -1012,7 +1012,7 @@ function isAccountEntity(entity) {
1012
1012
  entity.hasOwnProperty("authorityType"));
1013
1013
  }
1014
1014
 
1015
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1015
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1016
1016
  /*
1017
1017
  * Copyright (c) Microsoft Corporation. All rights reserved.
1018
1018
  * Licensed under the MIT License.
@@ -1029,7 +1029,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
1029
1029
  unexpectedError: unexpectedError
1030
1030
  });
1031
1031
 
1032
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1032
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1033
1033
 
1034
1034
  /*
1035
1035
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1049,7 +1049,7 @@ function createClientConfigurationError(errorCode, correlationId) {
1049
1049
  return new ClientConfigurationError(errorCode, correlationId);
1050
1050
  }
1051
1051
 
1052
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1052
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1053
1053
  /*
1054
1054
  * Copyright (c) Microsoft Corporation. All rights reserved.
1055
1055
  * Licensed under the MIT License.
@@ -1089,7 +1089,7 @@ function getResponseHeader(headers, name) {
1089
1089
  return headerName === undefined ? undefined : headers[headerName];
1090
1090
  }
1091
1091
 
1092
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1092
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1093
1093
  /*
1094
1094
  * Copyright (c) Microsoft Corporation. All rights reserved.
1095
1095
  * Licensed under the MIT License.
@@ -1159,7 +1159,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1159
1159
  urlParseError: urlParseError
1160
1160
  });
1161
1161
 
1162
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1162
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1163
1163
  /*
1164
1164
  * Copyright (c) Microsoft Corporation. All rights reserved.
1165
1165
  * Licensed under the MIT License.
@@ -1171,7 +1171,7 @@ function isOpenIdConfigResponse(response) {
1171
1171
  response.hasOwnProperty("jwks_uri"));
1172
1172
  }
1173
1173
 
1174
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1174
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1175
1175
  /*
1176
1176
  * Copyright (c) Microsoft Corporation. All rights reserved.
1177
1177
  * Licensed under the MIT License.
@@ -1251,7 +1251,7 @@ class StringUtils {
1251
1251
  }
1252
1252
  }
1253
1253
 
1254
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1254
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1255
1255
 
1256
1256
  /*
1257
1257
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1409,7 +1409,7 @@ class UrlString {
1409
1409
  }
1410
1410
  }
1411
1411
 
1412
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1412
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1413
1413
 
1414
1414
  /*
1415
1415
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1563,7 +1563,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
1563
1563
  return null;
1564
1564
  }
1565
1565
 
1566
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1566
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1567
1567
  /*
1568
1568
  * Copyright (c) Microsoft Corporation. All rights reserved.
1569
1569
  * Licensed under the MIT License.
@@ -1581,7 +1581,7 @@ const AzureCloudInstance = {
1581
1581
  AzureUsGovernment: "https://login.microsoftonline.us",
1582
1582
  };
1583
1583
 
1584
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1584
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1585
1585
  /*
1586
1586
  * Copyright (c) Microsoft Corporation. All rights reserved.
1587
1587
  * Licensed under the MIT License.
@@ -1591,7 +1591,7 @@ function isCloudInstanceDiscoveryResponse(response) {
1591
1591
  response.hasOwnProperty("metadata"));
1592
1592
  }
1593
1593
 
1594
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1594
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1595
1595
  /*
1596
1596
  * Copyright (c) Microsoft Corporation. All rights reserved.
1597
1597
  * Licensed under the MIT License.
@@ -1601,7 +1601,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
1601
1601
  response.hasOwnProperty("error_description"));
1602
1602
  }
1603
1603
 
1604
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1604
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1605
1605
  /*
1606
1606
  * Copyright (c) Microsoft Corporation. All rights reserved.
1607
1607
  * Licensed under the MIT License.
@@ -1663,7 +1663,7 @@ const RegionDiscoveryGetCurrentVersion = "regionDiscoveryGetCurrentVersion";
1663
1663
  */
1664
1664
  const CacheManagerGetRefreshToken = "cacheManagerGetRefreshToken";
1665
1665
 
1666
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1666
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1667
1667
  /*
1668
1668
  * Copyright (c) Microsoft Corporation. All rights reserved.
1669
1669
  * Licensed under the MIT License.
@@ -1756,7 +1756,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
1756
1756
  };
1757
1757
  };
1758
1758
 
1759
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1759
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1760
1760
 
1761
1761
  /*
1762
1762
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1867,7 +1867,7 @@ RegionDiscovery.IMDS_OPTIONS = {
1867
1867
  },
1868
1868
  };
1869
1869
 
1870
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1870
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1871
1871
  /*
1872
1872
  * Copyright (c) Microsoft Corporation. All rights reserved.
1873
1873
  * Licensed under the MIT License.
@@ -1922,7 +1922,7 @@ function delay(t, value) {
1922
1922
  return new Promise((resolve) => setTimeout(() => resolve(value), t));
1923
1923
  }
1924
1924
 
1925
- /*! @azure/msal-common v16.15.0 2026-10-27 */
1925
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
1926
1926
 
1927
1927
  /*
1928
1928
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2209,7 +2209,7 @@ function serializeAttributeTokens(attributeTokens) {
2209
2209
  return [...attributeTokens].sort().join(" ");
2210
2210
  }
2211
2211
 
2212
- /*! @azure/msal-common v16.15.0 2026-10-27 */
2212
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
2213
2213
 
2214
2214
  /*
2215
2215
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3177,7 +3177,7 @@ function buildStaticAuthorityOptions(authOptions) {
3177
3177
  };
3178
3178
  }
3179
3179
 
3180
- /*! @azure/msal-common v16.15.0 2026-10-27 */
3180
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
3181
3181
 
3182
3182
  /*
3183
3183
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3211,7 +3211,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
3211
3211
  }
3212
3212
  }
3213
3213
 
3214
- /*! @azure/msal-common v16.15.0 2026-10-27 */
3214
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
3215
3215
 
3216
3216
  /*
3217
3217
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3407,7 +3407,7 @@ class ScopeSet {
3407
3407
  }
3408
3408
  }
3409
3409
 
3410
- /*! @azure/msal-common v16.15.0 2026-10-27 */
3410
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
3411
3411
 
3412
3412
  /*
3413
3413
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3925,7 +3925,7 @@ function addAttributeTokens(parameters, attributeTokens) {
3925
3925
  }
3926
3926
  }
3927
3927
 
3928
- /*! @azure/msal-common v16.15.0 2026-10-27 */
3928
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
3929
3929
 
3930
3930
  /*
3931
3931
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3992,7 +3992,7 @@ function mapToQueryString(parameters) {
3992
3992
  return queryParameterArray.join("&");
3993
3993
  }
3994
3994
 
3995
- /*! @azure/msal-common v16.15.0 2026-10-27 */
3995
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
3996
3996
 
3997
3997
  /*
3998
3998
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4040,7 +4040,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
4040
4040
  },
4041
4041
  };
4042
4042
 
4043
- /*! @azure/msal-common v16.15.0 2026-10-27 */
4043
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
4044
4044
 
4045
4045
  /*
4046
4046
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4063,7 +4063,7 @@ const DEFAULT_TOKEN_BINDING_KEY_MANAGER = {
4063
4063
  },
4064
4064
  };
4065
4065
 
4066
- /*! @azure/msal-common v16.15.0 2026-10-27 */
4066
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
4067
4067
  /*
4068
4068
  * Copyright (c) Microsoft Corporation. All rights reserved.
4069
4069
  * Licensed under the MIT License.
@@ -4338,12 +4338,12 @@ class Logger {
4338
4338
  }
4339
4339
  }
4340
4340
 
4341
- /*! @azure/msal-common v16.15.0 2026-10-27 */
4341
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
4342
4342
  /* eslint-disable header/header */
4343
4343
  const name$1 = "@azure/msal-common";
4344
- const version$1 = "16.15.0";
4344
+ const version$1 = "16.16.1";
4345
4345
 
4346
- /*! @azure/msal-common v16.15.0 2026-10-27 */
4346
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
4347
4347
  /*
4348
4348
  * Copyright (c) Microsoft Corporation. All rights reserved.
4349
4349
  * Licensed under the MIT License.
@@ -4351,7 +4351,7 @@ const version$1 = "16.15.0";
4351
4351
  const cacheQuotaExceeded = "cache_quota_exceeded";
4352
4352
  const cacheErrorUnknown = "cache_error_unknown";
4353
4353
 
4354
- /*! @azure/msal-common v16.15.0 2026-10-27 */
4354
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
4355
4355
 
4356
4356
  /*
4357
4357
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4389,7 +4389,7 @@ function createCacheError(e) {
4389
4389
  }
4390
4390
  }
4391
4391
 
4392
- /*! @azure/msal-common v16.15.0 2026-10-27 */
4392
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
4393
4393
 
4394
4394
  /*
4395
4395
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4638,6 +4638,7 @@ class CacheManager {
4638
4638
  };
4639
4639
  const tokenKeys = this.getTokenKeys();
4640
4640
  const currentScopes = ScopeSet.fromString(credential.target, correlationId);
4641
+ const accessTokenKeysToRemove = [];
4641
4642
  tokenKeys.accessToken.forEach((key) => {
4642
4643
  if (!this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
4643
4644
  return;
@@ -4647,10 +4648,13 @@ class CacheManager {
4647
4648
  this.credentialMatchesFilter(tokenEntity, accessTokenFilter, correlationId)) {
4648
4649
  const tokenScopeSet = ScopeSet.fromString(tokenEntity.target, correlationId);
4649
4650
  if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
4650
- this.removeAccessToken(key, correlationId);
4651
+ accessTokenKeysToRemove.push(key);
4651
4652
  }
4652
4653
  }
4653
4654
  });
4655
+ for (const key of accessTokenKeysToRemove) {
4656
+ await this.removeAccessTokenAndTokenBindingKey(key, correlationId, credential.keyId);
4657
+ }
4654
4658
  await this.setAccessTokenCredential(credential, correlationId, kmsi, additionalCacheKeyHash);
4655
4659
  }
4656
4660
  /**
@@ -4849,19 +4853,25 @@ class CacheManager {
4849
4853
  * @param account
4850
4854
  */
4851
4855
  removeAccount(account, correlationId) {
4852
- this.removeAccountContext(account, correlationId);
4853
4856
  const accountKeys = this.getAccountKeys();
4854
4857
  const keyFilter = (key) => {
4855
4858
  return (key.includes(account.homeAccountId) &&
4856
4859
  key.includes(account.environment));
4857
4860
  };
4861
+ this.getTokenKeys()
4862
+ .idToken.filter(keyFilter)
4863
+ .forEach((key) => {
4864
+ this.removeIdToken(key, correlationId);
4865
+ });
4866
+ this.removeAccountContext(account, correlationId);
4858
4867
  accountKeys.filter(keyFilter).forEach((key) => {
4859
4868
  this.removeItem(key, correlationId);
4860
4869
  this.performanceClient.incrementFields({ accountsRemoved: 1 }, correlationId);
4861
4870
  });
4862
4871
  }
4863
4872
  /**
4864
- * Removes credentials associated with the provided account
4873
+ * Removes access and refresh tokens associated with the provided account,
4874
+ * preserving the account and its ID tokens.
4865
4875
  * @param account
4866
4876
  */
4867
4877
  removeAccountContext(account, correlationId) {
@@ -4870,9 +4880,6 @@ class CacheManager {
4870
4880
  return (key.includes(account.homeAccountId) &&
4871
4881
  key.includes(account.environment));
4872
4882
  };
4873
- allTokenKeys.idToken.filter(keyFilter).forEach((key) => {
4874
- this.removeIdToken(key, correlationId);
4875
- });
4876
4883
  allTokenKeys.accessToken.filter(keyFilter).forEach((key) => {
4877
4884
  this.removeAccessToken(key, correlationId);
4878
4885
  });
@@ -4886,12 +4893,32 @@ class CacheManager {
4886
4893
  * @param correlationId
4887
4894
  */
4888
4895
  removeAccessToken(key, correlationId) {
4896
+ const credential = this.removeAccessTokenCredential(key, correlationId);
4897
+ if (credential) {
4898
+ void this.removeTokenBindingKeyForCredential(credential, correlationId);
4899
+ }
4900
+ }
4901
+ /**
4902
+ * Removes an access token and waits for any unreferenced token-binding key
4903
+ * cleanup. Internal callers that require deterministic cleanup should use
4904
+ * this method instead of the synchronous public cache contract.
4905
+ */
4906
+ async removeAccessTokenAndTokenBindingKey(key, correlationId, preservedKeyId) {
4907
+ const credential = this.removeAccessTokenCredential(key, correlationId);
4908
+ if (credential) {
4909
+ await this.removeTokenBindingKeyForCredential(credential, correlationId, preservedKeyId);
4910
+ }
4911
+ }
4912
+ removeAccessTokenCredential(key, correlationId) {
4889
4913
  const credential = this.getAccessTokenCredential(key, correlationId);
4890
4914
  if (!credential) {
4891
- return;
4915
+ return null;
4892
4916
  }
4893
4917
  this.removeItem(key, correlationId);
4894
4918
  this.performanceClient.incrementFields({ accessTokensRemoved: 1 }, correlationId);
4919
+ return credential;
4920
+ }
4921
+ async removeTokenBindingKeyForCredential(credential, correlationId, preservedKeyId) {
4895
4922
  // Remove Token Binding Key from key store for token-bound access token credentials
4896
4923
  if (credential.credentialType.toLowerCase() ===
4897
4924
  CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) {
@@ -4901,19 +4928,28 @@ class CacheManager {
4901
4928
  case AuthenticationScheme.DPOP.toLowerCase(): {
4902
4929
  const accessTokenWithAuthSchemeEntity = credential;
4903
4930
  const kid = accessTokenWithAuthSchemeEntity.keyId;
4904
- if (kid) {
4905
- void this.tokenBindingKeyManager
4906
- .removeTokenBindingKey(kid, correlationId)
4907
- .catch(() => {
4931
+ if (kid &&
4932
+ kid !== preservedKeyId &&
4933
+ !this.isTokenBindingKeyReferenced(kid, correlationId)) {
4934
+ try {
4935
+ await this.tokenBindingKeyManager.removeTokenBindingKey(kid, correlationId);
4936
+ }
4937
+ catch {
4908
4938
  this.commonLogger.error("Failed to remove token binding key", correlationId);
4909
4939
  this.performanceClient?.incrementFields({ removeTokenBindingKeyFailure: 1 }, correlationId);
4910
- });
4940
+ }
4911
4941
  }
4912
4942
  break;
4913
4943
  }
4914
4944
  }
4915
4945
  }
4916
4946
  }
4947
+ isTokenBindingKeyReferenced(keyId, correlationId) {
4948
+ return this.getTokenKeys().accessToken.some((accessTokenKey) => {
4949
+ const accessToken = this.getAccessTokenCredential(accessTokenKey, correlationId);
4950
+ return accessToken?.keyId === keyId;
4951
+ });
4952
+ }
4917
4953
  /**
4918
4954
  * Removes all app metadata objects from cache.
4919
4955
  */
@@ -5052,6 +5088,7 @@ class CacheManager {
5052
5088
  const scopes = ScopeSet.createSearchScopes(request.scopes, correlationId);
5053
5089
  const authScheme = request.authenticationScheme ||
5054
5090
  AuthenticationScheme.BEARER;
5091
+ const normalizedAuthScheme = authScheme.toLowerCase();
5055
5092
  /*
5056
5093
  * Distinguish between Bearer and PoP/SSH token cache types
5057
5094
  * Cast to lowercase to handle "bearer" from ADFS
@@ -5076,7 +5113,10 @@ class CacheManager {
5076
5113
  tokenType: authScheme,
5077
5114
  keyId: authScheme === AuthenticationScheme.SSH
5078
5115
  ? request.sshKid
5079
- : undefined,
5116
+ : normalizedAuthScheme ===
5117
+ AuthenticationScheme.DPOP.toLowerCase()
5118
+ ? request.popKid || request.dpopJkt
5119
+ : undefined,
5080
5120
  additionalCacheKeyComponents: additionalCacheKeyComponents,
5081
5121
  };
5082
5122
  const accessTokenKeys = (tokenKeys && tokenKeys.accessToken) ||
@@ -5576,7 +5616,7 @@ class DefaultStorageClass extends CacheManager {
5576
5616
  }
5577
5617
  }
5578
5618
 
5579
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5619
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5580
5620
  /*
5581
5621
  * Copyright (c) Microsoft Corporation. All rights reserved.
5582
5622
  * Licensed under the MIT License.
@@ -5590,7 +5630,7 @@ class DefaultStorageClass extends CacheManager {
5590
5630
  const PerformanceEventStatus = {
5591
5631
  InProgress: 1};
5592
5632
 
5593
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5633
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5594
5634
 
5595
5635
  /*
5596
5636
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5648,7 +5688,7 @@ class StubPerformanceClient {
5648
5688
  }
5649
5689
  }
5650
5690
 
5651
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5691
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5652
5692
 
5653
5693
  /*
5654
5694
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5746,7 +5786,7 @@ function isOidcProtocolMode(config) {
5746
5786
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
5747
5787
  }
5748
5788
 
5749
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5789
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5750
5790
  /*
5751
5791
  * Copyright (c) Microsoft Corporation. All rights reserved.
5752
5792
  * Licensed under the MIT License.
@@ -5773,7 +5813,7 @@ function isOidcProtocolMode(config) {
5773
5813
  }
5774
5814
  }
5775
5815
 
5776
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5816
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5777
5817
 
5778
5818
  /*
5779
5819
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5794,7 +5834,7 @@ function createJoseHeaderError(code, correlationId) {
5794
5834
  return new JoseHeaderError(code, correlationId);
5795
5835
  }
5796
5836
 
5797
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5837
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5798
5838
  /*
5799
5839
  * Copyright (c) Microsoft Corporation. All rights reserved.
5800
5840
  * Licensed under the MIT License.
@@ -5819,7 +5859,7 @@ function isPlainObject(value) {
5819
5859
  return Object.getPrototypeOf(value) === proto;
5820
5860
  }
5821
5861
 
5822
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5862
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5823
5863
  /*
5824
5864
  * Copyright (c) Microsoft Corporation. All rights reserved.
5825
5865
  * Licensed under the MIT License.
@@ -5829,7 +5869,7 @@ const missingAlgError = "missing_alg_error";
5829
5869
  const missingJwkError = "missing_jwk_error";
5830
5870
  const invalidJwkError = "invalid_jwk_error";
5831
5871
 
5832
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5872
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5833
5873
 
5834
5874
  /*
5835
5875
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5895,7 +5935,7 @@ class JoseHeader {
5895
5935
  }
5896
5936
  }
5897
5937
 
5898
- /*! @azure/msal-common v16.15.0 2026-10-27 */
5938
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
5899
5939
 
5900
5940
  /*
5901
5941
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5996,7 +6036,7 @@ class PopTokenGenerator {
5996
6036
  }
5997
6037
  }
5998
6038
 
5999
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6039
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6000
6040
 
6001
6041
  /*
6002
6042
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6046,13 +6086,22 @@ function validateDpopNonce(nonce, correlationId) {
6046
6086
  throw createClientConfigurationError(invalidDpopNonce, correlationId);
6047
6087
  }
6048
6088
  }
6089
+ /**
6090
+ * Validates and normalizes the HTTP resource context for a DPoP-bound request.
6091
+ * @internal
6092
+ */
6093
+ function normalizeDpopResourceRequestContext(context, correlationId = "") {
6094
+ return {
6095
+ htm: normalizeHtm(context.htm, correlationId),
6096
+ htu: normalizeHtu(context.htu, correlationId),
6097
+ };
6098
+ }
6049
6099
  /**
6050
6100
  * Builds RFC 9449 DPoP proof JWT payloads for token-endpoint and
6051
6101
  * resource-endpoint proof bindings.
6052
6102
  *
6053
- * Not exported from any public package entry point.
6054
- * This helper is internal-only until DPoP is wired into acquisition flows
6055
- * in a subsequent work item.
6103
+ * Exported from package entry points for use by MSAL Browser.
6104
+ * This helper remains an unsupported internal API for direct consumers.
6056
6105
  *
6057
6106
  * DPoP proofs do not contain SHR fields (at, ts, m, u, p, q).
6058
6107
  * @internal
@@ -6107,10 +6156,11 @@ class DpopProofGenerator {
6107
6156
  */
6108
6157
  buildResourceProofClaims(params, correlationId = "") {
6109
6158
  validateDpopNonce(params.nonce, correlationId);
6159
+ const resourceContext = normalizeDpopResourceRequestContext(params, correlationId);
6110
6160
  const claims = {
6111
6161
  jti: this.cryptoUtils.createNewGuid(),
6112
- htm: normalizeHtm(params.htm, correlationId),
6113
- htu: normalizeHtu(params.htu, correlationId),
6162
+ htm: resourceContext.htm,
6163
+ htu: resourceContext.htu,
6114
6164
  ath: params.ath,
6115
6165
  iat: nowSeconds(),
6116
6166
  };
@@ -6141,7 +6191,7 @@ class DpopProofGenerator {
6141
6191
  }
6142
6192
  }
6143
6193
 
6144
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6194
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6145
6195
  /*
6146
6196
  * Copyright (c) Microsoft Corporation. All rights reserved.
6147
6197
  * Licensed under the MIT License.
@@ -6205,7 +6255,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6205
6255
  uiNotAllowed: uiNotAllowed
6206
6256
  });
6207
6257
 
6208
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6258
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6209
6259
 
6210
6260
  /*
6211
6261
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6272,7 +6322,7 @@ function createInteractionRequiredAuthError(errorCode, correlationId, errorMessa
6272
6322
  return new InteractionRequiredAuthError(errorCode, correlationId, errorMessage);
6273
6323
  }
6274
6324
 
6275
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6325
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6276
6326
 
6277
6327
  /*
6278
6328
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6291,7 +6341,42 @@ class ServerError extends AuthError {
6291
6341
  }
6292
6342
  }
6293
6343
 
6294
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6344
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6345
+
6346
+ /*
6347
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6348
+ * Licensed under the MIT License.
6349
+ */
6350
+ /**
6351
+ * Appends user state with random guid, or returns random guid.
6352
+ * @param cryptoObj
6353
+ * @param userState
6354
+ * @param meta
6355
+ * @param correlationId
6356
+ */
6357
+ function setRequestState(cryptoObj, userState, meta, correlationId) {
6358
+ const libraryState = generateLibraryState(cryptoObj, correlationId);
6359
+ return userState
6360
+ ? `${libraryState}${RESOURCE_DELIM}${userState}`
6361
+ : libraryState;
6362
+ }
6363
+ /**
6364
+ * Generates the state value used by the common library.
6365
+ * @param cryptoObj
6366
+ * @param correlationId
6367
+ * @param meta
6368
+ */
6369
+ function generateLibraryState(cryptoObj, correlationId, meta) {
6370
+ if (!cryptoObj) {
6371
+ throw createClientAuthError(noCryptoObject, correlationId);
6372
+ }
6373
+ // Create a state object containing a unique id and the timestamp of the request creation
6374
+ const stateObj = {
6375
+ id: cryptoObj.createNewGuid(),
6376
+ };
6377
+ const stateString = JSON.stringify(stateObj);
6378
+ return cryptoObj.base64Encode(stateString);
6379
+ }
6295
6380
  /**
6296
6381
  * Parses the state into the RequestStateObject, which contains the LibraryState info and the state passed by the user.
6297
6382
  * @param base64Decode
@@ -6324,7 +6409,7 @@ function parseRequestState(base64Decode, state, correlationId) {
6324
6409
  }
6325
6410
  }
6326
6411
 
6327
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6412
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6328
6413
 
6329
6414
  /*
6330
6415
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6752,7 +6837,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
6752
6837
  return baseAccount;
6753
6838
  }
6754
6839
 
6755
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6840
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6756
6841
  /*
6757
6842
  * Copyright (c) Microsoft Corporation. All rights reserved.
6758
6843
  * Licensed under the MIT License.
@@ -6762,7 +6847,7 @@ const CcsCredentialType = {
6762
6847
  UPN: "UPN",
6763
6848
  };
6764
6849
 
6765
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6850
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6766
6851
  /*
6767
6852
  * Copyright (c) Microsoft Corporation. All rights reserved.
6768
6853
  * Licensed under the MIT License.
@@ -6781,7 +6866,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint, fmiP
6781
6866
  }
6782
6867
  }
6783
6868
 
6784
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6869
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6785
6870
 
6786
6871
  /*
6787
6872
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6805,7 +6890,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
6805
6890
  };
6806
6891
  }
6807
6892
 
6808
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6893
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6809
6894
 
6810
6895
  /*
6811
6896
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6895,7 +6980,7 @@ function getRetryAfterHeader(response) {
6895
6980
  return undefined;
6896
6981
  }
6897
6982
 
6898
- /*! @azure/msal-common v16.15.0 2026-10-27 */
6983
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6899
6984
 
6900
6985
  /*
6901
6986
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6926,7 +7011,7 @@ function createNetworkError(error, httpStatus, responseHeaders, additionalError)
6926
7011
  return new NetworkError(error, httpStatus, responseHeaders);
6927
7012
  }
6928
7013
 
6929
- /*! @azure/msal-common v16.15.0 2026-10-27 */
7014
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
6930
7015
 
6931
7016
  /*
6932
7017
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7060,7 +7145,7 @@ async function sendPostRequest(thumbprint, tokenEndpoint, options, correlationId
7060
7145
  return response;
7061
7146
  }
7062
7147
 
7063
- /*! @azure/msal-common v16.15.0 2026-10-27 */
7148
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
7064
7149
 
7065
7150
  /*
7066
7151
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7327,7 +7412,7 @@ class AuthorizationCodeClient {
7327
7412
  }
7328
7413
  }
7329
7414
 
7330
- /*! @azure/msal-common v16.15.0 2026-10-27 */
7415
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
7331
7416
 
7332
7417
  /*
7333
7418
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7481,7 +7566,7 @@ function extractLoginHint(account) {
7481
7566
  return account.loginHint || account.idTokenClaims?.login_hint || null;
7482
7567
  }
7483
7568
 
7484
- /*! @azure/msal-common v16.15.0 2026-10-27 */
7569
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
7485
7570
 
7486
7571
  /*
7487
7572
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7716,7 +7801,7 @@ class RefreshTokenClient {
7716
7801
  }
7717
7802
  }
7718
7803
 
7719
- /*! @azure/msal-common v16.15.0 2026-10-27 */
7804
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
7720
7805
 
7721
7806
  /*
7722
7807
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7982,7 +8067,7 @@ class ServerTelemetryManager {
7982
8067
  }
7983
8068
  }
7984
8069
 
7985
- /*! @azure/msal-common v16.15.0 2026-10-27 */
8070
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
7986
8071
 
7987
8072
  /*
7988
8073
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8109,7 +8194,7 @@ class SilentFlowClient {
8109
8194
  }
8110
8195
  }
8111
8196
 
8112
- /*! @azure/msal-common v16.15.0 2026-10-27 */
8197
+ /*! @azure/msal-common v16.16.1 2026-11-06 */
8113
8198
 
8114
8199
  /*
8115
8200
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10159,7 +10244,7 @@ class ClientAssertion {
10159
10244
 
10160
10245
  /* eslint-disable header/header */
10161
10246
  const name = "@azure/msal-node";
10162
- const version = "7.1.2";
10247
+ const version = "7.2.1";
10163
10248
 
10164
10249
  /*
10165
10250
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10869,14 +10954,18 @@ class LoopbackClient {
10869
10954
  }
10870
10955
  /**
10871
10956
  * Spins up a loopback server which returns the server response when the localhost redirectUri is hit
10957
+ * @param expectedState - State sent in the authorization request
10872
10958
  * @param successTemplate
10873
10959
  * @param errorTemplate
10874
10960
  * @returns
10875
10961
  */
10876
- async listenForAuthCode(successTemplate, errorTemplate) {
10962
+ async listenForAuthCode(expectedState, successTemplate, errorTemplate) {
10877
10963
  if (this.server) {
10878
10964
  throw NodeAuthError.createLoopbackServerAlreadyExistsError();
10879
10965
  }
10966
+ if (!expectedState) {
10967
+ throw NodeAuthError.createStateNotFoundError("");
10968
+ }
10880
10969
  return new Promise((resolve, reject) => {
10881
10970
  this.server = http.createServer((req, res) => {
10882
10971
  const method = req.method?.toUpperCase();
@@ -10897,7 +10986,7 @@ class LoopbackClient {
10897
10986
  }
10898
10987
  else if (url === FORWARD_SLASH) {
10899
10988
  if (method === "POST") {
10900
- this.handlePostRequest(req, res, resolve, successTemplate, errorTemplate);
10989
+ this.handlePostRequest(req, res, resolve, expectedState, successTemplate, errorTemplate);
10901
10990
  return;
10902
10991
  }
10903
10992
  // GET to root — return success page (after redirect)
@@ -10919,6 +11008,11 @@ class LoopbackClient {
10919
11008
  res.end();
10920
11009
  return;
10921
11010
  }
11011
+ if (!this.isExpectedState(parsedUrl.searchParams, expectedState)) {
11012
+ res.writeHead(400);
11013
+ res.end("Invalid authorization response state.");
11014
+ return;
11015
+ }
10922
11016
  res.writeHead(400);
10923
11017
  res.end("OAuth responses must use form_post and cannot be returned in the URL.");
10924
11018
  reject(NodeAuthError.createLoopbackServerQueryResponseNotSupportedError());
@@ -10951,7 +11045,7 @@ class LoopbackClient {
10951
11045
  /**
10952
11046
  * Handles POST requests for form_post response mode
10953
11047
  */
10954
- handlePostRequest(req, res, resolve, successTemplate, errorTemplate) {
11048
+ handlePostRequest(req, res, resolve, expectedState, successTemplate, errorTemplate) {
10955
11049
  const contentType = req.headers["content-type"]?.split(";")[0]?.trim();
10956
11050
  if (contentType !== "application/x-www-form-urlencoded") {
10957
11051
  res.writeHead(415);
@@ -10976,6 +11070,12 @@ class LoopbackClient {
10976
11070
  res.end();
10977
11071
  return;
10978
11072
  }
11073
+ // Unrelated callbacks must not settle or cancel the pending sign-in.
11074
+ if (!this.isExpectedState(new URLSearchParams(body), expectedState)) {
11075
+ res.writeHead(400);
11076
+ res.end("Invalid authorization response state.");
11077
+ return;
11078
+ }
10979
11079
  if (authCodeResponse.error) {
10980
11080
  res.writeHead(200);
10981
11081
  res.end(errorTemplate || `Error occurred: ${authCodeResponse.error}`);
@@ -10988,6 +11088,13 @@ class LoopbackClient {
10988
11088
  resolve(authCodeResponse);
10989
11089
  });
10990
11090
  }
11091
+ /**
11092
+ * Requires exactly one state value matching the pending authorization request.
11093
+ */
11094
+ isExpectedState(parameters, expectedState) {
11095
+ const states = parameters.getAll("state");
11096
+ return states.length === 1 && states[0] === expectedState;
11097
+ }
10991
11098
  /**
10992
11099
  * Get the port that the loopback server is running on
10993
11100
  * @returns
@@ -11348,11 +11455,14 @@ class PublicClientApplication extends ClientApplication {
11348
11455
  responseMode !== ResponseMode$1.FORM_POST) {
11349
11456
  throw createClientConfigurationError(invalidResponseMode, correlationId);
11350
11457
  }
11458
+ const state = setRequestState(this.cryptoProvider, remainingProperties.state
11459
+ ? this.cryptoProvider.base64Encode(remainingProperties.state)
11460
+ : remainingProperties.state, undefined, correlationId);
11351
11461
  let authCodeResponse = {};
11352
11462
  let authCodeListenerError = null;
11353
11463
  try {
11354
11464
  const authCodeListener = loopbackClient
11355
- .listenForAuthCode(successTemplate, errorTemplate)
11465
+ .listenForAuthCode(state, successTemplate, errorTemplate)
11356
11466
  .then((response) => {
11357
11467
  authCodeResponse = response;
11358
11468
  })
@@ -11370,6 +11480,7 @@ class PublicClientApplication extends ClientApplication {
11370
11480
  responseMode: ResponseMode$1.FORM_POST,
11371
11481
  codeChallenge: challenge,
11372
11482
  codeChallengeMethod: CodeChallengeMethodValues.S256,
11483
+ state,
11373
11484
  };
11374
11485
  const authCodeUrl = await this.getAuthCodeUrl(validRequest);
11375
11486
  await openBrowser(authCodeUrl);
@@ -11377,6 +11488,7 @@ class PublicClientApplication extends ClientApplication {
11377
11488
  if (authCodeListenerError) {
11378
11489
  throw authCodeListenerError;
11379
11490
  }
11491
+ this.validateState(state, authCodeResponse.state || "", correlationId);
11380
11492
  if (authCodeResponse.error) {
11381
11493
  throw new ServerError(authCodeResponse.error, correlationId, authCodeResponse.error_description, authCodeResponse.suberror);
11382
11494
  }
@@ -11389,6 +11501,7 @@ class PublicClientApplication extends ClientApplication {
11389
11501
  codeVerifier: verifier,
11390
11502
  clientInfo: clientInfo || "",
11391
11503
  ...validRequest,
11504
+ state: remainingProperties.state,
11392
11505
  };
11393
11506
  return await this.acquireTokenByCode(tokenRequest); // Await this so the server doesn't close prematurely
11394
11507
  }