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/esm/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.
|
1
|
+
// Axios v1.6.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
2
2
|
function bind(fn, thisArg) {
|
3
3
|
return function wrap() {
|
4
4
|
return fn.apply(thisArg, arguments);
|
@@ -543,8 +543,9 @@ const reduceDescriptors = (obj, reducer) => {
|
|
543
543
|
const reducedDescriptors = {};
|
544
544
|
|
545
545
|
forEach(descriptors, (descriptor, name) => {
|
546
|
-
|
547
|
-
|
546
|
+
let ret;
|
547
|
+
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
548
|
+
reducedDescriptors[name] = ret || descriptor;
|
548
549
|
}
|
549
550
|
});
|
550
551
|
|
@@ -1386,10 +1387,6 @@ function formDataToJSON(formData) {
|
|
1386
1387
|
return null;
|
1387
1388
|
}
|
1388
1389
|
|
1389
|
-
const DEFAULT_CONTENT_TYPE = {
|
1390
|
-
'Content-Type': undefined
|
1391
|
-
};
|
1392
|
-
|
1393
1390
|
/**
|
1394
1391
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
1395
1392
|
* of the input
|
@@ -1528,19 +1525,16 @@ const defaults = {
|
|
1528
1525
|
|
1529
1526
|
headers: {
|
1530
1527
|
common: {
|
1531
|
-
'Accept': 'application/json, text/plain, */*'
|
1528
|
+
'Accept': 'application/json, text/plain, */*',
|
1529
|
+
'Content-Type': undefined
|
1532
1530
|
}
|
1533
1531
|
}
|
1534
1532
|
};
|
1535
1533
|
|
1536
|
-
utils.forEach(['delete', 'get', 'head'],
|
1534
|
+
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
1537
1535
|
defaults.headers[method] = {};
|
1538
1536
|
});
|
1539
1537
|
|
1540
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
1541
|
-
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
1542
|
-
});
|
1543
|
-
|
1544
1538
|
const defaults$1 = defaults;
|
1545
1539
|
|
1546
1540
|
// RawAxiosHeaders whose duplicates are ignored by node
|
@@ -1874,7 +1868,17 @@ class AxiosHeaders$1 {
|
|
1874
1868
|
|
1875
1869
|
AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
1876
1870
|
|
1877
|
-
|
1871
|
+
// reserved names hotfix
|
1872
|
+
utils.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
|
1873
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
1874
|
+
return {
|
1875
|
+
get: () => value,
|
1876
|
+
set(headerValue) {
|
1877
|
+
this[mapped] = headerValue;
|
1878
|
+
}
|
1879
|
+
}
|
1880
|
+
});
|
1881
|
+
|
1878
1882
|
utils.freezeMethods(AxiosHeaders$1);
|
1879
1883
|
|
1880
1884
|
const AxiosHeaders$2 = AxiosHeaders$1;
|
@@ -2209,11 +2213,16 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
2209
2213
|
}
|
2210
2214
|
}
|
2211
2215
|
|
2216
|
+
let contentType;
|
2217
|
+
|
2212
2218
|
if (utils.isFormData(requestData)) {
|
2213
2219
|
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
|
2214
2220
|
requestHeaders.setContentType(false); // Let the browser set it
|
2215
|
-
} else {
|
2216
|
-
requestHeaders.setContentType('multipart/form-data
|
2221
|
+
} else if(!requestHeaders.getContentType(/^\s*multipart\/form-data/)){
|
2222
|
+
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
|
2223
|
+
} else if(utils.isString(contentType = requestHeaders.getContentType())){
|
2224
|
+
// fix semicolon duplication issue for ReactNative FormData implementation
|
2225
|
+
requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, '$1'));
|
2217
2226
|
}
|
2218
2227
|
}
|
2219
2228
|
|
@@ -2331,8 +2340,8 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
2331
2340
|
// Specifically not if we're in a web worker, or react-native.
|
2332
2341
|
if (platform.isStandardBrowserEnv) {
|
2333
2342
|
// Add xsrf header
|
2334
|
-
|
2335
|
-
|
2343
|
+
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
|
2344
|
+
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
2336
2345
|
|
2337
2346
|
if (xsrfValue) {
|
2338
2347
|
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
@@ -2406,7 +2415,7 @@ const knownAdapters = {
|
|
2406
2415
|
};
|
2407
2416
|
|
2408
2417
|
utils.forEach(knownAdapters, (fn, value) => {
|
2409
|
-
if(fn) {
|
2418
|
+
if (fn) {
|
2410
2419
|
try {
|
2411
2420
|
Object.defineProperty(fn, 'name', {value});
|
2412
2421
|
} catch (e) {
|
@@ -2416,6 +2425,10 @@ utils.forEach(knownAdapters, (fn, value) => {
|
|
2416
2425
|
}
|
2417
2426
|
});
|
2418
2427
|
|
2428
|
+
const renderReason = (reason) => `- ${reason}`;
|
2429
|
+
|
2430
|
+
const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;
|
2431
|
+
|
2419
2432
|
const adapters = {
|
2420
2433
|
getAdapter: (adapters) => {
|
2421
2434
|
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
@@ -2424,30 +2437,44 @@ const adapters = {
|
|
2424
2437
|
let nameOrAdapter;
|
2425
2438
|
let adapter;
|
2426
2439
|
|
2440
|
+
const rejectedReasons = {};
|
2441
|
+
|
2427
2442
|
for (let i = 0; i < length; i++) {
|
2428
2443
|
nameOrAdapter = adapters[i];
|
2429
|
-
|
2444
|
+
let id;
|
2445
|
+
|
2446
|
+
adapter = nameOrAdapter;
|
2447
|
+
|
2448
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
2449
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
2450
|
+
|
2451
|
+
if (adapter === undefined) {
|
2452
|
+
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
2453
|
+
}
|
2454
|
+
}
|
2455
|
+
|
2456
|
+
if (adapter) {
|
2430
2457
|
break;
|
2431
2458
|
}
|
2459
|
+
|
2460
|
+
rejectedReasons[id || '#' + i] = adapter;
|
2432
2461
|
}
|
2433
2462
|
|
2434
2463
|
if (!adapter) {
|
2435
|
-
|
2436
|
-
|
2437
|
-
|
2438
|
-
'
|
2464
|
+
|
2465
|
+
const reasons = Object.entries(rejectedReasons)
|
2466
|
+
.map(([id, state]) => `adapter ${id} ` +
|
2467
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
2439
2468
|
);
|
2440
|
-
}
|
2441
2469
|
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
`Unknown adapter '${nameOrAdapter}'`
|
2446
|
-
);
|
2447
|
-
}
|
2470
|
+
let s = length ?
|
2471
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
2472
|
+
'as no adapter specified';
|
2448
2473
|
|
2449
|
-
|
2450
|
-
|
2474
|
+
throw new AxiosError$1(
|
2475
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
2476
|
+
'ERR_NOT_SUPPORT'
|
2477
|
+
);
|
2451
2478
|
}
|
2452
2479
|
|
2453
2480
|
return adapter;
|
@@ -2629,7 +2656,7 @@ function mergeConfig$1(config1, config2) {
|
|
2629
2656
|
return config;
|
2630
2657
|
}
|
2631
2658
|
|
2632
|
-
const VERSION$1 = "1.
|
2659
|
+
const VERSION$1 = "1.6.0";
|
2633
2660
|
|
2634
2661
|
const validators$1 = {};
|
2635
2662
|
|
@@ -2782,15 +2809,13 @@ class Axios$1 {
|
|
2782
2809
|
// Set config.method
|
2783
2810
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
2784
2811
|
|
2785
|
-
let contextHeaders;
|
2786
|
-
|
2787
2812
|
// Flatten headers
|
2788
|
-
contextHeaders = headers && utils.merge(
|
2813
|
+
let contextHeaders = headers && utils.merge(
|
2789
2814
|
headers.common,
|
2790
2815
|
headers[config.method]
|
2791
2816
|
);
|
2792
2817
|
|
2793
|
-
|
2818
|
+
headers && utils.forEach(
|
2794
2819
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
2795
2820
|
(method) => {
|
2796
2821
|
delete headers[method];
|
@@ -3200,6 +3225,8 @@ axios.AxiosHeaders = AxiosHeaders$2;
|
|
3200
3225
|
|
3201
3226
|
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
3202
3227
|
|
3228
|
+
axios.getAdapter = adapters.getAdapter;
|
3229
|
+
|
3203
3230
|
axios.HttpStatusCode = HttpStatusCode$2;
|
3204
3231
|
|
3205
3232
|
axios.default = axios;
|
@@ -3225,8 +3252,9 @@ const {
|
|
3225
3252
|
AxiosHeaders,
|
3226
3253
|
HttpStatusCode,
|
3227
3254
|
formToJSON,
|
3255
|
+
getAdapter,
|
3228
3256
|
mergeConfig
|
3229
3257
|
} = axios$1;
|
3230
3258
|
|
3231
|
-
export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, mergeConfig, spread, toFormData };
|
3259
|
+
export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, getAdapter, isAxiosError, isCancel, mergeConfig, spread, toFormData };
|
3232
3260
|
//# sourceMappingURL=axios.js.map
|