axios 0.33.0 → 0.34.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.
- package/CHANGELOG.md +20 -0
- package/README.md +70 -1
- package/dist/axios.js +177 -27
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/esm/axios.js +177 -27
- 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/index.d.ts +5 -1
- package/lib/adapters/http.js +54 -5
- package/lib/adapters/xhr.js +2 -2
- package/lib/cancel/fromSignal.js +20 -0
- package/lib/core/Axios.js +78 -10
- package/lib/core/dispatchRequest.js +5 -4
- package/lib/core/mergeConfig.js +7 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/shouldBypassProxy.js +212 -1
- package/lib/helpers/toFormData.js +35 -8
- package/lib/utils.js +33 -3
- package/package.json +1 -1
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.34.0 Copyright (c) 2026 Matt Zabriskie
|
|
2
2
|
var bind = function bind(fn, thisArg) {
|
|
3
3
|
return function wrap() {
|
|
4
4
|
return fn.apply(thisArg, arguments);
|
|
@@ -396,6 +396,15 @@ function stripBOM(content) {
|
|
|
396
396
|
return content;
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
+
function defineOwnProperty(target, key, value) {
|
|
400
|
+
var descriptor = Object.create(null);
|
|
401
|
+
descriptor.value = value;
|
|
402
|
+
descriptor.writable = true;
|
|
403
|
+
descriptor.enumerable = true;
|
|
404
|
+
descriptor.configurable = true;
|
|
405
|
+
Object.defineProperty(target, key, descriptor);
|
|
406
|
+
}
|
|
407
|
+
|
|
399
408
|
/**
|
|
400
409
|
* Inherit the prototype methods from one constructor into another
|
|
401
410
|
* @param {function} constructor
|
|
@@ -403,14 +412,35 @@ function stripBOM(content) {
|
|
|
403
412
|
* @param {object} [props]
|
|
404
413
|
* @param {object} [descriptors]
|
|
405
414
|
*/
|
|
406
|
-
|
|
407
415
|
function inherits(constructor, superConstructor, props, descriptors) {
|
|
408
416
|
constructor.prototype = Object.create(
|
|
409
417
|
superConstructor.prototype,
|
|
410
418
|
descriptors
|
|
411
419
|
);
|
|
412
|
-
|
|
413
|
-
|
|
420
|
+
if (Object.prototype.hasOwnProperty.call(constructor.prototype, 'constructor')) {
|
|
421
|
+
constructor.prototype.constructor = constructor;
|
|
422
|
+
} else {
|
|
423
|
+
defineOwnProperty(constructor.prototype, 'constructor', constructor);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (props) {
|
|
427
|
+
var keys = Object.keys(props);
|
|
428
|
+
if (Object.getOwnPropertySymbols) {
|
|
429
|
+
keys = keys.concat(Object.getOwnPropertySymbols(props).filter(function(key) {
|
|
430
|
+
return Object.prototype.propertyIsEnumerable.call(props, key);
|
|
431
|
+
}));
|
|
432
|
+
}
|
|
433
|
+
keys.forEach(function(key) {
|
|
434
|
+
var value = props[key];
|
|
435
|
+
if (Object.prototype.hasOwnProperty.call(constructor.prototype, key)) {
|
|
436
|
+
constructor.prototype[key] = value;
|
|
437
|
+
} else {
|
|
438
|
+
// Assignment would invoke an inherited setter or fail on a read-only
|
|
439
|
+
// property installed by another library, such as Error.prototype.toJSON.
|
|
440
|
+
defineOwnProperty(constructor.prototype, key, value);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
}
|
|
414
444
|
}
|
|
415
445
|
|
|
416
446
|
/**
|
|
@@ -773,6 +803,40 @@ function isSpecCompliant(thing) {
|
|
|
773
803
|
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
|
774
804
|
}
|
|
775
805
|
|
|
806
|
+
var UNSAFE_OPTION_KEYS = ['__proto__', 'constructor', 'prototype'];
|
|
807
|
+
|
|
808
|
+
// Materialises the serializer options onto a null-prototype object. Reading the
|
|
809
|
+
// options from a plain object let a polluted Object.prototype supply a visitor,
|
|
810
|
+
// a depth limit, a Blob implementation or key-format flags that the caller never
|
|
811
|
+
// asked for, and also let a polluted key mask an option the caller did set.
|
|
812
|
+
// Only own, defined properties of the caller's options are carried over.
|
|
813
|
+
function toFormDataOptions(source) {
|
|
814
|
+
var options = Object.create(null);
|
|
815
|
+
|
|
816
|
+
options.metaTokens = true;
|
|
817
|
+
options.dots = false;
|
|
818
|
+
options.indexes = false;
|
|
819
|
+
|
|
820
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
821
|
+
if (source == null) {
|
|
822
|
+
return options;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
var names = Object.getOwnPropertyNames(source);
|
|
826
|
+
|
|
827
|
+
for (var i = 0; i < names.length; i++) {
|
|
828
|
+
var name = names[i];
|
|
829
|
+
|
|
830
|
+
if (UNSAFE_OPTION_KEYS.indexOf(name) !== -1 || utils.isUndefined(source[name])) {
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
options[name] = source[name];
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
return options;
|
|
838
|
+
}
|
|
839
|
+
|
|
776
840
|
/**
|
|
777
841
|
* Convert a data object to FormData
|
|
778
842
|
* @param {Object} obj
|
|
@@ -794,14 +858,7 @@ function toFormData(obj, formData, options) {
|
|
|
794
858
|
formData = formData || new (FormData$1 || FormData)();
|
|
795
859
|
|
|
796
860
|
// eslint-disable-next-line no-param-reassign
|
|
797
|
-
options =
|
|
798
|
-
metaTokens: true,
|
|
799
|
-
dots: false,
|
|
800
|
-
indexes: false
|
|
801
|
-
}, false, function defined(option, source) {
|
|
802
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
803
|
-
return !utils.isUndefined(source[option]);
|
|
804
|
-
});
|
|
861
|
+
options = toFormDataOptions(options);
|
|
805
862
|
|
|
806
863
|
var metaTokens = options.metaTokens;
|
|
807
864
|
// eslint-disable-next-line no-use-before-define
|
|
@@ -1513,6 +1570,23 @@ utils.inherits(CanceledError, AxiosError_1, {
|
|
|
1513
1570
|
|
|
1514
1571
|
var CanceledError_1 = CanceledError;
|
|
1515
1572
|
|
|
1573
|
+
var fromSignal = function fromSignal(signal, config, request) {
|
|
1574
|
+
var error = new CanceledError_1(null, config, request);
|
|
1575
|
+
|
|
1576
|
+
if (signal) {
|
|
1577
|
+
try {
|
|
1578
|
+
var reason = signal.reason;
|
|
1579
|
+
if (reason !== undefined) {
|
|
1580
|
+
error.reason = reason;
|
|
1581
|
+
}
|
|
1582
|
+
} catch (e) {
|
|
1583
|
+
// A custom signal getter must not prevent cancellation.
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
return error;
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1516
1590
|
var parseProtocol = function parseProtocol(url) {
|
|
1517
1591
|
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
1518
1592
|
return match && match[1] || '';
|
|
@@ -1766,7 +1840,7 @@ var xhr = function xhrAdapter(config) {
|
|
|
1766
1840
|
}
|
|
1767
1841
|
reject(
|
|
1768
1842
|
!cancel || cancel.type
|
|
1769
|
-
?
|
|
1843
|
+
? fromSignal(config.signal, config, request)
|
|
1770
1844
|
: cancel
|
|
1771
1845
|
);
|
|
1772
1846
|
request.abort();
|
|
@@ -2030,7 +2104,7 @@ function throwIfCancellationRequested(config) {
|
|
|
2030
2104
|
}
|
|
2031
2105
|
|
|
2032
2106
|
if (config.signal && config.signal.aborted) {
|
|
2033
|
-
throw
|
|
2107
|
+
throw fromSignal(config.signal, config);
|
|
2034
2108
|
}
|
|
2035
2109
|
}
|
|
2036
2110
|
|
|
@@ -2043,8 +2117,9 @@ function throwIfCancellationRequested(config) {
|
|
|
2043
2117
|
var dispatchRequest = function dispatchRequest(config) {
|
|
2044
2118
|
throwIfCancellationRequested(config);
|
|
2045
2119
|
|
|
2046
|
-
// Ensure headers exist
|
|
2047
|
-
|
|
2120
|
+
// Ensure headers exist. A request interceptor may return a replacement config
|
|
2121
|
+
// that inherits from Object.prototype, so only an own headers value is used.
|
|
2122
|
+
config.headers = (utils.hasOwnProperty(config, 'headers') && config.headers) || {};
|
|
2048
2123
|
|
|
2049
2124
|
// Transform request data
|
|
2050
2125
|
config.data = transformData.call(
|
|
@@ -2177,6 +2252,11 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
2177
2252
|
}
|
|
2178
2253
|
}
|
|
2179
2254
|
|
|
2255
|
+
function defaultToConfig2Reference(prop) {
|
|
2256
|
+
var value = getOwn(config2, prop);
|
|
2257
|
+
return utils.isUndefined(value) ? getOwn(config1, prop) : value;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2180
2260
|
// eslint-disable-next-line consistent-return
|
|
2181
2261
|
function mergeDirectKeys(prop) {
|
|
2182
2262
|
if (hasOwn(config2, prop)) {
|
|
@@ -2212,6 +2292,8 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
2212
2292
|
'httpAgent': defaultToConfig2,
|
|
2213
2293
|
'httpsAgent': defaultToConfig2,
|
|
2214
2294
|
'cancelToken': defaultToConfig2,
|
|
2295
|
+
// Signals are live objects; cloning them snapshots getters and reasons.
|
|
2296
|
+
'signal': defaultToConfig2Reference,
|
|
2215
2297
|
'socketPath': defaultToConfig2,
|
|
2216
2298
|
'allowedSocketPaths': defaultToConfig2,
|
|
2217
2299
|
'responseEncoding': defaultToConfig2,
|
|
@@ -2231,7 +2313,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
2231
2313
|
};
|
|
2232
2314
|
|
|
2233
2315
|
var data = {
|
|
2234
|
-
"version": "0.
|
|
2316
|
+
"version": "0.34.0"
|
|
2235
2317
|
};
|
|
2236
2318
|
|
|
2237
2319
|
var VERSION = data.version;
|
|
@@ -2320,6 +2402,56 @@ var validator = {
|
|
|
2320
2402
|
};
|
|
2321
2403
|
|
|
2322
2404
|
var validators = validator.validators;
|
|
2405
|
+
|
|
2406
|
+
function captureCallerStack(boundary) {
|
|
2407
|
+
var caller = {};
|
|
2408
|
+
try {
|
|
2409
|
+
if (Error.captureStackTrace) {
|
|
2410
|
+
Error.captureStackTrace(caller, boundary);
|
|
2411
|
+
} else {
|
|
2412
|
+
caller = new Error();
|
|
2413
|
+
}
|
|
2414
|
+
} catch (e) {
|
|
2415
|
+
// Stack hooks must not prevent a request from being sent.
|
|
2416
|
+
}
|
|
2417
|
+
return caller;
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
function attachCallerStack(promise, caller) {
|
|
2421
|
+
if (!caller) {
|
|
2422
|
+
return promise;
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
return promise.then(null, function onRequestRejected(error) {
|
|
2426
|
+
try {
|
|
2427
|
+
if (error instanceof Error || Object.prototype.toString.call(error) === '[object Error]') {
|
|
2428
|
+
// Capture at dispatch time, but only format the stack on failure.
|
|
2429
|
+
// Capturing in this callback would lose callers using .then/.catch.
|
|
2430
|
+
var stack = caller.stack;
|
|
2431
|
+
if (typeof stack === 'string') {
|
|
2432
|
+
var newline = stack.indexOf('\n');
|
|
2433
|
+
stack = newline === -1 ? '' : stack.slice(newline + 1);
|
|
2434
|
+
var original = error.stack;
|
|
2435
|
+
if (stack && (original === undefined || original === null || original === '')) {
|
|
2436
|
+
error.stack = stack;
|
|
2437
|
+
} else if (stack && typeof original === 'string' && original.indexOf(stack) === -1) {
|
|
2438
|
+
error.stack = original + '\n' + stack;
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
} catch (e) {
|
|
2443
|
+
// Frozen errors and custom stack accessors must retain their rejection.
|
|
2444
|
+
}
|
|
2445
|
+
return Promise.reject(error);
|
|
2446
|
+
});
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
function dispatchAfterRecovery(config) {
|
|
2450
|
+
return function dispatchRecoveredRequest() {
|
|
2451
|
+
return dispatchRequest(config);
|
|
2452
|
+
};
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2323
2455
|
/**
|
|
2324
2456
|
* Create a new instance of Axios
|
|
2325
2457
|
*
|
|
@@ -2350,11 +2482,14 @@ Axios.prototype.request = function request(configOrUrl, config) {
|
|
|
2350
2482
|
}
|
|
2351
2483
|
|
|
2352
2484
|
config = mergeConfig(this.defaults, config);
|
|
2485
|
+
var caller = config.captureCallerStack === true ? captureCallerStack(request) : null;
|
|
2353
2486
|
|
|
2354
|
-
// Set config.method
|
|
2487
|
+
// Set config.method. The merged config is null-prototype, but instance
|
|
2488
|
+
// defaults may be an ordinary object, so the fallback is read as an own
|
|
2489
|
+
// property to keep an inherited value from choosing the request method.
|
|
2355
2490
|
if (config.method) {
|
|
2356
2491
|
config.method = config.method.toLowerCase();
|
|
2357
|
-
} else if (this.defaults.method) {
|
|
2492
|
+
} else if (utils.hasOwnProperty(this.defaults, 'method') && this.defaults.method) {
|
|
2358
2493
|
config.method = this.defaults.method.toLowerCase();
|
|
2359
2494
|
} else {
|
|
2360
2495
|
config.method = 'get';
|
|
@@ -2416,7 +2551,7 @@ Axios.prototype.request = function request(configOrUrl, config) {
|
|
|
2416
2551
|
promise = promise.then(chain.shift(), chain.shift());
|
|
2417
2552
|
}
|
|
2418
2553
|
|
|
2419
|
-
return promise;
|
|
2554
|
+
return attachCallerStack(promise, caller);
|
|
2420
2555
|
}
|
|
2421
2556
|
|
|
2422
2557
|
|
|
@@ -2425,24 +2560,39 @@ Axios.prototype.request = function request(configOrUrl, config) {
|
|
|
2425
2560
|
var onFulfilled = requestInterceptorChain.shift();
|
|
2426
2561
|
var onRejected = requestInterceptorChain.shift();
|
|
2427
2562
|
try {
|
|
2428
|
-
newConfig = onFulfilled(newConfig);
|
|
2563
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
2429
2564
|
} catch (error) {
|
|
2430
|
-
onRejected
|
|
2565
|
+
if (!onRejected) {
|
|
2566
|
+
promise = Promise.reject(error);
|
|
2567
|
+
break;
|
|
2568
|
+
}
|
|
2569
|
+
try {
|
|
2570
|
+
var recovery = onRejected(error);
|
|
2571
|
+
if (recovery && typeof recovery.then === 'function') {
|
|
2572
|
+
promise = Promise.resolve(recovery).then(dispatchAfterRecovery(newConfig));
|
|
2573
|
+
}
|
|
2574
|
+
} catch (rejectedError) {
|
|
2575
|
+
promise = Promise.reject(rejectedError);
|
|
2576
|
+
}
|
|
2431
2577
|
break;
|
|
2432
2578
|
}
|
|
2433
2579
|
}
|
|
2434
2580
|
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2581
|
+
if (!promise) {
|
|
2582
|
+
try {
|
|
2583
|
+
promise = dispatchRequest(newConfig);
|
|
2584
|
+
} catch (error) {
|
|
2585
|
+
// Dispatch errors, including pre-aborted signals, still go through the
|
|
2586
|
+
// response interceptors registered below.
|
|
2587
|
+
promise = Promise.reject(error);
|
|
2588
|
+
}
|
|
2439
2589
|
}
|
|
2440
2590
|
|
|
2441
2591
|
while (responseInterceptorChain.length) {
|
|
2442
2592
|
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
2443
2593
|
}
|
|
2444
2594
|
|
|
2445
|
-
return promise;
|
|
2595
|
+
return attachCallerStack(promise, caller);
|
|
2446
2596
|
};
|
|
2447
2597
|
|
|
2448
2598
|
Axios.prototype.getUri = function getUri(config) {
|