@azure/msal-node 3.8.1 → 3.8.3

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 (60) 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/ClientApplication.mjs +1 -1
  8. package/dist/client/ClientAssertion.mjs +1 -1
  9. package/dist/client/ClientCredentialClient.mjs +1 -1
  10. package/dist/client/ConfidentialClientApplication.mjs +1 -1
  11. package/dist/client/DeviceCodeClient.mjs +1 -1
  12. package/dist/client/ManagedIdentityApplication.mjs +1 -1
  13. package/dist/client/ManagedIdentityClient.mjs +1 -1
  14. package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
  15. package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
  16. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +1 -1
  17. package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
  18. package/dist/client/ManagedIdentitySources/Imds.mjs +1 -1
  19. package/dist/client/ManagedIdentitySources/MachineLearning.mjs +1 -1
  20. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +1 -1
  21. package/dist/client/OnBehalfOfClient.mjs +1 -1
  22. package/dist/client/PublicClientApplication.mjs +1 -1
  23. package/dist/client/UsernamePasswordClient.mjs +1 -1
  24. package/dist/config/Configuration.mjs +1 -1
  25. package/dist/config/ManagedIdentityId.mjs +1 -1
  26. package/dist/config/ManagedIdentityRequestParameters.mjs +1 -1
  27. package/dist/crypto/CryptoProvider.mjs +1 -1
  28. package/dist/crypto/GuidGenerator.mjs +1 -1
  29. package/dist/crypto/HashUtils.mjs +1 -1
  30. package/dist/crypto/PkceGenerator.mjs +1 -1
  31. package/dist/error/ManagedIdentityError.mjs +1 -1
  32. package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
  33. package/dist/error/NodeAuthError.mjs +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/internals.mjs +1 -1
  36. package/dist/network/HttpClient.d.ts +29 -2
  37. package/dist/network/HttpClient.d.ts.map +1 -1
  38. package/dist/network/HttpClient.mjs +296 -250
  39. package/dist/network/HttpClient.mjs.map +1 -1
  40. package/dist/network/HttpClientWithRetries.mjs +1 -1
  41. package/dist/network/LoopbackClient.mjs +1 -1
  42. package/dist/packageMetadata.d.ts +1 -1
  43. package/dist/packageMetadata.mjs +2 -2
  44. package/dist/protocol/Authorize.mjs +1 -1
  45. package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +1 -1
  46. package/dist/retry/ExponentialRetryStrategy.mjs +1 -1
  47. package/dist/retry/ImdsRetryPolicy.mjs +1 -1
  48. package/dist/retry/LinearRetryStrategy.mjs +1 -1
  49. package/dist/utils/Constants.mjs +1 -1
  50. package/dist/utils/EncodingUtils.mjs +1 -1
  51. package/dist/utils/NetworkUtils.mjs +1 -1
  52. package/dist/utils/TimeUtils.mjs +1 -1
  53. package/lib/msal-node.cjs +365 -313
  54. package/lib/msal-node.cjs.map +1 -1
  55. package/lib/types/network/HttpClient.d.ts +29 -2
  56. package/lib/types/network/HttpClient.d.ts.map +1 -1
  57. package/lib/types/packageMetadata.d.ts +1 -1
  58. package/package.json +2 -2
  59. package/src/network/HttpClient.ts +399 -314
  60. package/src/packageMetadata.ts +1 -1
package/lib/msal-node.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v3.8.1 2025-10-29 */
1
+ /*! @azure/msal-node v3.8.3 2025-11-19 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -153,7 +153,7 @@ class Serializer {
153
153
  }
154
154
  }
155
155
 
156
- /*! @azure/msal-common v15.13.1 2025-10-29 */
156
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
157
157
  /*
158
158
  * Copyright (c) Microsoft Corporation. All rights reserved.
159
159
  * Licensed under the MIT License.
@@ -433,7 +433,7 @@ const EncodingTypes = {
433
433
  UTF8: "utf-8",
434
434
  };
435
435
 
436
- /*! @azure/msal-common v15.13.1 2025-10-29 */
436
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
437
437
  /*
438
438
  * Copyright (c) Microsoft Corporation. All rights reserved.
439
439
  * Licensed under the MIT License.
@@ -450,7 +450,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
450
450
  unexpectedError: unexpectedError
451
451
  });
452
452
 
453
- /*! @azure/msal-common v15.13.1 2025-10-29 */
453
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
454
454
 
455
455
  /*
456
456
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -499,7 +499,7 @@ function createAuthError(code, additionalMessage) {
499
499
  : AuthErrorMessages[code]);
500
500
  }
501
501
 
502
- /*! @azure/msal-common v15.13.1 2025-10-29 */
502
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
503
503
  /*
504
504
  * Copyright (c) Microsoft Corporation. All rights reserved.
505
505
  * Licensed under the MIT License.
@@ -547,7 +547,8 @@ const noNetworkConnectivity = "no_network_connectivity";
547
547
  const userCanceled = "user_canceled";
548
548
  const missingTenantIdError = "missing_tenant_id_error";
549
549
  const methodNotImplemented = "method_not_implemented";
550
- const nestedAppAuthBridgeDisabled = "nested_app_auth_bridge_disabled";
550
+ const nestedAppAuthBridgeDisabled = "nested_app_auth_bridge_disabled";
551
+ const platformBrokerError = "platform_broker_error";
551
552
 
552
553
  var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
553
554
  __proto__: null,
@@ -586,6 +587,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
586
587
  nonceMismatch: nonceMismatch,
587
588
  nullOrEmptyToken: nullOrEmptyToken,
588
589
  openIdConfigError: openIdConfigError,
590
+ platformBrokerError: platformBrokerError,
589
591
  requestCannotBeMade: requestCannotBeMade,
590
592
  stateMismatch: stateMismatch,
591
593
  stateNotFound: stateNotFound,
@@ -597,7 +599,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
597
599
  userTimeoutReached: userTimeoutReached
598
600
  });
599
601
 
600
- /*! @azure/msal-common v15.13.1 2025-10-29 */
602
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
601
603
 
