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