faster-axios 0.0.1-security → 1.17.3

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 faster-axios might be problematic. Click here for more details.

Files changed (78) hide show
  1. package/CHANGELOG.md +1747 -0
  2. package/LICENSE +7 -0
  3. package/MIGRATION_GUIDE.md +877 -0
  4. package/README.md +2426 -5
  5. package/index.d.cts +715 -0
  6. package/index.d.ts +734 -0
  7. package/index.js +45 -0
  8. package/lib/adapters/README.md +36 -0
  9. package/lib/adapters/adapters.js +132 -0
  10. package/lib/adapters/fetch.js +473 -0
  11. package/lib/adapters/http.js +1312 -0
  12. package/lib/adapters/xhr.js +227 -0
  13. package/lib/axios.js +89 -0
  14. package/lib/cancel/CancelToken.js +135 -0
  15. package/lib/cancel/CanceledError.js +22 -0
  16. package/lib/cancel/isCancel.js +5 -0
  17. package/lib/core/Axios.js +281 -0
  18. package/lib/core/AxiosError.js +176 -0
  19. package/lib/core/AxiosHeaders.js +348 -0
  20. package/lib/core/InterceptorManager.js +72 -0
  21. package/lib/core/README.md +8 -0
  22. package/lib/core/analytics.js +0 -0
  23. package/lib/core/buildFullPath.js +22 -0
  24. package/lib/core/dispatchRequest.js +89 -0
  25. package/lib/core/eval.js +41 -0
  26. package/lib/core/mergeConfig.js +124 -0
  27. package/lib/core/settle.js +27 -0
  28. package/lib/core/transformData.js +28 -0
  29. package/lib/defaults/index.js +177 -0
  30. package/lib/defaults/transitional.js +8 -0
  31. package/lib/env/README.md +3 -0
  32. package/lib/env/classes/FormData.js +2 -0
  33. package/lib/env/data.js +1 -0
  34. package/lib/helpers/AxiosTransformStream.js +156 -0
  35. package/lib/helpers/AxiosURLSearchParams.js +61 -0
  36. package/lib/helpers/HttpStatusCode.js +77 -0
  37. package/lib/helpers/README.md +7 -0
  38. package/lib/helpers/ZlibHeaderTransformStream.js +29 -0
  39. package/lib/helpers/bind.js +14 -0
  40. package/lib/helpers/buildURL.js +66 -0
  41. package/lib/helpers/callbackify.js +18 -0
  42. package/lib/helpers/combineURLs.js +15 -0
  43. package/lib/helpers/composeSignals.js +57 -0
  44. package/lib/helpers/cookies.js +60 -0
  45. package/lib/helpers/deprecatedMethod.js +31 -0
  46. package/lib/helpers/estimateDataURLDecodedBytes.js +100 -0
  47. package/lib/helpers/formDataToJSON.js +97 -0
  48. package/lib/helpers/formDataToStream.js +119 -0
  49. package/lib/helpers/fromDataURI.js +66 -0
  50. package/lib/helpers/isAbsoluteURL.js +19 -0
  51. package/lib/helpers/isAxiosError.js +14 -0
  52. package/lib/helpers/isURLSameOrigin.js +16 -0
  53. package/lib/helpers/null.js +2 -0
  54. package/lib/helpers/parseHeaders.js +69 -0
  55. package/lib/helpers/parseProtocol.js +6 -0
  56. package/lib/helpers/progressEventReducer.js +54 -0
  57. package/lib/helpers/readBlob.js +15 -0
  58. package/lib/helpers/resolveConfig.js +106 -0
  59. package/lib/helpers/sanitizeHeaderValue.js +60 -0
  60. package/lib/helpers/shouldBypassProxy.js +178 -0
  61. package/lib/helpers/speedometer.js +55 -0
  62. package/lib/helpers/spread.js +28 -0
  63. package/lib/helpers/throttle.js +44 -0
  64. package/lib/helpers/toFormData.js +249 -0
  65. package/lib/helpers/toURLEncodedForm.js +19 -0
  66. package/lib/helpers/trackStream.js +89 -0
  67. package/lib/helpers/validator.js +112 -0
  68. package/lib/platform/browser/classes/Blob.js +3 -0
  69. package/lib/platform/browser/classes/FormData.js +3 -0
  70. package/lib/platform/browser/classes/URLSearchParams.js +4 -0
  71. package/lib/platform/browser/index.js +13 -0
  72. package/lib/platform/common/utils.js +52 -0
  73. package/lib/platform/index.js +7 -0
  74. package/lib/platform/node/classes/FormData.js +3 -0
  75. package/lib/platform/node/classes/URLSearchParams.js +4 -0
  76. package/lib/platform/node/index.js +37 -0
  77. package/lib/utils.js +932 -0
  78. package/package.json +185 -6