602
604
  /*
603
605
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -654,6 +656,7 @@ const ClientAuthErrorMessages = {
654
656
  [missingTenantIdError]: "A tenant id - not common, organizations, or consumers - must be specified when using the client_credentials flow.",
655
657
  [methodNotImplemented]: "This method has not been implemented",
656
658
  [nestedAppAuthBridgeDisabled]: "The nested app auth bridge is disabled",
659
+ [platformBrokerError]: "An error occurred in the native broker. See the platformBrokerError property for details.",
657
660
  };
658
661
  /**
659
662
  * String constants used by error codes and messages.
@@ -832,6 +835,10 @@ const ClientAuthErrorMessage = {
832
835
  code: nestedAppAuthBridgeDisabled,
833
836
  desc: ClientAuthErrorMessages[nestedAppAuthBridgeDisabled],
834
837
  },
838
+ platformBrokerError: {
839
+ code: platformBrokerError,
840
+ desc: ClientAuthErrorMessages[platformBrokerError],
841
+ },
835
842
  };
836
843
  /**
837
844
  * Error thrown when there is an error in the client code running on the browser.
@@ -849,7 +856,7 @@ function createClientAuthError(errorCode, additionalMessage) {
849
856
  return new ClientAuthError(errorCode, additionalMessage);
850
857
  }
851
858
 
852
- /*! @azure/msal-common v15.13.1 2025-10-29 */
859
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
853
860
 
854
861
  /*
855
862
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -888,7 +895,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
888
895
  },
889
896
  };
890
897
 
891
- /*! @azure/msal-common v15.13.1 2025-10-29 */
898
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
892
899
 
893
900
  /*
894
901
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1079,12 +1086,12 @@ class Logger {
1079
1086
  }
1080
1087
  }
1081
1088
 
1082
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1089
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1083
1090
  /* eslint-disable header/header */
1084
1091
  const name$1 = "@azure/msal-common";
1085
- const version$1 = "15.13.1";
1092
+ const version$1 = "15.13.2";
1086
1093
 
1087
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1094
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1088
1095
  /*
1089
1096
  * Copyright (c) Microsoft Corporation. All rights reserved.
1090
1097
  * Licensed under the MIT License.
@@ -1104,7 +1111,7 @@ const AzureCloudInstance = {
1104
1111
  AzureUsGovernment: "https://login.microsoftonline.us",
1105
1112
  };
1106
1113
 
1107
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1114
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1108
1115
  /*
1109
1116
  * Copyright (c) Microsoft Corporation. All rights reserved.
1110
1117
  * Licensed under the MIT License.
@@ -1160,7 +1167,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1160
1167
  urlParseError: urlParseError
1161
1168
  });
1162
1169
 
1163
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1170
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1164
1171
 
1165
1172
  /*
1166
1173
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1303,7 +1310,7 @@ function createClientConfigurationError(errorCode) {
1303
1310
  return new ClientConfigurationError(errorCode);
1304
1311
  }
1305
1312
 
1306
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1313
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1307
1314
  /*
1308
1315
  * Copyright (c) Microsoft Corporation. All rights reserved.
1309
1316
  * Licensed under the MIT License.
@@ -1400,7 +1407,7 @@ class StringUtils {
1400
1407
  }
1401
1408
  }
1402
1409
 
1403
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1410
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1404
1411
 
1405
1412
  /*
1406
1413
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1595,7 +1602,7 @@ class ScopeSet {
1595
1602
  }
1596
1603
  }
1597
1604
 
1598
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1605
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1599
1606
 
1600
1607
  /*
1601
1608
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1635,7 +1642,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
1635
1642
  };
1636
1643
  }
1637
1644
 
1638
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1645
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1639
1646
  /*
1640
1647
  * Copyright (c) Microsoft Corporation. All rights reserved.
1641
1648
  * Licensed under the MIT License.
@@ -1717,7 +1724,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
1717
1724
  return updatedAccountInfo;
1718
1725
  }
1719
1726
 
1720
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1727
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1721
1728
  /*
1722
1729
  * Copyright (c) Microsoft Corporation. All rights reserved.
1723
1730
  * Licensed under the MIT License.
@@ -1732,7 +1739,7 @@ const AuthorityType = {
1732
1739
  Ciam: 3,
1733
1740
  };
1734
1741
 
1735
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1742
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1736
1743
  /*
1737
1744
  * Copyright (c) Microsoft Corporation. All rights reserved.
1738
1745
  * Licensed under the MIT License.
@@ -1754,7 +1761,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
1754
1761
  return null;
1755
1762
  }
1756
1763
 
1757
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1764
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1758
1765
  /*
1759
1766
  * Copyright (c) Microsoft Corporation. All rights reserved.
1760
1767
  * Licensed under the MIT License.
@@ -1778,7 +1785,7 @@ const ProtocolMode = {
1778
1785
  EAR: "EAR",
1779
1786
  };
1780
1787
 
1781
- /*! @azure/msal-common v15.13.1 2025-10-29 */
1788
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
1782
1789
 
1783
1790
  /*
1784
1791
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1999,7 +2006,7 @@ class AccountEntity {
1999
2006
  }
2000
2007
  }
2001
2008
 
2002
- /*! @azure/msal-common v15.13.1 2025-10-29 */
2009
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
2003
2010
 
2004
2011
  /*
2005
2012
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2080,7 +2087,7 @@ function checkMaxAge(authTime, maxAge) {
2080
2087
  }
2081
2088
  }
2082
2089
 
2083
- /*! @azure/msal-common v15.13.1 2025-10-29 */
2090
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
2084
2091
  /**
2085
2092
  * Parses hash string from given string. Returns empty string if no hash symbol is found.
2086
2093
  * @param hashString
@@ -2140,7 +2147,7 @@ function mapToQueryString(parameters, encodeExtraParams = true, extraQueryParame
2140
2147
  return queryParameterArray.join("&");
2141
2148
  }
2142
2149
 
2143
- /*! @azure/msal-common v15.13.1 2025-10-29 */
2150
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
2144
2151
 
