axios 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

@@ -1,4 +1,4 @@
1
- // Axios v1.5.1 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.6.0 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -1965,7 +1965,7 @@ function buildFullPath(baseURL, requestedURL) {
1965
1965
  return requestedURL;
1966
1966
  }
1967
1967
 
1968
- const VERSION = "1.5.1";
1968
+ const VERSION = "1.6.0";
1969
1969
 
1970
1970
  function parseProtocol(url) {
1971
1971
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2569,6 +2569,18 @@ const wrapAsync = (asyncExecutor) => {
2569
2569
  })
2570
2570
  };
2571
2571
 
2572
+ const resolveFamily = ({address, family}) => {
2573
+ if (!utils.isString(address)) {
2574
+ throw TypeError('address must be a string');
2575
+ }
2576
+ return ({
2577
+ address,
2578
+ family: family || (address.indexOf('.') < 0 ? 6 : 4)
2579
+ });
2580
+ };
2581
+
2582
+ const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(address) ? address : {address, family});
2583
+
2572
2584
  /*eslint consistent-return:0*/
2573
2585
  const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2574
2586
  return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
@@ -2579,15 +2591,16 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2579
2591
  let rejected = false;
2580
2592
  let req;
2581
2593
 
2582
- if (lookup && utils.isAsyncFn(lookup)) {
2583
- lookup = callbackify$1(lookup, (entry) => {
2584
- if(utils.isString(entry)) {
2585
- entry = [entry, entry.indexOf('.') < 0 ? 6 : 4];
2586
- } else if (!utils.isArray(entry)) {
2587
- throw new TypeError('lookup async function must return an array [ip: string, family: number]]')
2588
- }
2589
- return entry;
2590
- });
2594
+ if (lookup) {
2595
+ const _lookup = callbackify$1(lookup, (value) => utils.isArray(value) ? value : [value]);
2596
+ // hotfix to support opt.all option which is required for node 20.x
2597
+ lookup = (hostname, opt, cb) => {
2598
+ _lookup(hostname, opt, (err, arg0, arg1) => {
2599
+ const addresses = utils.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
2600
+
2601
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
2602
+ });
2603
+ };
2591
2604
  }
2592
2605
 
2593
2606
  // temporary internal emitter until the AxiosRequest class will be implemented
@@ -2990,7 +3003,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2990
3003
  }
2991
3004
  response.data = responseData;
2992
3005
  } catch (err) {
2993
- reject(AxiosError.from(err, null, config, response.request, response));
3006
+ return reject(AxiosError.from(err, null, config, response.request, response));
2994
3007
  }
2995
3008
  settle(resolve, reject, response);
2996
3009
  });
@@ -3373,8 +3386,8 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3373
3386
  // Specifically not if we're in a web worker, or react-native.
3374
3387
  if (platform.isStandardBrowserEnv) {
3375
3388
  // Add xsrf header
3376
- const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
3377
- && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
3389
+ // regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
3390
+ const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
3378
3391
 
3379
3392
  if (xsrfValue) {
3380
3393
  requestHeaders.set(config.xsrfHeaderName, xsrfValue);