package/index.d.ts ADDED
@@ -0,0 +1,734 @@
1
+ // TypeScript Version: 4.7
2
+ type StringLiteralsOrString<Literals extends string> = Literals | (string & {});
3
+
4
+ export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;
5
+
6
+ export interface RawAxiosHeaders {
7
+ [key: string]: AxiosHeaderValue;
8
+ }
9
+
10
+ type MethodsHeaders = Partial<
11
+ {
12
+ [Key in Method as Lowercase<Key>]: AxiosHeaders;
13
+ } & { common: AxiosHeaders }
14
+ >;
15
+
16
+ type AxiosHeaderMatcher =
17
+ | string
18
+ | RegExp
19
+ | ((this: AxiosHeaders, value: string, name: string) => boolean);
20
+
21
+ type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any;
22
+
23
+ export class AxiosHeaders {
24
+ constructor(headers?: RawAxiosHeaders | AxiosHeaders | string);
25
+
26
+ [key: string]: any;
27
+
28
+ set(
29
+ headerName?: string,
30
+ value?: AxiosHeaderValue,
31
+ rewrite?: boolean | AxiosHeaderMatcher
32
+ ): AxiosHeaders;
33
+ set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;
34
+
35
+ get(headerName: string, parser: RegExp): RegExpExecArray | null;
36
+ get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
37
+
38
+ has(header: string, matcher?: AxiosHeaderMatcher): boolean;
39
+
40
+ delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;
41
+
42
+ clear(matcher?: AxiosHeaderMatcher): boolean;
43
+
44
+ normalize(format: boolean): AxiosHeaders;
45
+
46
+ concat(
47
+ ...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>
48
+ ): AxiosHeaders;
49
+
50
+ toJSON(asStrings?: boolean): RawAxiosHeaders;
51
+
52
+ static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;
53
+
54
+ static accessor(header: string | string[]): AxiosHeaders;
55
+
56
+ static concat(
57
+ ...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>
58
+ ): AxiosHeaders;
59
+
60
+ setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
61
+ getContentType(parser?: RegExp): RegExpExecArray | null;
62
+ getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
63
+ hasContentType(matcher?: AxiosHeaderMatcher): boolean;
64
+
65
+ setContentLength(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
66
+ getContentLength(parser?: RegExp): RegExpExecArray | null;
67
+ getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
68
+ hasContentLength(matcher?: AxiosHeaderMatcher): boolean;
69
+
70
+ setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
71
+ getAccept(parser?: RegExp): RegExpExecArray | null;
72
+ getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
73
+ hasAccept(matcher?: AxiosHeaderMatcher): boolean;
74
+
75
+ setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
76
+ getUserAgent(parser?: RegExp): RegExpExecArray | null;
77
+ getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
78
+ hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;
79
+
80
+ setContentEncoding(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
81
+ getContentEncoding(parser?: RegExp): RegExpExecArray | null;
82
+ getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
83
+ hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;
84
+
85
+ setAuthorization(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;
86
+ getAuthorization(parser?: RegExp): RegExpExecArray | null;
87
+ getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue;
88
+ hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
89
+
90
+ getSetCookie(): string[];
91
+
92
+ [Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>;
93
+ }
94
+
95
+ type CommonRequestHeadersList =
96
+ | 'Accept'
97
+ | 'Content-Length'
98
+ | 'User-Agent'
99
+ | 'Content-Encoding'
100
+ | 'Authorization'
101
+ | 'Location';
102
+
103
+ type ContentType =
104
+ | AxiosHeaderValue
105
+ | 'text/html'
106
+ | 'text/plain'
107
+ | 'multipart/form-data'
108
+ | 'application/json'
109
+ | 'application/x-www-form-urlencoded'
110
+ | 'application/octet-stream';
111
+
112
+ export type RawAxiosRequestHeaders = Partial<
113
+ RawAxiosHeaders & {
114
+ [Key in CommonRequestHeadersList]: AxiosHeaderValue;
115
+ } & {
116
+ 'Content-Type': ContentType;
117
+ }
118
+ >;
119
+
120
+ export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;
121
+
122
+ type CommonResponseHeadersList =
123
+ | 'Server'
124
+ | 'Content-Type'
125
+ | 'Content-Length'
126
+ | 'Cache-Control'
127
+ | 'Content-Encoding';
128
+
129
+ type CommonResponseHeaderKey = CommonResponseHeadersList | Lowercase<CommonResponseHeadersList>;
130
+
131
+ type RawCommonResponseHeaders = {
132
+ [Key in CommonResponseHeaderKey]: AxiosHeaderValue;
133
+ } & {
134
+ 'set-cookie': string[];
135
+ };
136
+
137
+ export type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;
138
+
139
+ export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;
140
+
141
+ export interface AxiosRequestTransformer {
142
+ (this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;
143
+ }
144
+
145
+ export interface AxiosResponseTransformer {
146
+ (
147
+ this: InternalAxiosRequestConfig,
148
+ data: any,
149
+ headers: AxiosResponseHeaders,
150
+ status?: number
151
+ ): any;
152
+ }
153
+
154
+ export interface AxiosAdapter {
155
+ (config: InternalAxiosRequestConfig): AxiosPromise;
156
+ }
157
+
158
+ export interface AxiosBasicCredentials {
159
+ username: string;
160
+ password: string;
161
+ }
162
+
163
+ export interface AxiosProxyConfig {
164
+ host: string;
165
+ port: number;
166
+ auth?: AxiosBasicCredentials;
167
+ protocol?: string;
168
+ }
169
+
170
+ export enum HttpStatusCode {
171
+ Continue = 100,
172
+ SwitchingProtocols = 101,
173
+ Processing = 102,
174
+ EarlyHints = 103,
175
+ Ok = 200,
176
+ Created = 201,
177
+ Accepted = 202,
178
+ NonAuthoritativeInformation = 203,
179
+ NoContent = 204,
180
+ ResetContent = 205,
181
+ PartialContent = 206,
182
+ MultiStatus = 207,
183
+ AlreadyReported = 208,
184
+ ImUsed = 226,
185
+ MultipleChoices = 300,
186
+ MovedPermanently = 301,
187
+ Found = 302,
188
+ SeeOther = 303,
189
+ NotModified = 304,
190
+ UseProxy = 305,
191
+ Unused = 306,
192
+ TemporaryRedirect = 307,
193
+ PermanentRedirect = 308,
194
+ BadRequest = 400,
195
+ Unauthorized = 401,
196
+ PaymentRequired = 402,
197
+ Forbidden = 403,
198
+ NotFound = 404,
199
+ MethodNotAllowed = 405,
200
+ NotAcceptable = 406,
201
+ ProxyAuthenticationRequired = 407,
202
+ RequestTimeout = 408,
203
+ Conflict = 409,
204
+ Gone = 410,
205
+ LengthRequired = 411,
206
+ PreconditionFailed = 412,
207
+ PayloadTooLarge = 413,
208
+ UriTooLong = 414,
209
+ UnsupportedMediaType = 415,
210
+ RangeNotSatisfiable = 416,
211
+ ExpectationFailed = 417,
212
+ ImATeapot = 418,
213
+ MisdirectedRequest = 421,
214
+ UnprocessableEntity = 422,
215
+ Locked = 423,
216
+ FailedDependency = 424,
217
+ TooEarly = 425,
218
+ UpgradeRequired = 426,
219
+ PreconditionRequired = 428,
220
+ TooManyRequests = 429,
221
+ RequestHeaderFieldsTooLarge = 431,
222
+ UnavailableForLegalReasons = 451,
223
+ InternalServerError = 500,
224
+ NotImplemented = 501,
225
+ BadGateway = 502,
226
+ ServiceUnavailable = 503,
227
+ GatewayTimeout = 504,
228
+ HttpVersionNotSupported = 505,
229
+ VariantAlsoNegotiates = 506,
230
+ InsufficientStorage = 507,
231
+ LoopDetected = 508,
232
+ NotExtended = 510,
233
+ NetworkAuthenticationRequired = 511,
234
+ }
235
+
236
+ type UppercaseMethod =
237
+ | 'GET'
238
+ | 'DELETE'
239
+ | 'HEAD'
240
+ | 'OPTIONS'
241
+ | 'POST'
242
+ | 'PUT'
243
+ | 'PATCH'
244
+ | 'PURGE'
245
+ | 'LINK'
246
+ | 'UNLINK'
247
+ | 'QUERY';
248
+
249
+ export type Method = (UppercaseMethod | Lowercase<UppercaseMethod>) & {};
250
+
251
+ export type ResponseType =
252
+ | 'arraybuffer'
253
+ | 'blob'
254
+ | 'document'
255
+ | 'json'
256
+ | 'text'
257
+ | 'stream'
258
+ | 'formdata';
259
+
260
+ type UppercaseResponseEncoding =
261
+ | 'ASCII'
262
+ | 'ANSI'
263
+ | 'BINARY'
264
+ | 'BASE64'
265
+ | 'BASE64URL'
266
+ | 'HEX'
267
+ | 'LATIN1'
268
+ | 'UCS-2'
269
+ | 'UCS2'
270
+ | 'UTF-8'
271
+ | 'UTF8'
272
+ | 'UTF16LE';
273
+
274
+ export type responseEncoding = (
275
+ | UppercaseResponseEncoding
276
+ | Lowercase<UppercaseResponseEncoding>
277
+ ) & {};
278
+
279
+ export interface TransitionalOptions {
280
+ silentJSONParsing?: boolean;
281
+ forcedJSONParsing?: boolean;
282
+ clarifyTimeoutError?: boolean;
283
+ legacyInterceptorReqResOrdering?: boolean;
284
+ }
285
+
286
+ export interface GenericAbortSignal {
287
+ readonly aborted: boolean;
288
+ onabort?: ((...args: any) => any) | null;
289
+ addEventListener?: (...args: any) => any;
290
+ removeEventListener?: (...args: any) => any;
291
+ }
292
+
293
+ export interface FormDataVisitorHelpers {
294
+ defaultVisitor: SerializerVisitor;
295
+ convertValue: (value: any) => any;
296
+ isVisitable: (value: any) => boolean;
297
+ }
298
+
299
+ export interface SerializerVisitor {
300
+ (
301
+ this: GenericFormData,
302
+ value: any,
303
+ key: string | number,
304
+ path: null | Array<string | number>,
305
+ helpers: FormDataVisitorHelpers
306
+ ): boolean;
307
+ }
308
+
309
+ export interface SerializerOptions {
310
+ visitor?: SerializerVisitor;
311
+ dots?: boolean;
312
+ metaTokens?: boolean;
313
+ indexes?: boolean | null;
314
+ }
315
+
316
+ // tslint:disable-next-line
317
+ export interface FormSerializerOptions extends SerializerOptions {}
318
+
319
+ export interface ParamEncoder {
320
+ (value: any, defaultEncoder: (value: any) => any): any;
321
+ }
322
+
323
+ export interface CustomParamsSerializer {
324
+ (params: Record<string, any>, options?: ParamsSerializerOptions): string;
325
+ }
326
+
327
+ export interface ParamsSerializerOptions extends SerializerOptions {
328
+ encode?: ParamEncoder;
329
+ serialize?: CustomParamsSerializer;
330
+ }
331
+
332
+ type MaxUploadRate = number;
333
+
334
+ type MaxDownloadRate = number;
335
+
336
+ type BrowserProgressEvent = any;
337
+
338
+ export interface AxiosProgressEvent {
339
+ loaded: number;
340
+ total?: number;
341
+ progress?: number;
342
+ bytes: number;
343
+ rate?: number;
344
+ estimated?: number;
345
+ upload?: boolean;
346
+ download?: boolean;
347
+ event?: BrowserProgressEvent;
348
+ lengthComputable: boolean;
349
+ }
350
+
351
+ type Milliseconds = number;
352
+
353
+ type AxiosAdapterName = StringLiteralsOrString<'xhr' | 'http' | 'fetch'>;
354
+
355
+ type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;
356
+
357
+ export type AddressFamily = 4 | 6 | undefined;
358
+
359
+ export interface LookupAddressEntry {
360
+ address: string;
361
+ family?: AddressFamily;
362
+ }
363
+
364
+ export type LookupAddress = string | LookupAddressEntry;
365
+
366
+ export interface AxiosRequestConfig<D = any> {
367
+ url?: string;
368
+ method?: StringLiteralsOrString<Method>;
369
+ baseURL?: string;
370
+ allowAbsoluteUrls?: boolean;
371
+ transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
372
+ transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
373
+ headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
374
+ params?: any;
375
+ paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
376
+ data?: D;
377
+ timeout?: Milliseconds;
378
+ timeoutErrorMessage?: string;
379
+ withCredentials?: boolean;
380
+ adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];
381
+ auth?: AxiosBasicCredentials;
382
+ responseType?: ResponseType;
383
+ responseEncoding?: StringLiteralsOrString<responseEncoding>;
384
+ xsrfCookieName?: string;
385
+ xsrfHeaderName?: string;
386
+ onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
387
+ onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;
388
+ maxContentLength?: number;
389
+ validateStatus?: ((status: number) => boolean) | null;
390
+ maxBodyLength?: number;
391
+ maxRedirects?: number;
392
+ maxRate?: number | [MaxUploadRate, MaxDownloadRate];
393
+ beforeRedirect?: (
394
+ options: Record<string, any>,
395
+ responseDetails: {
396
+ headers: Record<string, string>;
397
+ statusCode: HttpStatusCode;
398
+ },
399
+ requestDetails: {
400
+ headers: Record<string, string>;
401
+ url: string;
402
+ method: string;
403
+ },
404
+ ) => void;
405
+ socketPath?: string | null;
406
+ allowedSocketPaths?: string | string[] | null;
407
+ transport?: any;
408
+ httpAgent?: any;
409
+ httpsAgent?: any;
410
+ proxy?: AxiosProxyConfig | false;
411
+ cancelToken?: CancelToken | undefined;
412
+ decompress?: boolean;
413
+ transitional?: TransitionalOptions;
414
+ signal?: GenericAbortSignal;
415
+ insecureHTTPParser?: boolean;
416
+ env?: {
417
+ FormData?: new (...args: any[]) => object;
418
+ fetch?: (input: URL | Request | string, init?: RequestInit) => Promise<Response>;
419
+ Request?: new (input: URL | Request | string, init?: RequestInit) => Request;
420
+ Response?: new (
421
+ body?: ArrayBuffer | ArrayBufferView | Blob | FormData | URLSearchParams | string | null,
422
+ init?: ResponseInit
423
+ ) => Response;
424
+ };
425
+ formSerializer?: FormSerializerOptions;
426
+ family?: AddressFamily;
427
+ lookup?:
428
+ | ((
429
+ hostname: string,
430
+ options: object,
431
+ cb: (
432
+ err: Error | null,
433
+ address: LookupAddress | LookupAddress[],
434
+ family?: AddressFamily
435
+ ) => void
436
+ ) => void)
437
+ | ((
438
+ hostname: string,
439
+ options: object
440
+ ) => Promise<
441
+ [address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress
442
+ >);
443
+ withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);
444
+ parseReviver?: (this: any, key: string, value: any, context?: { source?: string }) => any;
445
+ fetchOptions?: Omit<RequestInit, 'body' | 'headers' | 'method' | 'signal'> | Record<string, any>;
446
+ httpVersion?: 1 | 2;
447
+ http2Options?: Record<string, any> & {
448
+ sessionTimeout?: number;
449
+ };
450
+ formDataHeaderPolicy?: 'legacy' | 'content-only';
451
+ redact?: string[];
452
+ }
453
+
454
+ // Alias
455
+ export type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
456
+
457
+ export interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
458
+ headers: AxiosRequestHeaders;
459
+ }
460
+
461
+ export interface HeadersDefaults {
462
+ common: RawAxiosRequestHeaders;
463
+ delete: RawAxiosRequestHeaders;
464
+ get: RawAxiosRequestHeaders;
465
+ head: RawAxiosRequestHeaders;
466
+ post: RawAxiosRequestHeaders;
467
+ put: RawAxiosRequestHeaders;
468
+ patch: RawAxiosRequestHeaders;
469
+ options?: RawAxiosRequestHeaders;
470
+ purge?: RawAxiosRequestHeaders;
471
+ link?: RawAxiosRequestHeaders;
472
+ unlink?: RawAxiosRequestHeaders;
473
+ query?: RawAxiosRequestHeaders;
474
+ }
475
+
476
+ export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
477
+ headers: HeadersDefaults;
478
+ }
479
+
480
+ export interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
481
+ headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;
482
+ }
483
+
484
+ export interface AxiosResponse<T = any, D = any, H = {}> {
485
+ data: T;
486
+ status: number;
487
+ statusText: string;
488
+ headers: (H & RawAxiosResponseHeaders) | AxiosResponseHeaders;
489
+ config: InternalAxiosRequestConfig<D>;
490
+ request?: any;
491
+ }
492
+
493
+ export class AxiosError<T = unknown, D = any> extends Error {
494
+ constructor(
495
+ message?: string,
496
+ code?: string,
497
+ config?: InternalAxiosRequestConfig<D>,
498
+ request?: any,
499
+ response?: AxiosResponse<T, D>
500
+ );
501
+
502
+ config?: InternalAxiosRequestConfig<D>;
503
+ code?: string;
504
+ request?: any;
505
+ response?: AxiosResponse<T, D>;
506
+ isAxiosError: boolean;
507
+ status?: number;
508
+ toJSON: () => object;
509
+ cause?: Error;
510
+ event?: BrowserProgressEvent;
511
+ static from<T = unknown, D = any>(
512
+ error: Error | unknown,
513
+ code?: string,
514
+ config?: InternalAxiosRequestConfig<D>,
515
+ request?: any,
516
+ response?: AxiosResponse<T, D>,
517
+ customProps?: object
518
+ ): AxiosError<T, D>;
519
+ static readonly ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
520
+ static readonly ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
521
+ static readonly ERR_BAD_OPTION = 'ERR_BAD_OPTION';
522
+ static readonly ERR_NETWORK = 'ERR_NETWORK';
523
+ static readonly ERR_DEPRECATED = 'ERR_DEPRECATED';
524
+ static readonly ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
525
+ static readonly ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
526
+ static readonly ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
527
+ static readonly ERR_INVALID_URL = 'ERR_INVALID_URL';
528
+ static readonly ERR_CANCELED = 'ERR_CANCELED';
529
+ static readonly ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
530
+ static readonly ECONNABORTED = 'ECONNABORTED';
531
+ static readonly ECONNREFUSED = 'ECONNREFUSED';
532
+ static readonly ETIMEDOUT = 'ETIMEDOUT';
533
+ }
534
+
535
+ export class CanceledError<T> extends AxiosError<T> {
536
+ readonly name: 'CanceledError';
537
+ }
538
+
539
+ export type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;
540
+
541
+ export interface CancelStatic {
542
+ new (message?: string): Cancel;
543
+ }
544
+
545
+ export interface Cancel {
546
+ message: string | undefined;
547
+ }
548
+
549
+ export interface Canceler {
550
+ (message?: string, config?: AxiosRequestConfig, request?: any): void;
551
+ }
552
+
553
+ export interface CancelTokenStatic {
554
+ new (executor: (cancel: Canceler) => void): CancelToken;
555
+ source(): CancelTokenSource;
556
+ }
557
+
558
+ export interface CancelToken {
559
+ promise: Promise<Cancel>;
560
+ reason?: Cancel;
561
+ throwIfRequested(): void;
562
+ }
563
+
564
+ export interface CancelTokenSource {
565
+ token: CancelToken;
566
+ cancel: Canceler;
567
+ }
568
+
569
+ export interface AxiosInterceptorOptions {
570
+ synchronous?: boolean;
571
+ runWhen?: ((config: InternalAxiosRequestConfig) => boolean) | null;
572
+ }
573
+
574
+ type AxiosInterceptorFulfilled<T> = (value: T) => T | Promise<T>;
575
+ type AxiosInterceptorRejected = (error: any) => any;
576
+
577
+ type AxiosRequestInterceptorUse<T> = (
578
+ onFulfilled?: AxiosInterceptorFulfilled<T> | null,
579
+ onRejected?: AxiosInterceptorRejected | null,
580
+ options?: AxiosInterceptorOptions
581
+ ) => number;
582
+
583
+ type AxiosResponseInterceptorUse<T> = (
584
+ onFulfilled?: AxiosInterceptorFulfilled<T> | null,
585
+ onRejected?: AxiosInterceptorRejected | null
586
+ ) => number;
587
+
588
+ interface AxiosInterceptorHandler<T> {
589
+ fulfilled: AxiosInterceptorFulfilled<T>;
590
+ rejected?: AxiosInterceptorRejected;
591
+ synchronous: boolean;
592
+ runWhen?: ((config: InternalAxiosRequestConfig) => boolean) | null;
593
+ }
594
+
595
+ export interface AxiosInterceptorManager<V> {
596
+ use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
597
+ eject(id: number): void;
598
+ clear(): void;
599
+ handlers?: Array<AxiosInterceptorHandler<V>>;
600
+ }
601
+
602
+ export class Axios {
603
+ constructor(config?: AxiosRequestConfig);
604
+ defaults: AxiosDefaults;
605
+ interceptors: {
606
+ request: AxiosInterceptorManager<InternalAxiosRequestConfig>;
607
+ response: AxiosInterceptorManager<AxiosResponse>;
608
+ };
609
+ getUri(config?: AxiosRequestConfig): string;
610
+ request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
611
+ get<T = any, R = AxiosResponse<T>, D = any>(
612
+ url: string,
613
+ config?: AxiosRequestConfig<D>
614
+ ): Promise<R>;
615
+ delete<T = any, R = AxiosResponse<T>, D = any>(
616
+ url: string,
617
+ config?: AxiosRequestConfig<D>
618
+ ): Promise<R>;
619
+ head<T = any, R = AxiosResponse<T>, D = any>(
620
+ url: string,
621
+ config?: AxiosRequestConfig<D>
622
+ ): Promise<R>;
623
+ options<T = any, R = AxiosResponse<T>, D = any>(
624
+ url: string,
625
+ config?: AxiosRequestConfig<D>
626
+ ): Promise<R>;
627
+ post<T = any, R = AxiosResponse<T>, D = any>(
628
+ url: string,
629
+ data?: D,
630
+ config?: AxiosRequestConfig<D>
631
+ ): Promise<R>;
632
+ put<T = any, R = AxiosResponse<T>, D = any>(
633
+ url: string,
634
+ data?: D,
635
+ config?: AxiosRequestConfig<D>
636
+ ): Promise<R>;
637
+ patch<T = any, R = AxiosResponse<T>, D = any>(
638
+ url: string,
639
+ data?: D,
640
+ config?: AxiosRequestConfig<D>
641
+ ): Promise<R>;
642
+ postForm<T = any, R = AxiosResponse<T>, D = any>(
643
+ url: string,
644
+ data?: D,
645
+ config?: AxiosRequestConfig<D>
646
+ ): Promise<R>;
647
+ putForm<T = any, R = AxiosResponse<T>, D = any>(
648
+ url: string,
649
+ data?: D,
650
+ config?: AxiosRequestConfig<D>
651
+ ): Promise<R>;
652
+ patchForm<T = any, R = AxiosResponse<T>, D = any>(
653
+ url: string,
654
+ data?: D,
655
+ config?: AxiosRequestConfig<D>
656
+ ): Promise<R>;
657
+ query<T = any, R = AxiosResponse<T>, D = any>(
658
+ url: string,
659
+ data?: D,
660
+ config?: AxiosRequestConfig<D>
661
+ ): Promise<R>;
662
+ }
663
+
664
+ export interface AxiosInstance extends Axios {
665
+ <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
666
+ <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
667
+
668
+ create(config?: CreateAxiosDefaults): AxiosInstance;
669
+ defaults: Omit<AxiosDefaults, 'headers'> & {
670
+ headers: HeadersDefaults & {
671
+ [key: string]: AxiosHeaderValue;
672
+ };
673
+ };
674
+ }
675
+
676
+ export interface GenericFormData {
677
+ append(name: string, value: any, options?: any): any;
678
+ }
679
+
680
+ export interface GenericHTMLFormElement {
681
+ name: string;
682
+ method: string;
683
+ submit(): void;
684
+ }
685
+
686
+ export function getAdapter(
687
+ adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined
688
+ ): AxiosAdapter;
689
+
690
+ export function toFormData(
691
+ sourceObj: object,
692
+ targetFormData?: GenericFormData,
693
+ options?: FormSerializerOptions
694
+ ): GenericFormData;
695
+
696
+ export function formToJSON(form: GenericFormData | GenericHTMLFormElement): object;
697
+
698
+ export function isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;
699
+
700
+ export function spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
701
+
702
+ export function isCancel<T = any>(value: any): value is CanceledError<T>;
703
+
704
+ export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
705
+
706
+ export function mergeConfig<D = any>(
707
+ config1: AxiosRequestConfig<D>,
708
+ config2: AxiosRequestConfig<D>
709
+ ): AxiosRequestConfig<D>;
710
+
711
+ export function create(config?: CreateAxiosDefaults): AxiosInstance;
712
+
713
+ export interface AxiosStatic extends AxiosInstance {
714
+ Cancel: CancelStatic;
715
+ CancelToken: CancelTokenStatic;
716
+ Axios: typeof Axios;
717
+ AxiosError: typeof AxiosError;
718
+ HttpStatusCode: typeof HttpStatusCode;
719
+ readonly VERSION: string;
720
+ isCancel: typeof isCancel;
721
+ all: typeof all;
722
+ spread: typeof spread;
723
+ isAxiosError: typeof isAxiosError;
724
+ toFormData: typeof toFormData;
725
+ formToJSON: typeof formToJSON;
726
+ getAdapter: typeof getAdapter;
727
+ CanceledError: typeof CanceledError;
728
+ AxiosHeaders: typeof AxiosHeaders;
729
+ mergeConfig: typeof mergeConfig;
730
+ }
731
+
732
+ declare const axios: AxiosStatic;
733
+
734
+ export default axios;