2145
2152
  /*
2146
2153
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2304,7 +2311,7 @@ class UrlString {
2304
2311
  }
2305
2312
  }
2306
2313
 
2307
- /*! @azure/msal-common v15.13.1 2025-10-29 */
2314
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
2308
2315
 
2309
2316
  /*
2310
2317
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2443,7 +2450,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2443
2450
  return null;
2444
2451
  }
2445
2452
 
2446
- /*! @azure/msal-common v15.13.1 2025-10-29 */
2453
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
2447
2454
  /*
2448
2455
  * Copyright (c) Microsoft Corporation. All rights reserved.
2449
2456
  * Licensed under the MIT License.
@@ -2451,7 +2458,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2451
2458
  const cacheQuotaExceeded = "cache_quota_exceeded";
2452
2459
  const cacheErrorUnknown = "cache_error_unknown";
2453
2460
 
2454
- /*! @azure/msal-common v15.13.1 2025-10-29 */
2461
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
2455
2462
 
2456
2463
  /*
2457
2464
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2496,7 +2503,7 @@ function createCacheError(e) {
2496
2503
  }
2497
2504
  }
2498
2505
 
2499
- /*! @azure/msal-common v15.13.1 2025-10-29 */
2506
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
2500
2507
 
2501
2508
  /*
2502
2509
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3605,7 +3612,7 @@ class DefaultStorageClass extends CacheManager {
3605
3612
  }
3606
3613
  }
3607
3614
 
3608
- /*! @azure/msal-common v15.13.1 2025-10-29 */
3615
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
3609
3616
  /*
3610
3617
  * Copyright (c) Microsoft Corporation. All rights reserved.
3611
3618
  * Licensed under the MIT License.
@@ -3872,7 +3879,7 @@ const PerformanceEvents = {
3872
3879
  const PerformanceEventStatus = {
3873
3880
  InProgress: 1};
3874
3881
 
3875
- /*! @azure/msal-common v15.13.1 2025-10-29 */
3882
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
3876
3883
 
3877
3884
  /*
3878
3885
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3951,7 +3958,7 @@ class StubPerformanceClient {
3951
3958
  }
3952
3959
  }
3953
3960
 
3954
- /*! @azure/msal-common v15.13.1 2025-10-29 */
3961
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
3955
3962
 
3956
3963
  /*
3957
3964
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4051,7 +4058,7 @@ function isOidcProtocolMode(config) {
4051
4058
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4052
4059
  }
4053
4060
 
4054
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4061
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4055
4062
  /*
4056
4063
  * Copyright (c) Microsoft Corporation. All rights reserved.
4057
4064
  * Licensed under the MIT License.
@@ -4061,7 +4068,7 @@ const CcsCredentialType = {
4061
4068
  UPN: "UPN",
4062
4069
  };
4063
4070
 
4064
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4071
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4065
4072
  /*
4066
4073
  * Copyright (c) Microsoft Corporation. All rights reserved.
4067
4074
  * Licensed under the MIT License.
@@ -4112,7 +4119,7 @@ const BROKER_CLIENT_ID = "brk_client_id";
4112
4119
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4113
4120
  const INSTANCE_AWARE = "instance_aware";
4114
4121
 
4115
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4122
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4116
4123
 
4117
4124
  /*
4118
4125
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4498,7 +4505,7 @@ function addBrokerParameters(parameters, brokerClientId, brokerRedirectUri) {
4498
4505
  }
4499
4506
  }
4500
4507
 
4501
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4508
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4502
4509
  /*
4503
4510
  * Copyright (c) Microsoft Corporation. All rights reserved.
4504
4511
  * Licensed under the MIT License.
@@ -4510,7 +4517,7 @@ function isOpenIdConfigResponse(response) {
4510
4517
  response.hasOwnProperty("jwks_uri"));
4511
4518
  }
4512
4519
 
4513
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4520
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4514
4521
  /*
4515
4522
  * Copyright (c) Microsoft Corporation. All rights reserved.
4516
4523
  * Licensed under the MIT License.
@@ -4520,7 +4527,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4520
4527
  response.hasOwnProperty("metadata"));
4521
4528
  }
4522
4529
 
4523
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4530
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4524
4531
  /*
4525
4532
  * Copyright (c) Microsoft Corporation. All rights reserved.
4526
4533
  * Licensed under the MIT License.
@@ -4530,7 +4537,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4530
4537
  response.hasOwnProperty("error_description"));
4531
4538
  }
4532
4539
 
4533
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4540
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4534
4541
  /*
4535
4542
  * Copyright (c) Microsoft Corporation. All rights reserved.
4536
4543
  * Licensed under the MIT License.
@@ -4626,7 +4633,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
4626
4633
  };
4627
4634
  };
4628
4635
 
4629
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4636
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4630
4637
 
4631
4638
  /*
4632
4639
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4732,7 +4739,7 @@ RegionDiscovery.IMDS_OPTIONS = {
4732
4739
  },
4733
4740
  };
4734
4741
 
4735
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4742
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4736
4743
  /*
4737
4744
  * Copyright (c) Microsoft Corporation. All rights reserved.
4738
4745
  * Licensed under the MIT License.
@@ -4787,7 +4794,7 @@ function delay(t, value) {
4787
4794
  return new Promise((resolve) => setTimeout(() => resolve(value), t));
4788
4795
  }
4789
4796
 
4790
- /*! @azure/msal-common v15.13.1 2025-10-29 */
4797
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
4791
4798
 
4792
4799
  /*
4793
4800
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5049,7 +5056,7 @@ function isAuthorityMetadataExpired(metadata) {
5049
5056
  return metadata.expiresAt <= nowSeconds();
5050
5057
  }
5051
5058
 
5052
- /*! @azure/msal-common v15.13.1 2025-10-29 */
5059
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
5053
5060
 
