@xchainjs/xchain-aggregator 2.3.3 → 2.3.4
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/lib/index.esm.js +1566 -1170
- package/lib/index.js +1566 -1170
- package/package.json +16 -16
package/lib/index.js
CHANGED
|
@@ -508,9 +508,9 @@ const isFile = kindOfTest('File');
|
|
|
508
508
|
* also have a `name` and `type` attribute to specify filename and content type
|
|
509
509
|
*
|
|
510
510
|
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
511
|
-
*
|
|
511
|
+
*
|
|
512
512
|
* @param {*} value The value to test
|
|
513
|
-
*
|
|
513
|
+
*
|
|
514
514
|
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
515
515
|
*/
|
|
516
516
|
const isReactNativeBlob = (value) => {
|
|
@@ -520,9 +520,9 @@ const isReactNativeBlob = (value) => {
|
|
|
520
520
|
/**
|
|
521
521
|
* Determine if environment is React Native
|
|
522
522
|
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
523
|
-
*
|
|
523
|
+
*
|
|
524
524
|
* @param {*} formData The formData to test
|
|
525
|
-
*
|
|
525
|
+
*
|
|
526
526
|
* @returns {boolean} True if environment is React Native, otherwise false
|
|
527
527
|
*/
|
|
528
528
|
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
@@ -541,7 +541,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
541
541
|
*
|
|
542
542
|
* @param {*} val The value to test
|
|
543
543
|
*
|
|
544
|
-
* @returns {boolean} True if value is a
|
|
544
|
+
* @returns {boolean} True if value is a FileList, otherwise false
|
|
545
545
|
*/
|
|
546
546
|
const isFileList = kindOfTest('FileList');
|
|
547
547
|
|
|
@@ -575,14 +575,16 @@ const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
|
575
575
|
const isFormData = (thing) => {
|
|
576
576
|
if (!thing) return false;
|
|
577
577
|
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
578
|
-
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData
|
|
578
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
579
579
|
const proto = getPrototypeOf(thing);
|
|
580
580
|
if (!proto || proto === Object.prototype) return false;
|
|
581
581
|
if (!isFunction$1(thing.append)) return false;
|
|
582
582
|
const kind = kindOf(thing);
|
|
583
|
-
return
|
|
583
|
+
return (
|
|
584
|
+
kind === 'formdata' ||
|
|
584
585
|
// detect form-data instance
|
|
585
|
-
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
586
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
587
|
+
);
|
|
586
588
|
};
|
|
587
589
|
|
|
588
590
|
/**
|
|
@@ -717,7 +719,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
717
719
|
*
|
|
718
720
|
* @returns {Object} Result of all merge properties
|
|
719
721
|
*/
|
|
720
|
-
function merge(
|
|
722
|
+
function merge(...objs) {
|
|
721
723
|
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
722
724
|
const result = {};
|
|
723
725
|
const assignValue = (val, key) => {
|
|
@@ -727,8 +729,12 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
727
729
|
}
|
|
728
730
|
|
|
729
731
|
const targetKey = (caseless && findKey(result, key)) || key;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
+
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
733
|
+
// chain, so a polluted Object.prototype value could surface here and get
|
|
734
|
+
// copied into the merged result.
|
|
735
|
+
const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
|
|
736
|
+
if (isPlainObject(existing) && isPlainObject(val)) {
|
|
737
|
+
result[targetKey] = merge(existing, val);
|
|
732
738
|
} else if (isPlainObject(val)) {
|
|
733
739
|
result[targetKey] = merge({}, val);
|
|
734
740
|
} else if (isArray(val)) {
|
|
@@ -738,8 +744,8 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
738
744
|
}
|
|
739
745
|
};
|
|
740
746
|
|
|
741
|
-
for (let i = 0, l =
|
|
742
|
-
|
|
747
|
+
for (let i = 0, l = objs.length; i < l; i++) {
|
|
748
|
+
objs[i] && forEach(objs[i], assignValue);
|
|
743
749
|
}
|
|
744
750
|
return result;
|
|
745
751
|
}
|
|
@@ -761,6 +767,9 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
761
767
|
(val, key) => {
|
|
762
768
|
if (thisArg && isFunction$1(val)) {
|
|
763
769
|
Object.defineProperty(a, key, {
|
|
770
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot
|
|
771
|
+
// hijack defineProperty's accessor-vs-data resolution.
|
|
772
|
+
__proto__: null,
|
|
764
773
|
value: bind(val, thisArg),
|
|
765
774
|
writable: true,
|
|
766
775
|
enumerable: true,
|
|
@@ -768,6 +777,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
768
777
|
});
|
|
769
778
|
} else {
|
|
770
779
|
Object.defineProperty(a, key, {
|
|
780
|
+
__proto__: null,
|
|
771
781
|
value: val,
|
|
772
782
|
writable: true,
|
|
773
783
|
enumerable: true,
|
|
@@ -806,12 +816,14 @@ const stripBOM = (content) => {
|
|
|
806
816
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
807
817
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
808
818
|
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
819
|
+
__proto__: null,
|
|
809
820
|
value: constructor,
|
|
810
821
|
writable: true,
|
|
811
822
|
enumerable: false,
|
|
812
823
|
configurable: true,
|
|
813
824
|
});
|
|
814
825
|
Object.defineProperty(constructor, 'super', {
|
|
826
|
+
__proto__: null,
|
|
815
827
|
value: superConstructor.prototype,
|
|
816
828
|
});
|
|
817
829
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -993,7 +1005,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
993
1005
|
const freezeMethods = (obj) => {
|
|
994
1006
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
995
1007
|
// skip restricted props in strict mode
|
|
996
|
-
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].
|
|
1008
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
|
997
1009
|
return false;
|
|
998
1010
|
}
|
|
999
1011
|
|
|
@@ -1067,11 +1079,11 @@ function isSpecCompliantForm(thing) {
|
|
|
1067
1079
|
* @returns {Object} The JSON-compatible object.
|
|
1068
1080
|
*/
|
|
1069
1081
|
const toJSONObject = (obj) => {
|
|
1070
|
-
const
|
|
1082
|
+
const visited = new WeakSet();
|
|
1071
1083
|
|
|
1072
|
-
const visit = (source
|
|
1084
|
+
const visit = (source) => {
|
|
1073
1085
|
if (isObject(source)) {
|
|
1074
|
-
if (
|
|
1086
|
+
if (visited.has(source)) {
|
|
1075
1087
|
return;
|
|
1076
1088
|
}
|
|
1077
1089
|
|
|
@@ -1081,15 +1093,16 @@ const toJSONObject = (obj) => {
|
|
|
1081
1093
|
}
|
|
1082
1094
|
|
|
1083
1095
|
if (!('toJSON' in source)) {
|
|
1084
|
-
|
|
1096
|
+
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
1097
|
+
visited.add(source);
|
|
1085
1098
|
const target = isArray(source) ? [] : {};
|
|
1086
1099
|
|
|
1087
1100
|
forEach(source, (value, key) => {
|
|
1088
|
-
const reducedValue = visit(value
|
|
1101
|
+
const reducedValue = visit(value);
|
|
1089
1102
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
1090
1103
|
});
|
|
1091
1104
|
|
|
1092
|
-
|
|
1105
|
+
visited.delete(source);
|
|
1093
1106
|
|
|
1094
1107
|
return target;
|
|
1095
1108
|
}
|
|
@@ -1098,7 +1111,7 @@ const toJSONObject = (obj) => {
|
|
|
1098
1111
|
return source;
|
|
1099
1112
|
};
|
|
1100
1113
|
|
|
1101
|
-
return visit(obj
|
|
1114
|
+
return visit(obj);
|
|
1102
1115
|
};
|
|
1103
1116
|
|
|
1104
1117
|
/**
|
|
@@ -1234,1312 +1247,1423 @@ var utils$1 = {
|
|
|
1234
1247
|
isIterable,
|
|
1235
1248
|
};
|
|
1236
1249
|
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1250
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1251
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1252
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1253
|
+
'age',
|
|
1254
|
+
'authorization',
|
|
1255
|
+
'content-length',
|
|
1256
|
+
'content-type',
|
|
1257
|
+
'etag',
|
|
1258
|
+
'expires',
|
|
1259
|
+
'from',
|
|
1260
|
+
'host',
|
|
1261
|
+
'if-modified-since',
|
|
1262
|
+
'if-unmodified-since',
|
|
1263
|
+
'last-modified',
|
|
1264
|
+
'location',
|
|
1265
|
+
'max-forwards',
|
|
1266
|
+
'proxy-authorization',
|
|
1267
|
+
'referer',
|
|
1268
|
+
'retry-after',
|
|
1269
|
+
'user-agent',
|
|
1270
|
+
]);
|
|
1242
1271
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1272
|
+
/**
|
|
1273
|
+
* Parse headers into an object
|
|
1274
|
+
*
|
|
1275
|
+
* ```
|
|
1276
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
1277
|
+
* Content-Type: application/json
|
|
1278
|
+
* Connection: keep-alive
|
|
1279
|
+
* Transfer-Encoding: chunked
|
|
1280
|
+
* ```
|
|
1281
|
+
*
|
|
1282
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
|
1283
|
+
*
|
|
1284
|
+
* @returns {Object} Headers parsed into an object
|
|
1285
|
+
*/
|
|
1286
|
+
var parseHeaders = (rawHeaders) => {
|
|
1287
|
+
const parsed = {};
|
|
1288
|
+
let key;
|
|
1289
|
+
let val;
|
|
1290
|
+
let i;
|
|
1247
1291
|
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1292
|
+
rawHeaders &&
|
|
1293
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
1294
|
+
i = line.indexOf(':');
|
|
1295
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1296
|
+
val = line.substring(i + 1).trim();
|
|
1251
1297
|
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
* @param {string} message The error message.
|
|
1256
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1257
|
-
* @param {Object} [config] The config.
|
|
1258
|
-
* @param {Object} [request] The request.
|
|
1259
|
-
* @param {Object} [response] The response.
|
|
1260
|
-
*
|
|
1261
|
-
* @returns {Error} The created error.
|
|
1262
|
-
*/
|
|
1263
|
-
constructor(message, code, config, request, response) {
|
|
1264
|
-
super(message);
|
|
1298
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1265
1301
|
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1302
|
+
if (key === 'set-cookie') {
|
|
1303
|
+
if (parsed[key]) {
|
|
1304
|
+
parsed[key].push(val);
|
|
1305
|
+
} else {
|
|
1306
|
+
parsed[key] = [val];
|
|
1307
|
+
}
|
|
1308
|
+
} else {
|
|
1309
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1310
|
+
}
|
|
1274
1311
|
});
|
|
1275
1312
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1313
|
+
return parsed;
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
function trimSPorHTAB(str) {
|
|
1317
|
+
let start = 0;
|
|
1318
|
+
let end = str.length;
|
|
1319
|
+
|
|
1320
|
+
while (start < end) {
|
|
1321
|
+
const code = str.charCodeAt(start);
|
|
1322
|
+
|
|
1323
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1324
|
+
break;
|
|
1284
1325
|
}
|
|
1285
|
-
}
|
|
1286
1326
|
|
|
1287
|
-
|
|
1288
|
-
return {
|
|
1289
|
-
// Standard
|
|
1290
|
-
message: this.message,
|
|
1291
|
-
name: this.name,
|
|
1292
|
-
// Microsoft
|
|
1293
|
-
description: this.description,
|
|
1294
|
-
number: this.number,
|
|
1295
|
-
// Mozilla
|
|
1296
|
-
fileName: this.fileName,
|
|
1297
|
-
lineNumber: this.lineNumber,
|
|
1298
|
-
columnNumber: this.columnNumber,
|
|
1299
|
-
stack: this.stack,
|
|
1300
|
-
// Axios
|
|
1301
|
-
config: utils$1.toJSONObject(this.config),
|
|
1302
|
-
code: this.code,
|
|
1303
|
-
status: this.status,
|
|
1304
|
-
};
|
|
1327
|
+
start += 1;
|
|
1305
1328
|
}
|
|
1306
|
-
};
|
|
1307
1329
|
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1311
|
-
AxiosError$1.ECONNABORTED = 'ECONNABORTED';
|
|
1312
|
-
AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';
|
|
1313
|
-
AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';
|
|
1314
|
-
AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1315
|
-
AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1316
|
-
AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1317
|
-
AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1318
|
-
AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
|
|
1319
|
-
AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1320
|
-
AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1321
|
-
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1330
|
+
while (end > start) {
|
|
1331
|
+
const code = str.charCodeAt(end - 1);
|
|
1322
1332
|
|
|
1323
|
-
|
|
1324
|
-
|
|
1333
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1334
|
+
break;
|
|
1335
|
+
}
|
|
1325
1336
|
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
*
|
|
1329
|
-
* @param {string} thing - The object or array to be visited.
|
|
1330
|
-
*
|
|
1331
|
-
* @returns {boolean}
|
|
1332
|
-
*/
|
|
1333
|
-
function isVisitable(thing) {
|
|
1334
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1335
|
-
}
|
|
1337
|
+
end -= 1;
|
|
1338
|
+
}
|
|
1336
1339
|
|
|
1337
|
-
|
|
1338
|
-
* It removes the brackets from the end of a string
|
|
1339
|
-
*
|
|
1340
|
-
* @param {string} key - The key of the parameter.
|
|
1341
|
-
*
|
|
1342
|
-
* @returns {string} the key without the brackets.
|
|
1343
|
-
*/
|
|
1344
|
-
function removeBrackets(key) {
|
|
1345
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1340
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
1346
1341
|
}
|
|
1347
1342
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
return
|
|
1360
|
-
.concat(key)
|
|
1361
|
-
.map(function each(token, i) {
|
|
1362
|
-
// eslint-disable-next-line no-param-reassign
|
|
1363
|
-
token = removeBrackets(token);
|
|
1364
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
1365
|
-
})
|
|
1366
|
-
.join(dots ? '.' : '');
|
|
1343
|
+
// The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
|
|
1344
|
+
// eslint-disable-next-line no-control-regex
|
|
1345
|
+
const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
|
|
1346
|
+
// eslint-disable-next-line no-control-regex
|
|
1347
|
+
const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
|
|
1348
|
+
|
|
1349
|
+
function sanitizeValue(value, invalidChars) {
|
|
1350
|
+
if (utils$1.isArray(value)) {
|
|
1351
|
+
return value.map((item) => sanitizeValue(item, invalidChars));
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
return trimSPorHTAB(String(value).replace(invalidChars, ''));
|
|
1367
1355
|
}
|
|
1368
1356
|
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1357
|
+
const sanitizeHeaderValue = (value) =>
|
|
1358
|
+
sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
|
|
1359
|
+
|
|
1360
|
+
const sanitizeByteStringHeaderValue = (value) =>
|
|
1361
|
+
sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
|
|
1362
|
+
|
|
1363
|
+
function toByteStringHeaderObject(headers) {
|
|
1364
|
+
const byteStringHeaders = Object.create(null);
|
|
1365
|
+
|
|
1366
|
+
utils$1.forEach(headers.toJSON(), (value, header) => {
|
|
1367
|
+
byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
|
|
1368
|
+
});
|
|
1369
|
+
|
|
1370
|
+
return byteStringHeaders;
|
|
1378
1371
|
}
|
|
1379
1372
|
|
|
1380
|
-
const
|
|
1381
|
-
return /^is[A-Z]/.test(prop);
|
|
1382
|
-
});
|
|
1373
|
+
const $internals = Symbol('internals');
|
|
1383
1374
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
* @param {Object} obj
|
|
1388
|
-
* @param {?Object} [formData]
|
|
1389
|
-
* @param {?Object} [options]
|
|
1390
|
-
* @param {Function} [options.visitor]
|
|
1391
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
1392
|
-
* @param {Boolean} [options.dots = false]
|
|
1393
|
-
* @param {?Boolean} [options.indexes = false]
|
|
1394
|
-
*
|
|
1395
|
-
* @returns {Object}
|
|
1396
|
-
**/
|
|
1375
|
+
function normalizeHeader(header) {
|
|
1376
|
+
return header && String(header).trim().toLowerCase();
|
|
1377
|
+
}
|
|
1397
1378
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
1402
|
-
* @param {string} formData - The FormData object to append to.
|
|
1403
|
-
* @param {Object<string, any>} options
|
|
1404
|
-
*
|
|
1405
|
-
* @returns
|
|
1406
|
-
*/
|
|
1407
|
-
function toFormData$1(obj, formData, options) {
|
|
1408
|
-
if (!utils$1.isObject(obj)) {
|
|
1409
|
-
throw new TypeError('target must be an object');
|
|
1379
|
+
function normalizeValue(value) {
|
|
1380
|
+
if (value === false || value == null) {
|
|
1381
|
+
return value;
|
|
1410
1382
|
}
|
|
1411
1383
|
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
// eslint-disable-next-line no-param-reassign
|
|
1416
|
-
options = utils$1.toFlatObject(
|
|
1417
|
-
options,
|
|
1418
|
-
{
|
|
1419
|
-
metaTokens: true,
|
|
1420
|
-
dots: false,
|
|
1421
|
-
indexes: false,
|
|
1422
|
-
},
|
|
1423
|
-
false,
|
|
1424
|
-
function defined(option, source) {
|
|
1425
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1426
|
-
return !utils$1.isUndefined(source[option]);
|
|
1427
|
-
}
|
|
1428
|
-
);
|
|
1384
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
1385
|
+
}
|
|
1429
1386
|
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
const
|
|
1433
|
-
|
|
1434
|
-
const indexes = options.indexes;
|
|
1435
|
-
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1436
|
-
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1437
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1387
|
+
function parseTokens(str) {
|
|
1388
|
+
const tokens = Object.create(null);
|
|
1389
|
+
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
1390
|
+
let match;
|
|
1438
1391
|
|
|
1439
|
-
|
|
1440
|
-
|
|
1392
|
+
while ((match = tokensRE.exec(str))) {
|
|
1393
|
+
tokens[match[1]] = match[2];
|
|
1441
1394
|
}
|
|
1442
1395
|
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
if (utils$1.isDate(value)) {
|
|
1447
|
-
return value.toISOString();
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
if (utils$1.isBoolean(value)) {
|
|
1451
|
-
return value.toString();
|
|
1452
|
-
}
|
|
1396
|
+
return tokens;
|
|
1397
|
+
}
|
|
1453
1398
|
|
|
1454
|
-
|
|
1455
|
-
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
1456
|
-
}
|
|
1399
|
+
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1457
1400
|
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1401
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1402
|
+
if (utils$1.isFunction(filter)) {
|
|
1403
|
+
return filter.call(this, value, header);
|
|
1404
|
+
}
|
|
1461
1405
|
|
|
1462
|
-
|
|
1406
|
+
if (isHeaderNameFilter) {
|
|
1407
|
+
value = header;
|
|
1463
1408
|
}
|
|
1464
1409
|
|
|
1465
|
-
|
|
1466
|
-
* Default visitor.
|
|
1467
|
-
*
|
|
1468
|
-
* @param {*} value
|
|
1469
|
-
* @param {String|Number} key
|
|
1470
|
-
* @param {Array<String|Number>} path
|
|
1471
|
-
* @this {FormData}
|
|
1472
|
-
*
|
|
1473
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
1474
|
-
*/
|
|
1475
|
-
function defaultVisitor(value, key, path) {
|
|
1476
|
-
let arr = value;
|
|
1410
|
+
if (!utils$1.isString(value)) return;
|
|
1477
1411
|
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
}
|
|
1412
|
+
if (utils$1.isString(filter)) {
|
|
1413
|
+
return value.indexOf(filter) !== -1;
|
|
1414
|
+
}
|
|
1482
1415
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
// eslint-disable-next-line no-param-reassign
|
|
1488
|
-
value = JSON.stringify(value);
|
|
1489
|
-
} else if (
|
|
1490
|
-
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1491
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1492
|
-
) {
|
|
1493
|
-
// eslint-disable-next-line no-param-reassign
|
|
1494
|
-
key = removeBrackets(key);
|
|
1416
|
+
if (utils$1.isRegExp(filter)) {
|
|
1417
|
+
return filter.test(value);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1495
1420
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
: key + '[]',
|
|
1505
|
-
convertValue(el)
|
|
1506
|
-
);
|
|
1507
|
-
});
|
|
1508
|
-
return false;
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1421
|
+
function formatHeader(header) {
|
|
1422
|
+
return header
|
|
1423
|
+
.trim()
|
|
1424
|
+
.toLowerCase()
|
|
1425
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1426
|
+
return char.toUpperCase() + str;
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1511
1429
|
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
}
|
|
1430
|
+
function buildAccessors(obj, header) {
|
|
1431
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1515
1432
|
|
|
1516
|
-
|
|
1433
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
1434
|
+
Object.defineProperty(obj, methodName + accessorName, {
|
|
1435
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1436
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1437
|
+
__proto__: null,
|
|
1438
|
+
value: function (arg1, arg2, arg3) {
|
|
1439
|
+
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1440
|
+
},
|
|
1441
|
+
configurable: true,
|
|
1442
|
+
});
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1517
1445
|
|
|
1518
|
-
|
|
1446
|
+
let AxiosHeaders$1 = class AxiosHeaders {
|
|
1447
|
+
constructor(headers) {
|
|
1448
|
+
headers && this.set(headers);
|
|
1519
1449
|
}
|
|
1520
1450
|
|
|
1521
|
-
|
|
1451
|
+
set(header, valueOrRewrite, rewrite) {
|
|
1452
|
+
const self = this;
|
|
1522
1453
|
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
convertValue,
|
|
1526
|
-
isVisitable,
|
|
1527
|
-
});
|
|
1454
|
+
function setHeader(_value, _header, _rewrite) {
|
|
1455
|
+
const lHeader = normalizeHeader(_header);
|
|
1528
1456
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1457
|
+
if (!lHeader) {
|
|
1458
|
+
throw new Error('header name must be a non-empty string');
|
|
1459
|
+
}
|
|
1531
1460
|
|
|
1532
|
-
|
|
1533
|
-
throw new AxiosError$1(
|
|
1534
|
-
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1535
|
-
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1536
|
-
);
|
|
1537
|
-
}
|
|
1461
|
+
const key = utils$1.findKey(self, lHeader);
|
|
1538
1462
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1463
|
+
if (
|
|
1464
|
+
!key ||
|
|
1465
|
+
self[key] === undefined ||
|
|
1466
|
+
_rewrite === true ||
|
|
1467
|
+
(_rewrite === undefined && self[key] !== false)
|
|
1468
|
+
) {
|
|
1469
|
+
self[key || _header] = normalizeValue(_value);
|
|
1470
|
+
}
|
|
1541
1471
|
}
|
|
1542
1472
|
|
|
1543
|
-
|
|
1473
|
+
const setHeaders = (headers, _rewrite) =>
|
|
1474
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1544
1475
|
|
|
1545
|
-
utils$1.
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1476
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1477
|
+
setHeaders(header, valueOrRewrite);
|
|
1478
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1479
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1480
|
+
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1481
|
+
let obj = {},
|
|
1482
|
+
dest,
|
|
1483
|
+
key;
|
|
1484
|
+
for (const entry of header) {
|
|
1485
|
+
if (!utils$1.isArray(entry)) {
|
|
1486
|
+
throw TypeError('Object iterator must return a key-value pair');
|
|
1487
|
+
}
|
|
1549
1488
|
|
|
1550
|
-
|
|
1551
|
-
|
|
1489
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
1490
|
+
? utils$1.isArray(dest)
|
|
1491
|
+
? [...dest, entry[1]]
|
|
1492
|
+
: [dest, entry[1]]
|
|
1493
|
+
: entry[1];
|
|
1552
1494
|
}
|
|
1553
|
-
});
|
|
1554
1495
|
|
|
1555
|
-
|
|
1556
|
-
|
|
1496
|
+
setHeaders(obj, valueOrRewrite);
|
|
1497
|
+
} else {
|
|
1498
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1499
|
+
}
|
|
1557
1500
|
|
|
1558
|
-
|
|
1559
|
-
throw new TypeError('data must be an object');
|
|
1501
|
+
return this;
|
|
1560
1502
|
}
|
|
1561
1503
|
|
|
1562
|
-
|
|
1504
|
+
get(header, parser) {
|
|
1505
|
+
header = normalizeHeader(header);
|
|
1563
1506
|
|
|
1564
|
-
|
|
1565
|
-
|
|
1507
|
+
if (header) {
|
|
1508
|
+
const key = utils$1.findKey(this, header);
|
|
1566
1509
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
* their percent-encoded equivalents
|
|
1570
|
-
*
|
|
1571
|
-
* @param {string} str - The string to encode.
|
|
1572
|
-
*
|
|
1573
|
-
* @returns {string} The encoded string.
|
|
1574
|
-
*/
|
|
1575
|
-
function encode$1(str) {
|
|
1576
|
-
const charMap = {
|
|
1577
|
-
'!': '%21',
|
|
1578
|
-
"'": '%27',
|
|
1579
|
-
'(': '%28',
|
|
1580
|
-
')': '%29',
|
|
1581
|
-
'~': '%7E',
|
|
1582
|
-
'%20': '+',
|
|
1583
|
-
};
|
|
1584
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1585
|
-
return charMap[match];
|
|
1586
|
-
});
|
|
1587
|
-
}
|
|
1510
|
+
if (key) {
|
|
1511
|
+
const value = this[key];
|
|
1588
1512
|
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
1593
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
1594
|
-
*
|
|
1595
|
-
* @returns {void}
|
|
1596
|
-
*/
|
|
1597
|
-
function AxiosURLSearchParams(params, options) {
|
|
1598
|
-
this._pairs = [];
|
|
1513
|
+
if (!parser) {
|
|
1514
|
+
return value;
|
|
1515
|
+
}
|
|
1599
1516
|
|
|
1600
|
-
|
|
1601
|
-
|
|
1517
|
+
if (parser === true) {
|
|
1518
|
+
return parseTokens(value);
|
|
1519
|
+
}
|
|
1602
1520
|
|
|
1603
|
-
|
|
1521
|
+
if (utils$1.isFunction(parser)) {
|
|
1522
|
+
return parser.call(this, value, key);
|
|
1523
|
+
}
|
|
1604
1524
|
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
}
|
|
1525
|
+
if (utils$1.isRegExp(parser)) {
|
|
1526
|
+
return parser.exec(value);
|
|
1527
|
+
}
|
|
1608
1528
|
|
|
1609
|
-
|
|
1610
|
-
const _encode = encoder
|
|
1611
|
-
? function (value) {
|
|
1612
|
-
return encoder.call(this, value, encode$1);
|
|
1529
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
|
1613
1530
|
}
|
|
1614
|
-
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1615
1533
|
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1619
|
-
}, '')
|
|
1620
|
-
.join('&');
|
|
1621
|
-
};
|
|
1534
|
+
has(header, matcher) {
|
|
1535
|
+
header = normalizeHeader(header);
|
|
1622
1536
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1626
|
-
*
|
|
1627
|
-
* @param {string} val The value to be encoded.
|
|
1628
|
-
*
|
|
1629
|
-
* @returns {string} The encoded value.
|
|
1630
|
-
*/
|
|
1631
|
-
function encode(val) {
|
|
1632
|
-
return encodeURIComponent(val)
|
|
1633
|
-
.replace(/%3A/gi, ':')
|
|
1634
|
-
.replace(/%24/g, '$')
|
|
1635
|
-
.replace(/%2C/gi, ',')
|
|
1636
|
-
.replace(/%20/g, '+');
|
|
1637
|
-
}
|
|
1537
|
+
if (header) {
|
|
1538
|
+
const key = utils$1.findKey(this, header);
|
|
1638
1539
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
*/
|
|
1648
|
-
function buildURL(url, params, options) {
|
|
1649
|
-
if (!params) {
|
|
1650
|
-
return url;
|
|
1540
|
+
return !!(
|
|
1541
|
+
key &&
|
|
1542
|
+
this[key] !== undefined &&
|
|
1543
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
return false;
|
|
1651
1548
|
}
|
|
1652
1549
|
|
|
1653
|
-
|
|
1550
|
+
delete(header, matcher) {
|
|
1551
|
+
const self = this;
|
|
1552
|
+
let deleted = false;
|
|
1654
1553
|
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
serialize: options,
|
|
1658
|
-
}
|
|
1659
|
-
: options;
|
|
1554
|
+
function deleteHeader(_header) {
|
|
1555
|
+
_header = normalizeHeader(_header);
|
|
1660
1556
|
|
|
1661
|
-
|
|
1557
|
+
if (_header) {
|
|
1558
|
+
const key = utils$1.findKey(self, _header);
|
|
1662
1559
|
|
|
1663
|
-
|
|
1560
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1561
|
+
delete self[key];
|
|
1664
1562
|
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1563
|
+
deleted = true;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
if (utils$1.isArray(header)) {
|
|
1569
|
+
header.forEach(deleteHeader);
|
|
1570
|
+
} else {
|
|
1571
|
+
deleteHeader(header);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
return deleted;
|
|
1671
1575
|
}
|
|
1672
1576
|
|
|
1673
|
-
|
|
1674
|
-
const
|
|
1577
|
+
clear(matcher) {
|
|
1578
|
+
const keys = Object.keys(this);
|
|
1579
|
+
let i = keys.length;
|
|
1580
|
+
let deleted = false;
|
|
1675
1581
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1582
|
+
while (i--) {
|
|
1583
|
+
const key = keys[i];
|
|
1584
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
1585
|
+
delete this[key];
|
|
1586
|
+
deleted = true;
|
|
1587
|
+
}
|
|
1678
1588
|
}
|
|
1679
|
-
|
|
1589
|
+
|
|
1590
|
+
return deleted;
|
|
1680
1591
|
}
|
|
1681
1592
|
|
|
1682
|
-
|
|
1683
|
-
|
|
1593
|
+
normalize(format) {
|
|
1594
|
+
const self = this;
|
|
1595
|
+
const headers = {};
|
|
1684
1596
|
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1597
|
+
utils$1.forEach(this, (value, header) => {
|
|
1598
|
+
const key = utils$1.findKey(headers, header);
|
|
1599
|
+
|
|
1600
|
+
if (key) {
|
|
1601
|
+
self[key] = normalizeValue(value);
|
|
1602
|
+
delete self[header];
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
1607
|
+
|
|
1608
|
+
if (normalized !== header) {
|
|
1609
|
+
delete self[header];
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
self[normalized] = normalizeValue(value);
|
|
1613
|
+
|
|
1614
|
+
headers[normalized] = true;
|
|
1615
|
+
});
|
|
1616
|
+
|
|
1617
|
+
return this;
|
|
1688
1618
|
}
|
|
1689
1619
|
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
fulfilled,
|
|
1702
|
-
rejected,
|
|
1703
|
-
synchronous: options ? options.synchronous : false,
|
|
1704
|
-
runWhen: options ? options.runWhen : null,
|
|
1620
|
+
concat(...targets) {
|
|
1621
|
+
return this.constructor.concat(this, ...targets);
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
toJSON(asStrings) {
|
|
1625
|
+
const obj = Object.create(null);
|
|
1626
|
+
|
|
1627
|
+
utils$1.forEach(this, (value, header) => {
|
|
1628
|
+
value != null &&
|
|
1629
|
+
value !== false &&
|
|
1630
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
1705
1631
|
});
|
|
1706
|
-
|
|
1632
|
+
|
|
1633
|
+
return obj;
|
|
1707
1634
|
}
|
|
1708
1635
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
*
|
|
1712
|
-
* @param {Number} id The ID that was returned by `use`
|
|
1713
|
-
*
|
|
1714
|
-
* @returns {void}
|
|
1715
|
-
*/
|
|
1716
|
-
eject(id) {
|
|
1717
|
-
if (this.handlers[id]) {
|
|
1718
|
-
this.handlers[id] = null;
|
|
1719
|
-
}
|
|
1636
|
+
[Symbol.iterator]() {
|
|
1637
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
1720
1638
|
}
|
|
1721
1639
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
*/
|
|
1727
|
-
clear() {
|
|
1728
|
-
if (this.handlers) {
|
|
1729
|
-
this.handlers = [];
|
|
1730
|
-
}
|
|
1640
|
+
toString() {
|
|
1641
|
+
return Object.entries(this.toJSON())
|
|
1642
|
+
.map(([header, value]) => header + ': ' + value)
|
|
1643
|
+
.join('\n');
|
|
1731
1644
|
}
|
|
1732
1645
|
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
*
|
|
1736
|
-
* This method is particularly useful for skipping over any
|
|
1737
|
-
* interceptors that may have become `null` calling `eject`.
|
|
1738
|
-
*
|
|
1739
|
-
* @param {Function} fn The function to call for each interceptor
|
|
1740
|
-
*
|
|
1741
|
-
* @returns {void}
|
|
1742
|
-
*/
|
|
1743
|
-
forEach(fn) {
|
|
1744
|
-
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
1745
|
-
if (h !== null) {
|
|
1746
|
-
fn(h);
|
|
1747
|
-
}
|
|
1748
|
-
});
|
|
1646
|
+
getSetCookie() {
|
|
1647
|
+
return this.get('set-cookie') || [];
|
|
1749
1648
|
}
|
|
1750
|
-
}
|
|
1751
1649
|
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
clarifyTimeoutError: false,
|
|
1756
|
-
legacyInterceptorReqResOrdering: true,
|
|
1757
|
-
};
|
|
1650
|
+
get [Symbol.toStringTag]() {
|
|
1651
|
+
return 'AxiosHeaders';
|
|
1652
|
+
}
|
|
1758
1653
|
|
|
1759
|
-
|
|
1654
|
+
static from(thing) {
|
|
1655
|
+
return thing instanceof this ? thing : new this(thing);
|
|
1656
|
+
}
|
|
1760
1657
|
|
|
1761
|
-
|
|
1658
|
+
static concat(first, ...targets) {
|
|
1659
|
+
const computed = new this(first);
|
|
1762
1660
|
|
|
1763
|
-
|
|
1661
|
+
targets.forEach((target) => computed.set(target));
|
|
1764
1662
|
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
classes: {
|
|
1768
|
-
URLSearchParams: URLSearchParams$1,
|
|
1769
|
-
FormData: FormData$1,
|
|
1770
|
-
Blob: Blob$1,
|
|
1771
|
-
},
|
|
1772
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
1773
|
-
};
|
|
1663
|
+
return computed;
|
|
1664
|
+
}
|
|
1774
1665
|
|
|
1775
|
-
|
|
1666
|
+
static accessor(header) {
|
|
1667
|
+
const internals =
|
|
1668
|
+
(this[$internals] =
|
|
1669
|
+
this[$internals] =
|
|
1670
|
+
{
|
|
1671
|
+
accessors: {},
|
|
1672
|
+
});
|
|
1776
1673
|
|
|
1777
|
-
const
|
|
1674
|
+
const accessors = internals.accessors;
|
|
1675
|
+
const prototype = this.prototype;
|
|
1778
1676
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
*
|
|
1782
|
-
* This allows axios to run in a web worker, and react-native.
|
|
1783
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
1784
|
-
*
|
|
1785
|
-
* web workers:
|
|
1786
|
-
* typeof window -> undefined
|
|
1787
|
-
* typeof document -> undefined
|
|
1788
|
-
*
|
|
1789
|
-
* react-native:
|
|
1790
|
-
* navigator.product -> 'ReactNative'
|
|
1791
|
-
* nativescript
|
|
1792
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
1793
|
-
*
|
|
1794
|
-
* @returns {boolean}
|
|
1795
|
-
*/
|
|
1796
|
-
const hasStandardBrowserEnv =
|
|
1797
|
-
hasBrowserEnv &&
|
|
1798
|
-
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1799
|
-
|
|
1800
|
-
/**
|
|
1801
|
-
* Determine if we're running in a standard browser webWorker environment
|
|
1802
|
-
*
|
|
1803
|
-
* Although the `isStandardBrowserEnv` method indicates that
|
|
1804
|
-
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
1805
|
-
* filtered out due to its judgment standard
|
|
1806
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
1807
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
1808
|
-
*/
|
|
1809
|
-
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
1810
|
-
return (
|
|
1811
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
|
1812
|
-
// eslint-disable-next-line no-undef
|
|
1813
|
-
self instanceof WorkerGlobalScope &&
|
|
1814
|
-
typeof self.importScripts === 'function'
|
|
1815
|
-
);
|
|
1816
|
-
})();
|
|
1677
|
+
function defineAccessor(_header) {
|
|
1678
|
+
const lHeader = normalizeHeader(_header);
|
|
1817
1679
|
|
|
1818
|
-
|
|
1680
|
+
if (!accessors[lHeader]) {
|
|
1681
|
+
buildAccessors(prototype, _header);
|
|
1682
|
+
accessors[lHeader] = true;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1819
1685
|
|
|
1820
|
-
|
|
1821
|
-
__proto__: null,
|
|
1822
|
-
hasBrowserEnv: hasBrowserEnv,
|
|
1823
|
-
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
1824
|
-
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
1825
|
-
navigator: _navigator,
|
|
1826
|
-
origin: origin
|
|
1827
|
-
});
|
|
1686
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1828
1687
|
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
...platform$1,
|
|
1688
|
+
return this;
|
|
1689
|
+
}
|
|
1832
1690
|
};
|
|
1833
1691
|
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1692
|
+
AxiosHeaders$1.accessor([
|
|
1693
|
+
'Content-Type',
|
|
1694
|
+
'Content-Length',
|
|
1695
|
+
'Accept',
|
|
1696
|
+
'Accept-Encoding',
|
|
1697
|
+
'User-Agent',
|
|
1698
|
+
'Authorization',
|
|
1699
|
+
]);
|
|
1841
1700
|
|
|
1842
|
-
|
|
1701
|
+
// reserved names hotfix
|
|
1702
|
+
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
1703
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
1704
|
+
return {
|
|
1705
|
+
get: () => value,
|
|
1706
|
+
set(headerValue) {
|
|
1707
|
+
this[mapped] = headerValue;
|
|
1843
1708
|
},
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
}
|
|
1709
|
+
};
|
|
1710
|
+
});
|
|
1847
1711
|
|
|
1848
|
-
|
|
1849
|
-
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
1850
|
-
*
|
|
1851
|
-
* @param {string} name - The name of the property to get.
|
|
1852
|
-
*
|
|
1853
|
-
* @returns An array of strings.
|
|
1854
|
-
*/
|
|
1855
|
-
function parsePropPath(name) {
|
|
1856
|
-
// foo[x][y][z]
|
|
1857
|
-
// foo.x.y.z
|
|
1858
|
-
// foo-x-y-z
|
|
1859
|
-
// foo x y z
|
|
1860
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
1861
|
-
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1862
|
-
});
|
|
1863
|
-
}
|
|
1712
|
+
utils$1.freezeMethods(AxiosHeaders$1);
|
|
1864
1713
|
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
* @returns An object with the same keys and values as the array.
|
|
1871
|
-
*/
|
|
1872
|
-
function arrayToObject(arr) {
|
|
1873
|
-
const obj = {};
|
|
1874
|
-
const keys = Object.keys(arr);
|
|
1875
|
-
let i;
|
|
1876
|
-
const len = keys.length;
|
|
1877
|
-
let key;
|
|
1878
|
-
for (i = 0; i < len; i++) {
|
|
1879
|
-
key = keys[i];
|
|
1880
|
-
obj[key] = arr[key];
|
|
1714
|
+
const REDACTED = '[REDACTED ****]';
|
|
1715
|
+
|
|
1716
|
+
function hasOwnOrPrototypeToJSON(source) {
|
|
1717
|
+
if (utils$1.hasOwnProp(source, 'toJSON')) {
|
|
1718
|
+
return true;
|
|
1881
1719
|
}
|
|
1882
|
-
|
|
1720
|
+
|
|
1721
|
+
let prototype = Object.getPrototypeOf(source);
|
|
1722
|
+
|
|
1723
|
+
while (prototype && prototype !== Object.prototype) {
|
|
1724
|
+
if (utils$1.hasOwnProp(prototype, 'toJSON')) {
|
|
1725
|
+
return true;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
return false;
|
|
1883
1732
|
}
|
|
1884
1733
|
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
*/
|
|
1892
|
-
function formDataToJSON(formData) {
|
|
1893
|
-
function buildPath(path, value, target, index) {
|
|
1894
|
-
let name = path[index++];
|
|
1734
|
+
// Build a plain-object snapshot of `config` and replace the value of any key
|
|
1735
|
+
// (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|
1736
|
+
// and AxiosHeaders, and short-circuits on circular references.
|
|
1737
|
+
function redactConfig(config, redactKeys) {
|
|
1738
|
+
const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
|
|
1739
|
+
const seen = [];
|
|
1895
1740
|
|
|
1896
|
-
|
|
1741
|
+
const visit = (source) => {
|
|
1742
|
+
if (source === null || typeof source !== 'object') return source;
|
|
1743
|
+
if (utils$1.isBuffer(source)) return source;
|
|
1744
|
+
if (seen.indexOf(source) !== -1) return undefined;
|
|
1897
1745
|
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1746
|
+
if (source instanceof AxiosHeaders$1) {
|
|
1747
|
+
source = source.toJSON();
|
|
1748
|
+
}
|
|
1901
1749
|
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1750
|
+
seen.push(source);
|
|
1751
|
+
|
|
1752
|
+
let result;
|
|
1753
|
+
if (utils$1.isArray(source)) {
|
|
1754
|
+
result = [];
|
|
1755
|
+
source.forEach((v, i) => {
|
|
1756
|
+
const reducedValue = visit(v);
|
|
1757
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1758
|
+
result[i] = reducedValue;
|
|
1759
|
+
}
|
|
1760
|
+
});
|
|
1761
|
+
} else {
|
|
1762
|
+
if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|
1763
|
+
seen.pop();
|
|
1764
|
+
return source;
|
|
1909
1765
|
}
|
|
1910
1766
|
|
|
1911
|
-
|
|
1767
|
+
result = Object.create(null);
|
|
1768
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1769
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
|
|
1770
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1771
|
+
result[key] = reducedValue;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1912
1774
|
}
|
|
1913
1775
|
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1776
|
+
seen.pop();
|
|
1777
|
+
return result;
|
|
1778
|
+
};
|
|
1917
1779
|
|
|
1918
|
-
|
|
1780
|
+
return visit(config);
|
|
1781
|
+
}
|
|
1919
1782
|
|
|
1920
|
-
|
|
1921
|
-
|
|
1783
|
+
let AxiosError$1 = class AxiosError extends Error {
|
|
1784
|
+
static from(error, code, config, request, response, customProps) {
|
|
1785
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1786
|
+
axiosError.cause = error;
|
|
1787
|
+
axiosError.name = error.name;
|
|
1788
|
+
|
|
1789
|
+
// Preserve status from the original error if not already set from response
|
|
1790
|
+
if (error.status != null && axiosError.status == null) {
|
|
1791
|
+
axiosError.status = error.status;
|
|
1922
1792
|
}
|
|
1923
1793
|
|
|
1924
|
-
|
|
1794
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1795
|
+
return axiosError;
|
|
1925
1796
|
}
|
|
1926
1797
|
|
|
1927
|
-
|
|
1928
|
-
|
|
1798
|
+
/**
|
|
1799
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1800
|
+
*
|
|
1801
|
+
* @param {string} message The error message.
|
|
1802
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1803
|
+
* @param {Object} [config] The config.
|
|
1804
|
+
* @param {Object} [request] The request.
|
|
1805
|
+
* @param {Object} [response] The response.
|
|
1806
|
+
*
|
|
1807
|
+
* @returns {Error} The created error.
|
|
1808
|
+
*/
|
|
1809
|
+
constructor(message, code, config, request, response) {
|
|
1810
|
+
super(message);
|
|
1929
1811
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1812
|
+
// Make message enumerable to maintain backward compatibility
|
|
1813
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1814
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1815
|
+
Object.defineProperty(this, 'message', {
|
|
1816
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1817
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1818
|
+
__proto__: null,
|
|
1819
|
+
value: message,
|
|
1820
|
+
enumerable: true,
|
|
1821
|
+
writable: true,
|
|
1822
|
+
configurable: true,
|
|
1932
1823
|
});
|
|
1933
1824
|
|
|
1934
|
-
|
|
1825
|
+
this.name = 'AxiosError';
|
|
1826
|
+
this.isAxiosError = true;
|
|
1827
|
+
code && (this.code = code);
|
|
1828
|
+
config && (this.config = config);
|
|
1829
|
+
request && (this.request = request);
|
|
1830
|
+
if (response) {
|
|
1831
|
+
this.response = response;
|
|
1832
|
+
this.status = response.status;
|
|
1833
|
+
}
|
|
1935
1834
|
}
|
|
1936
1835
|
|
|
1937
|
-
|
|
1938
|
-
|
|
1836
|
+
toJSON() {
|
|
1837
|
+
// Opt-in redaction: when the request config carries a `redact` array, the
|
|
1838
|
+
// value of any matching key (case-insensitive, at any depth) is replaced
|
|
1839
|
+
// with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|
1840
|
+
// existing serialization behavior unchanged.
|
|
1841
|
+
const config = this.config;
|
|
1842
|
+
const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|
1843
|
+
const serializedConfig =
|
|
1844
|
+
utils$1.isArray(redactKeys) && redactKeys.length > 0
|
|
1845
|
+
? redactConfig(config, redactKeys)
|
|
1846
|
+
: utils$1.toJSONObject(config);
|
|
1939
1847
|
|
|
1940
|
-
|
|
1848
|
+
return {
|
|
1849
|
+
// Standard
|
|
1850
|
+
message: this.message,
|
|
1851
|
+
name: this.name,
|
|
1852
|
+
// Microsoft
|
|
1853
|
+
description: this.description,
|
|
1854
|
+
number: this.number,
|
|
1855
|
+
// Mozilla
|
|
1856
|
+
fileName: this.fileName,
|
|
1857
|
+
lineNumber: this.lineNumber,
|
|
1858
|
+
columnNumber: this.columnNumber,
|
|
1859
|
+
stack: this.stack,
|
|
1860
|
+
// Axios
|
|
1861
|
+
config: serializedConfig,
|
|
1862
|
+
code: this.code,
|
|
1863
|
+
status: this.status,
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
|
|
1868
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
1869
|
+
AxiosError$1.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
1870
|
+
AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1871
|
+
AxiosError$1.ECONNABORTED = 'ECONNABORTED';
|
|
1872
|
+
AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';
|
|
1873
|
+
AxiosError$1.ECONNREFUSED = 'ECONNREFUSED';
|
|
1874
|
+
AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';
|
|
1875
|
+
AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1876
|
+
AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1877
|
+
AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1878
|
+
AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1879
|
+
AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
|
|
1880
|
+
AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1881
|
+
AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1882
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1883
|
+
|
|
1884
|
+
// eslint-disable-next-line strict
|
|
1885
|
+
var httpAdapter = null;
|
|
1941
1886
|
|
|
1942
1887
|
/**
|
|
1943
|
-
*
|
|
1944
|
-
* of the input
|
|
1888
|
+
* Determines if the given thing is a array or js object.
|
|
1945
1889
|
*
|
|
1946
|
-
* @param {
|
|
1947
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
1948
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
1890
|
+
* @param {string} thing - The object or array to be visited.
|
|
1949
1891
|
*
|
|
1950
|
-
* @returns {
|
|
1892
|
+
* @returns {boolean}
|
|
1951
1893
|
*/
|
|
1952
|
-
function
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
(parser || JSON.parse)(rawValue);
|
|
1956
|
-
return utils$1.trim(rawValue);
|
|
1957
|
-
} catch (e) {
|
|
1958
|
-
if (e.name !== 'SyntaxError') {
|
|
1959
|
-
throw e;
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1894
|
+
function isVisitable(thing) {
|
|
1895
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1896
|
+
}
|
|
1963
1897
|
|
|
1964
|
-
|
|
1898
|
+
/**
|
|
1899
|
+
* It removes the brackets from the end of a string
|
|
1900
|
+
*
|
|
1901
|
+
* @param {string} key - The key of the parameter.
|
|
1902
|
+
*
|
|
1903
|
+
* @returns {string} the key without the brackets.
|
|
1904
|
+
*/
|
|
1905
|
+
function removeBrackets(key) {
|
|
1906
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1965
1907
|
}
|
|
1966
1908
|
|
|
1967
|
-
|
|
1968
|
-
|
|
1909
|
+
/**
|
|
1910
|
+
* It takes a path, a key, and a boolean, and returns a string
|
|
1911
|
+
*
|
|
1912
|
+
* @param {string} path - The path to the current key.
|
|
1913
|
+
* @param {string} key - The key of the current object being iterated over.
|
|
1914
|
+
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
1915
|
+
*
|
|
1916
|
+
* @returns {string} The path to the current key.
|
|
1917
|
+
*/
|
|
1918
|
+
function renderKey(path, key, dots) {
|
|
1919
|
+
if (!path) return key;
|
|
1920
|
+
return path
|
|
1921
|
+
.concat(key)
|
|
1922
|
+
.map(function each(token, i) {
|
|
1923
|
+
// eslint-disable-next-line no-param-reassign
|
|
1924
|
+
token = removeBrackets(token);
|
|
1925
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1926
|
+
})
|
|
1927
|
+
.join(dots ? '.' : '');
|
|
1928
|
+
}
|
|
1969
1929
|
|
|
1970
|
-
|
|
1930
|
+
/**
|
|
1931
|
+
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
1932
|
+
*
|
|
1933
|
+
* @param {Array<any>} arr - The array to check
|
|
1934
|
+
*
|
|
1935
|
+
* @returns {boolean}
|
|
1936
|
+
*/
|
|
1937
|
+
function isFlatArray(arr) {
|
|
1938
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
1939
|
+
}
|
|
1971
1940
|
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1976
|
-
const isObjectPayload = utils$1.isObject(data);
|
|
1941
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
1942
|
+
return /^is[A-Z]/.test(prop);
|
|
1943
|
+
});
|
|
1977
1944
|
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1945
|
+
/**
|
|
1946
|
+
* Convert a data object to FormData
|
|
1947
|
+
*
|
|
1948
|
+
* @param {Object} obj
|
|
1949
|
+
* @param {?Object} [formData]
|
|
1950
|
+
* @param {?Object} [options]
|
|
1951
|
+
* @param {Function} [options.visitor]
|
|
1952
|
+
* @param {Boolean} [options.metaTokens = true]
|
|
1953
|
+
* @param {Boolean} [options.dots = false]
|
|
1954
|
+
* @param {?Boolean} [options.indexes = false]
|
|
1955
|
+
*
|
|
1956
|
+
* @returns {Object}
|
|
1957
|
+
**/
|
|
1981
1958
|
|
|
1982
|
-
|
|
1959
|
+
/**
|
|
1960
|
+
* It converts an object into a FormData object
|
|
1961
|
+
*
|
|
1962
|
+
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
1963
|
+
* @param {string} formData - The FormData object to append to.
|
|
1964
|
+
* @param {Object<string, any>} options
|
|
1965
|
+
*
|
|
1966
|
+
* @returns
|
|
1967
|
+
*/
|
|
1968
|
+
function toFormData$1(obj, formData, options) {
|
|
1969
|
+
if (!utils$1.isObject(obj)) {
|
|
1970
|
+
throw new TypeError('target must be an object');
|
|
1971
|
+
}
|
|
1983
1972
|
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
}
|
|
1973
|
+
// eslint-disable-next-line no-param-reassign
|
|
1974
|
+
formData = formData || new (FormData)();
|
|
1987
1975
|
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
2003
|
-
return data.toString();
|
|
2004
|
-
}
|
|
1976
|
+
// eslint-disable-next-line no-param-reassign
|
|
1977
|
+
options = utils$1.toFlatObject(
|
|
1978
|
+
options,
|
|
1979
|
+
{
|
|
1980
|
+
metaTokens: true,
|
|
1981
|
+
dots: false,
|
|
1982
|
+
indexes: false,
|
|
1983
|
+
},
|
|
1984
|
+
false,
|
|
1985
|
+
function defined(option, source) {
|
|
1986
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1987
|
+
return !utils$1.isUndefined(source[option]);
|
|
1988
|
+
}
|
|
1989
|
+
);
|
|
2005
1990
|
|
|
2006
|
-
|
|
1991
|
+
const metaTokens = options.metaTokens;
|
|
1992
|
+
// eslint-disable-next-line no-use-before-define
|
|
1993
|
+
const visitor = options.visitor || defaultVisitor;
|
|
1994
|
+
const dots = options.dots;
|
|
1995
|
+
const indexes = options.indexes;
|
|
1996
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1997
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1998
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
2007
1999
|
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
return toURLEncodedForm(data, formSerializer).toString();
|
|
2012
|
-
}
|
|
2000
|
+
if (!utils$1.isFunction(visitor)) {
|
|
2001
|
+
throw new TypeError('visitor must be a function');
|
|
2002
|
+
}
|
|
2013
2003
|
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
contentType.indexOf('multipart/form-data') > -1
|
|
2017
|
-
) {
|
|
2018
|
-
const env = own(this, 'env');
|
|
2019
|
-
const _FormData = env && env.FormData;
|
|
2004
|
+
function convertValue(value) {
|
|
2005
|
+
if (value === null) return '';
|
|
2020
2006
|
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
formSerializer
|
|
2025
|
-
);
|
|
2026
|
-
}
|
|
2027
|
-
}
|
|
2007
|
+
if (utils$1.isDate(value)) {
|
|
2008
|
+
return value.toISOString();
|
|
2009
|
+
}
|
|
2028
2010
|
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
}
|
|
2011
|
+
if (utils$1.isBoolean(value)) {
|
|
2012
|
+
return value.toString();
|
|
2013
|
+
}
|
|
2033
2014
|
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2015
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
2016
|
+
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
2017
|
+
}
|
|
2037
2018
|
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
2042
|
-
const responseType = own(this, 'responseType');
|
|
2043
|
-
const JSONRequested = responseType === 'json';
|
|
2019
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
2020
|
+
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
2021
|
+
}
|
|
2044
2022
|
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
}
|
|
2023
|
+
return value;
|
|
2024
|
+
}
|
|
2048
2025
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2026
|
+
/**
|
|
2027
|
+
* Default visitor.
|
|
2028
|
+
*
|
|
2029
|
+
* @param {*} value
|
|
2030
|
+
* @param {String|Number} key
|
|
2031
|
+
* @param {Array<String|Number>} path
|
|
2032
|
+
* @this {FormData}
|
|
2033
|
+
*
|
|
2034
|
+
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
2035
|
+
*/
|
|
2036
|
+
function defaultVisitor(value, key, path) {
|
|
2037
|
+
let arr = value;
|
|
2038
|
+
|
|
2039
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
2040
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
2041
|
+
return false;
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
if (value && !path && typeof value === 'object') {
|
|
2045
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
2046
|
+
// eslint-disable-next-line no-param-reassign
|
|
2047
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
2048
|
+
// eslint-disable-next-line no-param-reassign
|
|
2049
|
+
value = JSON.stringify(value);
|
|
2050
|
+
} else if (
|
|
2051
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
2052
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
2053
2053
|
) {
|
|
2054
|
-
|
|
2055
|
-
|
|
2054
|
+
// eslint-disable-next-line no-param-reassign
|
|
2055
|
+
key = removeBrackets(key);
|
|
2056
2056
|
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2057
|
+
arr.forEach(function each(el, index) {
|
|
2058
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
2059
|
+
formData.append(
|
|
2060
|
+
// eslint-disable-next-line no-nested-ternary
|
|
2061
|
+
indexes === true
|
|
2062
|
+
? renderKey([key], index, dots)
|
|
2063
|
+
: indexes === null
|
|
2064
|
+
? key
|
|
2065
|
+
: key + '[]',
|
|
2066
|
+
convertValue(el)
|
|
2067
|
+
);
|
|
2068
|
+
});
|
|
2069
|
+
return false;
|
|
2067
2070
|
}
|
|
2071
|
+
}
|
|
2068
2072
|
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2073
|
+
if (isVisitable(value)) {
|
|
2074
|
+
return true;
|
|
2075
|
+
}
|
|
2072
2076
|
|
|
2073
|
-
|
|
2074
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
2075
|
-
* timeout is not created.
|
|
2076
|
-
*/
|
|
2077
|
-
timeout: 0,
|
|
2077
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
2078
2078
|
|
|
2079
|
-
|
|
2080
|
-
|
|
2079
|
+
return false;
|
|
2080
|
+
}
|
|
2081
2081
|
|
|
2082
|
-
|
|
2083
|
-
maxBodyLength: -1,
|
|
2082
|
+
const stack = [];
|
|
2084
2083
|
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2084
|
+
const exposedHelpers = Object.assign(predicates, {
|
|
2085
|
+
defaultVisitor,
|
|
2086
|
+
convertValue,
|
|
2087
|
+
isVisitable,
|
|
2088
|
+
});
|
|
2089
2089
|
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
},
|
|
2090
|
+
function build(value, path, depth = 0) {
|
|
2091
|
+
if (utils$1.isUndefined(value)) return;
|
|
2093
2092
|
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
};
|
|
2093
|
+
if (depth > maxDepth) {
|
|
2094
|
+
throw new AxiosError$1(
|
|
2095
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
2096
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2097
|
+
);
|
|
2098
|
+
}
|
|
2101
2099
|
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
}
|
|
2100
|
+
if (stack.indexOf(value) !== -1) {
|
|
2101
|
+
throw Error('Circular reference detected in ' + path.join('.'));
|
|
2102
|
+
}
|
|
2105
2103
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2104
|
+
stack.push(value);
|
|
2105
|
+
|
|
2106
|
+
utils$1.forEach(value, function each(el, key) {
|
|
2107
|
+
const result =
|
|
2108
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
2109
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
2110
|
+
|
|
2111
|
+
if (result === true) {
|
|
2112
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
2113
|
+
}
|
|
2114
|
+
});
|
|
2115
|
+
|
|
2116
|
+
stack.pop();
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
if (!utils$1.isObject(obj)) {
|
|
2120
|
+
throw new TypeError('data must be an object');
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
build(obj);
|
|
2124
|
+
|
|
2125
|
+
return formData;
|
|
2126
|
+
}
|
|
2127
2127
|
|
|
2128
2128
|
/**
|
|
2129
|
-
*
|
|
2130
|
-
*
|
|
2131
|
-
* ```
|
|
2132
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
2133
|
-
* Content-Type: application/json
|
|
2134
|
-
* Connection: keep-alive
|
|
2135
|
-
* Transfer-Encoding: chunked
|
|
2136
|
-
* ```
|
|
2129
|
+
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
2130
|
+
* their percent-encoded equivalents
|
|
2137
2131
|
*
|
|
2138
|
-
* @param {
|
|
2132
|
+
* @param {string} str - The string to encode.
|
|
2139
2133
|
*
|
|
2140
|
-
* @returns {
|
|
2134
|
+
* @returns {string} The encoded string.
|
|
2141
2135
|
*/
|
|
2142
|
-
|
|
2143
|
-
const
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2136
|
+
function encode$1(str) {
|
|
2137
|
+
const charMap = {
|
|
2138
|
+
'!': '%21',
|
|
2139
|
+
"'": '%27',
|
|
2140
|
+
'(': '%28',
|
|
2141
|
+
')': '%29',
|
|
2142
|
+
'~': '%7E',
|
|
2143
|
+
'%20': '+',
|
|
2144
|
+
};
|
|
2145
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
2146
|
+
return charMap[match];
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2147
2149
|
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2150
|
+
/**
|
|
2151
|
+
* It takes a params object and converts it to a FormData object
|
|
2152
|
+
*
|
|
2153
|
+
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
2154
|
+
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
2155
|
+
*
|
|
2156
|
+
* @returns {void}
|
|
2157
|
+
*/
|
|
2158
|
+
function AxiosURLSearchParams(params, options) {
|
|
2159
|
+
this._pairs = [];
|
|
2153
2160
|
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
}
|
|
2161
|
+
params && toFormData$1(params, this, options);
|
|
2162
|
+
}
|
|
2157
2163
|
|
|
2158
|
-
|
|
2159
|
-
if (parsed[key]) {
|
|
2160
|
-
parsed[key].push(val);
|
|
2161
|
-
} else {
|
|
2162
|
-
parsed[key] = [val];
|
|
2163
|
-
}
|
|
2164
|
-
} else {
|
|
2165
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
2166
|
-
}
|
|
2167
|
-
});
|
|
2164
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
2168
2165
|
|
|
2169
|
-
|
|
2166
|
+
prototype.append = function append(name, value) {
|
|
2167
|
+
this._pairs.push([name, value]);
|
|
2170
2168
|
};
|
|
2171
2169
|
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
let end = str.length;
|
|
2170
|
+
prototype.toString = function toString(encoder) {
|
|
2171
|
+
const _encode = encoder
|
|
2172
|
+
? function (value) {
|
|
2173
|
+
return encoder.call(this, value, encode$1);
|
|
2174
|
+
}
|
|
2175
|
+
: encode$1;
|
|
2179
2176
|
|
|
2180
|
-
|
|
2181
|
-
|
|
2177
|
+
return this._pairs
|
|
2178
|
+
.map(function each(pair) {
|
|
2179
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
2180
|
+
}, '')
|
|
2181
|
+
.join('&');
|
|
2182
|
+
};
|
|
2182
2183
|
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2184
|
+
/**
|
|
2185
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
2186
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
2187
|
+
*
|
|
2188
|
+
* @param {string} val The value to be encoded.
|
|
2189
|
+
*
|
|
2190
|
+
* @returns {string} The encoded value.
|
|
2191
|
+
*/
|
|
2192
|
+
function encode(val) {
|
|
2193
|
+
return encodeURIComponent(val)
|
|
2194
|
+
.replace(/%3A/gi, ':')
|
|
2195
|
+
.replace(/%24/g, '$')
|
|
2196
|
+
.replace(/%2C/gi, ',')
|
|
2197
|
+
.replace(/%20/g, '+');
|
|
2198
|
+
}
|
|
2186
2199
|
|
|
2187
|
-
|
|
2200
|
+
/**
|
|
2201
|
+
* Build a URL by appending params to the end
|
|
2202
|
+
*
|
|
2203
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
2204
|
+
* @param {object} [params] The params to be appended
|
|
2205
|
+
* @param {?(object|Function)} options
|
|
2206
|
+
*
|
|
2207
|
+
* @returns {string} The formatted url
|
|
2208
|
+
*/
|
|
2209
|
+
function buildURL(url, params, options) {
|
|
2210
|
+
if (!params) {
|
|
2211
|
+
return url;
|
|
2188
2212
|
}
|
|
2189
2213
|
|
|
2190
|
-
|
|
2191
|
-
const code = str.charCodeAt(end - 1);
|
|
2192
|
-
|
|
2193
|
-
if (code !== 0x09 && code !== 0x20) {
|
|
2194
|
-
break;
|
|
2195
|
-
}
|
|
2196
|
-
|
|
2197
|
-
end -= 1;
|
|
2198
|
-
}
|
|
2214
|
+
const _encode = (options && options.encode) || encode;
|
|
2199
2215
|
|
|
2200
|
-
|
|
2201
|
-
|
|
2216
|
+
const _options = utils$1.isFunction(options)
|
|
2217
|
+
? {
|
|
2218
|
+
serialize: options,
|
|
2219
|
+
}
|
|
2220
|
+
: options;
|
|
2202
2221
|
|
|
2203
|
-
|
|
2204
|
-
return header && String(header).trim().toLowerCase();
|
|
2205
|
-
}
|
|
2222
|
+
const serializeFn = _options && _options.serialize;
|
|
2206
2223
|
|
|
2207
|
-
|
|
2208
|
-
return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
|
|
2209
|
-
}
|
|
2224
|
+
let serializedParams;
|
|
2210
2225
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2226
|
+
if (serializeFn) {
|
|
2227
|
+
serializedParams = serializeFn(params, _options);
|
|
2228
|
+
} else {
|
|
2229
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
2230
|
+
? params.toString()
|
|
2231
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
2214
2232
|
}
|
|
2215
2233
|
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
function parseTokens(str) {
|
|
2220
|
-
const tokens = Object.create(null);
|
|
2221
|
-
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
2222
|
-
let match;
|
|
2234
|
+
if (serializedParams) {
|
|
2235
|
+
const hashmarkIndex = url.indexOf('#');
|
|
2223
2236
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2237
|
+
if (hashmarkIndex !== -1) {
|
|
2238
|
+
url = url.slice(0, hashmarkIndex);
|
|
2239
|
+
}
|
|
2240
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
2226
2241
|
}
|
|
2227
2242
|
|
|
2228
|
-
return
|
|
2243
|
+
return url;
|
|
2229
2244
|
}
|
|
2230
2245
|
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
if (utils$1.isFunction(filter)) {
|
|
2235
|
-
return filter.call(this, value, header);
|
|
2246
|
+
class InterceptorManager {
|
|
2247
|
+
constructor() {
|
|
2248
|
+
this.handlers = [];
|
|
2236
2249
|
}
|
|
2237
2250
|
|
|
2238
|
-
|
|
2239
|
-
|
|
2251
|
+
/**
|
|
2252
|
+
* Add a new interceptor to the stack
|
|
2253
|
+
*
|
|
2254
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
2255
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
2256
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
2257
|
+
*
|
|
2258
|
+
* @return {Number} An ID used to remove interceptor later
|
|
2259
|
+
*/
|
|
2260
|
+
use(fulfilled, rejected, options) {
|
|
2261
|
+
this.handlers.push({
|
|
2262
|
+
fulfilled,
|
|
2263
|
+
rejected,
|
|
2264
|
+
synchronous: options ? options.synchronous : false,
|
|
2265
|
+
runWhen: options ? options.runWhen : null,
|
|
2266
|
+
});
|
|
2267
|
+
return this.handlers.length - 1;
|
|
2240
2268
|
}
|
|
2241
2269
|
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2270
|
+
/**
|
|
2271
|
+
* Remove an interceptor from the stack
|
|
2272
|
+
*
|
|
2273
|
+
* @param {Number} id The ID that was returned by `use`
|
|
2274
|
+
*
|
|
2275
|
+
* @returns {void}
|
|
2276
|
+
*/
|
|
2277
|
+
eject(id) {
|
|
2278
|
+
if (this.handlers[id]) {
|
|
2279
|
+
this.handlers[id] = null;
|
|
2280
|
+
}
|
|
2246
2281
|
}
|
|
2247
2282
|
|
|
2248
|
-
|
|
2249
|
-
|
|
2283
|
+
/**
|
|
2284
|
+
* Clear all interceptors from the stack
|
|
2285
|
+
*
|
|
2286
|
+
* @returns {void}
|
|
2287
|
+
*/
|
|
2288
|
+
clear() {
|
|
2289
|
+
if (this.handlers) {
|
|
2290
|
+
this.handlers = [];
|
|
2291
|
+
}
|
|
2250
2292
|
}
|
|
2251
|
-
}
|
|
2252
2293
|
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2294
|
+
/**
|
|
2295
|
+
* Iterate over all the registered interceptors
|
|
2296
|
+
*
|
|
2297
|
+
* This method is particularly useful for skipping over any
|
|
2298
|
+
* interceptors that may have become `null` calling `eject`.
|
|
2299
|
+
*
|
|
2300
|
+
* @param {Function} fn The function to call for each interceptor
|
|
2301
|
+
*
|
|
2302
|
+
* @returns {void}
|
|
2303
|
+
*/
|
|
2304
|
+
forEach(fn) {
|
|
2305
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
2306
|
+
if (h !== null) {
|
|
2307
|
+
fn(h);
|
|
2308
|
+
}
|
|
2259
2309
|
});
|
|
2310
|
+
}
|
|
2260
2311
|
}
|
|
2261
2312
|
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
2269
|
-
},
|
|
2270
|
-
configurable: true,
|
|
2271
|
-
});
|
|
2272
|
-
});
|
|
2273
|
-
}
|
|
2313
|
+
var transitionalDefaults = {
|
|
2314
|
+
silentJSONParsing: true,
|
|
2315
|
+
forcedJSONParsing: true,
|
|
2316
|
+
clarifyTimeoutError: false,
|
|
2317
|
+
legacyInterceptorReqResOrdering: true,
|
|
2318
|
+
};
|
|
2274
2319
|
|
|
2275
|
-
|
|
2276
|
-
constructor(headers) {
|
|
2277
|
-
headers && this.set(headers);
|
|
2278
|
-
}
|
|
2320
|
+
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
2279
2321
|
|
|
2280
|
-
|
|
2281
|
-
const self = this;
|
|
2322
|
+
var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
2282
2323
|
|
|
2283
|
-
|
|
2284
|
-
const lHeader = normalizeHeader(_header);
|
|
2324
|
+
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
2285
2325
|
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2326
|
+
var platform$1 = {
|
|
2327
|
+
isBrowser: true,
|
|
2328
|
+
classes: {
|
|
2329
|
+
URLSearchParams: URLSearchParams$1,
|
|
2330
|
+
FormData: FormData$1,
|
|
2331
|
+
Blob: Blob$1,
|
|
2332
|
+
},
|
|
2333
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
2334
|
+
};
|
|
2289
2335
|
|
|
2290
|
-
|
|
2336
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2291
2337
|
|
|
2292
|
-
|
|
2293
|
-
!key ||
|
|
2294
|
-
self[key] === undefined ||
|
|
2295
|
-
_rewrite === true ||
|
|
2296
|
-
(_rewrite === undefined && self[key] !== false)
|
|
2297
|
-
) {
|
|
2298
|
-
self[key || _header] = normalizeValue(_value);
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2338
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
2301
2339
|
|
|
2302
|
-
|
|
2303
|
-
|
|
2340
|
+
/**
|
|
2341
|
+
* Determine if we're running in a standard browser environment
|
|
2342
|
+
*
|
|
2343
|
+
* This allows axios to run in a web worker, and react-native.
|
|
2344
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
2345
|
+
*
|
|
2346
|
+
* web workers:
|
|
2347
|
+
* typeof window -> undefined
|
|
2348
|
+
* typeof document -> undefined
|
|
2349
|
+
*
|
|
2350
|
+
* react-native:
|
|
2351
|
+
* navigator.product -> 'ReactNative'
|
|
2352
|
+
* nativescript
|
|
2353
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
|
2354
|
+
*
|
|
2355
|
+
* @returns {boolean}
|
|
2356
|
+
*/
|
|
2357
|
+
const hasStandardBrowserEnv =
|
|
2358
|
+
hasBrowserEnv &&
|
|
2359
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2304
2360
|
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2361
|
+
/**
|
|
2362
|
+
* Determine if we're running in a standard browser webWorker environment
|
|
2363
|
+
*
|
|
2364
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
|
2365
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
2366
|
+
* filtered out due to its judgment standard
|
|
2367
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
2368
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
|
2369
|
+
*/
|
|
2370
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
2371
|
+
return (
|
|
2372
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
|
2373
|
+
// eslint-disable-next-line no-undef
|
|
2374
|
+
self instanceof WorkerGlobalScope &&
|
|
2375
|
+
typeof self.importScripts === 'function'
|
|
2376
|
+
);
|
|
2377
|
+
})();
|
|
2317
2378
|
|
|
2318
|
-
|
|
2319
|
-
? utils$1.isArray(dest)
|
|
2320
|
-
? [...dest, entry[1]]
|
|
2321
|
-
: [dest, entry[1]]
|
|
2322
|
-
: entry[1];
|
|
2323
|
-
}
|
|
2379
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
2324
2380
|
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2381
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
2382
|
+
__proto__: null,
|
|
2383
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
2384
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
2385
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
2386
|
+
navigator: _navigator,
|
|
2387
|
+
origin: origin
|
|
2388
|
+
});
|
|
2329
2389
|
|
|
2330
|
-
|
|
2331
|
-
|
|
2390
|
+
var platform = {
|
|
2391
|
+
...utils,
|
|
2392
|
+
...platform$1,
|
|
2393
|
+
};
|
|
2332
2394
|
|
|
2333
|
-
|
|
2334
|
-
|
|
2395
|
+
function toURLEncodedForm(data, options) {
|
|
2396
|
+
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
2397
|
+
visitor: function (value, key, path, helpers) {
|
|
2398
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
2399
|
+
this.append(key, value.toString('base64'));
|
|
2400
|
+
return false;
|
|
2401
|
+
}
|
|
2335
2402
|
|
|
2336
|
-
|
|
2337
|
-
|
|
2403
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
2404
|
+
},
|
|
2405
|
+
...options,
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2338
2408
|
|
|
2339
|
-
|
|
2340
|
-
|
|
2409
|
+
/**
|
|
2410
|
+
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
2411
|
+
*
|
|
2412
|
+
* @param {string} name - The name of the property to get.
|
|
2413
|
+
*
|
|
2414
|
+
* @returns An array of strings.
|
|
2415
|
+
*/
|
|
2416
|
+
function parsePropPath(name) {
|
|
2417
|
+
// foo[x][y][z]
|
|
2418
|
+
// foo.x.y.z
|
|
2419
|
+
// foo-x-y-z
|
|
2420
|
+
// foo x y z
|
|
2421
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
2422
|
+
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2341
2425
|
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2426
|
+
/**
|
|
2427
|
+
* Convert an array to an object.
|
|
2428
|
+
*
|
|
2429
|
+
* @param {Array<any>} arr - The array to convert to an object.
|
|
2430
|
+
*
|
|
2431
|
+
* @returns An object with the same keys and values as the array.
|
|
2432
|
+
*/
|
|
2433
|
+
function arrayToObject(arr) {
|
|
2434
|
+
const obj = {};
|
|
2435
|
+
const keys = Object.keys(arr);
|
|
2436
|
+
let i;
|
|
2437
|
+
const len = keys.length;
|
|
2438
|
+
let key;
|
|
2439
|
+
for (i = 0; i < len; i++) {
|
|
2440
|
+
key = keys[i];
|
|
2441
|
+
obj[key] = arr[key];
|
|
2442
|
+
}
|
|
2443
|
+
return obj;
|
|
2444
|
+
}
|
|
2345
2445
|
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2446
|
+
/**
|
|
2447
|
+
* It takes a FormData object and returns a JavaScript object
|
|
2448
|
+
*
|
|
2449
|
+
* @param {string} formData The FormData object to convert to JSON.
|
|
2450
|
+
*
|
|
2451
|
+
* @returns {Object<string, any> | null} The converted object.
|
|
2452
|
+
*/
|
|
2453
|
+
function formDataToJSON(formData) {
|
|
2454
|
+
function buildPath(path, value, target, index) {
|
|
2455
|
+
let name = path[index++];
|
|
2349
2456
|
|
|
2350
|
-
|
|
2351
|
-
return parser.call(this, value, key);
|
|
2352
|
-
}
|
|
2457
|
+
if (name === '__proto__') return true;
|
|
2353
2458
|
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2459
|
+
const isNumericKey = Number.isFinite(+name);
|
|
2460
|
+
const isLast = index >= path.length;
|
|
2461
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
2357
2462
|
|
|
2358
|
-
|
|
2463
|
+
if (isLast) {
|
|
2464
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
2465
|
+
target[name] = utils$1.isArray(target[name])
|
|
2466
|
+
? target[name].concat(value)
|
|
2467
|
+
: [target[name], value];
|
|
2468
|
+
} else {
|
|
2469
|
+
target[name] = value;
|
|
2359
2470
|
}
|
|
2471
|
+
|
|
2472
|
+
return !isNumericKey;
|
|
2360
2473
|
}
|
|
2361
|
-
}
|
|
2362
2474
|
|
|
2363
|
-
|
|
2364
|
-
|
|
2475
|
+
if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
|
|
2476
|
+
target[name] = [];
|
|
2477
|
+
}
|
|
2365
2478
|
|
|
2366
|
-
|
|
2367
|
-
const key = utils$1.findKey(this, header);
|
|
2479
|
+
const result = buildPath(path, value, target[name], index);
|
|
2368
2480
|
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
this[key] !== undefined &&
|
|
2372
|
-
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2373
|
-
);
|
|
2481
|
+
if (result && utils$1.isArray(target[name])) {
|
|
2482
|
+
target[name] = arrayToObject(target[name]);
|
|
2374
2483
|
}
|
|
2375
2484
|
|
|
2376
|
-
return
|
|
2485
|
+
return !isNumericKey;
|
|
2377
2486
|
}
|
|
2378
2487
|
|
|
2379
|
-
|
|
2380
|
-
const
|
|
2381
|
-
let deleted = false;
|
|
2382
|
-
|
|
2383
|
-
function deleteHeader(_header) {
|
|
2384
|
-
_header = normalizeHeader(_header);
|
|
2385
|
-
|
|
2386
|
-
if (_header) {
|
|
2387
|
-
const key = utils$1.findKey(self, _header);
|
|
2388
|
-
|
|
2389
|
-
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
2390
|
-
delete self[key];
|
|
2391
|
-
|
|
2392
|
-
deleted = true;
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2488
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
2489
|
+
const obj = {};
|
|
2396
2490
|
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
}
|
|
2400
|
-
deleteHeader(header);
|
|
2401
|
-
}
|
|
2491
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
2492
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
2493
|
+
});
|
|
2402
2494
|
|
|
2403
|
-
return
|
|
2495
|
+
return obj;
|
|
2404
2496
|
}
|
|
2405
2497
|
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
let i = keys.length;
|
|
2409
|
-
let deleted = false;
|
|
2498
|
+
return null;
|
|
2499
|
+
}
|
|
2410
2500
|
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2501
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
2502
|
+
|
|
2503
|
+
/**
|
|
2504
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
2505
|
+
* of the input
|
|
2506
|
+
*
|
|
2507
|
+
* @param {any} rawValue - The value to be stringified.
|
|
2508
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
2509
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
2510
|
+
*
|
|
2511
|
+
* @returns {string} A stringified version of the rawValue.
|
|
2512
|
+
*/
|
|
2513
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
2514
|
+
if (utils$1.isString(rawValue)) {
|
|
2515
|
+
try {
|
|
2516
|
+
(parser || JSON.parse)(rawValue);
|
|
2517
|
+
return utils$1.trim(rawValue);
|
|
2518
|
+
} catch (e) {
|
|
2519
|
+
if (e.name !== 'SyntaxError') {
|
|
2520
|
+
throw e;
|
|
2416
2521
|
}
|
|
2417
2522
|
}
|
|
2418
|
-
|
|
2419
|
-
return deleted;
|
|
2420
2523
|
}
|
|
2421
2524
|
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
const headers = {};
|
|
2525
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
2526
|
+
}
|
|
2425
2527
|
|
|
2426
|
-
|
|
2427
|
-
|
|
2528
|
+
const defaults = {
|
|
2529
|
+
transitional: transitionalDefaults,
|
|
2428
2530
|
|
|
2429
|
-
|
|
2430
|
-
self[key] = normalizeValue(value);
|
|
2431
|
-
delete self[header];
|
|
2432
|
-
return;
|
|
2433
|
-
}
|
|
2531
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
2434
2532
|
|
|
2435
|
-
|
|
2533
|
+
transformRequest: [
|
|
2534
|
+
function transformRequest(data, headers) {
|
|
2535
|
+
const contentType = headers.getContentType() || '';
|
|
2536
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
2537
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
2436
2538
|
|
|
2437
|
-
if (
|
|
2438
|
-
|
|
2539
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
2540
|
+
data = new FormData(data);
|
|
2439
2541
|
}
|
|
2440
2542
|
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
headers[normalized] = true;
|
|
2444
|
-
});
|
|
2543
|
+
const isFormData = utils$1.isFormData(data);
|
|
2445
2544
|
|
|
2446
|
-
|
|
2447
|
-
|
|
2545
|
+
if (isFormData) {
|
|
2546
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
2547
|
+
}
|
|
2448
2548
|
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2549
|
+
if (
|
|
2550
|
+
utils$1.isArrayBuffer(data) ||
|
|
2551
|
+
utils$1.isBuffer(data) ||
|
|
2552
|
+
utils$1.isStream(data) ||
|
|
2553
|
+
utils$1.isFile(data) ||
|
|
2554
|
+
utils$1.isBlob(data) ||
|
|
2555
|
+
utils$1.isReadableStream(data)
|
|
2556
|
+
) {
|
|
2557
|
+
return data;
|
|
2558
|
+
}
|
|
2559
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
2560
|
+
return data.buffer;
|
|
2561
|
+
}
|
|
2562
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
2563
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
2564
|
+
return data.toString();
|
|
2565
|
+
}
|
|
2452
2566
|
|
|
2453
|
-
|
|
2454
|
-
const obj = Object.create(null);
|
|
2567
|
+
let isFileList;
|
|
2455
2568
|
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2569
|
+
if (isObjectPayload) {
|
|
2570
|
+
const formSerializer = own(this, 'formSerializer');
|
|
2571
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
2572
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
2573
|
+
}
|
|
2461
2574
|
|
|
2462
|
-
|
|
2463
|
-
|
|
2575
|
+
if (
|
|
2576
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
2577
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
2578
|
+
) {
|
|
2579
|
+
const env = own(this, 'env');
|
|
2580
|
+
const _FormData = env && env.FormData;
|
|
2464
2581
|
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2582
|
+
return toFormData$1(
|
|
2583
|
+
isFileList ? { 'files[]': data } : data,
|
|
2584
|
+
_FormData && new _FormData(),
|
|
2585
|
+
formSerializer
|
|
2586
|
+
);
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2468
2589
|
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
}
|
|
2590
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
2591
|
+
headers.setContentType('application/json', false);
|
|
2592
|
+
return stringifySafely(data);
|
|
2593
|
+
}
|
|
2474
2594
|
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2595
|
+
return data;
|
|
2596
|
+
},
|
|
2597
|
+
],
|
|
2478
2598
|
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2599
|
+
transformResponse: [
|
|
2600
|
+
function transformResponse(data) {
|
|
2601
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
2602
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
2603
|
+
const responseType = own(this, 'responseType');
|
|
2604
|
+
const JSONRequested = responseType === 'json';
|
|
2482
2605
|
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2606
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
2607
|
+
return data;
|
|
2608
|
+
}
|
|
2486
2609
|
|
|
2487
|
-
|
|
2488
|
-
|
|
2610
|
+
if (
|
|
2611
|
+
data &&
|
|
2612
|
+
utils$1.isString(data) &&
|
|
2613
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
2614
|
+
) {
|
|
2615
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2616
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
2489
2617
|
|
|
2490
|
-
|
|
2618
|
+
try {
|
|
2619
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
2620
|
+
} catch (e) {
|
|
2621
|
+
if (strictJSONParsing) {
|
|
2622
|
+
if (e.name === 'SyntaxError') {
|
|
2623
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
2624
|
+
}
|
|
2625
|
+
throw e;
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2491
2629
|
|
|
2492
|
-
|
|
2493
|
-
|
|
2630
|
+
return data;
|
|
2631
|
+
},
|
|
2632
|
+
],
|
|
2494
2633
|
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
accessors: {},
|
|
2501
|
-
});
|
|
2634
|
+
/**
|
|
2635
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
2636
|
+
* timeout is not created.
|
|
2637
|
+
*/
|
|
2638
|
+
timeout: 0,
|
|
2502
2639
|
|
|
2503
|
-
|
|
2504
|
-
|
|
2640
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
2641
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
2505
2642
|
|
|
2506
|
-
|
|
2507
|
-
|
|
2643
|
+
maxContentLength: -1,
|
|
2644
|
+
maxBodyLength: -1,
|
|
2508
2645
|
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
}
|
|
2646
|
+
env: {
|
|
2647
|
+
FormData: platform.classes.FormData,
|
|
2648
|
+
Blob: platform.classes.Blob,
|
|
2649
|
+
},
|
|
2514
2650
|
|
|
2515
|
-
|
|
2651
|
+
validateStatus: function validateStatus(status) {
|
|
2652
|
+
return status >= 200 && status < 300;
|
|
2653
|
+
},
|
|
2516
2654
|
|
|
2517
|
-
|
|
2518
|
-
|
|
2655
|
+
headers: {
|
|
2656
|
+
common: {
|
|
2657
|
+
Accept: 'application/json, text/plain, */*',
|
|
2658
|
+
'Content-Type': undefined,
|
|
2659
|
+
},
|
|
2660
|
+
},
|
|
2519
2661
|
};
|
|
2520
2662
|
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
'Content-Length',
|
|
2524
|
-
'Accept',
|
|
2525
|
-
'Accept-Encoding',
|
|
2526
|
-
'User-Agent',
|
|
2527
|
-
'Authorization',
|
|
2528
|
-
]);
|
|
2529
|
-
|
|
2530
|
-
// reserved names hotfix
|
|
2531
|
-
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
2532
|
-
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2533
|
-
return {
|
|
2534
|
-
get: () => value,
|
|
2535
|
-
set(headerValue) {
|
|
2536
|
-
this[mapped] = headerValue;
|
|
2537
|
-
},
|
|
2538
|
-
};
|
|
2663
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
|
|
2664
|
+
defaults.headers[method] = {};
|
|
2539
2665
|
});
|
|
2540
2666
|
|
|
2541
|
-
utils$1.freezeMethods(AxiosHeaders$1);
|
|
2542
|
-
|
|
2543
2667
|
/**
|
|
2544
2668
|
* Transform the data for a request or a response
|
|
2545
2669
|
*
|
|
@@ -2598,22 +2722,18 @@ function settle(resolve, reject, response) {
|
|
|
2598
2722
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2599
2723
|
resolve(response);
|
|
2600
2724
|
} else {
|
|
2601
|
-
reject(
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
response.request,
|
|
2609
|
-
response
|
|
2610
|
-
)
|
|
2611
|
-
);
|
|
2725
|
+
reject(new AxiosError$1(
|
|
2726
|
+
'Request failed with status code ' + response.status,
|
|
2727
|
+
response.status >= 400 && response.status < 500 ? AxiosError$1.ERR_BAD_REQUEST : AxiosError$1.ERR_BAD_RESPONSE,
|
|
2728
|
+
response.config,
|
|
2729
|
+
response.request,
|
|
2730
|
+
response
|
|
2731
|
+
));
|
|
2612
2732
|
}
|
|
2613
2733
|
}
|
|
2614
2734
|
|
|
2615
2735
|
function parseProtocol(url) {
|
|
2616
|
-
const match = /^([-+\w]{1,25})(
|
|
2736
|
+
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
2617
2737
|
return (match && match[1]) || '';
|
|
2618
2738
|
}
|
|
2619
2739
|
|
|
@@ -2717,6 +2837,9 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2717
2837
|
const _speedometer = speedometer(50, 250);
|
|
2718
2838
|
|
|
2719
2839
|
return throttle((e) => {
|
|
2840
|
+
if (!e || typeof e.loaded !== 'number') {
|
|
2841
|
+
return;
|
|
2842
|
+
}
|
|
2720
2843
|
const rawLoaded = e.loaded;
|
|
2721
2844
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2722
2845
|
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
@@ -2804,8 +2927,20 @@ var cookies = platform.hasStandardBrowserEnv
|
|
|
2804
2927
|
|
|
2805
2928
|
read(name) {
|
|
2806
2929
|
if (typeof document === 'undefined') return null;
|
|
2807
|
-
|
|
2808
|
-
|
|
2930
|
+
// Match name=value by splitting on the semicolon separator instead of building a
|
|
2931
|
+
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
2932
|
+
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
2933
|
+
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
2934
|
+
// "; ", so ignore optional whitespace before each cookie name.
|
|
2935
|
+
const cookies = document.cookie.split(';');
|
|
2936
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
2937
|
+
const cookie = cookies[i].replace(/^\s+/, '');
|
|
2938
|
+
const eq = cookie.indexOf('=');
|
|
2939
|
+
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
2940
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
return null;
|
|
2809
2944
|
},
|
|
2810
2945
|
|
|
2811
2946
|
remove(name) {
|
|
@@ -2887,11 +3022,14 @@ function mergeConfig$1(config1, config2) {
|
|
|
2887
3022
|
config2 = config2 || {};
|
|
2888
3023
|
|
|
2889
3024
|
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
2890
|
-
// or `config.baseURL` cannot inherit polluted values from Object.prototype
|
|
2891
|
-
//
|
|
2892
|
-
//
|
|
3025
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype.
|
|
3026
|
+
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
3027
|
+
// ergonomics for user code that relies on it.
|
|
2893
3028
|
const config = Object.create(null);
|
|
2894
3029
|
Object.defineProperty(config, 'hasOwnProperty', {
|
|
3030
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
3031
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
3032
|
+
__proto__: null,
|
|
2895
3033
|
value: Object.prototype.hasOwnProperty,
|
|
2896
3034
|
enumerable: false,
|
|
2897
3035
|
writable: true,
|
|
@@ -2988,11 +3126,39 @@ function mergeConfig$1(config1, config2) {
|
|
|
2988
3126
|
return config;
|
|
2989
3127
|
}
|
|
2990
3128
|
|
|
3129
|
+
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
3130
|
+
|
|
3131
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
3132
|
+
if (policy !== 'content-only') {
|
|
3133
|
+
headers.set(formHeaders);
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3138
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
3139
|
+
headers.set(key, val);
|
|
3140
|
+
}
|
|
3141
|
+
});
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
/**
|
|
3145
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
3146
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
3147
|
+
*
|
|
3148
|
+
* @param {string} str The string to encode
|
|
3149
|
+
*
|
|
3150
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
3151
|
+
*/
|
|
3152
|
+
const encodeUTF8 = (str) =>
|
|
3153
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
3154
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
3155
|
+
);
|
|
3156
|
+
|
|
2991
3157
|
var resolveConfig = (config) => {
|
|
2992
3158
|
const newConfig = mergeConfig$1({}, config);
|
|
2993
3159
|
|
|
2994
3160
|
// Read only own properties to prevent prototype pollution gadgets
|
|
2995
|
-
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
3161
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
2996
3162
|
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
2997
3163
|
|
|
2998
3164
|
const data = own('data');
|
|
@@ -3018,11 +3184,7 @@ var resolveConfig = (config) => {
|
|
|
3018
3184
|
headers.set(
|
|
3019
3185
|
'Authorization',
|
|
3020
3186
|
'Basic ' +
|
|
3021
|
-
btoa(
|
|
3022
|
-
(auth.username || '') +
|
|
3023
|
-
':' +
|
|
3024
|
-
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
|
3025
|
-
)
|
|
3187
|
+
btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
|
|
3026
3188
|
);
|
|
3027
3189
|
}
|
|
3028
3190
|
|
|
@@ -3031,14 +3193,7 @@ var resolveConfig = (config) => {
|
|
|
3031
3193
|
headers.setContentType(undefined); // browser handles it
|
|
3032
3194
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
3033
3195
|
// Node.js FormData (like form-data package)
|
|
3034
|
-
|
|
3035
|
-
// Only set safe headers to avoid overwriting security headers
|
|
3036
|
-
const allowedHeaders = ['content-type', 'content-length'];
|
|
3037
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3038
|
-
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
3039
|
-
headers.set(key, val);
|
|
3040
|
-
}
|
|
3041
|
-
});
|
|
3196
|
+
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
3042
3197
|
}
|
|
3043
3198
|
}
|
|
3044
3199
|
|
|
@@ -3053,10 +3208,9 @@ var resolveConfig = (config) => {
|
|
|
3053
3208
|
|
|
3054
3209
|
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
3055
3210
|
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
3056
|
-
// the XSRF token cross-origin.
|
|
3211
|
+
// the XSRF token cross-origin.
|
|
3057
3212
|
const shouldSendXSRF =
|
|
3058
|
-
withXSRFToken === true ||
|
|
3059
|
-
(withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
3213
|
+
withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
3060
3214
|
|
|
3061
3215
|
if (shouldSendXSRF) {
|
|
3062
3216
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
@@ -3152,7 +3306,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3152
3306
|
// will return status as 0 even though it's a successful request
|
|
3153
3307
|
if (
|
|
3154
3308
|
request.status === 0 &&
|
|
3155
|
-
!(request.responseURL && request.responseURL.
|
|
3309
|
+
!(request.responseURL && request.responseURL.startsWith('file:'))
|
|
3156
3310
|
) {
|
|
3157
3311
|
return;
|
|
3158
3312
|
}
|
|
@@ -3169,6 +3323,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3169
3323
|
}
|
|
3170
3324
|
|
|
3171
3325
|
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
3326
|
+
done();
|
|
3172
3327
|
|
|
3173
3328
|
// Clean up request
|
|
3174
3329
|
request = null;
|
|
@@ -3184,6 +3339,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3184
3339
|
// attach the underlying event for consumers who want details
|
|
3185
3340
|
err.event = event || null;
|
|
3186
3341
|
reject(err);
|
|
3342
|
+
done();
|
|
3187
3343
|
request = null;
|
|
3188
3344
|
};
|
|
3189
3345
|
|
|
@@ -3204,6 +3360,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3204
3360
|
request
|
|
3205
3361
|
)
|
|
3206
3362
|
);
|
|
3363
|
+
done();
|
|
3207
3364
|
|
|
3208
3365
|
// Clean up request
|
|
3209
3366
|
request = null;
|
|
@@ -3214,7 +3371,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3214
3371
|
|
|
3215
3372
|
// Add headers to the request
|
|
3216
3373
|
if ('setRequestHeader' in request) {
|
|
3217
|
-
utils$1.forEach(requestHeaders
|
|
3374
|
+
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
3218
3375
|
request.setRequestHeader(key, val);
|
|
3219
3376
|
});
|
|
3220
3377
|
}
|
|
@@ -3253,6 +3410,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3253
3410
|
}
|
|
3254
3411
|
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
3255
3412
|
request.abort();
|
|
3413
|
+
done();
|
|
3256
3414
|
request = null;
|
|
3257
3415
|
};
|
|
3258
3416
|
|
|
@@ -3266,7 +3424,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3266
3424
|
|
|
3267
3425
|
const protocol = parseProtocol(_config.url);
|
|
3268
3426
|
|
|
3269
|
-
if (protocol && platform.protocols.
|
|
3427
|
+
if (protocol && !platform.protocols.includes(protocol)) {
|
|
3270
3428
|
reject(
|
|
3271
3429
|
new AxiosError$1(
|
|
3272
3430
|
'Unsupported protocol ' + protocol + ':',
|
|
@@ -3283,54 +3441,55 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3283
3441
|
};
|
|
3284
3442
|
|
|
3285
3443
|
const composeSignals = (signals, timeout) => {
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
if (timeout || length) {
|
|
3289
|
-
let controller = new AbortController();
|
|
3290
|
-
|
|
3291
|
-
let aborted;
|
|
3292
|
-
|
|
3293
|
-
const onabort = function (reason) {
|
|
3294
|
-
if (!aborted) {
|
|
3295
|
-
aborted = true;
|
|
3296
|
-
unsubscribe();
|
|
3297
|
-
const err = reason instanceof Error ? reason : this.reason;
|
|
3298
|
-
controller.abort(
|
|
3299
|
-
err instanceof AxiosError$1
|
|
3300
|
-
? err
|
|
3301
|
-
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3302
|
-
);
|
|
3303
|
-
}
|
|
3304
|
-
};
|
|
3444
|
+
signals = signals ? signals.filter(Boolean) : [];
|
|
3305
3445
|
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
timer = null;
|
|
3310
|
-
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3311
|
-
}, timeout);
|
|
3312
|
-
|
|
3313
|
-
const unsubscribe = () => {
|
|
3314
|
-
if (signals) {
|
|
3315
|
-
timer && clearTimeout(timer);
|
|
3316
|
-
timer = null;
|
|
3317
|
-
signals.forEach((signal) => {
|
|
3318
|
-
signal.unsubscribe
|
|
3319
|
-
? signal.unsubscribe(onabort)
|
|
3320
|
-
: signal.removeEventListener('abort', onabort);
|
|
3321
|
-
});
|
|
3322
|
-
signals = null;
|
|
3323
|
-
}
|
|
3324
|
-
};
|
|
3446
|
+
if (!timeout && !signals.length) {
|
|
3447
|
+
return;
|
|
3448
|
+
}
|
|
3325
3449
|
|
|
3326
|
-
|
|
3450
|
+
const controller = new AbortController();
|
|
3327
3451
|
|
|
3328
|
-
|
|
3452
|
+
let aborted = false;
|
|
3329
3453
|
|
|
3330
|
-
|
|
3454
|
+
const onabort = function (reason) {
|
|
3455
|
+
if (!aborted) {
|
|
3456
|
+
aborted = true;
|
|
3457
|
+
unsubscribe();
|
|
3458
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
3459
|
+
controller.abort(
|
|
3460
|
+
err instanceof AxiosError$1
|
|
3461
|
+
? err
|
|
3462
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3463
|
+
);
|
|
3464
|
+
}
|
|
3465
|
+
};
|
|
3331
3466
|
|
|
3332
|
-
|
|
3333
|
-
|
|
3467
|
+
let timer =
|
|
3468
|
+
timeout &&
|
|
3469
|
+
setTimeout(() => {
|
|
3470
|
+
timer = null;
|
|
3471
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3472
|
+
}, timeout);
|
|
3473
|
+
|
|
3474
|
+
const unsubscribe = () => {
|
|
3475
|
+
if (!signals) { return; }
|
|
3476
|
+
timer && clearTimeout(timer);
|
|
3477
|
+
timer = null;
|
|
3478
|
+
signals.forEach((signal) => {
|
|
3479
|
+
signal.unsubscribe
|
|
3480
|
+
? signal.unsubscribe(onabort)
|
|
3481
|
+
: signal.removeEventListener('abort', onabort);
|
|
3482
|
+
});
|
|
3483
|
+
signals = null;
|
|
3484
|
+
};
|
|
3485
|
+
|
|
3486
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
3487
|
+
|
|
3488
|
+
const { signal } = controller;
|
|
3489
|
+
|
|
3490
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
3491
|
+
|
|
3492
|
+
return signal;
|
|
3334
3493
|
};
|
|
3335
3494
|
|
|
3336
3495
|
const streamChunk = function* (chunk, chunkSize) {
|
|
@@ -3423,16 +3582,112 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3423
3582
|
);
|
|
3424
3583
|
};
|
|
3425
3584
|
|
|
3426
|
-
|
|
3585
|
+
/**
|
|
3586
|
+
* Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|
3587
|
+
* - For base64: compute exact decoded size using length and padding;
|
|
3588
|
+
* handle %XX at the character-count level (no string allocation).
|
|
3589
|
+
* - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
|
|
3590
|
+
*
|
|
3591
|
+
* @param {string} url
|
|
3592
|
+
* @returns {number}
|
|
3593
|
+
*/
|
|
3594
|
+
function estimateDataURLDecodedBytes(url) {
|
|
3595
|
+
if (!url || typeof url !== 'string') return 0;
|
|
3596
|
+
if (!url.startsWith('data:')) return 0;
|
|
3427
3597
|
|
|
3428
|
-
const
|
|
3598
|
+
const comma = url.indexOf(',');
|
|
3599
|
+
if (comma < 0) return 0;
|
|
3600
|
+
|
|
3601
|
+
const meta = url.slice(5, comma);
|
|
3602
|
+
const body = url.slice(comma + 1);
|
|
3603
|
+
const isBase64 = /;base64/i.test(meta);
|
|
3604
|
+
|
|
3605
|
+
if (isBase64) {
|
|
3606
|
+
let effectiveLen = body.length;
|
|
3607
|
+
const len = body.length; // cache length
|
|
3608
|
+
|
|
3609
|
+
for (let i = 0; i < len; i++) {
|
|
3610
|
+
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
3611
|
+
const a = body.charCodeAt(i + 1);
|
|
3612
|
+
const b = body.charCodeAt(i + 2);
|
|
3613
|
+
const isHex =
|
|
3614
|
+
((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
|
|
3615
|
+
((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
|
|
3616
|
+
|
|
3617
|
+
if (isHex) {
|
|
3618
|
+
effectiveLen -= 2;
|
|
3619
|
+
i += 2;
|
|
3620
|
+
}
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
let pad = 0;
|
|
3625
|
+
let idx = len - 1;
|
|
3626
|
+
|
|
3627
|
+
const tailIsPct3D = (j) =>
|
|
3628
|
+
j >= 2 &&
|
|
3629
|
+
body.charCodeAt(j - 2) === 37 && // '%'
|
|
3630
|
+
body.charCodeAt(j - 1) === 51 && // '3'
|
|
3631
|
+
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
|
|
3632
|
+
|
|
3633
|
+
if (idx >= 0) {
|
|
3634
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
3635
|
+
pad++;
|
|
3636
|
+
idx--;
|
|
3637
|
+
} else if (tailIsPct3D(idx)) {
|
|
3638
|
+
pad++;
|
|
3639
|
+
idx -= 3;
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
|
|
3643
|
+
if (pad === 1 && idx >= 0) {
|
|
3644
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
3645
|
+
pad++;
|
|
3646
|
+
} else if (tailIsPct3D(idx)) {
|
|
3647
|
+
pad++;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
|
|
3651
|
+
const groups = Math.floor(effectiveLen / 4);
|
|
3652
|
+
const bytes = groups * 3 - (pad || 0);
|
|
3653
|
+
return bytes > 0 ? bytes : 0;
|
|
3654
|
+
}
|
|
3655
|
+
|
|
3656
|
+
if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
|
|
3657
|
+
return Buffer.byteLength(body, 'utf8');
|
|
3658
|
+
}
|
|
3659
|
+
|
|
3660
|
+
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
3661
|
+
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
3662
|
+
// Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
|
|
3663
|
+
// but 3 UTF-8 bytes).
|
|
3664
|
+
let bytes = 0;
|
|
3665
|
+
for (let i = 0, len = body.length; i < len; i++) {
|
|
3666
|
+
const c = body.charCodeAt(i);
|
|
3667
|
+
if (c < 0x80) {
|
|
3668
|
+
bytes += 1;
|
|
3669
|
+
} else if (c < 0x800) {
|
|
3670
|
+
bytes += 2;
|
|
3671
|
+
} else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
|
3672
|
+
const next = body.charCodeAt(i + 1);
|
|
3673
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
3674
|
+
bytes += 4;
|
|
3675
|
+
i++;
|
|
3676
|
+
} else {
|
|
3677
|
+
bytes += 3;
|
|
3678
|
+
}
|
|
3679
|
+
} else {
|
|
3680
|
+
bytes += 3;
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
return bytes;
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
const VERSION$1 = "1.16.1";
|
|
3429
3687
|
|
|
3430
|
-
const
|
|
3431
|
-
Request,
|
|
3432
|
-
Response,
|
|
3433
|
-
}))(utils$1.global);
|
|
3688
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3434
3689
|
|
|
3435
|
-
const {
|
|
3690
|
+
const { isFunction } = utils$1;
|
|
3436
3691
|
|
|
3437
3692
|
const test = (fn, ...args) => {
|
|
3438
3693
|
try {
|
|
@@ -3443,11 +3698,20 @@ const test = (fn, ...args) => {
|
|
|
3443
3698
|
};
|
|
3444
3699
|
|
|
3445
3700
|
const factory = (env) => {
|
|
3701
|
+
const globalObject =
|
|
3702
|
+
utils$1.global !== undefined && utils$1.global !== null
|
|
3703
|
+
? utils$1.global
|
|
3704
|
+
: globalThis;
|
|
3705
|
+
const { ReadableStream, TextEncoder } = globalObject;
|
|
3706
|
+
|
|
3446
3707
|
env = utils$1.merge.call(
|
|
3447
3708
|
{
|
|
3448
3709
|
skipUndefined: true,
|
|
3449
3710
|
},
|
|
3450
|
-
|
|
3711
|
+
{
|
|
3712
|
+
Request: globalObject.Request,
|
|
3713
|
+
Response: globalObject.Response,
|
|
3714
|
+
},
|
|
3451
3715
|
env
|
|
3452
3716
|
);
|
|
3453
3717
|
|
|
@@ -3460,7 +3724,7 @@ const factory = (env) => {
|
|
|
3460
3724
|
return false;
|
|
3461
3725
|
}
|
|
3462
3726
|
|
|
3463
|
-
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream
|
|
3727
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
|
3464
3728
|
|
|
3465
3729
|
const encodeText =
|
|
3466
3730
|
isFetchSupported &&
|
|
@@ -3478,7 +3742,7 @@ const factory = (env) => {
|
|
|
3478
3742
|
let duplexAccessed = false;
|
|
3479
3743
|
|
|
3480
3744
|
const request = new Request(platform.origin, {
|
|
3481
|
-
body: new ReadableStream
|
|
3745
|
+
body: new ReadableStream(),
|
|
3482
3746
|
method: 'POST',
|
|
3483
3747
|
get duplex() {
|
|
3484
3748
|
duplexAccessed = true;
|
|
@@ -3574,8 +3838,13 @@ const factory = (env) => {
|
|
|
3574
3838
|
headers,
|
|
3575
3839
|
withCredentials = 'same-origin',
|
|
3576
3840
|
fetchOptions,
|
|
3841
|
+
maxContentLength,
|
|
3842
|
+
maxBodyLength,
|
|
3577
3843
|
} = resolveConfig(config);
|
|
3578
3844
|
|
|
3845
|
+
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
3846
|
+
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
3847
|
+
|
|
3579
3848
|
let _fetch = envFetch || fetch;
|
|
3580
3849
|
|
|
3581
3850
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
@@ -3597,6 +3866,41 @@ const factory = (env) => {
|
|
|
3597
3866
|
let requestContentLength;
|
|
3598
3867
|
|
|
3599
3868
|
try {
|
|
3869
|
+
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
3870
|
+
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
3871
|
+
// "if (protocol === 'data:')" branch).
|
|
3872
|
+
if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
|
|
3873
|
+
const estimated = estimateDataURLDecodedBytes(url);
|
|
3874
|
+
if (estimated > maxContentLength) {
|
|
3875
|
+
throw new AxiosError$1(
|
|
3876
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3877
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
3878
|
+
config,
|
|
3879
|
+
request
|
|
3880
|
+
);
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
// Enforce maxBodyLength against the outbound request body before dispatch.
|
|
3885
|
+
// Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
|
|
3886
|
+
// maxBodyLength limit'). Skip when the body length cannot be determined
|
|
3887
|
+
// (e.g. a live ReadableStream supplied by the caller).
|
|
3888
|
+
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
3889
|
+
const outboundLength = await resolveBodyLength(headers, data);
|
|
3890
|
+
if (
|
|
3891
|
+
typeof outboundLength === 'number' &&
|
|
3892
|
+
isFinite(outboundLength) &&
|
|
3893
|
+
outboundLength > maxBodyLength
|
|
3894
|
+
) {
|
|
3895
|
+
throw new AxiosError$1(
|
|
3896
|
+
'Request body larger than maxBodyLength limit',
|
|
3897
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
3898
|
+
config,
|
|
3899
|
+
request
|
|
3900
|
+
);
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
|
|
3600
3904
|
if (
|
|
3601
3905
|
onUploadProgress &&
|
|
3602
3906
|
supportsRequestStream &&
|
|
@@ -3647,11 +3951,14 @@ const factory = (env) => {
|
|
|
3647
3951
|
}
|
|
3648
3952
|
}
|
|
3649
3953
|
|
|
3954
|
+
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
3955
|
+
headers.set('User-Agent', 'axios/' + VERSION$1, false);
|
|
3956
|
+
|
|
3650
3957
|
const resolvedOptions = {
|
|
3651
3958
|
...fetchOptions,
|
|
3652
3959
|
signal: composedSignal,
|
|
3653
3960
|
method: method.toUpperCase(),
|
|
3654
|
-
headers: headers.normalize()
|
|
3961
|
+
headers: toByteStringHeaderObject(headers.normalize()),
|
|
3655
3962
|
body: data,
|
|
3656
3963
|
duplex: 'half',
|
|
3657
3964
|
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
@@ -3663,10 +3970,28 @@ const factory = (env) => {
|
|
|
3663
3970
|
? _fetch(request, fetchOptions)
|
|
3664
3971
|
: _fetch(url, resolvedOptions));
|
|
3665
3972
|
|
|
3973
|
+
// Cheap pre-check: if the server honestly declares a content-length that
|
|
3974
|
+
// already exceeds the cap, reject before we start streaming.
|
|
3975
|
+
if (hasMaxContentLength) {
|
|
3976
|
+
const declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3977
|
+
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
3978
|
+
throw new AxiosError$1(
|
|
3979
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3980
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
3981
|
+
config,
|
|
3982
|
+
request
|
|
3983
|
+
);
|
|
3984
|
+
}
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3666
3987
|
const isStreamResponse =
|
|
3667
3988
|
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3668
3989
|
|
|
3669
|
-
if (
|
|
3990
|
+
if (
|
|
3991
|
+
supportsResponseStream &&
|
|
3992
|
+
response.body &&
|
|
3993
|
+
(onDownloadProgress || hasMaxContentLength || (isStreamResponse && unsubscribe))
|
|
3994
|
+
) {
|
|
3670
3995
|
const options = {};
|
|
3671
3996
|
|
|
3672
3997
|
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
@@ -3683,8 +4008,24 @@ const factory = (env) => {
|
|
|
3683
4008
|
)) ||
|
|
3684
4009
|
[];
|
|
3685
4010
|
|
|
4011
|
+
let bytesRead = 0;
|
|
4012
|
+
const onChunkProgress = (loadedBytes) => {
|
|
4013
|
+
if (hasMaxContentLength) {
|
|
4014
|
+
bytesRead = loadedBytes;
|
|
4015
|
+
if (bytesRead > maxContentLength) {
|
|
4016
|
+
throw new AxiosError$1(
|
|
4017
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4018
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4019
|
+
config,
|
|
4020
|
+
request
|
|
4021
|
+
);
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
onProgress && onProgress(loadedBytes);
|
|
4025
|
+
};
|
|
4026
|
+
|
|
3686
4027
|
response = new Response(
|
|
3687
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE,
|
|
4028
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
|
|
3688
4029
|
flush && flush();
|
|
3689
4030
|
unsubscribe && unsubscribe();
|
|
3690
4031
|
}),
|
|
@@ -3699,6 +4040,33 @@ const factory = (env) => {
|
|
|
3699
4040
|
config
|
|
3700
4041
|
);
|
|
3701
4042
|
|
|
4043
|
+
// Fallback enforcement for environments without ReadableStream support
|
|
4044
|
+
// (legacy runtimes). Detect materialized size from typed output; skip
|
|
4045
|
+
// streams/Response passthrough since the user will read those themselves.
|
|
4046
|
+
if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
|
|
4047
|
+
let materializedSize;
|
|
4048
|
+
if (responseData != null) {
|
|
4049
|
+
if (typeof responseData.byteLength === 'number') {
|
|
4050
|
+
materializedSize = responseData.byteLength;
|
|
4051
|
+
} else if (typeof responseData.size === 'number') {
|
|
4052
|
+
materializedSize = responseData.size;
|
|
4053
|
+
} else if (typeof responseData === 'string') {
|
|
4054
|
+
materializedSize =
|
|
4055
|
+
typeof TextEncoder === 'function'
|
|
4056
|
+
? new TextEncoder().encode(responseData).byteLength
|
|
4057
|
+
: responseData.length;
|
|
4058
|
+
}
|
|
4059
|
+
}
|
|
4060
|
+
if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
|
|
4061
|
+
throw new AxiosError$1(
|
|
4062
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4063
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4064
|
+
config,
|
|
4065
|
+
request
|
|
4066
|
+
);
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
|
|
3702
4070
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3703
4071
|
|
|
3704
4072
|
return await new Promise((resolve, reject) => {
|
|
@@ -3714,6 +4082,17 @@ const factory = (env) => {
|
|
|
3714
4082
|
} catch (err) {
|
|
3715
4083
|
unsubscribe && unsubscribe();
|
|
3716
4084
|
|
|
4085
|
+
// Safari can surface fetch aborts as a DOMException-like object whose
|
|
4086
|
+
// branded getters throw. Prefer our composed signal reason before reading
|
|
4087
|
+
// the caught error, preserving timeout vs cancellation semantics.
|
|
4088
|
+
if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError$1) {
|
|
4089
|
+
const canceledError = composedSignal.reason;
|
|
4090
|
+
canceledError.config = config;
|
|
4091
|
+
request && (canceledError.request = request);
|
|
4092
|
+
err !== canceledError && (canceledError.cause = err);
|
|
4093
|
+
throw canceledError;
|
|
4094
|
+
}
|
|
4095
|
+
|
|
3717
4096
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3718
4097
|
throw Object.assign(
|
|
3719
4098
|
new AxiosError$1(
|
|
@@ -3782,11 +4161,13 @@ const knownAdapters = {
|
|
|
3782
4161
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3783
4162
|
if (fn) {
|
|
3784
4163
|
try {
|
|
3785
|
-
Object.
|
|
4164
|
+
// Null-proto descriptors so a polluted Object.prototype.get cannot turn
|
|
4165
|
+
// these data descriptors into accessor descriptors on the way in.
|
|
4166
|
+
Object.defineProperty(fn, 'name', { __proto__: null, value });
|
|
3786
4167
|
} catch (e) {
|
|
3787
4168
|
// eslint-disable-next-line no-empty
|
|
3788
4169
|
}
|
|
3789
|
-
Object.defineProperty(fn, 'adapterName', { value });
|
|
4170
|
+
Object.defineProperty(fn, 'adapterName', { __proto__: null, value });
|
|
3790
4171
|
}
|
|
3791
4172
|
});
|
|
3792
4173
|
|
|
@@ -3928,8 +4309,15 @@ function dispatchRequest(config) {
|
|
|
3928
4309
|
function onAdapterResolution(response) {
|
|
3929
4310
|
throwIfCancellationRequested(config);
|
|
3930
4311
|
|
|
3931
|
-
//
|
|
3932
|
-
|
|
4312
|
+
// Expose the current response on config so that transformResponse can
|
|
4313
|
+
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
4314
|
+
// We clean it up afterwards to avoid polluting the config object.
|
|
4315
|
+
config.response = response;
|
|
4316
|
+
try {
|
|
4317
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
4318
|
+
} finally {
|
|
4319
|
+
delete config.response;
|
|
4320
|
+
}
|
|
3933
4321
|
|
|
3934
4322
|
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3935
4323
|
|
|
@@ -3941,11 +4329,16 @@ function dispatchRequest(config) {
|
|
|
3941
4329
|
|
|
3942
4330
|
// Transform response data
|
|
3943
4331
|
if (reason && reason.response) {
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
4332
|
+
config.response = reason.response;
|
|
4333
|
+
try {
|
|
4334
|
+
reason.response.data = transformData.call(
|
|
4335
|
+
config,
|
|
4336
|
+
config.transformResponse,
|
|
4337
|
+
reason.response
|
|
4338
|
+
);
|
|
4339
|
+
} finally {
|
|
4340
|
+
delete config.response;
|
|
4341
|
+
}
|
|
3949
4342
|
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
3950
4343
|
}
|
|
3951
4344
|
}
|
|
@@ -3955,8 +4348,6 @@ function dispatchRequest(config) {
|
|
|
3955
4348
|
);
|
|
3956
4349
|
}
|
|
3957
4350
|
|
|
3958
|
-
const VERSION$1 = "1.15.2";
|
|
3959
|
-
|
|
3960
4351
|
const validators$1 = {};
|
|
3961
4352
|
|
|
3962
4353
|
// eslint-disable-next-line func-names
|
|
@@ -4041,7 +4432,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
4041
4432
|
while (i-- > 0) {
|
|
4042
4433
|
const opt = keys[i];
|
|
4043
4434
|
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
4044
|
-
// a non-function validator and cause a TypeError.
|
|
4435
|
+
// a non-function validator and cause a TypeError.
|
|
4045
4436
|
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
4046
4437
|
if (validator) {
|
|
4047
4438
|
const value = options[opt];
|
|
@@ -4201,7 +4592,7 @@ let Axios$1 = class Axios {
|
|
|
4201
4592
|
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
4202
4593
|
|
|
4203
4594
|
headers &&
|
|
4204
|
-
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
4595
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
|
|
4205
4596
|
delete headers[method];
|
|
4206
4597
|
});
|
|
4207
4598
|
|
|
@@ -4304,7 +4695,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
4304
4695
|
};
|
|
4305
4696
|
});
|
|
4306
4697
|
|
|
4307
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
4698
|
+
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
4308
4699
|
function generateHTTPMethod(isForm) {
|
|
4309
4700
|
return function httpMethod(url, data, config) {
|
|
4310
4701
|
return this.request(
|
|
@@ -4324,7 +4715,11 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
|
|
|
4324
4715
|
|
|
4325
4716
|
Axios$1.prototype[method] = generateHTTPMethod();
|
|
4326
4717
|
|
|
4327
|
-
|
|
4718
|
+
// QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|
4719
|
+
// its semantics, so no queryForm shorthand is generated.
|
|
4720
|
+
if (method !== 'query') {
|
|
4721
|
+
Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
4722
|
+
}
|
|
4328
4723
|
});
|
|
4329
4724
|
|
|
4330
4725
|
/**
|
|
@@ -4658,6 +5053,7 @@ const {
|
|
|
4658
5053
|
formToJSON,
|
|
4659
5054
|
getAdapter,
|
|
4660
5055
|
mergeConfig,
|
|
5056
|
+
create,
|
|
4661
5057
|
} = axios;
|
|
4662
5058
|
|
|
4663
5059
|
/******************************************************************************
|