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