5054
5061
  /*
5055
5062
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5888,7 +5895,7 @@ function buildStaticAuthorityOptions(authOptions) {
5888
5895
  };
5889
5896
  }
5890
5897
 
5891
- /*! @azure/msal-common v15.13.1 2025-10-29 */
5898
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
5892
5899
 
5893
5900
  /*
5894
5901
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5919,7 +5926,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
5919
5926
  }
5920
5927
  }
5921
5928
 
5922
- /*! @azure/msal-common v15.13.1 2025-10-29 */
5929
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
5923
5930
 
5924
5931
  /*
5925
5932
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5938,7 +5945,7 @@ class ServerError extends AuthError {
5938
5945
  }
5939
5946
  }
5940
5947
 
5941
- /*! @azure/msal-common v15.13.1 2025-10-29 */
5948
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
5942
5949
  /*
5943
5950
  * Copyright (c) Microsoft Corporation. All rights reserved.
5944
5951
  * Licensed under the MIT License.
@@ -5959,7 +5966,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
5959
5966
  };
5960
5967
  }
5961
5968
 
5962
- /*! @azure/msal-common v15.13.1 2025-10-29 */
5969
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
5963
5970
 
5964
5971
  /*
5965
5972
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6046,7 +6053,7 @@ class ThrottlingUtils {
6046
6053
  }
6047
6054
  }
6048
6055
 
6049
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6056
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6050
6057
 
6051
6058
  /*
6052
6059
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6066,7 +6073,7 @@ class NetworkError extends AuthError {
6066
6073
  }
6067
6074
  }
6068
6075
 
6069
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6076
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6070
6077
 
6071
6078
  /*
6072
6079
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6214,7 +6221,7 @@ class BaseClient {
6214
6221
  }
6215
6222
  }
6216
6223
 
6217
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6224
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6218
6225
  /*
6219
6226
  * Copyright (c) Microsoft Corporation. All rights reserved.
6220
6227
  * Licensed under the MIT License.
@@ -6242,7 +6249,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6242
6249
  uxNotAllowed: uxNotAllowed
6243
6250
  });
6244
6251
 
6245
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6252
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6246
6253
 
6247
6254
  /*
6248
6255
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6332,7 +6339,7 @@ function createInteractionRequiredAuthError(errorCode) {
6332
6339
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6333
6340
  }
6334
6341
 
6335
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6342
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6336
6343
 
6337
6344
  /*
6338
6345
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6404,7 +6411,7 @@ class ProtocolUtils {
6404
6411
  }
6405
6412
  }
6406
6413
 
6407
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6414
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6408
6415
 
6409
6416
  /*
6410
6417
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6486,7 +6493,7 @@ class PopTokenGenerator {
6486
6493
  }
6487
6494
  }
6488
6495
 
6489
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6496
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6490
6497
  /*
6491
6498
  * Copyright (c) Microsoft Corporation. All rights reserved.
6492
6499
  * Licensed under the MIT License.
@@ -6513,7 +6520,7 @@ class PopTokenGenerator {
6513
6520
  }
6514
6521
  }
6515
6522
 
6516
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6523
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6517
6524
 
6518
6525
  /*
6519
6526
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6844,7 +6851,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
6844
6851
  return baseAccount;
6845
6852
  }
6846
6853
 
6847
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6854
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6848
6855
  /*
6849
6856
  * Copyright (c) Microsoft Corporation. All rights reserved.
6850
6857
  * Licensed under the MIT License.
@@ -6862,7 +6869,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
6862
6869
  }
6863
6870
  }
6864
6871
 
6865
- /*! @azure/msal-common v15.13.1 2025-10-29 */
6872
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
6866
6873
 
6867
6874
  /*
6868
6875
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7097,7 +7104,7 @@ class AuthorizationCodeClient extends BaseClient {
7097
7104
  }
7098
7105
  }
7099
7106
 
7100
- /*! @azure/msal-common v15.13.1 2025-10-29 */
7107
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
7101
7108
 
7102
7109
  /*
7103
7110
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7306,7 +7313,7 @@ class RefreshTokenClient extends BaseClient {
7306
7313
  }
7307
7314
  }
7308
7315
 
7309
- /*! @azure/msal-common v15.13.1 2025-10-29 */
7316
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
7310
7317
 
7311
7318
  /*
7312
7319
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7404,7 +7411,7 @@ class SilentFlowClient extends BaseClient {
7404
7411
  }
7405
7412
  }
7406
7413
 
7407
- /*! @azure/msal-common v15.13.1 2025-10-29 */
7414
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
7408
7415
 
7409
7416
  /*
7410
7417
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7554,7 +7561,7 @@ function extractLoginHint(account) {
7554
7561
  return account.loginHint || account.idTokenClaims?.login_hint || null;
7555
7562
  }
7556
7563
 
7557
- /*! @azure/msal-common v15.13.1 2025-10-29 */
7564
+ /*! @azure/msal-common v15.13.2 2025-11-19 */
7558
7565
 
7559
7566
  /*
7560
7567
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8191,6 +8198,10 @@ class NetworkUtils {
8191
8198
  }
8192
8199
  }
8193
8200
 
8201
+ /* eslint-disable header/header */
8202
+ const name = "@azure/msal-node";
8203
+ const version = "3.8.3";
8204
+
8194
8205
  /*
8195
8206
  * Copyright (c) Microsoft Corporation. All rights reserved.
8196
8207
  * Licensed under the MIT License.
@@ -8199,9 +8210,296 @@ class NetworkUtils {
8199
8210
  * This class implements the API for network requests.
8200
8211
  */
