axios 1.9.0 → 1.11.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 +41 -0
- package/README.md +19 -19
- package/dist/axios.js +43 -6
- 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 +51 -10
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +51 -10
- 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 +51 -10
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +14 -3
- package/index.d.ts +1 -1
- package/lib/adapters/fetch.js +1 -1
- package/lib/core/Axios.js +2 -2
- package/lib/core/mergeConfig.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/throttle.js +1 -1
- package/lib/helpers/toFormData.js +4 -0
- package/lib/helpers/toURLEncodedForm.js +4 -3
- package/lib/utils.js +36 -0
- package/package.json +14 -5
package/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ type MethodsHeaders = Partial<{
|
|
|
6
6
|
[Key in axios.Method as Lowercase<Key>]: AxiosHeaders;
|
|
7
7
|
} & {common: AxiosHeaders}>;
|
|
8
8
|
|
|
9
|
-
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string
|
|
9
|
+
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);
|
|
10
10
|
|
|
11
11
|
type AxiosHeaderParser = (this: AxiosHeaders, value: axios.AxiosHeaderValue, header: string) => any;
|
|
12
12
|
|
|
@@ -77,6 +77,8 @@ declare class AxiosHeaders {
|
|
|
77
77
|
getAuthorization(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
|
78
78
|
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
|
79
79
|
|
|
80
|
+
getSetCookie(): string[];
|
|
81
|
+
|
|
80
82
|
[Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>;
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -97,6 +99,14 @@ declare class AxiosError<T = unknown, D = any> extends Error {
|
|
|
97
99
|
status?: number;
|
|
98
100
|
toJSON: () => object;
|
|
99
101
|
cause?: Error;
|
|
102
|
+
static from<T = unknown, D = any>(
|
|
103
|
+
error: Error | unknown,
|
|
104
|
+
code?: string,
|
|
105
|
+
config?: axios.InternalAxiosRequestConfig<D>,
|
|
106
|
+
request?: any,
|
|
107
|
+
response?: axios.AxiosResponse<T, D>,
|
|
108
|
+
customProps?: object,
|
|
109
|
+
): AxiosError<T, D>;
|
|
100
110
|
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
|
101
111
|
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
|
102
112
|
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
|
@@ -418,13 +428,13 @@ declare namespace axios {
|
|
|
418
428
|
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
|
419
429
|
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
|
420
430
|
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
|
421
|
-
fetchOptions?: Record<string, any>;
|
|
431
|
+
fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
|
|
422
432
|
}
|
|
423
433
|
|
|
424
434
|
// Alias
|
|
425
435
|
type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
|
426
436
|
|
|
427
|
-
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig {
|
|
437
|
+
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
|
|
428
438
|
headers: AxiosRequestHeaders;
|
|
429
439
|
}
|
|
430
440
|
|
|
@@ -542,6 +552,7 @@ declare namespace axios {
|
|
|
542
552
|
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
|
543
553
|
getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
|
|
544
554
|
AxiosHeaders: typeof AxiosHeaders;
|
|
555
|
+
mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
|
545
556
|
}
|
|
546
557
|
}
|
|
547
558
|
|
package/index.d.ts
CHANGED
|
@@ -361,7 +361,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
|
361
361
|
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
|
362
362
|
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
|
363
363
|
withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
|
|
364
|
-
fetchOptions?: Record<string, any>;
|
|
364
|
+
fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
// Alias
|
package/lib/adapters/fetch.js
CHANGED
|
@@ -167,7 +167,7 @@ export default isFetchSupported && (async (config) => {
|
|
|
167
167
|
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
let response = await fetch(request);
|
|
170
|
+
let response = await fetch(request, fetchOptions);
|
|
171
171
|
|
|
172
172
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
173
173
|
|
package/lib/core/Axios.js
CHANGED
|
@@ -153,8 +153,8 @@ class Axios {
|
|
|
153
153
|
|
|
154
154
|
if (!synchronousRequestInterceptors) {
|
|
155
155
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
156
|
-
chain.unshift
|
|
157
|
-
chain.push
|
|
156
|
+
chain.unshift(...requestInterceptorChain);
|
|
157
|
+
chain.push(...responseInterceptorChain);
|
|
158
158
|
len = chain.length;
|
|
159
159
|
|
|
160
160
|
promise = Promise.resolve(config);
|
package/lib/core/mergeConfig.js
CHANGED
|
@@ -96,7 +96,7 @@ export default function mergeConfig(config1, config2) {
|
|
|
96
96
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
utils.forEach(Object.keys(
|
|
99
|
+
utils.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
100
100
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
101
101
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
102
102
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
package/lib/env/data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.11.0";
|
package/lib/helpers/throttle.js
CHANGED
|
@@ -120,6 +120,10 @@ function toFormData(obj, formData, options) {
|
|
|
120
120
|
return value.toISOString();
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
if (utils.isBoolean(value)) {
|
|
124
|
+
return value.toString();
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
if (!useBlob && utils.isBlob(value)) {
|
|
124
128
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
125
129
|
}
|
|
@@ -5,7 +5,7 @@ import toFormData from './toFormData.js';
|
|
|
5
5
|
import platform from '../platform/index.js';
|
|
6
6
|
|
|
7
7
|
export default function toURLEncodedForm(data, options) {
|
|
8
|
-
return toFormData(data, new platform.classes.URLSearchParams(),
|
|
8
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
9
9
|
visitor: function(value, key, path, helpers) {
|
|
10
10
|
if (platform.isNode && utils.isBuffer(value)) {
|
|
11
11
|
this.append(key, value.toString('base64'));
|
|
@@ -13,6 +13,7 @@ export default function toURLEncodedForm(data, options) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
16
|
-
}
|
|
17
|
-
|
|
16
|
+
},
|
|
17
|
+
...options
|
|
18
|
+
});
|
|
18
19
|
}
|
package/lib/utils.js
CHANGED
|
@@ -136,6 +136,27 @@ const isPlainObject = (val) => {
|
|
|
136
136
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
141
|
+
*
|
|
142
|
+
* @param {*} val The value to test
|
|
143
|
+
*
|
|
144
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
145
|
+
*/
|
|
146
|
+
const isEmptyObject = (val) => {
|
|
147
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
148
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
154
|
+
} catch (e) {
|
|
155
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
139
160
|
/**
|
|
140
161
|
* Determine if a value is a Date
|
|
141
162
|
*
|
|
@@ -258,6 +279,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
258
279
|
fn.call(null, obj[i], i, obj);
|
|
259
280
|
}
|
|
260
281
|
} else {
|
|
282
|
+
// Buffer check
|
|
283
|
+
if (isBuffer(obj)) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
261
287
|
// Iterate over object keys
|
|
262
288
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
263
289
|
const len = keys.length;
|
|
@@ -271,6 +297,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
271
297
|
}
|
|
272
298
|
|
|
273
299
|
function findKey(obj, key) {
|
|
300
|
+
if (isBuffer(obj)){
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
|
|
274
304
|
key = key.toLowerCase();
|
|
275
305
|
const keys = Object.keys(obj);
|
|
276
306
|
let i = keys.length;
|
|
@@ -624,6 +654,11 @@ const toJSONObject = (obj) => {
|
|
|
624
654
|
return;
|
|
625
655
|
}
|
|
626
656
|
|
|
657
|
+
//Buffer check
|
|
658
|
+
if (isBuffer(source)) {
|
|
659
|
+
return source;
|
|
660
|
+
}
|
|
661
|
+
|
|
627
662
|
if(!('toJSON' in source)) {
|
|
628
663
|
stack[i] = source;
|
|
629
664
|
const target = isArray(source) ? [] : {};
|
|
@@ -695,6 +730,7 @@ export default {
|
|
|
695
730
|
isBoolean,
|
|
696
731
|
isObject,
|
|
697
732
|
isPlainObject,
|
|
733
|
+
isEmptyObject,
|
|
698
734
|
isReadableStream,
|
|
699
735
|
isRequest,
|
|
700
736
|
isResponse,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axios",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"require": "./index.d.cts",
|
|
10
10
|
"default": "./index.d.ts"
|
|
11
11
|
},
|
|
12
|
+
"react-native": {
|
|
13
|
+
"require": "./dist/browser/axios.cjs",
|
|
14
|
+
"default": "./dist/esm/axios.js"
|
|
15
|
+
},
|
|
12
16
|
"browser": {
|
|
13
17
|
"require": "./dist/browser/axios.cjs",
|
|
14
18
|
"default": "./index.js"
|
|
@@ -143,12 +147,17 @@
|
|
|
143
147
|
"./lib/platform/node/index.js": "./lib/platform/browser/index.js",
|
|
144
148
|
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js"
|
|
145
149
|
},
|
|
150
|
+
"react-native": {
|
|
151
|
+
"./lib/adapters/http.js": "./lib/helpers/null.js",
|
|
152
|
+
"./lib/platform/node/index.js": "./lib/platform/browser/index.js",
|
|
153
|
+
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js"
|
|
154
|
+
},
|
|
146
155
|
"jsdelivr": "dist/axios.min.js",
|
|
147
156
|
"unpkg": "dist/axios.min.js",
|
|
148
157
|
"typings": "./index.d.ts",
|
|
149
158
|
"dependencies": {
|
|
150
159
|
"follow-redirects": "^1.15.6",
|
|
151
|
-
"form-data": "^4.0.
|
|
160
|
+
"form-data": "^4.0.4",
|
|
152
161
|
"proxy-from-env": "^1.1.0"
|
|
153
162
|
},
|
|
154
163
|
"bundlesize": [
|
|
@@ -167,10 +176,10 @@
|
|
|
167
176
|
"Justin Beckwith (https://github.com/JustinBeckwith)",
|
|
168
177
|
"Martti Laine (https://github.com/codeclown)",
|
|
169
178
|
"Xianming Zhong (https://github.com/chinesedfan)",
|
|
170
|
-
"Rikki Gibson (https://github.com/RikkiGibson)",
|
|
171
179
|
"Remco Haszing (https://github.com/remcohaszing)",
|
|
172
|
-
"
|
|
173
|
-
"Ben Carp (https://github.com/carpben)"
|
|
180
|
+
"Rikki Gibson (https://github.com/RikkiGibson)",
|
|
181
|
+
"Ben Carp (https://github.com/carpben)",
|
|
182
|
+
"Yasu Flores (https://github.com/yasuf)"
|
|
174
183
|
],
|
|
175
184
|
"sideEffects": false,
|
|
176
185
|
"release-it": {
|