axios 1.5.1 → 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 +162 -0
- package/README.md +256 -1
- package/dist/axios.js +4 -3
- 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 +4 -4
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +4 -4
- 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 +27 -14
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +18 -7
- package/index.d.ts +19 -8
- package/lib/adapters/http.js +23 -10
- package/lib/adapters/xhr.js +2 -2
- package/lib/env/data.js +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
@@ -8,6 +8,8 @@ type MethodsHeaders = Partial<{
|
|
8
8
|
|
9
9
|
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;
|
10
10
|
|
11
|
+
type AxiosHeaderParser = (this: AxiosHeaders, value: axios.AxiosHeaderValue, header: string) => any;
|
12
|
+
|
11
13
|
type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent'| 'Content-Encoding' | 'Authorization';
|
12
14
|
|
13
15
|
type ContentType = axios.AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream';
|
@@ -16,18 +18,18 @@ type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' |
|
|
16
18
|
|
17
19
|
declare class AxiosHeaders {
|
18
20
|
constructor(
|
19
|
-
headers?: RawAxiosHeaders | AxiosHeaders
|
21
|
+
headers?: RawAxiosHeaders | AxiosHeaders | string
|
20
22
|
);
|
21
23
|
|
22
24
|
[key: string]: any;
|
23
25
|
|
24
26
|
set(headerName?: string, value?: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
25
|
-
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders;
|
27
|
+
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
|
26
28
|
|
27
29
|
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
28
|
-
get(headerName: string, matcher?: true |
|
30
|
+
get(headerName: string, matcher?: true | AxiosHeaderParser): axios.AxiosHeaderValue;
|
29
31
|
|
30
|
-
has(header: string, matcher?:
|
32
|
+
has(header: string, matcher?: AxiosHeaderMatcher): boolean;
|
31
33
|
|
32
34
|
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
33
35
|
|
@@ -359,6 +361,15 @@ declare namespace axios {
|
|
359
361
|
|
360
362
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
361
363
|
|
364
|
+
type AddressFamily = 4 | 6 | undefined;
|
365
|
+
|
366
|
+
interface LookupAddressEntry {
|
367
|
+
address: string;
|
368
|
+
family?: AddressFamily;
|
369
|
+
}
|
370
|
+
|
371
|
+
type LookupAddress = string | LookupAddressEntry;
|
372
|
+
|
362
373
|
interface AxiosRequestConfig<D = any> {
|
363
374
|
url?: string;
|
364
375
|
method?: Method | string;
|
@@ -400,9 +411,9 @@ declare namespace axios {
|
|
400
411
|
FormData?: new (...args: any[]) => object;
|
401
412
|
};
|
402
413
|
formSerializer?: FormSerializerOptions;
|
403
|
-
family?:
|
404
|
-
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address:
|
405
|
-
((hostname: string, options: object) => Promise<[address:
|
414
|
+
family?: AddressFamily;
|
415
|
+
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
416
|
+
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
406
417
|
}
|
407
418
|
|
408
419
|
// Alias
|
package/index.d.ts
CHANGED
@@ -9,22 +9,24 @@ type MethodsHeaders = Partial<{
|
|
9
9
|
[Key in Method as Lowercase<Key>]: AxiosHeaders;
|
10
10
|
} & {common: AxiosHeaders}>;
|
11
11
|
|
12
|
-
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string
|
12
|
+
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);
|
13
|
+
|
14
|
+
type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any;
|
13
15
|
|
14
16
|
export class AxiosHeaders {
|
15
17
|
constructor(
|
16
|
-
headers?: RawAxiosHeaders | AxiosHeaders
|
18
|
+
headers?: RawAxiosHeaders | AxiosHeaders | string
|
17
19
|
);
|
18
20
|
|
19
21
|
[key: string]: any;
|
20
22
|
|
21
23
|
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
22
|
-
set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders;
|
24
|
+
set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
|
23
25
|
|
24
26
|
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
25
|
-
get(headerName: string, matcher?: true |
|
27
|
+
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
|
26
28
|
|
27
|
-
has(header: string, matcher?:
|
29
|
+
has(header: string, matcher?: AxiosHeaderMatcher): boolean;
|
28
30
|
|
29
31
|
delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
|
30
32
|
|
@@ -300,6 +302,15 @@ type AxiosAdapterName = 'xhr' | 'http' | string;
|
|
300
302
|
|
301
303
|
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
302
304
|
|
305
|
+
export type AddressFamily = 4 | 6 | undefined;
|
306
|
+
|
307
|
+
export interface LookupAddressEntry {
|
308
|
+
address: string;
|
309
|
+
family?: AddressFamily;
|
310
|
+
}
|
311
|
+
|
312
|
+
export type LookupAddress = string | LookupAddressEntry;
|
313
|
+
|
303
314
|
export interface AxiosRequestConfig<D = any> {
|
304
315
|
url?: string;
|
305
316
|
method?: Method | string;
|
@@ -341,9 +352,9 @@ export interface AxiosRequestConfig<D = any> {
|
|
341
352
|
FormData?: new (...args: any[]) => object;
|
342
353
|
};
|
343
354
|
formSerializer?: FormSerializerOptions;
|
344
|
-
family?:
|
345
|
-
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address:
|
346
|
-
((hostname: string, options: object) => Promise<[address:
|
355
|
+
family?: AddressFamily;
|
356
|
+
lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |
|
357
|
+
((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);
|
347
358
|
}
|
348
359
|
|
349
360
|
// Alias
|
package/lib/adapters/http.js
CHANGED
@@ -144,6 +144,18 @@ const wrapAsync = (asyncExecutor) => {
|
|
144
144
|
})
|
145
145
|
};
|
146
146
|
|
147
|
+
const resolveFamily = ({address, family}) => {
|
148
|
+
if (!utils.isString(address)) {
|
149
|
+
throw TypeError('address must be a string');
|
150
|
+
}
|
151
|
+
return ({
|
152
|
+
address,
|
153
|
+
family: family || (address.indexOf('.') < 0 ? 6 : 4)
|
154
|
+
});
|
155
|
+
}
|
156
|
+
|
157
|
+
const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(address) ? address : {address, family});
|
158
|
+
|
147
159
|
/*eslint consistent-return:0*/
|
148
160
|
export default isHttpAdapterSupported && function httpAdapter(config) {
|
149
161
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
@@ -154,15 +166,16 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
154
166
|
let rejected = false;
|
155
167
|
let req;
|
156
168
|
|
157
|
-
if (lookup
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
169
|
+
if (lookup) {
|
170
|
+
const _lookup = callbackify(lookup, (value) => utils.isArray(value) ? value : [value]);
|
171
|
+
// hotfix to support opt.all option which is required for node 20.x
|
172
|
+
lookup = (hostname, opt, cb) => {
|
173
|
+
_lookup(hostname, opt, (err, arg0, arg1) => {
|
174
|
+
const addresses = utils.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
175
|
+
|
176
|
+
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
177
|
+
});
|
178
|
+
}
|
166
179
|
}
|
167
180
|
|
168
181
|
// temporary internal emitter until the AxiosRequest class will be implemented
|
@@ -567,7 +580,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
567
580
|
}
|
568
581
|
response.data = responseData;
|
569
582
|
} catch (err) {
|
570
|
-
reject(AxiosError.from(err, null, config, response.request, response));
|
583
|
+
return reject(AxiosError.from(err, null, config, response.request, response));
|
571
584
|
}
|
572
585
|
settle(resolve, reject, response);
|
573
586
|
});
|
package/lib/adapters/xhr.js
CHANGED
@@ -188,8 +188,8 @@ export default isXHRAdapterSupported && function (config) {
|
|
188
188
|
// Specifically not if we're in a web worker, or react-native.
|
189
189
|
if (platform.isStandardBrowserEnv) {
|
190
190
|
// Add xsrf header
|
191
|
-
|
192
|
-
|
191
|
+
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
|
192
|
+
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
193
193
|
|
194
194
|
if (xsrfValue) {
|
195
195
|
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.
|
1
|
+
export const VERSION = "1.6.0";
|