8201
8212
  class HttpClient {
8202
- constructor(proxyUrl, customAgentOptions) {
8213
+ constructor(proxyUrl, customAgentOptions, loggerOptions) {
8214
+ this.networkRequestViaProxy = (httpMethod, destinationUrlString, options, timeout) => {
8215
+ const destinationUrl = new URL(destinationUrlString);
8216
+ const proxyUrl = new URL(this.proxyUrl);
8217
+ // "method: connect" must be used to establish a connection to the proxy
8218
+ const headers = options?.headers || {};
8219
+ const tunnelRequestOptions = {
8220
+ host: proxyUrl.hostname,
8221
+ port: proxyUrl.port,
8222
+ method: "CONNECT",
8223
+ path: destinationUrl.hostname,
8224
+ headers: headers,
8225
+ };
8226
+ if (this.customAgentOptions &&
8227
+ Object.keys(this.customAgentOptions).length) {
8228
+ tunnelRequestOptions.agent = new http.Agent(this.customAgentOptions);
8229
+ }
8230
+ // compose a request string for the socket
8231
+ let postRequestStringContent = "";
8232
+ if (httpMethod === HttpMethod.POST) {
8233
+ const body = options?.body || "";
8234
+ postRequestStringContent =
8235
+ "Content-Type: application/x-www-form-urlencoded\r\n" +
8236
+ `Content-Length: ${body.length}\r\n` +
8237
+ `\r\n${body}`;
8238
+ }
8239
+ else {
8240
+ // optional timeout is only for get requests (regionDiscovery, for example)
8241
+ if (timeout) {
8242
+ tunnelRequestOptions.timeout = timeout;
8243
+ }
8244
+ }
8245
+ const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` +
8246
+ `Host: ${destinationUrl.host}\r\n` +
8247
+ "Connection: close\r\n" +
8248
+ postRequestStringContent +
8249
+ "\r\n";
8250
+ return new Promise((resolve, reject) => {
8251
+ const request = http.request(tunnelRequestOptions);
8252
+ if (timeout) {
8253
+ request.on("timeout", () => {
8254
+ this.logUrlWithPiiAwareness(`Request timeout after ${timeout}ms for URL`, destinationUrlString);
8255
+ request.destroy();
8256
+ reject(new Error(`Request time out after ${timeout}ms`));
8257
+ });
8258
+ }
8259
+ request.end();
8260
+ // establish connection to the proxy
8261
+ request.on("connect", (response, socket) => {
8262
+ const proxyStatusCode = response?.statusCode || ProxyStatus.SERVER_ERROR;
8263
+ if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START ||
8264
+ proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
8265
+ request.destroy();
8266
+ socket.destroy();
8267
+ reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${response?.statusMessage || "Unknown"}`));
8268
+ }
8269
+ // make a request over an HTTP tunnel
8270
+ socket.write(outgoingRequestString);
8271
+ const data = [];
8272
+ socket.on("data", (chunk) => {
8273
+ data.push(chunk);
8274
+ });
8275
+ socket.on("end", () => {
8276
+ // combine all received buffer streams into one buffer, and then into a string
8277
+ const dataString = Buffer.concat([...data]).toString();
8278
+ // separate each line into it's own entry in an arry
8279
+ const dataStringArray = dataString.split("\r\n");
8280
+ // the first entry will contain the statusCode and statusMessage
8281
+ const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]);
8282
+ // remove "HTTP/1.1" and the status code to get the status message
8283
+ const statusMessage = dataStringArray[0]
8284
+ .split(" ")
8285
+ .slice(2)
8286
+ .join(" ");
8287
+ // the last entry will contain the body
8288
+ const body = dataStringArray[dataStringArray.length - 1];
8289
+ // everything in between the first and last entries are the headers
8290
+ const headersArray = dataStringArray.slice(1, dataStringArray.length - 2);
8291
+ // build an object out of all the headers
8292
+ const entries = new Map();
8293
+ headersArray.forEach((header) => {
8294
+ /**
8295
+ * the header might look like "Content-Length: 1531", but that is just a string
8296
+ * it needs to be converted to a key/value pair
8297
+ * split the string at the first instance of ":"
8298
+ * there may be more than one ":" if the value of the header is supposed to be a JSON object
8299
+ */
8300
+ const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
8301
+ const headerKey = headerKeyValue[0];
8302
+ let headerValue = headerKeyValue[1];
8303
+ // check if the value of the header is supposed to be a JSON object
8304
+ try {
8305
+ const object = JSON.parse(headerValue);
8306
+ // if it is, then convert it from a string to a JSON object
8307
+ if (object && typeof object === "object") {
8308
+ headerValue = object;
8309
+ }
8310
+ }
8311
+ catch (e) {
8312
+ // otherwise, leave it as a string
8313
+ }
8314
+ entries.set(headerKey, headerValue);
8315
+ });
8316
+ const headers = Object.fromEntries(entries);
8317
+ const parsedHeaders = headers;
8318
+ const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, this.parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
8319
+ if (this.shouldDestroyRequest(httpStatusCode, networkResponse)) {
8320
+ request.destroy();
8321
+ }
8322
+ resolve(networkResponse);
8323
+ });
8324
+ socket.on("error", (chunk) => {
8325
+ request.destroy();
8326
+ socket.destroy();
8327
+ reject(new Error(chunk.toString()));
8328
+ });
8329
+ });
8330
+ request.on("error", (chunk) => {
8331
+ this.logger.error(`HttpClient - Proxy request error: ${chunk.toString()}`, "");
8332
+ this.logUrlWithPiiAwareness("Destination URL", destinationUrlString);
8333
+ this.logUrlWithPiiAwareness("Proxy URL", this.proxyUrl);
8334
+ this.logger.error(`HttpClient - Method: ${httpMethod}`, "");
8335
+ this.logger.errorPii(`HttpClient - Headers: ${JSON.stringify(headers)}`, "");
8336
+ request.destroy();
8337
+ reject(new Error(chunk.toString()));
8338
+ });
8339
+ });
8340
+ };
8341
+ this.networkRequestViaHttps = (httpMethod, urlString, options, timeout) => {
8342
+ const isPostRequest = httpMethod === HttpMethod.POST;
8343
+ const body = options?.body || "";
8344
+ const url = new URL(urlString);
8345
+ const headers = options?.headers || {};
8346
+ const customOptions = {
8347
+ method: httpMethod,
8348
+ headers: headers,
8349
+ ...NetworkUtils.urlToHttpOptions(url),
8350
+ };
8351
+ if (this.customAgentOptions &&
8352
+ Object.keys(this.customAgentOptions).length) {
8353
+ customOptions.agent = new https.Agent(this.customAgentOptions);
8354
+ }
8355
+ if (isPostRequest) {
8356
+ // needed for post request to work
8357
+ customOptions.headers = {
8358
+ ...customOptions.headers,
8359
+ "Content-Length": body.length,
8360
+ };
8361
+ }
8362
+ else {
8363
+ // optional timeout is only for get requests (regionDiscovery, for example)
8364
+ if (timeout) {
8365
+ customOptions.timeout = timeout;
8366
+ }
8367
+ }
8368
+ return new Promise((resolve, reject) => {
8369
+ let request;
8370
+ // managed identity sources use http instead of https
8371
+ if (customOptions.protocol === "http:") {
8372
+ request = http.request(customOptions);
8373
+ }
8374
+ else {
8375
+ request = https.request(customOptions);
8376
+ }
8377
+ if (isPostRequest) {
8378
+ request.write(body);
8379
+ }
8380
+ if (timeout) {
8381
+ request.on("timeout", () => {
8382
+ this.logUrlWithPiiAwareness(`HTTPS request timeout after ${timeout}ms for URL`, urlString);
8383
+ request.destroy();
8384
+ reject(new Error(`Request time out after ${timeout}ms`));
8385
+ });
8386
+ }
8387
+ request.end();
8388
+ request.on("response", (response) => {
8389
+ const headers = response.headers;
8390
+ const statusCode = response.statusCode;
8391
+ const statusMessage = response.statusMessage;
8392
+ const data = [];
8393
+ response.on("data", (chunk) => {
8394
+ data.push(chunk);
8395
+ });
8396
+ response.on("end", () => {
8397
+ // combine all received buffer streams into one buffer, and then into a string
8398
+ const body = Buffer.concat([...data]).toString();
8399
+ const parsedHeaders = headers;
8400
+ const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, this.parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
8401
+ if (this.shouldDestroyRequest(statusCode, networkResponse)) {
8402
+ request.destroy();
8403
+ }
8404
+ resolve(networkResponse);
8405
+ });
8406
+ });
8407
+ request.on("error", (chunk) => {
8408
+ this.logger.error(`HttpClient - HTTPS request error: ${chunk.toString()}`, "");
8409
+ this.logUrlWithPiiAwareness("URL", urlString);
8410
+ this.logger.error(`HttpClient - Method: ${httpMethod}`, "");
8411
+ this.logger.errorPii(`HttpClient - Headers: ${JSON.stringify(headers)}`, "");
8412
+ request.destroy();
8413
+ reject(new Error(chunk.toString()));
8414
+ });
8415
+ });
8416
+ };
8417
+ /**
8418
+ * Check if extra parsing is needed on the repsonse from the server
8419
+ * @param statusCode {number} the status code of the response from the server
8420
+ * @param statusMessage {string | undefined} the status message of the response from the server
8421
+ * @param headers {Record<string, string>} the headers of the response from the server
8422
+ * @param body {string} the body from the response of the server
8423
+ * @returns {Object} JSON parsed body or error object
8424
+ */
8425
+ this.parseBody = (statusCode, statusMessage, headers, body) => {
8426
+ /*
8427
+ * Informational responses (100 – 199)
8428
+ * Successful responses (200 – 299)
8429
+ * Redirection messages (300 – 399)
8430
+ * Client error responses (400 – 499)
8431
+ * Server error responses (500 – 599)
8432
+ */
8433
+ let parsedBody;
8434
+ try {
8435
+ parsedBody = JSON.parse(body);
8436
+ }
8437
+ catch (error) {
8438
+ let errorType;
8439
+ let errorDescriptionHelper;
8440
+ if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START &&
8441
+ statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
8442
+ errorType = "client_error";
8443
+ errorDescriptionHelper = "A client";
8444
+ }
8445
+ else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START &&
8446
+ statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
8447
+ errorType = "server_error";
8448
+ errorDescriptionHelper = "A server";
8449
+ }
8450
+ else {
8451
+ errorType = "unknown_error";
8452
+ errorDescriptionHelper = "An unknown";
8453
+ }
8454
+ parsedBody = {
8455
+ error: errorType,
8456
+ error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`,
8457
+ };
8458
+ }
8459
+ return parsedBody;
8460
+ };
8461
+ /**
8462
+ * Helper function to log a formatted message containing URLs, with PII-aware sanitization
8463
+ * @param label {string} the label for the log message
8464
+ * @param urlString {string} the URL to log
8465
+ */
8466
+ this.logUrlWithPiiAwareness = (label, urlString) => {
8467
+ if (this.isPiiEnabled) {
8468
+ this.logger.errorPii(`HttpClient - ${label}: ${urlString}`, "");
8469
+ }
8470
+ else {
8471
+ let urlHelper;
8472
+ try {
8473
+ const url = new URL(urlString);
8474
+ urlHelper = `${url.protocol}//${url.host}${url.pathname}`;
8475
+ }
8476
+ catch {
8477
+ urlHelper = urlString.split("?")[0] || "unknown";
8478
+ }
8479
+ this.logger.error(`HttpClient - ${label}: ${urlHelper} [Enable PII logging to see additional details]`, "");
8480
+ }
8481
+ };
8482
+ /**
8483
+ * Helper function to determine if a request should be destroyed based on status code and response body.
8484
+ * Checks if the response is an error and not part of the device code flow (authorization_pending).
8485
+ * @param statusCode {number} the status code of the response
8486
+ * @param networkResponse {NetworkResponse<T>} the network response object
8487
+ * @returns {boolean} true if the request should be destroyed, false otherwise
8488
+ */
8489
+ this.shouldDestroyRequest = (statusCode, networkResponse) => {
8490
+ return ((statusCode < HttpStatus.SUCCESS_RANGE_START ||
8491
+ statusCode > HttpStatus.SUCCESS_RANGE_END) &&
8492
+ // do not destroy the request for the device code flow
8493
+ !(networkResponse.body &&
8494
+ typeof networkResponse.body === "object" &&
8495
+ "error" in networkResponse.body &&
8496
+ networkResponse.body.error ===
8497
+ Constants.AUTHORIZATION_PENDING));
8498
+ };
8203
8499
  this.proxyUrl = proxyUrl || "";
