@kontent-ai/core-sdk 10.12.4 → 10.12.6
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/.npmignore +14 -14
- package/LICENSE.md +9 -9
- package/README.md +30 -30
- package/dist/cjs/sdk-info.generated.js +1 -1
- package/dist/es6/sdk-info.generated.js +1 -1
- package/dist/esnext/sdk-info.generated.js +1 -1
- package/dist/umd/kontent-core.umd.js +2101 -1228
- package/dist/umd/kontent-core.umd.js.map +1 -1
- package/dist/umd/kontent-core.umd.min.js +1 -1
- package/dist/umd/kontent-core.umd.min.js.LICENSE.txt +1 -1
- package/dist/umd/kontent-core.umd.min.js.map +1 -1
- package/dist/umd/report.json +1 -1
- package/dist/umd/report.min.json +1 -1
- package/dist/umd/stats.json +437 -437
- package/dist/umd/stats.min.json +437 -437
- package/lib/helpers/header.helper.ts +23 -23
- package/lib/helpers/headers-helper.ts +15 -15
- package/lib/helpers/index.ts +4 -4
- package/lib/helpers/retry-helper.ts +204 -204
- package/lib/helpers/url.helper.ts +26 -26
- package/lib/http/http.debugger.ts +21 -21
- package/lib/http/http.functions.ts +314 -314
- package/lib/http/http.models.ts +83 -83
- package/lib/http/http.service.ts +91 -91
- package/lib/http/ihttp.service.ts +20 -20
- package/lib/http/index.ts +6 -6
- package/lib/http/test-http.service.ts +70 -70
- package/lib/index.ts +4 -4
- package/lib/models/index.ts +3 -3
- package/lib/models/isdk-info.ts +15 -15
- package/lib/models/parameters.ts +25 -25
- package/lib/models/url.models.ts +3 -3
- package/lib/sdk-info.generated.ts +1 -1
- package/package.json +93 -93
|
@@ -899,7 +899,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
899
899
|
\***************************************************/
|
|
900
900
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
901
901
|
|
|
902
|
-
/*! Axios v1.
|
|
902
|
+
/*! Axios v1.18.1 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
903
903
|
|
|
904
904
|
|
|
905
905
|
/**
|
|
@@ -921,6 +921,57 @@ const { toString } = Object.prototype;
|
|
|
921
921
|
const { getPrototypeOf } = Object;
|
|
922
922
|
const { iterator, toStringTag } = Symbol;
|
|
923
923
|
|
|
924
|
+
/* Creating a function that will check if an object has a property. */
|
|
925
|
+
const hasOwnProperty = (
|
|
926
|
+
({ hasOwnProperty }) =>
|
|
927
|
+
(obj, prop) =>
|
|
928
|
+
hasOwnProperty.call(obj, prop)
|
|
929
|
+
)(Object.prototype);
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Walk the prototype chain (excluding the shared Object.prototype) looking for
|
|
933
|
+
* an own `prop`. This distinguishes genuine own/inherited members — including
|
|
934
|
+
* class accessors and template prototypes — from members injected via
|
|
935
|
+
* Object.prototype pollution (e.g. `Object.prototype.username = '...'`), which
|
|
936
|
+
* live on Object.prototype itself and are therefore never matched.
|
|
937
|
+
*
|
|
938
|
+
* @param {*} thing The value whose chain to inspect
|
|
939
|
+
* @param {string|symbol} prop The property key to look for
|
|
940
|
+
*
|
|
941
|
+
* @returns {boolean} True when `prop` is owned below Object.prototype
|
|
942
|
+
*/
|
|
943
|
+
const hasOwnInPrototypeChain = (thing, prop) => {
|
|
944
|
+
let obj = thing;
|
|
945
|
+
const seen = [];
|
|
946
|
+
|
|
947
|
+
while (obj != null && obj !== Object.prototype) {
|
|
948
|
+
if (seen.indexOf(obj) !== -1) {
|
|
949
|
+
return false;
|
|
950
|
+
}
|
|
951
|
+
seen.push(obj);
|
|
952
|
+
|
|
953
|
+
if (hasOwnProperty(obj, prop)) {
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
obj = getPrototypeOf(obj);
|
|
957
|
+
}
|
|
958
|
+
return false;
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
|
|
963
|
+
* properties and members inherited from a non-Object.prototype source (a class
|
|
964
|
+
* instance or template object) are honored; a value reachable only through a
|
|
965
|
+
* polluted Object.prototype is ignored and `undefined` is returned.
|
|
966
|
+
*
|
|
967
|
+
* @param {*} obj The source object
|
|
968
|
+
* @param {string|symbol} prop The property key to read
|
|
969
|
+
*
|
|
970
|
+
* @returns {*} The resolved value, or undefined when unsafe/absent
|
|
971
|
+
*/
|
|
972
|
+
const getSafeProp = (obj, prop) =>
|
|
973
|
+
obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
|
|
974
|
+
|
|
924
975
|
const kindOf = ((cache) => (thing) => {
|
|
925
976
|
const str = toString.call(thing);
|
|
926
977
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -1046,7 +1097,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
1046
1097
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
1047
1098
|
*/
|
|
1048
1099
|
const isPlainObject = (val) => {
|
|
1049
|
-
if (
|
|
1100
|
+
if (!isObject(val)) {
|
|
1050
1101
|
return false;
|
|
1051
1102
|
}
|
|
1052
1103
|
|
|
@@ -1054,9 +1105,12 @@ const isPlainObject = (val) => {
|
|
|
1054
1105
|
return (
|
|
1055
1106
|
(prototype === null ||
|
|
1056
1107
|
prototype === Object.prototype ||
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1108
|
+
getPrototypeOf(prototype) === null) &&
|
|
1109
|
+
// Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
|
|
1110
|
+
// Symbol.iterator as evidence the value is a tagged/iterable type rather
|
|
1111
|
+
// than a plain object, while ignoring keys injected onto Object.prototype.
|
|
1112
|
+
!hasOwnInPrototypeChain(val, toStringTag) &&
|
|
1113
|
+
!hasOwnInPrototypeChain(val, iterator)
|
|
1060
1114
|
);
|
|
1061
1115
|
};
|
|
1062
1116
|
|
|
@@ -1105,9 +1159,9 @@ const isFile = kindOfTest('File');
|
|
|
1105
1159
|
* also have a `name` and `type` attribute to specify filename and content type
|
|
1106
1160
|
*
|
|
1107
1161
|
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
1108
|
-
*
|
|
1162
|
+
*
|
|
1109
1163
|
* @param {*} value The value to test
|
|
1110
|
-
*
|
|
1164
|
+
*
|
|
1111
1165
|
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
1112
1166
|
*/
|
|
1113
1167
|
const isReactNativeBlob = (value) => {
|
|
@@ -1117,9 +1171,9 @@ const isReactNativeBlob = (value) => {
|
|
|
1117
1171
|
/**
|
|
1118
1172
|
* Determine if environment is React Native
|
|
1119
1173
|
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
1120
|
-
*
|
|
1174
|
+
*
|
|
1121
1175
|
* @param {*} formData The formData to test
|
|
1122
|
-
*
|
|
1176
|
+
*
|
|
1123
1177
|
* @returns {boolean} True if environment is React Native, otherwise false
|
|
1124
1178
|
*/
|
|
1125
1179
|
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
@@ -1138,7 +1192,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
1138
1192
|
*
|
|
1139
1193
|
* @param {*} val The value to test
|
|
1140
1194
|
*
|
|
1141
|
-
* @returns {boolean} True if value is a
|
|
1195
|
+
* @returns {boolean} True if value is a FileList, otherwise false
|
|
1142
1196
|
*/
|
|
1143
1197
|
const isFileList = kindOfTest('FileList');
|
|
1144
1198
|
|
|
@@ -1170,15 +1224,17 @@ const G = getGlobal();
|
|
|
1170
1224
|
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
1171
1225
|
|
|
1172
1226
|
const isFormData = (thing) => {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1227
|
+
if (!thing) return false;
|
|
1228
|
+
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
1229
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
1230
|
+
const proto = getPrototypeOf(thing);
|
|
1231
|
+
if (!proto || proto === Object.prototype) return false;
|
|
1232
|
+
if (!isFunction$1(thing.append)) return false;
|
|
1233
|
+
const kind = kindOf(thing);
|
|
1234
|
+
return (
|
|
1235
|
+
kind === 'formdata' ||
|
|
1236
|
+
// detect form-data instance
|
|
1237
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
1182
1238
|
);
|
|
1183
1239
|
};
|
|
1184
1240
|
|
|
@@ -1314,7 +1370,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
1314
1370
|
*
|
|
1315
1371
|
* @returns {Object} Result of all merge properties
|
|
1316
1372
|
*/
|
|
1317
|
-
function merge(
|
|
1373
|
+
function merge(...objs) {
|
|
1318
1374
|
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
1319
1375
|
const result = {};
|
|
1320
1376
|
const assignValue = (val, key) => {
|
|
@@ -1323,9 +1379,15 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
1323
1379
|
return;
|
|
1324
1380
|
}
|
|
1325
1381
|
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1382
|
+
// findKey lowercases the key, so caseless lookup only applies to strings —
|
|
1383
|
+
// symbol keys are identity-matched.
|
|
1384
|
+
const targetKey = (caseless && typeof key === 'string' && findKey(result, key)) || key;
|
|
1385
|
+
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
1386
|
+
// chain, so a polluted Object.prototype value could surface here and get
|
|
1387
|
+
// copied into the merged result.
|
|
1388
|
+
const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
|
|
1389
|
+
if (isPlainObject(existing) && isPlainObject(val)) {
|
|
1390
|
+
result[targetKey] = merge(existing, val);
|
|
1329
1391
|
} else if (isPlainObject(val)) {
|
|
1330
1392
|
result[targetKey] = merge({}, val);
|
|
1331
1393
|
} else if (isArray(val)) {
|
|
@@ -1335,8 +1397,25 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
1335
1397
|
}
|
|
1336
1398
|
};
|
|
1337
1399
|
|
|
1338
|
-
for (let i = 0, l =
|
|
1339
|
-
|
|
1400
|
+
for (let i = 0, l = objs.length; i < l; i++) {
|
|
1401
|
+
const source = objs[i];
|
|
1402
|
+
if (!source || isBuffer(source)) {
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
forEach(source, assignValue);
|
|
1407
|
+
|
|
1408
|
+
if (typeof source !== 'object' || isArray(source)) {
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
const symbols = Object.getOwnPropertySymbols(source);
|
|
1413
|
+
for (let j = 0; j < symbols.length; j++) {
|
|
1414
|
+
const symbol = symbols[j];
|
|
1415
|
+
if (propertyIsEnumerable.call(source, symbol)) {
|
|
1416
|
+
assignValue(source[symbol], symbol);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1340
1419
|
}
|
|
1341
1420
|
return result;
|
|
1342
1421
|
}
|
|
@@ -1358,6 +1437,9 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
1358
1437
|
(val, key) => {
|
|
1359
1438
|
if (thisArg && isFunction$1(val)) {
|
|
1360
1439
|
Object.defineProperty(a, key, {
|
|
1440
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot
|
|
1441
|
+
// hijack defineProperty's accessor-vs-data resolution.
|
|
1442
|
+
__proto__: null,
|
|
1361
1443
|
value: bind(val, thisArg),
|
|
1362
1444
|
writable: true,
|
|
1363
1445
|
enumerable: true,
|
|
@@ -1365,6 +1447,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
1365
1447
|
});
|
|
1366
1448
|
} else {
|
|
1367
1449
|
Object.defineProperty(a, key, {
|
|
1450
|
+
__proto__: null,
|
|
1368
1451
|
value: val,
|
|
1369
1452
|
writable: true,
|
|
1370
1453
|
enumerable: true,
|
|
@@ -1403,12 +1486,14 @@ const stripBOM = (content) => {
|
|
|
1403
1486
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
1404
1487
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
1405
1488
|
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
1489
|
+
__proto__: null,
|
|
1406
1490
|
value: constructor,
|
|
1407
1491
|
writable: true,
|
|
1408
1492
|
enumerable: false,
|
|
1409
1493
|
configurable: true,
|
|
1410
1494
|
});
|
|
1411
1495
|
Object.defineProperty(constructor, 'super', {
|
|
1496
|
+
__proto__: null,
|
|
1412
1497
|
value: superConstructor.prototype,
|
|
1413
1498
|
});
|
|
1414
1499
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -1552,12 +1637,7 @@ const toCamelCase = (str) => {
|
|
|
1552
1637
|
});
|
|
1553
1638
|
};
|
|
1554
1639
|
|
|
1555
|
-
|
|
1556
|
-
const hasOwnProperty = (
|
|
1557
|
-
({ hasOwnProperty }) =>
|
|
1558
|
-
(obj, prop) =>
|
|
1559
|
-
hasOwnProperty.call(obj, prop)
|
|
1560
|
-
)(Object.prototype);
|
|
1640
|
+
const { propertyIsEnumerable } = Object.prototype;
|
|
1561
1641
|
|
|
1562
1642
|
/**
|
|
1563
1643
|
* Determine if a value is a RegExp object
|
|
@@ -1590,7 +1670,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
1590
1670
|
const freezeMethods = (obj) => {
|
|
1591
1671
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
1592
1672
|
// skip restricted props in strict mode
|
|
1593
|
-
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].
|
|
1673
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
|
1594
1674
|
return false;
|
|
1595
1675
|
}
|
|
1596
1676
|
|
|
@@ -1664,11 +1744,11 @@ function isSpecCompliantForm(thing) {
|
|
|
1664
1744
|
* @returns {Object} The JSON-compatible object.
|
|
1665
1745
|
*/
|
|
1666
1746
|
const toJSONObject = (obj) => {
|
|
1667
|
-
const
|
|
1747
|
+
const visited = new WeakSet();
|
|
1668
1748
|
|
|
1669
|
-
const visit = (source
|
|
1749
|
+
const visit = (source) => {
|
|
1670
1750
|
if (isObject(source)) {
|
|
1671
|
-
if (
|
|
1751
|
+
if (visited.has(source)) {
|
|
1672
1752
|
return;
|
|
1673
1753
|
}
|
|
1674
1754
|
|
|
@@ -1678,15 +1758,16 @@ const toJSONObject = (obj) => {
|
|
|
1678
1758
|
}
|
|
1679
1759
|
|
|
1680
1760
|
if (!('toJSON' in source)) {
|
|
1681
|
-
|
|
1761
|
+
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
1762
|
+
visited.add(source);
|
|
1682
1763
|
const target = isArray(source) ? [] : {};
|
|
1683
1764
|
|
|
1684
1765
|
forEach(source, (value, key) => {
|
|
1685
|
-
const reducedValue = visit(value
|
|
1766
|
+
const reducedValue = visit(value);
|
|
1686
1767
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
1687
1768
|
});
|
|
1688
1769
|
|
|
1689
|
-
|
|
1770
|
+
visited.delete(source);
|
|
1690
1771
|
|
|
1691
1772
|
return target;
|
|
1692
1773
|
}
|
|
@@ -1695,7 +1776,7 @@ const toJSONObject = (obj) => {
|
|
|
1695
1776
|
return source;
|
|
1696
1777
|
};
|
|
1697
1778
|
|
|
1698
|
-
return visit(obj
|
|
1779
|
+
return visit(obj);
|
|
1699
1780
|
};
|
|
1700
1781
|
|
|
1701
1782
|
/**
|
|
@@ -1769,6 +1850,20 @@ const asap =
|
|
|
1769
1850
|
|
|
1770
1851
|
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
1771
1852
|
|
|
1853
|
+
/**
|
|
1854
|
+
* Determine if a value is iterable via an iterator that is NOT sourced solely
|
|
1855
|
+
* from a polluted Object.prototype. Use this instead of `isIterable` whenever
|
|
1856
|
+
* the iterable comes from untrusted input (e.g. user-supplied header sources),
|
|
1857
|
+
* so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
|
|
1858
|
+
* into an attacker-controlled entries iterator.
|
|
1859
|
+
*
|
|
1860
|
+
* @param {*} thing The value to test
|
|
1861
|
+
*
|
|
1862
|
+
* @returns {boolean} True if value has a non-polluted iterator
|
|
1863
|
+
*/
|
|
1864
|
+
const isSafeIterable = (thing) =>
|
|
1865
|
+
thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
|
|
1866
|
+
|
|
1772
1867
|
var utils$1 = {
|
|
1773
1868
|
isArray,
|
|
1774
1869
|
isArrayBuffer,
|
|
@@ -1813,6 +1908,8 @@ var utils$1 = {
|
|
|
1813
1908
|
isHTMLForm,
|
|
1814
1909
|
hasOwnProperty,
|
|
1815
1910
|
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
|
1911
|
+
hasOwnInPrototypeChain,
|
|
1912
|
+
getSafeProp,
|
|
1816
1913
|
reduceDescriptors,
|
|
1817
1914
|
freezeMethods,
|
|
1818
1915
|
toObjectSet,
|
|
@@ -1829,1299 +1926,1499 @@ var utils$1 = {
|
|
|
1829
1926
|
setImmediate: _setImmediate,
|
|
1830
1927
|
asap,
|
|
1831
1928
|
isIterable,
|
|
1929
|
+
isSafeIterable,
|
|
1832
1930
|
};
|
|
1833
1931
|
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1932
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1933
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1934
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1935
|
+
'age',
|
|
1936
|
+
'authorization',
|
|
1937
|
+
'content-length',
|
|
1938
|
+
'content-type',
|
|
1939
|
+
'etag',
|
|
1940
|
+
'expires',
|
|
1941
|
+
'from',
|
|
1942
|
+
'host',
|
|
1943
|
+
'if-modified-since',
|
|
1944
|
+
'if-unmodified-since',
|
|
1945
|
+
'last-modified',
|
|
1946
|
+
'location',
|
|
1947
|
+
'max-forwards',
|
|
1948
|
+
'proxy-authorization',
|
|
1949
|
+
'referer',
|
|
1950
|
+
'retry-after',
|
|
1951
|
+
'user-agent',
|
|
1952
|
+
]);
|
|
1839
1953
|
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1954
|
+
/**
|
|
1955
|
+
* Parse headers into an object
|
|
1956
|
+
*
|
|
1957
|
+
* ```
|
|
1958
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
1959
|
+
* Content-Type: application/json
|
|
1960
|
+
* Connection: keep-alive
|
|
1961
|
+
* Transfer-Encoding: chunked
|
|
1962
|
+
* ```
|
|
1963
|
+
*
|
|
1964
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
|
1965
|
+
*
|
|
1966
|
+
* @returns {Object} Headers parsed into an object
|
|
1967
|
+
*/
|
|
1968
|
+
var parseHeaders = (rawHeaders) => {
|
|
1969
|
+
const parsed = {};
|
|
1970
|
+
let key;
|
|
1971
|
+
let val;
|
|
1972
|
+
let i;
|
|
1973
|
+
|
|
1974
|
+
rawHeaders &&
|
|
1975
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
1976
|
+
i = line.indexOf(':');
|
|
1977
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1978
|
+
val = line.substring(i + 1).trim();
|
|
1979
|
+
|
|
1980
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
1981
|
+
return;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
if (key === 'set-cookie') {
|
|
1985
|
+
if (parsed[key]) {
|
|
1986
|
+
parsed[key].push(val);
|
|
1987
|
+
} else {
|
|
1988
|
+
parsed[key] = [val];
|
|
1989
|
+
}
|
|
1990
|
+
} else {
|
|
1991
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1992
|
+
}
|
|
1993
|
+
});
|
|
1994
|
+
|
|
1995
|
+
return parsed;
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1998
|
+
function trimSPorHTAB(str) {
|
|
1999
|
+
let start = 0;
|
|
2000
|
+
let end = str.length;
|
|
2001
|
+
|
|
2002
|
+
while (start < end) {
|
|
2003
|
+
const code = str.charCodeAt(start);
|
|
2004
|
+
|
|
2005
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2006
|
+
break;
|
|
1843
2007
|
}
|
|
1844
2008
|
|
|
1845
|
-
|
|
1846
|
-
return axiosError;
|
|
2009
|
+
start += 1;
|
|
1847
2010
|
}
|
|
1848
2011
|
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
* @param {Object} [config] The config.
|
|
1855
|
-
* @param {Object} [request] The request.
|
|
1856
|
-
* @param {Object} [response] The response.
|
|
1857
|
-
*
|
|
1858
|
-
* @returns {Error} The created error.
|
|
1859
|
-
*/
|
|
1860
|
-
constructor(message, code, config, request, response) {
|
|
1861
|
-
super(message);
|
|
1862
|
-
|
|
1863
|
-
// Make message enumerable to maintain backward compatibility
|
|
1864
|
-
// The native Error constructor sets message as non-enumerable,
|
|
1865
|
-
// but axios < v1.13.3 had it as enumerable
|
|
1866
|
-
Object.defineProperty(this, 'message', {
|
|
1867
|
-
value: message,
|
|
1868
|
-
enumerable: true,
|
|
1869
|
-
writable: true,
|
|
1870
|
-
configurable: true
|
|
1871
|
-
});
|
|
1872
|
-
|
|
1873
|
-
this.name = 'AxiosError';
|
|
1874
|
-
this.isAxiosError = true;
|
|
1875
|
-
code && (this.code = code);
|
|
1876
|
-
config && (this.config = config);
|
|
1877
|
-
request && (this.request = request);
|
|
1878
|
-
if (response) {
|
|
1879
|
-
this.response = response;
|
|
1880
|
-
this.status = response.status;
|
|
1881
|
-
}
|
|
2012
|
+
while (end > start) {
|
|
2013
|
+
const code = str.charCodeAt(end - 1);
|
|
2014
|
+
|
|
2015
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2016
|
+
break;
|
|
1882
2017
|
}
|
|
1883
2018
|
|
|
1884
|
-
|
|
1885
|
-
return {
|
|
1886
|
-
// Standard
|
|
1887
|
-
message: this.message,
|
|
1888
|
-
name: this.name,
|
|
1889
|
-
// Microsoft
|
|
1890
|
-
description: this.description,
|
|
1891
|
-
number: this.number,
|
|
1892
|
-
// Mozilla
|
|
1893
|
-
fileName: this.fileName,
|
|
1894
|
-
lineNumber: this.lineNumber,
|
|
1895
|
-
columnNumber: this.columnNumber,
|
|
1896
|
-
stack: this.stack,
|
|
1897
|
-
// Axios
|
|
1898
|
-
config: utils$1.toJSONObject(this.config),
|
|
1899
|
-
code: this.code,
|
|
1900
|
-
status: this.status,
|
|
1901
|
-
};
|
|
2019
|
+
end -= 1;
|
|
1902
2020
|
}
|
|
2021
|
+
|
|
2022
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
1903
2023
|
}
|
|
1904
2024
|
|
|
1905
|
-
//
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
1911
|
-
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1912
|
-
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1913
|
-
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1914
|
-
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1915
|
-
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
1916
|
-
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1917
|
-
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
2025
|
+
// The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
|
|
2026
|
+
// eslint-disable-next-line no-control-regex
|
|
2027
|
+
const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
|
|
2028
|
+
// eslint-disable-next-line no-control-regex
|
|
2029
|
+
const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
|
|
1918
2030
|
|
|
1919
|
-
|
|
1920
|
-
|
|
2031
|
+
function sanitizeValue(value, invalidChars) {
|
|
2032
|
+
if (utils$1.isArray(value)) {
|
|
2033
|
+
return value.map((item) => sanitizeValue(item, invalidChars));
|
|
2034
|
+
}
|
|
1921
2035
|
|
|
1922
|
-
|
|
1923
|
-
* Determines if the given thing is a array or js object.
|
|
1924
|
-
*
|
|
1925
|
-
* @param {string} thing - The object or array to be visited.
|
|
1926
|
-
*
|
|
1927
|
-
* @returns {boolean}
|
|
1928
|
-
*/
|
|
1929
|
-
function isVisitable(thing) {
|
|
1930
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
2036
|
+
return trimSPorHTAB(String(value).replace(invalidChars, ''));
|
|
1931
2037
|
}
|
|
1932
2038
|
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
*
|
|
1936
|
-
* @param {string} key - The key of the parameter.
|
|
1937
|
-
*
|
|
1938
|
-
* @returns {string} the key without the brackets.
|
|
1939
|
-
*/
|
|
1940
|
-
function removeBrackets(key) {
|
|
1941
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1942
|
-
}
|
|
2039
|
+
const sanitizeHeaderValue = (value) =>
|
|
2040
|
+
sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
|
|
1943
2041
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
return path
|
|
1956
|
-
.concat(key)
|
|
1957
|
-
.map(function each(token, i) {
|
|
1958
|
-
// eslint-disable-next-line no-param-reassign
|
|
1959
|
-
token = removeBrackets(token);
|
|
1960
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
1961
|
-
})
|
|
1962
|
-
.join(dots ? '.' : '');
|
|
2042
|
+
const sanitizeByteStringHeaderValue = (value) =>
|
|
2043
|
+
sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
|
|
2044
|
+
|
|
2045
|
+
function toByteStringHeaderObject(headers) {
|
|
2046
|
+
const byteStringHeaders = Object.create(null);
|
|
2047
|
+
|
|
2048
|
+
utils$1.forEach(headers.toJSON(), (value, header) => {
|
|
2049
|
+
byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
|
|
2050
|
+
});
|
|
2051
|
+
|
|
2052
|
+
return byteStringHeaders;
|
|
1963
2053
|
}
|
|
1964
2054
|
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
*
|
|
1970
|
-
* @returns {boolean}
|
|
1971
|
-
*/
|
|
1972
|
-
function isFlatArray(arr) {
|
|
1973
|
-
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
2055
|
+
const $internals = Symbol('internals');
|
|
2056
|
+
|
|
2057
|
+
function normalizeHeader(header) {
|
|
2058
|
+
return header && String(header).trim().toLowerCase();
|
|
1974
2059
|
}
|
|
1975
2060
|
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2061
|
+
function normalizeValue(value) {
|
|
2062
|
+
if (value === false || value == null) {
|
|
2063
|
+
return value;
|
|
2064
|
+
}
|
|
1979
2065
|
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
*
|
|
1983
|
-
* @param {Object} obj
|
|
1984
|
-
* @param {?Object} [formData]
|
|
1985
|
-
* @param {?Object} [options]
|
|
1986
|
-
* @param {Function} [options.visitor]
|
|
1987
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
1988
|
-
* @param {Boolean} [options.dots = false]
|
|
1989
|
-
* @param {?Boolean} [options.indexes = false]
|
|
1990
|
-
*
|
|
1991
|
-
* @returns {Object}
|
|
1992
|
-
**/
|
|
2066
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
2067
|
+
}
|
|
1993
2068
|
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
*
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
* @returns
|
|
2002
|
-
*/
|
|
2003
|
-
function toFormData(obj, formData, options) {
|
|
2004
|
-
if (!utils$1.isObject(obj)) {
|
|
2005
|
-
throw new TypeError('target must be an object');
|
|
2069
|
+
function parseTokens(str) {
|
|
2070
|
+
const tokens = Object.create(null);
|
|
2071
|
+
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
2072
|
+
let match;
|
|
2073
|
+
|
|
2074
|
+
while ((match = tokensRE.exec(str))) {
|
|
2075
|
+
tokens[match[1]] = match[2];
|
|
2006
2076
|
}
|
|
2007
2077
|
|
|
2008
|
-
|
|
2009
|
-
|
|
2078
|
+
return tokens;
|
|
2079
|
+
}
|
|
2010
2080
|
|
|
2011
|
-
|
|
2012
|
-
options = utils$1.toFlatObject(
|
|
2013
|
-
options,
|
|
2014
|
-
{
|
|
2015
|
-
metaTokens: true,
|
|
2016
|
-
dots: false,
|
|
2017
|
-
indexes: false,
|
|
2018
|
-
},
|
|
2019
|
-
false,
|
|
2020
|
-
function defined(option, source) {
|
|
2021
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
2022
|
-
return !utils$1.isUndefined(source[option]);
|
|
2023
|
-
}
|
|
2024
|
-
);
|
|
2081
|
+
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
2025
2082
|
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
const indexes = options.indexes;
|
|
2031
|
-
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
2032
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
2083
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
2084
|
+
if (utils$1.isFunction(filter)) {
|
|
2085
|
+
return filter.call(this, value, header);
|
|
2086
|
+
}
|
|
2033
2087
|
|
|
2034
|
-
if (
|
|
2035
|
-
|
|
2088
|
+
if (isHeaderNameFilter) {
|
|
2089
|
+
value = header;
|
|
2036
2090
|
}
|
|
2037
2091
|
|
|
2038
|
-
|
|
2039
|
-
if (value === null) return '';
|
|
2092
|
+
if (!utils$1.isString(value)) return;
|
|
2040
2093
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2094
|
+
if (utils$1.isString(filter)) {
|
|
2095
|
+
return value.indexOf(filter) !== -1;
|
|
2096
|
+
}
|
|
2044
2097
|
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2098
|
+
if (utils$1.isRegExp(filter)) {
|
|
2099
|
+
return filter.test(value);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2048
2102
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2103
|
+
function formatHeader(header) {
|
|
2104
|
+
return header
|
|
2105
|
+
.trim()
|
|
2106
|
+
.toLowerCase()
|
|
2107
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
2108
|
+
return char.toUpperCase() + str;
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2052
2111
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
}
|
|
2112
|
+
function buildAccessors(obj, header) {
|
|
2113
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
2056
2114
|
|
|
2057
|
-
|
|
2115
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
2116
|
+
Object.defineProperty(obj, methodName + accessorName, {
|
|
2117
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
2118
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
2119
|
+
__proto__: null,
|
|
2120
|
+
value: function (arg1, arg2, arg3) {
|
|
2121
|
+
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
2122
|
+
},
|
|
2123
|
+
configurable: true,
|
|
2124
|
+
});
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
class AxiosHeaders {
|
|
2129
|
+
constructor(headers) {
|
|
2130
|
+
headers && this.set(headers);
|
|
2058
2131
|
}
|
|
2059
2132
|
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
*
|
|
2063
|
-
* @param {*} value
|
|
2064
|
-
* @param {String|Number} key
|
|
2065
|
-
* @param {Array<String|Number>} path
|
|
2066
|
-
* @this {FormData}
|
|
2067
|
-
*
|
|
2068
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
2069
|
-
*/
|
|
2070
|
-
function defaultVisitor(value, key, path) {
|
|
2071
|
-
let arr = value;
|
|
2133
|
+
set(header, valueOrRewrite, rewrite) {
|
|
2134
|
+
const self = this;
|
|
2072
2135
|
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
return false;
|
|
2076
|
-
}
|
|
2136
|
+
function setHeader(_value, _header, _rewrite) {
|
|
2137
|
+
const lHeader = normalizeHeader(_header);
|
|
2077
2138
|
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
key = metaTokens ? key : key.slice(0, -2);
|
|
2082
|
-
// eslint-disable-next-line no-param-reassign
|
|
2083
|
-
value = JSON.stringify(value);
|
|
2084
|
-
} else if (
|
|
2085
|
-
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
2086
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
2087
|
-
) {
|
|
2088
|
-
// eslint-disable-next-line no-param-reassign
|
|
2089
|
-
key = removeBrackets(key);
|
|
2139
|
+
if (!lHeader) {
|
|
2140
|
+
return;
|
|
2141
|
+
}
|
|
2090
2142
|
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
convertValue(el)
|
|
2101
|
-
);
|
|
2102
|
-
});
|
|
2103
|
-
return false;
|
|
2143
|
+
const key = utils$1.findKey(self, lHeader);
|
|
2144
|
+
|
|
2145
|
+
if (
|
|
2146
|
+
!key ||
|
|
2147
|
+
self[key] === undefined ||
|
|
2148
|
+
_rewrite === true ||
|
|
2149
|
+
(_rewrite === undefined && self[key] !== false)
|
|
2150
|
+
) {
|
|
2151
|
+
self[key || _header] = normalizeValue(_value);
|
|
2104
2152
|
}
|
|
2105
2153
|
}
|
|
2106
2154
|
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
}
|
|
2155
|
+
const setHeaders = (headers, _rewrite) =>
|
|
2156
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
2110
2157
|
|
|
2111
|
-
|
|
2158
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
2159
|
+
setHeaders(header, valueOrRewrite);
|
|
2160
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2161
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
2162
|
+
} else if (utils$1.isObject(header) && utils$1.isSafeIterable(header)) {
|
|
2163
|
+
let obj = Object.create(null),
|
|
2164
|
+
dest,
|
|
2165
|
+
key;
|
|
2166
|
+
for (const entry of header) {
|
|
2167
|
+
if (!utils$1.isArray(entry)) {
|
|
2168
|
+
throw new TypeError('Object iterator must return a key-value pair');
|
|
2169
|
+
}
|
|
2112
2170
|
|
|
2113
|
-
|
|
2171
|
+
key = entry[0];
|
|
2172
|
+
|
|
2173
|
+
if (utils$1.hasOwnProp(obj, key)) {
|
|
2174
|
+
dest = obj[key];
|
|
2175
|
+
obj[key] = utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]];
|
|
2176
|
+
} else {
|
|
2177
|
+
obj[key] = entry[1];
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
setHeaders(obj, valueOrRewrite);
|
|
2182
|
+
} else {
|
|
2183
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
return this;
|
|
2114
2187
|
}
|
|
2115
2188
|
|
|
2116
|
-
|
|
2189
|
+
get(header, parser) {
|
|
2190
|
+
header = normalizeHeader(header);
|
|
2117
2191
|
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
convertValue,
|
|
2121
|
-
isVisitable,
|
|
2122
|
-
});
|
|
2192
|
+
if (header) {
|
|
2193
|
+
const key = utils$1.findKey(this, header);
|
|
2123
2194
|
|
|
2124
|
-
|
|
2125
|
-
|
|
2195
|
+
if (key) {
|
|
2196
|
+
const value = this[key];
|
|
2126
2197
|
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2198
|
+
if (!parser) {
|
|
2199
|
+
return value;
|
|
2200
|
+
}
|
|
2130
2201
|
|
|
2131
|
-
|
|
2202
|
+
if (parser === true) {
|
|
2203
|
+
return parseTokens(value);
|
|
2204
|
+
}
|
|
2132
2205
|
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
2206
|
+
if (utils$1.isFunction(parser)) {
|
|
2207
|
+
return parser.call(this, value, key);
|
|
2208
|
+
}
|
|
2137
2209
|
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
});
|
|
2210
|
+
if (utils$1.isRegExp(parser)) {
|
|
2211
|
+
return parser.exec(value);
|
|
2212
|
+
}
|
|
2142
2213
|
|
|
2143
|
-
|
|
2214
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2144
2217
|
}
|
|
2145
2218
|
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
}
|
|
2219
|
+
has(header, matcher) {
|
|
2220
|
+
header = normalizeHeader(header);
|
|
2149
2221
|
|
|
2150
|
-
|
|
2222
|
+
if (header) {
|
|
2223
|
+
const key = utils$1.findKey(this, header);
|
|
2151
2224
|
|
|
2152
|
-
|
|
2153
|
-
|
|
2225
|
+
return !!(
|
|
2226
|
+
key &&
|
|
2227
|
+
this[key] !== undefined &&
|
|
2228
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2229
|
+
);
|
|
2230
|
+
}
|
|
2154
2231
|
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
* their percent-encoded equivalents
|
|
2158
|
-
*
|
|
2159
|
-
* @param {string} str - The string to encode.
|
|
2160
|
-
*
|
|
2161
|
-
* @returns {string} The encoded string.
|
|
2162
|
-
*/
|
|
2163
|
-
function encode$1(str) {
|
|
2164
|
-
const charMap = {
|
|
2165
|
-
'!': '%21',
|
|
2166
|
-
"'": '%27',
|
|
2167
|
-
'(': '%28',
|
|
2168
|
-
')': '%29',
|
|
2169
|
-
'~': '%7E',
|
|
2170
|
-
'%20': '+',
|
|
2171
|
-
'%00': '\x00',
|
|
2172
|
-
};
|
|
2173
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
2174
|
-
return charMap[match];
|
|
2175
|
-
});
|
|
2176
|
-
}
|
|
2232
|
+
return false;
|
|
2233
|
+
}
|
|
2177
2234
|
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
2182
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
2183
|
-
*
|
|
2184
|
-
* @returns {void}
|
|
2185
|
-
*/
|
|
2186
|
-
function AxiosURLSearchParams(params, options) {
|
|
2187
|
-
this._pairs = [];
|
|
2235
|
+
delete(header, matcher) {
|
|
2236
|
+
const self = this;
|
|
2237
|
+
let deleted = false;
|
|
2188
2238
|
|
|
2189
|
-
|
|
2190
|
-
|
|
2239
|
+
function deleteHeader(_header) {
|
|
2240
|
+
_header = normalizeHeader(_header);
|
|
2191
2241
|
|
|
2192
|
-
|
|
2242
|
+
if (_header) {
|
|
2243
|
+
const key = utils$1.findKey(self, _header);
|
|
2193
2244
|
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
};
|
|
2245
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
2246
|
+
delete self[key];
|
|
2197
2247
|
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
? function (value) {
|
|
2201
|
-
return encoder.call(this, value, encode$1);
|
|
2248
|
+
deleted = true;
|
|
2249
|
+
}
|
|
2202
2250
|
}
|
|
2203
|
-
|
|
2251
|
+
}
|
|
2204
2252
|
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
};
|
|
2253
|
+
if (utils$1.isArray(header)) {
|
|
2254
|
+
header.forEach(deleteHeader);
|
|
2255
|
+
} else {
|
|
2256
|
+
deleteHeader(header);
|
|
2257
|
+
}
|
|
2211
2258
|
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
2215
|
-
*
|
|
2216
|
-
* @param {string} val The value to be encoded.
|
|
2217
|
-
*
|
|
2218
|
-
* @returns {string} The encoded value.
|
|
2219
|
-
*/
|
|
2220
|
-
function encode(val) {
|
|
2221
|
-
return encodeURIComponent(val)
|
|
2222
|
-
.replace(/%3A/gi, ':')
|
|
2223
|
-
.replace(/%24/g, '$')
|
|
2224
|
-
.replace(/%2C/gi, ',')
|
|
2225
|
-
.replace(/%20/g, '+');
|
|
2226
|
-
}
|
|
2259
|
+
return deleted;
|
|
2260
|
+
}
|
|
2227
2261
|
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2262
|
+
clear(matcher) {
|
|
2263
|
+
const keys = Object.keys(this);
|
|
2264
|
+
let i = keys.length;
|
|
2265
|
+
let deleted = false;
|
|
2266
|
+
|
|
2267
|
+
while (i--) {
|
|
2268
|
+
const key = keys[i];
|
|
2269
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2270
|
+
delete this[key];
|
|
2271
|
+
deleted = true;
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
return deleted;
|
|
2240
2276
|
}
|
|
2241
2277
|
|
|
2242
|
-
|
|
2278
|
+
normalize(format) {
|
|
2279
|
+
const self = this;
|
|
2280
|
+
const headers = {};
|
|
2243
2281
|
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2282
|
+
utils$1.forEach(this, (value, header) => {
|
|
2283
|
+
const key = utils$1.findKey(headers, header);
|
|
2284
|
+
|
|
2285
|
+
if (key) {
|
|
2286
|
+
self[key] = normalizeValue(value);
|
|
2287
|
+
delete self[header];
|
|
2288
|
+
return;
|
|
2247
2289
|
}
|
|
2248
|
-
: options;
|
|
2249
2290
|
|
|
2250
|
-
|
|
2291
|
+
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
2251
2292
|
|
|
2252
|
-
|
|
2293
|
+
if (normalized !== header) {
|
|
2294
|
+
delete self[header];
|
|
2295
|
+
}
|
|
2253
2296
|
|
|
2254
|
-
|
|
2255
|
-
serializedParams = serializeFn(params, _options);
|
|
2256
|
-
} else {
|
|
2257
|
-
serializedParams = utils$1.isURLSearchParams(params)
|
|
2258
|
-
? params.toString()
|
|
2259
|
-
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
2260
|
-
}
|
|
2297
|
+
self[normalized] = normalizeValue(value);
|
|
2261
2298
|
|
|
2262
|
-
|
|
2263
|
-
|
|
2299
|
+
headers[normalized] = true;
|
|
2300
|
+
});
|
|
2264
2301
|
|
|
2265
|
-
|
|
2266
|
-
url = url.slice(0, hashmarkIndex);
|
|
2267
|
-
}
|
|
2268
|
-
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
2302
|
+
return this;
|
|
2269
2303
|
}
|
|
2270
2304
|
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
class InterceptorManager {
|
|
2275
|
-
constructor() {
|
|
2276
|
-
this.handlers = [];
|
|
2305
|
+
concat(...targets) {
|
|
2306
|
+
return this.constructor.concat(this, ...targets);
|
|
2277
2307
|
}
|
|
2278
2308
|
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
* @return {Number} An ID used to remove interceptor later
|
|
2287
|
-
*/
|
|
2288
|
-
use(fulfilled, rejected, options) {
|
|
2289
|
-
this.handlers.push({
|
|
2290
|
-
fulfilled,
|
|
2291
|
-
rejected,
|
|
2292
|
-
synchronous: options ? options.synchronous : false,
|
|
2293
|
-
runWhen: options ? options.runWhen : null,
|
|
2309
|
+
toJSON(asStrings) {
|
|
2310
|
+
const obj = Object.create(null);
|
|
2311
|
+
|
|
2312
|
+
utils$1.forEach(this, (value, header) => {
|
|
2313
|
+
value != null &&
|
|
2314
|
+
value !== false &&
|
|
2315
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
2294
2316
|
});
|
|
2295
|
-
|
|
2317
|
+
|
|
2318
|
+
return obj;
|
|
2296
2319
|
}
|
|
2297
2320
|
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
*
|
|
2301
|
-
* @param {Number} id The ID that was returned by `use`
|
|
2302
|
-
*
|
|
2303
|
-
* @returns {void}
|
|
2304
|
-
*/
|
|
2305
|
-
eject(id) {
|
|
2306
|
-
if (this.handlers[id]) {
|
|
2307
|
-
this.handlers[id] = null;
|
|
2308
|
-
}
|
|
2321
|
+
[Symbol.iterator]() {
|
|
2322
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
2309
2323
|
}
|
|
2310
2324
|
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
*/
|
|
2316
|
-
clear() {
|
|
2317
|
-
if (this.handlers) {
|
|
2318
|
-
this.handlers = [];
|
|
2319
|
-
}
|
|
2325
|
+
toString() {
|
|
2326
|
+
return Object.entries(this.toJSON())
|
|
2327
|
+
.map(([header, value]) => header + ': ' + value)
|
|
2328
|
+
.join('\n');
|
|
2320
2329
|
}
|
|
2321
2330
|
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
*
|
|
2325
|
-
* This method is particularly useful for skipping over any
|
|
2326
|
-
* interceptors that may have become `null` calling `eject`.
|
|
2327
|
-
*
|
|
2328
|
-
* @param {Function} fn The function to call for each interceptor
|
|
2329
|
-
*
|
|
2330
|
-
* @returns {void}
|
|
2331
|
-
*/
|
|
2332
|
-
forEach(fn) {
|
|
2333
|
-
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
2334
|
-
if (h !== null) {
|
|
2335
|
-
fn(h);
|
|
2336
|
-
}
|
|
2337
|
-
});
|
|
2331
|
+
getSetCookie() {
|
|
2332
|
+
return this.get('set-cookie') || [];
|
|
2338
2333
|
}
|
|
2339
|
-
}
|
|
2340
2334
|
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
clarifyTimeoutError: false,
|
|
2345
|
-
legacyInterceptorReqResOrdering: true,
|
|
2346
|
-
};
|
|
2335
|
+
get [Symbol.toStringTag]() {
|
|
2336
|
+
return 'AxiosHeaders';
|
|
2337
|
+
}
|
|
2347
2338
|
|
|
2348
|
-
|
|
2339
|
+
static from(thing) {
|
|
2340
|
+
return thing instanceof this ? thing : new this(thing);
|
|
2341
|
+
}
|
|
2349
2342
|
|
|
2350
|
-
|
|
2343
|
+
static concat(first, ...targets) {
|
|
2344
|
+
const computed = new this(first);
|
|
2351
2345
|
|
|
2352
|
-
|
|
2346
|
+
targets.forEach((target) => computed.set(target));
|
|
2353
2347
|
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
classes: {
|
|
2357
|
-
URLSearchParams: URLSearchParams$1,
|
|
2358
|
-
FormData: FormData$1,
|
|
2359
|
-
Blob: Blob$1,
|
|
2360
|
-
},
|
|
2361
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
2362
|
-
};
|
|
2348
|
+
return computed;
|
|
2349
|
+
}
|
|
2363
2350
|
|
|
2364
|
-
|
|
2351
|
+
static accessor(header) {
|
|
2352
|
+
const internals =
|
|
2353
|
+
(this[$internals] =
|
|
2354
|
+
this[$internals] =
|
|
2355
|
+
{
|
|
2356
|
+
accessors: {},
|
|
2357
|
+
});
|
|
2365
2358
|
|
|
2366
|
-
const
|
|
2359
|
+
const accessors = internals.accessors;
|
|
2360
|
+
const prototype = this.prototype;
|
|
2367
2361
|
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
*
|
|
2371
|
-
* This allows axios to run in a web worker, and react-native.
|
|
2372
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
2373
|
-
*
|
|
2374
|
-
* web workers:
|
|
2375
|
-
* typeof window -> undefined
|
|
2376
|
-
* typeof document -> undefined
|
|
2377
|
-
*
|
|
2378
|
-
* react-native:
|
|
2379
|
-
* navigator.product -> 'ReactNative'
|
|
2380
|
-
* nativescript
|
|
2381
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
2382
|
-
*
|
|
2383
|
-
* @returns {boolean}
|
|
2384
|
-
*/
|
|
2385
|
-
const hasStandardBrowserEnv =
|
|
2386
|
-
hasBrowserEnv &&
|
|
2387
|
-
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2362
|
+
function defineAccessor(_header) {
|
|
2363
|
+
const lHeader = normalizeHeader(_header);
|
|
2388
2364
|
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
* filtered out due to its judgment standard
|
|
2395
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
2396
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
2397
|
-
*/
|
|
2398
|
-
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
2399
|
-
return (
|
|
2400
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
|
2401
|
-
// eslint-disable-next-line no-undef
|
|
2402
|
-
self instanceof WorkerGlobalScope &&
|
|
2403
|
-
typeof self.importScripts === 'function'
|
|
2404
|
-
);
|
|
2405
|
-
})();
|
|
2365
|
+
if (!accessors[lHeader]) {
|
|
2366
|
+
buildAccessors(prototype, _header);
|
|
2367
|
+
accessors[lHeader] = true;
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2406
2370
|
|
|
2407
|
-
|
|
2371
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
2408
2372
|
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2373
|
+
return this;
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
AxiosHeaders.accessor([
|
|
2378
|
+
'Content-Type',
|
|
2379
|
+
'Content-Length',
|
|
2380
|
+
'Accept',
|
|
2381
|
+
'Accept-Encoding',
|
|
2382
|
+
'User-Agent',
|
|
2383
|
+
'Authorization',
|
|
2384
|
+
]);
|
|
2385
|
+
|
|
2386
|
+
// reserved names hotfix
|
|
2387
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
|
2388
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2389
|
+
return {
|
|
2390
|
+
get: () => value,
|
|
2391
|
+
set(headerValue) {
|
|
2392
|
+
this[mapped] = headerValue;
|
|
2393
|
+
},
|
|
2394
|
+
};
|
|
2416
2395
|
});
|
|
2417
2396
|
|
|
2418
|
-
|
|
2419
|
-
...utils,
|
|
2420
|
-
...platform$1,
|
|
2421
|
-
};
|
|
2397
|
+
utils$1.freezeMethods(AxiosHeaders);
|
|
2422
2398
|
|
|
2423
|
-
|
|
2424
|
-
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
2425
|
-
visitor: function (value, key, path, helpers) {
|
|
2426
|
-
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
2427
|
-
this.append(key, value.toString('base64'));
|
|
2428
|
-
return false;
|
|
2429
|
-
}
|
|
2399
|
+
const REDACTED = '[REDACTED ****]';
|
|
2430
2400
|
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2401
|
+
function hasOwnOrPrototypeToJSON(source) {
|
|
2402
|
+
if (utils$1.hasOwnProp(source, 'toJSON')) {
|
|
2403
|
+
return true;
|
|
2404
|
+
}
|
|
2436
2405
|
|
|
2437
|
-
|
|
2438
|
-
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
2439
|
-
*
|
|
2440
|
-
* @param {string} name - The name of the property to get.
|
|
2441
|
-
*
|
|
2442
|
-
* @returns An array of strings.
|
|
2443
|
-
*/
|
|
2444
|
-
function parsePropPath(name) {
|
|
2445
|
-
// foo[x][y][z]
|
|
2446
|
-
// foo.x.y.z
|
|
2447
|
-
// foo-x-y-z
|
|
2448
|
-
// foo x y z
|
|
2449
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
2450
|
-
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
2451
|
-
});
|
|
2452
|
-
}
|
|
2406
|
+
let prototype = Object.getPrototypeOf(source);
|
|
2453
2407
|
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
*/
|
|
2461
|
-
function arrayToObject(arr) {
|
|
2462
|
-
const obj = {};
|
|
2463
|
-
const keys = Object.keys(arr);
|
|
2464
|
-
let i;
|
|
2465
|
-
const len = keys.length;
|
|
2466
|
-
let key;
|
|
2467
|
-
for (i = 0; i < len; i++) {
|
|
2468
|
-
key = keys[i];
|
|
2469
|
-
obj[key] = arr[key];
|
|
2408
|
+
while (prototype && prototype !== Object.prototype) {
|
|
2409
|
+
if (utils$1.hasOwnProp(prototype, 'toJSON')) {
|
|
2410
|
+
return true;
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
2470
2414
|
}
|
|
2471
|
-
|
|
2415
|
+
|
|
2416
|
+
return false;
|
|
2472
2417
|
}
|
|
2473
2418
|
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
*/
|
|
2481
|
-
function formDataToJSON(formData) {
|
|
2482
|
-
function buildPath(path, value, target, index) {
|
|
2483
|
-
let name = path[index++];
|
|
2419
|
+
// Build a plain-object snapshot of `config` and replace the value of any key
|
|
2420
|
+
// (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|
2421
|
+
// and AxiosHeaders, and short-circuits on circular references.
|
|
2422
|
+
function redactConfig(config, redactKeys) {
|
|
2423
|
+
const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
|
|
2424
|
+
const seen = [];
|
|
2484
2425
|
|
|
2485
|
-
|
|
2426
|
+
const visit = (source) => {
|
|
2427
|
+
if (source === null || typeof source !== 'object') return source;
|
|
2428
|
+
if (utils$1.isBuffer(source)) return source;
|
|
2429
|
+
if (seen.indexOf(source) !== -1) return undefined;
|
|
2486
2430
|
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2431
|
+
if (source instanceof AxiosHeaders) {
|
|
2432
|
+
source = source.toJSON();
|
|
2433
|
+
}
|
|
2490
2434
|
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2435
|
+
seen.push(source);
|
|
2436
|
+
|
|
2437
|
+
let result;
|
|
2438
|
+
if (utils$1.isArray(source)) {
|
|
2439
|
+
result = [];
|
|
2440
|
+
source.forEach((v, i) => {
|
|
2441
|
+
const reducedValue = visit(v);
|
|
2442
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
2443
|
+
result[i] = reducedValue;
|
|
2444
|
+
}
|
|
2445
|
+
});
|
|
2446
|
+
} else {
|
|
2447
|
+
if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|
2448
|
+
seen.pop();
|
|
2449
|
+
return source;
|
|
2496
2450
|
}
|
|
2497
2451
|
|
|
2498
|
-
|
|
2452
|
+
result = Object.create(null);
|
|
2453
|
+
for (const [key, value] of Object.entries(source)) {
|
|
2454
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
|
|
2455
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
2456
|
+
result[key] = reducedValue;
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2499
2459
|
}
|
|
2500
2460
|
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2461
|
+
seen.pop();
|
|
2462
|
+
return result;
|
|
2463
|
+
};
|
|
2504
2464
|
|
|
2505
|
-
|
|
2465
|
+
return visit(config);
|
|
2466
|
+
}
|
|
2506
2467
|
|
|
2507
|
-
|
|
2508
|
-
|
|
2468
|
+
class AxiosError extends Error {
|
|
2469
|
+
static from(error, code, config, request, response, customProps) {
|
|
2470
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
2471
|
+
// Match native `Error` `cause` semantics: non-enumerable. The wrapped
|
|
2472
|
+
// error often carries circular internals (sockets, requests, agents), so
|
|
2473
|
+
// an enumerable `cause` makes structured loggers (pino/winston) and any
|
|
2474
|
+
// own-property walk throw "Converting circular structure to JSON".
|
|
2475
|
+
// Regression from #6982; see #7205. `__proto__: null` mirrors the
|
|
2476
|
+
// `message` descriptor below (prototype-pollution-safe descriptor).
|
|
2477
|
+
Object.defineProperty(axiosError, 'cause', {
|
|
2478
|
+
__proto__: null,
|
|
2479
|
+
value: error,
|
|
2480
|
+
writable: true,
|
|
2481
|
+
enumerable: false,
|
|
2482
|
+
configurable: true,
|
|
2483
|
+
});
|
|
2484
|
+
axiosError.name = error.name;
|
|
2485
|
+
|
|
2486
|
+
// Preserve status from the original error if not already set from response
|
|
2487
|
+
if (error.status != null && axiosError.status == null) {
|
|
2488
|
+
axiosError.status = error.status;
|
|
2509
2489
|
}
|
|
2510
2490
|
|
|
2511
|
-
|
|
2491
|
+
customProps && Object.assign(axiosError, customProps);
|
|
2492
|
+
return axiosError;
|
|
2512
2493
|
}
|
|
2513
2494
|
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2495
|
+
/**
|
|
2496
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
2497
|
+
*
|
|
2498
|
+
* @param {string} message The error message.
|
|
2499
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
2500
|
+
* @param {Object} [config] The config.
|
|
2501
|
+
* @param {Object} [request] The request.
|
|
2502
|
+
* @param {Object} [response] The response.
|
|
2503
|
+
*
|
|
2504
|
+
* @returns {Error} The created error.
|
|
2505
|
+
*/
|
|
2506
|
+
constructor(message, code, config, request, response) {
|
|
2507
|
+
super(message);
|
|
2508
|
+
|
|
2509
|
+
// Make message enumerable to maintain backward compatibility
|
|
2510
|
+
// The native Error constructor sets message as non-enumerable,
|
|
2511
|
+
// but axios < v1.13.3 had it as enumerable
|
|
2512
|
+
Object.defineProperty(this, 'message', {
|
|
2513
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
2514
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
2515
|
+
__proto__: null,
|
|
2516
|
+
value: message,
|
|
2517
|
+
enumerable: true,
|
|
2518
|
+
writable: true,
|
|
2519
|
+
configurable: true,
|
|
2519
2520
|
});
|
|
2520
2521
|
|
|
2521
|
-
|
|
2522
|
+
this.name = 'AxiosError';
|
|
2523
|
+
this.isAxiosError = true;
|
|
2524
|
+
code && (this.code = code);
|
|
2525
|
+
config && (this.config = config);
|
|
2526
|
+
request && (this.request = request);
|
|
2527
|
+
if (response) {
|
|
2528
|
+
this.response = response;
|
|
2529
|
+
this.status = response.status;
|
|
2530
|
+
}
|
|
2522
2531
|
}
|
|
2523
2532
|
|
|
2524
|
-
|
|
2525
|
-
|
|
2533
|
+
toJSON() {
|
|
2534
|
+
// Opt-in redaction: when the request config carries a `redact` array, the
|
|
2535
|
+
// value of any matching key (case-insensitive, at any depth) is replaced
|
|
2536
|
+
// with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|
2537
|
+
// existing serialization behavior unchanged.
|
|
2538
|
+
const config = this.config;
|
|
2539
|
+
const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|
2540
|
+
const serializedConfig =
|
|
2541
|
+
utils$1.isArray(redactKeys) && redactKeys.length > 0
|
|
2542
|
+
? redactConfig(config, redactKeys)
|
|
2543
|
+
: utils$1.toJSONObject(config);
|
|
2526
2544
|
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
throw e;
|
|
2545
|
-
}
|
|
2546
|
-
}
|
|
2545
|
+
return {
|
|
2546
|
+
// Standard
|
|
2547
|
+
message: this.message,
|
|
2548
|
+
name: this.name,
|
|
2549
|
+
// Microsoft
|
|
2550
|
+
description: this.description,
|
|
2551
|
+
number: this.number,
|
|
2552
|
+
// Mozilla
|
|
2553
|
+
fileName: this.fileName,
|
|
2554
|
+
lineNumber: this.lineNumber,
|
|
2555
|
+
columnNumber: this.columnNumber,
|
|
2556
|
+
stack: this.stack,
|
|
2557
|
+
// Axios
|
|
2558
|
+
config: serializedConfig,
|
|
2559
|
+
code: this.code,
|
|
2560
|
+
status: this.status,
|
|
2561
|
+
};
|
|
2547
2562
|
}
|
|
2548
|
-
|
|
2549
|
-
return (encoder || JSON.stringify)(rawValue);
|
|
2550
2563
|
}
|
|
2551
2564
|
|
|
2552
|
-
|
|
2553
|
-
|
|
2565
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
2566
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
2567
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
2568
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
2569
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
2570
|
+
AxiosError.ECONNREFUSED = 'ECONNREFUSED';
|
|
2571
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
2572
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
2573
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
2574
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
2575
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
2576
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
2577
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
2578
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
2579
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
2554
2580
|
|
|
2555
|
-
|
|
2581
|
+
// eslint-disable-next-line strict
|
|
2582
|
+
var httpAdapter = null;
|
|
2556
2583
|
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
2561
|
-
const isObjectPayload = utils$1.isObject(data);
|
|
2584
|
+
// Default nesting limit shared with the inverse transform (formDataToJSON) so
|
|
2585
|
+
// the FormData <-> JSON round-trip stays symmetric.
|
|
2586
|
+
const DEFAULT_FORM_DATA_MAX_DEPTH = 100;
|
|
2562
2587
|
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2588
|
+
/**
|
|
2589
|
+
* Determines if the given thing is a array or js object.
|
|
2590
|
+
*
|
|
2591
|
+
* @param {string} thing - The object or array to be visited.
|
|
2592
|
+
*
|
|
2593
|
+
* @returns {boolean}
|
|
2594
|
+
*/
|
|
2595
|
+
function isVisitable(thing) {
|
|
2596
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
2597
|
+
}
|
|
2566
2598
|
|
|
2567
|
-
|
|
2599
|
+
/**
|
|
2600
|
+
* It removes the brackets from the end of a string
|
|
2601
|
+
*
|
|
2602
|
+
* @param {string} key - The key of the parameter.
|
|
2603
|
+
*
|
|
2604
|
+
* @returns {string} the key without the brackets.
|
|
2605
|
+
*/
|
|
2606
|
+
function removeBrackets(key) {
|
|
2607
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
2608
|
+
}
|
|
2568
2609
|
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
}
|
|
2610
|
+
/**
|
|
2611
|
+
* It takes a path, a key, and a boolean, and returns a string
|
|
2612
|
+
*
|
|
2613
|
+
* @param {string} path - The path to the current key.
|
|
2614
|
+
* @param {string} key - The key of the current object being iterated over.
|
|
2615
|
+
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
2616
|
+
*
|
|
2617
|
+
* @returns {string} The path to the current key.
|
|
2618
|
+
*/
|
|
2619
|
+
function renderKey(path, key, dots) {
|
|
2620
|
+
if (!path) return key;
|
|
2621
|
+
return path
|
|
2622
|
+
.concat(key)
|
|
2623
|
+
.map(function each(token, i) {
|
|
2624
|
+
// eslint-disable-next-line no-param-reassign
|
|
2625
|
+
token = removeBrackets(token);
|
|
2626
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
2627
|
+
})
|
|
2628
|
+
.join(dots ? '.' : '');
|
|
2629
|
+
}
|
|
2590
2630
|
|
|
2591
|
-
|
|
2631
|
+
/**
|
|
2632
|
+
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
2633
|
+
*
|
|
2634
|
+
* @param {Array<any>} arr - The array to check
|
|
2635
|
+
*
|
|
2636
|
+
* @returns {boolean}
|
|
2637
|
+
*/
|
|
2638
|
+
function isFlatArray(arr) {
|
|
2639
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
2640
|
+
}
|
|
2592
2641
|
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
}
|
|
2642
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
2643
|
+
return /^is[A-Z]/.test(prop);
|
|
2644
|
+
});
|
|
2597
2645
|
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2646
|
+
/**
|
|
2647
|
+
* Convert a data object to FormData
|
|
2648
|
+
*
|
|
2649
|
+
* @param {Object} obj
|
|
2650
|
+
* @param {?Object} [formData]
|
|
2651
|
+
* @param {?Object} [options]
|
|
2652
|
+
* @param {Function} [options.visitor]
|
|
2653
|
+
* @param {Boolean} [options.metaTokens = true]
|
|
2654
|
+
* @param {Boolean} [options.dots = false]
|
|
2655
|
+
* @param {?Boolean} [options.indexes = false]
|
|
2656
|
+
*
|
|
2657
|
+
* @returns {Object}
|
|
2658
|
+
**/
|
|
2603
2659
|
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2660
|
+
/**
|
|
2661
|
+
* It converts an object into a FormData object
|
|
2662
|
+
*
|
|
2663
|
+
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
2664
|
+
* @param {string} formData - The FormData object to append to.
|
|
2665
|
+
* @param {Object<string, any>} options
|
|
2666
|
+
*
|
|
2667
|
+
* @returns
|
|
2668
|
+
*/
|
|
2669
|
+
function toFormData(obj, formData, options) {
|
|
2670
|
+
if (!utils$1.isObject(obj)) {
|
|
2671
|
+
throw new TypeError('target must be an object');
|
|
2672
|
+
}
|
|
2611
2673
|
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
return stringifySafely(data);
|
|
2615
|
-
}
|
|
2674
|
+
// eslint-disable-next-line no-param-reassign
|
|
2675
|
+
formData = formData || new (FormData)();
|
|
2616
2676
|
|
|
2617
|
-
|
|
2677
|
+
// eslint-disable-next-line no-param-reassign
|
|
2678
|
+
options = utils$1.toFlatObject(
|
|
2679
|
+
options,
|
|
2680
|
+
{
|
|
2681
|
+
metaTokens: true,
|
|
2682
|
+
dots: false,
|
|
2683
|
+
indexes: false,
|
|
2618
2684
|
},
|
|
2619
|
-
|
|
2685
|
+
false,
|
|
2686
|
+
function defined(option, source) {
|
|
2687
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
2688
|
+
return !utils$1.isUndefined(source[option]);
|
|
2689
|
+
}
|
|
2690
|
+
);
|
|
2620
2691
|
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2692
|
+
const metaTokens = options.metaTokens;
|
|
2693
|
+
// eslint-disable-next-line no-use-before-define
|
|
2694
|
+
const visitor = options.visitor || defaultVisitor;
|
|
2695
|
+
const dots = options.dots;
|
|
2696
|
+
const indexes = options.indexes;
|
|
2697
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
2698
|
+
const maxDepth = options.maxDepth === undefined ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
|
|
2699
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
2700
|
+
const stack = [];
|
|
2626
2701
|
|
|
2627
|
-
|
|
2628
|
-
|
|
2702
|
+
if (!utils$1.isFunction(visitor)) {
|
|
2703
|
+
throw new TypeError('visitor must be a function');
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
function convertValue(value) {
|
|
2707
|
+
if (value === null) return '';
|
|
2708
|
+
|
|
2709
|
+
if (utils$1.isDate(value)) {
|
|
2710
|
+
return value.toISOString();
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
if (utils$1.isBoolean(value)) {
|
|
2714
|
+
return value.toString();
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
2718
|
+
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
2722
|
+
if (useBlob && typeof _Blob === 'function') {
|
|
2723
|
+
return new _Blob([value]);
|
|
2629
2724
|
}
|
|
2725
|
+
if (typeof Buffer !== 'undefined') {
|
|
2726
|
+
return Buffer.from(value);
|
|
2727
|
+
}
|
|
2728
|
+
throw new AxiosError('Blob is not supported. Use a Buffer instead.', AxiosError.ERR_NOT_SUPPORT);
|
|
2729
|
+
}
|
|
2630
2730
|
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
utils$1.isString(data) &&
|
|
2634
|
-
((forcedJSONParsing && !this.responseType) || JSONRequested)
|
|
2635
|
-
) {
|
|
2636
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2637
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
2731
|
+
return value;
|
|
2732
|
+
}
|
|
2638
2733
|
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2734
|
+
function throwIfMaxDepthExceeded(depth) {
|
|
2735
|
+
if (depth > maxDepth) {
|
|
2736
|
+
throw new AxiosError(
|
|
2737
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
2738
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2739
|
+
);
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
function stringifyWithDepthLimit(value, depth) {
|
|
2744
|
+
if (maxDepth === Infinity) {
|
|
2745
|
+
return JSON.stringify(value);
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
const ancestors = [];
|
|
2749
|
+
|
|
2750
|
+
return JSON.stringify(value, function limitDepth(_key, currentValue) {
|
|
2751
|
+
if (!utils$1.isObject(currentValue)) {
|
|
2752
|
+
return currentValue;
|
|
2649
2753
|
}
|
|
2650
2754
|
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2755
|
+
while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
|
|
2756
|
+
ancestors.pop();
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
ancestors.push(currentValue);
|
|
2760
|
+
throwIfMaxDepthExceeded(depth + ancestors.length - 1);
|
|
2761
|
+
|
|
2762
|
+
return currentValue;
|
|
2763
|
+
});
|
|
2764
|
+
}
|
|
2654
2765
|
|
|
2655
2766
|
/**
|
|
2656
|
-
*
|
|
2657
|
-
*
|
|
2767
|
+
* Default visitor.
|
|
2768
|
+
*
|
|
2769
|
+
* @param {*} value
|
|
2770
|
+
* @param {String|Number} key
|
|
2771
|
+
* @param {Array<String|Number>} path
|
|
2772
|
+
* @this {FormData}
|
|
2773
|
+
*
|
|
2774
|
+
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
2658
2775
|
*/
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
|
2662
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
2776
|
+
function defaultVisitor(value, key, path) {
|
|
2777
|
+
let arr = value;
|
|
2663
2778
|
|
|
2664
|
-
|
|
2665
|
-
|
|
2779
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
2780
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
2781
|
+
return false;
|
|
2782
|
+
}
|
|
2666
2783
|
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2784
|
+
if (value && !path && typeof value === 'object') {
|
|
2785
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
2786
|
+
// eslint-disable-next-line no-param-reassign
|
|
2787
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
2788
|
+
// eslint-disable-next-line no-param-reassign
|
|
2789
|
+
value = stringifyWithDepthLimit(value, 1);
|
|
2790
|
+
} else if (
|
|
2791
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
2792
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
2793
|
+
) {
|
|
2794
|
+
// eslint-disable-next-line no-param-reassign
|
|
2795
|
+
key = removeBrackets(key);
|
|
2671
2796
|
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2797
|
+
arr.forEach(function each(el, index) {
|
|
2798
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
2799
|
+
formData.append(
|
|
2800
|
+
// eslint-disable-next-line no-nested-ternary
|
|
2801
|
+
indexes === true
|
|
2802
|
+
? renderKey([key], index, dots)
|
|
2803
|
+
: indexes === null
|
|
2804
|
+
? key
|
|
2805
|
+
: key + '[]',
|
|
2806
|
+
convertValue(el)
|
|
2807
|
+
);
|
|
2808
|
+
});
|
|
2809
|
+
return false;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2675
2812
|
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
'Content-Type': undefined,
|
|
2680
|
-
},
|
|
2681
|
-
},
|
|
2682
|
-
};
|
|
2813
|
+
if (isVisitable(value)) {
|
|
2814
|
+
return true;
|
|
2815
|
+
}
|
|
2683
2816
|
|
|
2684
|
-
|
|
2685
|
-
defaults.headers[method] = {};
|
|
2686
|
-
});
|
|
2817
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
2687
2818
|
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
2691
|
-
'age',
|
|
2692
|
-
'authorization',
|
|
2693
|
-
'content-length',
|
|
2694
|
-
'content-type',
|
|
2695
|
-
'etag',
|
|
2696
|
-
'expires',
|
|
2697
|
-
'from',
|
|
2698
|
-
'host',
|
|
2699
|
-
'if-modified-since',
|
|
2700
|
-
'if-unmodified-since',
|
|
2701
|
-
'last-modified',
|
|
2702
|
-
'location',
|
|
2703
|
-
'max-forwards',
|
|
2704
|
-
'proxy-authorization',
|
|
2705
|
-
'referer',
|
|
2706
|
-
'retry-after',
|
|
2707
|
-
'user-agent',
|
|
2708
|
-
]);
|
|
2819
|
+
return false;
|
|
2820
|
+
}
|
|
2709
2821
|
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
* Content-Type: application/json
|
|
2716
|
-
* Connection: keep-alive
|
|
2717
|
-
* Transfer-Encoding: chunked
|
|
2718
|
-
* ```
|
|
2719
|
-
*
|
|
2720
|
-
* @param {String} rawHeaders Headers needing to be parsed
|
|
2721
|
-
*
|
|
2722
|
-
* @returns {Object} Headers parsed into an object
|
|
2723
|
-
*/
|
|
2724
|
-
var parseHeaders = (rawHeaders) => {
|
|
2725
|
-
const parsed = {};
|
|
2726
|
-
let key;
|
|
2727
|
-
let val;
|
|
2728
|
-
let i;
|
|
2822
|
+
const exposedHelpers = Object.assign(predicates, {
|
|
2823
|
+
defaultVisitor,
|
|
2824
|
+
convertValue,
|
|
2825
|
+
isVisitable,
|
|
2826
|
+
});
|
|
2729
2827
|
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
i = line.indexOf(':');
|
|
2733
|
-
key = line.substring(0, i).trim().toLowerCase();
|
|
2734
|
-
val = line.substring(i + 1).trim();
|
|
2828
|
+
function build(value, path, depth = 0) {
|
|
2829
|
+
if (utils$1.isUndefined(value)) return;
|
|
2735
2830
|
|
|
2736
|
-
|
|
2737
|
-
return;
|
|
2738
|
-
}
|
|
2831
|
+
throwIfMaxDepthExceeded(depth);
|
|
2739
2832
|
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
} else {
|
|
2744
|
-
parsed[key] = [val];
|
|
2745
|
-
}
|
|
2746
|
-
} else {
|
|
2747
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
2748
|
-
}
|
|
2749
|
-
});
|
|
2833
|
+
if (stack.indexOf(value) !== -1) {
|
|
2834
|
+
throw new Error('Circular reference detected in ' + path.join('.'));
|
|
2835
|
+
}
|
|
2750
2836
|
|
|
2751
|
-
|
|
2752
|
-
};
|
|
2837
|
+
stack.push(value);
|
|
2753
2838
|
|
|
2754
|
-
|
|
2839
|
+
utils$1.forEach(value, function each(el, key) {
|
|
2840
|
+
const result =
|
|
2841
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
2842
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
2755
2843
|
|
|
2756
|
-
|
|
2844
|
+
if (result === true) {
|
|
2845
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
2846
|
+
}
|
|
2847
|
+
});
|
|
2757
2848
|
|
|
2758
|
-
|
|
2759
|
-
if (value === false || value == null) {
|
|
2760
|
-
return;
|
|
2849
|
+
stack.pop();
|
|
2761
2850
|
}
|
|
2762
2851
|
|
|
2763
|
-
if (utils$1.
|
|
2764
|
-
|
|
2765
|
-
return;
|
|
2852
|
+
if (!utils$1.isObject(obj)) {
|
|
2853
|
+
throw new TypeError('data must be an object');
|
|
2766
2854
|
}
|
|
2767
2855
|
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2856
|
+
build(obj);
|
|
2857
|
+
|
|
2858
|
+
return formData;
|
|
2771
2859
|
}
|
|
2772
2860
|
|
|
2773
|
-
|
|
2774
|
-
|
|
2861
|
+
/**
|
|
2862
|
+
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
2863
|
+
* their percent-encoded equivalents
|
|
2864
|
+
*
|
|
2865
|
+
* @param {string} str - The string to encode.
|
|
2866
|
+
*
|
|
2867
|
+
* @returns {string} The encoded string.
|
|
2868
|
+
*/
|
|
2869
|
+
function encode$1(str) {
|
|
2870
|
+
const charMap = {
|
|
2871
|
+
'!': '%21',
|
|
2872
|
+
"'": '%27',
|
|
2873
|
+
'(': '%28',
|
|
2874
|
+
')': '%29',
|
|
2875
|
+
'~': '%7E',
|
|
2876
|
+
'%20': '+',
|
|
2877
|
+
};
|
|
2878
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
2879
|
+
return charMap[match];
|
|
2880
|
+
});
|
|
2775
2881
|
}
|
|
2776
2882
|
|
|
2777
|
-
|
|
2778
|
-
|
|
2883
|
+
/**
|
|
2884
|
+
* It takes a params object and converts it to a FormData object
|
|
2885
|
+
*
|
|
2886
|
+
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
2887
|
+
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
2888
|
+
*
|
|
2889
|
+
* @returns {void}
|
|
2890
|
+
*/
|
|
2891
|
+
function AxiosURLSearchParams(params, options) {
|
|
2892
|
+
this._pairs = [];
|
|
2779
2893
|
|
|
2780
|
-
|
|
2781
|
-
|
|
2894
|
+
params && toFormData(params, this, options);
|
|
2895
|
+
}
|
|
2782
2896
|
|
|
2783
|
-
|
|
2784
|
-
break;
|
|
2785
|
-
}
|
|
2897
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
2786
2898
|
|
|
2787
|
-
|
|
2788
|
-
|
|
2899
|
+
prototype.append = function append(name, value) {
|
|
2900
|
+
this._pairs.push([name, value]);
|
|
2901
|
+
};
|
|
2789
2902
|
|
|
2790
|
-
|
|
2791
|
-
|
|
2903
|
+
prototype.toString = function toString(encoder) {
|
|
2904
|
+
const _encode = encoder
|
|
2905
|
+
? (value) => encoder.call(this, value, encode$1)
|
|
2906
|
+
: encode$1;
|
|
2792
2907
|
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2908
|
+
return this._pairs
|
|
2909
|
+
.map(function each(pair) {
|
|
2910
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
2911
|
+
}, '')
|
|
2912
|
+
.join('&');
|
|
2913
|
+
};
|
|
2797
2914
|
|
|
2798
|
-
|
|
2915
|
+
/**
|
|
2916
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
2917
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
2918
|
+
*
|
|
2919
|
+
* @param {string} val The value to be encoded.
|
|
2920
|
+
*
|
|
2921
|
+
* @returns {string} The encoded value.
|
|
2922
|
+
*/
|
|
2923
|
+
function encode(val) {
|
|
2924
|
+
return encodeURIComponent(val)
|
|
2925
|
+
.replace(/%3A/gi, ':')
|
|
2926
|
+
.replace(/%24/g, '$')
|
|
2927
|
+
.replace(/%2C/gi, ',')
|
|
2928
|
+
.replace(/%20/g, '+');
|
|
2799
2929
|
}
|
|
2800
2930
|
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2931
|
+
/**
|
|
2932
|
+
* Build a URL by appending params to the end
|
|
2933
|
+
*
|
|
2934
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
2935
|
+
* @param {object} [params] The params to be appended
|
|
2936
|
+
* @param {?(object|Function)} options
|
|
2937
|
+
*
|
|
2938
|
+
* @returns {string} The formatted url
|
|
2939
|
+
*/
|
|
2940
|
+
function buildURL(url, params, options) {
|
|
2941
|
+
if (!params) {
|
|
2942
|
+
return url;
|
|
2808
2943
|
}
|
|
2944
|
+
url = url || '';
|
|
2809
2945
|
|
|
2810
|
-
|
|
2811
|
-
|
|
2946
|
+
const _options = utils$1.isFunction(options)
|
|
2947
|
+
? {
|
|
2948
|
+
serialize: options,
|
|
2949
|
+
}
|
|
2950
|
+
: options;
|
|
2812
2951
|
|
|
2813
|
-
|
|
2952
|
+
// Read serializer options pollution-safely: own properties and methods on a
|
|
2953
|
+
// class/template prototype are honored, but values injected onto a polluted
|
|
2954
|
+
// Object.prototype are ignored.
|
|
2955
|
+
const _encode = utils$1.getSafeProp(_options, 'encode') || encode;
|
|
2956
|
+
const serializeFn = utils$1.getSafeProp(_options, 'serialize');
|
|
2814
2957
|
|
|
2815
|
-
|
|
2816
|
-
if (utils$1.isFunction(filter)) {
|
|
2817
|
-
return filter.call(this, value, header);
|
|
2818
|
-
}
|
|
2958
|
+
let serializedParams;
|
|
2819
2959
|
|
|
2820
|
-
if (
|
|
2821
|
-
|
|
2960
|
+
if (serializeFn) {
|
|
2961
|
+
serializedParams = serializeFn(params, _options);
|
|
2962
|
+
} else {
|
|
2963
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
2964
|
+
? params.toString()
|
|
2965
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
2822
2966
|
}
|
|
2823
2967
|
|
|
2824
|
-
if (
|
|
2825
|
-
|
|
2826
|
-
if (utils$1.isString(filter)) {
|
|
2827
|
-
return value.indexOf(filter) !== -1;
|
|
2828
|
-
}
|
|
2968
|
+
if (serializedParams) {
|
|
2969
|
+
const hashmarkIndex = url.indexOf('#');
|
|
2829
2970
|
|
|
2830
|
-
|
|
2831
|
-
|
|
2971
|
+
if (hashmarkIndex !== -1) {
|
|
2972
|
+
url = url.slice(0, hashmarkIndex);
|
|
2973
|
+
}
|
|
2974
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
2832
2975
|
}
|
|
2833
|
-
}
|
|
2834
2976
|
|
|
2835
|
-
|
|
2836
|
-
return header
|
|
2837
|
-
.trim()
|
|
2838
|
-
.toLowerCase()
|
|
2839
|
-
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
2840
|
-
return char.toUpperCase() + str;
|
|
2841
|
-
});
|
|
2977
|
+
return url;
|
|
2842
2978
|
}
|
|
2843
2979
|
|
|
2844
|
-
|
|
2845
|
-
|
|
2980
|
+
class InterceptorManager {
|
|
2981
|
+
constructor() {
|
|
2982
|
+
this.handlers = [];
|
|
2983
|
+
}
|
|
2846
2984
|
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2985
|
+
/**
|
|
2986
|
+
* Add a new interceptor to the stack
|
|
2987
|
+
*
|
|
2988
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
2989
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
2990
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
2991
|
+
*
|
|
2992
|
+
* @return {Number} An ID used to remove interceptor later
|
|
2993
|
+
*/
|
|
2994
|
+
use(fulfilled, rejected, options) {
|
|
2995
|
+
this.handlers.push({
|
|
2996
|
+
fulfilled,
|
|
2997
|
+
rejected,
|
|
2998
|
+
synchronous: options ? options.synchronous : false,
|
|
2999
|
+
runWhen: options ? options.runWhen : null,
|
|
2853
3000
|
});
|
|
2854
|
-
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
class AxiosHeaders {
|
|
2858
|
-
constructor(headers) {
|
|
2859
|
-
headers && this.set(headers);
|
|
3001
|
+
return this.handlers.length - 1;
|
|
2860
3002
|
}
|
|
2861
3003
|
|
|
2862
|
-
|
|
2863
|
-
|
|
3004
|
+
/**
|
|
3005
|
+
* Remove an interceptor from the stack
|
|
3006
|
+
*
|
|
3007
|
+
* @param {Number} id The ID that was returned by `use`
|
|
3008
|
+
*
|
|
3009
|
+
* @returns {void}
|
|
3010
|
+
*/
|
|
3011
|
+
eject(id) {
|
|
3012
|
+
if (this.handlers[id]) {
|
|
3013
|
+
this.handlers[id] = null;
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
2864
3016
|
|
|
2865
|
-
|
|
2866
|
-
|
|
3017
|
+
/**
|
|
3018
|
+
* Clear all interceptors from the stack
|
|
3019
|
+
*
|
|
3020
|
+
* @returns {void}
|
|
3021
|
+
*/
|
|
3022
|
+
clear() {
|
|
3023
|
+
if (this.handlers) {
|
|
3024
|
+
this.handlers = [];
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
2867
3027
|
|
|
2868
|
-
|
|
2869
|
-
|
|
3028
|
+
/**
|
|
3029
|
+
* Iterate over all the registered interceptors
|
|
3030
|
+
*
|
|
3031
|
+
* This method is particularly useful for skipping over any
|
|
3032
|
+
* interceptors that may have become `null` calling `eject`.
|
|
3033
|
+
*
|
|
3034
|
+
* @param {Function} fn The function to call for each interceptor
|
|
3035
|
+
*
|
|
3036
|
+
* @returns {void}
|
|
3037
|
+
*/
|
|
3038
|
+
forEach(fn) {
|
|
3039
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
3040
|
+
if (h !== null) {
|
|
3041
|
+
fn(h);
|
|
2870
3042
|
}
|
|
3043
|
+
});
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
2871
3046
|
|
|
2872
|
-
|
|
3047
|
+
var transitionalDefaults = {
|
|
3048
|
+
silentJSONParsing: true,
|
|
3049
|
+
forcedJSONParsing: true,
|
|
3050
|
+
clarifyTimeoutError: false,
|
|
3051
|
+
legacyInterceptorReqResOrdering: true,
|
|
3052
|
+
advertiseZstdAcceptEncoding: false,
|
|
3053
|
+
validateStatusUndefinedResolves: true,
|
|
3054
|
+
};
|
|
2873
3055
|
|
|
2874
|
-
|
|
2875
|
-
!key ||
|
|
2876
|
-
self[key] === undefined ||
|
|
2877
|
-
_rewrite === true ||
|
|
2878
|
-
(_rewrite === undefined && self[key] !== false)
|
|
2879
|
-
) {
|
|
2880
|
-
assertValidHeaderValue(_value, _header);
|
|
2881
|
-
self[key || _header] = normalizeValue(_value);
|
|
2882
|
-
}
|
|
2883
|
-
}
|
|
3056
|
+
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
2884
3057
|
|
|
2885
|
-
|
|
2886
|
-
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
3058
|
+
var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
2887
3059
|
|
|
2888
|
-
|
|
2889
|
-
setHeaders(header, valueOrRewrite);
|
|
2890
|
-
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2891
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
2892
|
-
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
2893
|
-
let obj = {},
|
|
2894
|
-
dest,
|
|
2895
|
-
key;
|
|
2896
|
-
for (const entry of header) {
|
|
2897
|
-
if (!utils$1.isArray(entry)) {
|
|
2898
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
2899
|
-
}
|
|
3060
|
+
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
2900
3061
|
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
3062
|
+
var platform$1 = {
|
|
3063
|
+
isBrowser: true,
|
|
3064
|
+
classes: {
|
|
3065
|
+
URLSearchParams: URLSearchParams$1,
|
|
3066
|
+
FormData: FormData$1,
|
|
3067
|
+
Blob: Blob$1,
|
|
3068
|
+
},
|
|
3069
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
3070
|
+
};
|
|
2907
3071
|
|
|
2908
|
-
|
|
2909
|
-
} else {
|
|
2910
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
2911
|
-
}
|
|
3072
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2912
3073
|
|
|
2913
|
-
|
|
2914
|
-
}
|
|
3074
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
2915
3075
|
|
|
2916
|
-
|
|
2917
|
-
|
|
3076
|
+
/**
|
|
3077
|
+
* Determine if we're running in a standard browser environment
|
|
3078
|
+
*
|
|
3079
|
+
* This allows axios to run in a web worker, and react-native.
|
|
3080
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
3081
|
+
*
|
|
3082
|
+
* web workers:
|
|
3083
|
+
* typeof window -> undefined
|
|
3084
|
+
* typeof document -> undefined
|
|
3085
|
+
*
|
|
3086
|
+
* react-native:
|
|
3087
|
+
* navigator.product -> 'ReactNative'
|
|
3088
|
+
* nativescript
|
|
3089
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
|
3090
|
+
*
|
|
3091
|
+
* @returns {boolean}
|
|
3092
|
+
*/
|
|
3093
|
+
const hasStandardBrowserEnv =
|
|
3094
|
+
hasBrowserEnv &&
|
|
3095
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2918
3096
|
|
|
2919
|
-
|
|
2920
|
-
|
|
3097
|
+
/**
|
|
3098
|
+
* Determine if we're running in a standard browser webWorker environment
|
|
3099
|
+
*
|
|
3100
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
|
3101
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
3102
|
+
* filtered out due to its judgment standard
|
|
3103
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
3104
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
|
3105
|
+
*/
|
|
3106
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
3107
|
+
return (
|
|
3108
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
|
3109
|
+
// eslint-disable-next-line no-undef
|
|
3110
|
+
self instanceof WorkerGlobalScope &&
|
|
3111
|
+
typeof self.importScripts === 'function'
|
|
3112
|
+
);
|
|
3113
|
+
})();
|
|
2921
3114
|
|
|
2922
|
-
|
|
2923
|
-
const value = this[key];
|
|
3115
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
2924
3116
|
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
3117
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
3118
|
+
__proto__: null,
|
|
3119
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
3120
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
3121
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
3122
|
+
navigator: _navigator,
|
|
3123
|
+
origin: origin
|
|
3124
|
+
});
|
|
2928
3125
|
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
3126
|
+
var platform = {
|
|
3127
|
+
...utils,
|
|
3128
|
+
...platform$1,
|
|
3129
|
+
};
|
|
2932
3130
|
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
3131
|
+
function toURLEncodedForm(data, options) {
|
|
3132
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
3133
|
+
visitor: function (value, key, path, helpers) {
|
|
3134
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
3135
|
+
this.append(key, value.toString('base64'));
|
|
3136
|
+
return false;
|
|
3137
|
+
}
|
|
2936
3138
|
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
3139
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
3140
|
+
},
|
|
3141
|
+
...options,
|
|
3142
|
+
});
|
|
3143
|
+
}
|
|
2940
3144
|
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
3145
|
+
const MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
|
|
3146
|
+
|
|
3147
|
+
function throwIfDepthExceeded(index) {
|
|
3148
|
+
if (index > MAX_DEPTH) {
|
|
3149
|
+
throw new AxiosError(
|
|
3150
|
+
'FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH,
|
|
3151
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
3152
|
+
);
|
|
2944
3153
|
}
|
|
3154
|
+
}
|
|
2945
3155
|
|
|
2946
|
-
|
|
2947
|
-
|
|
3156
|
+
/**
|
|
3157
|
+
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
3158
|
+
*
|
|
3159
|
+
* @param {string} name - The name of the property to get.
|
|
3160
|
+
*
|
|
3161
|
+
* @returns An array of strings.
|
|
3162
|
+
*/
|
|
3163
|
+
function parsePropPath(name) {
|
|
3164
|
+
// foo[x][y][z]
|
|
3165
|
+
// foo.x.y.z
|
|
3166
|
+
// foo-x-y-z
|
|
3167
|
+
// foo x y z
|
|
3168
|
+
const path = [];
|
|
3169
|
+
const pattern = /\w+|\[(\w*)]/g;
|
|
3170
|
+
let match;
|
|
2948
3171
|
|
|
2949
|
-
|
|
2950
|
-
|
|
3172
|
+
while ((match = pattern.exec(name)) !== null) {
|
|
3173
|
+
throwIfDepthExceeded(path.length);
|
|
3174
|
+
path.push(match[0] === '[]' ? '' : match[1] || match[0]);
|
|
3175
|
+
}
|
|
2951
3176
|
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
this[key] !== undefined &&
|
|
2955
|
-
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2956
|
-
);
|
|
2957
|
-
}
|
|
3177
|
+
return path;
|
|
3178
|
+
}
|
|
2958
3179
|
|
|
2959
|
-
|
|
3180
|
+
/**
|
|
3181
|
+
* Convert an array to an object.
|
|
3182
|
+
*
|
|
3183
|
+
* @param {Array<any>} arr - The array to convert to an object.
|
|
3184
|
+
*
|
|
3185
|
+
* @returns An object with the same keys and values as the array.
|
|
3186
|
+
*/
|
|
3187
|
+
function arrayToObject(arr) {
|
|
3188
|
+
const obj = {};
|
|
3189
|
+
const keys = Object.keys(arr);
|
|
3190
|
+
let i;
|
|
3191
|
+
const len = keys.length;
|
|
3192
|
+
let key;
|
|
3193
|
+
for (i = 0; i < len; i++) {
|
|
3194
|
+
key = keys[i];
|
|
3195
|
+
obj[key] = arr[key];
|
|
2960
3196
|
}
|
|
3197
|
+
return obj;
|
|
3198
|
+
}
|
|
2961
3199
|
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
3200
|
+
/**
|
|
3201
|
+
* It takes a FormData object and returns a JavaScript object
|
|
3202
|
+
*
|
|
3203
|
+
* @param {string} formData The FormData object to convert to JSON.
|
|
3204
|
+
*
|
|
3205
|
+
* @returns {Object<string, any> | null} The converted object.
|
|
3206
|
+
*/
|
|
3207
|
+
function formDataToJSON(formData) {
|
|
3208
|
+
function buildPath(path, value, target, index) {
|
|
3209
|
+
throwIfDepthExceeded(index);
|
|
2965
3210
|
|
|
2966
|
-
|
|
2967
|
-
_header = normalizeHeader(_header);
|
|
3211
|
+
let name = path[index++];
|
|
2968
3212
|
|
|
2969
|
-
|
|
2970
|
-
const key = utils$1.findKey(self, _header);
|
|
3213
|
+
if (name === '__proto__') return true;
|
|
2971
3214
|
|
|
2972
|
-
|
|
2973
|
-
|
|
3215
|
+
const isNumericKey = Number.isFinite(+name);
|
|
3216
|
+
const isLast = index >= path.length;
|
|
3217
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
2974
3218
|
|
|
2975
|
-
|
|
2976
|
-
|
|
3219
|
+
if (isLast) {
|
|
3220
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
3221
|
+
target[name] = utils$1.isArray(target[name])
|
|
3222
|
+
? target[name].concat(value)
|
|
3223
|
+
: [target[name], value];
|
|
3224
|
+
} else {
|
|
3225
|
+
target[name] = value;
|
|
2977
3226
|
}
|
|
2978
|
-
}
|
|
2979
3227
|
|
|
2980
|
-
|
|
2981
|
-
header.forEach(deleteHeader);
|
|
2982
|
-
} else {
|
|
2983
|
-
deleteHeader(header);
|
|
3228
|
+
return !isNumericKey;
|
|
2984
3229
|
}
|
|
2985
3230
|
|
|
2986
|
-
|
|
2987
|
-
|
|
3231
|
+
if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
|
|
3232
|
+
target[name] = [];
|
|
3233
|
+
}
|
|
2988
3234
|
|
|
2989
|
-
|
|
2990
|
-
const keys = Object.keys(this);
|
|
2991
|
-
let i = keys.length;
|
|
2992
|
-
let deleted = false;
|
|
3235
|
+
const result = buildPath(path, value, target[name], index);
|
|
2993
3236
|
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2997
|
-
delete this[key];
|
|
2998
|
-
deleted = true;
|
|
2999
|
-
}
|
|
3237
|
+
if (result && utils$1.isArray(target[name])) {
|
|
3238
|
+
target[name] = arrayToObject(target[name]);
|
|
3000
3239
|
}
|
|
3001
3240
|
|
|
3002
|
-
return
|
|
3241
|
+
return !isNumericKey;
|
|
3003
3242
|
}
|
|
3004
3243
|
|
|
3005
|
-
|
|
3006
|
-
const
|
|
3007
|
-
const headers = {};
|
|
3244
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
3245
|
+
const obj = {};
|
|
3008
3246
|
|
|
3009
|
-
utils$1.
|
|
3010
|
-
|
|
3247
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
3248
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
3249
|
+
});
|
|
3011
3250
|
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
delete self[header];
|
|
3015
|
-
return;
|
|
3016
|
-
}
|
|
3251
|
+
return obj;
|
|
3252
|
+
}
|
|
3017
3253
|
|
|
3018
|
-
|
|
3254
|
+
return null;
|
|
3255
|
+
}
|
|
3019
3256
|
|
|
3020
|
-
|
|
3021
|
-
delete self[header];
|
|
3022
|
-
}
|
|
3257
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
3023
3258
|
|
|
3024
|
-
|
|
3259
|
+
/**
|
|
3260
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
3261
|
+
* of the input
|
|
3262
|
+
*
|
|
3263
|
+
* @param {any} rawValue - The value to be stringified.
|
|
3264
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
3265
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
3266
|
+
*
|
|
3267
|
+
* @returns {string} A stringified version of the rawValue.
|
|
3268
|
+
*/
|
|
3269
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
3270
|
+
if (utils$1.isString(rawValue)) {
|
|
3271
|
+
try {
|
|
3272
|
+
(parser || JSON.parse)(rawValue);
|
|
3273
|
+
return utils$1.trim(rawValue);
|
|
3274
|
+
} catch (e) {
|
|
3275
|
+
if (e.name !== 'SyntaxError') {
|
|
3276
|
+
throw e;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3025
3280
|
|
|
3026
|
-
|
|
3027
|
-
|
|
3281
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
3282
|
+
}
|
|
3028
3283
|
|
|
3029
|
-
|
|
3030
|
-
|
|
3284
|
+
const defaults = {
|
|
3285
|
+
transitional: transitionalDefaults,
|
|
3031
3286
|
|
|
3032
|
-
|
|
3033
|
-
return this.constructor.concat(this, ...targets);
|
|
3034
|
-
}
|
|
3287
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
3035
3288
|
|
|
3036
|
-
|
|
3037
|
-
|
|
3289
|
+
transformRequest: [
|
|
3290
|
+
function transformRequest(data, headers) {
|
|
3291
|
+
const contentType = headers.getContentType() || '';
|
|
3292
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
3293
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
3038
3294
|
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
3043
|
-
});
|
|
3295
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
3296
|
+
data = new FormData(data);
|
|
3297
|
+
}
|
|
3044
3298
|
|
|
3045
|
-
|
|
3046
|
-
}
|
|
3299
|
+
const isFormData = utils$1.isFormData(data);
|
|
3047
3300
|
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3301
|
+
if (isFormData) {
|
|
3302
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
3303
|
+
}
|
|
3051
3304
|
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3305
|
+
if (
|
|
3306
|
+
utils$1.isArrayBuffer(data) ||
|
|
3307
|
+
utils$1.isBuffer(data) ||
|
|
3308
|
+
utils$1.isStream(data) ||
|
|
3309
|
+
utils$1.isFile(data) ||
|
|
3310
|
+
utils$1.isBlob(data) ||
|
|
3311
|
+
utils$1.isReadableStream(data)
|
|
3312
|
+
) {
|
|
3313
|
+
return data;
|
|
3314
|
+
}
|
|
3315
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
3316
|
+
return data.buffer;
|
|
3317
|
+
}
|
|
3318
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
3319
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
3320
|
+
return data.toString();
|
|
3321
|
+
}
|
|
3057
3322
|
|
|
3058
|
-
|
|
3059
|
-
return this.get('set-cookie') || [];
|
|
3060
|
-
}
|
|
3323
|
+
let isFileList;
|
|
3061
3324
|
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3325
|
+
if (isObjectPayload) {
|
|
3326
|
+
const formSerializer = own(this, 'formSerializer');
|
|
3327
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
3328
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
3329
|
+
}
|
|
3065
3330
|
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3331
|
+
if (
|
|
3332
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
3333
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
3334
|
+
) {
|
|
3335
|
+
const env = own(this, 'env');
|
|
3336
|
+
const _FormData = env && env.FormData;
|
|
3069
3337
|
|
|
3070
|
-
|
|
3071
|
-
|
|
3338
|
+
return toFormData(
|
|
3339
|
+
isFileList ? { 'files[]': data } : data,
|
|
3340
|
+
_FormData && new _FormData(),
|
|
3341
|
+
formSerializer
|
|
3342
|
+
);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3072
3345
|
|
|
3073
|
-
|
|
3346
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
3347
|
+
headers.setContentType('application/json', false);
|
|
3348
|
+
return stringifySafely(data);
|
|
3349
|
+
}
|
|
3074
3350
|
|
|
3075
|
-
|
|
3076
|
-
|
|
3351
|
+
return data;
|
|
3352
|
+
},
|
|
3353
|
+
],
|
|
3077
3354
|
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
(this
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
});
|
|
3355
|
+
transformResponse: [
|
|
3356
|
+
function transformResponse(data) {
|
|
3357
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
3358
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
3359
|
+
const responseType = own(this, 'responseType');
|
|
3360
|
+
const JSONRequested = responseType === 'json';
|
|
3085
3361
|
|
|
3086
|
-
|
|
3087
|
-
|
|
3362
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
3363
|
+
return data;
|
|
3364
|
+
}
|
|
3088
3365
|
|
|
3089
|
-
|
|
3090
|
-
|
|
3366
|
+
if (
|
|
3367
|
+
data &&
|
|
3368
|
+
utils$1.isString(data) &&
|
|
3369
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
3370
|
+
) {
|
|
3371
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
3372
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
3091
3373
|
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3374
|
+
try {
|
|
3375
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
3376
|
+
} catch (e) {
|
|
3377
|
+
if (strictJSONParsing) {
|
|
3378
|
+
if (e.name === 'SyntaxError') {
|
|
3379
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
3380
|
+
}
|
|
3381
|
+
throw e;
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3095
3384
|
}
|
|
3096
|
-
}
|
|
3097
3385
|
|
|
3098
|
-
|
|
3386
|
+
return data;
|
|
3387
|
+
},
|
|
3388
|
+
],
|
|
3099
3389
|
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3390
|
+
/**
|
|
3391
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
3392
|
+
* timeout is not created.
|
|
3393
|
+
*/
|
|
3394
|
+
timeout: 0,
|
|
3103
3395
|
|
|
3104
|
-
|
|
3105
|
-
'
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3396
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
3397
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
3398
|
+
|
|
3399
|
+
maxContentLength: -1,
|
|
3400
|
+
maxBodyLength: -1,
|
|
3401
|
+
|
|
3402
|
+
env: {
|
|
3403
|
+
FormData: platform.classes.FormData,
|
|
3404
|
+
Blob: platform.classes.Blob,
|
|
3405
|
+
},
|
|
3112
3406
|
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3407
|
+
validateStatus: function validateStatus(status) {
|
|
3408
|
+
return status >= 200 && status < 300;
|
|
3409
|
+
},
|
|
3410
|
+
|
|
3411
|
+
headers: {
|
|
3412
|
+
common: {
|
|
3413
|
+
Accept: 'application/json, text/plain, */*',
|
|
3414
|
+
'Content-Type': undefined,
|
|
3120
3415
|
},
|
|
3121
|
-
}
|
|
3122
|
-
}
|
|
3416
|
+
},
|
|
3417
|
+
};
|
|
3123
3418
|
|
|
3124
|
-
utils$1.
|
|
3419
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
|
|
3420
|
+
defaults.headers[method] = {};
|
|
3421
|
+
});
|
|
3125
3422
|
|
|
3126
3423
|
/**
|
|
3127
3424
|
* Transform the data for a request or a response
|
|
@@ -3181,22 +3478,18 @@ function settle(resolve, reject, response) {
|
|
|
3181
3478
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
3182
3479
|
resolve(response);
|
|
3183
3480
|
} else {
|
|
3184
|
-
reject(
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
response.request,
|
|
3192
|
-
response
|
|
3193
|
-
)
|
|
3194
|
-
);
|
|
3481
|
+
reject(new AxiosError(
|
|
3482
|
+
'Request failed with status code ' + response.status,
|
|
3483
|
+
response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE,
|
|
3484
|
+
response.config,
|
|
3485
|
+
response.request,
|
|
3486
|
+
response
|
|
3487
|
+
));
|
|
3195
3488
|
}
|
|
3196
3489
|
}
|
|
3197
3490
|
|
|
3198
3491
|
function parseProtocol(url) {
|
|
3199
|
-
const match = /^([-+\w]{1,25})(
|
|
3492
|
+
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
3200
3493
|
return (match && match[1]) || '';
|
|
3201
3494
|
}
|
|
3202
3495
|
|
|
@@ -3300,13 +3593,16 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
3300
3593
|
const _speedometer = speedometer(50, 250);
|
|
3301
3594
|
|
|
3302
3595
|
return throttle((e) => {
|
|
3303
|
-
|
|
3596
|
+
if (!e || typeof e.loaded !== 'number') {
|
|
3597
|
+
return;
|
|
3598
|
+
}
|
|
3599
|
+
const rawLoaded = e.loaded;
|
|
3304
3600
|
const total = e.lengthComputable ? e.total : undefined;
|
|
3305
|
-
const
|
|
3601
|
+
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
3602
|
+
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
3306
3603
|
const rate = _speedometer(progressBytes);
|
|
3307
|
-
const inRange = loaded <= total;
|
|
3308
3604
|
|
|
3309
|
-
bytesNotified = loaded;
|
|
3605
|
+
bytesNotified = Math.max(bytesNotified, loaded);
|
|
3310
3606
|
|
|
3311
3607
|
const data = {
|
|
3312
3608
|
loaded,
|
|
@@ -3314,7 +3610,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
3314
3610
|
progress: total ? loaded / total : undefined,
|
|
3315
3611
|
bytes: progressBytes,
|
|
3316
3612
|
rate: rate ? rate : undefined,
|
|
3317
|
-
estimated: rate && total
|
|
3613
|
+
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
3318
3614
|
event: e,
|
|
3319
3615
|
lengthComputable: total != null,
|
|
3320
3616
|
[isDownloadStream ? 'download' : 'upload']: true,
|
|
@@ -3387,8 +3683,24 @@ var cookies = platform.hasStandardBrowserEnv
|
|
|
3387
3683
|
|
|
3388
3684
|
read(name) {
|
|
3389
3685
|
if (typeof document === 'undefined') return null;
|
|
3390
|
-
|
|
3391
|
-
|
|
3686
|
+
// Match name=value by splitting on the semicolon separator instead of building a
|
|
3687
|
+
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
3688
|
+
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
3689
|
+
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
3690
|
+
// "; ", so ignore optional whitespace before each cookie name.
|
|
3691
|
+
const cookies = document.cookie.split(';');
|
|
3692
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
3693
|
+
const cookie = cookies[i].replace(/^\s+/, '');
|
|
3694
|
+
const eq = cookie.indexOf('=');
|
|
3695
|
+
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
3696
|
+
try {
|
|
3697
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
3698
|
+
} catch (e) {
|
|
3699
|
+
return cookie.slice(eq + 1);
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
return null;
|
|
3392
3704
|
},
|
|
3393
3705
|
|
|
3394
3706
|
remove(name) {
|
|
@@ -3436,6 +3748,31 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
3436
3748
|
: baseURL;
|
|
3437
3749
|
}
|
|
3438
3750
|
|
|
3751
|
+
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
3752
|
+
const httpProtocolControlCharacters = /[\t\n\r]/g;
|
|
3753
|
+
|
|
3754
|
+
function stripLeadingC0ControlOrSpace(url) {
|
|
3755
|
+
let i = 0;
|
|
3756
|
+
while (i < url.length && url.charCodeAt(i) <= 0x20) {
|
|
3757
|
+
i++;
|
|
3758
|
+
}
|
|
3759
|
+
return url.slice(i);
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3762
|
+
function normalizeURLForProtocolCheck(url) {
|
|
3763
|
+
return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
function assertValidHttpProtocolURL(url, config) {
|
|
3767
|
+
if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
|
|
3768
|
+
throw new AxiosError(
|
|
3769
|
+
'Invalid URL: missing "//" after protocol',
|
|
3770
|
+
AxiosError.ERR_INVALID_URL,
|
|
3771
|
+
config
|
|
3772
|
+
);
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
|
|
3439
3776
|
/**
|
|
3440
3777
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
3441
3778
|
* only when the requestedURL is not already an absolute URL.
|
|
@@ -3446,9 +3783,11 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
3446
3783
|
*
|
|
3447
3784
|
* @returns {string} The combined full path
|
|
3448
3785
|
*/
|
|
3449
|
-
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
3786
|
+
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
3787
|
+
assertValidHttpProtocolURL(requestedURL, config);
|
|
3450
3788
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
3451
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls
|
|
3789
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
3790
|
+
assertValidHttpProtocolURL(baseURL, config);
|
|
3452
3791
|
return combineURLs(baseURL, requestedURL);
|
|
3453
3792
|
}
|
|
3454
3793
|
return requestedURL;
|
|
@@ -3467,8 +3806,23 @@ const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing }
|
|
|
3467
3806
|
*/
|
|
3468
3807
|
function mergeConfig(config1, config2) {
|
|
3469
3808
|
// eslint-disable-next-line no-param-reassign
|
|
3809
|
+
config1 = config1 || {};
|
|
3470
3810
|
config2 = config2 || {};
|
|
3471
|
-
|
|
3811
|
+
|
|
3812
|
+
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
3813
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype.
|
|
3814
|
+
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
3815
|
+
// ergonomics for user code that relies on it.
|
|
3816
|
+
const config = Object.create(null);
|
|
3817
|
+
Object.defineProperty(config, 'hasOwnProperty', {
|
|
3818
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
3819
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
3820
|
+
__proto__: null,
|
|
3821
|
+
value: Object.prototype.hasOwnProperty,
|
|
3822
|
+
enumerable: false,
|
|
3823
|
+
writable: true,
|
|
3824
|
+
configurable: true,
|
|
3825
|
+
});
|
|
3472
3826
|
|
|
3473
3827
|
function getMergedValue(target, source, prop, caseless) {
|
|
3474
3828
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
@@ -3505,11 +3859,33 @@ function mergeConfig(config1, config2) {
|
|
|
3505
3859
|
}
|
|
3506
3860
|
}
|
|
3507
3861
|
|
|
3862
|
+
function getMergedTransitionalOption(prop) {
|
|
3863
|
+
const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
|
|
3864
|
+
|
|
3865
|
+
if (!utils$1.isUndefined(transitional2)) {
|
|
3866
|
+
if (utils$1.isPlainObject(transitional2)) {
|
|
3867
|
+
if (utils$1.hasOwnProp(transitional2, prop)) {
|
|
3868
|
+
return transitional2[prop];
|
|
3869
|
+
}
|
|
3870
|
+
} else {
|
|
3871
|
+
return undefined;
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
|
|
3875
|
+
const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
|
|
3876
|
+
|
|
3877
|
+
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
3878
|
+
return transitional1[prop];
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3881
|
+
return undefined;
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3508
3884
|
// eslint-disable-next-line consistent-return
|
|
3509
3885
|
function mergeDirectKeys(a, b, prop) {
|
|
3510
|
-
if (prop
|
|
3886
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
3511
3887
|
return getMergedValue(a, b);
|
|
3512
|
-
} else if (prop
|
|
3888
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
3513
3889
|
return getMergedValue(undefined, a);
|
|
3514
3890
|
}
|
|
3515
3891
|
}
|
|
@@ -3541,6 +3917,7 @@ function mergeConfig(config1, config2) {
|
|
|
3541
3917
|
httpsAgent: defaultToConfig2,
|
|
3542
3918
|
cancelToken: defaultToConfig2,
|
|
3543
3919
|
socketPath: defaultToConfig2,
|
|
3920
|
+
allowedSocketPaths: defaultToConfig2,
|
|
3544
3921
|
responseEncoding: defaultToConfig2,
|
|
3545
3922
|
validateStatus: mergeDirectKeys,
|
|
3546
3923
|
headers: (a, b, prop) =>
|
|
@@ -3550,52 +3927,105 @@ function mergeConfig(config1, config2) {
|
|
|
3550
3927
|
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
3551
3928
|
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
3552
3929
|
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
3553
|
-
const
|
|
3930
|
+
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
3931
|
+
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
3932
|
+
const configValue = merge(a, b, prop);
|
|
3554
3933
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
3555
3934
|
});
|
|
3556
3935
|
|
|
3936
|
+
if (
|
|
3937
|
+
utils$1.hasOwnProp(config2, 'validateStatus') &&
|
|
3938
|
+
utils$1.isUndefined(config2.validateStatus) &&
|
|
3939
|
+
getMergedTransitionalOption('validateStatusUndefinedResolves') === false
|
|
3940
|
+
) {
|
|
3941
|
+
if (utils$1.hasOwnProp(config1, 'validateStatus')) {
|
|
3942
|
+
config.validateStatus = getMergedValue(undefined, config1.validateStatus);
|
|
3943
|
+
} else {
|
|
3944
|
+
delete config.validateStatus;
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3557
3948
|
return config;
|
|
3558
3949
|
}
|
|
3559
3950
|
|
|
3560
|
-
|
|
3951
|
+
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
3952
|
+
|
|
3953
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
3954
|
+
if (policy !== 'content-only') {
|
|
3955
|
+
headers.set(formHeaders);
|
|
3956
|
+
return;
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
3960
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
3961
|
+
headers.set(key, val);
|
|
3962
|
+
}
|
|
3963
|
+
});
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
/**
|
|
3967
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
3968
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
3969
|
+
*
|
|
3970
|
+
* @param {string} str The string to encode
|
|
3971
|
+
*
|
|
3972
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
3973
|
+
*/
|
|
3974
|
+
const encodeUTF8$1 = (str) =>
|
|
3975
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
3976
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
3977
|
+
);
|
|
3978
|
+
|
|
3979
|
+
function resolveConfig(config) {
|
|
3561
3980
|
const newConfig = mergeConfig({}, config);
|
|
3562
3981
|
|
|
3563
|
-
|
|
3982
|
+
// Read only own properties to prevent prototype pollution gadgets
|
|
3983
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
3984
|
+
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
3985
|
+
|
|
3986
|
+
const data = own('data');
|
|
3987
|
+
let withXSRFToken = own('withXSRFToken');
|
|
3988
|
+
const xsrfHeaderName = own('xsrfHeaderName');
|
|
3989
|
+
const xsrfCookieName = own('xsrfCookieName');
|
|
3990
|
+
let headers = own('headers');
|
|
3991
|
+
const auth = own('auth');
|
|
3992
|
+
const baseURL = own('baseURL');
|
|
3993
|
+
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
3994
|
+
const url = own('url');
|
|
3564
3995
|
|
|
3565
3996
|
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
3566
3997
|
|
|
3567
3998
|
newConfig.url = buildURL(
|
|
3568
|
-
buildFullPath(
|
|
3569
|
-
|
|
3570
|
-
|
|
3999
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig),
|
|
4000
|
+
own('params'),
|
|
4001
|
+
own('paramsSerializer')
|
|
3571
4002
|
);
|
|
3572
4003
|
|
|
3573
4004
|
// HTTP basic authentication
|
|
3574
4005
|
if (auth) {
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
)
|
|
4006
|
+
const username = utils$1.getSafeProp(auth, 'username') || '';
|
|
4007
|
+
const password = utils$1.getSafeProp(auth, 'password') || '';
|
|
4008
|
+
|
|
4009
|
+
try {
|
|
4010
|
+
headers.set(
|
|
4011
|
+
'Authorization',
|
|
4012
|
+
'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : ''))
|
|
4013
|
+
);
|
|
4014
|
+
} catch (e) {
|
|
4015
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
4016
|
+
}
|
|
3584
4017
|
}
|
|
3585
4018
|
|
|
3586
4019
|
if (utils$1.isFormData(data)) {
|
|
3587
|
-
if (
|
|
3588
|
-
|
|
4020
|
+
if (
|
|
4021
|
+
platform.hasStandardBrowserEnv ||
|
|
4022
|
+
platform.hasStandardBrowserWebWorkerEnv ||
|
|
4023
|
+
utils$1.isReactNative(data)
|
|
4024
|
+
) {
|
|
4025
|
+
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
3589
4026
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
3590
4027
|
// Node.js FormData (like form-data package)
|
|
3591
|
-
|
|
3592
|
-
// Only set safe headers to avoid overwriting security headers
|
|
3593
|
-
const allowedHeaders = ['content-type', 'content-length'];
|
|
3594
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3595
|
-
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
3596
|
-
headers.set(key, val);
|
|
3597
|
-
}
|
|
3598
|
-
});
|
|
4028
|
+
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
3599
4029
|
}
|
|
3600
4030
|
}
|
|
3601
4031
|
|
|
@@ -3604,10 +4034,17 @@ var resolveConfig = (config) => {
|
|
|
3604
4034
|
// Specifically not if we're in a web worker, or react-native.
|
|
3605
4035
|
|
|
3606
4036
|
if (platform.hasStandardBrowserEnv) {
|
|
3607
|
-
|
|
4037
|
+
if (utils$1.isFunction(withXSRFToken)) {
|
|
4038
|
+
withXSRFToken = withXSRFToken(newConfig);
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
4042
|
+
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
4043
|
+
// the XSRF token cross-origin.
|
|
4044
|
+
const shouldSendXSRF =
|
|
4045
|
+
withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
3608
4046
|
|
|
3609
|
-
if (
|
|
3610
|
-
// Add xsrf header
|
|
4047
|
+
if (shouldSendXSRF) {
|
|
3611
4048
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
3612
4049
|
|
|
3613
4050
|
if (xsrfValue) {
|
|
@@ -3617,7 +4054,7 @@ var resolveConfig = (config) => {
|
|
|
3617
4054
|
}
|
|
3618
4055
|
|
|
3619
4056
|
return newConfig;
|
|
3620
|
-
}
|
|
4057
|
+
}
|
|
3621
4058
|
|
|
3622
4059
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
3623
4060
|
|
|
@@ -3701,7 +4138,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3701
4138
|
// will return status as 0 even though it's a successful request
|
|
3702
4139
|
if (
|
|
3703
4140
|
request.status === 0 &&
|
|
3704
|
-
!(request.responseURL && request.responseURL.
|
|
4141
|
+
!(request.responseURL && request.responseURL.startsWith('file:'))
|
|
3705
4142
|
) {
|
|
3706
4143
|
return;
|
|
3707
4144
|
}
|
|
@@ -3718,6 +4155,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3718
4155
|
}
|
|
3719
4156
|
|
|
3720
4157
|
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
4158
|
+
done();
|
|
3721
4159
|
|
|
3722
4160
|
// Clean up request
|
|
3723
4161
|
request = null;
|
|
@@ -3733,6 +4171,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3733
4171
|
// attach the underlying event for consumers who want details
|
|
3734
4172
|
err.event = event || null;
|
|
3735
4173
|
reject(err);
|
|
4174
|
+
done();
|
|
3736
4175
|
request = null;
|
|
3737
4176
|
};
|
|
3738
4177
|
|
|
@@ -3753,6 +4192,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3753
4192
|
request
|
|
3754
4193
|
)
|
|
3755
4194
|
);
|
|
4195
|
+
done();
|
|
3756
4196
|
|
|
3757
4197
|
// Clean up request
|
|
3758
4198
|
request = null;
|
|
@@ -3763,7 +4203,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3763
4203
|
|
|
3764
4204
|
// Add headers to the request
|
|
3765
4205
|
if ('setRequestHeader' in request) {
|
|
3766
|
-
utils$1.forEach(requestHeaders
|
|
4206
|
+
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
3767
4207
|
request.setRequestHeader(key, val);
|
|
3768
4208
|
});
|
|
3769
4209
|
}
|
|
@@ -3802,6 +4242,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3802
4242
|
}
|
|
3803
4243
|
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
3804
4244
|
request.abort();
|
|
4245
|
+
done();
|
|
3805
4246
|
request = null;
|
|
3806
4247
|
};
|
|
3807
4248
|
|
|
@@ -3815,7 +4256,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3815
4256
|
|
|
3816
4257
|
const protocol = parseProtocol(_config.url);
|
|
3817
4258
|
|
|
3818
|
-
if (protocol && platform.protocols.
|
|
4259
|
+
if (protocol && !platform.protocols.includes(protocol)) {
|
|
3819
4260
|
reject(
|
|
3820
4261
|
new AxiosError(
|
|
3821
4262
|
'Unsupported protocol ' + protocol + ':',
|
|
@@ -3823,6 +4264,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3823
4264
|
config
|
|
3824
4265
|
)
|
|
3825
4266
|
);
|
|
4267
|
+
done();
|
|
3826
4268
|
return;
|
|
3827
4269
|
}
|
|
3828
4270
|
|
|
@@ -3832,54 +4274,55 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3832
4274
|
};
|
|
3833
4275
|
|
|
3834
4276
|
const composeSignals = (signals, timeout) => {
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
if (timeout || length) {
|
|
3838
|
-
let controller = new AbortController();
|
|
3839
|
-
|
|
3840
|
-
let aborted;
|
|
3841
|
-
|
|
3842
|
-
const onabort = function (reason) {
|
|
3843
|
-
if (!aborted) {
|
|
3844
|
-
aborted = true;
|
|
3845
|
-
unsubscribe();
|
|
3846
|
-
const err = reason instanceof Error ? reason : this.reason;
|
|
3847
|
-
controller.abort(
|
|
3848
|
-
err instanceof AxiosError
|
|
3849
|
-
? err
|
|
3850
|
-
: new CanceledError(err instanceof Error ? err.message : err)
|
|
3851
|
-
);
|
|
3852
|
-
}
|
|
3853
|
-
};
|
|
4277
|
+
signals = signals ? signals.filter(Boolean) : [];
|
|
3854
4278
|
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
timer = null;
|
|
3859
|
-
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
|
|
3860
|
-
}, timeout);
|
|
3861
|
-
|
|
3862
|
-
const unsubscribe = () => {
|
|
3863
|
-
if (signals) {
|
|
3864
|
-
timer && clearTimeout(timer);
|
|
3865
|
-
timer = null;
|
|
3866
|
-
signals.forEach((signal) => {
|
|
3867
|
-
signal.unsubscribe
|
|
3868
|
-
? signal.unsubscribe(onabort)
|
|
3869
|
-
: signal.removeEventListener('abort', onabort);
|
|
3870
|
-
});
|
|
3871
|
-
signals = null;
|
|
3872
|
-
}
|
|
3873
|
-
};
|
|
4279
|
+
if (!timeout && !signals.length) {
|
|
4280
|
+
return;
|
|
4281
|
+
}
|
|
3874
4282
|
|
|
3875
|
-
|
|
4283
|
+
const controller = new AbortController();
|
|
3876
4284
|
|
|
3877
|
-
|
|
4285
|
+
let aborted = false;
|
|
3878
4286
|
|
|
3879
|
-
|
|
4287
|
+
const onabort = function (reason) {
|
|
4288
|
+
if (!aborted) {
|
|
4289
|
+
aborted = true;
|
|
4290
|
+
unsubscribe();
|
|
4291
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
4292
|
+
controller.abort(
|
|
4293
|
+
err instanceof AxiosError
|
|
4294
|
+
? err
|
|
4295
|
+
: new CanceledError(err instanceof Error ? err.message : err)
|
|
4296
|
+
);
|
|
4297
|
+
}
|
|
4298
|
+
};
|
|
3880
4299
|
|
|
3881
|
-
|
|
3882
|
-
|
|
4300
|
+
let timer =
|
|
4301
|
+
timeout &&
|
|
4302
|
+
setTimeout(() => {
|
|
4303
|
+
timer = null;
|
|
4304
|
+
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
|
|
4305
|
+
}, timeout);
|
|
4306
|
+
|
|
4307
|
+
const unsubscribe = () => {
|
|
4308
|
+
if (!signals) { return; }
|
|
4309
|
+
timer && clearTimeout(timer);
|
|
4310
|
+
timer = null;
|
|
4311
|
+
signals.forEach((signal) => {
|
|
4312
|
+
signal.unsubscribe
|
|
4313
|
+
? signal.unsubscribe(onabort)
|
|
4314
|
+
: signal.removeEventListener('abort', onabort);
|
|
4315
|
+
});
|
|
4316
|
+
signals = null;
|
|
4317
|
+
};
|
|
4318
|
+
|
|
4319
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort, { once: true }));
|
|
4320
|
+
|
|
4321
|
+
const { signal } = controller;
|
|
4322
|
+
|
|
4323
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
4324
|
+
|
|
4325
|
+
return signal;
|
|
3883
4326
|
};
|
|
3884
4327
|
|
|
3885
4328
|
const streamChunk = function* (chunk, chunkSize) {
|
|
@@ -3972,16 +4415,146 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3972
4415
|
);
|
|
3973
4416
|
};
|
|
3974
4417
|
|
|
4418
|
+
/**
|
|
4419
|
+
* Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|
4420
|
+
* - For base64: compute exact decoded size using length and padding;
|
|
4421
|
+
* handle %XX at the character-count level (no string allocation).
|
|
4422
|
+
* - For non-base64: compute the exact percent-decoded UTF-8 byte length.
|
|
4423
|
+
*
|
|
4424
|
+
* @param {string} url
|
|
4425
|
+
* @returns {number}
|
|
4426
|
+
*/
|
|
4427
|
+
const isHexDigit = (charCode) =>
|
|
4428
|
+
(charCode >= 48 && charCode <= 57) ||
|
|
4429
|
+
(charCode >= 65 && charCode <= 70) ||
|
|
4430
|
+
(charCode >= 97 && charCode <= 102);
|
|
4431
|
+
|
|
4432
|
+
const isPercentEncodedByte = (str, i, len) =>
|
|
4433
|
+
i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
4434
|
+
|
|
4435
|
+
function estimateDataURLDecodedBytes(url) {
|
|
4436
|
+
if (!url || typeof url !== 'string') return 0;
|
|
4437
|
+
if (!url.startsWith('data:')) return 0;
|
|
4438
|
+
|
|
4439
|
+
const comma = url.indexOf(',');
|
|
4440
|
+
if (comma < 0) return 0;
|
|
4441
|
+
|
|
4442
|
+
const meta = url.slice(5, comma);
|
|
4443
|
+
const body = url.slice(comma + 1);
|
|
4444
|
+
const isBase64 = /;base64/i.test(meta);
|
|
4445
|
+
|
|
4446
|
+
if (isBase64) {
|
|
4447
|
+
let effectiveLen = body.length;
|
|
4448
|
+
const len = body.length; // cache length
|
|
4449
|
+
|
|
4450
|
+
for (let i = 0; i < len; i++) {
|
|
4451
|
+
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
4452
|
+
const a = body.charCodeAt(i + 1);
|
|
4453
|
+
const b = body.charCodeAt(i + 2);
|
|
4454
|
+
const isHex = isHexDigit(a) && isHexDigit(b);
|
|
4455
|
+
|
|
4456
|
+
if (isHex) {
|
|
4457
|
+
effectiveLen -= 2;
|
|
4458
|
+
i += 2;
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
|
|
4463
|
+
let pad = 0;
|
|
4464
|
+
let idx = len - 1;
|
|
4465
|
+
|
|
4466
|
+
const tailIsPct3D = (j) =>
|
|
4467
|
+
j >= 2 &&
|
|
4468
|
+
body.charCodeAt(j - 2) === 37 && // '%'
|
|
4469
|
+
body.charCodeAt(j - 1) === 51 && // '3'
|
|
4470
|
+
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
|
|
4471
|
+
|
|
4472
|
+
if (idx >= 0) {
|
|
4473
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
4474
|
+
pad++;
|
|
4475
|
+
idx--;
|
|
4476
|
+
} else if (tailIsPct3D(idx)) {
|
|
4477
|
+
pad++;
|
|
4478
|
+
idx -= 3;
|
|
4479
|
+
}
|
|
4480
|
+
}
|
|
4481
|
+
|
|
4482
|
+
if (pad === 1 && idx >= 0) {
|
|
4483
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
4484
|
+
pad++;
|
|
4485
|
+
} else if (tailIsPct3D(idx)) {
|
|
4486
|
+
pad++;
|
|
4487
|
+
}
|
|
4488
|
+
}
|
|
4489
|
+
|
|
4490
|
+
const groups = Math.floor(effectiveLen / 4);
|
|
4491
|
+
const bytes = groups * 3 - (pad || 0);
|
|
4492
|
+
return bytes > 0 ? bytes : 0;
|
|
4493
|
+
}
|
|
4494
|
+
|
|
4495
|
+
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
4496
|
+
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
4497
|
+
// Valid %XX triplets count as one decoded byte; this matches the bytes that
|
|
4498
|
+
// decodeURIComponent(body) would produce before Buffer re-encodes the string.
|
|
4499
|
+
let bytes = 0;
|
|
4500
|
+
for (let i = 0, len = body.length; i < len; i++) {
|
|
4501
|
+
const c = body.charCodeAt(i);
|
|
4502
|
+
if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
4503
|
+
bytes += 1;
|
|
4504
|
+
i += 2;
|
|
4505
|
+
} else if (c < 0x80) {
|
|
4506
|
+
bytes += 1;
|
|
4507
|
+
} else if (c < 0x800) {
|
|
4508
|
+
bytes += 2;
|
|
4509
|
+
} else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
|
4510
|
+
const next = body.charCodeAt(i + 1);
|
|
4511
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
4512
|
+
bytes += 4;
|
|
4513
|
+
i++;
|
|
4514
|
+
} else {
|
|
4515
|
+
bytes += 3;
|
|
4516
|
+
}
|
|
4517
|
+
} else {
|
|
4518
|
+
bytes += 3;
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4521
|
+
return bytes;
|
|
4522
|
+
}
|
|
4523
|
+
|
|
4524
|
+
const VERSION = "1.18.1";
|
|
4525
|
+
|
|
3975
4526
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3976
4527
|
|
|
3977
4528
|
const { isFunction } = utils$1;
|
|
3978
4529
|
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4530
|
+
/**
|
|
4531
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
4532
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
4533
|
+
*
|
|
4534
|
+
* @param {string} str The string to encode
|
|
4535
|
+
*
|
|
4536
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
4537
|
+
*/
|
|
4538
|
+
const encodeUTF8 = (str) =>
|
|
4539
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
4540
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
4541
|
+
);
|
|
4542
|
+
|
|
4543
|
+
// Node's WHATWG URL parser returns `username` and `password` percent-encoded.
|
|
4544
|
+
// Decode before composing the `auth` option so credentials such as
|
|
4545
|
+
// `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
|
|
4546
|
+
// original value for malformed input so a bad encoding never throws.
|
|
4547
|
+
const decodeURIComponentSafe = (value) => {
|
|
4548
|
+
if (!utils$1.isString(value)) {
|
|
4549
|
+
return value;
|
|
4550
|
+
}
|
|
3983
4551
|
|
|
3984
|
-
|
|
4552
|
+
try {
|
|
4553
|
+
return decodeURIComponent(value);
|
|
4554
|
+
} catch (error) {
|
|
4555
|
+
return value;
|
|
4556
|
+
}
|
|
4557
|
+
};
|
|
3985
4558
|
|
|
3986
4559
|
const test = (fn, ...args) => {
|
|
3987
4560
|
try {
|
|
@@ -3991,12 +4564,30 @@ const test = (fn, ...args) => {
|
|
|
3991
4564
|
}
|
|
3992
4565
|
};
|
|
3993
4566
|
|
|
4567
|
+
const maybeWithAuthCredentials = (url) => {
|
|
4568
|
+
const protocolIndex = url.indexOf('://');
|
|
4569
|
+
let urlToCheck = url;
|
|
4570
|
+
if (protocolIndex !== -1) {
|
|
4571
|
+
urlToCheck = urlToCheck.slice(protocolIndex + 3);
|
|
4572
|
+
}
|
|
4573
|
+
return urlToCheck.includes('@') || urlToCheck.includes(':');
|
|
4574
|
+
};
|
|
4575
|
+
|
|
3994
4576
|
const factory = (env) => {
|
|
4577
|
+
const globalObject =
|
|
4578
|
+
utils$1.global !== undefined && utils$1.global !== null
|
|
4579
|
+
? utils$1.global
|
|
4580
|
+
: globalThis;
|
|
4581
|
+
const { ReadableStream, TextEncoder } = globalObject;
|
|
4582
|
+
|
|
3995
4583
|
env = utils$1.merge.call(
|
|
3996
4584
|
{
|
|
3997
4585
|
skipUndefined: true,
|
|
3998
4586
|
},
|
|
3999
|
-
|
|
4587
|
+
{
|
|
4588
|
+
Request: globalObject.Request,
|
|
4589
|
+
Response: globalObject.Response,
|
|
4590
|
+
},
|
|
4000
4591
|
env
|
|
4001
4592
|
);
|
|
4002
4593
|
|
|
@@ -4009,7 +4600,7 @@ const factory = (env) => {
|
|
|
4009
4600
|
return false;
|
|
4010
4601
|
}
|
|
4011
4602
|
|
|
4012
|
-
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream
|
|
4603
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
|
4013
4604
|
|
|
4014
4605
|
const encodeText =
|
|
4015
4606
|
isFetchSupported &&
|
|
@@ -4026,18 +4617,20 @@ const factory = (env) => {
|
|
|
4026
4617
|
test(() => {
|
|
4027
4618
|
let duplexAccessed = false;
|
|
4028
4619
|
|
|
4029
|
-
const
|
|
4030
|
-
|
|
4031
|
-
const hasContentType = new Request(platform.origin, {
|
|
4032
|
-
body,
|
|
4620
|
+
const request = new Request(platform.origin, {
|
|
4621
|
+
body: new ReadableStream(),
|
|
4033
4622
|
method: 'POST',
|
|
4034
4623
|
get duplex() {
|
|
4035
4624
|
duplexAccessed = true;
|
|
4036
4625
|
return 'half';
|
|
4037
4626
|
},
|
|
4038
|
-
})
|
|
4627
|
+
});
|
|
4039
4628
|
|
|
4040
|
-
|
|
4629
|
+
const hasContentType = request.headers.has('Content-Type');
|
|
4630
|
+
|
|
4631
|
+
if (request.body != null) {
|
|
4632
|
+
request.body.cancel();
|
|
4633
|
+
}
|
|
4041
4634
|
|
|
4042
4635
|
return duplexAccessed && !hasContentType;
|
|
4043
4636
|
});
|
|
@@ -4121,8 +4714,14 @@ const factory = (env) => {
|
|
|
4121
4714
|
headers,
|
|
4122
4715
|
withCredentials = 'same-origin',
|
|
4123
4716
|
fetchOptions,
|
|
4717
|
+
maxContentLength,
|
|
4718
|
+
maxBodyLength,
|
|
4124
4719
|
} = resolveConfig(config);
|
|
4125
4720
|
|
|
4721
|
+
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
4722
|
+
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
4723
|
+
const own = (key) => (utils$1.hasOwnProp(config, key) ? config[key] : undefined);
|
|
4724
|
+
|
|
4126
4725
|
let _fetch = envFetch || fetch;
|
|
4127
4726
|
|
|
4128
4727
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
@@ -4143,34 +4742,166 @@ const factory = (env) => {
|
|
|
4143
4742
|
|
|
4144
4743
|
let requestContentLength;
|
|
4145
4744
|
|
|
4745
|
+
// AxiosError we raise while the request body is being streamed. Captured
|
|
4746
|
+
// by identity so the catch block can surface it directly, regardless of
|
|
4747
|
+
// how the runtime wraps the resulting fetch rejection (undici exposes it
|
|
4748
|
+
// as `err.cause`; some browsers drop the original error entirely).
|
|
4749
|
+
let pendingBodyError = null;
|
|
4750
|
+
|
|
4751
|
+
const maxBodyLengthError = () =>
|
|
4752
|
+
new AxiosError(
|
|
4753
|
+
'Request body larger than maxBodyLength limit',
|
|
4754
|
+
AxiosError.ERR_BAD_REQUEST,
|
|
4755
|
+
config,
|
|
4756
|
+
request
|
|
4757
|
+
);
|
|
4758
|
+
|
|
4146
4759
|
try {
|
|
4760
|
+
// HTTP basic authentication
|
|
4761
|
+
let auth = undefined;
|
|
4762
|
+
const configAuth = own('auth');
|
|
4763
|
+
|
|
4764
|
+
if (configAuth) {
|
|
4765
|
+
const username = utils$1.getSafeProp(configAuth, 'username') || '';
|
|
4766
|
+
const password = utils$1.getSafeProp(configAuth, 'password') || '';
|
|
4767
|
+
auth = {
|
|
4768
|
+
username,
|
|
4769
|
+
password
|
|
4770
|
+
};
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
if (maybeWithAuthCredentials(url)) {
|
|
4774
|
+
const parsedURL = new URL(url, platform.origin);
|
|
4775
|
+
|
|
4776
|
+
if (!auth && (parsedURL.username || parsedURL.password)) {
|
|
4777
|
+
const urlUsername = decodeURIComponentSafe(parsedURL.username);
|
|
4778
|
+
const urlPassword = decodeURIComponentSafe(parsedURL.password);
|
|
4779
|
+
auth = {
|
|
4780
|
+
username: urlUsername,
|
|
4781
|
+
password: urlPassword
|
|
4782
|
+
};
|
|
4783
|
+
}
|
|
4784
|
+
|
|
4785
|
+
if (parsedURL.username || parsedURL.password) {
|
|
4786
|
+
parsedURL.username = '';
|
|
4787
|
+
parsedURL.password = '';
|
|
4788
|
+
url = parsedURL.href;
|
|
4789
|
+
}
|
|
4790
|
+
}
|
|
4791
|
+
|
|
4792
|
+
if (auth) {
|
|
4793
|
+
headers.delete('authorization');
|
|
4794
|
+
headers.set(
|
|
4795
|
+
'Authorization',
|
|
4796
|
+
'Basic ' + btoa(encodeUTF8((auth.username || '') + ':' + (auth.password || '')))
|
|
4797
|
+
);
|
|
4798
|
+
}
|
|
4799
|
+
|
|
4800
|
+
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
4801
|
+
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
4802
|
+
// "if (protocol === 'data:')" branch).
|
|
4803
|
+
if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
|
|
4804
|
+
const estimated = estimateDataURLDecodedBytes(url);
|
|
4805
|
+
if (estimated > maxContentLength) {
|
|
4806
|
+
throw new AxiosError(
|
|
4807
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4808
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
4809
|
+
config,
|
|
4810
|
+
request
|
|
4811
|
+
);
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4814
|
+
|
|
4815
|
+
// Enforce maxBodyLength against known-size bodies before dispatch using
|
|
4816
|
+
// the body's *actual* size — never a caller-declared Content-Length,
|
|
4817
|
+
// which could under-report to slip an oversized body past the check.
|
|
4818
|
+
// Unknown-size streams return undefined here and are counted per-chunk
|
|
4819
|
+
// below as fetch consumes them.
|
|
4820
|
+
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
4821
|
+
const outboundLength = await getBodyLength(data);
|
|
4822
|
+
if (typeof outboundLength === 'number' && isFinite(outboundLength)) {
|
|
4823
|
+
requestContentLength = outboundLength;
|
|
4824
|
+
if (outboundLength > maxBodyLength) {
|
|
4825
|
+
throw maxBodyLengthError();
|
|
4826
|
+
}
|
|
4827
|
+
}
|
|
4828
|
+
}
|
|
4829
|
+
|
|
4830
|
+
// A streamed body under maxBodyLength must be counted as fetch consumes
|
|
4831
|
+
// it; its size is never trusted from a caller-declared Content-Length.
|
|
4832
|
+
const mustEnforceStreamBody =
|
|
4833
|
+
hasMaxBodyLength && (utils$1.isReadableStream(data) || utils$1.isStream(data));
|
|
4834
|
+
|
|
4835
|
+
const trackRequestStream = (stream, onProgress, flush) =>
|
|
4836
|
+
trackStream(
|
|
4837
|
+
stream,
|
|
4838
|
+
DEFAULT_CHUNK_SIZE,
|
|
4839
|
+
(loadedBytes) => {
|
|
4840
|
+
if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
|
|
4841
|
+
throw (pendingBodyError = maxBodyLengthError());
|
|
4842
|
+
}
|
|
4843
|
+
onProgress && onProgress(loadedBytes);
|
|
4844
|
+
},
|
|
4845
|
+
flush
|
|
4846
|
+
);
|
|
4847
|
+
|
|
4147
4848
|
if (
|
|
4148
|
-
onUploadProgress &&
|
|
4149
4849
|
supportsRequestStream &&
|
|
4150
4850
|
method !== 'get' &&
|
|
4151
4851
|
method !== 'head' &&
|
|
4152
|
-
(
|
|
4852
|
+
(onUploadProgress || mustEnforceStreamBody)
|
|
4153
4853
|
) {
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4854
|
+
requestContentLength =
|
|
4855
|
+
requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
|
|
4856
|
+
|
|
4857
|
+
// A declared length of 0 is only trusted to skip the wrap when we are
|
|
4858
|
+
// not enforcing a stream limit (which must not rely on that header).
|
|
4859
|
+
if (requestContentLength !== 0 || mustEnforceStreamBody) {
|
|
4860
|
+
let _request = new Request(url, {
|
|
4861
|
+
method: 'POST',
|
|
4862
|
+
body: data,
|
|
4863
|
+
duplex: 'half',
|
|
4864
|
+
});
|
|
4159
4865
|
|
|
4160
|
-
|
|
4866
|
+
let contentTypeHeader;
|
|
4161
4867
|
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4868
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
4869
|
+
headers.setContentType(contentTypeHeader);
|
|
4870
|
+
}
|
|
4165
4871
|
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4872
|
+
if (_request.body) {
|
|
4873
|
+
const [onProgress, flush] =
|
|
4874
|
+
(onUploadProgress &&
|
|
4875
|
+
progressEventDecorator(
|
|
4876
|
+
requestContentLength,
|
|
4877
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
4878
|
+
)) ||
|
|
4879
|
+
[];
|
|
4171
4880
|
|
|
4172
|
-
|
|
4881
|
+
data = trackRequestStream(_request.body, onProgress, flush);
|
|
4882
|
+
}
|
|
4173
4883
|
}
|
|
4884
|
+
} else if (
|
|
4885
|
+
mustEnforceStreamBody &&
|
|
4886
|
+
!isRequestSupported &&
|
|
4887
|
+
isReadableStreamSupported &&
|
|
4888
|
+
method !== 'get' &&
|
|
4889
|
+
method !== 'head'
|
|
4890
|
+
) {
|
|
4891
|
+
data = trackRequestStream(data);
|
|
4892
|
+
} else if (
|
|
4893
|
+
mustEnforceStreamBody &&
|
|
4894
|
+
isRequestSupported &&
|
|
4895
|
+
!supportsRequestStream &&
|
|
4896
|
+
method !== 'get' &&
|
|
4897
|
+
method !== 'head'
|
|
4898
|
+
) {
|
|
4899
|
+
throw new AxiosError(
|
|
4900
|
+
'Stream request bodies are not supported by the current fetch implementation',
|
|
4901
|
+
AxiosError.ERR_NOT_SUPPORT,
|
|
4902
|
+
config,
|
|
4903
|
+
request
|
|
4904
|
+
);
|
|
4174
4905
|
}
|
|
4175
4906
|
|
|
4176
4907
|
if (!utils$1.isString(withCredentials)) {
|
|
@@ -4181,11 +4912,27 @@ const factory = (env) => {
|
|
|
4181
4912
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
4182
4913
|
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
4183
4914
|
|
|
4915
|
+
// If data is FormData and Content-Type is multipart/form-data without boundary,
|
|
4916
|
+
// delete it so fetch can set it correctly with the boundary
|
|
4917
|
+
if (utils$1.isFormData(data)) {
|
|
4918
|
+
const contentType = headers.getContentType();
|
|
4919
|
+
if (
|
|
4920
|
+
contentType &&
|
|
4921
|
+
/^multipart\/form-data/i.test(contentType) &&
|
|
4922
|
+
!/boundary=/i.test(contentType)
|
|
4923
|
+
) {
|
|
4924
|
+
headers.delete('content-type');
|
|
4925
|
+
}
|
|
4926
|
+
}
|
|
4927
|
+
|
|
4928
|
+
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
4929
|
+
headers.set('User-Agent', 'axios/' + VERSION, false);
|
|
4930
|
+
|
|
4184
4931
|
const resolvedOptions = {
|
|
4185
4932
|
...fetchOptions,
|
|
4186
4933
|
signal: composedSignal,
|
|
4187
4934
|
method: method.toUpperCase(),
|
|
4188
|
-
headers: headers.normalize()
|
|
4935
|
+
headers: toByteStringHeaderObject(headers.normalize()),
|
|
4189
4936
|
body: data,
|
|
4190
4937
|
duplex: 'half',
|
|
4191
4938
|
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
@@ -4197,17 +4944,37 @@ const factory = (env) => {
|
|
|
4197
4944
|
? _fetch(request, fetchOptions)
|
|
4198
4945
|
: _fetch(url, resolvedOptions));
|
|
4199
4946
|
|
|
4947
|
+
const responseHeaders = AxiosHeaders.from(response.headers);
|
|
4948
|
+
|
|
4949
|
+
// Cheap pre-check: if the server honestly declares a content-length that
|
|
4950
|
+
// already exceeds the cap, reject before we start streaming.
|
|
4951
|
+
if (hasMaxContentLength) {
|
|
4952
|
+
const declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
4953
|
+
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
4954
|
+
throw new AxiosError(
|
|
4955
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4956
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
4957
|
+
config,
|
|
4958
|
+
request
|
|
4959
|
+
);
|
|
4960
|
+
}
|
|
4961
|
+
}
|
|
4962
|
+
|
|
4200
4963
|
const isStreamResponse =
|
|
4201
4964
|
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
4202
4965
|
|
|
4203
|
-
if (
|
|
4966
|
+
if (
|
|
4967
|
+
supportsResponseStream &&
|
|
4968
|
+
response.body &&
|
|
4969
|
+
(onDownloadProgress || hasMaxContentLength || (isStreamResponse && unsubscribe))
|
|
4970
|
+
) {
|
|
4204
4971
|
const options = {};
|
|
4205
4972
|
|
|
4206
4973
|
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
4207
4974
|
options[prop] = response[prop];
|
|
4208
4975
|
});
|
|
4209
4976
|
|
|
4210
|
-
const responseContentLength = utils$1.toFiniteNumber(
|
|
4977
|
+
const responseContentLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
4211
4978
|
|
|
4212
4979
|
const [onProgress, flush] =
|
|
4213
4980
|
(onDownloadProgress &&
|
|
@@ -4217,8 +4984,24 @@ const factory = (env) => {
|
|
|
4217
4984
|
)) ||
|
|
4218
4985
|
[];
|
|
4219
4986
|
|
|
4987
|
+
let bytesRead = 0;
|
|
4988
|
+
const onChunkProgress = (loadedBytes) => {
|
|
4989
|
+
if (hasMaxContentLength) {
|
|
4990
|
+
bytesRead = loadedBytes;
|
|
4991
|
+
if (bytesRead > maxContentLength) {
|
|
4992
|
+
throw new AxiosError(
|
|
4993
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4994
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
4995
|
+
config,
|
|
4996
|
+
request
|
|
4997
|
+
);
|
|
4998
|
+
}
|
|
4999
|
+
}
|
|
5000
|
+
onProgress && onProgress(loadedBytes);
|
|
5001
|
+
};
|
|
5002
|
+
|
|
4220
5003
|
response = new Response(
|
|
4221
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE,
|
|
5004
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
|
|
4222
5005
|
flush && flush();
|
|
4223
5006
|
unsubscribe && unsubscribe();
|
|
4224
5007
|
}),
|
|
@@ -4233,6 +5016,33 @@ const factory = (env) => {
|
|
|
4233
5016
|
config
|
|
4234
5017
|
);
|
|
4235
5018
|
|
|
5019
|
+
// Fallback enforcement for environments without ReadableStream support
|
|
5020
|
+
// (legacy runtimes). Detect materialized size from typed output; skip
|
|
5021
|
+
// streams/Response passthrough since the user will read those themselves.
|
|
5022
|
+
if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
|
|
5023
|
+
let materializedSize;
|
|
5024
|
+
if (responseData != null) {
|
|
5025
|
+
if (typeof responseData.byteLength === 'number') {
|
|
5026
|
+
materializedSize = responseData.byteLength;
|
|
5027
|
+
} else if (typeof responseData.size === 'number') {
|
|
5028
|
+
materializedSize = responseData.size;
|
|
5029
|
+
} else if (typeof responseData === 'string') {
|
|
5030
|
+
materializedSize =
|
|
5031
|
+
typeof TextEncoder === 'function'
|
|
5032
|
+
? new TextEncoder().encode(responseData).byteLength
|
|
5033
|
+
: responseData.length;
|
|
5034
|
+
}
|
|
5035
|
+
}
|
|
5036
|
+
if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
|
|
5037
|
+
throw new AxiosError(
|
|
5038
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
5039
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
5040
|
+
config,
|
|
5041
|
+
request
|
|
5042
|
+
);
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
|
|
4236
5046
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
4237
5047
|
|
|
4238
5048
|
return await new Promise((resolve, reject) => {
|
|
@@ -4248,19 +5058,62 @@ const factory = (env) => {
|
|
|
4248
5058
|
} catch (err) {
|
|
4249
5059
|
unsubscribe && unsubscribe();
|
|
4250
5060
|
|
|
5061
|
+
// Safari can surface fetch aborts as a DOMException-like object whose
|
|
5062
|
+
// branded getters throw. Prefer our composed signal reason before reading
|
|
5063
|
+
// the caught error, preserving timeout vs cancellation semantics.
|
|
5064
|
+
if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError) {
|
|
5065
|
+
const canceledError = composedSignal.reason;
|
|
5066
|
+
canceledError.config = config;
|
|
5067
|
+
request && (canceledError.request = request);
|
|
5068
|
+
if (err !== canceledError) {
|
|
5069
|
+
// Non-enumerable to match native Error `cause` semantics so loggers
|
|
5070
|
+
// don't recurse into circular fetch internals (see #7205).
|
|
5071
|
+
Object.defineProperty(canceledError, 'cause', {
|
|
5072
|
+
__proto__: null,
|
|
5073
|
+
value: err,
|
|
5074
|
+
writable: true,
|
|
5075
|
+
enumerable: false,
|
|
5076
|
+
configurable: true,
|
|
5077
|
+
});
|
|
5078
|
+
}
|
|
5079
|
+
throw canceledError;
|
|
5080
|
+
}
|
|
5081
|
+
|
|
5082
|
+
// Surface a maxBodyLength violation we raised while the request body was
|
|
5083
|
+
// being streamed. Matching by identity (rather than reading
|
|
5084
|
+
// `err.cause.isAxiosError`) keeps the error deterministic across runtimes
|
|
5085
|
+
// and avoids both prototype-pollution reads and mis-attributing a foreign
|
|
5086
|
+
// AxiosError that merely happened to land in `err.cause`.
|
|
5087
|
+
if (pendingBodyError) {
|
|
5088
|
+
request && !pendingBodyError.request && (pendingBodyError.request = request);
|
|
5089
|
+
throw pendingBodyError;
|
|
5090
|
+
}
|
|
5091
|
+
|
|
5092
|
+
// Re-throw AxiosErrors we raised synchronously (data: URL / content-length
|
|
5093
|
+
// pre-checks, response size enforcement) without re-wrapping them.
|
|
5094
|
+
if (err instanceof AxiosError) {
|
|
5095
|
+
request && !err.request && (err.request = request);
|
|
5096
|
+
throw err;
|
|
5097
|
+
}
|
|
5098
|
+
|
|
4251
5099
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
err && err.response
|
|
4259
|
-
),
|
|
4260
|
-
{
|
|
4261
|
-
cause: err.cause || err,
|
|
4262
|
-
}
|
|
5100
|
+
const networkError = new AxiosError(
|
|
5101
|
+
'Network Error',
|
|
5102
|
+
AxiosError.ERR_NETWORK,
|
|
5103
|
+
config,
|
|
5104
|
+
request,
|
|
5105
|
+
err && err.response
|
|
4263
5106
|
);
|
|
5107
|
+
// Non-enumerable to match native Error `cause` semantics so loggers
|
|
5108
|
+
// don't recurse into circular fetch internals (see #7205).
|
|
5109
|
+
Object.defineProperty(networkError, 'cause', {
|
|
5110
|
+
__proto__: null,
|
|
5111
|
+
value: err.cause || err,
|
|
5112
|
+
writable: true,
|
|
5113
|
+
enumerable: false,
|
|
5114
|
+
configurable: true,
|
|
5115
|
+
});
|
|
5116
|
+
throw networkError;
|
|
4264
5117
|
}
|
|
4265
5118
|
|
|
4266
5119
|
throw AxiosError.from(err, err && err.code, config, request, err && err.response);
|
|
@@ -4316,11 +5169,13 @@ const knownAdapters = {
|
|
|
4316
5169
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
4317
5170
|
if (fn) {
|
|
4318
5171
|
try {
|
|
4319
|
-
Object.
|
|
5172
|
+
// Null-proto descriptors so a polluted Object.prototype.get cannot turn
|
|
5173
|
+
// these data descriptors into accessor descriptors on the way in.
|
|
5174
|
+
Object.defineProperty(fn, 'name', { __proto__: null, value });
|
|
4320
5175
|
} catch (e) {
|
|
4321
5176
|
// eslint-disable-next-line no-empty
|
|
4322
5177
|
}
|
|
4323
|
-
Object.defineProperty(fn, 'adapterName', { value });
|
|
5178
|
+
Object.defineProperty(fn, 'adapterName', { __proto__: null, value });
|
|
4324
5179
|
}
|
|
4325
5180
|
});
|
|
4326
5181
|
|
|
@@ -4396,7 +5251,7 @@ function getAdapter(adapters, config) {
|
|
|
4396
5251
|
|
|
4397
5252
|
throw new AxiosError(
|
|
4398
5253
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
4399
|
-
|
|
5254
|
+
AxiosError.ERR_NOT_SUPPORT
|
|
4400
5255
|
);
|
|
4401
5256
|
}
|
|
4402
5257
|
|
|
@@ -4462,8 +5317,15 @@ function dispatchRequest(config) {
|
|
|
4462
5317
|
function onAdapterResolution(response) {
|
|
4463
5318
|
throwIfCancellationRequested(config);
|
|
4464
5319
|
|
|
4465
|
-
//
|
|
4466
|
-
|
|
5320
|
+
// Expose the current response on config so that transformResponse can
|
|
5321
|
+
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
5322
|
+
// We clean it up afterwards to avoid polluting the config object.
|
|
5323
|
+
config.response = response;
|
|
5324
|
+
try {
|
|
5325
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
5326
|
+
} finally {
|
|
5327
|
+
delete config.response;
|
|
5328
|
+
}
|
|
4467
5329
|
|
|
4468
5330
|
response.headers = AxiosHeaders.from(response.headers);
|
|
4469
5331
|
|
|
@@ -4475,11 +5337,16 @@ function dispatchRequest(config) {
|
|
|
4475
5337
|
|
|
4476
5338
|
// Transform response data
|
|
4477
5339
|
if (reason && reason.response) {
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
5340
|
+
config.response = reason.response;
|
|
5341
|
+
try {
|
|
5342
|
+
reason.response.data = transformData.call(
|
|
5343
|
+
config,
|
|
5344
|
+
config.transformResponse,
|
|
5345
|
+
reason.response
|
|
5346
|
+
);
|
|
5347
|
+
} finally {
|
|
5348
|
+
delete config.response;
|
|
5349
|
+
}
|
|
4483
5350
|
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|
4484
5351
|
}
|
|
4485
5352
|
}
|
|
@@ -4489,8 +5356,6 @@ function dispatchRequest(config) {
|
|
|
4489
5356
|
);
|
|
4490
5357
|
}
|
|
4491
5358
|
|
|
4492
|
-
const VERSION = "1.15.0";
|
|
4493
|
-
|
|
4494
5359
|
const validators$1 = {};
|
|
4495
5360
|
|
|
4496
5361
|
// eslint-disable-next-line func-names
|
|
@@ -4567,14 +5432,16 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
4567
5432
|
*/
|
|
4568
5433
|
|
|
4569
5434
|
function assertOptions(options, schema, allowUnknown) {
|
|
4570
|
-
if (typeof options !== 'object') {
|
|
5435
|
+
if (typeof options !== 'object' || options === null) {
|
|
4571
5436
|
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
|
4572
5437
|
}
|
|
4573
5438
|
const keys = Object.keys(options);
|
|
4574
5439
|
let i = keys.length;
|
|
4575
5440
|
while (i-- > 0) {
|
|
4576
5441
|
const opt = keys[i];
|
|
4577
|
-
|
|
5442
|
+
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
5443
|
+
// a non-function validator and cause a TypeError.
|
|
5444
|
+
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
4578
5445
|
if (validator) {
|
|
4579
5446
|
const value = options[opt];
|
|
4580
5447
|
const result = value === undefined || validator(value, opt, options);
|
|
@@ -4688,6 +5555,8 @@ class Axios {
|
|
|
4688
5555
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
4689
5556
|
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
4690
5557
|
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
5558
|
+
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
|
|
5559
|
+
validateStatusUndefinedResolves: validators.transitional(validators.boolean),
|
|
4691
5560
|
},
|
|
4692
5561
|
false
|
|
4693
5562
|
);
|
|
@@ -4733,7 +5602,7 @@ class Axios {
|
|
|
4733
5602
|
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
4734
5603
|
|
|
4735
5604
|
headers &&
|
|
4736
|
-
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
5605
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
|
|
4737
5606
|
delete headers[method];
|
|
4738
5607
|
});
|
|
4739
5608
|
|
|
@@ -4817,7 +5686,7 @@ class Axios {
|
|
|
4817
5686
|
|
|
4818
5687
|
getUri(config) {
|
|
4819
5688
|
config = mergeConfig(this.defaults, config);
|
|
4820
|
-
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
5689
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
|
|
4821
5690
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
4822
5691
|
}
|
|
4823
5692
|
}
|
|
@@ -4830,13 +5699,13 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
4830
5699
|
mergeConfig(config || {}, {
|
|
4831
5700
|
method,
|
|
4832
5701
|
url,
|
|
4833
|
-
data: (config
|
|
5702
|
+
data: config && utils$1.hasOwnProp(config, 'data') ? config.data : undefined,
|
|
4834
5703
|
})
|
|
4835
5704
|
);
|
|
4836
5705
|
};
|
|
4837
5706
|
});
|
|
4838
5707
|
|
|
4839
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
5708
|
+
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
4840
5709
|
function generateHTTPMethod(isForm) {
|
|
4841
5710
|
return function httpMethod(url, data, config) {
|
|
4842
5711
|
return this.request(
|
|
@@ -4856,7 +5725,11 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
|
|
|
4856
5725
|
|
|
4857
5726
|
Axios.prototype[method] = generateHTTPMethod();
|
|
4858
5727
|
|
|
4859
|
-
|
|
5728
|
+
// QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|
5729
|
+
// its semantics, so no queryForm shorthand is generated.
|
|
5730
|
+
if (method !== 'query') {
|
|
5731
|
+
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
5732
|
+
}
|
|
4860
5733
|
});
|
|
4861
5734
|
|
|
4862
5735
|
/**
|