axios 1.15.2 → 1.16.1
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 +103 -6
- package/README.md +396 -25
- package/dist/axios.js +1455 -1109
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +3 -3
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +1569 -1174
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +1569 -1173
- 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 +1395 -915
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +25 -13
- package/index.d.ts +21 -4
- package/index.js +2 -0
- package/lib/adapters/adapters.js +4 -2
- package/lib/adapters/fetch.js +131 -11
- package/lib/adapters/http.js +298 -69
- package/lib/adapters/xhr.js +8 -3
- package/lib/core/Axios.js +7 -3
- package/lib/core/AxiosError.js +86 -1
- package/lib/core/AxiosHeaders.js +4 -33
- package/lib/core/dispatchRequest.js +19 -7
- package/lib/core/mergeConfig.js +6 -3
- package/lib/core/settle.js +7 -11
- package/lib/defaults/index.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +1 -1
- package/lib/helpers/composeSignals.js +48 -47
- package/lib/helpers/cookies.js +14 -2
- package/lib/helpers/estimateDataURLDecodedBytes.js +28 -1
- package/lib/helpers/formDataToJSON.js +1 -1
- package/lib/helpers/formDataToStream.js +1 -1
- package/lib/helpers/fromDataURI.js +18 -5
- package/lib/helpers/parseProtocol.js +1 -1
- package/lib/helpers/progressEventReducer.js +3 -0
- package/lib/helpers/resolveConfig.js +33 -17
- package/lib/helpers/sanitizeHeaderValue.js +60 -0
- package/lib/helpers/shouldBypassProxy.js +26 -1
- package/lib/helpers/validator.js +1 -1
- package/lib/utils.js +35 -22
- package/package.json +19 -24
package/dist/browser/axios.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Axios v1.
|
|
1
|
+
/*! Axios v1.16.1 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -204,9 +204,9 @@ const isFile = kindOfTest('File');
|
|
|
204
204
|
* also have a `name` and `type` attribute to specify filename and content type
|
|
205
205
|
*
|
|
206
206
|
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
207
|
-
*
|
|
207
|
+
*
|
|
208
208
|
* @param {*} value The value to test
|
|
209
|
-
*
|
|
209
|
+
*
|
|
210
210
|
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
211
211
|
*/
|
|
212
212
|
const isReactNativeBlob = (value) => {
|
|
@@ -216,9 +216,9 @@ const isReactNativeBlob = (value) => {
|
|
|
216
216
|
/**
|
|
217
217
|
* Determine if environment is React Native
|
|
218
218
|
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
219
|
-
*
|
|
219
|
+
*
|
|
220
220
|
* @param {*} formData The formData to test
|
|
221
|
-
*
|
|
221
|
+
*
|
|
222
222
|
* @returns {boolean} True if environment is React Native, otherwise false
|
|
223
223
|
*/
|
|
224
224
|
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
@@ -237,7 +237,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
237
237
|
*
|
|
238
238
|
* @param {*} val The value to test
|
|
239
239
|
*
|
|
240
|
-
* @returns {boolean} True if value is a
|
|
240
|
+
* @returns {boolean} True if value is a FileList, otherwise false
|
|
241
241
|
*/
|
|
242
242
|
const isFileList = kindOfTest('FileList');
|
|
243
243
|
|
|
@@ -271,14 +271,16 @@ const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
|
271
271
|
const isFormData = (thing) => {
|
|
272
272
|
if (!thing) return false;
|
|
273
273
|
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
274
|
-
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData
|
|
274
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
275
275
|
const proto = getPrototypeOf(thing);
|
|
276
276
|
if (!proto || proto === Object.prototype) return false;
|
|
277
277
|
if (!isFunction$1(thing.append)) return false;
|
|
278
278
|
const kind = kindOf(thing);
|
|
279
|
-
return
|
|
279
|
+
return (
|
|
280
|
+
kind === 'formdata' ||
|
|
280
281
|
// detect form-data instance
|
|
281
|
-
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
282
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
283
|
+
);
|
|
282
284
|
};
|
|
283
285
|
|
|
284
286
|
/**
|
|
@@ -413,7 +415,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
413
415
|
*
|
|
414
416
|
* @returns {Object} Result of all merge properties
|
|
415
417
|
*/
|
|
416
|
-
function merge(
|
|
418
|
+
function merge(...objs) {
|
|
417
419
|
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
418
420
|
const result = {};
|
|
419
421
|
const assignValue = (val, key) => {
|
|
@@ -423,8 +425,12 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
423
425
|
}
|
|
424
426
|
|
|
425
427
|
const targetKey = (caseless && findKey(result, key)) || key;
|
|
426
|
-
|
|
427
|
-
|
|
428
|
+
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
429
|
+
// chain, so a polluted Object.prototype value could surface here and get
|
|
430
|
+
// copied into the merged result.
|
|
431
|
+
const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
|
|
432
|
+
if (isPlainObject(existing) && isPlainObject(val)) {
|
|
433
|
+
result[targetKey] = merge(existing, val);
|
|
428
434
|
} else if (isPlainObject(val)) {
|
|
429
435
|
result[targetKey] = merge({}, val);
|
|
430
436
|
} else if (isArray(val)) {
|
|
@@ -434,8 +440,8 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
434
440
|
}
|
|
435
441
|
};
|
|
436
442
|
|
|
437
|
-
for (let i = 0, l =
|
|
438
|
-
|
|
443
|
+
for (let i = 0, l = objs.length; i < l; i++) {
|
|
444
|
+
objs[i] && forEach(objs[i], assignValue);
|
|
439
445
|
}
|
|
440
446
|
return result;
|
|
441
447
|
}
|
|
@@ -457,6 +463,9 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
457
463
|
(val, key) => {
|
|
458
464
|
if (thisArg && isFunction$1(val)) {
|
|
459
465
|
Object.defineProperty(a, key, {
|
|
466
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot
|
|
467
|
+
// hijack defineProperty's accessor-vs-data resolution.
|
|
468
|
+
__proto__: null,
|
|
460
469
|
value: bind(val, thisArg),
|
|
461
470
|
writable: true,
|
|
462
471
|
enumerable: true,
|
|
@@ -464,6 +473,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
464
473
|
});
|
|
465
474
|
} else {
|
|
466
475
|
Object.defineProperty(a, key, {
|
|
476
|
+
__proto__: null,
|
|
467
477
|
value: val,
|
|
468
478
|
writable: true,
|
|
469
479
|
enumerable: true,
|
|
@@ -502,12 +512,14 @@ const stripBOM = (content) => {
|
|
|
502
512
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
503
513
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
504
514
|
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
515
|
+
__proto__: null,
|
|
505
516
|
value: constructor,
|
|
506
517
|
writable: true,
|
|
507
518
|
enumerable: false,
|
|
508
519
|
configurable: true,
|
|
509
520
|
});
|
|
510
521
|
Object.defineProperty(constructor, 'super', {
|
|
522
|
+
__proto__: null,
|
|
511
523
|
value: superConstructor.prototype,
|
|
512
524
|
});
|
|
513
525
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -689,7 +701,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
689
701
|
const freezeMethods = (obj) => {
|
|
690
702
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
691
703
|
// skip restricted props in strict mode
|
|
692
|
-
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].
|
|
704
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
|
693
705
|
return false;
|
|
694
706
|
}
|
|
695
707
|
|
|
@@ -763,11 +775,11 @@ function isSpecCompliantForm(thing) {
|
|
|
763
775
|
* @returns {Object} The JSON-compatible object.
|
|
764
776
|
*/
|
|
765
777
|
const toJSONObject = (obj) => {
|
|
766
|
-
const
|
|
778
|
+
const visited = new WeakSet();
|
|
767
779
|
|
|
768
|
-
const visit = (source
|
|
780
|
+
const visit = (source) => {
|
|
769
781
|
if (isObject(source)) {
|
|
770
|
-
if (
|
|
782
|
+
if (visited.has(source)) {
|
|
771
783
|
return;
|
|
772
784
|
}
|
|
773
785
|
|
|
@@ -777,15 +789,16 @@ const toJSONObject = (obj) => {
|
|
|
777
789
|
}
|
|
778
790
|
|
|
779
791
|
if (!('toJSON' in source)) {
|
|
780
|
-
|
|
792
|
+
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
793
|
+
visited.add(source);
|
|
781
794
|
const target = isArray(source) ? [] : {};
|
|
782
795
|
|
|
783
796
|
forEach(source, (value, key) => {
|
|
784
|
-
const reducedValue = visit(value
|
|
797
|
+
const reducedValue = visit(value);
|
|
785
798
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
786
799
|
});
|
|
787
800
|
|
|
788
|
-
|
|
801
|
+
visited.delete(source);
|
|
789
802
|
|
|
790
803
|
return target;
|
|
791
804
|
}
|
|
@@ -794,7 +807,7 @@ const toJSONObject = (obj) => {
|
|
|
794
807
|
return source;
|
|
795
808
|
};
|
|
796
809
|
|
|
797
|
-
return visit(obj
|
|
810
|
+
return visit(obj);
|
|
798
811
|
};
|
|
799
812
|
|
|
800
813
|
/**
|
|
@@ -930,1311 +943,1422 @@ var utils$1 = {
|
|
|
930
943
|
isIterable,
|
|
931
944
|
};
|
|
932
945
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
946
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
|
947
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
948
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
949
|
+
'age',
|
|
950
|
+
'authorization',
|
|
951
|
+
'content-length',
|
|
952
|
+
'content-type',
|
|
953
|
+
'etag',
|
|
954
|
+
'expires',
|
|
955
|
+
'from',
|
|
956
|
+
'host',
|
|
957
|
+
'if-modified-since',
|
|
958
|
+
'if-unmodified-since',
|
|
959
|
+
'last-modified',
|
|
960
|
+
'location',
|
|
961
|
+
'max-forwards',
|
|
962
|
+
'proxy-authorization',
|
|
963
|
+
'referer',
|
|
964
|
+
'retry-after',
|
|
965
|
+
'user-agent',
|
|
966
|
+
]);
|
|
938
967
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
968
|
+
/**
|
|
969
|
+
* Parse headers into an object
|
|
970
|
+
*
|
|
971
|
+
* ```
|
|
972
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
973
|
+
* Content-Type: application/json
|
|
974
|
+
* Connection: keep-alive
|
|
975
|
+
* Transfer-Encoding: chunked
|
|
976
|
+
* ```
|
|
977
|
+
*
|
|
978
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
|
979
|
+
*
|
|
980
|
+
* @returns {Object} Headers parsed into an object
|
|
981
|
+
*/
|
|
982
|
+
var parseHeaders = (rawHeaders) => {
|
|
983
|
+
const parsed = {};
|
|
984
|
+
let key;
|
|
985
|
+
let val;
|
|
986
|
+
let i;
|
|
943
987
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
988
|
+
rawHeaders &&
|
|
989
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
990
|
+
i = line.indexOf(':');
|
|
991
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
992
|
+
val = line.substring(i + 1).trim();
|
|
947
993
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
* @param {string} message The error message.
|
|
952
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
953
|
-
* @param {Object} [config] The config.
|
|
954
|
-
* @param {Object} [request] The request.
|
|
955
|
-
* @param {Object} [response] The response.
|
|
956
|
-
*
|
|
957
|
-
* @returns {Error} The created error.
|
|
958
|
-
*/
|
|
959
|
-
constructor(message, code, config, request, response) {
|
|
960
|
-
super(message);
|
|
994
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
961
997
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
998
|
+
if (key === 'set-cookie') {
|
|
999
|
+
if (parsed[key]) {
|
|
1000
|
+
parsed[key].push(val);
|
|
1001
|
+
} else {
|
|
1002
|
+
parsed[key] = [val];
|
|
1003
|
+
}
|
|
1004
|
+
} else {
|
|
1005
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1006
|
+
}
|
|
970
1007
|
});
|
|
971
1008
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1009
|
+
return parsed;
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
function trimSPorHTAB(str) {
|
|
1013
|
+
let start = 0;
|
|
1014
|
+
let end = str.length;
|
|
1015
|
+
|
|
1016
|
+
while (start < end) {
|
|
1017
|
+
const code = str.charCodeAt(start);
|
|
1018
|
+
|
|
1019
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1020
|
+
break;
|
|
980
1021
|
}
|
|
1022
|
+
|
|
1023
|
+
start += 1;
|
|
981
1024
|
}
|
|
982
1025
|
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
// Mozilla
|
|
992
|
-
fileName: this.fileName,
|
|
993
|
-
lineNumber: this.lineNumber,
|
|
994
|
-
columnNumber: this.columnNumber,
|
|
995
|
-
stack: this.stack,
|
|
996
|
-
// Axios
|
|
997
|
-
config: utils$1.toJSONObject(this.config),
|
|
998
|
-
code: this.code,
|
|
999
|
-
status: this.status,
|
|
1000
|
-
};
|
|
1026
|
+
while (end > start) {
|
|
1027
|
+
const code = str.charCodeAt(end - 1);
|
|
1028
|
+
|
|
1029
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
end -= 1;
|
|
1001
1034
|
}
|
|
1035
|
+
|
|
1036
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
1002
1037
|
}
|
|
1003
1038
|
|
|
1004
|
-
//
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
1010
|
-
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1011
|
-
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1012
|
-
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1013
|
-
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1014
|
-
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
1015
|
-
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1016
|
-
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1017
|
-
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1039
|
+
// The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
|
|
1040
|
+
// eslint-disable-next-line no-control-regex
|
|
1041
|
+
const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
|
|
1042
|
+
// eslint-disable-next-line no-control-regex
|
|
1043
|
+
const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
|
|
1018
1044
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1045
|
+
function sanitizeValue(value, invalidChars) {
|
|
1046
|
+
if (utils$1.isArray(value)) {
|
|
1047
|
+
return value.map((item) => sanitizeValue(item, invalidChars));
|
|
1048
|
+
}
|
|
1021
1049
|
|
|
1022
|
-
|
|
1023
|
-
* Determines if the given thing is a array or js object.
|
|
1024
|
-
*
|
|
1025
|
-
* @param {string} thing - The object or array to be visited.
|
|
1026
|
-
*
|
|
1027
|
-
* @returns {boolean}
|
|
1028
|
-
*/
|
|
1029
|
-
function isVisitable(thing) {
|
|
1030
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1050
|
+
return trimSPorHTAB(String(value).replace(invalidChars, ''));
|
|
1031
1051
|
}
|
|
1032
1052
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
*
|
|
1036
|
-
* @param {string} key - The key of the parameter.
|
|
1037
|
-
*
|
|
1038
|
-
* @returns {string} the key without the brackets.
|
|
1039
|
-
*/
|
|
1040
|
-
function removeBrackets(key) {
|
|
1041
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1042
|
-
}
|
|
1053
|
+
const sanitizeHeaderValue = (value) =>
|
|
1054
|
+
sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
|
|
1043
1055
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
*
|
|
1047
|
-
* @param {string} path - The path to the current key.
|
|
1048
|
-
* @param {string} key - The key of the current object being iterated over.
|
|
1049
|
-
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
1050
|
-
*
|
|
1051
|
-
* @returns {string} The path to the current key.
|
|
1052
|
-
*/
|
|
1053
|
-
function renderKey(path, key, dots) {
|
|
1054
|
-
if (!path) return key;
|
|
1055
|
-
return path
|
|
1056
|
-
.concat(key)
|
|
1057
|
-
.map(function each(token, i) {
|
|
1058
|
-
// eslint-disable-next-line no-param-reassign
|
|
1059
|
-
token = removeBrackets(token);
|
|
1060
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
1061
|
-
})
|
|
1062
|
-
.join(dots ? '.' : '');
|
|
1063
|
-
}
|
|
1056
|
+
const sanitizeByteStringHeaderValue = (value) =>
|
|
1057
|
+
sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
|
|
1064
1058
|
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
1059
|
+
function toByteStringHeaderObject(headers) {
|
|
1060
|
+
const byteStringHeaders = Object.create(null);
|
|
1061
|
+
|
|
1062
|
+
utils$1.forEach(headers.toJSON(), (value, header) => {
|
|
1063
|
+
byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
return byteStringHeaders;
|
|
1074
1067
|
}
|
|
1075
1068
|
|
|
1076
|
-
const
|
|
1077
|
-
return /^is[A-Z]/.test(prop);
|
|
1078
|
-
});
|
|
1069
|
+
const $internals = Symbol('internals');
|
|
1079
1070
|
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
* @param {Object} obj
|
|
1084
|
-
* @param {?Object} [formData]
|
|
1085
|
-
* @param {?Object} [options]
|
|
1086
|
-
* @param {Function} [options.visitor]
|
|
1087
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
1088
|
-
* @param {Boolean} [options.dots = false]
|
|
1089
|
-
* @param {?Boolean} [options.indexes = false]
|
|
1090
|
-
*
|
|
1091
|
-
* @returns {Object}
|
|
1092
|
-
**/
|
|
1071
|
+
function normalizeHeader(header) {
|
|
1072
|
+
return header && String(header).trim().toLowerCase();
|
|
1073
|
+
}
|
|
1093
1074
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
1098
|
-
* @param {string} formData - The FormData object to append to.
|
|
1099
|
-
* @param {Object<string, any>} options
|
|
1100
|
-
*
|
|
1101
|
-
* @returns
|
|
1102
|
-
*/
|
|
1103
|
-
function toFormData(obj, formData, options) {
|
|
1104
|
-
if (!utils$1.isObject(obj)) {
|
|
1105
|
-
throw new TypeError('target must be an object');
|
|
1075
|
+
function normalizeValue(value) {
|
|
1076
|
+
if (value === false || value == null) {
|
|
1077
|
+
return value;
|
|
1106
1078
|
}
|
|
1107
1079
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1080
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
1081
|
+
}
|
|
1110
1082
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
metaTokens: true,
|
|
1116
|
-
dots: false,
|
|
1117
|
-
indexes: false,
|
|
1118
|
-
},
|
|
1119
|
-
false,
|
|
1120
|
-
function defined(option, source) {
|
|
1121
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1122
|
-
return !utils$1.isUndefined(source[option]);
|
|
1123
|
-
}
|
|
1124
|
-
);
|
|
1125
|
-
|
|
1126
|
-
const metaTokens = options.metaTokens;
|
|
1127
|
-
// eslint-disable-next-line no-use-before-define
|
|
1128
|
-
const visitor = options.visitor || defaultVisitor;
|
|
1129
|
-
const dots = options.dots;
|
|
1130
|
-
const indexes = options.indexes;
|
|
1131
|
-
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1132
|
-
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1133
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1083
|
+
function parseTokens(str) {
|
|
1084
|
+
const tokens = Object.create(null);
|
|
1085
|
+
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
1086
|
+
let match;
|
|
1134
1087
|
|
|
1135
|
-
|
|
1136
|
-
|
|
1088
|
+
while ((match = tokensRE.exec(str))) {
|
|
1089
|
+
tokens[match[1]] = match[2];
|
|
1137
1090
|
}
|
|
1138
1091
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
if (utils$1.isDate(value)) {
|
|
1143
|
-
return value.toISOString();
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
if (utils$1.isBoolean(value)) {
|
|
1147
|
-
return value.toString();
|
|
1148
|
-
}
|
|
1092
|
+
return tokens;
|
|
1093
|
+
}
|
|
1149
1094
|
|
|
1150
|
-
|
|
1151
|
-
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1152
|
-
}
|
|
1095
|
+
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1153
1096
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1097
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1098
|
+
if (utils$1.isFunction(filter)) {
|
|
1099
|
+
return filter.call(this, value, header);
|
|
1100
|
+
}
|
|
1157
1101
|
|
|
1158
|
-
|
|
1102
|
+
if (isHeaderNameFilter) {
|
|
1103
|
+
value = header;
|
|
1159
1104
|
}
|
|
1160
1105
|
|
|
1161
|
-
|
|
1162
|
-
* Default visitor.
|
|
1163
|
-
*
|
|
1164
|
-
* @param {*} value
|
|
1165
|
-
* @param {String|Number} key
|
|
1166
|
-
* @param {Array<String|Number>} path
|
|
1167
|
-
* @this {FormData}
|
|
1168
|
-
*
|
|
1169
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
1170
|
-
*/
|
|
1171
|
-
function defaultVisitor(value, key, path) {
|
|
1172
|
-
let arr = value;
|
|
1106
|
+
if (!utils$1.isString(value)) return;
|
|
1173
1107
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
}
|
|
1108
|
+
if (utils$1.isString(filter)) {
|
|
1109
|
+
return value.indexOf(filter) !== -1;
|
|
1110
|
+
}
|
|
1178
1111
|
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
// eslint-disable-next-line no-param-reassign
|
|
1184
|
-
value = JSON.stringify(value);
|
|
1185
|
-
} else if (
|
|
1186
|
-
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1187
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1188
|
-
) {
|
|
1189
|
-
// eslint-disable-next-line no-param-reassign
|
|
1190
|
-
key = removeBrackets(key);
|
|
1112
|
+
if (utils$1.isRegExp(filter)) {
|
|
1113
|
+
return filter.test(value);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1191
1116
|
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
: key + '[]',
|
|
1201
|
-
convertValue(el)
|
|
1202
|
-
);
|
|
1203
|
-
});
|
|
1204
|
-
return false;
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1117
|
+
function formatHeader(header) {
|
|
1118
|
+
return header
|
|
1119
|
+
.trim()
|
|
1120
|
+
.toLowerCase()
|
|
1121
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1122
|
+
return char.toUpperCase() + str;
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1207
1125
|
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
}
|
|
1126
|
+
function buildAccessors(obj, header) {
|
|
1127
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1211
1128
|
|
|
1212
|
-
|
|
1129
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
1130
|
+
Object.defineProperty(obj, methodName + accessorName, {
|
|
1131
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1132
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1133
|
+
__proto__: null,
|
|
1134
|
+
value: function (arg1, arg2, arg3) {
|
|
1135
|
+
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1136
|
+
},
|
|
1137
|
+
configurable: true,
|
|
1138
|
+
});
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1213
1141
|
|
|
1214
|
-
|
|
1142
|
+
class AxiosHeaders {
|
|
1143
|
+
constructor(headers) {
|
|
1144
|
+
headers && this.set(headers);
|
|
1215
1145
|
}
|
|
1216
1146
|
|
|
1217
|
-
|
|
1147
|
+
set(header, valueOrRewrite, rewrite) {
|
|
1148
|
+
const self = this;
|
|
1218
1149
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
convertValue,
|
|
1222
|
-
isVisitable,
|
|
1223
|
-
});
|
|
1150
|
+
function setHeader(_value, _header, _rewrite) {
|
|
1151
|
+
const lHeader = normalizeHeader(_header);
|
|
1224
1152
|
|
|
1225
|
-
|
|
1226
|
-
|
|
1153
|
+
if (!lHeader) {
|
|
1154
|
+
throw new Error('header name must be a non-empty string');
|
|
1155
|
+
}
|
|
1227
1156
|
|
|
1228
|
-
|
|
1229
|
-
throw new AxiosError(
|
|
1230
|
-
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1231
|
-
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1232
|
-
);
|
|
1233
|
-
}
|
|
1157
|
+
const key = utils$1.findKey(self, lHeader);
|
|
1234
1158
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1159
|
+
if (
|
|
1160
|
+
!key ||
|
|
1161
|
+
self[key] === undefined ||
|
|
1162
|
+
_rewrite === true ||
|
|
1163
|
+
(_rewrite === undefined && self[key] !== false)
|
|
1164
|
+
) {
|
|
1165
|
+
self[key || _header] = normalizeValue(_value);
|
|
1166
|
+
}
|
|
1237
1167
|
}
|
|
1238
1168
|
|
|
1239
|
-
|
|
1169
|
+
const setHeaders = (headers, _rewrite) =>
|
|
1170
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1240
1171
|
|
|
1241
|
-
utils$1.
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1172
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1173
|
+
setHeaders(header, valueOrRewrite);
|
|
1174
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1175
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1176
|
+
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1177
|
+
let obj = {},
|
|
1178
|
+
dest,
|
|
1179
|
+
key;
|
|
1180
|
+
for (const entry of header) {
|
|
1181
|
+
if (!utils$1.isArray(entry)) {
|
|
1182
|
+
throw TypeError('Object iterator must return a key-value pair');
|
|
1183
|
+
}
|
|
1245
1184
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1185
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
1186
|
+
? utils$1.isArray(dest)
|
|
1187
|
+
? [...dest, entry[1]]
|
|
1188
|
+
: [dest, entry[1]]
|
|
1189
|
+
: entry[1];
|
|
1248
1190
|
}
|
|
1249
|
-
});
|
|
1250
1191
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1192
|
+
setHeaders(obj, valueOrRewrite);
|
|
1193
|
+
} else {
|
|
1194
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1195
|
+
}
|
|
1253
1196
|
|
|
1254
|
-
|
|
1255
|
-
throw new TypeError('data must be an object');
|
|
1197
|
+
return this;
|
|
1256
1198
|
}
|
|
1257
1199
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
return formData;
|
|
1261
|
-
}
|
|
1200
|
+
get(header, parser) {
|
|
1201
|
+
header = normalizeHeader(header);
|
|
1262
1202
|
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
* their percent-encoded equivalents
|
|
1266
|
-
*
|
|
1267
|
-
* @param {string} str - The string to encode.
|
|
1268
|
-
*
|
|
1269
|
-
* @returns {string} The encoded string.
|
|
1270
|
-
*/
|
|
1271
|
-
function encode$1(str) {
|
|
1272
|
-
const charMap = {
|
|
1273
|
-
'!': '%21',
|
|
1274
|
-
"'": '%27',
|
|
1275
|
-
'(': '%28',
|
|
1276
|
-
')': '%29',
|
|
1277
|
-
'~': '%7E',
|
|
1278
|
-
'%20': '+',
|
|
1279
|
-
};
|
|
1280
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1281
|
-
return charMap[match];
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1203
|
+
if (header) {
|
|
1204
|
+
const key = utils$1.findKey(this, header);
|
|
1284
1205
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
*
|
|
1288
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
1289
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
1290
|
-
*
|
|
1291
|
-
* @returns {void}
|
|
1292
|
-
*/
|
|
1293
|
-
function AxiosURLSearchParams(params, options) {
|
|
1294
|
-
this._pairs = [];
|
|
1206
|
+
if (key) {
|
|
1207
|
+
const value = this[key];
|
|
1295
1208
|
|
|
1296
|
-
|
|
1297
|
-
|
|
1209
|
+
if (!parser) {
|
|
1210
|
+
return value;
|
|
1211
|
+
}
|
|
1298
1212
|
|
|
1299
|
-
|
|
1213
|
+
if (parser === true) {
|
|
1214
|
+
return parseTokens(value);
|
|
1215
|
+
}
|
|
1300
1216
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
}
|
|
1217
|
+
if (utils$1.isFunction(parser)) {
|
|
1218
|
+
return parser.call(this, value, key);
|
|
1219
|
+
}
|
|
1304
1220
|
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1221
|
+
if (utils$1.isRegExp(parser)) {
|
|
1222
|
+
return parser.exec(value);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
|
1309
1226
|
}
|
|
1310
|
-
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1311
1229
|
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1315
|
-
}, '')
|
|
1316
|
-
.join('&');
|
|
1317
|
-
};
|
|
1230
|
+
has(header, matcher) {
|
|
1231
|
+
header = normalizeHeader(header);
|
|
1318
1232
|
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1322
|
-
*
|
|
1323
|
-
* @param {string} val The value to be encoded.
|
|
1324
|
-
*
|
|
1325
|
-
* @returns {string} The encoded value.
|
|
1326
|
-
*/
|
|
1327
|
-
function encode(val) {
|
|
1328
|
-
return encodeURIComponent(val)
|
|
1329
|
-
.replace(/%3A/gi, ':')
|
|
1330
|
-
.replace(/%24/g, '$')
|
|
1331
|
-
.replace(/%2C/gi, ',')
|
|
1332
|
-
.replace(/%20/g, '+');
|
|
1333
|
-
}
|
|
1233
|
+
if (header) {
|
|
1234
|
+
const key = utils$1.findKey(this, header);
|
|
1334
1235
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
*/
|
|
1344
|
-
function buildURL(url, params, options) {
|
|
1345
|
-
if (!params) {
|
|
1346
|
-
return url;
|
|
1236
|
+
return !!(
|
|
1237
|
+
key &&
|
|
1238
|
+
this[key] !== undefined &&
|
|
1239
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
return false;
|
|
1347
1244
|
}
|
|
1348
1245
|
|
|
1349
|
-
|
|
1246
|
+
delete(header, matcher) {
|
|
1247
|
+
const self = this;
|
|
1248
|
+
let deleted = false;
|
|
1350
1249
|
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
serialize: options,
|
|
1354
|
-
}
|
|
1355
|
-
: options;
|
|
1250
|
+
function deleteHeader(_header) {
|
|
1251
|
+
_header = normalizeHeader(_header);
|
|
1356
1252
|
|
|
1357
|
-
|
|
1253
|
+
if (_header) {
|
|
1254
|
+
const key = utils$1.findKey(self, _header);
|
|
1358
1255
|
|
|
1359
|
-
|
|
1256
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1257
|
+
delete self[key];
|
|
1360
1258
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1259
|
+
deleted = true;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
if (utils$1.isArray(header)) {
|
|
1265
|
+
header.forEach(deleteHeader);
|
|
1266
|
+
} else {
|
|
1267
|
+
deleteHeader(header);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
return deleted;
|
|
1367
1271
|
}
|
|
1368
1272
|
|
|
1369
|
-
|
|
1370
|
-
const
|
|
1273
|
+
clear(matcher) {
|
|
1274
|
+
const keys = Object.keys(this);
|
|
1275
|
+
let i = keys.length;
|
|
1276
|
+
let deleted = false;
|
|
1371
1277
|
|
|
1372
|
-
|
|
1373
|
-
|
|
1278
|
+
while (i--) {
|
|
1279
|
+
const key = keys[i];
|
|
1280
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
1281
|
+
delete this[key];
|
|
1282
|
+
deleted = true;
|
|
1283
|
+
}
|
|
1374
1284
|
}
|
|
1375
|
-
|
|
1285
|
+
|
|
1286
|
+
return deleted;
|
|
1376
1287
|
}
|
|
1377
1288
|
|
|
1378
|
-
|
|
1379
|
-
|
|
1289
|
+
normalize(format) {
|
|
1290
|
+
const self = this;
|
|
1291
|
+
const headers = {};
|
|
1380
1292
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1293
|
+
utils$1.forEach(this, (value, header) => {
|
|
1294
|
+
const key = utils$1.findKey(headers, header);
|
|
1295
|
+
|
|
1296
|
+
if (key) {
|
|
1297
|
+
self[key] = normalizeValue(value);
|
|
1298
|
+
delete self[header];
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
1303
|
+
|
|
1304
|
+
if (normalized !== header) {
|
|
1305
|
+
delete self[header];
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
self[normalized] = normalizeValue(value);
|
|
1309
|
+
|
|
1310
|
+
headers[normalized] = true;
|
|
1311
|
+
});
|
|
1312
|
+
|
|
1313
|
+
return this;
|
|
1384
1314
|
}
|
|
1385
1315
|
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
fulfilled,
|
|
1398
|
-
rejected,
|
|
1399
|
-
synchronous: options ? options.synchronous : false,
|
|
1400
|
-
runWhen: options ? options.runWhen : null,
|
|
1316
|
+
concat(...targets) {
|
|
1317
|
+
return this.constructor.concat(this, ...targets);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
toJSON(asStrings) {
|
|
1321
|
+
const obj = Object.create(null);
|
|
1322
|
+
|
|
1323
|
+
utils$1.forEach(this, (value, header) => {
|
|
1324
|
+
value != null &&
|
|
1325
|
+
value !== false &&
|
|
1326
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
1401
1327
|
});
|
|
1402
|
-
|
|
1328
|
+
|
|
1329
|
+
return obj;
|
|
1403
1330
|
}
|
|
1404
1331
|
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
*
|
|
1408
|
-
* @param {Number} id The ID that was returned by `use`
|
|
1409
|
-
*
|
|
1410
|
-
* @returns {void}
|
|
1411
|
-
*/
|
|
1412
|
-
eject(id) {
|
|
1413
|
-
if (this.handlers[id]) {
|
|
1414
|
-
this.handlers[id] = null;
|
|
1415
|
-
}
|
|
1332
|
+
[Symbol.iterator]() {
|
|
1333
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
1416
1334
|
}
|
|
1417
1335
|
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
*/
|
|
1423
|
-
clear() {
|
|
1424
|
-
if (this.handlers) {
|
|
1425
|
-
this.handlers = [];
|
|
1426
|
-
}
|
|
1336
|
+
toString() {
|
|
1337
|
+
return Object.entries(this.toJSON())
|
|
1338
|
+
.map(([header, value]) => header + ': ' + value)
|
|
1339
|
+
.join('\n');
|
|
1427
1340
|
}
|
|
1428
1341
|
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
*
|
|
1432
|
-
* This method is particularly useful for skipping over any
|
|
1433
|
-
* interceptors that may have become `null` calling `eject`.
|
|
1434
|
-
*
|
|
1435
|
-
* @param {Function} fn The function to call for each interceptor
|
|
1436
|
-
*
|
|
1437
|
-
* @returns {void}
|
|
1438
|
-
*/
|
|
1439
|
-
forEach(fn) {
|
|
1440
|
-
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
1441
|
-
if (h !== null) {
|
|
1442
|
-
fn(h);
|
|
1443
|
-
}
|
|
1444
|
-
});
|
|
1342
|
+
getSetCookie() {
|
|
1343
|
+
return this.get('set-cookie') || [];
|
|
1445
1344
|
}
|
|
1446
|
-
}
|
|
1447
1345
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
clarifyTimeoutError: false,
|
|
1452
|
-
legacyInterceptorReqResOrdering: true,
|
|
1453
|
-
};
|
|
1346
|
+
get [Symbol.toStringTag]() {
|
|
1347
|
+
return 'AxiosHeaders';
|
|
1348
|
+
}
|
|
1454
1349
|
|
|
1455
|
-
|
|
1350
|
+
static from(thing) {
|
|
1351
|
+
return thing instanceof this ? thing : new this(thing);
|
|
1352
|
+
}
|
|
1456
1353
|
|
|
1457
|
-
|
|
1354
|
+
static concat(first, ...targets) {
|
|
1355
|
+
const computed = new this(first);
|
|
1458
1356
|
|
|
1459
|
-
|
|
1357
|
+
targets.forEach((target) => computed.set(target));
|
|
1460
1358
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
classes: {
|
|
1464
|
-
URLSearchParams: URLSearchParams$1,
|
|
1465
|
-
FormData: FormData$1,
|
|
1466
|
-
Blob: Blob$1,
|
|
1467
|
-
},
|
|
1468
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
1469
|
-
};
|
|
1359
|
+
return computed;
|
|
1360
|
+
}
|
|
1470
1361
|
|
|
1471
|
-
|
|
1362
|
+
static accessor(header) {
|
|
1363
|
+
const internals =
|
|
1364
|
+
(this[$internals] =
|
|
1365
|
+
this[$internals] =
|
|
1366
|
+
{
|
|
1367
|
+
accessors: {},
|
|
1368
|
+
});
|
|
1472
1369
|
|
|
1473
|
-
const
|
|
1370
|
+
const accessors = internals.accessors;
|
|
1371
|
+
const prototype = this.prototype;
|
|
1474
1372
|
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
*
|
|
1478
|
-
* This allows axios to run in a web worker, and react-native.
|
|
1479
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
1480
|
-
*
|
|
1481
|
-
* web workers:
|
|
1482
|
-
* typeof window -> undefined
|
|
1483
|
-
* typeof document -> undefined
|
|
1484
|
-
*
|
|
1485
|
-
* react-native:
|
|
1486
|
-
* navigator.product -> 'ReactNative'
|
|
1487
|
-
* nativescript
|
|
1488
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
1489
|
-
*
|
|
1490
|
-
* @returns {boolean}
|
|
1491
|
-
*/
|
|
1492
|
-
const hasStandardBrowserEnv =
|
|
1493
|
-
hasBrowserEnv &&
|
|
1494
|
-
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1373
|
+
function defineAccessor(_header) {
|
|
1374
|
+
const lHeader = normalizeHeader(_header);
|
|
1495
1375
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
* filtered out due to its judgment standard
|
|
1502
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
1503
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
1504
|
-
*/
|
|
1505
|
-
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
1506
|
-
return (
|
|
1507
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
|
1508
|
-
// eslint-disable-next-line no-undef
|
|
1509
|
-
self instanceof WorkerGlobalScope &&
|
|
1510
|
-
typeof self.importScripts === 'function'
|
|
1511
|
-
);
|
|
1512
|
-
})();
|
|
1376
|
+
if (!accessors[lHeader]) {
|
|
1377
|
+
buildAccessors(prototype, _header);
|
|
1378
|
+
accessors[lHeader] = true;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1513
1381
|
|
|
1514
|
-
|
|
1382
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1515
1383
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1384
|
+
return this;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
AxiosHeaders.accessor([
|
|
1389
|
+
'Content-Type',
|
|
1390
|
+
'Content-Length',
|
|
1391
|
+
'Accept',
|
|
1392
|
+
'Accept-Encoding',
|
|
1393
|
+
'User-Agent',
|
|
1394
|
+
'Authorization',
|
|
1395
|
+
]);
|
|
1396
|
+
|
|
1397
|
+
// reserved names hotfix
|
|
1398
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
|
1399
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
1400
|
+
return {
|
|
1401
|
+
get: () => value,
|
|
1402
|
+
set(headerValue) {
|
|
1403
|
+
this[mapped] = headerValue;
|
|
1404
|
+
},
|
|
1405
|
+
};
|
|
1523
1406
|
});
|
|
1524
1407
|
|
|
1525
|
-
|
|
1526
|
-
...utils,
|
|
1527
|
-
...platform$1,
|
|
1528
|
-
};
|
|
1408
|
+
utils$1.freezeMethods(AxiosHeaders);
|
|
1529
1409
|
|
|
1530
|
-
|
|
1531
|
-
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
1532
|
-
visitor: function (value, key, path, helpers) {
|
|
1533
|
-
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1534
|
-
this.append(key, value.toString('base64'));
|
|
1535
|
-
return false;
|
|
1536
|
-
}
|
|
1410
|
+
const REDACTED = '[REDACTED ****]';
|
|
1537
1411
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1412
|
+
function hasOwnOrPrototypeToJSON(source) {
|
|
1413
|
+
if (utils$1.hasOwnProp(source, 'toJSON')) {
|
|
1414
|
+
return true;
|
|
1415
|
+
}
|
|
1543
1416
|
|
|
1544
|
-
|
|
1545
|
-
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
1546
|
-
*
|
|
1547
|
-
* @param {string} name - The name of the property to get.
|
|
1548
|
-
*
|
|
1549
|
-
* @returns An array of strings.
|
|
1550
|
-
*/
|
|
1551
|
-
function parsePropPath(name) {
|
|
1552
|
-
// foo[x][y][z]
|
|
1553
|
-
// foo.x.y.z
|
|
1554
|
-
// foo-x-y-z
|
|
1555
|
-
// foo x y z
|
|
1556
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
1557
|
-
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1558
|
-
});
|
|
1559
|
-
}
|
|
1417
|
+
let prototype = Object.getPrototypeOf(source);
|
|
1560
1418
|
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
*/
|
|
1568
|
-
function arrayToObject(arr) {
|
|
1569
|
-
const obj = {};
|
|
1570
|
-
const keys = Object.keys(arr);
|
|
1571
|
-
let i;
|
|
1572
|
-
const len = keys.length;
|
|
1573
|
-
let key;
|
|
1574
|
-
for (i = 0; i < len; i++) {
|
|
1575
|
-
key = keys[i];
|
|
1576
|
-
obj[key] = arr[key];
|
|
1419
|
+
while (prototype && prototype !== Object.prototype) {
|
|
1420
|
+
if (utils$1.hasOwnProp(prototype, 'toJSON')) {
|
|
1421
|
+
return true;
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
1577
1425
|
}
|
|
1578
|
-
|
|
1426
|
+
|
|
1427
|
+
return false;
|
|
1579
1428
|
}
|
|
1580
1429
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
*/
|
|
1588
|
-
function formDataToJSON(formData) {
|
|
1589
|
-
function buildPath(path, value, target, index) {
|
|
1590
|
-
let name = path[index++];
|
|
1430
|
+
// Build a plain-object snapshot of `config` and replace the value of any key
|
|
1431
|
+
// (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|
1432
|
+
// and AxiosHeaders, and short-circuits on circular references.
|
|
1433
|
+
function redactConfig(config, redactKeys) {
|
|
1434
|
+
const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
|
|
1435
|
+
const seen = [];
|
|
1591
1436
|
|
|
1592
|
-
|
|
1437
|
+
const visit = (source) => {
|
|
1438
|
+
if (source === null || typeof source !== 'object') return source;
|
|
1439
|
+
if (utils$1.isBuffer(source)) return source;
|
|
1440
|
+
if (seen.indexOf(source) !== -1) return undefined;
|
|
1593
1441
|
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1442
|
+
if (source instanceof AxiosHeaders) {
|
|
1443
|
+
source = source.toJSON();
|
|
1444
|
+
}
|
|
1597
1445
|
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1446
|
+
seen.push(source);
|
|
1447
|
+
|
|
1448
|
+
let result;
|
|
1449
|
+
if (utils$1.isArray(source)) {
|
|
1450
|
+
result = [];
|
|
1451
|
+
source.forEach((v, i) => {
|
|
1452
|
+
const reducedValue = visit(v);
|
|
1453
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1454
|
+
result[i] = reducedValue;
|
|
1455
|
+
}
|
|
1456
|
+
});
|
|
1457
|
+
} else {
|
|
1458
|
+
if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|
1459
|
+
seen.pop();
|
|
1460
|
+
return source;
|
|
1605
1461
|
}
|
|
1606
1462
|
|
|
1607
|
-
|
|
1463
|
+
result = Object.create(null);
|
|
1464
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1465
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
|
|
1466
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1467
|
+
result[key] = reducedValue;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1608
1470
|
}
|
|
1609
1471
|
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1472
|
+
seen.pop();
|
|
1473
|
+
return result;
|
|
1474
|
+
};
|
|
1613
1475
|
|
|
1614
|
-
|
|
1476
|
+
return visit(config);
|
|
1477
|
+
}
|
|
1615
1478
|
|
|
1616
|
-
|
|
1617
|
-
|
|
1479
|
+
class AxiosError extends Error {
|
|
1480
|
+
static from(error, code, config, request, response, customProps) {
|
|
1481
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1482
|
+
axiosError.cause = error;
|
|
1483
|
+
axiosError.name = error.name;
|
|
1484
|
+
|
|
1485
|
+
// Preserve status from the original error if not already set from response
|
|
1486
|
+
if (error.status != null && axiosError.status == null) {
|
|
1487
|
+
axiosError.status = error.status;
|
|
1618
1488
|
}
|
|
1619
1489
|
|
|
1620
|
-
|
|
1490
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1491
|
+
return axiosError;
|
|
1621
1492
|
}
|
|
1622
1493
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1494
|
+
/**
|
|
1495
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1496
|
+
*
|
|
1497
|
+
* @param {string} message The error message.
|
|
1498
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1499
|
+
* @param {Object} [config] The config.
|
|
1500
|
+
* @param {Object} [request] The request.
|
|
1501
|
+
* @param {Object} [response] The response.
|
|
1502
|
+
*
|
|
1503
|
+
* @returns {Error} The created error.
|
|
1504
|
+
*/
|
|
1505
|
+
constructor(message, code, config, request, response) {
|
|
1506
|
+
super(message);
|
|
1625
1507
|
|
|
1626
|
-
|
|
1627
|
-
|
|
1508
|
+
// Make message enumerable to maintain backward compatibility
|
|
1509
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1510
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1511
|
+
Object.defineProperty(this, 'message', {
|
|
1512
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1513
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1514
|
+
__proto__: null,
|
|
1515
|
+
value: message,
|
|
1516
|
+
enumerable: true,
|
|
1517
|
+
writable: true,
|
|
1518
|
+
configurable: true,
|
|
1628
1519
|
});
|
|
1629
1520
|
|
|
1630
|
-
|
|
1521
|
+
this.name = 'AxiosError';
|
|
1522
|
+
this.isAxiosError = true;
|
|
1523
|
+
code && (this.code = code);
|
|
1524
|
+
config && (this.config = config);
|
|
1525
|
+
request && (this.request = request);
|
|
1526
|
+
if (response) {
|
|
1527
|
+
this.response = response;
|
|
1528
|
+
this.status = response.status;
|
|
1529
|
+
}
|
|
1631
1530
|
}
|
|
1632
1531
|
|
|
1633
|
-
|
|
1532
|
+
toJSON() {
|
|
1533
|
+
// Opt-in redaction: when the request config carries a `redact` array, the
|
|
1534
|
+
// value of any matching key (case-insensitive, at any depth) is replaced
|
|
1535
|
+
// with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|
1536
|
+
// existing serialization behavior unchanged.
|
|
1537
|
+
const config = this.config;
|
|
1538
|
+
const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|
1539
|
+
const serializedConfig =
|
|
1540
|
+
utils$1.isArray(redactKeys) && redactKeys.length > 0
|
|
1541
|
+
? redactConfig(config, redactKeys)
|
|
1542
|
+
: utils$1.toJSONObject(config);
|
|
1543
|
+
|
|
1544
|
+
return {
|
|
1545
|
+
// Standard
|
|
1546
|
+
message: this.message,
|
|
1547
|
+
name: this.name,
|
|
1548
|
+
// Microsoft
|
|
1549
|
+
description: this.description,
|
|
1550
|
+
number: this.number,
|
|
1551
|
+
// Mozilla
|
|
1552
|
+
fileName: this.fileName,
|
|
1553
|
+
lineNumber: this.lineNumber,
|
|
1554
|
+
columnNumber: this.columnNumber,
|
|
1555
|
+
stack: this.stack,
|
|
1556
|
+
// Axios
|
|
1557
|
+
config: serializedConfig,
|
|
1558
|
+
code: this.code,
|
|
1559
|
+
status: this.status,
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1634
1562
|
}
|
|
1635
1563
|
|
|
1636
|
-
|
|
1564
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
1565
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
1566
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1567
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
1568
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
1569
|
+
AxiosError.ECONNREFUSED = 'ECONNREFUSED';
|
|
1570
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
1571
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1572
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1573
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1574
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1575
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
1576
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1577
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1578
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1579
|
+
|
|
1580
|
+
// eslint-disable-next-line strict
|
|
1581
|
+
var httpAdapter = null;
|
|
1637
1582
|
|
|
1638
1583
|
/**
|
|
1639
|
-
*
|
|
1640
|
-
* of the input
|
|
1584
|
+
* Determines if the given thing is a array or js object.
|
|
1641
1585
|
*
|
|
1642
|
-
* @param {
|
|
1643
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
1644
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
1586
|
+
* @param {string} thing - The object or array to be visited.
|
|
1645
1587
|
*
|
|
1646
|
-
* @returns {
|
|
1588
|
+
* @returns {boolean}
|
|
1647
1589
|
*/
|
|
1648
|
-
function
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
(parser || JSON.parse)(rawValue);
|
|
1652
|
-
return utils$1.trim(rawValue);
|
|
1653
|
-
} catch (e) {
|
|
1654
|
-
if (e.name !== 'SyntaxError') {
|
|
1655
|
-
throw e;
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1590
|
+
function isVisitable(thing) {
|
|
1591
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1592
|
+
}
|
|
1659
1593
|
|
|
1660
|
-
|
|
1594
|
+
/**
|
|
1595
|
+
* It removes the brackets from the end of a string
|
|
1596
|
+
*
|
|
1597
|
+
* @param {string} key - The key of the parameter.
|
|
1598
|
+
*
|
|
1599
|
+
* @returns {string} the key without the brackets.
|
|
1600
|
+
*/
|
|
1601
|
+
function removeBrackets(key) {
|
|
1602
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1661
1603
|
}
|
|
1662
1604
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1605
|
+
/**
|
|
1606
|
+
* It takes a path, a key, and a boolean, and returns a string
|
|
1607
|
+
*
|
|
1608
|
+
* @param {string} path - The path to the current key.
|
|
1609
|
+
* @param {string} key - The key of the current object being iterated over.
|
|
1610
|
+
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
1611
|
+
*
|
|
1612
|
+
* @returns {string} The path to the current key.
|
|
1613
|
+
*/
|
|
1614
|
+
function renderKey(path, key, dots) {
|
|
1615
|
+
if (!path) return key;
|
|
1616
|
+
return path
|
|
1617
|
+
.concat(key)
|
|
1618
|
+
.map(function each(token, i) {
|
|
1619
|
+
// eslint-disable-next-line no-param-reassign
|
|
1620
|
+
token = removeBrackets(token);
|
|
1621
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1622
|
+
})
|
|
1623
|
+
.join(dots ? '.' : '');
|
|
1624
|
+
}
|
|
1665
1625
|
|
|
1666
|
-
|
|
1626
|
+
/**
|
|
1627
|
+
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
1628
|
+
*
|
|
1629
|
+
* @param {Array<any>} arr - The array to check
|
|
1630
|
+
*
|
|
1631
|
+
* @returns {boolean}
|
|
1632
|
+
*/
|
|
1633
|
+
function isFlatArray(arr) {
|
|
1634
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
1635
|
+
}
|
|
1667
1636
|
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1672
|
-
const isObjectPayload = utils$1.isObject(data);
|
|
1637
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
1638
|
+
return /^is[A-Z]/.test(prop);
|
|
1639
|
+
});
|
|
1673
1640
|
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1641
|
+
/**
|
|
1642
|
+
* Convert a data object to FormData
|
|
1643
|
+
*
|
|
1644
|
+
* @param {Object} obj
|
|
1645
|
+
* @param {?Object} [formData]
|
|
1646
|
+
* @param {?Object} [options]
|
|
1647
|
+
* @param {Function} [options.visitor]
|
|
1648
|
+
* @param {Boolean} [options.metaTokens = true]
|
|
1649
|
+
* @param {Boolean} [options.dots = false]
|
|
1650
|
+
* @param {?Boolean} [options.indexes = false]
|
|
1651
|
+
*
|
|
1652
|
+
* @returns {Object}
|
|
1653
|
+
**/
|
|
1677
1654
|
|
|
1678
|
-
|
|
1655
|
+
/**
|
|
1656
|
+
* It converts an object into a FormData object
|
|
1657
|
+
*
|
|
1658
|
+
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
1659
|
+
* @param {string} formData - The FormData object to append to.
|
|
1660
|
+
* @param {Object<string, any>} options
|
|
1661
|
+
*
|
|
1662
|
+
* @returns
|
|
1663
|
+
*/
|
|
1664
|
+
function toFormData(obj, formData, options) {
|
|
1665
|
+
if (!utils$1.isObject(obj)) {
|
|
1666
|
+
throw new TypeError('target must be an object');
|
|
1667
|
+
}
|
|
1679
1668
|
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
}
|
|
1669
|
+
// eslint-disable-next-line no-param-reassign
|
|
1670
|
+
formData = formData || new (FormData)();
|
|
1683
1671
|
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1699
|
-
return data.toString();
|
|
1700
|
-
}
|
|
1672
|
+
// eslint-disable-next-line no-param-reassign
|
|
1673
|
+
options = utils$1.toFlatObject(
|
|
1674
|
+
options,
|
|
1675
|
+
{
|
|
1676
|
+
metaTokens: true,
|
|
1677
|
+
dots: false,
|
|
1678
|
+
indexes: false,
|
|
1679
|
+
},
|
|
1680
|
+
false,
|
|
1681
|
+
function defined(option, source) {
|
|
1682
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1683
|
+
return !utils$1.isUndefined(source[option]);
|
|
1684
|
+
}
|
|
1685
|
+
);
|
|
1701
1686
|
|
|
1702
|
-
|
|
1687
|
+
const metaTokens = options.metaTokens;
|
|
1688
|
+
// eslint-disable-next-line no-use-before-define
|
|
1689
|
+
const visitor = options.visitor || defaultVisitor;
|
|
1690
|
+
const dots = options.dots;
|
|
1691
|
+
const indexes = options.indexes;
|
|
1692
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1693
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1694
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1703
1695
|
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
return toURLEncodedForm(data, formSerializer).toString();
|
|
1708
|
-
}
|
|
1696
|
+
if (!utils$1.isFunction(visitor)) {
|
|
1697
|
+
throw new TypeError('visitor must be a function');
|
|
1698
|
+
}
|
|
1709
1699
|
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
contentType.indexOf('multipart/form-data') > -1
|
|
1713
|
-
) {
|
|
1714
|
-
const env = own(this, 'env');
|
|
1715
|
-
const _FormData = env && env.FormData;
|
|
1700
|
+
function convertValue(value) {
|
|
1701
|
+
if (value === null) return '';
|
|
1716
1702
|
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
formSerializer
|
|
1721
|
-
);
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1703
|
+
if (utils$1.isDate(value)) {
|
|
1704
|
+
return value.toISOString();
|
|
1705
|
+
}
|
|
1724
1706
|
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
}
|
|
1707
|
+
if (utils$1.isBoolean(value)) {
|
|
1708
|
+
return value.toString();
|
|
1709
|
+
}
|
|
1729
1710
|
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1711
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
1712
|
+
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1713
|
+
}
|
|
1733
1714
|
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1738
|
-
const responseType = own(this, 'responseType');
|
|
1739
|
-
const JSONRequested = responseType === 'json';
|
|
1715
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
1716
|
+
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
1717
|
+
}
|
|
1740
1718
|
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
}
|
|
1719
|
+
return value;
|
|
1720
|
+
}
|
|
1744
1721
|
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1722
|
+
/**
|
|
1723
|
+
* Default visitor.
|
|
1724
|
+
*
|
|
1725
|
+
* @param {*} value
|
|
1726
|
+
* @param {String|Number} key
|
|
1727
|
+
* @param {Array<String|Number>} path
|
|
1728
|
+
* @this {FormData}
|
|
1729
|
+
*
|
|
1730
|
+
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
1731
|
+
*/
|
|
1732
|
+
function defaultVisitor(value, key, path) {
|
|
1733
|
+
let arr = value;
|
|
1734
|
+
|
|
1735
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
1736
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1737
|
+
return false;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
if (value && !path && typeof value === 'object') {
|
|
1741
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
1742
|
+
// eslint-disable-next-line no-param-reassign
|
|
1743
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
1744
|
+
// eslint-disable-next-line no-param-reassign
|
|
1745
|
+
value = JSON.stringify(value);
|
|
1746
|
+
} else if (
|
|
1747
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1748
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1749
1749
|
) {
|
|
1750
|
-
|
|
1751
|
-
|
|
1750
|
+
// eslint-disable-next-line no-param-reassign
|
|
1751
|
+
key = removeBrackets(key);
|
|
1752
1752
|
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1753
|
+
arr.forEach(function each(el, index) {
|
|
1754
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1755
|
+
formData.append(
|
|
1756
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1757
|
+
indexes === true
|
|
1758
|
+
? renderKey([key], index, dots)
|
|
1759
|
+
: indexes === null
|
|
1760
|
+
? key
|
|
1761
|
+
: key + '[]',
|
|
1762
|
+
convertValue(el)
|
|
1763
|
+
);
|
|
1764
|
+
});
|
|
1765
|
+
return false;
|
|
1763
1766
|
}
|
|
1767
|
+
}
|
|
1764
1768
|
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1769
|
+
if (isVisitable(value)) {
|
|
1770
|
+
return true;
|
|
1771
|
+
}
|
|
1768
1772
|
|
|
1769
|
-
|
|
1770
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
1771
|
-
* timeout is not created.
|
|
1772
|
-
*/
|
|
1773
|
-
timeout: 0,
|
|
1773
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1774
1774
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1775
|
+
return false;
|
|
1776
|
+
}
|
|
1777
1777
|
|
|
1778
|
-
|
|
1779
|
-
maxBodyLength: -1,
|
|
1778
|
+
const stack = [];
|
|
1780
1779
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1780
|
+
const exposedHelpers = Object.assign(predicates, {
|
|
1781
|
+
defaultVisitor,
|
|
1782
|
+
convertValue,
|
|
1783
|
+
isVisitable,
|
|
1784
|
+
});
|
|
1785
1785
|
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
},
|
|
1786
|
+
function build(value, path, depth = 0) {
|
|
1787
|
+
if (utils$1.isUndefined(value)) return;
|
|
1789
1788
|
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
};
|
|
1789
|
+
if (depth > maxDepth) {
|
|
1790
|
+
throw new AxiosError(
|
|
1791
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1792
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1793
|
+
);
|
|
1794
|
+
}
|
|
1797
1795
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
}
|
|
1796
|
+
if (stack.indexOf(value) !== -1) {
|
|
1797
|
+
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1798
|
+
}
|
|
1801
1799
|
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1800
|
+
stack.push(value);
|
|
1801
|
+
|
|
1802
|
+
utils$1.forEach(value, function each(el, key) {
|
|
1803
|
+
const result =
|
|
1804
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1805
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1806
|
+
|
|
1807
|
+
if (result === true) {
|
|
1808
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
1811
|
+
|
|
1812
|
+
stack.pop();
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
if (!utils$1.isObject(obj)) {
|
|
1816
|
+
throw new TypeError('data must be an object');
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
build(obj);
|
|
1820
|
+
|
|
1821
|
+
return formData;
|
|
1822
|
+
}
|
|
1823
1823
|
|
|
1824
1824
|
/**
|
|
1825
|
-
*
|
|
1826
|
-
*
|
|
1827
|
-
* ```
|
|
1828
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
1829
|
-
* Content-Type: application/json
|
|
1830
|
-
* Connection: keep-alive
|
|
1831
|
-
* Transfer-Encoding: chunked
|
|
1832
|
-
* ```
|
|
1825
|
+
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
1826
|
+
* their percent-encoded equivalents
|
|
1833
1827
|
*
|
|
1834
|
-
* @param {
|
|
1828
|
+
* @param {string} str - The string to encode.
|
|
1835
1829
|
*
|
|
1836
|
-
* @returns {
|
|
1830
|
+
* @returns {string} The encoded string.
|
|
1837
1831
|
*/
|
|
1838
|
-
|
|
1839
|
-
const
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1832
|
+
function encode$1(str) {
|
|
1833
|
+
const charMap = {
|
|
1834
|
+
'!': '%21',
|
|
1835
|
+
"'": '%27',
|
|
1836
|
+
'(': '%28',
|
|
1837
|
+
')': '%29',
|
|
1838
|
+
'~': '%7E',
|
|
1839
|
+
'%20': '+',
|
|
1840
|
+
};
|
|
1841
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1842
|
+
return charMap[match];
|
|
1843
|
+
});
|
|
1844
|
+
}
|
|
1843
1845
|
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1846
|
+
/**
|
|
1847
|
+
* It takes a params object and converts it to a FormData object
|
|
1848
|
+
*
|
|
1849
|
+
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
1850
|
+
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
1851
|
+
*
|
|
1852
|
+
* @returns {void}
|
|
1853
|
+
*/
|
|
1854
|
+
function AxiosURLSearchParams(params, options) {
|
|
1855
|
+
this._pairs = [];
|
|
1849
1856
|
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
}
|
|
1857
|
+
params && toFormData(params, this, options);
|
|
1858
|
+
}
|
|
1853
1859
|
|
|
1854
|
-
|
|
1855
|
-
if (parsed[key]) {
|
|
1856
|
-
parsed[key].push(val);
|
|
1857
|
-
} else {
|
|
1858
|
-
parsed[key] = [val];
|
|
1859
|
-
}
|
|
1860
|
-
} else {
|
|
1861
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1862
|
-
}
|
|
1863
|
-
});
|
|
1860
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
1864
1861
|
|
|
1865
|
-
|
|
1862
|
+
prototype.append = function append(name, value) {
|
|
1863
|
+
this._pairs.push([name, value]);
|
|
1866
1864
|
};
|
|
1867
1865
|
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
let end = str.length;
|
|
1866
|
+
prototype.toString = function toString(encoder) {
|
|
1867
|
+
const _encode = encoder
|
|
1868
|
+
? function (value) {
|
|
1869
|
+
return encoder.call(this, value, encode$1);
|
|
1870
|
+
}
|
|
1871
|
+
: encode$1;
|
|
1875
1872
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1873
|
+
return this._pairs
|
|
1874
|
+
.map(function each(pair) {
|
|
1875
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1876
|
+
}, '')
|
|
1877
|
+
.join('&');
|
|
1878
|
+
};
|
|
1878
1879
|
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1880
|
+
/**
|
|
1881
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1882
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1883
|
+
*
|
|
1884
|
+
* @param {string} val The value to be encoded.
|
|
1885
|
+
*
|
|
1886
|
+
* @returns {string} The encoded value.
|
|
1887
|
+
*/
|
|
1888
|
+
function encode(val) {
|
|
1889
|
+
return encodeURIComponent(val)
|
|
1890
|
+
.replace(/%3A/gi, ':')
|
|
1891
|
+
.replace(/%24/g, '$')
|
|
1892
|
+
.replace(/%2C/gi, ',')
|
|
1893
|
+
.replace(/%20/g, '+');
|
|
1894
|
+
}
|
|
1882
1895
|
|
|
1883
|
-
|
|
1896
|
+
/**
|
|
1897
|
+
* Build a URL by appending params to the end
|
|
1898
|
+
*
|
|
1899
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
1900
|
+
* @param {object} [params] The params to be appended
|
|
1901
|
+
* @param {?(object|Function)} options
|
|
1902
|
+
*
|
|
1903
|
+
* @returns {string} The formatted url
|
|
1904
|
+
*/
|
|
1905
|
+
function buildURL(url, params, options) {
|
|
1906
|
+
if (!params) {
|
|
1907
|
+
return url;
|
|
1884
1908
|
}
|
|
1885
1909
|
|
|
1886
|
-
|
|
1887
|
-
const code = str.charCodeAt(end - 1);
|
|
1888
|
-
|
|
1889
|
-
if (code !== 0x09 && code !== 0x20) {
|
|
1890
|
-
break;
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
end -= 1;
|
|
1894
|
-
}
|
|
1910
|
+
const _encode = (options && options.encode) || encode;
|
|
1895
1911
|
|
|
1896
|
-
|
|
1897
|
-
|
|
1912
|
+
const _options = utils$1.isFunction(options)
|
|
1913
|
+
? {
|
|
1914
|
+
serialize: options,
|
|
1915
|
+
}
|
|
1916
|
+
: options;
|
|
1898
1917
|
|
|
1899
|
-
|
|
1900
|
-
return header && String(header).trim().toLowerCase();
|
|
1901
|
-
}
|
|
1918
|
+
const serializeFn = _options && _options.serialize;
|
|
1902
1919
|
|
|
1903
|
-
|
|
1904
|
-
return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
|
|
1905
|
-
}
|
|
1920
|
+
let serializedParams;
|
|
1906
1921
|
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1922
|
+
if (serializeFn) {
|
|
1923
|
+
serializedParams = serializeFn(params, _options);
|
|
1924
|
+
} else {
|
|
1925
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
1926
|
+
? params.toString()
|
|
1927
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1910
1928
|
}
|
|
1911
1929
|
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
function parseTokens(str) {
|
|
1916
|
-
const tokens = Object.create(null);
|
|
1917
|
-
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
1918
|
-
let match;
|
|
1930
|
+
if (serializedParams) {
|
|
1931
|
+
const hashmarkIndex = url.indexOf('#');
|
|
1919
1932
|
|
|
1920
|
-
|
|
1921
|
-
|
|
1933
|
+
if (hashmarkIndex !== -1) {
|
|
1934
|
+
url = url.slice(0, hashmarkIndex);
|
|
1935
|
+
}
|
|
1936
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
1922
1937
|
}
|
|
1923
1938
|
|
|
1924
|
-
return
|
|
1939
|
+
return url;
|
|
1925
1940
|
}
|
|
1926
1941
|
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
if (utils$1.isFunction(filter)) {
|
|
1931
|
-
return filter.call(this, value, header);
|
|
1942
|
+
class InterceptorManager {
|
|
1943
|
+
constructor() {
|
|
1944
|
+
this.handlers = [];
|
|
1932
1945
|
}
|
|
1933
1946
|
|
|
1934
|
-
|
|
1935
|
-
|
|
1947
|
+
/**
|
|
1948
|
+
* Add a new interceptor to the stack
|
|
1949
|
+
*
|
|
1950
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1951
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1952
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
1953
|
+
*
|
|
1954
|
+
* @return {Number} An ID used to remove interceptor later
|
|
1955
|
+
*/
|
|
1956
|
+
use(fulfilled, rejected, options) {
|
|
1957
|
+
this.handlers.push({
|
|
1958
|
+
fulfilled,
|
|
1959
|
+
rejected,
|
|
1960
|
+
synchronous: options ? options.synchronous : false,
|
|
1961
|
+
runWhen: options ? options.runWhen : null,
|
|
1962
|
+
});
|
|
1963
|
+
return this.handlers.length - 1;
|
|
1936
1964
|
}
|
|
1937
1965
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1966
|
+
/**
|
|
1967
|
+
* Remove an interceptor from the stack
|
|
1968
|
+
*
|
|
1969
|
+
* @param {Number} id The ID that was returned by `use`
|
|
1970
|
+
*
|
|
1971
|
+
* @returns {void}
|
|
1972
|
+
*/
|
|
1973
|
+
eject(id) {
|
|
1974
|
+
if (this.handlers[id]) {
|
|
1975
|
+
this.handlers[id] = null;
|
|
1976
|
+
}
|
|
1942
1977
|
}
|
|
1943
1978
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1979
|
+
/**
|
|
1980
|
+
* Clear all interceptors from the stack
|
|
1981
|
+
*
|
|
1982
|
+
* @returns {void}
|
|
1983
|
+
*/
|
|
1984
|
+
clear() {
|
|
1985
|
+
if (this.handlers) {
|
|
1986
|
+
this.handlers = [];
|
|
1987
|
+
}
|
|
1946
1988
|
}
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1949
|
-
function formatHeader(header) {
|
|
1950
|
-
return header
|
|
1951
|
-
.trim()
|
|
1952
|
-
.toLowerCase()
|
|
1953
|
-
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1954
|
-
return char.toUpperCase() + str;
|
|
1955
|
-
});
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
function buildAccessors(obj, header) {
|
|
1959
|
-
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1960
1989
|
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1990
|
+
/**
|
|
1991
|
+
* Iterate over all the registered interceptors
|
|
1992
|
+
*
|
|
1993
|
+
* This method is particularly useful for skipping over any
|
|
1994
|
+
* interceptors that may have become `null` calling `eject`.
|
|
1995
|
+
*
|
|
1996
|
+
* @param {Function} fn The function to call for each interceptor
|
|
1997
|
+
*
|
|
1998
|
+
* @returns {void}
|
|
1999
|
+
*/
|
|
2000
|
+
forEach(fn) {
|
|
2001
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
2002
|
+
if (h !== null) {
|
|
2003
|
+
fn(h);
|
|
2004
|
+
}
|
|
1967
2005
|
});
|
|
1968
|
-
});
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
class AxiosHeaders {
|
|
1972
|
-
constructor(headers) {
|
|
1973
|
-
headers && this.set(headers);
|
|
1974
2006
|
}
|
|
2007
|
+
}
|
|
1975
2008
|
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
if (!lHeader) {
|
|
1983
|
-
throw new Error('header name must be a non-empty string');
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
const key = utils$1.findKey(self, lHeader);
|
|
1987
|
-
|
|
1988
|
-
if (
|
|
1989
|
-
!key ||
|
|
1990
|
-
self[key] === undefined ||
|
|
1991
|
-
_rewrite === true ||
|
|
1992
|
-
(_rewrite === undefined && self[key] !== false)
|
|
1993
|
-
) {
|
|
1994
|
-
self[key || _header] = normalizeValue(_value);
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
const setHeaders = (headers, _rewrite) =>
|
|
1999
|
-
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
2009
|
+
var transitionalDefaults = {
|
|
2010
|
+
silentJSONParsing: true,
|
|
2011
|
+
forcedJSONParsing: true,
|
|
2012
|
+
clarifyTimeoutError: false,
|
|
2013
|
+
legacyInterceptorReqResOrdering: true,
|
|
2014
|
+
};
|
|
2000
2015
|
|
|
2001
|
-
|
|
2002
|
-
setHeaders(header, valueOrRewrite);
|
|
2003
|
-
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2004
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
2005
|
-
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
2006
|
-
let obj = {},
|
|
2007
|
-
dest,
|
|
2008
|
-
key;
|
|
2009
|
-
for (const entry of header) {
|
|
2010
|
-
if (!utils$1.isArray(entry)) {
|
|
2011
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
2012
|
-
}
|
|
2016
|
+
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
2013
2017
|
|
|
2014
|
-
|
|
2015
|
-
? utils$1.isArray(dest)
|
|
2016
|
-
? [...dest, entry[1]]
|
|
2017
|
-
: [dest, entry[1]]
|
|
2018
|
-
: entry[1];
|
|
2019
|
-
}
|
|
2018
|
+
var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
2020
2019
|
|
|
2021
|
-
|
|
2022
|
-
} else {
|
|
2023
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
2024
|
-
}
|
|
2020
|
+
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
2025
2021
|
|
|
2026
|
-
|
|
2027
|
-
|
|
2022
|
+
var platform$1 = {
|
|
2023
|
+
isBrowser: true,
|
|
2024
|
+
classes: {
|
|
2025
|
+
URLSearchParams: URLSearchParams$1,
|
|
2026
|
+
FormData: FormData$1,
|
|
2027
|
+
Blob: Blob$1,
|
|
2028
|
+
},
|
|
2029
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
2030
|
+
};
|
|
2028
2031
|
|
|
2029
|
-
|
|
2030
|
-
header = normalizeHeader(header);
|
|
2032
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2031
2033
|
|
|
2032
|
-
|
|
2033
|
-
const key = utils$1.findKey(this, header);
|
|
2034
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
2034
2035
|
|
|
2035
|
-
|
|
2036
|
-
|
|
2036
|
+
/**
|
|
2037
|
+
* Determine if we're running in a standard browser environment
|
|
2038
|
+
*
|
|
2039
|
+
* This allows axios to run in a web worker, and react-native.
|
|
2040
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
2041
|
+
*
|
|
2042
|
+
* web workers:
|
|
2043
|
+
* typeof window -> undefined
|
|
2044
|
+
* typeof document -> undefined
|
|
2045
|
+
*
|
|
2046
|
+
* react-native:
|
|
2047
|
+
* navigator.product -> 'ReactNative'
|
|
2048
|
+
* nativescript
|
|
2049
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
|
2050
|
+
*
|
|
2051
|
+
* @returns {boolean}
|
|
2052
|
+
*/
|
|
2053
|
+
const hasStandardBrowserEnv =
|
|
2054
|
+
hasBrowserEnv &&
|
|
2055
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2037
2056
|
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2057
|
+
/**
|
|
2058
|
+
* Determine if we're running in a standard browser webWorker environment
|
|
2059
|
+
*
|
|
2060
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
|
2061
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
2062
|
+
* filtered out due to its judgment standard
|
|
2063
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
2064
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
|
2065
|
+
*/
|
|
2066
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
2067
|
+
return (
|
|
2068
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
|
2069
|
+
// eslint-disable-next-line no-undef
|
|
2070
|
+
self instanceof WorkerGlobalScope &&
|
|
2071
|
+
typeof self.importScripts === 'function'
|
|
2072
|
+
);
|
|
2073
|
+
})();
|
|
2041
2074
|
|
|
2042
|
-
|
|
2043
|
-
return parseTokens(value);
|
|
2044
|
-
}
|
|
2075
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
2045
2076
|
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2077
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
2078
|
+
__proto__: null,
|
|
2079
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
2080
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
2081
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
2082
|
+
navigator: _navigator,
|
|
2083
|
+
origin: origin
|
|
2084
|
+
});
|
|
2049
2085
|
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2086
|
+
var platform = {
|
|
2087
|
+
...utils,
|
|
2088
|
+
...platform$1,
|
|
2089
|
+
};
|
|
2053
2090
|
|
|
2054
|
-
|
|
2091
|
+
function toURLEncodedForm(data, options) {
|
|
2092
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
2093
|
+
visitor: function (value, key, path, helpers) {
|
|
2094
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
2095
|
+
this.append(key, value.toString('base64'));
|
|
2096
|
+
return false;
|
|
2055
2097
|
}
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
has(header, matcher) {
|
|
2060
|
-
header = normalizeHeader(header);
|
|
2061
2098
|
|
|
2062
|
-
|
|
2063
|
-
|
|
2099
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
2100
|
+
},
|
|
2101
|
+
...options,
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2064
2104
|
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2105
|
+
/**
|
|
2106
|
+
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
2107
|
+
*
|
|
2108
|
+
* @param {string} name - The name of the property to get.
|
|
2109
|
+
*
|
|
2110
|
+
* @returns An array of strings.
|
|
2111
|
+
*/
|
|
2112
|
+
function parsePropPath(name) {
|
|
2113
|
+
// foo[x][y][z]
|
|
2114
|
+
// foo.x.y.z
|
|
2115
|
+
// foo-x-y-z
|
|
2116
|
+
// foo x y z
|
|
2117
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
2118
|
+
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2071
2121
|
|
|
2072
|
-
|
|
2122
|
+
/**
|
|
2123
|
+
* Convert an array to an object.
|
|
2124
|
+
*
|
|
2125
|
+
* @param {Array<any>} arr - The array to convert to an object.
|
|
2126
|
+
*
|
|
2127
|
+
* @returns An object with the same keys and values as the array.
|
|
2128
|
+
*/
|
|
2129
|
+
function arrayToObject(arr) {
|
|
2130
|
+
const obj = {};
|
|
2131
|
+
const keys = Object.keys(arr);
|
|
2132
|
+
let i;
|
|
2133
|
+
const len = keys.length;
|
|
2134
|
+
let key;
|
|
2135
|
+
for (i = 0; i < len; i++) {
|
|
2136
|
+
key = keys[i];
|
|
2137
|
+
obj[key] = arr[key];
|
|
2073
2138
|
}
|
|
2139
|
+
return obj;
|
|
2140
|
+
}
|
|
2074
2141
|
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2142
|
+
/**
|
|
2143
|
+
* It takes a FormData object and returns a JavaScript object
|
|
2144
|
+
*
|
|
2145
|
+
* @param {string} formData The FormData object to convert to JSON.
|
|
2146
|
+
*
|
|
2147
|
+
* @returns {Object<string, any> | null} The converted object.
|
|
2148
|
+
*/
|
|
2149
|
+
function formDataToJSON(formData) {
|
|
2150
|
+
function buildPath(path, value, target, index) {
|
|
2151
|
+
let name = path[index++];
|
|
2081
2152
|
|
|
2082
|
-
|
|
2083
|
-
const key = utils$1.findKey(self, _header);
|
|
2153
|
+
if (name === '__proto__') return true;
|
|
2084
2154
|
|
|
2085
|
-
|
|
2086
|
-
|
|
2155
|
+
const isNumericKey = Number.isFinite(+name);
|
|
2156
|
+
const isLast = index >= path.length;
|
|
2157
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
2087
2158
|
|
|
2088
|
-
|
|
2089
|
-
|
|
2159
|
+
if (isLast) {
|
|
2160
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
2161
|
+
target[name] = utils$1.isArray(target[name])
|
|
2162
|
+
? target[name].concat(value)
|
|
2163
|
+
: [target[name], value];
|
|
2164
|
+
} else {
|
|
2165
|
+
target[name] = value;
|
|
2090
2166
|
}
|
|
2091
|
-
}
|
|
2092
2167
|
|
|
2093
|
-
|
|
2094
|
-
header.forEach(deleteHeader);
|
|
2095
|
-
} else {
|
|
2096
|
-
deleteHeader(header);
|
|
2168
|
+
return !isNumericKey;
|
|
2097
2169
|
}
|
|
2098
2170
|
|
|
2099
|
-
|
|
2100
|
-
|
|
2171
|
+
if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
|
|
2172
|
+
target[name] = [];
|
|
2173
|
+
}
|
|
2101
2174
|
|
|
2102
|
-
|
|
2103
|
-
const keys = Object.keys(this);
|
|
2104
|
-
let i = keys.length;
|
|
2105
|
-
let deleted = false;
|
|
2175
|
+
const result = buildPath(path, value, target[name], index);
|
|
2106
2176
|
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2110
|
-
delete this[key];
|
|
2111
|
-
deleted = true;
|
|
2112
|
-
}
|
|
2177
|
+
if (result && utils$1.isArray(target[name])) {
|
|
2178
|
+
target[name] = arrayToObject(target[name]);
|
|
2113
2179
|
}
|
|
2114
2180
|
|
|
2115
|
-
return
|
|
2181
|
+
return !isNumericKey;
|
|
2116
2182
|
}
|
|
2117
2183
|
|
|
2118
|
-
|
|
2119
|
-
const
|
|
2120
|
-
const headers = {};
|
|
2184
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
2185
|
+
const obj = {};
|
|
2121
2186
|
|
|
2122
|
-
utils$1.
|
|
2123
|
-
|
|
2187
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
2188
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
2189
|
+
});
|
|
2124
2190
|
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
delete self[header];
|
|
2128
|
-
return;
|
|
2129
|
-
}
|
|
2191
|
+
return obj;
|
|
2192
|
+
}
|
|
2130
2193
|
|
|
2131
|
-
|
|
2194
|
+
return null;
|
|
2195
|
+
}
|
|
2132
2196
|
|
|
2133
|
-
|
|
2134
|
-
delete self[header];
|
|
2135
|
-
}
|
|
2197
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
2136
2198
|
|
|
2137
|
-
|
|
2199
|
+
/**
|
|
2200
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
2201
|
+
* of the input
|
|
2202
|
+
*
|
|
2203
|
+
* @param {any} rawValue - The value to be stringified.
|
|
2204
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
2205
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
2206
|
+
*
|
|
2207
|
+
* @returns {string} A stringified version of the rawValue.
|
|
2208
|
+
*/
|
|
2209
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
2210
|
+
if (utils$1.isString(rawValue)) {
|
|
2211
|
+
try {
|
|
2212
|
+
(parser || JSON.parse)(rawValue);
|
|
2213
|
+
return utils$1.trim(rawValue);
|
|
2214
|
+
} catch (e) {
|
|
2215
|
+
if (e.name !== 'SyntaxError') {
|
|
2216
|
+
throw e;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2138
2220
|
|
|
2139
|
-
|
|
2140
|
-
|
|
2221
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
2222
|
+
}
|
|
2141
2223
|
|
|
2142
|
-
|
|
2143
|
-
|
|
2224
|
+
const defaults = {
|
|
2225
|
+
transitional: transitionalDefaults,
|
|
2144
2226
|
|
|
2145
|
-
|
|
2146
|
-
return this.constructor.concat(this, ...targets);
|
|
2147
|
-
}
|
|
2227
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
2148
2228
|
|
|
2149
|
-
|
|
2150
|
-
|
|
2229
|
+
transformRequest: [
|
|
2230
|
+
function transformRequest(data, headers) {
|
|
2231
|
+
const contentType = headers.getContentType() || '';
|
|
2232
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
2233
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
2151
2234
|
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
2156
|
-
});
|
|
2235
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
2236
|
+
data = new FormData(data);
|
|
2237
|
+
}
|
|
2157
2238
|
|
|
2158
|
-
|
|
2159
|
-
}
|
|
2239
|
+
const isFormData = utils$1.isFormData(data);
|
|
2160
2240
|
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2241
|
+
if (isFormData) {
|
|
2242
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
2243
|
+
}
|
|
2164
2244
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2245
|
+
if (
|
|
2246
|
+
utils$1.isArrayBuffer(data) ||
|
|
2247
|
+
utils$1.isBuffer(data) ||
|
|
2248
|
+
utils$1.isStream(data) ||
|
|
2249
|
+
utils$1.isFile(data) ||
|
|
2250
|
+
utils$1.isBlob(data) ||
|
|
2251
|
+
utils$1.isReadableStream(data)
|
|
2252
|
+
) {
|
|
2253
|
+
return data;
|
|
2254
|
+
}
|
|
2255
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
2256
|
+
return data.buffer;
|
|
2257
|
+
}
|
|
2258
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
2259
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
2260
|
+
return data.toString();
|
|
2261
|
+
}
|
|
2170
2262
|
|
|
2171
|
-
|
|
2172
|
-
return this.get('set-cookie') || [];
|
|
2173
|
-
}
|
|
2263
|
+
let isFileList;
|
|
2174
2264
|
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2265
|
+
if (isObjectPayload) {
|
|
2266
|
+
const formSerializer = own(this, 'formSerializer');
|
|
2267
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
2268
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
2269
|
+
}
|
|
2178
2270
|
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2271
|
+
if (
|
|
2272
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
2273
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
2274
|
+
) {
|
|
2275
|
+
const env = own(this, 'env');
|
|
2276
|
+
const _FormData = env && env.FormData;
|
|
2182
2277
|
|
|
2183
|
-
|
|
2184
|
-
|
|
2278
|
+
return toFormData(
|
|
2279
|
+
isFileList ? { 'files[]': data } : data,
|
|
2280
|
+
_FormData && new _FormData(),
|
|
2281
|
+
formSerializer
|
|
2282
|
+
);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2185
2285
|
|
|
2186
|
-
|
|
2286
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
2287
|
+
headers.setContentType('application/json', false);
|
|
2288
|
+
return stringifySafely(data);
|
|
2289
|
+
}
|
|
2187
2290
|
|
|
2188
|
-
|
|
2189
|
-
|
|
2291
|
+
return data;
|
|
2292
|
+
},
|
|
2293
|
+
],
|
|
2190
2294
|
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
(this
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
});
|
|
2295
|
+
transformResponse: [
|
|
2296
|
+
function transformResponse(data) {
|
|
2297
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
2298
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
2299
|
+
const responseType = own(this, 'responseType');
|
|
2300
|
+
const JSONRequested = responseType === 'json';
|
|
2198
2301
|
|
|
2199
|
-
|
|
2200
|
-
|
|
2302
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
2303
|
+
return data;
|
|
2304
|
+
}
|
|
2201
2305
|
|
|
2202
|
-
|
|
2203
|
-
|
|
2306
|
+
if (
|
|
2307
|
+
data &&
|
|
2308
|
+
utils$1.isString(data) &&
|
|
2309
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
2310
|
+
) {
|
|
2311
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2312
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
2204
2313
|
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2314
|
+
try {
|
|
2315
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
2316
|
+
} catch (e) {
|
|
2317
|
+
if (strictJSONParsing) {
|
|
2318
|
+
if (e.name === 'SyntaxError') {
|
|
2319
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
2320
|
+
}
|
|
2321
|
+
throw e;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2208
2324
|
}
|
|
2209
|
-
}
|
|
2210
2325
|
|
|
2211
|
-
|
|
2326
|
+
return data;
|
|
2327
|
+
},
|
|
2328
|
+
],
|
|
2212
2329
|
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2330
|
+
/**
|
|
2331
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
2332
|
+
* timeout is not created.
|
|
2333
|
+
*/
|
|
2334
|
+
timeout: 0,
|
|
2216
2335
|
|
|
2217
|
-
|
|
2218
|
-
'
|
|
2219
|
-
'Content-Length',
|
|
2220
|
-
'Accept',
|
|
2221
|
-
'Accept-Encoding',
|
|
2222
|
-
'User-Agent',
|
|
2223
|
-
'Authorization',
|
|
2224
|
-
]);
|
|
2336
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
2337
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
2225
2338
|
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2339
|
+
maxContentLength: -1,
|
|
2340
|
+
maxBodyLength: -1,
|
|
2341
|
+
|
|
2342
|
+
env: {
|
|
2343
|
+
FormData: platform.classes.FormData,
|
|
2344
|
+
Blob: platform.classes.Blob,
|
|
2345
|
+
},
|
|
2346
|
+
|
|
2347
|
+
validateStatus: function validateStatus(status) {
|
|
2348
|
+
return status >= 200 && status < 300;
|
|
2349
|
+
},
|
|
2350
|
+
|
|
2351
|
+
headers: {
|
|
2352
|
+
common: {
|
|
2353
|
+
Accept: 'application/json, text/plain, */*',
|
|
2354
|
+
'Content-Type': undefined,
|
|
2233
2355
|
},
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2356
|
+
},
|
|
2357
|
+
};
|
|
2236
2358
|
|
|
2237
|
-
utils$1.
|
|
2359
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
|
|
2360
|
+
defaults.headers[method] = {};
|
|
2361
|
+
});
|
|
2238
2362
|
|
|
2239
2363
|
/**
|
|
2240
2364
|
* Transform the data for a request or a response
|
|
@@ -2294,22 +2418,18 @@ function settle(resolve, reject, response) {
|
|
|
2294
2418
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2295
2419
|
resolve(response);
|
|
2296
2420
|
} else {
|
|
2297
|
-
reject(
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
response.request,
|
|
2305
|
-
response
|
|
2306
|
-
)
|
|
2307
|
-
);
|
|
2421
|
+
reject(new AxiosError(
|
|
2422
|
+
'Request failed with status code ' + response.status,
|
|
2423
|
+
response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE,
|
|
2424
|
+
response.config,
|
|
2425
|
+
response.request,
|
|
2426
|
+
response
|
|
2427
|
+
));
|
|
2308
2428
|
}
|
|
2309
2429
|
}
|
|
2310
2430
|
|
|
2311
2431
|
function parseProtocol(url) {
|
|
2312
|
-
const match = /^([-+\w]{1,25})(
|
|
2432
|
+
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
2313
2433
|
return (match && match[1]) || '';
|
|
2314
2434
|
}
|
|
2315
2435
|
|
|
@@ -2413,6 +2533,9 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2413
2533
|
const _speedometer = speedometer(50, 250);
|
|
2414
2534
|
|
|
2415
2535
|
return throttle((e) => {
|
|
2536
|
+
if (!e || typeof e.loaded !== 'number') {
|
|
2537
|
+
return;
|
|
2538
|
+
}
|
|
2416
2539
|
const rawLoaded = e.loaded;
|
|
2417
2540
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2418
2541
|
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
@@ -2500,8 +2623,20 @@ var cookies = platform.hasStandardBrowserEnv
|
|
|
2500
2623
|
|
|
2501
2624
|
read(name) {
|
|
2502
2625
|
if (typeof document === 'undefined') return null;
|
|
2503
|
-
|
|
2504
|
-
|
|
2626
|
+
// Match name=value by splitting on the semicolon separator instead of building a
|
|
2627
|
+
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
2628
|
+
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
2629
|
+
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
2630
|
+
// "; ", so ignore optional whitespace before each cookie name.
|
|
2631
|
+
const cookies = document.cookie.split(';');
|
|
2632
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
2633
|
+
const cookie = cookies[i].replace(/^\s+/, '');
|
|
2634
|
+
const eq = cookie.indexOf('=');
|
|
2635
|
+
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
2636
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
return null;
|
|
2505
2640
|
},
|
|
2506
2641
|
|
|
2507
2642
|
remove(name) {
|
|
@@ -2583,11 +2718,14 @@ function mergeConfig(config1, config2) {
|
|
|
2583
2718
|
config2 = config2 || {};
|
|
2584
2719
|
|
|
2585
2720
|
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
2586
|
-
// or `config.baseURL` cannot inherit polluted values from Object.prototype
|
|
2587
|
-
//
|
|
2588
|
-
//
|
|
2721
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype.
|
|
2722
|
+
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
2723
|
+
// ergonomics for user code that relies on it.
|
|
2589
2724
|
const config = Object.create(null);
|
|
2590
2725
|
Object.defineProperty(config, 'hasOwnProperty', {
|
|
2726
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
2727
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
2728
|
+
__proto__: null,
|
|
2591
2729
|
value: Object.prototype.hasOwnProperty,
|
|
2592
2730
|
enumerable: false,
|
|
2593
2731
|
writable: true,
|
|
@@ -2684,11 +2822,39 @@ function mergeConfig(config1, config2) {
|
|
|
2684
2822
|
return config;
|
|
2685
2823
|
}
|
|
2686
2824
|
|
|
2825
|
+
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
2826
|
+
|
|
2827
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
2828
|
+
if (policy !== 'content-only') {
|
|
2829
|
+
headers.set(formHeaders);
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
2834
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
2835
|
+
headers.set(key, val);
|
|
2836
|
+
}
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2840
|
+
/**
|
|
2841
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
2842
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
2843
|
+
*
|
|
2844
|
+
* @param {string} str The string to encode
|
|
2845
|
+
*
|
|
2846
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
2847
|
+
*/
|
|
2848
|
+
const encodeUTF8 = (str) =>
|
|
2849
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
2850
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
2851
|
+
);
|
|
2852
|
+
|
|
2687
2853
|
var resolveConfig = (config) => {
|
|
2688
2854
|
const newConfig = mergeConfig({}, config);
|
|
2689
2855
|
|
|
2690
2856
|
// Read only own properties to prevent prototype pollution gadgets
|
|
2691
|
-
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
2857
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
2692
2858
|
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
2693
2859
|
|
|
2694
2860
|
const data = own('data');
|
|
@@ -2714,11 +2880,7 @@ var resolveConfig = (config) => {
|
|
|
2714
2880
|
headers.set(
|
|
2715
2881
|
'Authorization',
|
|
2716
2882
|
'Basic ' +
|
|
2717
|
-
btoa(
|
|
2718
|
-
(auth.username || '') +
|
|
2719
|
-
':' +
|
|
2720
|
-
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
|
2721
|
-
)
|
|
2883
|
+
btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
|
|
2722
2884
|
);
|
|
2723
2885
|
}
|
|
2724
2886
|
|
|
@@ -2727,14 +2889,7 @@ var resolveConfig = (config) => {
|
|
|
2727
2889
|
headers.setContentType(undefined); // browser handles it
|
|
2728
2890
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
2729
2891
|
// Node.js FormData (like form-data package)
|
|
2730
|
-
|
|
2731
|
-
// Only set safe headers to avoid overwriting security headers
|
|
2732
|
-
const allowedHeaders = ['content-type', 'content-length'];
|
|
2733
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
2734
|
-
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
2735
|
-
headers.set(key, val);
|
|
2736
|
-
}
|
|
2737
|
-
});
|
|
2892
|
+
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
2738
2893
|
}
|
|
2739
2894
|
}
|
|
2740
2895
|
|
|
@@ -2749,10 +2904,9 @@ var resolveConfig = (config) => {
|
|
|
2749
2904
|
|
|
2750
2905
|
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
2751
2906
|
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
2752
|
-
// the XSRF token cross-origin.
|
|
2907
|
+
// the XSRF token cross-origin.
|
|
2753
2908
|
const shouldSendXSRF =
|
|
2754
|
-
withXSRFToken === true ||
|
|
2755
|
-
(withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
2909
|
+
withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
2756
2910
|
|
|
2757
2911
|
if (shouldSendXSRF) {
|
|
2758
2912
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
@@ -2848,7 +3002,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
2848
3002
|
// will return status as 0 even though it's a successful request
|
|
2849
3003
|
if (
|
|
2850
3004
|
request.status === 0 &&
|
|
2851
|
-
!(request.responseURL && request.responseURL.
|
|
3005
|
+
!(request.responseURL && request.responseURL.startsWith('file:'))
|
|
2852
3006
|
) {
|
|
2853
3007
|
return;
|
|
2854
3008
|
}
|
|
@@ -2865,6 +3019,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
2865
3019
|
}
|
|
2866
3020
|
|
|
2867
3021
|
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
3022
|
+
done();
|
|
2868
3023
|
|
|
2869
3024
|
// Clean up request
|
|
2870
3025
|
request = null;
|
|
@@ -2880,6 +3035,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
2880
3035
|
// attach the underlying event for consumers who want details
|
|
2881
3036
|
err.event = event || null;
|
|
2882
3037
|
reject(err);
|
|
3038
|
+
done();
|
|
2883
3039
|
request = null;
|
|
2884
3040
|
};
|
|
2885
3041
|
|
|
@@ -2900,6 +3056,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
2900
3056
|
request
|
|
2901
3057
|
)
|
|
2902
3058
|
);
|
|
3059
|
+
done();
|
|
2903
3060
|
|
|
2904
3061
|
// Clean up request
|
|
2905
3062
|
request = null;
|
|
@@ -2910,7 +3067,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
2910
3067
|
|
|
2911
3068
|
// Add headers to the request
|
|
2912
3069
|
if ('setRequestHeader' in request) {
|
|
2913
|
-
utils$1.forEach(requestHeaders
|
|
3070
|
+
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
2914
3071
|
request.setRequestHeader(key, val);
|
|
2915
3072
|
});
|
|
2916
3073
|
}
|
|
@@ -2949,6 +3106,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
2949
3106
|
}
|
|
2950
3107
|
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
2951
3108
|
request.abort();
|
|
3109
|
+
done();
|
|
2952
3110
|
request = null;
|
|
2953
3111
|
};
|
|
2954
3112
|
|
|
@@ -2962,7 +3120,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
2962
3120
|
|
|
2963
3121
|
const protocol = parseProtocol(_config.url);
|
|
2964
3122
|
|
|
2965
|
-
if (protocol && platform.protocols.
|
|
3123
|
+
if (protocol && !platform.protocols.includes(protocol)) {
|
|
2966
3124
|
reject(
|
|
2967
3125
|
new AxiosError(
|
|
2968
3126
|
'Unsupported protocol ' + protocol + ':',
|
|
@@ -2979,54 +3137,55 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
2979
3137
|
};
|
|
2980
3138
|
|
|
2981
3139
|
const composeSignals = (signals, timeout) => {
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
if (timeout || length) {
|
|
2985
|
-
let controller = new AbortController();
|
|
2986
|
-
|
|
2987
|
-
let aborted;
|
|
2988
|
-
|
|
2989
|
-
const onabort = function (reason) {
|
|
2990
|
-
if (!aborted) {
|
|
2991
|
-
aborted = true;
|
|
2992
|
-
unsubscribe();
|
|
2993
|
-
const err = reason instanceof Error ? reason : this.reason;
|
|
2994
|
-
controller.abort(
|
|
2995
|
-
err instanceof AxiosError
|
|
2996
|
-
? err
|
|
2997
|
-
: new CanceledError(err instanceof Error ? err.message : err)
|
|
2998
|
-
);
|
|
2999
|
-
}
|
|
3000
|
-
};
|
|
3140
|
+
signals = signals ? signals.filter(Boolean) : [];
|
|
3001
3141
|
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
}, timeout);
|
|
3008
|
-
|
|
3009
|
-
const unsubscribe = () => {
|
|
3010
|
-
if (signals) {
|
|
3011
|
-
timer && clearTimeout(timer);
|
|
3012
|
-
timer = null;
|
|
3013
|
-
signals.forEach((signal) => {
|
|
3014
|
-
signal.unsubscribe
|
|
3015
|
-
? signal.unsubscribe(onabort)
|
|
3016
|
-
: signal.removeEventListener('abort', onabort);
|
|
3017
|
-
});
|
|
3018
|
-
signals = null;
|
|
3019
|
-
}
|
|
3020
|
-
};
|
|
3142
|
+
if (!timeout && !signals.length) {
|
|
3143
|
+
return;
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
const controller = new AbortController();
|
|
3021
3147
|
|
|
3022
|
-
|
|
3148
|
+
let aborted = false;
|
|
3023
3149
|
|
|
3024
|
-
|
|
3150
|
+
const onabort = function (reason) {
|
|
3151
|
+
if (!aborted) {
|
|
3152
|
+
aborted = true;
|
|
3153
|
+
unsubscribe();
|
|
3154
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
3155
|
+
controller.abort(
|
|
3156
|
+
err instanceof AxiosError
|
|
3157
|
+
? err
|
|
3158
|
+
: new CanceledError(err instanceof Error ? err.message : err)
|
|
3159
|
+
);
|
|
3160
|
+
}
|
|
3161
|
+
};
|
|
3162
|
+
|
|
3163
|
+
let timer =
|
|
3164
|
+
timeout &&
|
|
3165
|
+
setTimeout(() => {
|
|
3166
|
+
timer = null;
|
|
3167
|
+
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
|
|
3168
|
+
}, timeout);
|
|
3169
|
+
|
|
3170
|
+
const unsubscribe = () => {
|
|
3171
|
+
if (!signals) { return; }
|
|
3172
|
+
timer && clearTimeout(timer);
|
|
3173
|
+
timer = null;
|
|
3174
|
+
signals.forEach((signal) => {
|
|
3175
|
+
signal.unsubscribe
|
|
3176
|
+
? signal.unsubscribe(onabort)
|
|
3177
|
+
: signal.removeEventListener('abort', onabort);
|
|
3178
|
+
});
|
|
3179
|
+
signals = null;
|
|
3180
|
+
};
|
|
3025
3181
|
|
|
3026
|
-
|
|
3182
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
3027
3183
|
|
|
3028
|
-
|
|
3029
|
-
|
|
3184
|
+
const { signal } = controller;
|
|
3185
|
+
|
|
3186
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
3187
|
+
|
|
3188
|
+
return signal;
|
|
3030
3189
|
};
|
|
3031
3190
|
|
|
3032
3191
|
const streamChunk = function* (chunk, chunkSize) {
|
|
@@ -3119,16 +3278,112 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3119
3278
|
);
|
|
3120
3279
|
};
|
|
3121
3280
|
|
|
3122
|
-
|
|
3281
|
+
/**
|
|
3282
|
+
* Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|
3283
|
+
* - For base64: compute exact decoded size using length and padding;
|
|
3284
|
+
* handle %XX at the character-count level (no string allocation).
|
|
3285
|
+
* - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
|
|
3286
|
+
*
|
|
3287
|
+
* @param {string} url
|
|
3288
|
+
* @returns {number}
|
|
3289
|
+
*/
|
|
3290
|
+
function estimateDataURLDecodedBytes(url) {
|
|
3291
|
+
if (!url || typeof url !== 'string') return 0;
|
|
3292
|
+
if (!url.startsWith('data:')) return 0;
|
|
3293
|
+
|
|
3294
|
+
const comma = url.indexOf(',');
|
|
3295
|
+
if (comma < 0) return 0;
|
|
3296
|
+
|
|
3297
|
+
const meta = url.slice(5, comma);
|
|
3298
|
+
const body = url.slice(comma + 1);
|
|
3299
|
+
const isBase64 = /;base64/i.test(meta);
|
|
3300
|
+
|
|
3301
|
+
if (isBase64) {
|
|
3302
|
+
let effectiveLen = body.length;
|
|
3303
|
+
const len = body.length; // cache length
|
|
3304
|
+
|
|
3305
|
+
for (let i = 0; i < len; i++) {
|
|
3306
|
+
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
3307
|
+
const a = body.charCodeAt(i + 1);
|
|
3308
|
+
const b = body.charCodeAt(i + 2);
|
|
3309
|
+
const isHex =
|
|
3310
|
+
((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
|
|
3311
|
+
((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
|
|
3312
|
+
|
|
3313
|
+
if (isHex) {
|
|
3314
|
+
effectiveLen -= 2;
|
|
3315
|
+
i += 2;
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3123
3319
|
|
|
3124
|
-
|
|
3320
|
+
let pad = 0;
|
|
3321
|
+
let idx = len - 1;
|
|
3322
|
+
|
|
3323
|
+
const tailIsPct3D = (j) =>
|
|
3324
|
+
j >= 2 &&
|
|
3325
|
+
body.charCodeAt(j - 2) === 37 && // '%'
|
|
3326
|
+
body.charCodeAt(j - 1) === 51 && // '3'
|
|
3327
|
+
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
|
|
3328
|
+
|
|
3329
|
+
if (idx >= 0) {
|
|
3330
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
3331
|
+
pad++;
|
|
3332
|
+
idx--;
|
|
3333
|
+
} else if (tailIsPct3D(idx)) {
|
|
3334
|
+
pad++;
|
|
3335
|
+
idx -= 3;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
|
|
3339
|
+
if (pad === 1 && idx >= 0) {
|
|
3340
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
3341
|
+
pad++;
|
|
3342
|
+
} else if (tailIsPct3D(idx)) {
|
|
3343
|
+
pad++;
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
const groups = Math.floor(effectiveLen / 4);
|
|
3348
|
+
const bytes = groups * 3 - (pad || 0);
|
|
3349
|
+
return bytes > 0 ? bytes : 0;
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
|
|
3353
|
+
return Buffer.byteLength(body, 'utf8');
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
3357
|
+
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
3358
|
+
// Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
|
|
3359
|
+
// but 3 UTF-8 bytes).
|
|
3360
|
+
let bytes = 0;
|
|
3361
|
+
for (let i = 0, len = body.length; i < len; i++) {
|
|
3362
|
+
const c = body.charCodeAt(i);
|
|
3363
|
+
if (c < 0x80) {
|
|
3364
|
+
bytes += 1;
|
|
3365
|
+
} else if (c < 0x800) {
|
|
3366
|
+
bytes += 2;
|
|
3367
|
+
} else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
|
3368
|
+
const next = body.charCodeAt(i + 1);
|
|
3369
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
3370
|
+
bytes += 4;
|
|
3371
|
+
i++;
|
|
3372
|
+
} else {
|
|
3373
|
+
bytes += 3;
|
|
3374
|
+
}
|
|
3375
|
+
} else {
|
|
3376
|
+
bytes += 3;
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
return bytes;
|
|
3380
|
+
}
|
|
3381
|
+
|
|
3382
|
+
const VERSION = "1.16.1";
|
|
3125
3383
|
|
|
3126
|
-
const
|
|
3127
|
-
Request,
|
|
3128
|
-
Response,
|
|
3129
|
-
}))(utils$1.global);
|
|
3384
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3130
3385
|
|
|
3131
|
-
const {
|
|
3386
|
+
const { isFunction } = utils$1;
|
|
3132
3387
|
|
|
3133
3388
|
const test = (fn, ...args) => {
|
|
3134
3389
|
try {
|
|
@@ -3139,11 +3394,20 @@ const test = (fn, ...args) => {
|
|
|
3139
3394
|
};
|
|
3140
3395
|
|
|
3141
3396
|
const factory = (env) => {
|
|
3397
|
+
const globalObject =
|
|
3398
|
+
utils$1.global !== undefined && utils$1.global !== null
|
|
3399
|
+
? utils$1.global
|
|
3400
|
+
: globalThis;
|
|
3401
|
+
const { ReadableStream, TextEncoder } = globalObject;
|
|
3402
|
+
|
|
3142
3403
|
env = utils$1.merge.call(
|
|
3143
3404
|
{
|
|
3144
3405
|
skipUndefined: true,
|
|
3145
3406
|
},
|
|
3146
|
-
|
|
3407
|
+
{
|
|
3408
|
+
Request: globalObject.Request,
|
|
3409
|
+
Response: globalObject.Response,
|
|
3410
|
+
},
|
|
3147
3411
|
env
|
|
3148
3412
|
);
|
|
3149
3413
|
|
|
@@ -3156,7 +3420,7 @@ const factory = (env) => {
|
|
|
3156
3420
|
return false;
|
|
3157
3421
|
}
|
|
3158
3422
|
|
|
3159
|
-
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream
|
|
3423
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
|
3160
3424
|
|
|
3161
3425
|
const encodeText =
|
|
3162
3426
|
isFetchSupported &&
|
|
@@ -3174,7 +3438,7 @@ const factory = (env) => {
|
|
|
3174
3438
|
let duplexAccessed = false;
|
|
3175
3439
|
|
|
3176
3440
|
const request = new Request(platform.origin, {
|
|
3177
|
-
body: new ReadableStream
|
|
3441
|
+
body: new ReadableStream(),
|
|
3178
3442
|
method: 'POST',
|
|
3179
3443
|
get duplex() {
|
|
3180
3444
|
duplexAccessed = true;
|
|
@@ -3270,8 +3534,13 @@ const factory = (env) => {
|
|
|
3270
3534
|
headers,
|
|
3271
3535
|
withCredentials = 'same-origin',
|
|
3272
3536
|
fetchOptions,
|
|
3537
|
+
maxContentLength,
|
|
3538
|
+
maxBodyLength,
|
|
3273
3539
|
} = resolveConfig(config);
|
|
3274
3540
|
|
|
3541
|
+
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
3542
|
+
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
3543
|
+
|
|
3275
3544
|
let _fetch = envFetch || fetch;
|
|
3276
3545
|
|
|
3277
3546
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
@@ -3293,6 +3562,41 @@ const factory = (env) => {
|
|
|
3293
3562
|
let requestContentLength;
|
|
3294
3563
|
|
|
3295
3564
|
try {
|
|
3565
|
+
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
3566
|
+
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
3567
|
+
// "if (protocol === 'data:')" branch).
|
|
3568
|
+
if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
|
|
3569
|
+
const estimated = estimateDataURLDecodedBytes(url);
|
|
3570
|
+
if (estimated > maxContentLength) {
|
|
3571
|
+
throw new AxiosError(
|
|
3572
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3573
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
3574
|
+
config,
|
|
3575
|
+
request
|
|
3576
|
+
);
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
// Enforce maxBodyLength against the outbound request body before dispatch.
|
|
3581
|
+
// Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
|
|
3582
|
+
// maxBodyLength limit'). Skip when the body length cannot be determined
|
|
3583
|
+
// (e.g. a live ReadableStream supplied by the caller).
|
|
3584
|
+
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
3585
|
+
const outboundLength = await resolveBodyLength(headers, data);
|
|
3586
|
+
if (
|
|
3587
|
+
typeof outboundLength === 'number' &&
|
|
3588
|
+
isFinite(outboundLength) &&
|
|
3589
|
+
outboundLength > maxBodyLength
|
|
3590
|
+
) {
|
|
3591
|
+
throw new AxiosError(
|
|
3592
|
+
'Request body larger than maxBodyLength limit',
|
|
3593
|
+
AxiosError.ERR_BAD_REQUEST,
|
|
3594
|
+
config,
|
|
3595
|
+
request
|
|
3596
|
+
);
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3296
3600
|
if (
|
|
3297
3601
|
onUploadProgress &&
|
|
3298
3602
|
supportsRequestStream &&
|
|
@@ -3343,11 +3647,14 @@ const factory = (env) => {
|
|
|
3343
3647
|
}
|
|
3344
3648
|
}
|
|
3345
3649
|
|
|
3650
|
+
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
3651
|
+
headers.set('User-Agent', 'axios/' + VERSION, false);
|
|
3652
|
+
|
|
3346
3653
|
const resolvedOptions = {
|
|
3347
3654
|
...fetchOptions,
|
|
3348
3655
|
signal: composedSignal,
|
|
3349
3656
|
method: method.toUpperCase(),
|
|
3350
|
-
headers: headers.normalize()
|
|
3657
|
+
headers: toByteStringHeaderObject(headers.normalize()),
|
|
3351
3658
|
body: data,
|
|
3352
3659
|
duplex: 'half',
|
|
3353
3660
|
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
@@ -3359,10 +3666,28 @@ const factory = (env) => {
|
|
|
3359
3666
|
? _fetch(request, fetchOptions)
|
|
3360
3667
|
: _fetch(url, resolvedOptions));
|
|
3361
3668
|
|
|
3669
|
+
// Cheap pre-check: if the server honestly declares a content-length that
|
|
3670
|
+
// already exceeds the cap, reject before we start streaming.
|
|
3671
|
+
if (hasMaxContentLength) {
|
|
3672
|
+
const declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3673
|
+
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
3674
|
+
throw new AxiosError(
|
|
3675
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3676
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
3677
|
+
config,
|
|
3678
|
+
request
|
|
3679
|
+
);
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3362
3683
|
const isStreamResponse =
|
|
3363
3684
|
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3364
3685
|
|
|
3365
|
-
if (
|
|
3686
|
+
if (
|
|
3687
|
+
supportsResponseStream &&
|
|
3688
|
+
response.body &&
|
|
3689
|
+
(onDownloadProgress || hasMaxContentLength || (isStreamResponse && unsubscribe))
|
|
3690
|
+
) {
|
|
3366
3691
|
const options = {};
|
|
3367
3692
|
|
|
3368
3693
|
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
@@ -3379,8 +3704,24 @@ const factory = (env) => {
|
|
|
3379
3704
|
)) ||
|
|
3380
3705
|
[];
|
|
3381
3706
|
|
|
3707
|
+
let bytesRead = 0;
|
|
3708
|
+
const onChunkProgress = (loadedBytes) => {
|
|
3709
|
+
if (hasMaxContentLength) {
|
|
3710
|
+
bytesRead = loadedBytes;
|
|
3711
|
+
if (bytesRead > maxContentLength) {
|
|
3712
|
+
throw new AxiosError(
|
|
3713
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3714
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
3715
|
+
config,
|
|
3716
|
+
request
|
|
3717
|
+
);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
onProgress && onProgress(loadedBytes);
|
|
3721
|
+
};
|
|
3722
|
+
|
|
3382
3723
|
response = new Response(
|
|
3383
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE,
|
|
3724
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
|
|
3384
3725
|
flush && flush();
|
|
3385
3726
|
unsubscribe && unsubscribe();
|
|
3386
3727
|
}),
|
|
@@ -3395,6 +3736,33 @@ const factory = (env) => {
|
|
|
3395
3736
|
config
|
|
3396
3737
|
);
|
|
3397
3738
|
|
|
3739
|
+
// Fallback enforcement for environments without ReadableStream support
|
|
3740
|
+
// (legacy runtimes). Detect materialized size from typed output; skip
|
|
3741
|
+
// streams/Response passthrough since the user will read those themselves.
|
|
3742
|
+
if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
|
|
3743
|
+
let materializedSize;
|
|
3744
|
+
if (responseData != null) {
|
|
3745
|
+
if (typeof responseData.byteLength === 'number') {
|
|
3746
|
+
materializedSize = responseData.byteLength;
|
|
3747
|
+
} else if (typeof responseData.size === 'number') {
|
|
3748
|
+
materializedSize = responseData.size;
|
|
3749
|
+
} else if (typeof responseData === 'string') {
|
|
3750
|
+
materializedSize =
|
|
3751
|
+
typeof TextEncoder === 'function'
|
|
3752
|
+
? new TextEncoder().encode(responseData).byteLength
|
|
3753
|
+
: responseData.length;
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
|
|
3757
|
+
throw new AxiosError(
|
|
3758
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3759
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
3760
|
+
config,
|
|
3761
|
+
request
|
|
3762
|
+
);
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3398
3766
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3399
3767
|
|
|
3400
3768
|
return await new Promise((resolve, reject) => {
|
|
@@ -3410,6 +3778,17 @@ const factory = (env) => {
|
|
|
3410
3778
|
} catch (err) {
|
|
3411
3779
|
unsubscribe && unsubscribe();
|
|
3412
3780
|
|
|
3781
|
+
// Safari can surface fetch aborts as a DOMException-like object whose
|
|
3782
|
+
// branded getters throw. Prefer our composed signal reason before reading
|
|
3783
|
+
// the caught error, preserving timeout vs cancellation semantics.
|
|
3784
|
+
if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError) {
|
|
3785
|
+
const canceledError = composedSignal.reason;
|
|
3786
|
+
canceledError.config = config;
|
|
3787
|
+
request && (canceledError.request = request);
|
|
3788
|
+
err !== canceledError && (canceledError.cause = err);
|
|
3789
|
+
throw canceledError;
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3413
3792
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3414
3793
|
throw Object.assign(
|
|
3415
3794
|
new AxiosError(
|
|
@@ -3478,11 +3857,13 @@ const knownAdapters = {
|
|
|
3478
3857
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3479
3858
|
if (fn) {
|
|
3480
3859
|
try {
|
|
3481
|
-
Object.
|
|
3860
|
+
// Null-proto descriptors so a polluted Object.prototype.get cannot turn
|
|
3861
|
+
// these data descriptors into accessor descriptors on the way in.
|
|
3862
|
+
Object.defineProperty(fn, 'name', { __proto__: null, value });
|
|
3482
3863
|
} catch (e) {
|
|
3483
3864
|
// eslint-disable-next-line no-empty
|
|
3484
3865
|
}
|
|
3485
|
-
Object.defineProperty(fn, 'adapterName', { value });
|
|
3866
|
+
Object.defineProperty(fn, 'adapterName', { __proto__: null, value });
|
|
3486
3867
|
}
|
|
3487
3868
|
});
|
|
3488
3869
|
|
|
@@ -3624,8 +4005,15 @@ function dispatchRequest(config) {
|
|
|
3624
4005
|
function onAdapterResolution(response) {
|
|
3625
4006
|
throwIfCancellationRequested(config);
|
|
3626
4007
|
|
|
3627
|
-
//
|
|
3628
|
-
|
|
4008
|
+
// Expose the current response on config so that transformResponse can
|
|
4009
|
+
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
4010
|
+
// We clean it up afterwards to avoid polluting the config object.
|
|
4011
|
+
config.response = response;
|
|
4012
|
+
try {
|
|
4013
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
4014
|
+
} finally {
|
|
4015
|
+
delete config.response;
|
|
4016
|
+
}
|
|
3629
4017
|
|
|
3630
4018
|
response.headers = AxiosHeaders.from(response.headers);
|
|
3631
4019
|
|
|
@@ -3637,11 +4025,16 @@ function dispatchRequest(config) {
|
|
|
3637
4025
|
|
|
3638
4026
|
// Transform response data
|
|
3639
4027
|
if (reason && reason.response) {
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
4028
|
+
config.response = reason.response;
|
|
4029
|
+
try {
|
|
4030
|
+
reason.response.data = transformData.call(
|
|
4031
|
+
config,
|
|
4032
|
+
config.transformResponse,
|
|
4033
|
+
reason.response
|
|
4034
|
+
);
|
|
4035
|
+
} finally {
|
|
4036
|
+
delete config.response;
|
|
4037
|
+
}
|
|
3645
4038
|
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|
3646
4039
|
}
|
|
3647
4040
|
}
|
|
@@ -3651,8 +4044,6 @@ function dispatchRequest(config) {
|
|
|
3651
4044
|
);
|
|
3652
4045
|
}
|
|
3653
4046
|
|
|
3654
|
-
const VERSION = "1.15.2";
|
|
3655
|
-
|
|
3656
4047
|
const validators$1 = {};
|
|
3657
4048
|
|
|
3658
4049
|
// eslint-disable-next-line func-names
|
|
@@ -3737,7 +4128,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3737
4128
|
while (i-- > 0) {
|
|
3738
4129
|
const opt = keys[i];
|
|
3739
4130
|
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
3740
|
-
// a non-function validator and cause a TypeError.
|
|
4131
|
+
// a non-function validator and cause a TypeError.
|
|
3741
4132
|
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
3742
4133
|
if (validator) {
|
|
3743
4134
|
const value = options[opt];
|
|
@@ -3897,7 +4288,7 @@ class Axios {
|
|
|
3897
4288
|
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
3898
4289
|
|
|
3899
4290
|
headers &&
|
|
3900
|
-
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
4291
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
|
|
3901
4292
|
delete headers[method];
|
|
3902
4293
|
});
|
|
3903
4294
|
|
|
@@ -4000,7 +4391,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
4000
4391
|
};
|
|
4001
4392
|
});
|
|
4002
4393
|
|
|
4003
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
4394
|
+
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
4004
4395
|
function generateHTTPMethod(isForm) {
|
|
4005
4396
|
return function httpMethod(url, data, config) {
|
|
4006
4397
|
return this.request(
|
|
@@ -4020,7 +4411,11 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
|
|
|
4020
4411
|
|
|
4021
4412
|
Axios.prototype[method] = generateHTTPMethod();
|
|
4022
4413
|
|
|
4023
|
-
|
|
4414
|
+
// QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|
4415
|
+
// its semantics, so no queryForm shorthand is generated.
|
|
4416
|
+
if (method !== 'query') {
|
|
4417
|
+
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
4418
|
+
}
|
|
4024
4419
|
});
|
|
4025
4420
|
|
|
4026
4421
|
/**
|