8204
8500
  this.customAgentOptions = customAgentOptions || {};
8501
+ this.logger = new Logger(loggerOptions || {}, name, version);
8502
+ this.isPiiEnabled = this.logger.isPiiLoggingEnabled();
8205
8503
  }
8206
8504
  /**
8207
8505
  * Http Get request
@@ -8210,10 +8508,10 @@ class HttpClient {
8210
8508
  */
8211
8509
  async sendGetRequestAsync(url, options, timeout) {
8212
8510
  if (this.proxyUrl) {
8213
- return networkRequestViaProxy(url, this.proxyUrl, HttpMethod.GET, options, this.customAgentOptions, timeout);
8511
+ return this.networkRequestViaProxy(HttpMethod.GET, url, options, timeout);
8214
8512
  }
8215
8513
  else {
8216
- return networkRequestViaHttps(url, HttpMethod.GET, options, this.customAgentOptions, timeout);
8514
+ return this.networkRequestViaHttps(HttpMethod.GET, url, options, timeout);
8217
8515
  }
8218
8516
  }
8219
8517
  /**
@@ -8223,255 +8521,13 @@ class HttpClient {
8223
8521
  */
8224
8522
  async sendPostRequestAsync(url, options) {
8225
8523
  if (this.proxyUrl) {
8226
- return networkRequestViaProxy(url, this.proxyUrl, HttpMethod.POST, options, this.customAgentOptions);
8524
+ return this.networkRequestViaProxy(HttpMethod.POST, url, options);
8227
8525
  }
8228
8526
  else {
8229
- return networkRequestViaHttps(url, HttpMethod.POST, options, this.customAgentOptions);
8230
- }
8231
- }
8232
- }
8233
- const networkRequestViaProxy = (destinationUrlString, proxyUrlString, httpMethod, options, agentOptions, timeout) => {
8234
- const destinationUrl = new URL(destinationUrlString);
8235
- const proxyUrl = new URL(proxyUrlString);
8236
- // "method: connect" must be used to establish a connection to the proxy
8237
- const headers = options?.headers || {};
8238
- const tunnelRequestOptions = {
8239
- host: proxyUrl.hostname,
8240
- port: proxyUrl.port,
8241
- method: "CONNECT",
8242
- path: destinationUrl.hostname,
8243
- headers: headers,
8244
- };
8245
- if (agentOptions && Object.keys(agentOptions).length) {
8246
- tunnelRequestOptions.agent = new http.Agent(agentOptions);
8247
- }
8248
- // compose a request string for the socket
8249
- let postRequestStringContent = "";
8250
- if (httpMethod === HttpMethod.POST) {
8251
- const body = options?.body || "";
8252
- postRequestStringContent =
8253
- "Content-Type: application/x-www-form-urlencoded\r\n" +
8254
- `Content-Length: ${body.length}\r\n` +
8255
- `\r\n${body}`;
8256
- }
8257
- else {
8258
- // optional timeout is only for get requests (regionDiscovery, for example)
8259
- if (timeout) {
8260
- tunnelRequestOptions.timeout = timeout;
8261
- }
8262
- }
8263
- const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` +
8264
- `Host: ${destinationUrl.host}\r\n` +
8265
- "Connection: close\r\n" +
8266
- postRequestStringContent +
8267
- "\r\n";
8268
- return new Promise((resolve, reject) => {
8269
- const request = http.request(tunnelRequestOptions);
8270
- if (timeout) {
8271
- request.on("timeout", () => {
8272
- request.destroy();
8273
- reject(new Error("Request time out"));
8274
- });
8275
- }
8276
- request.end();
8277
- // establish connection to the proxy
8278
- request.on("connect", (response, socket) => {
8279
- const proxyStatusCode = response?.statusCode || ProxyStatus.SERVER_ERROR;
8280
- if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START ||
8281
- proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
8282
- request.destroy();
8283
- socket.destroy();
8284
- reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${response?.statusMessage || "Unknown"}`));
8285
- }
8286
- // make a request over an HTTP tunnel
8287
- socket.write(outgoingRequestString);
8288
- const data = [];
8289
- socket.on("data", (chunk) => {
8290
- data.push(chunk);
8291
- });
8292
- socket.on("end", () => {
8293
- // combine all received buffer streams into one buffer, and then into a string
8294
- const dataString = Buffer.concat([...data]).toString();
8295
- // separate each line into it's own entry in an arry
8296
- const dataStringArray = dataString.split("\r\n");
8297
- // the first entry will contain the statusCode and statusMessage
8298
- const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]);
8299
- // remove "HTTP/1.1" and the status code to get the status message
8300
- const statusMessage = dataStringArray[0]
8301
- .split(" ")
8302
- .slice(2)
8303
- .join(" ");
8304
- // the last entry will contain the body
8305
- const body = dataStringArray[dataStringArray.length - 1];
8306
- // everything in between the first and last entries are the headers
8307
- const headersArray = dataStringArray.slice(1, dataStringArray.length - 2);
8308
- // build an object out of all the headers
8309
- const entries = new Map();
8310
- headersArray.forEach((header) => {
8311
- /**
8312
- * the header might look like "Content-Length: 1531", but that is just a string
8313
- * it needs to be converted to a key/value pair
8314
- * split the string at the first instance of ":"
8315
- * there may be more than one ":" if the value of the header is supposed to be a JSON object
8316
- */
8317
- const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
8318
- const headerKey = headerKeyValue[0];
8319
- let headerValue = headerKeyValue[1];
8320
- // check if the value of the header is supposed to be a JSON object
8321
- try {
8322
- const object = JSON.parse(headerValue);
8323
- // if it is, then convert it from a string to a JSON object
8324
- if (object && typeof object === "object") {
8325
- headerValue = object;
8326
- }
8327
- }
8328
- catch (e) {
8329
- // otherwise, leave it as a string
8330
- }
8331
- entries.set(headerKey, headerValue);
8332
- });
8333
- const headers = Object.fromEntries(entries);
8334
- const parsedHeaders = headers;
8335
- const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
8336
- if ((httpStatusCode < HttpStatus.SUCCESS_RANGE_START ||
8337
- httpStatusCode > HttpStatus.SUCCESS_RANGE_END) &&
8338
- // do not destroy the request for the device code flow
8339
- networkResponse.body["error"] !==
8340
- Constants.AUTHORIZATION_PENDING) {
8341
- request.destroy();
8342
- }
8343
- resolve(networkResponse);
8344
- });
8345
- socket.on("error", (chunk) => {
8346
- request.destroy();
8347
- socket.destroy();
8348
- reject(new Error(chunk.toString()));
8349
- });
8350
- });
8351
- request.on("error", (chunk) => {
8352
- request.destroy();
8353
- reject(new Error(chunk.toString()));
8354
- });
8355
- });
8356
- };
8357
- const networkRequestViaHttps = (urlString, httpMethod, options, agentOptions, timeout) => {
8358
- const isPostRequest = httpMethod === HttpMethod.POST;
8359
- const body = options?.body || "";
8360
- const url = new URL(urlString);
8361
- const headers = options?.headers || {};
8362
- const customOptions = {
8363
- method: httpMethod,
8364
- headers: headers,
8365
- ...NetworkUtils.urlToHttpOptions(url),
8366
- };
8367
- if (agentOptions && Object.keys(agentOptions).length) {
8368
- customOptions.agent = new https.Agent(agentOptions);
8369
- }
8370
- if (isPostRequest) {
8371
- // needed for post request to work
8372
- customOptions.headers = {
8373
- ...customOptions.headers,
8374
- "Content-Length": body.length,
8375
- };
8376
- }
8377
- else {
8378
- // optional timeout is only for get requests (regionDiscovery, for example)
8379
- if (timeout) {
8380
- customOptions.timeout = timeout;
8527
+ return this.networkRequestViaHttps(HttpMethod.POST, url, options);
8381
8528
  }
8382
8529
  }
8383
- return new Promise((resolve, reject) => {
8384
- let request;
8385
- // managed identity sources use http instead of https
8386
- if (customOptions.protocol === "http:") {
8387
- request = http.request(customOptions);
8388
- }
8389
- else {
8390
- request = https.request(customOptions);
8391
- }
8392
- if (isPostRequest) {
8393
- request.write(body);
8394
- }
8395
- if (timeout) {
8396
- request.on("timeout", () => {
8397
- request.destroy();
8398
- reject(new Error("Request time out"));
8399
- });
8400
- }
8401
- request.end();
8402
- request.on("response", (response) => {
8403
- const headers = response.headers;
8404
- const statusCode = response.statusCode;
8405
- const statusMessage = response.statusMessage;
8406
- const data = [];
8407
- response.on("data", (chunk) => {
8408
- data.push(chunk);
8409
- });
8410
- response.on("end", () => {
8411
- // combine all received buffer streams into one buffer, and then into a string
8412
- const body = Buffer.concat([...data]).toString();
8413
- const parsedHeaders = headers;
8414
- const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
8415
- if ((statusCode < HttpStatus.SUCCESS_RANGE_START ||
8416
- statusCode > HttpStatus.SUCCESS_RANGE_END) &&
8417
- // do not destroy the request for the device code flow
8418
- networkResponse.body["error"] !==
8419
- Constants.AUTHORIZATION_PENDING) {
8420
- request.destroy();
8421
- }
8422
- resolve(networkResponse);
8423
- });
8424
- });
8425
- request.on("error", (chunk) => {
8426
- request.destroy();
8427
- reject(new Error(chunk.toString()));
8428
- });
8429
- });
8430
- };
8431
- /**
8432
- * Check if extra parsing is needed on the repsonse from the server
8433
- * @param statusCode {number} the status code of the response from the server
8434
- * @param statusMessage {string | undefined} the status message of the response from the server
8435
- * @param headers {Record<string, string>} the headers of the response from the server
8436
- * @param body {string} the body from the response of the server
8437
- * @returns {Object} JSON parsed body or error object
8438
- */
8439
- const parseBody = (statusCode, statusMessage, headers, body) => {
8440
- /*
8441
- * Informational responses (100 – 199)
8442
- * Successful responses (200 – 299)
8443
- * Redirection messages (300 – 399)
8444
- * Client error responses (400 – 499)
8445
- * Server error responses (500 – 599)
8446
- */
8447
- let parsedBody;
8448
- try {
8449
- parsedBody = JSON.parse(body);
8450
- }
8451
- catch (error) {
8452
- let errorType;
8453
- let errorDescriptionHelper;
8454
- if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START &&
8455
- statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
8456
- errorType = "client_error";
8457
- errorDescriptionHelper = "A client";
8458
- }
8459
- else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START &&
8460
- statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
8461
- errorType = "server_error";
8462
- errorDescriptionHelper = "A server";
8463
- }
8464
- else {
8465
- errorType = "unknown_error";
8466
- errorDescriptionHelper = "An unknown";
8467
- }
8468
- parsedBody = {
8469
- error: errorType,
8470
- error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`,
8471
- };
8472
- }
8473
- return parsedBody;
8474
- };
8530
+ }
8475
8531
 
8476
8532
  /*
8477
8533
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9909,10 +9965,6 @@ class ClientAssertion {
9909
9965
  }
9910
9966
  }
9911
9967
 
9912
- /* eslint-disable header/header */
9913
- const name = "@azure/msal-node";
9914
- const version = "3.8.1";
9915
-
9916
9968
  /*
9917
9969
  * Copyright (c) Microsoft Corporation. All rights reserved.
9918
9970
  * Licensed under the MIT License.