axios 1.2.0 → 1.2.2
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 +54 -0
- package/README.md +2 -3
- package/dist/axios.js +102 -5
- 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 +108 -7
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +118 -15
- 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 +111 -15
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +23 -12
- package/index.d.ts +17 -6
- package/index.js +6 -2
- package/lib/.DS_Store +0 -0
- package/lib/adapters/http.js +23 -8
- package/lib/adapters/xhr.js +2 -2
- package/lib/axios.js +6 -0
- package/lib/core/dispatchRequest.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/HttpStatusCode.js +71 -0
- package/lib/helpers/speedometer.js +1 -1
- package/lib/platform/browser/index.js +20 -0
- package/lib/utils.js +5 -1
- package/package.json +54 -6
- package/bin/ssl_hotfix.js +0 -22
- package/gulpfile.js +0 -88
- package/karma.conf.cjs +0 -250
- package/rollup.config.js +0 -117
- package/tsconfig.json +0 -9
- package/tslint.json +0 -11
package/index.d.cts
CHANGED
@@ -18,16 +18,9 @@ type AxiosHeaderGetter = ((parser?: RegExp) => RegExpExecArray | null) |
|
|
18
18
|
|
19
19
|
type AxiosHeaderTester = (matcher?: AxiosHeaderMatcher) => boolean;
|
20
20
|
|
21
|
-
type MaxUploadRate = number;
|
22
|
-
|
23
|
-
type MaxDownloadRate = number;
|
24
|
-
|
25
|
-
type Milliseconds = number;
|
26
|
-
|
27
21
|
declare class AxiosHeaders {
|
28
22
|
constructor(
|
29
|
-
headers?: RawAxiosHeaders | AxiosHeaders
|
30
|
-
defaultHeaders?: RawAxiosHeaders | AxiosHeaders
|
23
|
+
headers?: RawAxiosHeaders | AxiosHeaders
|
31
24
|
);
|
32
25
|
|
33
26
|
set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
|
@@ -44,12 +37,16 @@ declare class AxiosHeaders {
|
|
44
37
|
|
45
38
|
normalize(format: boolean): AxiosHeaders;
|
46
39
|
|
40
|
+
concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string>): AxiosHeaders;
|
41
|
+
|
47
42
|
toJSON(asStrings?: boolean): RawAxiosHeaders;
|
48
43
|
|
49
44
|
static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
|
50
45
|
|
51
46
|
static accessor(header: string | string[]): AxiosHeaders;
|
52
47
|
|
48
|
+
static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string>): AxiosHeaders;
|
49
|
+
|
53
50
|
setContentType: AxiosHeaderSetter;
|
54
51
|
getContentType: AxiosHeaderGetter;
|
55
52
|
hasContentType: AxiosHeaderTester;
|
@@ -199,7 +196,7 @@ declare namespace axios {
|
|
199
196
|
|
200
197
|
type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>;
|
201
198
|
|
202
|
-
type AxiosRequestHeaders =
|
199
|
+
type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
203
200
|
|
204
201
|
type RawAxiosResponseHeaders = Partial<Record<string, string> & {
|
205
202
|
"set-cookie"?: string[]
|
@@ -321,6 +318,12 @@ declare namespace axios {
|
|
321
318
|
serialize?: CustomParamsSerializer;
|
322
319
|
}
|
323
320
|
|
321
|
+
type MaxUploadRate = number;
|
322
|
+
|
323
|
+
type MaxDownloadRate = number;
|
324
|
+
|
325
|
+
type BrowserProgressEvent = any;
|
326
|
+
|
324
327
|
interface AxiosProgressEvent {
|
325
328
|
loaded: number;
|
326
329
|
total?: number;
|
@@ -330,22 +333,29 @@ declare namespace axios {
|
|
330
333
|
estimated?: number;
|
331
334
|
upload?: boolean;
|
332
335
|
download?: boolean;
|
336
|
+
event?: BrowserProgressEvent;
|
333
337
|
}
|
334
338
|
|
339
|
+
type Milliseconds = number;
|
340
|
+
|
341
|
+
type AxiosAdapterName = 'xhr' | 'http' | string;
|
342
|
+
|
343
|
+
type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
|
344
|
+
|
335
345
|
interface AxiosRequestConfig<D = any> {
|
336
346
|
url?: string;
|
337
347
|
method?: Method | string;
|
338
348
|
baseURL?: string;
|
339
349
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
340
350
|
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
341
|
-
headers?: RawAxiosRequestHeaders;
|
351
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders;
|
342
352
|
params?: any;
|
343
353
|
paramsSerializer?: ParamsSerializerOptions;
|
344
354
|
data?: D;
|
345
355
|
timeout?: Milliseconds;
|
346
356
|
timeoutErrorMessage?: string;
|
347
357
|
withCredentials?: boolean;
|
348
|
-
adapter?:
|
358
|
+
adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
|
349
359
|
auth?: AxiosBasicCredentials;
|
350
360
|
responseType?: ResponseType;
|
351
361
|
responseEncoding?: responseEncoding | string;
|
@@ -393,7 +403,7 @@ declare namespace axios {
|
|
393
403
|
}
|
394
404
|
|
395
405
|
interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
396
|
-
headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>;
|
406
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
397
407
|
}
|
398
408
|
|
399
409
|
interface AxiosResponse<T = any, D = any> {
|
@@ -482,6 +492,7 @@ declare namespace axios {
|
|
482
492
|
isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
|
483
493
|
toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;
|
484
494
|
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
495
|
+
AxiosHeaders: typeof AxiosHeaders;
|
485
496
|
}
|
486
497
|
}
|
487
498
|
|
package/index.d.ts
CHANGED
@@ -6,7 +6,7 @@ type MethodsHeaders = {
|
|
6
6
|
[Key in Method as Lowercase<Key>]: AxiosHeaders;
|
7
7
|
};
|
8
8
|
|
9
|
-
interface CommonHeaders
|
9
|
+
interface CommonHeaders {
|
10
10
|
common: AxiosHeaders;
|
11
11
|
}
|
12
12
|
|
@@ -71,7 +71,7 @@ export class AxiosHeaders {
|
|
71
71
|
|
72
72
|
export type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & MethodsHeaders & CommonHeaders>;
|
73
73
|
|
74
|
-
export type AxiosRequestHeaders =
|
74
|
+
export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
|
75
75
|
|
76
76
|
export type RawAxiosResponseHeaders = Partial<Record<string, string> & {
|
77
77
|
"set-cookie"?: string[]
|
@@ -263,6 +263,8 @@ type MaxUploadRate = number;
|
|
263
263
|
|
264
264
|
type MaxDownloadRate = number;
|
265
265
|
|
266
|
+
type BrowserProgressEvent = any;
|
267
|
+
|
266
268
|
export interface AxiosProgressEvent {
|
267
269
|
loaded: number;
|
268
270
|
total?: number;
|
@@ -272,7 +274,7 @@ export interface AxiosProgressEvent {
|
|
272
274
|
estimated?: number;
|
273
275
|
upload?: boolean;
|
274
276
|
download?: boolean;
|
275
|
-
event?:
|
277
|
+
event?: BrowserProgressEvent;
|
276
278
|
}
|
277
279
|
|
278
280
|
type Milliseconds = number;
|
@@ -287,7 +289,7 @@ export interface AxiosRequestConfig<D = any> {
|
|
287
289
|
baseURL?: string;
|
288
290
|
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
289
291
|
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
290
|
-
headers?: RawAxiosRequestHeaders;
|
292
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders;
|
291
293
|
params?: any;
|
292
294
|
paramsSerializer?: ParamsSerializerOptions;
|
293
295
|
data?: D;
|
@@ -342,10 +344,10 @@ export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'hea
|
|
342
344
|
}
|
343
345
|
|
344
346
|
export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
345
|
-
headers?: RawAxiosRequestHeaders | Partial<HeadersDefaults>;
|
347
|
+
headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
|
346
348
|
}
|
347
349
|
|
348
|
-
export interface AxiosResponse<T = any, D = any>
|
350
|
+
export interface AxiosResponse<T = any, D = any> {
|
349
351
|
data: T;
|
350
352
|
status: number;
|
351
353
|
statusText: string;
|
@@ -371,6 +373,14 @@ export class AxiosError<T = unknown, D = any> extends Error {
|
|
371
373
|
status?: number;
|
372
374
|
toJSON: () => object;
|
373
375
|
cause?: Error;
|
376
|
+
static from<T = unknown, D = any>(
|
377
|
+
error: Error | unknown,
|
378
|
+
code?: string,
|
379
|
+
config?: AxiosRequestConfig<D>,
|
380
|
+
request?: any,
|
381
|
+
response?: AxiosResponse<T, D>,
|
382
|
+
customProps?: object,
|
383
|
+
): AxiosError<T, D>;
|
374
384
|
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
375
385
|
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
376
386
|
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
@@ -489,6 +499,7 @@ export interface AxiosStatic extends AxiosInstance {
|
|
489
499
|
CancelToken: CancelTokenStatic;
|
490
500
|
Axios: typeof Axios;
|
491
501
|
AxiosError: typeof AxiosError;
|
502
|
+
HttpStatusCode: typeof HttpStatusCode;
|
492
503
|
readonly VERSION: string;
|
493
504
|
isCancel: typeof isCancel;
|
494
505
|
all: typeof all;
|
package/index.js
CHANGED
@@ -16,7 +16,9 @@ const {
|
|
16
16
|
spread,
|
17
17
|
toFormData,
|
18
18
|
AxiosHeaders,
|
19
|
-
|
19
|
+
HttpStatusCode,
|
20
|
+
formToJSON,
|
21
|
+
mergeConfig
|
20
22
|
} = axios;
|
21
23
|
|
22
24
|
export {
|
@@ -33,5 +35,7 @@ export {
|
|
33
35
|
spread,
|
34
36
|
toFormData,
|
35
37
|
AxiosHeaders,
|
36
|
-
|
38
|
+
HttpStatusCode,
|
39
|
+
formToJSON,
|
40
|
+
mergeConfig
|
37
41
|
}
|
package/lib/.DS_Store
ADDED
Binary file
|
package/lib/adapters/http.js
CHANGED
@@ -20,6 +20,16 @@ import AxiosHeaders from '../core/AxiosHeaders.js';
|
|
20
20
|
import AxiosTransformStream from '../helpers/AxiosTransformStream.js';
|
21
21
|
import EventEmitter from 'events';
|
22
22
|
|
23
|
+
const zlibOptions = {
|
24
|
+
flush: zlib.constants.Z_SYNC_FLUSH,
|
25
|
+
finishFlush: zlib.constants.Z_SYNC_FLUSH
|
26
|
+
};
|
27
|
+
|
28
|
+
const brotliOptions = {
|
29
|
+
flush: zlib.constants.BROTLI_OPERATION_FLUSH,
|
30
|
+
finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
|
31
|
+
}
|
32
|
+
|
23
33
|
const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
|
24
34
|
|
25
35
|
const {http: httpFollow, https: httpsFollow} = followRedirects;
|
@@ -262,7 +272,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
262
272
|
}
|
263
273
|
}
|
264
274
|
|
265
|
-
const contentLength =
|
275
|
+
const contentLength = utils.toFiniteNumber(headers.getContentLength());
|
266
276
|
|
267
277
|
if (utils.isArray(maxRate)) {
|
268
278
|
maxUploadRate = maxRate[0];
|
@@ -277,7 +287,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
277
287
|
}
|
278
288
|
|
279
289
|
data = stream.pipeline([data, new AxiosTransformStream({
|
280
|
-
length:
|
290
|
+
length: contentLength,
|
281
291
|
maxRate: utils.toFiniteNumber(maxUploadRate)
|
282
292
|
})], utils.noop);
|
283
293
|
|
@@ -320,7 +330,10 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
320
330
|
return reject(customErr);
|
321
331
|
}
|
322
332
|
|
323
|
-
headers.set(
|
333
|
+
headers.set(
|
334
|
+
'Accept-Encoding',
|
335
|
+
'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
|
336
|
+
);
|
324
337
|
|
325
338
|
const options = {
|
326
339
|
path,
|
@@ -392,34 +405,36 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
392
405
|
streams.push(transformStream);
|
393
406
|
}
|
394
407
|
|
395
|
-
//
|
408
|
+
// decompress the response body transparently if required
|
396
409
|
let responseStream = res;
|
397
410
|
|
398
411
|
// return the last request in case of redirects
|
399
412
|
const lastRequest = res.req || req;
|
400
413
|
|
401
414
|
// if decompress disabled we should not decompress
|
402
|
-
if (config.decompress !== false) {
|
415
|
+
if (config.decompress !== false && res.headers['content-encoding']) {
|
403
416
|
// if no content, but headers still say that it is encoded,
|
404
417
|
// remove the header not confuse downstream operations
|
405
|
-
if (
|
418
|
+
if (method === 'HEAD' || res.statusCode === 204) {
|
406
419
|
delete res.headers['content-encoding'];
|
407
420
|
}
|
408
421
|
|
409
422
|
switch (res.headers['content-encoding']) {
|
410
423
|
/*eslint default-case:0*/
|
411
424
|
case 'gzip':
|
425
|
+
case 'x-gzip':
|
412
426
|
case 'compress':
|
427
|
+
case 'x-compress':
|
413
428
|
case 'deflate':
|
414
429
|
// add the unzipper to the body stream processing pipeline
|
415
|
-
streams.push(zlib.createUnzip());
|
430
|
+
streams.push(zlib.createUnzip(zlibOptions));
|
416
431
|
|
417
432
|
// remove the content-encoding in order to not confuse downstream operations
|
418
433
|
delete res.headers['content-encoding'];
|
419
434
|
break;
|
420
435
|
case 'br':
|
421
436
|
if (isBrotliSupported) {
|
422
|
-
streams.push(zlib.createBrotliDecompress());
|
437
|
+
streams.push(zlib.createBrotliDecompress(brotliOptions));
|
423
438
|
delete res.headers['content-encoding'];
|
424
439
|
}
|
425
440
|
}
|
package/lib/adapters/xhr.js
CHANGED
@@ -61,7 +61,7 @@ export default isXHRAdapterSupported && function (config) {
|
|
61
61
|
}
|
62
62
|
}
|
63
63
|
|
64
|
-
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
|
64
|
+
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
|
65
65
|
requestHeaders.setContentType(false); // Let the browser set it
|
66
66
|
}
|
67
67
|
|
@@ -89,7 +89,7 @@ export default isXHRAdapterSupported && function (config) {
|
|
89
89
|
const responseHeaders = AxiosHeaders.from(
|
90
90
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
91
91
|
);
|
92
|
-
const responseData = !responseType || responseType === 'text' ||
|
92
|
+
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
93
93
|
request.responseText : request.response;
|
94
94
|
const response = {
|
95
95
|
data: responseData,
|
package/lib/axios.js
CHANGED
@@ -15,6 +15,7 @@ import AxiosError from './core/AxiosError.js';
|
|
15
15
|
import spread from './helpers/spread.js';
|
16
16
|
import isAxiosError from './helpers/isAxiosError.js';
|
17
17
|
import AxiosHeaders from "./core/AxiosHeaders.js";
|
18
|
+
import HttpStatusCode from './helpers/HttpStatusCode.js';
|
18
19
|
|
19
20
|
/**
|
20
21
|
* Create an instance of Axios
|
@@ -70,10 +71,15 @@ axios.spread = spread;
|
|
70
71
|
// Expose isAxiosError
|
71
72
|
axios.isAxiosError = isAxiosError;
|
72
73
|
|
74
|
+
// Expose mergeConfig
|
75
|
+
axios.mergeConfig = mergeConfig;
|
76
|
+
|
73
77
|
axios.AxiosHeaders = AxiosHeaders;
|
74
78
|
|
75
79
|
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
76
80
|
|
81
|
+
axios.HttpStatusCode = HttpStatusCode;
|
82
|
+
|
77
83
|
axios.default = axios;
|
78
84
|
|
79
85
|
// this module should only have a default export
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.2.
|
1
|
+
export const VERSION = "1.2.2";
|
@@ -0,0 +1,71 @@
|
|
1
|
+
const HttpStatusCode = {
|
2
|
+
Continue: 100,
|
3
|
+
SwitchingProtocols: 101,
|
4
|
+
Processing: 102,
|
5
|
+
EarlyHints: 103,
|
6
|
+
Ok: 200,
|
7
|
+
Created: 201,
|
8
|
+
Accepted: 202,
|
9
|
+
NonAuthoritativeInformation: 203,
|
10
|
+
NoContent: 204,
|
11
|
+
ResetContent: 205,
|
12
|
+
PartialContent: 206,
|
13
|
+
MultiStatus: 207,
|
14
|
+
AlreadyReported: 208,
|
15
|
+
ImUsed: 226,
|
16
|
+
MultipleChoices: 300,
|
17
|
+
MovedPermanently: 301,
|
18
|
+
Found: 302,
|
19
|
+
SeeOther: 303,
|
20
|
+
NotModified: 304,
|
21
|
+
UseProxy: 305,
|
22
|
+
Unused: 306,
|
23
|
+
TemporaryRedirect: 307,
|
24
|
+
PermanentRedirect: 308,
|
25
|
+
BadRequest: 400,
|
26
|
+
Unauthorized: 401,
|
27
|
+
PaymentRequired: 402,
|
28
|
+
Forbidden: 403,
|
29
|
+
NotFound: 404,
|
30
|
+
MethodNotAllowed: 405,
|
31
|
+
NotAcceptable: 406,
|
32
|
+
ProxyAuthenticationRequired: 407,
|
33
|
+
RequestTimeout: 408,
|
34
|
+
Conflict: 409,
|
35
|
+
Gone: 410,
|
36
|
+
LengthRequired: 411,
|
37
|
+
PreconditionFailed: 412,
|
38
|
+
PayloadTooLarge: 413,
|
39
|
+
UriTooLong: 414,
|
40
|
+
UnsupportedMediaType: 415,
|
41
|
+
RangeNotSatisfiable: 416,
|
42
|
+
ExpectationFailed: 417,
|
43
|
+
ImATeapot: 418,
|
44
|
+
MisdirectedRequest: 421,
|
45
|
+
UnprocessableEntity: 422,
|
46
|
+
Locked: 423,
|
47
|
+
FailedDependency: 424,
|
48
|
+
TooEarly: 425,
|
49
|
+
UpgradeRequired: 426,
|
50
|
+
PreconditionRequired: 428,
|
51
|
+
TooManyRequests: 429,
|
52
|
+
RequestHeaderFieldsTooLarge: 431,
|
53
|
+
UnavailableForLegalReasons: 451,
|
54
|
+
InternalServerError: 500,
|
55
|
+
NotImplemented: 501,
|
56
|
+
BadGateway: 502,
|
57
|
+
ServiceUnavailable: 503,
|
58
|
+
GatewayTimeout: 504,
|
59
|
+
HttpVersionNotSupported: 505,
|
60
|
+
VariantAlsoNegotiates: 506,
|
61
|
+
InsufficientStorage: 507,
|
62
|
+
LoopDetected: 508,
|
63
|
+
NotExtended: 510,
|
64
|
+
NetworkAuthenticationRequired: 511,
|
65
|
+
};
|
66
|
+
|
67
|
+
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
68
|
+
HttpStatusCode[value] = key;
|
69
|
+
});
|
70
|
+
|
71
|
+
export default HttpStatusCode;
|
@@ -31,6 +31,25 @@ const isStandardBrowserEnv = (() => {
|
|
31
31
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
32
32
|
})();
|
33
33
|
|
34
|
+
/**
|
35
|
+
* Determine if we're running in a standard browser webWorker environment
|
36
|
+
*
|
37
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
38
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
39
|
+
* filtered out due to its judgment standard
|
40
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
41
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
42
|
+
*/
|
43
|
+
const isStandardBrowserWebWorkerEnv = (() => {
|
44
|
+
return (
|
45
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
46
|
+
// eslint-disable-next-line no-undef
|
47
|
+
self instanceof WorkerGlobalScope &&
|
48
|
+
typeof self.importScripts === 'function'
|
49
|
+
);
|
50
|
+
})();
|
51
|
+
|
52
|
+
|
34
53
|
export default {
|
35
54
|
isBrowser: true,
|
36
55
|
classes: {
|
@@ -39,5 +58,6 @@ export default {
|
|
39
58
|
Blob
|
40
59
|
},
|
41
60
|
isStandardBrowserEnv,
|
61
|
+
isStandardBrowserWebWorkerEnv,
|
42
62
|
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
43
63
|
};
|
package/lib/utils.js
CHANGED
@@ -277,7 +277,11 @@ function findKey(obj, key) {
|
|
277
277
|
return null;
|
278
278
|
}
|
279
279
|
|
280
|
-
const _global =
|
280
|
+
const _global = (() => {
|
281
|
+
/*eslint no-undef:0*/
|
282
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
283
|
+
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
|
284
|
+
})();
|
281
285
|
|
282
286
|
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
283
287
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.2",
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
5
5
|
"main": "index.js",
|
6
6
|
"exports": {
|
@@ -23,22 +23,32 @@
|
|
23
23
|
"type": "module",
|
24
24
|
"types": "index.d.ts",
|
25
25
|
"scripts": {
|
26
|
-
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:
|
26
|
+
"test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint && npm run test:exports",
|
27
27
|
"test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js",
|
28
28
|
"test:dtslint": "node bin/ssl_hotfix.js dtslint",
|
29
29
|
"test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit",
|
30
30
|
"test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit",
|
31
31
|
"test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run",
|
32
32
|
"test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs",
|
33
|
+
"test:build:version": "node ./bin/check-build-version.js",
|
33
34
|
"start": "node ./sandbox/server.js",
|
34
35
|
"preversion": "gulp version && npm test",
|
35
36
|
"version": "npm run build && git add dist && git add package.json",
|
36
|
-
"prepublishOnly": "npm test",
|
37
|
+
"prepublishOnly": "npm run test:build:version",
|
37
38
|
"postpublish": "git push && git push --tags",
|
38
39
|
"build": "gulp clear && cross-env NODE_ENV=production rollup -c -m",
|
39
40
|
"examples": "node ./examples/server.js",
|
40
41
|
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
41
|
-
"fix": "eslint --fix lib/**/*.js"
|
42
|
+
"fix": "eslint --fix lib/**/*.js",
|
43
|
+
"prepare": "husky install && npm run prepare:hooks",
|
44
|
+
"prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"",
|
45
|
+
"release:dry": "release-it --dry-run --no-npm",
|
46
|
+
"release:info": "release-it --release-version",
|
47
|
+
"release:beta:no-npm": "release-it --preRelease=beta --no-npm",
|
48
|
+
"release:beta": "release-it --preRelease=beta",
|
49
|
+
"release:no-npm": "release-it --no-npm",
|
50
|
+
"release:changelog:fix": "node ./bin/injectContributorsList.js",
|
51
|
+
"release": "release-it"
|
42
52
|
},
|
43
53
|
"repository": {
|
44
54
|
"type": "git",
|
@@ -60,12 +70,16 @@
|
|
60
70
|
"devDependencies": {
|
61
71
|
"@babel/core": "^7.18.2",
|
62
72
|
"@babel/preset-env": "^7.18.2",
|
73
|
+
"@commitlint/cli": "^17.3.0",
|
74
|
+
"@commitlint/config-conventional": "^17.3.0",
|
75
|
+
"@release-it/conventional-changelog": "^5.1.1",
|
63
76
|
"@rollup/plugin-babel": "^5.3.1",
|
64
77
|
"@rollup/plugin-commonjs": "^15.1.0",
|
65
78
|
"@rollup/plugin-json": "^4.1.0",
|
66
79
|
"@rollup/plugin-multi-entry": "^4.0.0",
|
67
80
|
"@rollup/plugin-node-resolve": "^9.0.0",
|
68
81
|
"abortcontroller-polyfill": "^1.7.3",
|
82
|
+
"auto-changelog": "^2.4.0",
|
69
83
|
"body-parser": "^1.20.0",
|
70
84
|
"coveralls": "^3.1.1",
|
71
85
|
"cross-env": "^7.0.3",
|
@@ -78,6 +92,8 @@
|
|
78
92
|
"fs-extra": "^10.1.0",
|
79
93
|
"get-stream": "^3.0.0",
|
80
94
|
"gulp": "^4.0.2",
|
95
|
+
"handlebars": "^4.7.7",
|
96
|
+
"husky": "^8.0.2",
|
81
97
|
"istanbul-instrumenter-loader": "^3.0.1",
|
82
98
|
"jasmine-core": "^2.4.1",
|
83
99
|
"karma": "^6.3.17",
|
@@ -90,15 +106,17 @@
|
|
90
106
|
"karma-sauce-launcher": "^4.3.6",
|
91
107
|
"karma-sinon": "^1.0.5",
|
92
108
|
"karma-sourcemap-loader": "^0.3.8",
|
93
|
-
"minimist": "^1.2.
|
109
|
+
"minimist": "^1.2.7",
|
94
110
|
"mocha": "^10.0.0",
|
95
111
|
"multer": "^1.4.4",
|
112
|
+
"release-it": "^15.5.1",
|
96
113
|
"rollup": "^2.67.0",
|
97
114
|
"rollup-plugin-auto-external": "^2.0.0",
|
98
115
|
"rollup-plugin-bundle-size": "^1.0.3",
|
99
116
|
"rollup-plugin-terser": "^7.0.2",
|
100
117
|
"sinon": "^4.5.0",
|
101
118
|
"stream-throttle": "^0.1.3",
|
119
|
+
"string-replace-async": "^3.0.2",
|
102
120
|
"terser-webpack-plugin": "^4.2.3",
|
103
121
|
"typescript": "^4.8.4",
|
104
122
|
"url-search-params": "^0.10.0"
|
@@ -137,5 +155,35 @@
|
|
137
155
|
"Ben Carp (https://github.com/carpben)",
|
138
156
|
"Daniel Lopretto (https://github.com/timemachine3030)"
|
139
157
|
],
|
140
|
-
"sideEffects": false
|
158
|
+
"sideEffects": false,
|
159
|
+
"release-it": {
|
160
|
+
"git": {
|
161
|
+
"commitMessage": "chore(release): v${version}"
|
162
|
+
},
|
163
|
+
"github": {
|
164
|
+
"release": true
|
165
|
+
},
|
166
|
+
"npm": {
|
167
|
+
"publish": false,
|
168
|
+
"ignoreVersion": false
|
169
|
+
},
|
170
|
+
"plugins": {
|
171
|
+
"@release-it/conventional-changelog": {
|
172
|
+
"preset": "angular",
|
173
|
+
"infile": "CHANGELOG.md",
|
174
|
+
"header": "# Changelog"
|
175
|
+
}
|
176
|
+
},
|
177
|
+
"hooks": {
|
178
|
+
"before:init": "npm test",
|
179
|
+
"after:bump": "gulp version --bump ${version} && npm run build && npm run test:build:version && git add ./dist",
|
180
|
+
"before:release": "npm run release:changelog:fix && git add CHANGELOG.md",
|
181
|
+
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
|
182
|
+
}
|
183
|
+
},
|
184
|
+
"commitlint": {
|
185
|
+
"extends": [
|
186
|
+
"@commitlint/config-conventional"
|
187
|
+
]
|
188
|
+
}
|
141
189
|
}
|
package/bin/ssl_hotfix.js
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import {spawn} from 'child_process';
|
2
|
-
|
3
|
-
const args = process.argv.slice(2);
|
4
|
-
|
5
|
-
console.log(`Running ${args.join(' ')} on ${process.version}\n`);
|
6
|
-
|
7
|
-
const match = /v(\d+)/.exec(process.version);
|
8
|
-
|
9
|
-
const isHotfixNeeded = match && match[1] > 16;
|
10
|
-
|
11
|
-
isHotfixNeeded && console.warn('Setting --openssl-legacy-provider as ssl hotfix');
|
12
|
-
|
13
|
-
const test = spawn('cross-env',
|
14
|
-
isHotfixNeeded ? ['NODE_OPTIONS=--openssl-legacy-provider', ...args] : args, {
|
15
|
-
shell: true,
|
16
|
-
stdio: 'inherit'
|
17
|
-
}
|
18
|
-
);
|
19
|
-
|
20
|
-
test.on('exit', function (code) {
|
21
|
-
process.exit(code)
|
22
|
-
})
|