axios 1.4.0 → 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.
- package/CHANGELOG.md +204 -0
- package/README.md +301 -12
- package/dist/axios.js +58 -29
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +65 -38
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +67 -39
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +93 -51
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +20 -11
- package/index.d.ts +23 -12
- package/index.js +2 -0
- package/lib/adapters/adapters.js +33 -15
- package/lib/adapters/http.js +28 -13
- package/lib/adapters/xhr.js +9 -4
- package/lib/axios.js +3 -0
- package/lib/core/Axios.js +2 -4
- package/lib/core/AxiosHeaders.js +11 -1
- package/lib/defaults/index.js +3 -10
- package/lib/env/data.js +1 -1
- package/lib/utils.js +3 -2
- package/package.json +3 -1
package/dist/browser/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.
|
1
|
+
// Axios v1.6.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
function bind(fn, thisArg) {
|
@@ -545,8 +545,9 @@ const reduceDescriptors = (obj, reducer) => {
|
|
545
545
|
const reducedDescriptors = {};
|
546
546
|
|
547
547
|
forEach(descriptors, (descriptor, name) => {
|
548
|
-
|
549
|
-
|
548
|
+
let ret;
|
549
|
+
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
550
|
+
reducedDescriptors[name] = ret || descriptor;
|
550
551
|
}
|
551
552
|
});
|
552
553
|
|
@@ -1388,10 +1389,6 @@ function formDataToJSON(formData) {
|
|
1388
1389
|
return null;
|
1389
1390
|
}
|
1390
1391
|
|
1391
|
-
const DEFAULT_CONTENT_TYPE = {
|
1392
|
-
'Content-Type': undefined
|
1393
|
-
};
|
1394
|
-
|
1395
1392
|
/**
|
1396
1393
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1397
1394
|
* of the input
|
@@ -1530,19 +1527,16 @@ const defaults = {
|
|
1530
1527
|
|
1531
1528
|
headers: {
|
1532
1529
|
common: {
|
1533
|
-
'Accept': 'application/json, text/plain, */*'
|
1530
|
+
'Accept': 'application/json, text/plain, */*',
|
1531
|
+
'Content-Type': undefined
|
1534
1532
|
}
|
1535
1533
|
}
|
1536
1534
|
};
|
1537
1535
|
|
1538
|
-
utils.forEach(['delete', 'get', 'head'],
|
1536
|
+
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
1539
1537
|
defaults.headers[method] = {};
|
1540
1538
|
});
|
1541
1539
|
|
1542
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
1543
|
-
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
1544
|
-
});
|
1545
|
-
|
1546
1540
|
var defaults$1 = defaults;
|
1547
1541
|
|
1548
1542
|
// RawAxiosHeaders whose duplicates are ignored by node
|
@@ -1876,7 +1870,17 @@ class AxiosHeaders {
|
|
1876
1870
|
|
1877
1871
|
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
1878
1872
|
|
1879
|
-
|
1873
|
+
// reserved names hotfix
|
1874
|
+
utils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
1875
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
1876
|
+
return {
|
1877
|
+
get: () => value,
|
1878
|
+
set(headerValue) {
|
1879
|
+
this[mapped] = headerValue;
|
1880
|
+
}
|
1881
|
+
}
|
1882
|
+
});
|
1883
|
+
|
1880
1884
|
utils.freezeMethods(AxiosHeaders);
|
1881
1885
|
|
1882
1886
|
var AxiosHeaders$1 = AxiosHeaders;
|
@@ -2211,11 +2215,16 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
2211
2215
|
}
|
2212
2216
|
}
|
2213
2217
|
|
2218
|
+
let contentType;
|
2219
|
+
|
2214
2220
|
if (utils.isFormData(requestData)) {
|
2215
2221
|
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
|
2216
2222
|
requestHeaders.setContentType(false); // Let the browser set it
|
2217
|
-
} else {
|
2218
|
-
requestHeaders.setContentType('multipart/form-data
|
2223
|
+
} else if(!requestHeaders.getContentType(/^\s*multipart\/form-data/)){
|
2224
|
+
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
|
2225
|
+
} else if(utils.isString(contentType = requestHeaders.getContentType())){
|
2226
|
+
// fix semicolon duplication issue for ReactNative FormData implementation
|
2227
|
+
requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, '$1'));
|
2219
2228
|
}
|
2220
2229
|
}
|
2221
2230
|
|
@@ -2333,8 +2342,8 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
2333
2342
|
// Specifically not if we're in a web worker, or react-native.
|
2334
2343
|
if (platform.isStandardBrowserEnv) {
|
2335
2344
|
// Add xsrf header
|
2336
|
-
|
2337
|
-
|
2345
|
+
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
|
2346
|
+
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
2338
2347
|
|
2339
2348
|
if (xsrfValue) {
|
2340
2349
|
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
@@ -2408,7 +2417,7 @@ const knownAdapters = {
|
|
2408
2417
|
};
|
2409
2418
|
|
2410
2419
|
utils.forEach(knownAdapters, (fn, value) => {
|
2411
|
-
if(fn) {
|
2420
|
+
if (fn) {
|
2412
2421
|
try {
|
2413
2422
|
Object.defineProperty(fn, 'name', {value});
|
2414
2423
|
} catch (e) {
|
@@ -2418,6 +2427,10 @@ utils.forEach(knownAdapters, (fn, value) => {
|
|
2418
2427
|
}
|
2419
2428
|
});
|
2420
2429
|
|
2430
|
+
const renderReason = (reason) => `- ${reason}`;
|
2431
|
+
|
2432
|
+
const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;
|
2433
|
+
|
2421
2434
|
var adapters = {
|
2422
2435
|
getAdapter: (adapters) => {
|
2423
2436
|
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
@@ -2426,30 +2439,44 @@ var adapters = {
|
|
2426
2439
|
let nameOrAdapter;
|
2427
2440
|
let adapter;
|
2428
2441
|
|
2442
|
+
const rejectedReasons = {};
|
2443
|
+
|
2429
2444
|
for (let i = 0; i < length; i++) {
|
2430
2445
|
nameOrAdapter = adapters[i];
|
2431
|
-
|
2446
|
+
let id;
|
2447
|
+
|
2448
|
+
adapter = nameOrAdapter;
|
2449
|
+
|
2450
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
2451
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
2452
|
+
|
2453
|
+
if (adapter === undefined) {
|
2454
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
2455
|
+
}
|
2456
|
+
}
|
2457
|
+
|
2458
|
+
if (adapter) {
|
2432
2459
|
break;
|
2433
2460
|
}
|
2461
|
+
|
2462
|
+
rejectedReasons[id || '#' + i] = adapter;
|
2434
2463
|
}
|
2435
2464
|
|
2436
2465
|
if (!adapter) {
|
2437
|
-
|
2438
|
-
|
2439
|
-
|
2440
|
-
'
|
2466
|
+
|
2467
|
+
const reasons = Object.entries(rejectedReasons)
|
2468
|
+
.map(([id, state]) => `adapter ${id} ` +
|
2469
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
2441
2470
|
);
|
2442
|
-
}
|
2443
2471
|
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
`Unknown adapter '${nameOrAdapter}'`
|
2448
|
-
);
|
2449
|
-
}
|
2472
|
+
let s = length ?
|
2473
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
2474
|
+
'as no adapter specified';
|
2450
2475
|
|
2451
|
-
|
2452
|
-
|
2476
|
+
throw new AxiosError(
|
2477
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
2478
|
+
'ERR_NOT_SUPPORT'
|
2479
|
+
);
|
2453
2480
|
}
|
2454
2481
|
|
2455
2482
|
return adapter;
|
@@ -2631,7 +2658,7 @@ function mergeConfig(config1, config2) {
|
|
2631
2658
|
return config;
|
2632
2659
|
}
|
2633
2660
|
|
2634
|
-
const VERSION = "1.
|
2661
|
+
const VERSION = "1.6.0";
|
2635
2662
|
|
2636
2663
|
const validators$1 = {};
|
2637
2664
|
|
@@ -2784,15 +2811,13 @@ class Axios {
|
|
2784
2811
|
// Set config.method
|
2785
2812
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
2786
2813
|
|
2787
|
-
let contextHeaders;
|
2788
|
-
|
2789
2814
|
// Flatten headers
|
2790
|
-
contextHeaders = headers && utils.merge(
|
2815
|
+
let contextHeaders = headers && utils.merge(
|
2791
2816
|
headers.common,
|
2792
2817
|
headers[config.method]
|
2793
2818
|
);
|
2794
2819
|
|
2795
|
-
|
2820
|
+
headers && utils.forEach(
|
2796
2821
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
2797
2822
|
(method) => {
|
2798
2823
|
delete headers[method];
|
@@ -3202,6 +3227,8 @@ axios.AxiosHeaders = AxiosHeaders$1;
|
|
3202
3227
|
|
3203
3228
|
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
3204
3229
|
|
3230
|
+
axios.getAdapter = adapters.getAdapter;
|
3231
|
+
|
3205
3232
|
axios.HttpStatusCode = HttpStatusCode$1;
|
3206
3233
|
|
3207
3234
|
axios.default = axios;
|