axios 1.12.1 → 1.13.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 +402 -356
- package/README.md +153 -48
- package/dist/axios.js +155 -83
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +140 -73
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +140 -73
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +361 -114
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +4 -0
- package/index.d.ts +4 -0
- package/lib/adapters/adapters.js +85 -40
- package/lib/adapters/fetch.js +13 -11
- package/lib/adapters/http.js +221 -43
- package/lib/core/Axios.js +0 -2
- package/lib/core/InterceptorManager.js +1 -1
- package/lib/core/mergeConfig.js +4 -4
- package/lib/env/data.js +1 -1
- package/lib/helpers/HttpStatusCode.js +6 -0
- package/lib/helpers/bind.js +7 -0
- package/lib/helpers/cookies.js +24 -13
- package/lib/utils.js +2 -4
- package/package.json +15 -7
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
/*! Axios v1.
|
|
1
|
+
/*! Axios v1.13.0 Copyright (c) 2025 Matt Zabriskie and contributors */
|
|
2
|
+
/**
|
|
3
|
+
* Create a bound version of a function with a specified `this` context
|
|
4
|
+
*
|
|
5
|
+
* @param {Function} fn - The function to bind
|
|
6
|
+
* @param {*} thisArg - The value to be passed as the `this` parameter
|
|
7
|
+
* @returns {Function} A new function that will call the original function with the specified `this` context
|
|
8
|
+
*/
|
|
2
9
|
function bind(fn, thisArg) {
|
|
3
10
|
return function wrap() {
|
|
4
11
|
return fn.apply(thisArg, arguments);
|
|
@@ -354,10 +361,8 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
354
361
|
result[targetKey] = merge({}, val);
|
|
355
362
|
} else if (isArray(val)) {
|
|
356
363
|
result[targetKey] = val.slice();
|
|
357
|
-
} else {
|
|
358
|
-
|
|
359
|
-
result[targetKey] = val;
|
|
360
|
-
}
|
|
364
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
365
|
+
result[targetKey] = val;
|
|
361
366
|
}
|
|
362
367
|
};
|
|
363
368
|
|
|
@@ -1253,7 +1258,7 @@ class InterceptorManager {
|
|
|
1253
1258
|
*
|
|
1254
1259
|
* @param {Number} id The ID that was returned by `use`
|
|
1255
1260
|
*
|
|
1256
|
-
* @returns {
|
|
1261
|
+
* @returns {void}
|
|
1257
1262
|
*/
|
|
1258
1263
|
eject(id) {
|
|
1259
1264
|
if (this.handlers[id]) {
|
|
@@ -2219,27 +2224,38 @@ const cookies = platform.hasStandardBrowserEnv ?
|
|
|
2219
2224
|
|
|
2220
2225
|
// Standard browser envs support document.cookie
|
|
2221
2226
|
{
|
|
2222
|
-
write(name, value, expires, path, domain, secure) {
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2227
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2228
|
+
if (typeof document === 'undefined') return;
|
|
2226
2229
|
|
|
2227
|
-
|
|
2230
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2228
2231
|
|
|
2229
|
-
utils$1.
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
+
if (utils$1.isNumber(expires)) {
|
|
2233
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2234
|
+
}
|
|
2235
|
+
if (utils$1.isString(path)) {
|
|
2236
|
+
cookie.push(`path=${path}`);
|
|
2237
|
+
}
|
|
2238
|
+
if (utils$1.isString(domain)) {
|
|
2239
|
+
cookie.push(`domain=${domain}`);
|
|
2240
|
+
}
|
|
2241
|
+
if (secure === true) {
|
|
2242
|
+
cookie.push('secure');
|
|
2243
|
+
}
|
|
2244
|
+
if (utils$1.isString(sameSite)) {
|
|
2245
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2246
|
+
}
|
|
2232
2247
|
|
|
2233
2248
|
document.cookie = cookie.join('; ');
|
|
2234
2249
|
},
|
|
2235
2250
|
|
|
2236
2251
|
read(name) {
|
|
2237
|
-
|
|
2238
|
-
|
|
2252
|
+
if (typeof document === 'undefined') return null;
|
|
2253
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
2254
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
2239
2255
|
},
|
|
2240
2256
|
|
|
2241
2257
|
remove(name) {
|
|
2242
|
-
this.write(name, '', Date.now() - 86400000);
|
|
2258
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2243
2259
|
}
|
|
2244
2260
|
}
|
|
2245
2261
|
|
|
@@ -2328,11 +2344,11 @@ function mergeConfig$1(config1, config2) {
|
|
|
2328
2344
|
}
|
|
2329
2345
|
|
|
2330
2346
|
// eslint-disable-next-line consistent-return
|
|
2331
|
-
function mergeDeepProperties(a, b, prop
|
|
2347
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
2332
2348
|
if (!utils$1.isUndefined(b)) {
|
|
2333
|
-
return getMergedValue(a, b, prop
|
|
2349
|
+
return getMergedValue(a, b, prop, caseless);
|
|
2334
2350
|
} else if (!utils$1.isUndefined(a)) {
|
|
2335
|
-
return getMergedValue(undefined, a, prop
|
|
2351
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
2336
2352
|
}
|
|
2337
2353
|
}
|
|
2338
2354
|
|
|
@@ -2390,7 +2406,7 @@ function mergeConfig$1(config1, config2) {
|
|
|
2390
2406
|
socketPath: defaultToConfig2,
|
|
2391
2407
|
responseEncoding: defaultToConfig2,
|
|
2392
2408
|
validateStatus: mergeDirectKeys,
|
|
2393
|
-
headers: (a, b
|
|
2409
|
+
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
2394
2410
|
};
|
|
2395
2411
|
|
|
2396
2412
|
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
@@ -2780,9 +2796,9 @@ const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
|
2780
2796
|
|
|
2781
2797
|
const {isFunction} = utils$1;
|
|
2782
2798
|
|
|
2783
|
-
const globalFetchAPI = (({
|
|
2784
|
-
|
|
2785
|
-
|
|
2799
|
+
const globalFetchAPI = (({Request, Response}) => ({
|
|
2800
|
+
Request, Response
|
|
2801
|
+
}))(utils$1.global);
|
|
2786
2802
|
|
|
2787
2803
|
const {
|
|
2788
2804
|
ReadableStream: ReadableStream$1, TextEncoder
|
|
@@ -2798,8 +2814,12 @@ const test = (fn, ...args) => {
|
|
|
2798
2814
|
};
|
|
2799
2815
|
|
|
2800
2816
|
const factory = (env) => {
|
|
2801
|
-
|
|
2802
|
-
|
|
2817
|
+
env = utils$1.merge.call({
|
|
2818
|
+
skipUndefined: true
|
|
2819
|
+
}, globalFetchAPI, env);
|
|
2820
|
+
|
|
2821
|
+
const {fetch: envFetch, Request, Response} = env;
|
|
2822
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
2803
2823
|
const isRequestSupported = isFunction(Request);
|
|
2804
2824
|
const isResponseSupported = isFunction(Response);
|
|
2805
2825
|
|
|
@@ -2902,6 +2922,8 @@ const factory = (env) => {
|
|
|
2902
2922
|
fetchOptions
|
|
2903
2923
|
} = resolveConfig(config);
|
|
2904
2924
|
|
|
2925
|
+
let _fetch = envFetch || fetch;
|
|
2926
|
+
|
|
2905
2927
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
2906
2928
|
|
|
2907
2929
|
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
@@ -2961,7 +2983,7 @@ const factory = (env) => {
|
|
|
2961
2983
|
|
|
2962
2984
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
2963
2985
|
|
|
2964
|
-
let response = await (isRequestSupported ?
|
|
2986
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
2965
2987
|
|
|
2966
2988
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
2967
2989
|
|
|
@@ -3024,12 +3046,8 @@ const factory = (env) => {
|
|
|
3024
3046
|
const seedCache = new Map();
|
|
3025
3047
|
|
|
3026
3048
|
const getFetch = (config) => {
|
|
3027
|
-
let env =
|
|
3028
|
-
skipUndefined: true
|
|
3029
|
-
}, globalFetchAPI, config ? config.env : null);
|
|
3030
|
-
|
|
3049
|
+
let env = (config && config.env) || {};
|
|
3031
3050
|
const {fetch, Request, Response} = env;
|
|
3032
|
-
|
|
3033
3051
|
const seeds = [
|
|
3034
3052
|
Request, Response, fetch
|
|
3035
3053
|
];
|
|
@@ -3051,6 +3069,15 @@ const getFetch = (config) => {
|
|
|
3051
3069
|
|
|
3052
3070
|
getFetch();
|
|
3053
3071
|
|
|
3072
|
+
/**
|
|
3073
|
+
* Known adapters mapping.
|
|
3074
|
+
* Provides environment-specific adapters for Axios:
|
|
3075
|
+
* - `http` for Node.js
|
|
3076
|
+
* - `xhr` for browsers
|
|
3077
|
+
* - `fetch` for fetch API-based requests
|
|
3078
|
+
*
|
|
3079
|
+
* @type {Object<string, Function|Object>}
|
|
3080
|
+
*/
|
|
3054
3081
|
const knownAdapters = {
|
|
3055
3082
|
http: httpAdapter,
|
|
3056
3083
|
xhr: xhrAdapter,
|
|
@@ -3059,71 +3086,107 @@ const knownAdapters = {
|
|
|
3059
3086
|
}
|
|
3060
3087
|
};
|
|
3061
3088
|
|
|
3089
|
+
// Assign adapter names for easier debugging and identification
|
|
3062
3090
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3063
3091
|
if (fn) {
|
|
3064
3092
|
try {
|
|
3065
|
-
Object.defineProperty(fn, 'name', {value});
|
|
3093
|
+
Object.defineProperty(fn, 'name', { value });
|
|
3066
3094
|
} catch (e) {
|
|
3067
3095
|
// eslint-disable-next-line no-empty
|
|
3068
3096
|
}
|
|
3069
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
3097
|
+
Object.defineProperty(fn, 'adapterName', { value });
|
|
3070
3098
|
}
|
|
3071
3099
|
});
|
|
3072
3100
|
|
|
3101
|
+
/**
|
|
3102
|
+
* Render a rejection reason string for unknown or unsupported adapters
|
|
3103
|
+
*
|
|
3104
|
+
* @param {string} reason
|
|
3105
|
+
* @returns {string}
|
|
3106
|
+
*/
|
|
3073
3107
|
const renderReason = (reason) => `- ${reason}`;
|
|
3074
3108
|
|
|
3109
|
+
/**
|
|
3110
|
+
* Check if the adapter is resolved (function, null, or false)
|
|
3111
|
+
*
|
|
3112
|
+
* @param {Function|null|false} adapter
|
|
3113
|
+
* @returns {boolean}
|
|
3114
|
+
*/
|
|
3075
3115
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3076
3116
|
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3117
|
+
/**
|
|
3118
|
+
* Get the first suitable adapter from the provided list.
|
|
3119
|
+
* Tries each adapter in order until a supported one is found.
|
|
3120
|
+
* Throws an AxiosError if no adapter is suitable.
|
|
3121
|
+
*
|
|
3122
|
+
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3123
|
+
* @param {Object} config - Axios request configuration
|
|
3124
|
+
* @throws {AxiosError} If no suitable adapter is available
|
|
3125
|
+
* @returns {Function} The resolved adapter function
|
|
3126
|
+
*/
|
|
3127
|
+
function getAdapter$1(adapters, config) {
|
|
3128
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
3084
3129
|
|
|
3085
|
-
|
|
3130
|
+
const { length } = adapters;
|
|
3131
|
+
let nameOrAdapter;
|
|
3132
|
+
let adapter;
|
|
3086
3133
|
|
|
3087
|
-
|
|
3088
|
-
nameOrAdapter = adapters[i];
|
|
3089
|
-
let id;
|
|
3134
|
+
const rejectedReasons = {};
|
|
3090
3135
|
|
|
3091
|
-
|
|
3136
|
+
for (let i = 0; i < length; i++) {
|
|
3137
|
+
nameOrAdapter = adapters[i];
|
|
3138
|
+
let id;
|
|
3092
3139
|
|
|
3093
|
-
|
|
3094
|
-
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3140
|
+
adapter = nameOrAdapter;
|
|
3095
3141
|
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
}
|
|
3099
|
-
}
|
|
3142
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
3143
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3100
3144
|
|
|
3101
|
-
if (adapter
|
|
3102
|
-
|
|
3145
|
+
if (adapter === undefined) {
|
|
3146
|
+
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
|
3103
3147
|
}
|
|
3148
|
+
}
|
|
3104
3149
|
|
|
3105
|
-
|
|
3150
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
3151
|
+
break;
|
|
3106
3152
|
}
|
|
3107
3153
|
|
|
3108
|
-
|
|
3154
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
3155
|
+
}
|
|
3109
3156
|
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
)
|
|
3157
|
+
if (!adapter) {
|
|
3158
|
+
const reasons = Object.entries(rejectedReasons)
|
|
3159
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
3160
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3161
|
+
);
|
|
3114
3162
|
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3163
|
+
let s = length ?
|
|
3164
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
3165
|
+
'as no adapter specified';
|
|
3118
3166
|
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3167
|
+
throw new AxiosError$1(
|
|
3168
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
3169
|
+
'ERR_NOT_SUPPORT'
|
|
3170
|
+
);
|
|
3171
|
+
}
|
|
3124
3172
|
|
|
3125
|
-
|
|
3126
|
-
|
|
3173
|
+
return adapter;
|
|
3174
|
+
}
|
|
3175
|
+
|
|
3176
|
+
/**
|
|
3177
|
+
* Exports Axios adapters and utility to resolve an adapter
|
|
3178
|
+
*/
|
|
3179
|
+
const adapters = {
|
|
3180
|
+
/**
|
|
3181
|
+
* Resolve an adapter from a list of adapter names or functions.
|
|
3182
|
+
* @type {Function}
|
|
3183
|
+
*/
|
|
3184
|
+
getAdapter: getAdapter$1,
|
|
3185
|
+
|
|
3186
|
+
/**
|
|
3187
|
+
* Exposes all known adapters
|
|
3188
|
+
* @type {Object<string, Function|Object>}
|
|
3189
|
+
*/
|
|
3127
3190
|
adapters: knownAdapters
|
|
3128
3191
|
};
|
|
3129
3192
|
|
|
@@ -3200,7 +3263,7 @@ function dispatchRequest(config) {
|
|
|
3200
3263
|
});
|
|
3201
3264
|
}
|
|
3202
3265
|
|
|
3203
|
-
const VERSION$1 = "1.
|
|
3266
|
+
const VERSION$1 = "1.13.0";
|
|
3204
3267
|
|
|
3205
3268
|
const validators$1 = {};
|
|
3206
3269
|
|
|
@@ -3456,8 +3519,6 @@ class Axios$1 {
|
|
|
3456
3519
|
|
|
3457
3520
|
let newConfig = config;
|
|
3458
3521
|
|
|
3459
|
-
i = 0;
|
|
3460
|
-
|
|
3461
3522
|
while (i < len) {
|
|
3462
3523
|
const onFulfilled = requestInterceptorChain[i++];
|
|
3463
3524
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -3761,6 +3822,12 @@ const HttpStatusCode$1 = {
|
|
|
3761
3822
|
LoopDetected: 508,
|
|
3762
3823
|
NotExtended: 510,
|
|
3763
3824
|
NetworkAuthenticationRequired: 511,
|
|
3825
|
+
WebServerIsDown: 521,
|
|
3826
|
+
ConnectionTimedOut: 522,
|
|
3827
|
+
OriginIsUnreachable: 523,
|
|
3828
|
+
TimeoutOccurred: 524,
|
|
3829
|
+
SslHandshakeFailed: 525,
|
|
3830
|
+
InvalidSslCertificate: 526,
|
|
3764
3831
|
};
|
|
3765
3832
|
|
|
3766
3833
|
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|