@tryghost/content-api 1.12.7 → 1.12.9
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/cjs/content-api.js +8 -8
- package/es/content-api.js +1690 -1189
- package/es/content-api.js.map +1 -1
- package/package.json +8 -8
- package/umd/content-api.min.js +1 -1
- package/umd/content-api.min.js.map +1 -1
package/es/content-api.js
CHANGED
|
@@ -1212,9 +1212,9 @@ const isFile = kindOfTest('File');
|
|
|
1212
1212
|
* also have a `name` and `type` attribute to specify filename and content type
|
|
1213
1213
|
*
|
|
1214
1214
|
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
1215
|
-
*
|
|
1215
|
+
*
|
|
1216
1216
|
* @param {*} value The value to test
|
|
1217
|
-
*
|
|
1217
|
+
*
|
|
1218
1218
|
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
1219
1219
|
*/
|
|
1220
1220
|
const isReactNativeBlob = (value) => {
|
|
@@ -1224,9 +1224,9 @@ const isReactNativeBlob = (value) => {
|
|
|
1224
1224
|
/**
|
|
1225
1225
|
* Determine if environment is React Native
|
|
1226
1226
|
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
1227
|
-
*
|
|
1227
|
+
*
|
|
1228
1228
|
* @param {*} formData The formData to test
|
|
1229
|
-
*
|
|
1229
|
+
*
|
|
1230
1230
|
* @returns {boolean} True if environment is React Native, otherwise false
|
|
1231
1231
|
*/
|
|
1232
1232
|
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
@@ -1245,7 +1245,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
1245
1245
|
*
|
|
1246
1246
|
* @param {*} val The value to test
|
|
1247
1247
|
*
|
|
1248
|
-
* @returns {boolean} True if value is a
|
|
1248
|
+
* @returns {boolean} True if value is a FileList, otherwise false
|
|
1249
1249
|
*/
|
|
1250
1250
|
const isFileList = kindOfTest('FileList');
|
|
1251
1251
|
|
|
@@ -1279,14 +1279,16 @@ const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
|
1279
1279
|
const isFormData = (thing) => {
|
|
1280
1280
|
if (!thing) return false;
|
|
1281
1281
|
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
1282
|
-
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData
|
|
1282
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
1283
1283
|
const proto = getPrototypeOf(thing);
|
|
1284
1284
|
if (!proto || proto === Object.prototype) return false;
|
|
1285
1285
|
if (!isFunction$1(thing.append)) return false;
|
|
1286
1286
|
const kind = kindOf(thing);
|
|
1287
|
-
return
|
|
1287
|
+
return (
|
|
1288
|
+
kind === 'formdata' ||
|
|
1288
1289
|
// detect form-data instance
|
|
1289
|
-
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
1290
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
1291
|
+
);
|
|
1290
1292
|
};
|
|
1291
1293
|
|
|
1292
1294
|
/**
|
|
@@ -1421,7 +1423,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
1421
1423
|
*
|
|
1422
1424
|
* @returns {Object} Result of all merge properties
|
|
1423
1425
|
*/
|
|
1424
|
-
function merge(
|
|
1426
|
+
function merge(...objs) {
|
|
1425
1427
|
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
1426
1428
|
const result = {};
|
|
1427
1429
|
const assignValue = (val, key) => {
|
|
@@ -1430,9 +1432,15 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
1430
1432
|
return;
|
|
1431
1433
|
}
|
|
1432
1434
|
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1435
|
+
// findKey lowercases the key, so caseless lookup only applies to strings —
|
|
1436
|
+
// symbol keys are identity-matched.
|
|
1437
|
+
const targetKey = (caseless && typeof key === 'string' && findKey(result, key)) || key;
|
|
1438
|
+
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
1439
|
+
// chain, so a polluted Object.prototype value could surface here and get
|
|
1440
|
+
// copied into the merged result.
|
|
1441
|
+
const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
|
|
1442
|
+
if (isPlainObject(existing) && isPlainObject(val)) {
|
|
1443
|
+
result[targetKey] = merge(existing, val);
|
|
1436
1444
|
} else if (isPlainObject(val)) {
|
|
1437
1445
|
result[targetKey] = merge({}, val);
|
|
1438
1446
|
} else if (isArray(val)) {
|
|
@@ -1442,8 +1450,25 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
1442
1450
|
}
|
|
1443
1451
|
};
|
|
1444
1452
|
|
|
1445
|
-
for (let i = 0, l =
|
|
1446
|
-
|
|
1453
|
+
for (let i = 0, l = objs.length; i < l; i++) {
|
|
1454
|
+
const source = objs[i];
|
|
1455
|
+
if (!source || isBuffer(source)) {
|
|
1456
|
+
continue;
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
forEach(source, assignValue);
|
|
1460
|
+
|
|
1461
|
+
if (typeof source !== 'object' || isArray(source)) {
|
|
1462
|
+
continue;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
const symbols = Object.getOwnPropertySymbols(source);
|
|
1466
|
+
for (let j = 0; j < symbols.length; j++) {
|
|
1467
|
+
const symbol = symbols[j];
|
|
1468
|
+
if (propertyIsEnumerable.call(source, symbol)) {
|
|
1469
|
+
assignValue(source[symbol], symbol);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1447
1472
|
}
|
|
1448
1473
|
return result;
|
|
1449
1474
|
}
|
|
@@ -1465,6 +1490,9 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
1465
1490
|
(val, key) => {
|
|
1466
1491
|
if (thisArg && isFunction$1(val)) {
|
|
1467
1492
|
Object.defineProperty(a, key, {
|
|
1493
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot
|
|
1494
|
+
// hijack defineProperty's accessor-vs-data resolution.
|
|
1495
|
+
__proto__: null,
|
|
1468
1496
|
value: bind(val, thisArg),
|
|
1469
1497
|
writable: true,
|
|
1470
1498
|
enumerable: true,
|
|
@@ -1472,6 +1500,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
1472
1500
|
});
|
|
1473
1501
|
} else {
|
|
1474
1502
|
Object.defineProperty(a, key, {
|
|
1503
|
+
__proto__: null,
|
|
1475
1504
|
value: val,
|
|
1476
1505
|
writable: true,
|
|
1477
1506
|
enumerable: true,
|
|
@@ -1510,12 +1539,14 @@ const stripBOM = (content) => {
|
|
|
1510
1539
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
1511
1540
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
1512
1541
|
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
1542
|
+
__proto__: null,
|
|
1513
1543
|
value: constructor,
|
|
1514
1544
|
writable: true,
|
|
1515
1545
|
enumerable: false,
|
|
1516
1546
|
configurable: true,
|
|
1517
1547
|
});
|
|
1518
1548
|
Object.defineProperty(constructor, 'super', {
|
|
1549
|
+
__proto__: null,
|
|
1519
1550
|
value: superConstructor.prototype,
|
|
1520
1551
|
});
|
|
1521
1552
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -1666,6 +1697,8 @@ const hasOwnProperty = (
|
|
|
1666
1697
|
hasOwnProperty.call(obj, prop)
|
|
1667
1698
|
)(Object.prototype);
|
|
1668
1699
|
|
|
1700
|
+
const { propertyIsEnumerable } = Object.prototype;
|
|
1701
|
+
|
|
1669
1702
|
/**
|
|
1670
1703
|
* Determine if a value is a RegExp object
|
|
1671
1704
|
*
|
|
@@ -1697,7 +1730,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
1697
1730
|
const freezeMethods = (obj) => {
|
|
1698
1731
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
1699
1732
|
// skip restricted props in strict mode
|
|
1700
|
-
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].
|
|
1733
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
|
1701
1734
|
return false;
|
|
1702
1735
|
}
|
|
1703
1736
|
|
|
@@ -1771,11 +1804,11 @@ function isSpecCompliantForm(thing) {
|
|
|
1771
1804
|
* @returns {Object} The JSON-compatible object.
|
|
1772
1805
|
*/
|
|
1773
1806
|
const toJSONObject = (obj) => {
|
|
1774
|
-
const
|
|
1807
|
+
const visited = new WeakSet();
|
|
1775
1808
|
|
|
1776
|
-
const visit = (source
|
|
1809
|
+
const visit = (source) => {
|
|
1777
1810
|
if (isObject(source)) {
|
|
1778
|
-
if (
|
|
1811
|
+
if (visited.has(source)) {
|
|
1779
1812
|
return;
|
|
1780
1813
|
}
|
|
1781
1814
|
|
|
@@ -1785,15 +1818,16 @@ const toJSONObject = (obj) => {
|
|
|
1785
1818
|
}
|
|
1786
1819
|
|
|
1787
1820
|
if (!('toJSON' in source)) {
|
|
1788
|
-
|
|
1821
|
+
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
1822
|
+
visited.add(source);
|
|
1789
1823
|
const target = isArray(source) ? [] : {};
|
|
1790
1824
|
|
|
1791
1825
|
forEach(source, (value, key) => {
|
|
1792
|
-
const reducedValue = visit(value
|
|
1826
|
+
const reducedValue = visit(value);
|
|
1793
1827
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
1794
1828
|
});
|
|
1795
1829
|
|
|
1796
|
-
|
|
1830
|
+
visited.delete(source);
|
|
1797
1831
|
|
|
1798
1832
|
return target;
|
|
1799
1833
|
}
|
|
@@ -1802,7 +1836,7 @@ const toJSONObject = (obj) => {
|
|
|
1802
1836
|
return source;
|
|
1803
1837
|
};
|
|
1804
1838
|
|
|
1805
|
-
return visit(obj
|
|
1839
|
+
return visit(obj);
|
|
1806
1840
|
};
|
|
1807
1841
|
|
|
1808
1842
|
/**
|
|
@@ -1938,1319 +1972,1431 @@ var utils$1 = {
|
|
|
1938
1972
|
isIterable,
|
|
1939
1973
|
};
|
|
1940
1974
|
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1975
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1976
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1977
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1978
|
+
'age',
|
|
1979
|
+
'authorization',
|
|
1980
|
+
'content-length',
|
|
1981
|
+
'content-type',
|
|
1982
|
+
'etag',
|
|
1983
|
+
'expires',
|
|
1984
|
+
'from',
|
|
1985
|
+
'host',
|
|
1986
|
+
'if-modified-since',
|
|
1987
|
+
'if-unmodified-since',
|
|
1988
|
+
'last-modified',
|
|
1989
|
+
'location',
|
|
1990
|
+
'max-forwards',
|
|
1991
|
+
'proxy-authorization',
|
|
1992
|
+
'referer',
|
|
1993
|
+
'retry-after',
|
|
1994
|
+
'user-agent',
|
|
1995
|
+
]);
|
|
1946
1996
|
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1997
|
+
/**
|
|
1998
|
+
* Parse headers into an object
|
|
1999
|
+
*
|
|
2000
|
+
* ```
|
|
2001
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
2002
|
+
* Content-Type: application/json
|
|
2003
|
+
* Connection: keep-alive
|
|
2004
|
+
* Transfer-Encoding: chunked
|
|
2005
|
+
* ```
|
|
2006
|
+
*
|
|
2007
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
|
2008
|
+
*
|
|
2009
|
+
* @returns {Object} Headers parsed into an object
|
|
2010
|
+
*/
|
|
2011
|
+
var parseHeaders = (rawHeaders) => {
|
|
2012
|
+
const parsed = {};
|
|
2013
|
+
let key;
|
|
2014
|
+
let val;
|
|
2015
|
+
let i;
|
|
1951
2016
|
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2017
|
+
rawHeaders &&
|
|
2018
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
2019
|
+
i = line.indexOf(':');
|
|
2020
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
2021
|
+
val = line.substring(i + 1).trim();
|
|
1955
2022
|
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
* @param {string} message The error message.
|
|
1960
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1961
|
-
* @param {Object} [config] The config.
|
|
1962
|
-
* @param {Object} [request] The request.
|
|
1963
|
-
* @param {Object} [response] The response.
|
|
1964
|
-
*
|
|
1965
|
-
* @returns {Error} The created error.
|
|
1966
|
-
*/
|
|
1967
|
-
constructor(message, code, config, request, response) {
|
|
1968
|
-
super(message);
|
|
2023
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
2024
|
+
return;
|
|
2025
|
+
}
|
|
1969
2026
|
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
2027
|
+
if (key === 'set-cookie') {
|
|
2028
|
+
if (parsed[key]) {
|
|
2029
|
+
parsed[key].push(val);
|
|
2030
|
+
} else {
|
|
2031
|
+
parsed[key] = [val];
|
|
2032
|
+
}
|
|
2033
|
+
} else {
|
|
2034
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
2035
|
+
}
|
|
1978
2036
|
});
|
|
1979
2037
|
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
2038
|
+
return parsed;
|
|
2039
|
+
};
|
|
2040
|
+
|
|
2041
|
+
function trimSPorHTAB(str) {
|
|
2042
|
+
let start = 0;
|
|
2043
|
+
let end = str.length;
|
|
2044
|
+
|
|
2045
|
+
while (start < end) {
|
|
2046
|
+
const code = str.charCodeAt(start);
|
|
2047
|
+
|
|
2048
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2049
|
+
break;
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
start += 1;
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
while (end > start) {
|
|
2056
|
+
const code = str.charCodeAt(end - 1);
|
|
2057
|
+
|
|
2058
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2059
|
+
break;
|
|
1988
2060
|
}
|
|
2061
|
+
|
|
2062
|
+
end -= 1;
|
|
1989
2063
|
}
|
|
1990
2064
|
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
stack: this.stack,
|
|
2004
|
-
// Axios
|
|
2005
|
-
config: utils$1.toJSONObject(this.config),
|
|
2006
|
-
code: this.code,
|
|
2007
|
-
status: this.status,
|
|
2008
|
-
};
|
|
2065
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
// The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
|
|
2069
|
+
// eslint-disable-next-line no-control-regex
|
|
2070
|
+
const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
|
|
2071
|
+
// eslint-disable-next-line no-control-regex
|
|
2072
|
+
const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
|
|
2073
|
+
|
|
2074
|
+
function sanitizeValue(value, invalidChars) {
|
|
2075
|
+
if (utils$1.isArray(value)) {
|
|
2076
|
+
return value.map((item) => sanitizeValue(item, invalidChars));
|
|
2009
2077
|
}
|
|
2078
|
+
|
|
2079
|
+
return trimSPorHTAB(String(value).replace(invalidChars, ''));
|
|
2010
2080
|
}
|
|
2011
2081
|
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
2015
|
-
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
2016
|
-
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
2017
|
-
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
2018
|
-
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
2019
|
-
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
2020
|
-
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
2021
|
-
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
2022
|
-
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
2023
|
-
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
2024
|
-
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
2025
|
-
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
2082
|
+
const sanitizeHeaderValue = (value) =>
|
|
2083
|
+
sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
|
|
2026
2084
|
|
|
2027
|
-
|
|
2085
|
+
const sanitizeByteStringHeaderValue = (value) =>
|
|
2086
|
+
sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
|
|
2028
2087
|
|
|
2029
|
-
|
|
2030
|
-
|
|
2088
|
+
function toByteStringHeaderObject(headers) {
|
|
2089
|
+
const byteStringHeaders = Object.create(null);
|
|
2031
2090
|
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
* @returns {boolean}
|
|
2038
|
-
*/
|
|
2039
|
-
function isVisitable(thing) {
|
|
2040
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
2091
|
+
utils$1.forEach(headers.toJSON(), (value, header) => {
|
|
2092
|
+
byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
|
|
2093
|
+
});
|
|
2094
|
+
|
|
2095
|
+
return byteStringHeaders;
|
|
2041
2096
|
}
|
|
2042
2097
|
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
*
|
|
2048
|
-
* @returns {string} the key without the brackets.
|
|
2049
|
-
*/
|
|
2050
|
-
function removeBrackets(key) {
|
|
2051
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
2098
|
+
const $internals = Symbol('internals');
|
|
2099
|
+
|
|
2100
|
+
function normalizeHeader(header) {
|
|
2101
|
+
return header && String(header).trim().toLowerCase();
|
|
2052
2102
|
}
|
|
2053
2103
|
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
*
|
|
2061
|
-
* @returns {string} The path to the current key.
|
|
2062
|
-
*/
|
|
2063
|
-
function renderKey(path, key, dots) {
|
|
2064
|
-
if (!path) return key;
|
|
2065
|
-
return path
|
|
2066
|
-
.concat(key)
|
|
2067
|
-
.map(function each(token, i) {
|
|
2068
|
-
// eslint-disable-next-line no-param-reassign
|
|
2069
|
-
token = removeBrackets(token);
|
|
2070
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
2071
|
-
})
|
|
2072
|
-
.join(dots ? '.' : '');
|
|
2104
|
+
function normalizeValue(value) {
|
|
2105
|
+
if (value === false || value == null) {
|
|
2106
|
+
return value;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
2073
2110
|
}
|
|
2074
2111
|
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
*
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2112
|
+
function parseTokens(str) {
|
|
2113
|
+
const tokens = Object.create(null);
|
|
2114
|
+
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
2115
|
+
let match;
|
|
2116
|
+
|
|
2117
|
+
while ((match = tokensRE.exec(str))) {
|
|
2118
|
+
tokens[match[1]] = match[2];
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
return tokens;
|
|
2084
2122
|
}
|
|
2085
2123
|
|
|
2086
|
-
const
|
|
2087
|
-
return /^is[A-Z]/.test(prop);
|
|
2088
|
-
});
|
|
2124
|
+
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
2089
2125
|
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
* @param {Object} obj
|
|
2094
|
-
* @param {?Object} [formData]
|
|
2095
|
-
* @param {?Object} [options]
|
|
2096
|
-
* @param {Function} [options.visitor]
|
|
2097
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
2098
|
-
* @param {Boolean} [options.dots = false]
|
|
2099
|
-
* @param {?Boolean} [options.indexes = false]
|
|
2100
|
-
*
|
|
2101
|
-
* @returns {Object}
|
|
2102
|
-
**/
|
|
2103
|
-
|
|
2104
|
-
/**
|
|
2105
|
-
* It converts an object into a FormData object
|
|
2106
|
-
*
|
|
2107
|
-
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
2108
|
-
* @param {string} formData - The FormData object to append to.
|
|
2109
|
-
* @param {Object<string, any>} options
|
|
2110
|
-
*
|
|
2111
|
-
* @returns
|
|
2112
|
-
*/
|
|
2113
|
-
function toFormData(obj, formData, options) {
|
|
2114
|
-
if (!utils$1.isObject(obj)) {
|
|
2115
|
-
throw new TypeError('target must be an object');
|
|
2126
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
2127
|
+
if (utils$1.isFunction(filter)) {
|
|
2128
|
+
return filter.call(this, value, header);
|
|
2116
2129
|
}
|
|
2117
2130
|
|
|
2118
|
-
|
|
2119
|
-
|
|
2131
|
+
if (isHeaderNameFilter) {
|
|
2132
|
+
value = header;
|
|
2133
|
+
}
|
|
2120
2134
|
|
|
2121
|
-
|
|
2122
|
-
options = utils$1.toFlatObject(
|
|
2123
|
-
options,
|
|
2124
|
-
{
|
|
2125
|
-
metaTokens: true,
|
|
2126
|
-
dots: false,
|
|
2127
|
-
indexes: false,
|
|
2128
|
-
},
|
|
2129
|
-
false,
|
|
2130
|
-
function defined(option, source) {
|
|
2131
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
2132
|
-
return !utils$1.isUndefined(source[option]);
|
|
2133
|
-
}
|
|
2134
|
-
);
|
|
2135
|
+
if (!utils$1.isString(value)) return;
|
|
2135
2136
|
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
const dots = options.dots;
|
|
2140
|
-
const indexes = options.indexes;
|
|
2141
|
-
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
2142
|
-
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
2143
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
2137
|
+
if (utils$1.isString(filter)) {
|
|
2138
|
+
return value.indexOf(filter) !== -1;
|
|
2139
|
+
}
|
|
2144
2140
|
|
|
2145
|
-
if (
|
|
2146
|
-
|
|
2141
|
+
if (utils$1.isRegExp(filter)) {
|
|
2142
|
+
return filter.test(value);
|
|
2147
2143
|
}
|
|
2144
|
+
}
|
|
2148
2145
|
|
|
2149
|
-
|
|
2150
|
-
|
|
2146
|
+
function formatHeader(header) {
|
|
2147
|
+
return header
|
|
2148
|
+
.trim()
|
|
2149
|
+
.toLowerCase()
|
|
2150
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
2151
|
+
return char.toUpperCase() + str;
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2151
2154
|
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
}
|
|
2155
|
+
function buildAccessors(obj, header) {
|
|
2156
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
2155
2157
|
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2158
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
2159
|
+
Object.defineProperty(obj, methodName + accessorName, {
|
|
2160
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
2161
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
2162
|
+
__proto__: null,
|
|
2163
|
+
value: function (arg1, arg2, arg3) {
|
|
2164
|
+
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
2165
|
+
},
|
|
2166
|
+
configurable: true,
|
|
2167
|
+
});
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2159
2170
|
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2171
|
+
class AxiosHeaders {
|
|
2172
|
+
constructor(headers) {
|
|
2173
|
+
headers && this.set(headers);
|
|
2174
|
+
}
|
|
2163
2175
|
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
}
|
|
2176
|
+
set(header, valueOrRewrite, rewrite) {
|
|
2177
|
+
const self = this;
|
|
2167
2178
|
|
|
2168
|
-
|
|
2169
|
-
|
|
2179
|
+
function setHeader(_value, _header, _rewrite) {
|
|
2180
|
+
const lHeader = normalizeHeader(_header);
|
|
2170
2181
|
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
* @param {*} value
|
|
2175
|
-
* @param {String|Number} key
|
|
2176
|
-
* @param {Array<String|Number>} path
|
|
2177
|
-
* @this {FormData}
|
|
2178
|
-
*
|
|
2179
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
2180
|
-
*/
|
|
2181
|
-
function defaultVisitor(value, key, path) {
|
|
2182
|
-
let arr = value;
|
|
2182
|
+
if (!lHeader) {
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2183
2185
|
|
|
2184
|
-
|
|
2185
|
-
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
2186
|
-
return false;
|
|
2187
|
-
}
|
|
2186
|
+
const key = utils$1.findKey(self, lHeader);
|
|
2188
2187
|
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
value = JSON.stringify(value);
|
|
2195
|
-
} else if (
|
|
2196
|
-
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
2197
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
2188
|
+
if (
|
|
2189
|
+
!key ||
|
|
2190
|
+
self[key] === undefined ||
|
|
2191
|
+
_rewrite === true ||
|
|
2192
|
+
(_rewrite === undefined && self[key] !== false)
|
|
2198
2193
|
) {
|
|
2199
|
-
|
|
2200
|
-
key = removeBrackets(key);
|
|
2201
|
-
|
|
2202
|
-
arr.forEach(function each(el, index) {
|
|
2203
|
-
!(utils$1.isUndefined(el) || el === null) &&
|
|
2204
|
-
formData.append(
|
|
2205
|
-
// eslint-disable-next-line no-nested-ternary
|
|
2206
|
-
indexes === true
|
|
2207
|
-
? renderKey([key], index, dots)
|
|
2208
|
-
: indexes === null
|
|
2209
|
-
? key
|
|
2210
|
-
: key + '[]',
|
|
2211
|
-
convertValue(el)
|
|
2212
|
-
);
|
|
2213
|
-
});
|
|
2214
|
-
return false;
|
|
2194
|
+
self[key || _header] = normalizeValue(_value);
|
|
2215
2195
|
}
|
|
2216
2196
|
}
|
|
2217
2197
|
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
}
|
|
2198
|
+
const setHeaders = (headers, _rewrite) =>
|
|
2199
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
2221
2200
|
|
|
2222
|
-
|
|
2201
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
2202
|
+
setHeaders(header, valueOrRewrite);
|
|
2203
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2204
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
2205
|
+
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
2206
|
+
let obj = {},
|
|
2207
|
+
dest,
|
|
2208
|
+
key;
|
|
2209
|
+
for (const entry of header) {
|
|
2210
|
+
if (!utils$1.isArray(entry)) {
|
|
2211
|
+
throw new TypeError('Object iterator must return a key-value pair');
|
|
2212
|
+
}
|
|
2223
2213
|
|
|
2224
|
-
|
|
2214
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
2215
|
+
? utils$1.isArray(dest)
|
|
2216
|
+
? [...dest, entry[1]]
|
|
2217
|
+
: [dest, entry[1]]
|
|
2218
|
+
: entry[1];
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
setHeaders(obj, valueOrRewrite);
|
|
2222
|
+
} else {
|
|
2223
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
return this;
|
|
2225
2227
|
}
|
|
2226
2228
|
|
|
2227
|
-
|
|
2229
|
+
get(header, parser) {
|
|
2230
|
+
header = normalizeHeader(header);
|
|
2228
2231
|
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
convertValue,
|
|
2232
|
-
isVisitable,
|
|
2233
|
-
});
|
|
2232
|
+
if (header) {
|
|
2233
|
+
const key = utils$1.findKey(this, header);
|
|
2234
2234
|
|
|
2235
|
-
|
|
2236
|
-
|
|
2235
|
+
if (key) {
|
|
2236
|
+
const value = this[key];
|
|
2237
2237
|
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2242
|
-
);
|
|
2243
|
-
}
|
|
2238
|
+
if (!parser) {
|
|
2239
|
+
return value;
|
|
2240
|
+
}
|
|
2244
2241
|
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2242
|
+
if (parser === true) {
|
|
2243
|
+
return parseTokens(value);
|
|
2244
|
+
}
|
|
2248
2245
|
|
|
2249
|
-
|
|
2246
|
+
if (utils$1.isFunction(parser)) {
|
|
2247
|
+
return parser.call(this, value, key);
|
|
2248
|
+
}
|
|
2250
2249
|
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
2250
|
+
if (utils$1.isRegExp(parser)) {
|
|
2251
|
+
return parser.exec(value);
|
|
2252
|
+
}
|
|
2255
2253
|
|
|
2256
|
-
|
|
2257
|
-
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
2254
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
|
2258
2255
|
}
|
|
2259
|
-
}
|
|
2260
|
-
|
|
2261
|
-
stack.pop();
|
|
2256
|
+
}
|
|
2262
2257
|
}
|
|
2263
2258
|
|
|
2264
|
-
|
|
2265
|
-
|
|
2259
|
+
has(header, matcher) {
|
|
2260
|
+
header = normalizeHeader(header);
|
|
2261
|
+
|
|
2262
|
+
if (header) {
|
|
2263
|
+
const key = utils$1.findKey(this, header);
|
|
2264
|
+
|
|
2265
|
+
return !!(
|
|
2266
|
+
key &&
|
|
2267
|
+
this[key] !== undefined &&
|
|
2268
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
return false;
|
|
2266
2273
|
}
|
|
2267
2274
|
|
|
2268
|
-
|
|
2275
|
+
delete(header, matcher) {
|
|
2276
|
+
const self = this;
|
|
2277
|
+
let deleted = false;
|
|
2269
2278
|
|
|
2270
|
-
|
|
2271
|
-
|
|
2279
|
+
function deleteHeader(_header) {
|
|
2280
|
+
_header = normalizeHeader(_header);
|
|
2272
2281
|
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
* their percent-encoded equivalents
|
|
2276
|
-
*
|
|
2277
|
-
* @param {string} str - The string to encode.
|
|
2278
|
-
*
|
|
2279
|
-
* @returns {string} The encoded string.
|
|
2280
|
-
*/
|
|
2281
|
-
function encode$1(str) {
|
|
2282
|
-
const charMap = {
|
|
2283
|
-
'!': '%21',
|
|
2284
|
-
"'": '%27',
|
|
2285
|
-
'(': '%28',
|
|
2286
|
-
')': '%29',
|
|
2287
|
-
'~': '%7E',
|
|
2288
|
-
'%20': '+',
|
|
2289
|
-
};
|
|
2290
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
2291
|
-
return charMap[match];
|
|
2292
|
-
});
|
|
2293
|
-
}
|
|
2282
|
+
if (_header) {
|
|
2283
|
+
const key = utils$1.findKey(self, _header);
|
|
2294
2284
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
*
|
|
2298
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
2299
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
2300
|
-
*
|
|
2301
|
-
* @returns {void}
|
|
2302
|
-
*/
|
|
2303
|
-
function AxiosURLSearchParams(params, options) {
|
|
2304
|
-
this._pairs = [];
|
|
2285
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
2286
|
+
delete self[key];
|
|
2305
2287
|
|
|
2306
|
-
|
|
2307
|
-
}
|
|
2288
|
+
deleted = true;
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2308
2292
|
|
|
2309
|
-
|
|
2293
|
+
if (utils$1.isArray(header)) {
|
|
2294
|
+
header.forEach(deleteHeader);
|
|
2295
|
+
} else {
|
|
2296
|
+
deleteHeader(header);
|
|
2297
|
+
}
|
|
2310
2298
|
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
};
|
|
2299
|
+
return deleted;
|
|
2300
|
+
}
|
|
2314
2301
|
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2302
|
+
clear(matcher) {
|
|
2303
|
+
const keys = Object.keys(this);
|
|
2304
|
+
let i = keys.length;
|
|
2305
|
+
let deleted = false;
|
|
2306
|
+
|
|
2307
|
+
while (i--) {
|
|
2308
|
+
const key = keys[i];
|
|
2309
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2310
|
+
delete this[key];
|
|
2311
|
+
deleted = true;
|
|
2319
2312
|
}
|
|
2320
|
-
|
|
2313
|
+
}
|
|
2321
2314
|
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
2325
|
-
}, '')
|
|
2326
|
-
.join('&');
|
|
2327
|
-
};
|
|
2315
|
+
return deleted;
|
|
2316
|
+
}
|
|
2328
2317
|
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
*
|
|
2333
|
-
* @param {string} val The value to be encoded.
|
|
2334
|
-
*
|
|
2335
|
-
* @returns {string} The encoded value.
|
|
2336
|
-
*/
|
|
2337
|
-
function encode(val) {
|
|
2338
|
-
return encodeURIComponent(val)
|
|
2339
|
-
.replace(/%3A/gi, ':')
|
|
2340
|
-
.replace(/%24/g, '$')
|
|
2341
|
-
.replace(/%2C/gi, ',')
|
|
2342
|
-
.replace(/%20/g, '+');
|
|
2343
|
-
}
|
|
2318
|
+
normalize(format) {
|
|
2319
|
+
const self = this;
|
|
2320
|
+
const headers = {};
|
|
2344
2321
|
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
*
|
|
2348
|
-
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
2349
|
-
* @param {object} [params] The params to be appended
|
|
2350
|
-
* @param {?(object|Function)} options
|
|
2351
|
-
*
|
|
2352
|
-
* @returns {string} The formatted url
|
|
2353
|
-
*/
|
|
2354
|
-
function buildURL(url, params, options) {
|
|
2355
|
-
if (!params) {
|
|
2356
|
-
return url;
|
|
2357
|
-
}
|
|
2322
|
+
utils$1.forEach(this, (value, header) => {
|
|
2323
|
+
const key = utils$1.findKey(headers, header);
|
|
2358
2324
|
|
|
2359
|
-
|
|
2325
|
+
if (key) {
|
|
2326
|
+
self[key] = normalizeValue(value);
|
|
2327
|
+
delete self[header];
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2360
2330
|
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2331
|
+
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
2332
|
+
|
|
2333
|
+
if (normalized !== header) {
|
|
2334
|
+
delete self[header];
|
|
2364
2335
|
}
|
|
2365
|
-
: options;
|
|
2366
2336
|
|
|
2367
|
-
|
|
2337
|
+
self[normalized] = normalizeValue(value);
|
|
2368
2338
|
|
|
2369
|
-
|
|
2339
|
+
headers[normalized] = true;
|
|
2340
|
+
});
|
|
2370
2341
|
|
|
2371
|
-
|
|
2372
|
-
serializedParams = serializeFn(params, _options);
|
|
2373
|
-
} else {
|
|
2374
|
-
serializedParams = utils$1.isURLSearchParams(params)
|
|
2375
|
-
? params.toString()
|
|
2376
|
-
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
2342
|
+
return this;
|
|
2377
2343
|
}
|
|
2378
2344
|
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
if (hashmarkIndex !== -1) {
|
|
2383
|
-
url = url.slice(0, hashmarkIndex);
|
|
2384
|
-
}
|
|
2385
|
-
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
2345
|
+
concat(...targets) {
|
|
2346
|
+
return this.constructor.concat(this, ...targets);
|
|
2386
2347
|
}
|
|
2387
2348
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2349
|
+
toJSON(asStrings) {
|
|
2350
|
+
const obj = Object.create(null);
|
|
2390
2351
|
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2352
|
+
utils$1.forEach(this, (value, header) => {
|
|
2353
|
+
value != null &&
|
|
2354
|
+
value !== false &&
|
|
2355
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
2356
|
+
});
|
|
2357
|
+
|
|
2358
|
+
return obj;
|
|
2394
2359
|
}
|
|
2395
2360
|
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
*
|
|
2399
|
-
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
2400
|
-
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
2401
|
-
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
2402
|
-
*
|
|
2403
|
-
* @return {Number} An ID used to remove interceptor later
|
|
2404
|
-
*/
|
|
2405
|
-
use(fulfilled, rejected, options) {
|
|
2406
|
-
this.handlers.push({
|
|
2407
|
-
fulfilled,
|
|
2408
|
-
rejected,
|
|
2409
|
-
synchronous: options ? options.synchronous : false,
|
|
2410
|
-
runWhen: options ? options.runWhen : null,
|
|
2411
|
-
});
|
|
2412
|
-
return this.handlers.length - 1;
|
|
2361
|
+
[Symbol.iterator]() {
|
|
2362
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
2413
2363
|
}
|
|
2414
2364
|
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
*
|
|
2420
|
-
* @returns {void}
|
|
2421
|
-
*/
|
|
2422
|
-
eject(id) {
|
|
2423
|
-
if (this.handlers[id]) {
|
|
2424
|
-
this.handlers[id] = null;
|
|
2425
|
-
}
|
|
2365
|
+
toString() {
|
|
2366
|
+
return Object.entries(this.toJSON())
|
|
2367
|
+
.map(([header, value]) => header + ': ' + value)
|
|
2368
|
+
.join('\n');
|
|
2426
2369
|
}
|
|
2427
2370
|
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
*
|
|
2431
|
-
* @returns {void}
|
|
2432
|
-
*/
|
|
2433
|
-
clear() {
|
|
2434
|
-
if (this.handlers) {
|
|
2435
|
-
this.handlers = [];
|
|
2436
|
-
}
|
|
2371
|
+
getSetCookie() {
|
|
2372
|
+
return this.get('set-cookie') || [];
|
|
2437
2373
|
}
|
|
2438
2374
|
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
*
|
|
2442
|
-
* This method is particularly useful for skipping over any
|
|
2443
|
-
* interceptors that may have become `null` calling `eject`.
|
|
2444
|
-
*
|
|
2445
|
-
* @param {Function} fn The function to call for each interceptor
|
|
2446
|
-
*
|
|
2447
|
-
* @returns {void}
|
|
2448
|
-
*/
|
|
2449
|
-
forEach(fn) {
|
|
2450
|
-
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
2451
|
-
if (h !== null) {
|
|
2452
|
-
fn(h);
|
|
2453
|
-
}
|
|
2454
|
-
});
|
|
2375
|
+
get [Symbol.toStringTag]() {
|
|
2376
|
+
return 'AxiosHeaders';
|
|
2455
2377
|
}
|
|
2456
|
-
}
|
|
2457
2378
|
|
|
2458
|
-
|
|
2379
|
+
static from(thing) {
|
|
2380
|
+
return thing instanceof this ? thing : new this(thing);
|
|
2381
|
+
}
|
|
2459
2382
|
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
forcedJSONParsing: true,
|
|
2463
|
-
clarifyTimeoutError: false,
|
|
2464
|
-
legacyInterceptorReqResOrdering: true,
|
|
2465
|
-
};
|
|
2383
|
+
static concat(first, ...targets) {
|
|
2384
|
+
const computed = new this(first);
|
|
2466
2385
|
|
|
2467
|
-
|
|
2386
|
+
targets.forEach((target) => computed.set(target));
|
|
2468
2387
|
|
|
2469
|
-
|
|
2388
|
+
return computed;
|
|
2389
|
+
}
|
|
2470
2390
|
|
|
2471
|
-
|
|
2391
|
+
static accessor(header) {
|
|
2392
|
+
const internals =
|
|
2393
|
+
(this[$internals] =
|
|
2394
|
+
this[$internals] =
|
|
2395
|
+
{
|
|
2396
|
+
accessors: {},
|
|
2397
|
+
});
|
|
2472
2398
|
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
classes: {
|
|
2476
|
-
URLSearchParams: URLSearchParams$1,
|
|
2477
|
-
FormData: FormData$1,
|
|
2478
|
-
Blob: Blob$1,
|
|
2479
|
-
},
|
|
2480
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
2481
|
-
};
|
|
2399
|
+
const accessors = internals.accessors;
|
|
2400
|
+
const prototype = this.prototype;
|
|
2482
2401
|
|
|
2483
|
-
|
|
2402
|
+
function defineAccessor(_header) {
|
|
2403
|
+
const lHeader = normalizeHeader(_header);
|
|
2484
2404
|
|
|
2485
|
-
|
|
2405
|
+
if (!accessors[lHeader]) {
|
|
2406
|
+
buildAccessors(prototype, _header);
|
|
2407
|
+
accessors[lHeader] = true;
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2486
2410
|
|
|
2487
|
-
|
|
2488
|
-
* Determine if we're running in a standard browser environment
|
|
2489
|
-
*
|
|
2490
|
-
* This allows axios to run in a web worker, and react-native.
|
|
2491
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
2492
|
-
*
|
|
2493
|
-
* web workers:
|
|
2494
|
-
* typeof window -> undefined
|
|
2495
|
-
* typeof document -> undefined
|
|
2496
|
-
*
|
|
2497
|
-
* react-native:
|
|
2498
|
-
* navigator.product -> 'ReactNative'
|
|
2499
|
-
* nativescript
|
|
2500
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
2501
|
-
*
|
|
2502
|
-
* @returns {boolean}
|
|
2503
|
-
*/
|
|
2504
|
-
const hasStandardBrowserEnv =
|
|
2505
|
-
hasBrowserEnv &&
|
|
2506
|
-
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2411
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
2507
2412
|
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
* Although the `isStandardBrowserEnv` method indicates that
|
|
2512
|
-
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
2513
|
-
* filtered out due to its judgment standard
|
|
2514
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
2515
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
2516
|
-
*/
|
|
2517
|
-
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
2518
|
-
return (
|
|
2519
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
|
2520
|
-
// eslint-disable-next-line no-undef
|
|
2521
|
-
self instanceof WorkerGlobalScope &&
|
|
2522
|
-
typeof self.importScripts === 'function'
|
|
2523
|
-
);
|
|
2524
|
-
})();
|
|
2413
|
+
return this;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2525
2416
|
|
|
2526
|
-
|
|
2417
|
+
AxiosHeaders.accessor([
|
|
2418
|
+
'Content-Type',
|
|
2419
|
+
'Content-Length',
|
|
2420
|
+
'Accept',
|
|
2421
|
+
'Accept-Encoding',
|
|
2422
|
+
'User-Agent',
|
|
2423
|
+
'Authorization',
|
|
2424
|
+
]);
|
|
2527
2425
|
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2426
|
+
// reserved names hotfix
|
|
2427
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
|
2428
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2429
|
+
return {
|
|
2430
|
+
get: () => value,
|
|
2431
|
+
set(headerValue) {
|
|
2432
|
+
this[mapped] = headerValue;
|
|
2433
|
+
},
|
|
2434
|
+
};
|
|
2535
2435
|
});
|
|
2536
2436
|
|
|
2537
|
-
|
|
2538
|
-
...utils,
|
|
2539
|
-
...platform$1,
|
|
2540
|
-
};
|
|
2437
|
+
utils$1.freezeMethods(AxiosHeaders);
|
|
2541
2438
|
|
|
2542
|
-
|
|
2543
|
-
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
2544
|
-
visitor: function (value, key, path, helpers) {
|
|
2545
|
-
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
2546
|
-
this.append(key, value.toString('base64'));
|
|
2547
|
-
return false;
|
|
2548
|
-
}
|
|
2439
|
+
var AxiosHeaders$1 = AxiosHeaders;
|
|
2549
2440
|
|
|
2550
|
-
|
|
2551
|
-
},
|
|
2552
|
-
...options,
|
|
2553
|
-
});
|
|
2554
|
-
}
|
|
2441
|
+
const REDACTED = '[REDACTED ****]';
|
|
2555
2442
|
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
*
|
|
2561
|
-
* @returns An array of strings.
|
|
2562
|
-
*/
|
|
2563
|
-
function parsePropPath(name) {
|
|
2564
|
-
// foo[x][y][z]
|
|
2565
|
-
// foo.x.y.z
|
|
2566
|
-
// foo-x-y-z
|
|
2567
|
-
// foo x y z
|
|
2568
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
2569
|
-
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
2570
|
-
});
|
|
2571
|
-
}
|
|
2443
|
+
function hasOwnOrPrototypeToJSON(source) {
|
|
2444
|
+
if (utils$1.hasOwnProp(source, 'toJSON')) {
|
|
2445
|
+
return true;
|
|
2446
|
+
}
|
|
2572
2447
|
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
const obj = {};
|
|
2582
|
-
const keys = Object.keys(arr);
|
|
2583
|
-
let i;
|
|
2584
|
-
const len = keys.length;
|
|
2585
|
-
let key;
|
|
2586
|
-
for (i = 0; i < len; i++) {
|
|
2587
|
-
key = keys[i];
|
|
2588
|
-
obj[key] = arr[key];
|
|
2448
|
+
let prototype = Object.getPrototypeOf(source);
|
|
2449
|
+
|
|
2450
|
+
while (prototype && prototype !== Object.prototype) {
|
|
2451
|
+
if (utils$1.hasOwnProp(prototype, 'toJSON')) {
|
|
2452
|
+
return true;
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
2589
2456
|
}
|
|
2590
|
-
|
|
2457
|
+
|
|
2458
|
+
return false;
|
|
2591
2459
|
}
|
|
2592
2460
|
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
*/
|
|
2600
|
-
function formDataToJSON(formData) {
|
|
2601
|
-
function buildPath(path, value, target, index) {
|
|
2602
|
-
let name = path[index++];
|
|
2461
|
+
// Build a plain-object snapshot of `config` and replace the value of any key
|
|
2462
|
+
// (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|
2463
|
+
// and AxiosHeaders, and short-circuits on circular references.
|
|
2464
|
+
function redactConfig(config, redactKeys) {
|
|
2465
|
+
const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
|
|
2466
|
+
const seen = [];
|
|
2603
2467
|
|
|
2604
|
-
|
|
2468
|
+
const visit = (source) => {
|
|
2469
|
+
if (source === null || typeof source !== 'object') return source;
|
|
2470
|
+
if (utils$1.isBuffer(source)) return source;
|
|
2471
|
+
if (seen.indexOf(source) !== -1) return undefined;
|
|
2605
2472
|
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2473
|
+
if (source instanceof AxiosHeaders$1) {
|
|
2474
|
+
source = source.toJSON();
|
|
2475
|
+
}
|
|
2609
2476
|
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2477
|
+
seen.push(source);
|
|
2478
|
+
|
|
2479
|
+
let result;
|
|
2480
|
+
if (utils$1.isArray(source)) {
|
|
2481
|
+
result = [];
|
|
2482
|
+
source.forEach((v, i) => {
|
|
2483
|
+
const reducedValue = visit(v);
|
|
2484
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
2485
|
+
result[i] = reducedValue;
|
|
2486
|
+
}
|
|
2487
|
+
});
|
|
2488
|
+
} else {
|
|
2489
|
+
if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|
2490
|
+
seen.pop();
|
|
2491
|
+
return source;
|
|
2617
2492
|
}
|
|
2618
2493
|
|
|
2619
|
-
|
|
2494
|
+
result = Object.create(null);
|
|
2495
|
+
for (const [key, value] of Object.entries(source)) {
|
|
2496
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
|
|
2497
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
2498
|
+
result[key] = reducedValue;
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2620
2501
|
}
|
|
2621
2502
|
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2503
|
+
seen.pop();
|
|
2504
|
+
return result;
|
|
2505
|
+
};
|
|
2625
2506
|
|
|
2626
|
-
|
|
2507
|
+
return visit(config);
|
|
2508
|
+
}
|
|
2627
2509
|
|
|
2628
|
-
|
|
2629
|
-
|
|
2510
|
+
class AxiosError extends Error {
|
|
2511
|
+
static from(error, code, config, request, response, customProps) {
|
|
2512
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
2513
|
+
axiosError.cause = error;
|
|
2514
|
+
axiosError.name = error.name;
|
|
2515
|
+
|
|
2516
|
+
// Preserve status from the original error if not already set from response
|
|
2517
|
+
if (error.status != null && axiosError.status == null) {
|
|
2518
|
+
axiosError.status = error.status;
|
|
2630
2519
|
}
|
|
2631
2520
|
|
|
2632
|
-
|
|
2521
|
+
customProps && Object.assign(axiosError, customProps);
|
|
2522
|
+
return axiosError;
|
|
2633
2523
|
}
|
|
2634
2524
|
|
|
2635
|
-
|
|
2636
|
-
|
|
2525
|
+
/**
|
|
2526
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
2527
|
+
*
|
|
2528
|
+
* @param {string} message The error message.
|
|
2529
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
2530
|
+
* @param {Object} [config] The config.
|
|
2531
|
+
* @param {Object} [request] The request.
|
|
2532
|
+
* @param {Object} [response] The response.
|
|
2533
|
+
*
|
|
2534
|
+
* @returns {Error} The created error.
|
|
2535
|
+
*/
|
|
2536
|
+
constructor(message, code, config, request, response) {
|
|
2537
|
+
super(message);
|
|
2637
2538
|
|
|
2638
|
-
|
|
2639
|
-
|
|
2539
|
+
// Make message enumerable to maintain backward compatibility
|
|
2540
|
+
// The native Error constructor sets message as non-enumerable,
|
|
2541
|
+
// but axios < v1.13.3 had it as enumerable
|
|
2542
|
+
Object.defineProperty(this, 'message', {
|
|
2543
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
2544
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
2545
|
+
__proto__: null,
|
|
2546
|
+
value: message,
|
|
2547
|
+
enumerable: true,
|
|
2548
|
+
writable: true,
|
|
2549
|
+
configurable: true,
|
|
2640
2550
|
});
|
|
2641
2551
|
|
|
2642
|
-
|
|
2552
|
+
this.name = 'AxiosError';
|
|
2553
|
+
this.isAxiosError = true;
|
|
2554
|
+
code && (this.code = code);
|
|
2555
|
+
config && (this.config = config);
|
|
2556
|
+
request && (this.request = request);
|
|
2557
|
+
if (response) {
|
|
2558
|
+
this.response = response;
|
|
2559
|
+
this.status = response.status;
|
|
2560
|
+
}
|
|
2643
2561
|
}
|
|
2644
2562
|
|
|
2645
|
-
|
|
2563
|
+
toJSON() {
|
|
2564
|
+
// Opt-in redaction: when the request config carries a `redact` array, the
|
|
2565
|
+
// value of any matching key (case-insensitive, at any depth) is replaced
|
|
2566
|
+
// with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|
2567
|
+
// existing serialization behavior unchanged.
|
|
2568
|
+
const config = this.config;
|
|
2569
|
+
const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|
2570
|
+
const serializedConfig =
|
|
2571
|
+
utils$1.isArray(redactKeys) && redactKeys.length > 0
|
|
2572
|
+
? redactConfig(config, redactKeys)
|
|
2573
|
+
: utils$1.toJSONObject(config);
|
|
2574
|
+
|
|
2575
|
+
return {
|
|
2576
|
+
// Standard
|
|
2577
|
+
message: this.message,
|
|
2578
|
+
name: this.name,
|
|
2579
|
+
// Microsoft
|
|
2580
|
+
description: this.description,
|
|
2581
|
+
number: this.number,
|
|
2582
|
+
// Mozilla
|
|
2583
|
+
fileName: this.fileName,
|
|
2584
|
+
lineNumber: this.lineNumber,
|
|
2585
|
+
columnNumber: this.columnNumber,
|
|
2586
|
+
stack: this.stack,
|
|
2587
|
+
// Axios
|
|
2588
|
+
config: serializedConfig,
|
|
2589
|
+
code: this.code,
|
|
2590
|
+
status: this.status,
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2646
2593
|
}
|
|
2647
2594
|
|
|
2648
|
-
|
|
2595
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
2596
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
2597
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
2598
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
2599
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
2600
|
+
AxiosError.ECONNREFUSED = 'ECONNREFUSED';
|
|
2601
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
2602
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
2603
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
2604
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
2605
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
2606
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
2607
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
2608
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
2609
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
2649
2610
|
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
*
|
|
2611
|
+
var AxiosError$1 = AxiosError;
|
|
2612
|
+
|
|
2613
|
+
// eslint-disable-next-line strict
|
|
2614
|
+
var httpAdapter = null;
|
|
2615
|
+
|
|
2616
|
+
/**
|
|
2617
|
+
* Determines if the given thing is a array or js object.
|
|
2657
2618
|
*
|
|
2658
|
-
* @
|
|
2619
|
+
* @param {string} thing - The object or array to be visited.
|
|
2620
|
+
*
|
|
2621
|
+
* @returns {boolean}
|
|
2659
2622
|
*/
|
|
2660
|
-
function
|
|
2661
|
-
|
|
2662
|
-
try {
|
|
2663
|
-
(parser || JSON.parse)(rawValue);
|
|
2664
|
-
return utils$1.trim(rawValue);
|
|
2665
|
-
} catch (e) {
|
|
2666
|
-
if (e.name !== 'SyntaxError') {
|
|
2667
|
-
throw e;
|
|
2668
|
-
}
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
|
|
2672
|
-
return (encoder || JSON.stringify)(rawValue);
|
|
2623
|
+
function isVisitable(thing) {
|
|
2624
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
2673
2625
|
}
|
|
2674
2626
|
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2627
|
+
/**
|
|
2628
|
+
* It removes the brackets from the end of a string
|
|
2629
|
+
*
|
|
2630
|
+
* @param {string} key - The key of the parameter.
|
|
2631
|
+
*
|
|
2632
|
+
* @returns {string} the key without the brackets.
|
|
2633
|
+
*/
|
|
2634
|
+
function removeBrackets(key) {
|
|
2635
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
2636
|
+
}
|
|
2685
2637
|
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2638
|
+
/**
|
|
2639
|
+
* It takes a path, a key, and a boolean, and returns a string
|
|
2640
|
+
*
|
|
2641
|
+
* @param {string} path - The path to the current key.
|
|
2642
|
+
* @param {string} key - The key of the current object being iterated over.
|
|
2643
|
+
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
2644
|
+
*
|
|
2645
|
+
* @returns {string} The path to the current key.
|
|
2646
|
+
*/
|
|
2647
|
+
function renderKey(path, key, dots) {
|
|
2648
|
+
if (!path) return key;
|
|
2649
|
+
return path
|
|
2650
|
+
.concat(key)
|
|
2651
|
+
.map(function each(token, i) {
|
|
2652
|
+
// eslint-disable-next-line no-param-reassign
|
|
2653
|
+
token = removeBrackets(token);
|
|
2654
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
2655
|
+
})
|
|
2656
|
+
.join(dots ? '.' : '');
|
|
2657
|
+
}
|
|
2689
2658
|
|
|
2690
|
-
|
|
2659
|
+
/**
|
|
2660
|
+
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
2661
|
+
*
|
|
2662
|
+
* @param {Array<any>} arr - The array to check
|
|
2663
|
+
*
|
|
2664
|
+
* @returns {boolean}
|
|
2665
|
+
*/
|
|
2666
|
+
function isFlatArray(arr) {
|
|
2667
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
2668
|
+
}
|
|
2691
2669
|
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2670
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
2671
|
+
return /^is[A-Z]/.test(prop);
|
|
2672
|
+
});
|
|
2695
2673
|
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
2710
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
2711
|
-
return data.toString();
|
|
2712
|
-
}
|
|
2674
|
+
/**
|
|
2675
|
+
* Convert a data object to FormData
|
|
2676
|
+
*
|
|
2677
|
+
* @param {Object} obj
|
|
2678
|
+
* @param {?Object} [formData]
|
|
2679
|
+
* @param {?Object} [options]
|
|
2680
|
+
* @param {Function} [options.visitor]
|
|
2681
|
+
* @param {Boolean} [options.metaTokens = true]
|
|
2682
|
+
* @param {Boolean} [options.dots = false]
|
|
2683
|
+
* @param {?Boolean} [options.indexes = false]
|
|
2684
|
+
*
|
|
2685
|
+
* @returns {Object}
|
|
2686
|
+
**/
|
|
2713
2687
|
|
|
2714
|
-
|
|
2688
|
+
/**
|
|
2689
|
+
* It converts an object into a FormData object
|
|
2690
|
+
*
|
|
2691
|
+
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
2692
|
+
* @param {string} formData - The FormData object to append to.
|
|
2693
|
+
* @param {Object<string, any>} options
|
|
2694
|
+
*
|
|
2695
|
+
* @returns
|
|
2696
|
+
*/
|
|
2697
|
+
function toFormData(obj, formData, options) {
|
|
2698
|
+
if (!utils$1.isObject(obj)) {
|
|
2699
|
+
throw new TypeError('target must be an object');
|
|
2700
|
+
}
|
|
2715
2701
|
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
2719
|
-
return toURLEncodedForm(data, formSerializer).toString();
|
|
2720
|
-
}
|
|
2702
|
+
// eslint-disable-next-line no-param-reassign
|
|
2703
|
+
formData = formData || new (FormData)();
|
|
2721
2704
|
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2705
|
+
// eslint-disable-next-line no-param-reassign
|
|
2706
|
+
options = utils$1.toFlatObject(
|
|
2707
|
+
options,
|
|
2708
|
+
{
|
|
2709
|
+
metaTokens: true,
|
|
2710
|
+
dots: false,
|
|
2711
|
+
indexes: false,
|
|
2712
|
+
},
|
|
2713
|
+
false,
|
|
2714
|
+
function defined(option, source) {
|
|
2715
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
2716
|
+
return !utils$1.isUndefined(source[option]);
|
|
2717
|
+
}
|
|
2718
|
+
);
|
|
2728
2719
|
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2720
|
+
const metaTokens = options.metaTokens;
|
|
2721
|
+
// eslint-disable-next-line no-use-before-define
|
|
2722
|
+
const visitor = options.visitor || defaultVisitor;
|
|
2723
|
+
const dots = options.dots;
|
|
2724
|
+
const indexes = options.indexes;
|
|
2725
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
2726
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
2727
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
2736
2728
|
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
}
|
|
2729
|
+
if (!utils$1.isFunction(visitor)) {
|
|
2730
|
+
throw new TypeError('visitor must be a function');
|
|
2731
|
+
}
|
|
2741
2732
|
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
],
|
|
2733
|
+
function convertValue(value) {
|
|
2734
|
+
if (value === null) return '';
|
|
2745
2735
|
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
2750
|
-
const responseType = own(this, 'responseType');
|
|
2751
|
-
const JSONRequested = responseType === 'json';
|
|
2736
|
+
if (utils$1.isDate(value)) {
|
|
2737
|
+
return value.toISOString();
|
|
2738
|
+
}
|
|
2752
2739
|
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2740
|
+
if (utils$1.isBoolean(value)) {
|
|
2741
|
+
return value.toString();
|
|
2742
|
+
}
|
|
2756
2743
|
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
2761
|
-
) {
|
|
2762
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2763
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
2744
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
2745
|
+
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
2746
|
+
}
|
|
2764
2747
|
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
if (strictJSONParsing) {
|
|
2769
|
-
if (e.name === 'SyntaxError') {
|
|
2770
|
-
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
2771
|
-
}
|
|
2772
|
-
throw e;
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
}
|
|
2748
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
2749
|
+
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
2750
|
+
}
|
|
2776
2751
|
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
],
|
|
2752
|
+
return value;
|
|
2753
|
+
}
|
|
2780
2754
|
|
|
2781
2755
|
/**
|
|
2782
|
-
*
|
|
2783
|
-
*
|
|
2756
|
+
* Default visitor.
|
|
2757
|
+
*
|
|
2758
|
+
* @param {*} value
|
|
2759
|
+
* @param {String|Number} key
|
|
2760
|
+
* @param {Array<String|Number>} path
|
|
2761
|
+
* @this {FormData}
|
|
2762
|
+
*
|
|
2763
|
+
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
2784
2764
|
*/
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
xsrfCookieName: 'XSRF-TOKEN',
|
|
2788
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
2789
|
-
|
|
2790
|
-
maxContentLength: -1,
|
|
2791
|
-
maxBodyLength: -1,
|
|
2792
|
-
|
|
2793
|
-
env: {
|
|
2794
|
-
FormData: platform.classes.FormData,
|
|
2795
|
-
Blob: platform.classes.Blob,
|
|
2796
|
-
},
|
|
2797
|
-
|
|
2798
|
-
validateStatus: function validateStatus(status) {
|
|
2799
|
-
return status >= 200 && status < 300;
|
|
2800
|
-
},
|
|
2765
|
+
function defaultVisitor(value, key, path) {
|
|
2766
|
+
let arr = value;
|
|
2801
2767
|
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
},
|
|
2807
|
-
},
|
|
2808
|
-
};
|
|
2768
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
2769
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
2770
|
+
return false;
|
|
2771
|
+
}
|
|
2809
2772
|
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2773
|
+
if (value && !path && typeof value === 'object') {
|
|
2774
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
2775
|
+
// eslint-disable-next-line no-param-reassign
|
|
2776
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
2777
|
+
// eslint-disable-next-line no-param-reassign
|
|
2778
|
+
value = JSON.stringify(value);
|
|
2779
|
+
} else if (
|
|
2780
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
2781
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
2782
|
+
) {
|
|
2783
|
+
// eslint-disable-next-line no-param-reassign
|
|
2784
|
+
key = removeBrackets(key);
|
|
2813
2785
|
|
|
2814
|
-
|
|
2786
|
+
arr.forEach(function each(el, index) {
|
|
2787
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
2788
|
+
formData.append(
|
|
2789
|
+
// eslint-disable-next-line no-nested-ternary
|
|
2790
|
+
indexes === true
|
|
2791
|
+
? renderKey([key], index, dots)
|
|
2792
|
+
: indexes === null
|
|
2793
|
+
? key
|
|
2794
|
+
: key + '[]',
|
|
2795
|
+
convertValue(el)
|
|
2796
|
+
);
|
|
2797
|
+
});
|
|
2798
|
+
return false;
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2815
2801
|
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
'age',
|
|
2820
|
-
'authorization',
|
|
2821
|
-
'content-length',
|
|
2822
|
-
'content-type',
|
|
2823
|
-
'etag',
|
|
2824
|
-
'expires',
|
|
2825
|
-
'from',
|
|
2826
|
-
'host',
|
|
2827
|
-
'if-modified-since',
|
|
2828
|
-
'if-unmodified-since',
|
|
2829
|
-
'last-modified',
|
|
2830
|
-
'location',
|
|
2831
|
-
'max-forwards',
|
|
2832
|
-
'proxy-authorization',
|
|
2833
|
-
'referer',
|
|
2834
|
-
'retry-after',
|
|
2835
|
-
'user-agent',
|
|
2836
|
-
]);
|
|
2802
|
+
if (isVisitable(value)) {
|
|
2803
|
+
return true;
|
|
2804
|
+
}
|
|
2837
2805
|
|
|
2838
|
-
|
|
2839
|
-
* Parse headers into an object
|
|
2840
|
-
*
|
|
2841
|
-
* ```
|
|
2842
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
2843
|
-
* Content-Type: application/json
|
|
2844
|
-
* Connection: keep-alive
|
|
2845
|
-
* Transfer-Encoding: chunked
|
|
2846
|
-
* ```
|
|
2847
|
-
*
|
|
2848
|
-
* @param {String} rawHeaders Headers needing to be parsed
|
|
2849
|
-
*
|
|
2850
|
-
* @returns {Object} Headers parsed into an object
|
|
2851
|
-
*/
|
|
2852
|
-
var parseHeaders = (rawHeaders) => {
|
|
2853
|
-
const parsed = {};
|
|
2854
|
-
let key;
|
|
2855
|
-
let val;
|
|
2856
|
-
let i;
|
|
2806
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
2857
2807
|
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
i = line.indexOf(':');
|
|
2861
|
-
key = line.substring(0, i).trim().toLowerCase();
|
|
2862
|
-
val = line.substring(i + 1).trim();
|
|
2808
|
+
return false;
|
|
2809
|
+
}
|
|
2863
2810
|
|
|
2864
|
-
|
|
2865
|
-
return;
|
|
2866
|
-
}
|
|
2811
|
+
const stack = [];
|
|
2867
2812
|
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
}
|
|
2874
|
-
} else {
|
|
2875
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
2876
|
-
}
|
|
2877
|
-
});
|
|
2813
|
+
const exposedHelpers = Object.assign(predicates, {
|
|
2814
|
+
defaultVisitor,
|
|
2815
|
+
convertValue,
|
|
2816
|
+
isVisitable,
|
|
2817
|
+
});
|
|
2878
2818
|
|
|
2879
|
-
|
|
2880
|
-
|
|
2819
|
+
function build(value, path, depth = 0) {
|
|
2820
|
+
if (utils$1.isUndefined(value)) return;
|
|
2881
2821
|
|
|
2882
|
-
|
|
2822
|
+
if (depth > maxDepth) {
|
|
2823
|
+
throw new AxiosError$1(
|
|
2824
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
2825
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2826
|
+
);
|
|
2827
|
+
}
|
|
2883
2828
|
|
|
2884
|
-
|
|
2829
|
+
if (stack.indexOf(value) !== -1) {
|
|
2830
|
+
throw new Error('Circular reference detected in ' + path.join('.'));
|
|
2831
|
+
}
|
|
2885
2832
|
|
|
2886
|
-
|
|
2887
|
-
let start = 0;
|
|
2888
|
-
let end = str.length;
|
|
2833
|
+
stack.push(value);
|
|
2889
2834
|
|
|
2890
|
-
|
|
2891
|
-
|
|
2835
|
+
utils$1.forEach(value, function each(el, key) {
|
|
2836
|
+
const result =
|
|
2837
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
2838
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
2892
2839
|
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2840
|
+
if (result === true) {
|
|
2841
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
2842
|
+
}
|
|
2843
|
+
});
|
|
2896
2844
|
|
|
2897
|
-
|
|
2845
|
+
stack.pop();
|
|
2898
2846
|
}
|
|
2899
2847
|
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
if (code !== 0x09 && code !== 0x20) {
|
|
2904
|
-
break;
|
|
2905
|
-
}
|
|
2906
|
-
|
|
2907
|
-
end -= 1;
|
|
2848
|
+
if (!utils$1.isObject(obj)) {
|
|
2849
|
+
throw new TypeError('data must be an object');
|
|
2908
2850
|
}
|
|
2909
2851
|
|
|
2910
|
-
|
|
2911
|
-
}
|
|
2852
|
+
build(obj);
|
|
2912
2853
|
|
|
2913
|
-
|
|
2914
|
-
return header && String(header).trim().toLowerCase();
|
|
2854
|
+
return formData;
|
|
2915
2855
|
}
|
|
2916
2856
|
|
|
2917
|
-
|
|
2918
|
-
|
|
2857
|
+
/**
|
|
2858
|
+
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
2859
|
+
* their percent-encoded equivalents
|
|
2860
|
+
*
|
|
2861
|
+
* @param {string} str - The string to encode.
|
|
2862
|
+
*
|
|
2863
|
+
* @returns {string} The encoded string.
|
|
2864
|
+
*/
|
|
2865
|
+
function encode$1(str) {
|
|
2866
|
+
const charMap = {
|
|
2867
|
+
'!': '%21',
|
|
2868
|
+
"'": '%27',
|
|
2869
|
+
'(': '%28',
|
|
2870
|
+
')': '%29',
|
|
2871
|
+
'~': '%7E',
|
|
2872
|
+
'%20': '+',
|
|
2873
|
+
};
|
|
2874
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
2875
|
+
return charMap[match];
|
|
2876
|
+
});
|
|
2919
2877
|
}
|
|
2920
2878
|
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2879
|
+
/**
|
|
2880
|
+
* It takes a params object and converts it to a FormData object
|
|
2881
|
+
*
|
|
2882
|
+
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
2883
|
+
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
2884
|
+
*
|
|
2885
|
+
* @returns {void}
|
|
2886
|
+
*/
|
|
2887
|
+
function AxiosURLSearchParams(params, options) {
|
|
2888
|
+
this._pairs = [];
|
|
2925
2889
|
|
|
2926
|
-
|
|
2890
|
+
params && toFormData(params, this, options);
|
|
2927
2891
|
}
|
|
2928
2892
|
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2893
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
2894
|
+
|
|
2895
|
+
prototype.append = function append(name, value) {
|
|
2896
|
+
this._pairs.push([name, value]);
|
|
2897
|
+
};
|
|
2898
|
+
|
|
2899
|
+
prototype.toString = function toString(encoder) {
|
|
2900
|
+
const _encode = encoder
|
|
2901
|
+
? function (value) {
|
|
2902
|
+
return encoder.call(this, value, encode$1);
|
|
2903
|
+
}
|
|
2904
|
+
: encode$1;
|
|
2905
|
+
|
|
2906
|
+
return this._pairs
|
|
2907
|
+
.map(function each(pair) {
|
|
2908
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
2909
|
+
}, '')
|
|
2910
|
+
.join('&');
|
|
2911
|
+
};
|
|
2912
|
+
|
|
2913
|
+
/**
|
|
2914
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
2915
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
2916
|
+
*
|
|
2917
|
+
* @param {string} val The value to be encoded.
|
|
2918
|
+
*
|
|
2919
|
+
* @returns {string} The encoded value.
|
|
2920
|
+
*/
|
|
2921
|
+
function encode(val) {
|
|
2922
|
+
return encodeURIComponent(val)
|
|
2923
|
+
.replace(/%3A/gi, ':')
|
|
2924
|
+
.replace(/%24/g, '$')
|
|
2925
|
+
.replace(/%2C/gi, ',')
|
|
2926
|
+
.replace(/%20/g, '+');
|
|
2927
|
+
}
|
|
2933
2928
|
|
|
2934
|
-
|
|
2935
|
-
|
|
2929
|
+
/**
|
|
2930
|
+
* Build a URL by appending params to the end
|
|
2931
|
+
*
|
|
2932
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
2933
|
+
* @param {object} [params] The params to be appended
|
|
2934
|
+
* @param {?(object|Function)} options
|
|
2935
|
+
*
|
|
2936
|
+
* @returns {string} The formatted url
|
|
2937
|
+
*/
|
|
2938
|
+
function buildURL(url, params, options) {
|
|
2939
|
+
if (!params) {
|
|
2940
|
+
return url;
|
|
2936
2941
|
}
|
|
2937
2942
|
|
|
2938
|
-
|
|
2939
|
-
}
|
|
2940
|
-
|
|
2941
|
-
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
2943
|
+
const _encode = (options && options.encode) || encode;
|
|
2942
2944
|
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2945
|
+
const _options = utils$1.isFunction(options)
|
|
2946
|
+
? {
|
|
2947
|
+
serialize: options,
|
|
2948
|
+
}
|
|
2949
|
+
: options;
|
|
2947
2950
|
|
|
2948
|
-
|
|
2949
|
-
value = header;
|
|
2950
|
-
}
|
|
2951
|
+
const serializeFn = _options && _options.serialize;
|
|
2951
2952
|
|
|
2952
|
-
|
|
2953
|
+
let serializedParams;
|
|
2953
2954
|
|
|
2954
|
-
if (
|
|
2955
|
-
|
|
2955
|
+
if (serializeFn) {
|
|
2956
|
+
serializedParams = serializeFn(params, _options);
|
|
2957
|
+
} else {
|
|
2958
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
2959
|
+
? params.toString()
|
|
2960
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
2956
2961
|
}
|
|
2957
2962
|
|
|
2958
|
-
if (
|
|
2959
|
-
|
|
2963
|
+
if (serializedParams) {
|
|
2964
|
+
const hashmarkIndex = url.indexOf('#');
|
|
2965
|
+
|
|
2966
|
+
if (hashmarkIndex !== -1) {
|
|
2967
|
+
url = url.slice(0, hashmarkIndex);
|
|
2968
|
+
}
|
|
2969
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
2960
2970
|
}
|
|
2961
|
-
}
|
|
2962
2971
|
|
|
2963
|
-
|
|
2964
|
-
return header
|
|
2965
|
-
.trim()
|
|
2966
|
-
.toLowerCase()
|
|
2967
|
-
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
2968
|
-
return char.toUpperCase() + str;
|
|
2969
|
-
});
|
|
2972
|
+
return url;
|
|
2970
2973
|
}
|
|
2971
2974
|
|
|
2972
|
-
|
|
2973
|
-
|
|
2975
|
+
class InterceptorManager {
|
|
2976
|
+
constructor() {
|
|
2977
|
+
this.handlers = [];
|
|
2978
|
+
}
|
|
2974
2979
|
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2980
|
+
/**
|
|
2981
|
+
* Add a new interceptor to the stack
|
|
2982
|
+
*
|
|
2983
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
2984
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
2985
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
2986
|
+
*
|
|
2987
|
+
* @return {Number} An ID used to remove interceptor later
|
|
2988
|
+
*/
|
|
2989
|
+
use(fulfilled, rejected, options) {
|
|
2990
|
+
this.handlers.push({
|
|
2991
|
+
fulfilled,
|
|
2992
|
+
rejected,
|
|
2993
|
+
synchronous: options ? options.synchronous : false,
|
|
2994
|
+
runWhen: options ? options.runWhen : null,
|
|
2981
2995
|
});
|
|
2982
|
-
|
|
2983
|
-
}
|
|
2984
|
-
|
|
2985
|
-
class AxiosHeaders {
|
|
2986
|
-
constructor(headers) {
|
|
2987
|
-
headers && this.set(headers);
|
|
2996
|
+
return this.handlers.length - 1;
|
|
2988
2997
|
}
|
|
2989
2998
|
|
|
2990
|
-
|
|
2991
|
-
|
|
2999
|
+
/**
|
|
3000
|
+
* Remove an interceptor from the stack
|
|
3001
|
+
*
|
|
3002
|
+
* @param {Number} id The ID that was returned by `use`
|
|
3003
|
+
*
|
|
3004
|
+
* @returns {void}
|
|
3005
|
+
*/
|
|
3006
|
+
eject(id) {
|
|
3007
|
+
if (this.handlers[id]) {
|
|
3008
|
+
this.handlers[id] = null;
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
2992
3011
|
|
|
2993
|
-
|
|
2994
|
-
|
|
3012
|
+
/**
|
|
3013
|
+
* Clear all interceptors from the stack
|
|
3014
|
+
*
|
|
3015
|
+
* @returns {void}
|
|
3016
|
+
*/
|
|
3017
|
+
clear() {
|
|
3018
|
+
if (this.handlers) {
|
|
3019
|
+
this.handlers = [];
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
2995
3022
|
|
|
2996
|
-
|
|
2997
|
-
|
|
3023
|
+
/**
|
|
3024
|
+
* Iterate over all the registered interceptors
|
|
3025
|
+
*
|
|
3026
|
+
* This method is particularly useful for skipping over any
|
|
3027
|
+
* interceptors that may have become `null` calling `eject`.
|
|
3028
|
+
*
|
|
3029
|
+
* @param {Function} fn The function to call for each interceptor
|
|
3030
|
+
*
|
|
3031
|
+
* @returns {void}
|
|
3032
|
+
*/
|
|
3033
|
+
forEach(fn) {
|
|
3034
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
3035
|
+
if (h !== null) {
|
|
3036
|
+
fn(h);
|
|
2998
3037
|
}
|
|
3038
|
+
});
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
2999
3041
|
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
if (
|
|
3003
|
-
!key ||
|
|
3004
|
-
self[key] === undefined ||
|
|
3005
|
-
_rewrite === true ||
|
|
3006
|
-
(_rewrite === undefined && self[key] !== false)
|
|
3007
|
-
) {
|
|
3008
|
-
self[key || _header] = normalizeValue(_value);
|
|
3009
|
-
}
|
|
3010
|
-
}
|
|
3042
|
+
var InterceptorManager$1 = InterceptorManager;
|
|
3011
3043
|
|
|
3012
|
-
|
|
3013
|
-
|
|
3044
|
+
var transitionalDefaults = {
|
|
3045
|
+
silentJSONParsing: true,
|
|
3046
|
+
forcedJSONParsing: true,
|
|
3047
|
+
clarifyTimeoutError: false,
|
|
3048
|
+
legacyInterceptorReqResOrdering: true,
|
|
3049
|
+
advertiseZstdAcceptEncoding: false,
|
|
3050
|
+
};
|
|
3014
3051
|
|
|
3015
|
-
|
|
3016
|
-
setHeaders(header, valueOrRewrite);
|
|
3017
|
-
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
3018
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
3019
|
-
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
3020
|
-
let obj = {},
|
|
3021
|
-
dest,
|
|
3022
|
-
key;
|
|
3023
|
-
for (const entry of header) {
|
|
3024
|
-
if (!utils$1.isArray(entry)) {
|
|
3025
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
3026
|
-
}
|
|
3052
|
+
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
3027
3053
|
|
|
3028
|
-
|
|
3029
|
-
? utils$1.isArray(dest)
|
|
3030
|
-
? [...dest, entry[1]]
|
|
3031
|
-
: [dest, entry[1]]
|
|
3032
|
-
: entry[1];
|
|
3033
|
-
}
|
|
3054
|
+
var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
3034
3055
|
|
|
3035
|
-
|
|
3036
|
-
} else {
|
|
3037
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
3038
|
-
}
|
|
3056
|
+
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
3039
3057
|
|
|
3040
|
-
|
|
3041
|
-
|
|
3058
|
+
var platform$1 = {
|
|
3059
|
+
isBrowser: true,
|
|
3060
|
+
classes: {
|
|
3061
|
+
URLSearchParams: URLSearchParams$1,
|
|
3062
|
+
FormData: FormData$1,
|
|
3063
|
+
Blob: Blob$1,
|
|
3064
|
+
},
|
|
3065
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
3066
|
+
};
|
|
3042
3067
|
|
|
3043
|
-
|
|
3044
|
-
header = normalizeHeader(header);
|
|
3068
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
3045
3069
|
|
|
3046
|
-
|
|
3047
|
-
const key = utils$1.findKey(this, header);
|
|
3070
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
3048
3071
|
|
|
3049
|
-
|
|
3050
|
-
|
|
3072
|
+
/**
|
|
3073
|
+
* Determine if we're running in a standard browser environment
|
|
3074
|
+
*
|
|
3075
|
+
* This allows axios to run in a web worker, and react-native.
|
|
3076
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
3077
|
+
*
|
|
3078
|
+
* web workers:
|
|
3079
|
+
* typeof window -> undefined
|
|
3080
|
+
* typeof document -> undefined
|
|
3081
|
+
*
|
|
3082
|
+
* react-native:
|
|
3083
|
+
* navigator.product -> 'ReactNative'
|
|
3084
|
+
* nativescript
|
|
3085
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
|
3086
|
+
*
|
|
3087
|
+
* @returns {boolean}
|
|
3088
|
+
*/
|
|
3089
|
+
const hasStandardBrowserEnv =
|
|
3090
|
+
hasBrowserEnv &&
|
|
3091
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
3051
3092
|
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3093
|
+
/**
|
|
3094
|
+
* Determine if we're running in a standard browser webWorker environment
|
|
3095
|
+
*
|
|
3096
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
|
3097
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
3098
|
+
* filtered out due to its judgment standard
|
|
3099
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
3100
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
|
3101
|
+
*/
|
|
3102
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
3103
|
+
return (
|
|
3104
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
|
3105
|
+
// eslint-disable-next-line no-undef
|
|
3106
|
+
self instanceof WorkerGlobalScope &&
|
|
3107
|
+
typeof self.importScripts === 'function'
|
|
3108
|
+
);
|
|
3109
|
+
})();
|
|
3055
3110
|
|
|
3056
|
-
|
|
3057
|
-
return parseTokens(value);
|
|
3058
|
-
}
|
|
3111
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
3059
3112
|
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3113
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
3114
|
+
__proto__: null,
|
|
3115
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
3116
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
3117
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
3118
|
+
navigator: _navigator,
|
|
3119
|
+
origin: origin
|
|
3120
|
+
});
|
|
3063
3121
|
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3122
|
+
var platform = {
|
|
3123
|
+
...utils,
|
|
3124
|
+
...platform$1,
|
|
3125
|
+
};
|
|
3067
3126
|
|
|
3068
|
-
|
|
3127
|
+
function toURLEncodedForm(data, options) {
|
|
3128
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
3129
|
+
visitor: function (value, key, path, helpers) {
|
|
3130
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
3131
|
+
this.append(key, value.toString('base64'));
|
|
3132
|
+
return false;
|
|
3069
3133
|
}
|
|
3070
|
-
}
|
|
3071
|
-
}
|
|
3072
|
-
|
|
3073
|
-
has(header, matcher) {
|
|
3074
|
-
header = normalizeHeader(header);
|
|
3075
3134
|
|
|
3076
|
-
|
|
3077
|
-
|
|
3135
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
3136
|
+
},
|
|
3137
|
+
...options,
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3078
3140
|
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3141
|
+
/**
|
|
3142
|
+
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
3143
|
+
*
|
|
3144
|
+
* @param {string} name - The name of the property to get.
|
|
3145
|
+
*
|
|
3146
|
+
* @returns An array of strings.
|
|
3147
|
+
*/
|
|
3148
|
+
function parsePropPath(name) {
|
|
3149
|
+
// foo[x][y][z]
|
|
3150
|
+
// foo.x.y.z
|
|
3151
|
+
// foo-x-y-z
|
|
3152
|
+
// foo x y z
|
|
3153
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
3154
|
+
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3085
3157
|
|
|
3086
|
-
|
|
3158
|
+
/**
|
|
3159
|
+
* Convert an array to an object.
|
|
3160
|
+
*
|
|
3161
|
+
* @param {Array<any>} arr - The array to convert to an object.
|
|
3162
|
+
*
|
|
3163
|
+
* @returns An object with the same keys and values as the array.
|
|
3164
|
+
*/
|
|
3165
|
+
function arrayToObject(arr) {
|
|
3166
|
+
const obj = {};
|
|
3167
|
+
const keys = Object.keys(arr);
|
|
3168
|
+
let i;
|
|
3169
|
+
const len = keys.length;
|
|
3170
|
+
let key;
|
|
3171
|
+
for (i = 0; i < len; i++) {
|
|
3172
|
+
key = keys[i];
|
|
3173
|
+
obj[key] = arr[key];
|
|
3087
3174
|
}
|
|
3175
|
+
return obj;
|
|
3176
|
+
}
|
|
3088
3177
|
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3178
|
+
/**
|
|
3179
|
+
* It takes a FormData object and returns a JavaScript object
|
|
3180
|
+
*
|
|
3181
|
+
* @param {string} formData The FormData object to convert to JSON.
|
|
3182
|
+
*
|
|
3183
|
+
* @returns {Object<string, any> | null} The converted object.
|
|
3184
|
+
*/
|
|
3185
|
+
function formDataToJSON(formData) {
|
|
3186
|
+
function buildPath(path, value, target, index) {
|
|
3187
|
+
let name = path[index++];
|
|
3095
3188
|
|
|
3096
|
-
|
|
3097
|
-
const key = utils$1.findKey(self, _header);
|
|
3189
|
+
if (name === '__proto__') return true;
|
|
3098
3190
|
|
|
3099
|
-
|
|
3100
|
-
|
|
3191
|
+
const isNumericKey = Number.isFinite(+name);
|
|
3192
|
+
const isLast = index >= path.length;
|
|
3193
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
3101
3194
|
|
|
3102
|
-
|
|
3103
|
-
|
|
3195
|
+
if (isLast) {
|
|
3196
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
3197
|
+
target[name] = utils$1.isArray(target[name])
|
|
3198
|
+
? target[name].concat(value)
|
|
3199
|
+
: [target[name], value];
|
|
3200
|
+
} else {
|
|
3201
|
+
target[name] = value;
|
|
3104
3202
|
}
|
|
3203
|
+
|
|
3204
|
+
return !isNumericKey;
|
|
3105
3205
|
}
|
|
3106
3206
|
|
|
3107
|
-
if (utils$1.
|
|
3108
|
-
|
|
3109
|
-
} else {
|
|
3110
|
-
deleteHeader(header);
|
|
3207
|
+
if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
|
|
3208
|
+
target[name] = [];
|
|
3111
3209
|
}
|
|
3112
3210
|
|
|
3113
|
-
|
|
3211
|
+
const result = buildPath(path, value, target[name], index);
|
|
3212
|
+
|
|
3213
|
+
if (result && utils$1.isArray(target[name])) {
|
|
3214
|
+
target[name] = arrayToObject(target[name]);
|
|
3215
|
+
}
|
|
3216
|
+
|
|
3217
|
+
return !isNumericKey;
|
|
3114
3218
|
}
|
|
3115
3219
|
|
|
3116
|
-
|
|
3117
|
-
const
|
|
3118
|
-
let i = keys.length;
|
|
3119
|
-
let deleted = false;
|
|
3220
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
3221
|
+
const obj = {};
|
|
3120
3222
|
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
delete this[key];
|
|
3125
|
-
deleted = true;
|
|
3126
|
-
}
|
|
3127
|
-
}
|
|
3223
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
3224
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
3225
|
+
});
|
|
3128
3226
|
|
|
3129
|
-
return
|
|
3227
|
+
return obj;
|
|
3130
3228
|
}
|
|
3131
3229
|
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
const headers = {};
|
|
3230
|
+
return null;
|
|
3231
|
+
}
|
|
3135
3232
|
|
|
3136
|
-
|
|
3137
|
-
const key = utils$1.findKey(headers, header);
|
|
3233
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
3138
3234
|
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3235
|
+
/**
|
|
3236
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
3237
|
+
* of the input
|
|
3238
|
+
*
|
|
3239
|
+
* @param {any} rawValue - The value to be stringified.
|
|
3240
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
3241
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
3242
|
+
*
|
|
3243
|
+
* @returns {string} A stringified version of the rawValue.
|
|
3244
|
+
*/
|
|
3245
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
3246
|
+
if (utils$1.isString(rawValue)) {
|
|
3247
|
+
try {
|
|
3248
|
+
(parser || JSON.parse)(rawValue);
|
|
3249
|
+
return utils$1.trim(rawValue);
|
|
3250
|
+
} catch (e) {
|
|
3251
|
+
if (e.name !== 'SyntaxError') {
|
|
3252
|
+
throw e;
|
|
3143
3253
|
}
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3144
3256
|
|
|
3145
|
-
|
|
3257
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
3258
|
+
}
|
|
3146
3259
|
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
}
|
|
3260
|
+
const defaults = {
|
|
3261
|
+
transitional: transitionalDefaults,
|
|
3150
3262
|
|
|
3151
|
-
|
|
3263
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
3152
3264
|
|
|
3153
|
-
|
|
3154
|
-
|
|
3265
|
+
transformRequest: [
|
|
3266
|
+
function transformRequest(data, headers) {
|
|
3267
|
+
const contentType = headers.getContentType() || '';
|
|
3268
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
3269
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
3155
3270
|
|
|
3156
|
-
|
|
3157
|
-
|
|
3271
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
3272
|
+
data = new FormData(data);
|
|
3273
|
+
}
|
|
3158
3274
|
|
|
3159
|
-
|
|
3160
|
-
return this.constructor.concat(this, ...targets);
|
|
3161
|
-
}
|
|
3275
|
+
const isFormData = utils$1.isFormData(data);
|
|
3162
3276
|
|
|
3163
|
-
|
|
3164
|
-
|
|
3277
|
+
if (isFormData) {
|
|
3278
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
3279
|
+
}
|
|
3165
3280
|
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3281
|
+
if (
|
|
3282
|
+
utils$1.isArrayBuffer(data) ||
|
|
3283
|
+
utils$1.isBuffer(data) ||
|
|
3284
|
+
utils$1.isStream(data) ||
|
|
3285
|
+
utils$1.isFile(data) ||
|
|
3286
|
+
utils$1.isBlob(data) ||
|
|
3287
|
+
utils$1.isReadableStream(data)
|
|
3288
|
+
) {
|
|
3289
|
+
return data;
|
|
3290
|
+
}
|
|
3291
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
3292
|
+
return data.buffer;
|
|
3293
|
+
}
|
|
3294
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
3295
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
3296
|
+
return data.toString();
|
|
3297
|
+
}
|
|
3171
3298
|
|
|
3172
|
-
|
|
3173
|
-
}
|
|
3299
|
+
let isFileList;
|
|
3174
3300
|
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3301
|
+
if (isObjectPayload) {
|
|
3302
|
+
const formSerializer = own(this, 'formSerializer');
|
|
3303
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
3304
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
3305
|
+
}
|
|
3178
3306
|
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3307
|
+
if (
|
|
3308
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
3309
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
3310
|
+
) {
|
|
3311
|
+
const env = own(this, 'env');
|
|
3312
|
+
const _FormData = env && env.FormData;
|
|
3184
3313
|
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3314
|
+
return toFormData(
|
|
3315
|
+
isFileList ? { 'files[]': data } : data,
|
|
3316
|
+
_FormData && new _FormData(),
|
|
3317
|
+
formSerializer
|
|
3318
|
+
);
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3188
3321
|
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3322
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
3323
|
+
headers.setContentType('application/json', false);
|
|
3324
|
+
return stringifySafely(data);
|
|
3325
|
+
}
|
|
3192
3326
|
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3327
|
+
return data;
|
|
3328
|
+
},
|
|
3329
|
+
],
|
|
3196
3330
|
|
|
3197
|
-
|
|
3198
|
-
|
|
3331
|
+
transformResponse: [
|
|
3332
|
+
function transformResponse(data) {
|
|
3333
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
3334
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
3335
|
+
const responseType = own(this, 'responseType');
|
|
3336
|
+
const JSONRequested = responseType === 'json';
|
|
3199
3337
|
|
|
3200
|
-
|
|
3338
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
3339
|
+
return data;
|
|
3340
|
+
}
|
|
3201
3341
|
|
|
3202
|
-
|
|
3203
|
-
|
|
3342
|
+
if (
|
|
3343
|
+
data &&
|
|
3344
|
+
utils$1.isString(data) &&
|
|
3345
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
3346
|
+
) {
|
|
3347
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
3348
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
3204
3349
|
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3350
|
+
try {
|
|
3351
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
3352
|
+
} catch (e) {
|
|
3353
|
+
if (strictJSONParsing) {
|
|
3354
|
+
if (e.name === 'SyntaxError') {
|
|
3355
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
3356
|
+
}
|
|
3357
|
+
throw e;
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3212
3361
|
|
|
3213
|
-
|
|
3214
|
-
|
|
3362
|
+
return data;
|
|
3363
|
+
},
|
|
3364
|
+
],
|
|
3215
3365
|
|
|
3216
|
-
|
|
3217
|
-
|
|
3366
|
+
/**
|
|
3367
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
3368
|
+
* timeout is not created.
|
|
3369
|
+
*/
|
|
3370
|
+
timeout: 0,
|
|
3218
3371
|
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
accessors[lHeader] = true;
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3372
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
3373
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
3224
3374
|
|
|
3225
|
-
|
|
3375
|
+
maxContentLength: -1,
|
|
3376
|
+
maxBodyLength: -1,
|
|
3226
3377
|
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3378
|
+
env: {
|
|
3379
|
+
FormData: platform.classes.FormData,
|
|
3380
|
+
Blob: platform.classes.Blob,
|
|
3381
|
+
},
|
|
3230
3382
|
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
'Accept',
|
|
3235
|
-
'Accept-Encoding',
|
|
3236
|
-
'User-Agent',
|
|
3237
|
-
'Authorization',
|
|
3238
|
-
]);
|
|
3383
|
+
validateStatus: function validateStatus(status) {
|
|
3384
|
+
return status >= 200 && status < 300;
|
|
3385
|
+
},
|
|
3239
3386
|
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
get: () => value,
|
|
3245
|
-
set(headerValue) {
|
|
3246
|
-
this[mapped] = headerValue;
|
|
3387
|
+
headers: {
|
|
3388
|
+
common: {
|
|
3389
|
+
Accept: 'application/json, text/plain, */*',
|
|
3390
|
+
'Content-Type': undefined,
|
|
3247
3391
|
},
|
|
3248
|
-
}
|
|
3249
|
-
}
|
|
3392
|
+
},
|
|
3393
|
+
};
|
|
3250
3394
|
|
|
3251
|
-
utils$1.
|
|
3395
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
|
|
3396
|
+
defaults.headers[method] = {};
|
|
3397
|
+
});
|
|
3252
3398
|
|
|
3253
|
-
var
|
|
3399
|
+
var defaults$1 = defaults;
|
|
3254
3400
|
|
|
3255
3401
|
/**
|
|
3256
3402
|
* Transform the data for a request or a response
|
|
@@ -3312,22 +3458,18 @@ function settle(resolve, reject, response) {
|
|
|
3312
3458
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
3313
3459
|
resolve(response);
|
|
3314
3460
|
} else {
|
|
3315
|
-
reject(
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
response.request,
|
|
3323
|
-
response
|
|
3324
|
-
)
|
|
3325
|
-
);
|
|
3461
|
+
reject(new AxiosError$1(
|
|
3462
|
+
'Request failed with status code ' + response.status,
|
|
3463
|
+
response.status >= 400 && response.status < 500 ? AxiosError$1.ERR_BAD_REQUEST : AxiosError$1.ERR_BAD_RESPONSE,
|
|
3464
|
+
response.config,
|
|
3465
|
+
response.request,
|
|
3466
|
+
response
|
|
3467
|
+
));
|
|
3326
3468
|
}
|
|
3327
3469
|
}
|
|
3328
3470
|
|
|
3329
3471
|
function parseProtocol(url) {
|
|
3330
|
-
const match = /^([-+\w]{1,25})(
|
|
3472
|
+
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
3331
3473
|
return (match && match[1]) || '';
|
|
3332
3474
|
}
|
|
3333
3475
|
|
|
@@ -3431,6 +3573,9 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
3431
3573
|
const _speedometer = speedometer(50, 250);
|
|
3432
3574
|
|
|
3433
3575
|
return throttle((e) => {
|
|
3576
|
+
if (!e || typeof e.loaded !== 'number') {
|
|
3577
|
+
return;
|
|
3578
|
+
}
|
|
3434
3579
|
const rawLoaded = e.loaded;
|
|
3435
3580
|
const total = e.lengthComputable ? e.total : undefined;
|
|
3436
3581
|
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
@@ -3518,8 +3663,20 @@ var cookies = platform.hasStandardBrowserEnv
|
|
|
3518
3663
|
|
|
3519
3664
|
read(name) {
|
|
3520
3665
|
if (typeof document === 'undefined') return null;
|
|
3521
|
-
|
|
3522
|
-
|
|
3666
|
+
// Match name=value by splitting on the semicolon separator instead of building a
|
|
3667
|
+
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
3668
|
+
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
3669
|
+
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
3670
|
+
// "; ", so ignore optional whitespace before each cookie name.
|
|
3671
|
+
const cookies = document.cookie.split(';');
|
|
3672
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
3673
|
+
const cookie = cookies[i].replace(/^\s+/, '');
|
|
3674
|
+
const eq = cookie.indexOf('=');
|
|
3675
|
+
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
3676
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
return null;
|
|
3523
3680
|
},
|
|
3524
3681
|
|
|
3525
3682
|
remove(name) {
|
|
@@ -3601,11 +3758,14 @@ function mergeConfig(config1, config2) {
|
|
|
3601
3758
|
config2 = config2 || {};
|
|
3602
3759
|
|
|
3603
3760
|
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
3604
|
-
// or `config.baseURL` cannot inherit polluted values from Object.prototype
|
|
3605
|
-
//
|
|
3606
|
-
//
|
|
3761
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype.
|
|
3762
|
+
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
3763
|
+
// ergonomics for user code that relies on it.
|
|
3607
3764
|
const config = Object.create(null);
|
|
3608
3765
|
Object.defineProperty(config, 'hasOwnProperty', {
|
|
3766
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
3767
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
3768
|
+
__proto__: null,
|
|
3609
3769
|
value: Object.prototype.hasOwnProperty,
|
|
3610
3770
|
enumerable: false,
|
|
3611
3771
|
writable: true,
|
|
@@ -3702,11 +3862,39 @@ function mergeConfig(config1, config2) {
|
|
|
3702
3862
|
return config;
|
|
3703
3863
|
}
|
|
3704
3864
|
|
|
3705
|
-
|
|
3865
|
+
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
3866
|
+
|
|
3867
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
3868
|
+
if (policy !== 'content-only') {
|
|
3869
|
+
headers.set(formHeaders);
|
|
3870
|
+
return;
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3874
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
3875
|
+
headers.set(key, val);
|
|
3876
|
+
}
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
/**
|
|
3881
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
3882
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
3883
|
+
*
|
|
3884
|
+
* @param {string} str The string to encode
|
|
3885
|
+
*
|
|
3886
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
3887
|
+
*/
|
|
3888
|
+
const encodeUTF8$1 = (str) =>
|
|
3889
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
3890
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
3891
|
+
);
|
|
3892
|
+
|
|
3893
|
+
function resolveConfig(config) {
|
|
3706
3894
|
const newConfig = mergeConfig({}, config);
|
|
3707
3895
|
|
|
3708
3896
|
// Read only own properties to prevent prototype pollution gadgets
|
|
3709
|
-
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
3897
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
3710
3898
|
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
3711
3899
|
|
|
3712
3900
|
const data = own('data');
|
|
@@ -3723,8 +3911,8 @@ var resolveConfig = (config) => {
|
|
|
3723
3911
|
|
|
3724
3912
|
newConfig.url = buildURL(
|
|
3725
3913
|
buildFullPath(baseURL, url, allowAbsoluteUrls),
|
|
3726
|
-
|
|
3727
|
-
|
|
3914
|
+
own('params'),
|
|
3915
|
+
own('paramsSerializer')
|
|
3728
3916
|
);
|
|
3729
3917
|
|
|
3730
3918
|
// HTTP basic authentication
|
|
@@ -3732,27 +3920,20 @@ var resolveConfig = (config) => {
|
|
|
3732
3920
|
headers.set(
|
|
3733
3921
|
'Authorization',
|
|
3734
3922
|
'Basic ' +
|
|
3735
|
-
btoa(
|
|
3736
|
-
(auth.username || '') +
|
|
3737
|
-
':' +
|
|
3738
|
-
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
|
3739
|
-
)
|
|
3923
|
+
btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8$1(auth.password) : ''))
|
|
3740
3924
|
);
|
|
3741
3925
|
}
|
|
3742
3926
|
|
|
3743
3927
|
if (utils$1.isFormData(data)) {
|
|
3744
|
-
if (
|
|
3745
|
-
|
|
3928
|
+
if (
|
|
3929
|
+
platform.hasStandardBrowserEnv ||
|
|
3930
|
+
platform.hasStandardBrowserWebWorkerEnv ||
|
|
3931
|
+
utils$1.isReactNative(data)
|
|
3932
|
+
) {
|
|
3933
|
+
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
3746
3934
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
3747
3935
|
// Node.js FormData (like form-data package)
|
|
3748
|
-
|
|
3749
|
-
// Only set safe headers to avoid overwriting security headers
|
|
3750
|
-
const allowedHeaders = ['content-type', 'content-length'];
|
|
3751
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3752
|
-
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
3753
|
-
headers.set(key, val);
|
|
3754
|
-
}
|
|
3755
|
-
});
|
|
3936
|
+
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
3756
3937
|
}
|
|
3757
3938
|
}
|
|
3758
3939
|
|
|
@@ -3767,10 +3948,9 @@ var resolveConfig = (config) => {
|
|
|
3767
3948
|
|
|
3768
3949
|
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
3769
3950
|
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
3770
|
-
// the XSRF token cross-origin.
|
|
3951
|
+
// the XSRF token cross-origin.
|
|
3771
3952
|
const shouldSendXSRF =
|
|
3772
|
-
withXSRFToken === true ||
|
|
3773
|
-
(withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
3953
|
+
withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
3774
3954
|
|
|
3775
3955
|
if (shouldSendXSRF) {
|
|
3776
3956
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
@@ -3782,7 +3962,7 @@ var resolveConfig = (config) => {
|
|
|
3782
3962
|
}
|
|
3783
3963
|
|
|
3784
3964
|
return newConfig;
|
|
3785
|
-
}
|
|
3965
|
+
}
|
|
3786
3966
|
|
|
3787
3967
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
3788
3968
|
|
|
@@ -3866,7 +4046,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3866
4046
|
// will return status as 0 even though it's a successful request
|
|
3867
4047
|
if (
|
|
3868
4048
|
request.status === 0 &&
|
|
3869
|
-
!(request.responseURL && request.responseURL.
|
|
4049
|
+
!(request.responseURL && request.responseURL.startsWith('file:'))
|
|
3870
4050
|
) {
|
|
3871
4051
|
return;
|
|
3872
4052
|
}
|
|
@@ -3883,6 +4063,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3883
4063
|
}
|
|
3884
4064
|
|
|
3885
4065
|
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
4066
|
+
done();
|
|
3886
4067
|
|
|
3887
4068
|
// Clean up request
|
|
3888
4069
|
request = null;
|
|
@@ -3898,6 +4079,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3898
4079
|
// attach the underlying event for consumers who want details
|
|
3899
4080
|
err.event = event || null;
|
|
3900
4081
|
reject(err);
|
|
4082
|
+
done();
|
|
3901
4083
|
request = null;
|
|
3902
4084
|
};
|
|
3903
4085
|
|
|
@@ -3918,6 +4100,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3918
4100
|
request
|
|
3919
4101
|
)
|
|
3920
4102
|
);
|
|
4103
|
+
done();
|
|
3921
4104
|
|
|
3922
4105
|
// Clean up request
|
|
3923
4106
|
request = null;
|
|
@@ -3928,7 +4111,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3928
4111
|
|
|
3929
4112
|
// Add headers to the request
|
|
3930
4113
|
if ('setRequestHeader' in request) {
|
|
3931
|
-
utils$1.forEach(requestHeaders
|
|
4114
|
+
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
3932
4115
|
request.setRequestHeader(key, val);
|
|
3933
4116
|
});
|
|
3934
4117
|
}
|
|
@@ -3967,6 +4150,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3967
4150
|
}
|
|
3968
4151
|
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
3969
4152
|
request.abort();
|
|
4153
|
+
done();
|
|
3970
4154
|
request = null;
|
|
3971
4155
|
};
|
|
3972
4156
|
|
|
@@ -3980,7 +4164,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3980
4164
|
|
|
3981
4165
|
const protocol = parseProtocol(_config.url);
|
|
3982
4166
|
|
|
3983
|
-
if (protocol && platform.protocols.
|
|
4167
|
+
if (protocol && !platform.protocols.includes(protocol)) {
|
|
3984
4168
|
reject(
|
|
3985
4169
|
new AxiosError$1(
|
|
3986
4170
|
'Unsupported protocol ' + protocol + ':',
|
|
@@ -3997,54 +4181,55 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3997
4181
|
};
|
|
3998
4182
|
|
|
3999
4183
|
const composeSignals = (signals, timeout) => {
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
if (timeout || length) {
|
|
4003
|
-
let controller = new AbortController();
|
|
4004
|
-
|
|
4005
|
-
let aborted;
|
|
4006
|
-
|
|
4007
|
-
const onabort = function (reason) {
|
|
4008
|
-
if (!aborted) {
|
|
4009
|
-
aborted = true;
|
|
4010
|
-
unsubscribe();
|
|
4011
|
-
const err = reason instanceof Error ? reason : this.reason;
|
|
4012
|
-
controller.abort(
|
|
4013
|
-
err instanceof AxiosError$1
|
|
4014
|
-
? err
|
|
4015
|
-
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
4016
|
-
);
|
|
4017
|
-
}
|
|
4018
|
-
};
|
|
4184
|
+
signals = signals ? signals.filter(Boolean) : [];
|
|
4019
4185
|
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
}
|
|
4186
|
+
if (!timeout && !signals.length) {
|
|
4187
|
+
return;
|
|
4188
|
+
}
|
|
4189
|
+
|
|
4190
|
+
const controller = new AbortController();
|
|
4191
|
+
|
|
4192
|
+
let aborted = false;
|
|
4193
|
+
|
|
4194
|
+
const onabort = function (reason) {
|
|
4195
|
+
if (!aborted) {
|
|
4196
|
+
aborted = true;
|
|
4197
|
+
unsubscribe();
|
|
4198
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
4199
|
+
controller.abort(
|
|
4200
|
+
err instanceof AxiosError$1
|
|
4201
|
+
? err
|
|
4202
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
4203
|
+
);
|
|
4204
|
+
}
|
|
4205
|
+
};
|
|
4206
|
+
|
|
4207
|
+
let timer =
|
|
4208
|
+
timeout &&
|
|
4209
|
+
setTimeout(() => {
|
|
4210
|
+
timer = null;
|
|
4211
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
4212
|
+
}, timeout);
|
|
4213
|
+
|
|
4214
|
+
const unsubscribe = () => {
|
|
4215
|
+
if (!signals) { return; }
|
|
4216
|
+
timer && clearTimeout(timer);
|
|
4217
|
+
timer = null;
|
|
4218
|
+
signals.forEach((signal) => {
|
|
4219
|
+
signal.unsubscribe
|
|
4220
|
+
? signal.unsubscribe(onabort)
|
|
4221
|
+
: signal.removeEventListener('abort', onabort);
|
|
4222
|
+
});
|
|
4223
|
+
signals = null;
|
|
4224
|
+
};
|
|
4039
4225
|
|
|
4040
|
-
|
|
4226
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
4041
4227
|
|
|
4042
|
-
|
|
4228
|
+
const { signal } = controller;
|
|
4043
4229
|
|
|
4044
|
-
|
|
4230
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
4045
4231
|
|
|
4046
|
-
|
|
4047
|
-
}
|
|
4232
|
+
return signal;
|
|
4048
4233
|
};
|
|
4049
4234
|
|
|
4050
4235
|
var composeSignals$1 = composeSignals;
|
|
@@ -4139,16 +4324,141 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
4139
4324
|
);
|
|
4140
4325
|
};
|
|
4141
4326
|
|
|
4327
|
+
/**
|
|
4328
|
+
* Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|
4329
|
+
* - For base64: compute exact decoded size using length and padding;
|
|
4330
|
+
* handle %XX at the character-count level (no string allocation).
|
|
4331
|
+
* - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
|
|
4332
|
+
*
|
|
4333
|
+
* @param {string} url
|
|
4334
|
+
* @returns {number}
|
|
4335
|
+
*/
|
|
4336
|
+
function estimateDataURLDecodedBytes(url) {
|
|
4337
|
+
if (!url || typeof url !== 'string') return 0;
|
|
4338
|
+
if (!url.startsWith('data:')) return 0;
|
|
4339
|
+
|
|
4340
|
+
const comma = url.indexOf(',');
|
|
4341
|
+
if (comma < 0) return 0;
|
|
4342
|
+
|
|
4343
|
+
const meta = url.slice(5, comma);
|
|
4344
|
+
const body = url.slice(comma + 1);
|
|
4345
|
+
const isBase64 = /;base64/i.test(meta);
|
|
4346
|
+
|
|
4347
|
+
if (isBase64) {
|
|
4348
|
+
let effectiveLen = body.length;
|
|
4349
|
+
const len = body.length; // cache length
|
|
4350
|
+
|
|
4351
|
+
for (let i = 0; i < len; i++) {
|
|
4352
|
+
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
4353
|
+
const a = body.charCodeAt(i + 1);
|
|
4354
|
+
const b = body.charCodeAt(i + 2);
|
|
4355
|
+
const isHex =
|
|
4356
|
+
((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
|
|
4357
|
+
((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
|
|
4358
|
+
|
|
4359
|
+
if (isHex) {
|
|
4360
|
+
effectiveLen -= 2;
|
|
4361
|
+
i += 2;
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4364
|
+
}
|
|
4365
|
+
|
|
4366
|
+
let pad = 0;
|
|
4367
|
+
let idx = len - 1;
|
|
4368
|
+
|
|
4369
|
+
const tailIsPct3D = (j) =>
|
|
4370
|
+
j >= 2 &&
|
|
4371
|
+
body.charCodeAt(j - 2) === 37 && // '%'
|
|
4372
|
+
body.charCodeAt(j - 1) === 51 && // '3'
|
|
4373
|
+
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
|
|
4374
|
+
|
|
4375
|
+
if (idx >= 0) {
|
|
4376
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
4377
|
+
pad++;
|
|
4378
|
+
idx--;
|
|
4379
|
+
} else if (tailIsPct3D(idx)) {
|
|
4380
|
+
pad++;
|
|
4381
|
+
idx -= 3;
|
|
4382
|
+
}
|
|
4383
|
+
}
|
|
4384
|
+
|
|
4385
|
+
if (pad === 1 && idx >= 0) {
|
|
4386
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
4387
|
+
pad++;
|
|
4388
|
+
} else if (tailIsPct3D(idx)) {
|
|
4389
|
+
pad++;
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4393
|
+
const groups = Math.floor(effectiveLen / 4);
|
|
4394
|
+
const bytes = groups * 3 - (pad || 0);
|
|
4395
|
+
return bytes > 0 ? bytes : 0;
|
|
4396
|
+
}
|
|
4397
|
+
|
|
4398
|
+
if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
|
|
4399
|
+
return Buffer.byteLength(body, 'utf8');
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4402
|
+
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
4403
|
+
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
4404
|
+
// Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
|
|
4405
|
+
// but 3 UTF-8 bytes).
|
|
4406
|
+
let bytes = 0;
|
|
4407
|
+
for (let i = 0, len = body.length; i < len; i++) {
|
|
4408
|
+
const c = body.charCodeAt(i);
|
|
4409
|
+
if (c < 0x80) {
|
|
4410
|
+
bytes += 1;
|
|
4411
|
+
} else if (c < 0x800) {
|
|
4412
|
+
bytes += 2;
|
|
4413
|
+
} else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
|
4414
|
+
const next = body.charCodeAt(i + 1);
|
|
4415
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
4416
|
+
bytes += 4;
|
|
4417
|
+
i++;
|
|
4418
|
+
} else {
|
|
4419
|
+
bytes += 3;
|
|
4420
|
+
}
|
|
4421
|
+
} else {
|
|
4422
|
+
bytes += 3;
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4425
|
+
return bytes;
|
|
4426
|
+
}
|
|
4427
|
+
|
|
4428
|
+
const VERSION = "1.17.0";
|
|
4429
|
+
|
|
4142
4430
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
4143
4431
|
|
|
4144
4432
|
const { isFunction } = utils$1;
|
|
4145
4433
|
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4434
|
+
/**
|
|
4435
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
4436
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
4437
|
+
*
|
|
4438
|
+
* @param {string} str The string to encode
|
|
4439
|
+
*
|
|
4440
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
4441
|
+
*/
|
|
4442
|
+
const encodeUTF8 = (str) =>
|
|
4443
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
4444
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
4445
|
+
);
|
|
4446
|
+
|
|
4447
|
+
// Node's WHATWG URL parser returns `username` and `password` percent-encoded.
|
|
4448
|
+
// Decode before composing the `auth` option so credentials such as
|
|
4449
|
+
// `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
|
|
4450
|
+
// original value for malformed input so a bad encoding never throws.
|
|
4451
|
+
const decodeURIComponentSafe = (value) => {
|
|
4452
|
+
if (!utils$1.isString(value)) {
|
|
4453
|
+
return value;
|
|
4454
|
+
}
|
|
4150
4455
|
|
|
4151
|
-
|
|
4456
|
+
try {
|
|
4457
|
+
return decodeURIComponent(value);
|
|
4458
|
+
} catch (error) {
|
|
4459
|
+
return value;
|
|
4460
|
+
}
|
|
4461
|
+
};
|
|
4152
4462
|
|
|
4153
4463
|
const test = (fn, ...args) => {
|
|
4154
4464
|
try {
|
|
@@ -4158,12 +4468,30 @@ const test = (fn, ...args) => {
|
|
|
4158
4468
|
}
|
|
4159
4469
|
};
|
|
4160
4470
|
|
|
4471
|
+
const maybeWithAuthCredentials = (url) => {
|
|
4472
|
+
const protocolIndex = url.indexOf('://');
|
|
4473
|
+
let urlToCheck = url;
|
|
4474
|
+
if (protocolIndex !== -1) {
|
|
4475
|
+
urlToCheck = urlToCheck.slice(protocolIndex + 3);
|
|
4476
|
+
}
|
|
4477
|
+
return urlToCheck.includes('@') || urlToCheck.includes(':');
|
|
4478
|
+
};
|
|
4479
|
+
|
|
4161
4480
|
const factory = (env) => {
|
|
4481
|
+
const globalObject =
|
|
4482
|
+
utils$1.global !== undefined && utils$1.global !== null
|
|
4483
|
+
? utils$1.global
|
|
4484
|
+
: globalThis;
|
|
4485
|
+
const { ReadableStream, TextEncoder } = globalObject;
|
|
4486
|
+
|
|
4162
4487
|
env = utils$1.merge.call(
|
|
4163
4488
|
{
|
|
4164
4489
|
skipUndefined: true,
|
|
4165
4490
|
},
|
|
4166
|
-
|
|
4491
|
+
{
|
|
4492
|
+
Request: globalObject.Request,
|
|
4493
|
+
Response: globalObject.Response,
|
|
4494
|
+
},
|
|
4167
4495
|
env
|
|
4168
4496
|
);
|
|
4169
4497
|
|
|
@@ -4176,7 +4504,7 @@ const factory = (env) => {
|
|
|
4176
4504
|
return false;
|
|
4177
4505
|
}
|
|
4178
4506
|
|
|
4179
|
-
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream
|
|
4507
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
|
4180
4508
|
|
|
4181
4509
|
const encodeText =
|
|
4182
4510
|
isFetchSupported &&
|
|
@@ -4194,7 +4522,7 @@ const factory = (env) => {
|
|
|
4194
4522
|
let duplexAccessed = false;
|
|
4195
4523
|
|
|
4196
4524
|
const request = new Request(platform.origin, {
|
|
4197
|
-
body: new ReadableStream
|
|
4525
|
+
body: new ReadableStream(),
|
|
4198
4526
|
method: 'POST',
|
|
4199
4527
|
get duplex() {
|
|
4200
4528
|
duplexAccessed = true;
|
|
@@ -4290,8 +4618,14 @@ const factory = (env) => {
|
|
|
4290
4618
|
headers,
|
|
4291
4619
|
withCredentials = 'same-origin',
|
|
4292
4620
|
fetchOptions,
|
|
4621
|
+
maxContentLength,
|
|
4622
|
+
maxBodyLength,
|
|
4293
4623
|
} = resolveConfig(config);
|
|
4294
4624
|
|
|
4625
|
+
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
4626
|
+
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
4627
|
+
const own = (key) => (utils$1.hasOwnProp(config, key) ? config[key] : undefined);
|
|
4628
|
+
|
|
4295
4629
|
let _fetch = envFetch || fetch;
|
|
4296
4630
|
|
|
4297
4631
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
@@ -4313,6 +4647,81 @@ const factory = (env) => {
|
|
|
4313
4647
|
let requestContentLength;
|
|
4314
4648
|
|
|
4315
4649
|
try {
|
|
4650
|
+
// HTTP basic authentication
|
|
4651
|
+
let auth = undefined;
|
|
4652
|
+
const configAuth = own('auth');
|
|
4653
|
+
|
|
4654
|
+
if (configAuth) {
|
|
4655
|
+
const username = configAuth.username || '';
|
|
4656
|
+
const password = configAuth.password || '';
|
|
4657
|
+
auth = {
|
|
4658
|
+
username,
|
|
4659
|
+
password
|
|
4660
|
+
};
|
|
4661
|
+
}
|
|
4662
|
+
|
|
4663
|
+
if (maybeWithAuthCredentials(url)) {
|
|
4664
|
+
const parsedURL = new URL(url, platform.origin);
|
|
4665
|
+
|
|
4666
|
+
if (!auth && (parsedURL.username || parsedURL.password)) {
|
|
4667
|
+
const urlUsername = decodeURIComponentSafe(parsedURL.username);
|
|
4668
|
+
const urlPassword = decodeURIComponentSafe(parsedURL.password);
|
|
4669
|
+
auth = {
|
|
4670
|
+
username: urlUsername,
|
|
4671
|
+
password: urlPassword
|
|
4672
|
+
};
|
|
4673
|
+
}
|
|
4674
|
+
|
|
4675
|
+
if (parsedURL.username || parsedURL.password) {
|
|
4676
|
+
parsedURL.username = '';
|
|
4677
|
+
parsedURL.password = '';
|
|
4678
|
+
url = parsedURL.href;
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
|
|
4682
|
+
if (auth) {
|
|
4683
|
+
headers.delete('authorization');
|
|
4684
|
+
headers.set(
|
|
4685
|
+
'Authorization',
|
|
4686
|
+
'Basic ' + btoa(encodeUTF8((auth.username || '') + ':' + (auth.password || '')))
|
|
4687
|
+
);
|
|
4688
|
+
}
|
|
4689
|
+
|
|
4690
|
+
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
4691
|
+
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
4692
|
+
// "if (protocol === 'data:')" branch).
|
|
4693
|
+
if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
|
|
4694
|
+
const estimated = estimateDataURLDecodedBytes(url);
|
|
4695
|
+
if (estimated > maxContentLength) {
|
|
4696
|
+
throw new AxiosError$1(
|
|
4697
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4698
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4699
|
+
config,
|
|
4700
|
+
request
|
|
4701
|
+
);
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4704
|
+
|
|
4705
|
+
// Enforce maxBodyLength against the outbound request body before dispatch.
|
|
4706
|
+
// Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
|
|
4707
|
+
// maxBodyLength limit'). Skip when the body length cannot be determined
|
|
4708
|
+
// (e.g. a live ReadableStream supplied by the caller).
|
|
4709
|
+
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
4710
|
+
const outboundLength = await resolveBodyLength(headers, data);
|
|
4711
|
+
if (
|
|
4712
|
+
typeof outboundLength === 'number' &&
|
|
4713
|
+
isFinite(outboundLength) &&
|
|
4714
|
+
outboundLength > maxBodyLength
|
|
4715
|
+
) {
|
|
4716
|
+
throw new AxiosError$1(
|
|
4717
|
+
'Request body larger than maxBodyLength limit',
|
|
4718
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
4719
|
+
config,
|
|
4720
|
+
request
|
|
4721
|
+
);
|
|
4722
|
+
}
|
|
4723
|
+
}
|
|
4724
|
+
|
|
4316
4725
|
if (
|
|
4317
4726
|
onUploadProgress &&
|
|
4318
4727
|
supportsRequestStream &&
|
|
@@ -4363,11 +4772,14 @@ const factory = (env) => {
|
|
|
4363
4772
|
}
|
|
4364
4773
|
}
|
|
4365
4774
|
|
|
4775
|
+
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
4776
|
+
headers.set('User-Agent', 'axios/' + VERSION, false);
|
|
4777
|
+
|
|
4366
4778
|
const resolvedOptions = {
|
|
4367
4779
|
...fetchOptions,
|
|
4368
4780
|
signal: composedSignal,
|
|
4369
4781
|
method: method.toUpperCase(),
|
|
4370
|
-
headers: headers.normalize()
|
|
4782
|
+
headers: toByteStringHeaderObject(headers.normalize()),
|
|
4371
4783
|
body: data,
|
|
4372
4784
|
duplex: 'half',
|
|
4373
4785
|
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
@@ -4379,10 +4791,28 @@ const factory = (env) => {
|
|
|
4379
4791
|
? _fetch(request, fetchOptions)
|
|
4380
4792
|
: _fetch(url, resolvedOptions));
|
|
4381
4793
|
|
|
4794
|
+
// Cheap pre-check: if the server honestly declares a content-length that
|
|
4795
|
+
// already exceeds the cap, reject before we start streaming.
|
|
4796
|
+
if (hasMaxContentLength) {
|
|
4797
|
+
const declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
4798
|
+
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
4799
|
+
throw new AxiosError$1(
|
|
4800
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4801
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4802
|
+
config,
|
|
4803
|
+
request
|
|
4804
|
+
);
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4382
4808
|
const isStreamResponse =
|
|
4383
4809
|
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
4384
4810
|
|
|
4385
|
-
if (
|
|
4811
|
+
if (
|
|
4812
|
+
supportsResponseStream &&
|
|
4813
|
+
response.body &&
|
|
4814
|
+
(onDownloadProgress || hasMaxContentLength || (isStreamResponse && unsubscribe))
|
|
4815
|
+
) {
|
|
4386
4816
|
const options = {};
|
|
4387
4817
|
|
|
4388
4818
|
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
@@ -4399,8 +4829,24 @@ const factory = (env) => {
|
|
|
4399
4829
|
)) ||
|
|
4400
4830
|
[];
|
|
4401
4831
|
|
|
4832
|
+
let bytesRead = 0;
|
|
4833
|
+
const onChunkProgress = (loadedBytes) => {
|
|
4834
|
+
if (hasMaxContentLength) {
|
|
4835
|
+
bytesRead = loadedBytes;
|
|
4836
|
+
if (bytesRead > maxContentLength) {
|
|
4837
|
+
throw new AxiosError$1(
|
|
4838
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4839
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4840
|
+
config,
|
|
4841
|
+
request
|
|
4842
|
+
);
|
|
4843
|
+
}
|
|
4844
|
+
}
|
|
4845
|
+
onProgress && onProgress(loadedBytes);
|
|
4846
|
+
};
|
|
4847
|
+
|
|
4402
4848
|
response = new Response(
|
|
4403
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE,
|
|
4849
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
|
|
4404
4850
|
flush && flush();
|
|
4405
4851
|
unsubscribe && unsubscribe();
|
|
4406
4852
|
}),
|
|
@@ -4415,6 +4861,33 @@ const factory = (env) => {
|
|
|
4415
4861
|
config
|
|
4416
4862
|
);
|
|
4417
4863
|
|
|
4864
|
+
// Fallback enforcement for environments without ReadableStream support
|
|
4865
|
+
// (legacy runtimes). Detect materialized size from typed output; skip
|
|
4866
|
+
// streams/Response passthrough since the user will read those themselves.
|
|
4867
|
+
if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
|
|
4868
|
+
let materializedSize;
|
|
4869
|
+
if (responseData != null) {
|
|
4870
|
+
if (typeof responseData.byteLength === 'number') {
|
|
4871
|
+
materializedSize = responseData.byteLength;
|
|
4872
|
+
} else if (typeof responseData.size === 'number') {
|
|
4873
|
+
materializedSize = responseData.size;
|
|
4874
|
+
} else if (typeof responseData === 'string') {
|
|
4875
|
+
materializedSize =
|
|
4876
|
+
typeof TextEncoder === 'function'
|
|
4877
|
+
? new TextEncoder().encode(responseData).byteLength
|
|
4878
|
+
: responseData.length;
|
|
4879
|
+
}
|
|
4880
|
+
}
|
|
4881
|
+
if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
|
|
4882
|
+
throw new AxiosError$1(
|
|
4883
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4884
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4885
|
+
config,
|
|
4886
|
+
request
|
|
4887
|
+
);
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
|
|
4418
4891
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
4419
4892
|
|
|
4420
4893
|
return await new Promise((resolve, reject) => {
|
|
@@ -4430,6 +4903,17 @@ const factory = (env) => {
|
|
|
4430
4903
|
} catch (err) {
|
|
4431
4904
|
unsubscribe && unsubscribe();
|
|
4432
4905
|
|
|
4906
|
+
// Safari can surface fetch aborts as a DOMException-like object whose
|
|
4907
|
+
// branded getters throw. Prefer our composed signal reason before reading
|
|
4908
|
+
// the caught error, preserving timeout vs cancellation semantics.
|
|
4909
|
+
if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError$1) {
|
|
4910
|
+
const canceledError = composedSignal.reason;
|
|
4911
|
+
canceledError.config = config;
|
|
4912
|
+
request && (canceledError.request = request);
|
|
4913
|
+
err !== canceledError && (canceledError.cause = err);
|
|
4914
|
+
throw canceledError;
|
|
4915
|
+
}
|
|
4916
|
+
|
|
4433
4917
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
4434
4918
|
throw Object.assign(
|
|
4435
4919
|
new AxiosError$1(
|
|
@@ -4498,11 +4982,13 @@ const knownAdapters = {
|
|
|
4498
4982
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
4499
4983
|
if (fn) {
|
|
4500
4984
|
try {
|
|
4501
|
-
Object.
|
|
4985
|
+
// Null-proto descriptors so a polluted Object.prototype.get cannot turn
|
|
4986
|
+
// these data descriptors into accessor descriptors on the way in.
|
|
4987
|
+
Object.defineProperty(fn, 'name', { __proto__: null, value });
|
|
4502
4988
|
} catch (e) {
|
|
4503
4989
|
// eslint-disable-next-line no-empty
|
|
4504
4990
|
}
|
|
4505
|
-
Object.defineProperty(fn, 'adapterName', { value });
|
|
4991
|
+
Object.defineProperty(fn, 'adapterName', { __proto__: null, value });
|
|
4506
4992
|
}
|
|
4507
4993
|
});
|
|
4508
4994
|
|
|
@@ -4644,8 +5130,15 @@ function dispatchRequest(config) {
|
|
|
4644
5130
|
function onAdapterResolution(response) {
|
|
4645
5131
|
throwIfCancellationRequested(config);
|
|
4646
5132
|
|
|
4647
|
-
//
|
|
4648
|
-
|
|
5133
|
+
// Expose the current response on config so that transformResponse can
|
|
5134
|
+
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
5135
|
+
// We clean it up afterwards to avoid polluting the config object.
|
|
5136
|
+
config.response = response;
|
|
5137
|
+
try {
|
|
5138
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
5139
|
+
} finally {
|
|
5140
|
+
delete config.response;
|
|
5141
|
+
}
|
|
4649
5142
|
|
|
4650
5143
|
response.headers = AxiosHeaders$1.from(response.headers);
|
|
4651
5144
|
|
|
@@ -4657,11 +5150,16 @@ function dispatchRequest(config) {
|
|
|
4657
5150
|
|
|
4658
5151
|
// Transform response data
|
|
4659
5152
|
if (reason && reason.response) {
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
5153
|
+
config.response = reason.response;
|
|
5154
|
+
try {
|
|
5155
|
+
reason.response.data = transformData.call(
|
|
5156
|
+
config,
|
|
5157
|
+
config.transformResponse,
|
|
5158
|
+
reason.response
|
|
5159
|
+
);
|
|
5160
|
+
} finally {
|
|
5161
|
+
delete config.response;
|
|
5162
|
+
}
|
|
4665
5163
|
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
4666
5164
|
}
|
|
4667
5165
|
}
|
|
@@ -4671,8 +5169,6 @@ function dispatchRequest(config) {
|
|
|
4671
5169
|
);
|
|
4672
5170
|
}
|
|
4673
5171
|
|
|
4674
|
-
const VERSION = "1.15.2";
|
|
4675
|
-
|
|
4676
5172
|
const validators$1 = {};
|
|
4677
5173
|
|
|
4678
5174
|
// eslint-disable-next-line func-names
|
|
@@ -4757,7 +5253,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
4757
5253
|
while (i-- > 0) {
|
|
4758
5254
|
const opt = keys[i];
|
|
4759
5255
|
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
4760
|
-
// a non-function validator and cause a TypeError.
|
|
5256
|
+
// a non-function validator and cause a TypeError.
|
|
4761
5257
|
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
4762
5258
|
if (validator) {
|
|
4763
5259
|
const value = options[opt];
|
|
@@ -4872,6 +5368,7 @@ class Axios {
|
|
|
4872
5368
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
4873
5369
|
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
4874
5370
|
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
5371
|
+
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
|
|
4875
5372
|
},
|
|
4876
5373
|
false
|
|
4877
5374
|
);
|
|
@@ -4917,7 +5414,7 @@ class Axios {
|
|
|
4917
5414
|
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
4918
5415
|
|
|
4919
5416
|
headers &&
|
|
4920
|
-
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
5417
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
|
|
4921
5418
|
delete headers[method];
|
|
4922
5419
|
});
|
|
4923
5420
|
|
|
@@ -5020,7 +5517,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
5020
5517
|
};
|
|
5021
5518
|
});
|
|
5022
5519
|
|
|
5023
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
5520
|
+
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
5024
5521
|
function generateHTTPMethod(isForm) {
|
|
5025
5522
|
return function httpMethod(url, data, config) {
|
|
5026
5523
|
return this.request(
|
|
@@ -5040,7 +5537,11 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
|
|
|
5040
5537
|
|
|
5041
5538
|
Axios.prototype[method] = generateHTTPMethod();
|
|
5042
5539
|
|
|
5043
|
-
|
|
5540
|
+
// QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|
5541
|
+
// its semantics, so no queryForm shorthand is generated.
|
|
5542
|
+
if (method !== 'query') {
|
|
5543
|
+
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
5544
|
+
}
|
|
5044
5545
|
});
|
|
5045
5546
|
|
|
5046
5547
|
var Axios$1 = Axios;
|
|
@@ -5364,7 +5865,7 @@ axios.default = axios;
|
|
|
5364
5865
|
var axios$1 = axios;
|
|
5365
5866
|
|
|
5366
5867
|
var name$1 = "@tryghost/content-api";
|
|
5367
|
-
var version = "1.12.
|
|
5868
|
+
var version = "1.12.9";
|
|
5368
5869
|
var repository = {
|
|
5369
5870
|
type: "git",
|
|
5370
5871
|
url: "git+https://github.com/TryGhost/SDK.git",
|
|
@@ -5397,28 +5898,28 @@ var publishConfig = {
|
|
|
5397
5898
|
access: "public"
|
|
5398
5899
|
};
|
|
5399
5900
|
var devDependencies = {
|
|
5400
|
-
"@babel/core": "7.29.
|
|
5901
|
+
"@babel/core": "7.29.7",
|
|
5401
5902
|
"@babel/polyfill": "7.12.1",
|
|
5402
|
-
"@babel/preset-env": "7.29.
|
|
5403
|
-
"@rollup/plugin-babel": "7.
|
|
5903
|
+
"@babel/preset-env": "7.29.7",
|
|
5904
|
+
"@rollup/plugin-babel": "7.1.0",
|
|
5404
5905
|
"@rollup/plugin-json": "6.1.0",
|
|
5405
5906
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
5406
5907
|
"@rollup/plugin-terser": "1.0.0",
|
|
5407
5908
|
c8: "11.0.0",
|
|
5408
5909
|
"core-js": "3.49.0",
|
|
5409
5910
|
"eslint-plugin-ghost": "3.5.0",
|
|
5410
|
-
mocha: "11.7.
|
|
5911
|
+
mocha: "11.7.6",
|
|
5411
5912
|
rollup: "2.80.0",
|
|
5412
5913
|
"rollup-plugin-commonjs": "10.1.0",
|
|
5413
5914
|
"rollup-plugin-polyfill-node": "0.13.0",
|
|
5414
5915
|
"rollup-plugin-replace": "2.2.0",
|
|
5415
5916
|
should: "13.2.3",
|
|
5416
|
-
sinon: "
|
|
5917
|
+
sinon: "22.0.0"
|
|
5417
5918
|
};
|
|
5418
5919
|
var dependencies = {
|
|
5419
|
-
axios: "1.
|
|
5920
|
+
axios: "1.17.0"
|
|
5420
5921
|
};
|
|
5421
|
-
var gitHead = "
|
|
5922
|
+
var gitHead = "8cc9ae375d4851d0ea52916a5c5cd9570bb53d0b";
|
|
5422
5923
|
var packageInfo = {
|
|
5423
5924
|
name: name$1,
|
|
5424
5925
|
version: version,
|