@kontent-ai/core-sdk 10.12.4 → 10.12.5

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.
@@ -899,7 +899,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
899
899
  \***************************************************/
900
900
  (module, __unused_webpack_exports, __webpack_require__) {
901
901
 
902
- /*! Axios v1.15.0 Copyright (c) 2026 Matt Zabriskie and contributors */
902
+ /*! Axios v1.16.1 Copyright (c) 2026 Matt Zabriskie and contributors */
903
903
 
904
904
 
905
905
  /**
@@ -1105,9 +1105,9 @@ const isFile = kindOfTest('File');
1105
1105
  * also have a `name` and `type` attribute to specify filename and content type
1106
1106
  *
1107
1107
  * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
1108
- *
1108
+ *
1109
1109
  * @param {*} value The value to test
1110
- *
1110
+ *
1111
1111
  * @returns {boolean} True if value is a React Native Blob, otherwise false
1112
1112
  */
1113
1113
  const isReactNativeBlob = (value) => {
@@ -1117,9 +1117,9 @@ const isReactNativeBlob = (value) => {
1117
1117
  /**
1118
1118
  * Determine if environment is React Native
1119
1119
  * ReactNative `FormData` has a non-standard `getParts()` method
1120
- *
1120
+ *
1121
1121
  * @param {*} formData The formData to test
1122
- *
1122
+ *
1123
1123
  * @returns {boolean} True if environment is React Native, otherwise false
1124
1124
  */
1125
1125
  const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
@@ -1138,7 +1138,7 @@ const isBlob = kindOfTest('Blob');
1138
1138
  *
1139
1139
  * @param {*} val The value to test
1140
1140
  *
1141
- * @returns {boolean} True if value is a File, otherwise false
1141
+ * @returns {boolean} True if value is a FileList, otherwise false
1142
1142
  */
1143
1143
  const isFileList = kindOfTest('FileList');
1144
1144
 
@@ -1170,15 +1170,17 @@ const G = getGlobal();
1170
1170
  const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
1171
1171
 
1172
1172
  const isFormData = (thing) => {
1173
- let kind;
1174
- return thing && (
1175
- (FormDataCtor && thing instanceof FormDataCtor) || (
1176
- isFunction$1(thing.append) && (
1177
- (kind = kindOf(thing)) === 'formdata' ||
1178
- // detect form-data instance
1179
- (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
1180
- )
1181
- )
1173
+ if (!thing) return false;
1174
+ if (FormDataCtor && thing instanceof FormDataCtor) return true;
1175
+ // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
1176
+ const proto = getPrototypeOf(thing);
1177
+ if (!proto || proto === Object.prototype) return false;
1178
+ if (!isFunction$1(thing.append)) return false;
1179
+ const kind = kindOf(thing);
1180
+ return (
1181
+ kind === 'formdata' ||
1182
+ // detect form-data instance
1183
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
1182
1184
  );
1183
1185
  };
1184
1186
 
@@ -1314,7 +1316,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
1314
1316
  *
1315
1317
  * @returns {Object} Result of all merge properties
1316
1318
  */
1317
- function merge(/* obj1, obj2, obj3, ... */) {
1319
+ function merge(...objs) {
1318
1320
  const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
1319
1321
  const result = {};
1320
1322
  const assignValue = (val, key) => {
@@ -1324,8 +1326,12 @@ function merge(/* obj1, obj2, obj3, ... */) {
1324
1326
  }
1325
1327
 
1326
1328
  const targetKey = (caseless && findKey(result, key)) || key;
1327
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
1328
- result[targetKey] = merge(result[targetKey], val);
1329
+ // Read via own-prop only — a bare `result[targetKey]` walks the prototype
1330
+ // chain, so a polluted Object.prototype value could surface here and get
1331
+ // copied into the merged result.
1332
+ const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
1333
+ if (isPlainObject(existing) && isPlainObject(val)) {
1334
+ result[targetKey] = merge(existing, val);
1329
1335
  } else if (isPlainObject(val)) {
1330
1336
  result[targetKey] = merge({}, val);
1331
1337
  } else if (isArray(val)) {
@@ -1335,8 +1341,8 @@ function merge(/* obj1, obj2, obj3, ... */) {
1335
1341
  }
1336
1342
  };
1337
1343
 
1338
- for (let i = 0, l = arguments.length; i < l; i++) {
1339
- arguments[i] && forEach(arguments[i], assignValue);
1344
+ for (let i = 0, l = objs.length; i < l; i++) {
1345
+ objs[i] && forEach(objs[i], assignValue);
1340
1346
  }
1341
1347
  return result;
1342
1348
  }
@@ -1358,6 +1364,9 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
1358
1364
  (val, key) => {
1359
1365
  if (thisArg && isFunction$1(val)) {
1360
1366
  Object.defineProperty(a, key, {
1367
+ // Null-proto descriptor so a polluted Object.prototype.get cannot
1368
+ // hijack defineProperty's accessor-vs-data resolution.
1369
+ __proto__: null,
1361
1370
  value: bind(val, thisArg),
1362
1371
  writable: true,
1363
1372
  enumerable: true,
@@ -1365,6 +1374,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
1365
1374
  });
1366
1375
  } else {
1367
1376
  Object.defineProperty(a, key, {
1377
+ __proto__: null,
1368
1378
  value: val,
1369
1379
  writable: true,
1370
1380
  enumerable: true,
@@ -1403,12 +1413,14 @@ const stripBOM = (content) => {
1403
1413
  const inherits = (constructor, superConstructor, props, descriptors) => {
1404
1414
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
1405
1415
  Object.defineProperty(constructor.prototype, 'constructor', {
1416
+ __proto__: null,
1406
1417
  value: constructor,
1407
1418
  writable: true,
1408
1419
  enumerable: false,
1409
1420
  configurable: true,
1410
1421
  });
1411
1422
  Object.defineProperty(constructor, 'super', {
1423
+ __proto__: null,
1412
1424
  value: superConstructor.prototype,
1413
1425
  });
1414
1426
  props && Object.assign(constructor.prototype, props);
@@ -1590,7 +1602,7 @@ const reduceDescriptors = (obj, reducer) => {
1590
1602
  const freezeMethods = (obj) => {
1591
1603
  reduceDescriptors(obj, (descriptor, name) => {
1592
1604
  // skip restricted props in strict mode
1593
- if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
1605
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
1594
1606
  return false;
1595
1607
  }
1596
1608
 
@@ -1664,11 +1676,11 @@ function isSpecCompliantForm(thing) {
1664
1676
  * @returns {Object} The JSON-compatible object.
1665
1677
  */
1666
1678
  const toJSONObject = (obj) => {
1667
- const stack = new Array(10);
1679
+ const visited = new WeakSet();
1668
1680
 
1669
- const visit = (source, i) => {
1681
+ const visit = (source) => {
1670
1682
  if (isObject(source)) {
1671
- if (stack.indexOf(source) >= 0) {
1683
+ if (visited.has(source)) {
1672
1684
  return;
1673
1685
  }
1674
1686
 
@@ -1678,15 +1690,16 @@ const toJSONObject = (obj) => {
1678
1690
  }
1679
1691
 
1680
1692
  if (!('toJSON' in source)) {
1681
- stack[i] = source;
1693
+ // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
1694
+ visited.add(source);
1682
1695
  const target = isArray(source) ? [] : {};
1683
1696
 
1684
1697
  forEach(source, (value, key) => {
1685
- const reducedValue = visit(value, i + 1);
1698
+ const reducedValue = visit(value);
1686
1699
  !isUndefined(reducedValue) && (target[key] = reducedValue);
1687
1700
  });
1688
1701
 
1689
- stack[i] = undefined;
1702
+ visited.delete(source);
1690
1703
 
1691
1704
  return target;
1692
1705
  }
@@ -1695,7 +1708,7 @@ const toJSONObject = (obj) => {
1695
1708
  return source;
1696
1709
  };
1697
1710
 
1698
- return visit(obj, 0);
1711
+ return visit(obj);
1699
1712
  };
1700
1713
 
1701
1714
  /**
@@ -1831,1297 +1844,1422 @@ var utils$1 = {
1831
1844
  isIterable,
1832
1845
  };
1833
1846
 
1834
- class AxiosError extends Error {
1835
- static from(error, code, config, request, response, customProps) {
1836
- const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1837
- axiosError.cause = error;
1838
- axiosError.name = error.name;
1847
+ // RawAxiosHeaders whose duplicates are ignored by node
1848
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1849
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1850
+ 'age',
1851
+ 'authorization',
1852
+ 'content-length',
1853
+ 'content-type',
1854
+ 'etag',
1855
+ 'expires',
1856
+ 'from',
1857
+ 'host',
1858
+ 'if-modified-since',
1859
+ 'if-unmodified-since',
1860
+ 'last-modified',
1861
+ 'location',
1862
+ 'max-forwards',
1863
+ 'proxy-authorization',
1864
+ 'referer',
1865
+ 'retry-after',
1866
+ 'user-agent',
1867
+ ]);
1839
1868
 
1840
- // Preserve status from the original error if not already set from response
1841
- if (error.status != null && axiosError.status == null) {
1842
- axiosError.status = error.status;
1869
+ /**
1870
+ * Parse headers into an object
1871
+ *
1872
+ * ```
1873
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1874
+ * Content-Type: application/json
1875
+ * Connection: keep-alive
1876
+ * Transfer-Encoding: chunked
1877
+ * ```
1878
+ *
1879
+ * @param {String} rawHeaders Headers needing to be parsed
1880
+ *
1881
+ * @returns {Object} Headers parsed into an object
1882
+ */
1883
+ var parseHeaders = (rawHeaders) => {
1884
+ const parsed = {};
1885
+ let key;
1886
+ let val;
1887
+ let i;
1888
+
1889
+ rawHeaders &&
1890
+ rawHeaders.split('\n').forEach(function parser(line) {
1891
+ i = line.indexOf(':');
1892
+ key = line.substring(0, i).trim().toLowerCase();
1893
+ val = line.substring(i + 1).trim();
1894
+
1895
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1896
+ return;
1897
+ }
1898
+
1899
+ if (key === 'set-cookie') {
1900
+ if (parsed[key]) {
1901
+ parsed[key].push(val);
1902
+ } else {
1903
+ parsed[key] = [val];
1904
+ }
1905
+ } else {
1906
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1907
+ }
1908
+ });
1909
+
1910
+ return parsed;
1911
+ };
1912
+
1913
+ function trimSPorHTAB(str) {
1914
+ let start = 0;
1915
+ let end = str.length;
1916
+
1917
+ while (start < end) {
1918
+ const code = str.charCodeAt(start);
1919
+
1920
+ if (code !== 0x09 && code !== 0x20) {
1921
+ break;
1843
1922
  }
1844
1923
 
1845
- customProps && Object.assign(axiosError, customProps);
1846
- return axiosError;
1924
+ start += 1;
1847
1925
  }
1848
1926
 
1849
- /**
1850
- * Create an Error with the specified message, config, error code, request and response.
1851
- *
1852
- * @param {string} message The error message.
1853
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
1854
- * @param {Object} [config] The config.
1855
- * @param {Object} [request] The request.
1856
- * @param {Object} [response] The response.
1857
- *
1858
- * @returns {Error} The created error.
1859
- */
1860
- constructor(message, code, config, request, response) {
1861
- super(message);
1862
-
1863
- // Make message enumerable to maintain backward compatibility
1864
- // The native Error constructor sets message as non-enumerable,
1865
- // but axios < v1.13.3 had it as enumerable
1866
- Object.defineProperty(this, 'message', {
1867
- value: message,
1868
- enumerable: true,
1869
- writable: true,
1870
- configurable: true
1871
- });
1872
-
1873
- this.name = 'AxiosError';
1874
- this.isAxiosError = true;
1875
- code && (this.code = code);
1876
- config && (this.config = config);
1877
- request && (this.request = request);
1878
- if (response) {
1879
- this.response = response;
1880
- this.status = response.status;
1881
- }
1927
+ while (end > start) {
1928
+ const code = str.charCodeAt(end - 1);
1929
+
1930
+ if (code !== 0x09 && code !== 0x20) {
1931
+ break;
1882
1932
  }
1883
1933
 
1884
- toJSON() {
1885
- return {
1886
- // Standard
1887
- message: this.message,
1888
- name: this.name,
1889
- // Microsoft
1890
- description: this.description,
1891
- number: this.number,
1892
- // Mozilla
1893
- fileName: this.fileName,
1894
- lineNumber: this.lineNumber,
1895
- columnNumber: this.columnNumber,
1896
- stack: this.stack,
1897
- // Axios
1898
- config: utils$1.toJSONObject(this.config),
1899
- code: this.code,
1900
- status: this.status,
1901
- };
1934
+ end -= 1;
1902
1935
  }
1936
+
1937
+ return start === 0 && end === str.length ? str : str.slice(start, end);
1903
1938
  }
1904
1939
 
1905
- // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1906
- AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1907
- AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1908
- AxiosError.ECONNABORTED = 'ECONNABORTED';
1909
- AxiosError.ETIMEDOUT = 'ETIMEDOUT';
1910
- AxiosError.ERR_NETWORK = 'ERR_NETWORK';
1911
- AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1912
- AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
1913
- AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1914
- AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1915
- AxiosError.ERR_CANCELED = 'ERR_CANCELED';
1916
- AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1917
- AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
1940
+ // The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
1941
+ // eslint-disable-next-line no-control-regex
1942
+ const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
1943
+ // eslint-disable-next-line no-control-regex
1944
+ const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
1918
1945
 
1919
- // eslint-disable-next-line strict
1920
- var httpAdapter = null;
1946
+ function sanitizeValue(value, invalidChars) {
1947
+ if (utils$1.isArray(value)) {
1948
+ return value.map((item) => sanitizeValue(item, invalidChars));
1949
+ }
1921
1950
 
1922
- /**
1923
- * Determines if the given thing is a array or js object.
1924
- *
1925
- * @param {string} thing - The object or array to be visited.
1926
- *
1927
- * @returns {boolean}
1928
- */
1929
- function isVisitable(thing) {
1930
- return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
1951
+ return trimSPorHTAB(String(value).replace(invalidChars, ''));
1931
1952
  }
1932
1953
 
1933
- /**
1934
- * It removes the brackets from the end of a string
1935
- *
1936
- * @param {string} key - The key of the parameter.
1937
- *
1938
- * @returns {string} the key without the brackets.
1939
- */
1940
- function removeBrackets(key) {
1941
- return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1942
- }
1954
+ const sanitizeHeaderValue = (value) =>
1955
+ sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
1943
1956
 
1944
- /**
1945
- * It takes a path, a key, and a boolean, and returns a string
1946
- *
1947
- * @param {string} path - The path to the current key.
1948
- * @param {string} key - The key of the current object being iterated over.
1949
- * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
1950
- *
1951
- * @returns {string} The path to the current key.
1952
- */
1953
- function renderKey(path, key, dots) {
1954
- if (!path) return key;
1955
- return path
1956
- .concat(key)
1957
- .map(function each(token, i) {
1958
- // eslint-disable-next-line no-param-reassign
1959
- token = removeBrackets(token);
1960
- return !dots && i ? '[' + token + ']' : token;
1961
- })
1962
- .join(dots ? '.' : '');
1963
- }
1957
+ const sanitizeByteStringHeaderValue = (value) =>
1958
+ sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
1964
1959
 
1965
- /**
1966
- * If the array is an array and none of its elements are visitable, then it's a flat array.
1967
- *
1968
- * @param {Array<any>} arr - The array to check
1969
- *
1970
- * @returns {boolean}
1971
- */
1972
- function isFlatArray(arr) {
1973
- return utils$1.isArray(arr) && !arr.some(isVisitable);
1960
+ function toByteStringHeaderObject(headers) {
1961
+ const byteStringHeaders = Object.create(null);
1962
+
1963
+ utils$1.forEach(headers.toJSON(), (value, header) => {
1964
+ byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
1965
+ });
1966
+
1967
+ return byteStringHeaders;
1974
1968
  }
1975
1969
 
1976
- const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1977
- return /^is[A-Z]/.test(prop);
1978
- });
1970
+ const $internals = Symbol('internals');
1979
1971
 
1980
- /**
1981
- * Convert a data object to FormData
1982
- *
1983
- * @param {Object} obj
1984
- * @param {?Object} [formData]
1985
- * @param {?Object} [options]
1986
- * @param {Function} [options.visitor]
1987
- * @param {Boolean} [options.metaTokens = true]
1988
- * @param {Boolean} [options.dots = false]
1989
- * @param {?Boolean} [options.indexes = false]
1990
- *
1991
- * @returns {Object}
1992
- **/
1972
+ function normalizeHeader(header) {
1973
+ return header && String(header).trim().toLowerCase();
1974
+ }
1993
1975
 
1994
- /**
1995
- * It converts an object into a FormData object
1996
- *
1997
- * @param {Object<any, any>} obj - The object to convert to form data.
1998
- * @param {string} formData - The FormData object to append to.
1999
- * @param {Object<string, any>} options
2000
- *
2001
- * @returns
2002
- */
2003
- function toFormData(obj, formData, options) {
2004
- if (!utils$1.isObject(obj)) {
2005
- throw new TypeError('target must be an object');
1976
+ function normalizeValue(value) {
1977
+ if (value === false || value == null) {
1978
+ return value;
2006
1979
  }
2007
1980
 
2008
- // eslint-disable-next-line no-param-reassign
2009
- formData = formData || new (FormData)();
2010
-
2011
- // eslint-disable-next-line no-param-reassign
2012
- options = utils$1.toFlatObject(
2013
- options,
2014
- {
2015
- metaTokens: true,
2016
- dots: false,
2017
- indexes: false,
2018
- },
2019
- false,
2020
- function defined(option, source) {
2021
- // eslint-disable-next-line no-eq-null,eqeqeq
2022
- return !utils$1.isUndefined(source[option]);
2023
- }
2024
- );
1981
+ return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
1982
+ }
2025
1983
 
2026
- const metaTokens = options.metaTokens;
2027
- // eslint-disable-next-line no-use-before-define
2028
- const visitor = options.visitor || defaultVisitor;
2029
- const dots = options.dots;
2030
- const indexes = options.indexes;
2031
- const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
2032
- const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1984
+ function parseTokens(str) {
1985
+ const tokens = Object.create(null);
1986
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1987
+ let match;
2033
1988
 
2034
- if (!utils$1.isFunction(visitor)) {
2035
- throw new TypeError('visitor must be a function');
1989
+ while ((match = tokensRE.exec(str))) {
1990
+ tokens[match[1]] = match[2];
2036
1991
  }
2037
1992
 
2038
- function convertValue(value) {
2039
- if (value === null) return '';
1993
+ return tokens;
1994
+ }
2040
1995
 
2041
- if (utils$1.isDate(value)) {
2042
- return value.toISOString();
2043
- }
2044
-
2045
- if (utils$1.isBoolean(value)) {
2046
- return value.toString();
2047
- }
2048
-
2049
- if (!useBlob && utils$1.isBlob(value)) {
2050
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
2051
- }
1996
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2052
1997
 
2053
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
2054
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
2055
- }
1998
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1999
+ if (utils$1.isFunction(filter)) {
2000
+ return filter.call(this, value, header);
2001
+ }
2056
2002
 
2057
- return value;
2003
+ if (isHeaderNameFilter) {
2004
+ value = header;
2058
2005
  }
2059
2006
 
2060
- /**
2061
- * Default visitor.
2062
- *
2063
- * @param {*} value
2064
- * @param {String|Number} key
2065
- * @param {Array<String|Number>} path
2066
- * @this {FormData}
2067
- *
2068
- * @returns {boolean} return true to visit the each prop of the value recursively
2069
- */
2070
- function defaultVisitor(value, key, path) {
2071
- let arr = value;
2007
+ if (!utils$1.isString(value)) return;
2072
2008
 
2073
- if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
2074
- formData.append(renderKey(path, key, dots), convertValue(value));
2075
- return false;
2076
- }
2009
+ if (utils$1.isString(filter)) {
2010
+ return value.indexOf(filter) !== -1;
2011
+ }
2077
2012
 
2078
- if (value && !path && typeof value === 'object') {
2079
- if (utils$1.endsWith(key, '{}')) {
2080
- // eslint-disable-next-line no-param-reassign
2081
- key = metaTokens ? key : key.slice(0, -2);
2082
- // eslint-disable-next-line no-param-reassign
2083
- value = JSON.stringify(value);
2084
- } else if (
2085
- (utils$1.isArray(value) && isFlatArray(value)) ||
2086
- ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
2087
- ) {
2088
- // eslint-disable-next-line no-param-reassign
2089
- key = removeBrackets(key);
2013
+ if (utils$1.isRegExp(filter)) {
2014
+ return filter.test(value);
2015
+ }
2016
+ }
2090
2017
 
2091
- arr.forEach(function each(el, index) {
2092
- !(utils$1.isUndefined(el) || el === null) &&
2093
- formData.append(
2094
- // eslint-disable-next-line no-nested-ternary
2095
- indexes === true
2096
- ? renderKey([key], index, dots)
2097
- : indexes === null
2098
- ? key
2099
- : key + '[]',
2100
- convertValue(el)
2101
- );
2102
- });
2103
- return false;
2104
- }
2105
- }
2018
+ function formatHeader(header) {
2019
+ return header
2020
+ .trim()
2021
+ .toLowerCase()
2022
+ .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2023
+ return char.toUpperCase() + str;
2024
+ });
2025
+ }
2106
2026
 
2107
- if (isVisitable(value)) {
2108
- return true;
2109
- }
2027
+ function buildAccessors(obj, header) {
2028
+ const accessorName = utils$1.toCamelCase(' ' + header);
2110
2029
 
2111
- formData.append(renderKey(path, key, dots), convertValue(value));
2030
+ ['get', 'set', 'has'].forEach((methodName) => {
2031
+ Object.defineProperty(obj, methodName + accessorName, {
2032
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
2033
+ // this data descriptor into an accessor descriptor on the way in.
2034
+ __proto__: null,
2035
+ value: function (arg1, arg2, arg3) {
2036
+ return this[methodName].call(this, header, arg1, arg2, arg3);
2037
+ },
2038
+ configurable: true,
2039
+ });
2040
+ });
2041
+ }
2112
2042
 
2113
- return false;
2043
+ class AxiosHeaders {
2044
+ constructor(headers) {
2045
+ headers && this.set(headers);
2114
2046
  }
2115
2047
 
2116
- const stack = [];
2048
+ set(header, valueOrRewrite, rewrite) {
2049
+ const self = this;
2117
2050
 
2118
- const exposedHelpers = Object.assign(predicates, {
2119
- defaultVisitor,
2120
- convertValue,
2121
- isVisitable,
2122
- });
2051
+ function setHeader(_value, _header, _rewrite) {
2052
+ const lHeader = normalizeHeader(_header);
2123
2053
 
2124
- function build(value, path) {
2125
- if (utils$1.isUndefined(value)) return;
2054
+ if (!lHeader) {
2055
+ throw new Error('header name must be a non-empty string');
2056
+ }
2126
2057
 
2127
- if (stack.indexOf(value) !== -1) {
2128
- throw Error('Circular reference detected in ' + path.join('.'));
2058
+ const key = utils$1.findKey(self, lHeader);
2059
+
2060
+ if (
2061
+ !key ||
2062
+ self[key] === undefined ||
2063
+ _rewrite === true ||
2064
+ (_rewrite === undefined && self[key] !== false)
2065
+ ) {
2066
+ self[key || _header] = normalizeValue(_value);
2067
+ }
2129
2068
  }
2130
2069
 
2131
- stack.push(value);
2070
+ const setHeaders = (headers, _rewrite) =>
2071
+ utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
2132
2072
 
2133
- utils$1.forEach(value, function each(el, key) {
2134
- const result =
2135
- !(utils$1.isUndefined(el) || el === null) &&
2136
- visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
2073
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
2074
+ setHeaders(header, valueOrRewrite);
2075
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2076
+ setHeaders(parseHeaders(header), valueOrRewrite);
2077
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
2078
+ let obj = {},
2079
+ dest,
2080
+ key;
2081
+ for (const entry of header) {
2082
+ if (!utils$1.isArray(entry)) {
2083
+ throw TypeError('Object iterator must return a key-value pair');
2084
+ }
2137
2085
 
2138
- if (result === true) {
2139
- build(el, path ? path.concat(key) : [key]);
2086
+ obj[(key = entry[0])] = (dest = obj[key])
2087
+ ? utils$1.isArray(dest)
2088
+ ? [...dest, entry[1]]
2089
+ : [dest, entry[1]]
2090
+ : entry[1];
2140
2091
  }
2141
- });
2142
2092
 
2143
- stack.pop();
2144
- }
2093
+ setHeaders(obj, valueOrRewrite);
2094
+ } else {
2095
+ header != null && setHeader(valueOrRewrite, header, rewrite);
2096
+ }
2145
2097
 
2146
- if (!utils$1.isObject(obj)) {
2147
- throw new TypeError('data must be an object');
2098
+ return this;
2148
2099
  }
2149
2100
 
2150
- build(obj);
2101
+ get(header, parser) {
2102
+ header = normalizeHeader(header);
2151
2103
 
2152
- return formData;
2153
- }
2104
+ if (header) {
2105
+ const key = utils$1.findKey(this, header);
2154
2106
 
2155
- /**
2156
- * It encodes a string by replacing all characters that are not in the unreserved set with
2157
- * their percent-encoded equivalents
2158
- *
2159
- * @param {string} str - The string to encode.
2160
- *
2161
- * @returns {string} The encoded string.
2162
- */
2163
- function encode$1(str) {
2164
- const charMap = {
2165
- '!': '%21',
2166
- "'": '%27',
2167
- '(': '%28',
2168
- ')': '%29',
2169
- '~': '%7E',
2170
- '%20': '+',
2171
- '%00': '\x00',
2172
- };
2173
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
2174
- return charMap[match];
2175
- });
2176
- }
2107
+ if (key) {
2108
+ const value = this[key];
2177
2109
 
2178
- /**
2179
- * It takes a params object and converts it to a FormData object
2180
- *
2181
- * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
2182
- * @param {Object<string, any>} options - The options object passed to the Axios constructor.
2183
- *
2184
- * @returns {void}
2185
- */
2186
- function AxiosURLSearchParams(params, options) {
2187
- this._pairs = [];
2110
+ if (!parser) {
2111
+ return value;
2112
+ }
2188
2113
 
2189
- params && toFormData(params, this, options);
2190
- }
2114
+ if (parser === true) {
2115
+ return parseTokens(value);
2116
+ }
2191
2117
 
2192
- const prototype = AxiosURLSearchParams.prototype;
2118
+ if (utils$1.isFunction(parser)) {
2119
+ return parser.call(this, value, key);
2120
+ }
2193
2121
 
2194
- prototype.append = function append(name, value) {
2195
- this._pairs.push([name, value]);
2196
- };
2122
+ if (utils$1.isRegExp(parser)) {
2123
+ return parser.exec(value);
2124
+ }
2197
2125
 
2198
- prototype.toString = function toString(encoder) {
2199
- const _encode = encoder
2200
- ? function (value) {
2201
- return encoder.call(this, value, encode$1);
2126
+ throw new TypeError('parser must be boolean|regexp|function');
2202
2127
  }
2203
- : encode$1;
2128
+ }
2129
+ }
2204
2130
 
2205
- return this._pairs
2206
- .map(function each(pair) {
2207
- return _encode(pair[0]) + '=' + _encode(pair[1]);
2208
- }, '')
2209
- .join('&');
2210
- };
2131
+ has(header, matcher) {
2132
+ header = normalizeHeader(header);
2211
2133
 
2212
- /**
2213
- * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
2214
- * their plain counterparts (`:`, `$`, `,`, `+`).
2215
- *
2216
- * @param {string} val The value to be encoded.
2217
- *
2218
- * @returns {string} The encoded value.
2219
- */
2220
- function encode(val) {
2221
- return encodeURIComponent(val)
2222
- .replace(/%3A/gi, ':')
2223
- .replace(/%24/g, '$')
2224
- .replace(/%2C/gi, ',')
2225
- .replace(/%20/g, '+');
2226
- }
2134
+ if (header) {
2135
+ const key = utils$1.findKey(this, header);
2227
2136
 
2228
- /**
2229
- * Build a URL by appending params to the end
2230
- *
2231
- * @param {string} url The base of the url (e.g., http://www.google.com)
2232
- * @param {object} [params] The params to be appended
2233
- * @param {?(object|Function)} options
2234
- *
2235
- * @returns {string} The formatted url
2236
- */
2237
- function buildURL(url, params, options) {
2238
- if (!params) {
2239
- return url;
2137
+ return !!(
2138
+ key &&
2139
+ this[key] !== undefined &&
2140
+ (!matcher || matchHeaderValue(this, this[key], key, matcher))
2141
+ );
2142
+ }
2143
+
2144
+ return false;
2240
2145
  }
2241
2146
 
2242
- const _encode = (options && options.encode) || encode;
2147
+ delete(header, matcher) {
2148
+ const self = this;
2149
+ let deleted = false;
2243
2150
 
2244
- const _options = utils$1.isFunction(options)
2245
- ? {
2246
- serialize: options,
2247
- }
2248
- : options;
2151
+ function deleteHeader(_header) {
2152
+ _header = normalizeHeader(_header);
2249
2153
 
2250
- const serializeFn = _options && _options.serialize;
2154
+ if (_header) {
2155
+ const key = utils$1.findKey(self, _header);
2251
2156
 
2252
- let serializedParams;
2157
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
2158
+ delete self[key];
2253
2159
 
2254
- if (serializeFn) {
2255
- serializedParams = serializeFn(params, _options);
2256
- } else {
2257
- serializedParams = utils$1.isURLSearchParams(params)
2258
- ? params.toString()
2259
- : new AxiosURLSearchParams(params, _options).toString(_encode);
2160
+ deleted = true;
2161
+ }
2162
+ }
2163
+ }
2164
+
2165
+ if (utils$1.isArray(header)) {
2166
+ header.forEach(deleteHeader);
2167
+ } else {
2168
+ deleteHeader(header);
2169
+ }
2170
+
2171
+ return deleted;
2260
2172
  }
2261
2173
 
2262
- if (serializedParams) {
2263
- const hashmarkIndex = url.indexOf('#');
2174
+ clear(matcher) {
2175
+ const keys = Object.keys(this);
2176
+ let i = keys.length;
2177
+ let deleted = false;
2264
2178
 
2265
- if (hashmarkIndex !== -1) {
2266
- url = url.slice(0, hashmarkIndex);
2179
+ while (i--) {
2180
+ const key = keys[i];
2181
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2182
+ delete this[key];
2183
+ deleted = true;
2184
+ }
2267
2185
  }
2268
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
2186
+
2187
+ return deleted;
2269
2188
  }
2270
2189
 
2271
- return url;
2272
- }
2190
+ normalize(format) {
2191
+ const self = this;
2192
+ const headers = {};
2273
2193
 
2274
- class InterceptorManager {
2275
- constructor() {
2276
- this.handlers = [];
2277
- }
2194
+ utils$1.forEach(this, (value, header) => {
2195
+ const key = utils$1.findKey(headers, header);
2278
2196
 
2279
- /**
2280
- * Add a new interceptor to the stack
2281
- *
2282
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
2283
- * @param {Function} rejected The function to handle `reject` for a `Promise`
2284
- * @param {Object} options The options for the interceptor, synchronous and runWhen
2285
- *
2286
- * @return {Number} An ID used to remove interceptor later
2287
- */
2288
- use(fulfilled, rejected, options) {
2289
- this.handlers.push({
2290
- fulfilled,
2291
- rejected,
2292
- synchronous: options ? options.synchronous : false,
2293
- runWhen: options ? options.runWhen : null,
2197
+ if (key) {
2198
+ self[key] = normalizeValue(value);
2199
+ delete self[header];
2200
+ return;
2201
+ }
2202
+
2203
+ const normalized = format ? formatHeader(header) : String(header).trim();
2204
+
2205
+ if (normalized !== header) {
2206
+ delete self[header];
2207
+ }
2208
+
2209
+ self[normalized] = normalizeValue(value);
2210
+
2211
+ headers[normalized] = true;
2294
2212
  });
2295
- return this.handlers.length - 1;
2296
- }
2297
2213
 
2298
- /**
2299
- * Remove an interceptor from the stack
2300
- *
2301
- * @param {Number} id The ID that was returned by `use`
2302
- *
2303
- * @returns {void}
2304
- */
2305
- eject(id) {
2306
- if (this.handlers[id]) {
2307
- this.handlers[id] = null;
2308
- }
2214
+ return this;
2309
2215
  }
2310
2216
 
2311
- /**
2312
- * Clear all interceptors from the stack
2313
- *
2314
- * @returns {void}
2315
- */
2316
- clear() {
2317
- if (this.handlers) {
2318
- this.handlers = [];
2319
- }
2217
+ concat(...targets) {
2218
+ return this.constructor.concat(this, ...targets);
2320
2219
  }
2321
2220
 
2322
- /**
2323
- * Iterate over all the registered interceptors
2324
- *
2325
- * This method is particularly useful for skipping over any
2326
- * interceptors that may have become `null` calling `eject`.
2327
- *
2328
- * @param {Function} fn The function to call for each interceptor
2329
- *
2330
- * @returns {void}
2331
- */
2332
- forEach(fn) {
2333
- utils$1.forEach(this.handlers, function forEachHandler(h) {
2334
- if (h !== null) {
2335
- fn(h);
2336
- }
2221
+ toJSON(asStrings) {
2222
+ const obj = Object.create(null);
2223
+
2224
+ utils$1.forEach(this, (value, header) => {
2225
+ value != null &&
2226
+ value !== false &&
2227
+ (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
2337
2228
  });
2229
+
2230
+ return obj;
2338
2231
  }
2339
- }
2340
2232
 
2341
- var transitionalDefaults = {
2342
- silentJSONParsing: true,
2343
- forcedJSONParsing: true,
2344
- clarifyTimeoutError: false,
2345
- legacyInterceptorReqResOrdering: true,
2346
- };
2233
+ [Symbol.iterator]() {
2234
+ return Object.entries(this.toJSON())[Symbol.iterator]();
2235
+ }
2347
2236
 
2348
- var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
2237
+ toString() {
2238
+ return Object.entries(this.toJSON())
2239
+ .map(([header, value]) => header + ': ' + value)
2240
+ .join('\n');
2241
+ }
2349
2242
 
2350
- var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
2243
+ getSetCookie() {
2244
+ return this.get('set-cookie') || [];
2245
+ }
2351
2246
 
2352
- var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
2247
+ get [Symbol.toStringTag]() {
2248
+ return 'AxiosHeaders';
2249
+ }
2353
2250
 
2354
- var platform$1 = {
2355
- isBrowser: true,
2356
- classes: {
2357
- URLSearchParams: URLSearchParams$1,
2358
- FormData: FormData$1,
2359
- Blob: Blob$1,
2360
- },
2361
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
2362
- };
2251
+ static from(thing) {
2252
+ return thing instanceof this ? thing : new this(thing);
2253
+ }
2363
2254
 
2364
- const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2255
+ static concat(first, ...targets) {
2256
+ const computed = new this(first);
2365
2257
 
2366
- const _navigator = (typeof navigator === 'object' && navigator) || undefined;
2258
+ targets.forEach((target) => computed.set(target));
2367
2259
 
2368
- /**
2369
- * Determine if we're running in a standard browser environment
2370
- *
2371
- * This allows axios to run in a web worker, and react-native.
2372
- * Both environments support XMLHttpRequest, but not fully standard globals.
2373
- *
2374
- * web workers:
2375
- * typeof window -> undefined
2376
- * typeof document -> undefined
2377
- *
2378
- * react-native:
2379
- * navigator.product -> 'ReactNative'
2380
- * nativescript
2381
- * navigator.product -> 'NativeScript' or 'NS'
2382
- *
2383
- * @returns {boolean}
2384
- */
2385
- const hasStandardBrowserEnv =
2386
- hasBrowserEnv &&
2387
- (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
2260
+ return computed;
2261
+ }
2388
2262
 
2389
- /**
2390
- * Determine if we're running in a standard browser webWorker environment
2391
- *
2392
- * Although the `isStandardBrowserEnv` method indicates that
2393
- * `allows axios to run in a web worker`, the WebWorker will still be
2394
- * filtered out due to its judgment standard
2395
- * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
2396
- * This leads to a problem when axios post `FormData` in webWorker
2397
- */
2398
- const hasStandardBrowserWebWorkerEnv = (() => {
2399
- return (
2400
- typeof WorkerGlobalScope !== 'undefined' &&
2401
- // eslint-disable-next-line no-undef
2402
- self instanceof WorkerGlobalScope &&
2403
- typeof self.importScripts === 'function'
2404
- );
2405
- })();
2263
+ static accessor(header) {
2264
+ const internals =
2265
+ (this[$internals] =
2266
+ this[$internals] =
2267
+ {
2268
+ accessors: {},
2269
+ });
2406
2270
 
2407
- const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
2271
+ const accessors = internals.accessors;
2272
+ const prototype = this.prototype;
2408
2273
 
2409
- var utils = /*#__PURE__*/Object.freeze({
2410
- __proto__: null,
2411
- hasBrowserEnv: hasBrowserEnv,
2412
- hasStandardBrowserEnv: hasStandardBrowserEnv,
2413
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2414
- navigator: _navigator,
2415
- origin: origin
2416
- });
2274
+ function defineAccessor(_header) {
2275
+ const lHeader = normalizeHeader(_header);
2417
2276
 
2418
- var platform = {
2419
- ...utils,
2420
- ...platform$1,
2421
- };
2422
-
2423
- function toURLEncodedForm(data, options) {
2424
- return toFormData(data, new platform.classes.URLSearchParams(), {
2425
- visitor: function (value, key, path, helpers) {
2426
- if (platform.isNode && utils$1.isBuffer(value)) {
2427
- this.append(key, value.toString('base64'));
2428
- return false;
2277
+ if (!accessors[lHeader]) {
2278
+ buildAccessors(prototype, _header);
2279
+ accessors[lHeader] = true;
2429
2280
  }
2281
+ }
2430
2282
 
2431
- return helpers.defaultVisitor.apply(this, arguments);
2432
- },
2433
- ...options,
2434
- });
2435
- }
2436
-
2437
- /**
2438
- * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
2439
- *
2440
- * @param {string} name - The name of the property to get.
2441
- *
2442
- * @returns An array of strings.
2443
- */
2444
- function parsePropPath(name) {
2445
- // foo[x][y][z]
2446
- // foo.x.y.z
2447
- // foo-x-y-z
2448
- // foo x y z
2449
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
2450
- return match[0] === '[]' ? '' : match[1] || match[0];
2451
- });
2452
- }
2283
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2453
2284
 
2454
- /**
2455
- * Convert an array to an object.
2456
- *
2457
- * @param {Array<any>} arr - The array to convert to an object.
2458
- *
2459
- * @returns An object with the same keys and values as the array.
2460
- */
2461
- function arrayToObject(arr) {
2462
- const obj = {};
2463
- const keys = Object.keys(arr);
2464
- let i;
2465
- const len = keys.length;
2466
- let key;
2467
- for (i = 0; i < len; i++) {
2468
- key = keys[i];
2469
- obj[key] = arr[key];
2285
+ return this;
2470
2286
  }
2471
- return obj;
2472
2287
  }
2473
2288
 
2474
- /**
2475
- * It takes a FormData object and returns a JavaScript object
2476
- *
2477
- * @param {string} formData The FormData object to convert to JSON.
2478
- *
2479
- * @returns {Object<string, any> | null} The converted object.
2480
- */
2481
- function formDataToJSON(formData) {
2482
- function buildPath(path, value, target, index) {
2483
- let name = path[index++];
2484
-
2485
- if (name === '__proto__') return true;
2486
-
2487
- const isNumericKey = Number.isFinite(+name);
2488
- const isLast = index >= path.length;
2489
- name = !name && utils$1.isArray(target) ? target.length : name;
2490
-
2491
- if (isLast) {
2492
- if (utils$1.hasOwnProp(target, name)) {
2493
- target[name] = [target[name], value];
2494
- } else {
2495
- target[name] = value;
2496
- }
2497
-
2498
- return !isNumericKey;
2499
- }
2500
-
2501
- if (!target[name] || !utils$1.isObject(target[name])) {
2502
- target[name] = [];
2503
- }
2504
-
2505
- const result = buildPath(path, value, target[name], index);
2506
-
2507
- if (result && utils$1.isArray(target[name])) {
2508
- target[name] = arrayToObject(target[name]);
2509
- }
2289
+ AxiosHeaders.accessor([
2290
+ 'Content-Type',
2291
+ 'Content-Length',
2292
+ 'Accept',
2293
+ 'Accept-Encoding',
2294
+ 'User-Agent',
2295
+ 'Authorization',
2296
+ ]);
2510
2297
 
2511
- return !isNumericKey;
2512
- }
2298
+ // reserved names hotfix
2299
+ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
2300
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2301
+ return {
2302
+ get: () => value,
2303
+ set(headerValue) {
2304
+ this[mapped] = headerValue;
2305
+ },
2306
+ };
2307
+ });
2513
2308
 
2514
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
2515
- const obj = {};
2309
+ utils$1.freezeMethods(AxiosHeaders);
2516
2310
 
2517
- utils$1.forEachEntry(formData, (name, value) => {
2518
- buildPath(parsePropPath(name), value, obj, 0);
2519
- });
2311
+ const REDACTED = '[REDACTED ****]';
2520
2312
 
2521
- return obj;
2313
+ function hasOwnOrPrototypeToJSON(source) {
2314
+ if (utils$1.hasOwnProp(source, 'toJSON')) {
2315
+ return true;
2522
2316
  }
2523
2317
 
2524
- return null;
2525
- }
2318
+ let prototype = Object.getPrototypeOf(source);
2526
2319
 
2527
- /**
2528
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2529
- * of the input
2530
- *
2531
- * @param {any} rawValue - The value to be stringified.
2532
- * @param {Function} parser - A function that parses a string into a JavaScript object.
2533
- * @param {Function} encoder - A function that takes a value and returns a string.
2534
- *
2535
- * @returns {string} A stringified version of the rawValue.
2536
- */
2537
- function stringifySafely(rawValue, parser, encoder) {
2538
- if (utils$1.isString(rawValue)) {
2539
- try {
2540
- (parser || JSON.parse)(rawValue);
2541
- return utils$1.trim(rawValue);
2542
- } catch (e) {
2543
- if (e.name !== 'SyntaxError') {
2544
- throw e;
2545
- }
2320
+ while (prototype && prototype !== Object.prototype) {
2321
+ if (utils$1.hasOwnProp(prototype, 'toJSON')) {
2322
+ return true;
2546
2323
  }
2324
+
2325
+ prototype = Object.getPrototypeOf(prototype);
2547
2326
  }
2548
2327
 
2549
- return (encoder || JSON.stringify)(rawValue);
2328
+ return false;
2550
2329
  }
2551
2330
 
2552
- const defaults = {
2553
- transitional: transitionalDefaults,
2554
-
2555
- adapter: ['xhr', 'http', 'fetch'],
2556
-
2557
- transformRequest: [
2558
- function transformRequest(data, headers) {
2559
- const contentType = headers.getContentType() || '';
2560
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
2561
- const isObjectPayload = utils$1.isObject(data);
2562
-
2563
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
2564
- data = new FormData(data);
2565
- }
2566
-
2567
- const isFormData = utils$1.isFormData(data);
2568
-
2569
- if (isFormData) {
2570
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2571
- }
2572
-
2573
- if (
2574
- utils$1.isArrayBuffer(data) ||
2575
- utils$1.isBuffer(data) ||
2576
- utils$1.isStream(data) ||
2577
- utils$1.isFile(data) ||
2578
- utils$1.isBlob(data) ||
2579
- utils$1.isReadableStream(data)
2580
- ) {
2581
- return data;
2582
- }
2583
- if (utils$1.isArrayBufferView(data)) {
2584
- return data.buffer;
2585
- }
2586
- if (utils$1.isURLSearchParams(data)) {
2587
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2588
- return data.toString();
2589
- }
2331
+ // Build a plain-object snapshot of `config` and replace the value of any key
2332
+ // (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
2333
+ // and AxiosHeaders, and short-circuits on circular references.
2334
+ function redactConfig(config, redactKeys) {
2335
+ const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
2336
+ const seen = [];
2590
2337
 
2591
- let isFileList;
2338
+ const visit = (source) => {
2339
+ if (source === null || typeof source !== 'object') return source;
2340
+ if (utils$1.isBuffer(source)) return source;
2341
+ if (seen.indexOf(source) !== -1) return undefined;
2592
2342
 
2593
- if (isObjectPayload) {
2594
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2595
- return toURLEncodedForm(data, this.formSerializer).toString();
2596
- }
2343
+ if (source instanceof AxiosHeaders) {
2344
+ source = source.toJSON();
2345
+ }
2597
2346
 
2598
- if (
2599
- (isFileList = utils$1.isFileList(data)) ||
2600
- contentType.indexOf('multipart/form-data') > -1
2601
- ) {
2602
- const _FormData = this.env && this.env.FormData;
2347
+ seen.push(source);
2603
2348
 
2604
- return toFormData(
2605
- isFileList ? { 'files[]': data } : data,
2606
- _FormData && new _FormData(),
2607
- this.formSerializer
2608
- );
2349
+ let result;
2350
+ if (utils$1.isArray(source)) {
2351
+ result = [];
2352
+ source.forEach((v, i) => {
2353
+ const reducedValue = visit(v);
2354
+ if (!utils$1.isUndefined(reducedValue)) {
2355
+ result[i] = reducedValue;
2609
2356
  }
2357
+ });
2358
+ } else {
2359
+ if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
2360
+ seen.pop();
2361
+ return source;
2610
2362
  }
2611
2363
 
2612
- if (isObjectPayload || hasJSONContentType) {
2613
- headers.setContentType('application/json', false);
2614
- return stringifySafely(data);
2364
+ result = Object.create(null);
2365
+ for (const [key, value] of Object.entries(source)) {
2366
+ const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
2367
+ if (!utils$1.isUndefined(reducedValue)) {
2368
+ result[key] = reducedValue;
2369
+ }
2615
2370
  }
2371
+ }
2616
2372
 
2617
- return data;
2618
- },
2619
- ],
2620
-
2621
- transformResponse: [
2622
- function transformResponse(data) {
2623
- const transitional = this.transitional || defaults.transitional;
2624
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2625
- const JSONRequested = this.responseType === 'json';
2373
+ seen.pop();
2374
+ return result;
2375
+ };
2626
2376
 
2627
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2628
- return data;
2629
- }
2377
+ return visit(config);
2378
+ }
2630
2379
 
2631
- if (
2632
- data &&
2633
- utils$1.isString(data) &&
2634
- ((forcedJSONParsing && !this.responseType) || JSONRequested)
2635
- ) {
2636
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
2637
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
2380
+ class AxiosError extends Error {
2381
+ static from(error, code, config, request, response, customProps) {
2382
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
2383
+ axiosError.cause = error;
2384
+ axiosError.name = error.name;
2638
2385
 
2639
- try {
2640
- return JSON.parse(data, this.parseReviver);
2641
- } catch (e) {
2642
- if (strictJSONParsing) {
2643
- if (e.name === 'SyntaxError') {
2644
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
2645
- }
2646
- throw e;
2647
- }
2648
- }
2649
- }
2386
+ // Preserve status from the original error if not already set from response
2387
+ if (error.status != null && axiosError.status == null) {
2388
+ axiosError.status = error.status;
2389
+ }
2650
2390
 
2651
- return data;
2652
- },
2653
- ],
2391
+ customProps && Object.assign(axiosError, customProps);
2392
+ return axiosError;
2393
+ }
2654
2394
 
2655
2395
  /**
2656
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
2657
- * timeout is not created.
2396
+ * Create an Error with the specified message, config, error code, request and response.
2397
+ *
2398
+ * @param {string} message The error message.
2399
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
2400
+ * @param {Object} [config] The config.
2401
+ * @param {Object} [request] The request.
2402
+ * @param {Object} [response] The response.
2403
+ *
2404
+ * @returns {Error} The created error.
2658
2405
  */
2659
- timeout: 0,
2406
+ constructor(message, code, config, request, response) {
2407
+ super(message);
2408
+
2409
+ // Make message enumerable to maintain backward compatibility
2410
+ // The native Error constructor sets message as non-enumerable,
2411
+ // but axios < v1.13.3 had it as enumerable
2412
+ Object.defineProperty(this, 'message', {
2413
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
2414
+ // this data descriptor into an accessor descriptor on the way in.
2415
+ __proto__: null,
2416
+ value: message,
2417
+ enumerable: true,
2418
+ writable: true,
2419
+ configurable: true,
2420
+ });
2660
2421
 
2661
- xsrfCookieName: 'XSRF-TOKEN',
2662
- xsrfHeaderName: 'X-XSRF-TOKEN',
2422
+ this.name = 'AxiosError';
2423
+ this.isAxiosError = true;
2424
+ code && (this.code = code);
2425
+ config && (this.config = config);
2426
+ request && (this.request = request);
2427
+ if (response) {
2428
+ this.response = response;
2429
+ this.status = response.status;
2430
+ }
2431
+ }
2663
2432
 
2664
- maxContentLength: -1,
2665
- maxBodyLength: -1,
2433
+ toJSON() {
2434
+ // Opt-in redaction: when the request config carries a `redact` array, the
2435
+ // value of any matching key (case-insensitive, at any depth) is replaced
2436
+ // with REDACTED in the serialized snapshot. Undefined or empty leaves the
2437
+ // existing serialization behavior unchanged.
2438
+ const config = this.config;
2439
+ const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
2440
+ const serializedConfig =
2441
+ utils$1.isArray(redactKeys) && redactKeys.length > 0
2442
+ ? redactConfig(config, redactKeys)
2443
+ : utils$1.toJSONObject(config);
2666
2444
 
2667
- env: {
2668
- FormData: platform.classes.FormData,
2669
- Blob: platform.classes.Blob,
2670
- },
2445
+ return {
2446
+ // Standard
2447
+ message: this.message,
2448
+ name: this.name,
2449
+ // Microsoft
2450
+ description: this.description,
2451
+ number: this.number,
2452
+ // Mozilla
2453
+ fileName: this.fileName,
2454
+ lineNumber: this.lineNumber,
2455
+ columnNumber: this.columnNumber,
2456
+ stack: this.stack,
2457
+ // Axios
2458
+ config: serializedConfig,
2459
+ code: this.code,
2460
+ status: this.status,
2461
+ };
2462
+ }
2463
+ }
2671
2464
 
2672
- validateStatus: function validateStatus(status) {
2673
- return status >= 200 && status < 300;
2674
- },
2465
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
2466
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
2467
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
2468
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
2469
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
2470
+ AxiosError.ECONNREFUSED = 'ECONNREFUSED';
2471
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
2472
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
2473
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
2474
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
2475
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
2476
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
2477
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
2478
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
2479
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
2675
2480
 
2676
- headers: {
2677
- common: {
2678
- Accept: 'application/json, text/plain, */*',
2679
- 'Content-Type': undefined,
2680
- },
2681
- },
2682
- };
2481
+ // eslint-disable-next-line strict
2482
+ var httpAdapter = null;
2683
2483
 
2684
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
2685
- defaults.headers[method] = {};
2686
- });
2484
+ /**
2485
+ * Determines if the given thing is a array or js object.
2486
+ *
2487
+ * @param {string} thing - The object or array to be visited.
2488
+ *
2489
+ * @returns {boolean}
2490
+ */
2491
+ function isVisitable(thing) {
2492
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
2493
+ }
2687
2494
 
2688
- // RawAxiosHeaders whose duplicates are ignored by node
2689
- // c.f. https://nodejs.org/api/http.html#http_message_headers
2690
- const ignoreDuplicateOf = utils$1.toObjectSet([
2691
- 'age',
2692
- 'authorization',
2693
- 'content-length',
2694
- 'content-type',
2695
- 'etag',
2696
- 'expires',
2697
- 'from',
2698
- 'host',
2699
- 'if-modified-since',
2700
- 'if-unmodified-since',
2701
- 'last-modified',
2702
- 'location',
2703
- 'max-forwards',
2704
- 'proxy-authorization',
2705
- 'referer',
2706
- 'retry-after',
2707
- 'user-agent',
2708
- ]);
2495
+ /**
2496
+ * It removes the brackets from the end of a string
2497
+ *
2498
+ * @param {string} key - The key of the parameter.
2499
+ *
2500
+ * @returns {string} the key without the brackets.
2501
+ */
2502
+ function removeBrackets(key) {
2503
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
2504
+ }
2709
2505
 
2710
2506
  /**
2711
- * Parse headers into an object
2507
+ * It takes a path, a key, and a boolean, and returns a string
2712
2508
  *
2713
- * ```
2714
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
2715
- * Content-Type: application/json
2716
- * Connection: keep-alive
2717
- * Transfer-Encoding: chunked
2718
- * ```
2509
+ * @param {string} path - The path to the current key.
2510
+ * @param {string} key - The key of the current object being iterated over.
2511
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
2719
2512
  *
2720
- * @param {String} rawHeaders Headers needing to be parsed
2513
+ * @returns {string} The path to the current key.
2514
+ */
2515
+ function renderKey(path, key, dots) {
2516
+ if (!path) return key;
2517
+ return path
2518
+ .concat(key)
2519
+ .map(function each(token, i) {
2520
+ // eslint-disable-next-line no-param-reassign
2521
+ token = removeBrackets(token);
2522
+ return !dots && i ? '[' + token + ']' : token;
2523
+ })
2524
+ .join(dots ? '.' : '');
2525
+ }
2526
+
2527
+ /**
2528
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
2721
2529
  *
2722
- * @returns {Object} Headers parsed into an object
2530
+ * @param {Array<any>} arr - The array to check
2531
+ *
2532
+ * @returns {boolean}
2723
2533
  */
2724
- var parseHeaders = (rawHeaders) => {
2725
- const parsed = {};
2726
- let key;
2727
- let val;
2728
- let i;
2534
+ function isFlatArray(arr) {
2535
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
2536
+ }
2729
2537
 
2730
- rawHeaders &&
2731
- rawHeaders.split('\n').forEach(function parser(line) {
2732
- i = line.indexOf(':');
2733
- key = line.substring(0, i).trim().toLowerCase();
2734
- val = line.substring(i + 1).trim();
2538
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
2539
+ return /^is[A-Z]/.test(prop);
2540
+ });
2735
2541
 
2736
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
2737
- return;
2738
- }
2542
+ /**
2543
+ * Convert a data object to FormData
2544
+ *
2545
+ * @param {Object} obj
2546
+ * @param {?Object} [formData]
2547
+ * @param {?Object} [options]
2548
+ * @param {Function} [options.visitor]
2549
+ * @param {Boolean} [options.metaTokens = true]
2550
+ * @param {Boolean} [options.dots = false]
2551
+ * @param {?Boolean} [options.indexes = false]
2552
+ *
2553
+ * @returns {Object}
2554
+ **/
2739
2555
 
2740
- if (key === 'set-cookie') {
2741
- if (parsed[key]) {
2742
- parsed[key].push(val);
2743
- } else {
2744
- parsed[key] = [val];
2745
- }
2746
- } else {
2747
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
2748
- }
2749
- });
2556
+ /**
2557
+ * It converts an object into a FormData object
2558
+ *
2559
+ * @param {Object<any, any>} obj - The object to convert to form data.
2560
+ * @param {string} formData - The FormData object to append to.
2561
+ * @param {Object<string, any>} options
2562
+ *
2563
+ * @returns
2564
+ */
2565
+ function toFormData(obj, formData, options) {
2566
+ if (!utils$1.isObject(obj)) {
2567
+ throw new TypeError('target must be an object');
2568
+ }
2750
2569
 
2751
- return parsed;
2752
- };
2570
+ // eslint-disable-next-line no-param-reassign
2571
+ formData = formData || new (FormData)();
2753
2572
 
2754
- const $internals = Symbol('internals');
2573
+ // eslint-disable-next-line no-param-reassign
2574
+ options = utils$1.toFlatObject(
2575
+ options,
2576
+ {
2577
+ metaTokens: true,
2578
+ dots: false,
2579
+ indexes: false,
2580
+ },
2581
+ false,
2582
+ function defined(option, source) {
2583
+ // eslint-disable-next-line no-eq-null,eqeqeq
2584
+ return !utils$1.isUndefined(source[option]);
2585
+ }
2586
+ );
2755
2587
 
2756
- const isValidHeaderValue = (value) => !/[\r\n]/.test(value);
2588
+ const metaTokens = options.metaTokens;
2589
+ // eslint-disable-next-line no-use-before-define
2590
+ const visitor = options.visitor || defaultVisitor;
2591
+ const dots = options.dots;
2592
+ const indexes = options.indexes;
2593
+ const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
2594
+ const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
2595
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
2757
2596
 
2758
- function assertValidHeaderValue(value, header) {
2759
- if (value === false || value == null) {
2760
- return;
2597
+ if (!utils$1.isFunction(visitor)) {
2598
+ throw new TypeError('visitor must be a function');
2761
2599
  }
2762
2600
 
2763
- if (utils$1.isArray(value)) {
2764
- value.forEach((v) => assertValidHeaderValue(v, header));
2765
- return;
2601
+ function convertValue(value) {
2602
+ if (value === null) return '';
2603
+
2604
+ if (utils$1.isDate(value)) {
2605
+ return value.toISOString();
2606
+ }
2607
+
2608
+ if (utils$1.isBoolean(value)) {
2609
+ return value.toString();
2610
+ }
2611
+
2612
+ if (!useBlob && utils$1.isBlob(value)) {
2613
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
2614
+ }
2615
+
2616
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
2617
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
2618
+ }
2619
+
2620
+ return value;
2621
+ }
2622
+
2623
+ /**
2624
+ * Default visitor.
2625
+ *
2626
+ * @param {*} value
2627
+ * @param {String|Number} key
2628
+ * @param {Array<String|Number>} path
2629
+ * @this {FormData}
2630
+ *
2631
+ * @returns {boolean} return true to visit the each prop of the value recursively
2632
+ */
2633
+ function defaultVisitor(value, key, path) {
2634
+ let arr = value;
2635
+
2636
+ if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
2637
+ formData.append(renderKey(path, key, dots), convertValue(value));
2638
+ return false;
2639
+ }
2640
+
2641
+ if (value && !path && typeof value === 'object') {
2642
+ if (utils$1.endsWith(key, '{}')) {
2643
+ // eslint-disable-next-line no-param-reassign
2644
+ key = metaTokens ? key : key.slice(0, -2);
2645
+ // eslint-disable-next-line no-param-reassign
2646
+ value = JSON.stringify(value);
2647
+ } else if (
2648
+ (utils$1.isArray(value) && isFlatArray(value)) ||
2649
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
2650
+ ) {
2651
+ // eslint-disable-next-line no-param-reassign
2652
+ key = removeBrackets(key);
2653
+
2654
+ arr.forEach(function each(el, index) {
2655
+ !(utils$1.isUndefined(el) || el === null) &&
2656
+ formData.append(
2657
+ // eslint-disable-next-line no-nested-ternary
2658
+ indexes === true
2659
+ ? renderKey([key], index, dots)
2660
+ : indexes === null
2661
+ ? key
2662
+ : key + '[]',
2663
+ convertValue(el)
2664
+ );
2665
+ });
2666
+ return false;
2667
+ }
2668
+ }
2669
+
2670
+ if (isVisitable(value)) {
2671
+ return true;
2672
+ }
2673
+
2674
+ formData.append(renderKey(path, key, dots), convertValue(value));
2675
+
2676
+ return false;
2677
+ }
2678
+
2679
+ const stack = [];
2680
+
2681
+ const exposedHelpers = Object.assign(predicates, {
2682
+ defaultVisitor,
2683
+ convertValue,
2684
+ isVisitable,
2685
+ });
2686
+
2687
+ function build(value, path, depth = 0) {
2688
+ if (utils$1.isUndefined(value)) return;
2689
+
2690
+ if (depth > maxDepth) {
2691
+ throw new AxiosError(
2692
+ 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
2693
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
2694
+ );
2695
+ }
2696
+
2697
+ if (stack.indexOf(value) !== -1) {
2698
+ throw Error('Circular reference detected in ' + path.join('.'));
2699
+ }
2700
+
2701
+ stack.push(value);
2702
+
2703
+ utils$1.forEach(value, function each(el, key) {
2704
+ const result =
2705
+ !(utils$1.isUndefined(el) || el === null) &&
2706
+ visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
2707
+
2708
+ if (result === true) {
2709
+ build(el, path ? path.concat(key) : [key], depth + 1);
2710
+ }
2711
+ });
2712
+
2713
+ stack.pop();
2766
2714
  }
2767
2715
 
2768
- if (!isValidHeaderValue(String(value))) {
2769
- throw new Error(`Invalid character in header content ["${header}"]`);
2716
+ if (!utils$1.isObject(obj)) {
2717
+ throw new TypeError('data must be an object');
2770
2718
  }
2719
+
2720
+ build(obj);
2721
+
2722
+ return formData;
2771
2723
  }
2772
2724
 
2773
- function normalizeHeader(header) {
2774
- return header && String(header).trim().toLowerCase();
2725
+ /**
2726
+ * It encodes a string by replacing all characters that are not in the unreserved set with
2727
+ * their percent-encoded equivalents
2728
+ *
2729
+ * @param {string} str - The string to encode.
2730
+ *
2731
+ * @returns {string} The encoded string.
2732
+ */
2733
+ function encode$1(str) {
2734
+ const charMap = {
2735
+ '!': '%21',
2736
+ "'": '%27',
2737
+ '(': '%28',
2738
+ ')': '%29',
2739
+ '~': '%7E',
2740
+ '%20': '+',
2741
+ };
2742
+ return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
2743
+ return charMap[match];
2744
+ });
2745
+ }
2746
+
2747
+ /**
2748
+ * It takes a params object and converts it to a FormData object
2749
+ *
2750
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
2751
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
2752
+ *
2753
+ * @returns {void}
2754
+ */
2755
+ function AxiosURLSearchParams(params, options) {
2756
+ this._pairs = [];
2757
+
2758
+ params && toFormData(params, this, options);
2759
+ }
2760
+
2761
+ const prototype = AxiosURLSearchParams.prototype;
2762
+
2763
+ prototype.append = function append(name, value) {
2764
+ this._pairs.push([name, value]);
2765
+ };
2766
+
2767
+ prototype.toString = function toString(encoder) {
2768
+ const _encode = encoder
2769
+ ? function (value) {
2770
+ return encoder.call(this, value, encode$1);
2771
+ }
2772
+ : encode$1;
2773
+
2774
+ return this._pairs
2775
+ .map(function each(pair) {
2776
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
2777
+ }, '')
2778
+ .join('&');
2779
+ };
2780
+
2781
+ /**
2782
+ * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
2783
+ * their plain counterparts (`:`, `$`, `,`, `+`).
2784
+ *
2785
+ * @param {string} val The value to be encoded.
2786
+ *
2787
+ * @returns {string} The encoded value.
2788
+ */
2789
+ function encode(val) {
2790
+ return encodeURIComponent(val)
2791
+ .replace(/%3A/gi, ':')
2792
+ .replace(/%24/g, '$')
2793
+ .replace(/%2C/gi, ',')
2794
+ .replace(/%20/g, '+');
2775
2795
  }
2776
2796
 
2777
- function stripTrailingCRLF(str) {
2778
- let end = str.length;
2797
+ /**
2798
+ * Build a URL by appending params to the end
2799
+ *
2800
+ * @param {string} url The base of the url (e.g., http://www.google.com)
2801
+ * @param {object} [params] The params to be appended
2802
+ * @param {?(object|Function)} options
2803
+ *
2804
+ * @returns {string} The formatted url
2805
+ */
2806
+ function buildURL(url, params, options) {
2807
+ if (!params) {
2808
+ return url;
2809
+ }
2779
2810
 
2780
- while (end > 0) {
2781
- const charCode = str.charCodeAt(end - 1);
2811
+ const _encode = (options && options.encode) || encode;
2782
2812
 
2783
- if (charCode !== 10 && charCode !== 13) {
2784
- break;
2785
- }
2813
+ const _options = utils$1.isFunction(options)
2814
+ ? {
2815
+ serialize: options,
2816
+ }
2817
+ : options;
2786
2818
 
2787
- end -= 1;
2788
- }
2819
+ const serializeFn = _options && _options.serialize;
2789
2820
 
2790
- return end === str.length ? str : str.slice(0, end);
2791
- }
2821
+ let serializedParams;
2792
2822
 
2793
- function normalizeValue(value) {
2794
- if (value === false || value == null) {
2795
- return value;
2823
+ if (serializeFn) {
2824
+ serializedParams = serializeFn(params, _options);
2825
+ } else {
2826
+ serializedParams = utils$1.isURLSearchParams(params)
2827
+ ? params.toString()
2828
+ : new AxiosURLSearchParams(params, _options).toString(_encode);
2796
2829
  }
2797
2830
 
2798
- return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value));
2799
- }
2800
-
2801
- function parseTokens(str) {
2802
- const tokens = Object.create(null);
2803
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
2804
- let match;
2831
+ if (serializedParams) {
2832
+ const hashmarkIndex = url.indexOf('#');
2805
2833
 
2806
- while ((match = tokensRE.exec(str))) {
2807
- tokens[match[1]] = match[2];
2834
+ if (hashmarkIndex !== -1) {
2835
+ url = url.slice(0, hashmarkIndex);
2836
+ }
2837
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
2808
2838
  }
2809
2839
 
2810
- return tokens;
2840
+ return url;
2811
2841
  }
2812
2842
 
2813
- const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2814
-
2815
- function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
2816
- if (utils$1.isFunction(filter)) {
2817
- return filter.call(this, value, header);
2843
+ class InterceptorManager {
2844
+ constructor() {
2845
+ this.handlers = [];
2818
2846
  }
2819
2847
 
2820
- if (isHeaderNameFilter) {
2821
- value = header;
2848
+ /**
2849
+ * Add a new interceptor to the stack
2850
+ *
2851
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
2852
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
2853
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
2854
+ *
2855
+ * @return {Number} An ID used to remove interceptor later
2856
+ */
2857
+ use(fulfilled, rejected, options) {
2858
+ this.handlers.push({
2859
+ fulfilled,
2860
+ rejected,
2861
+ synchronous: options ? options.synchronous : false,
2862
+ runWhen: options ? options.runWhen : null,
2863
+ });
2864
+ return this.handlers.length - 1;
2822
2865
  }
2823
2866
 
2824
- if (!utils$1.isString(value)) return;
2825
-
2826
- if (utils$1.isString(filter)) {
2827
- return value.indexOf(filter) !== -1;
2867
+ /**
2868
+ * Remove an interceptor from the stack
2869
+ *
2870
+ * @param {Number} id The ID that was returned by `use`
2871
+ *
2872
+ * @returns {void}
2873
+ */
2874
+ eject(id) {
2875
+ if (this.handlers[id]) {
2876
+ this.handlers[id] = null;
2877
+ }
2828
2878
  }
2829
2879
 
2830
- if (utils$1.isRegExp(filter)) {
2831
- return filter.test(value);
2880
+ /**
2881
+ * Clear all interceptors from the stack
2882
+ *
2883
+ * @returns {void}
2884
+ */
2885
+ clear() {
2886
+ if (this.handlers) {
2887
+ this.handlers = [];
2888
+ }
2832
2889
  }
2833
- }
2834
-
2835
- function formatHeader(header) {
2836
- return header
2837
- .trim()
2838
- .toLowerCase()
2839
- .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2840
- return char.toUpperCase() + str;
2841
- });
2842
- }
2843
-
2844
- function buildAccessors(obj, header) {
2845
- const accessorName = utils$1.toCamelCase(' ' + header);
2846
2890
 
2847
- ['get', 'set', 'has'].forEach((methodName) => {
2848
- Object.defineProperty(obj, methodName + accessorName, {
2849
- value: function (arg1, arg2, arg3) {
2850
- return this[methodName].call(this, header, arg1, arg2, arg3);
2851
- },
2852
- configurable: true,
2891
+ /**
2892
+ * Iterate over all the registered interceptors
2893
+ *
2894
+ * This method is particularly useful for skipping over any
2895
+ * interceptors that may have become `null` calling `eject`.
2896
+ *
2897
+ * @param {Function} fn The function to call for each interceptor
2898
+ *
2899
+ * @returns {void}
2900
+ */
2901
+ forEach(fn) {
2902
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
2903
+ if (h !== null) {
2904
+ fn(h);
2905
+ }
2853
2906
  });
2854
- });
2855
- }
2856
-
2857
- class AxiosHeaders {
2858
- constructor(headers) {
2859
- headers && this.set(headers);
2860
2907
  }
2908
+ }
2861
2909
 
2862
- set(header, valueOrRewrite, rewrite) {
2863
- const self = this;
2864
-
2865
- function setHeader(_value, _header, _rewrite) {
2866
- const lHeader = normalizeHeader(_header);
2867
-
2868
- if (!lHeader) {
2869
- throw new Error('header name must be a non-empty string');
2870
- }
2871
-
2872
- const key = utils$1.findKey(self, lHeader);
2873
-
2874
- if (
2875
- !key ||
2876
- self[key] === undefined ||
2877
- _rewrite === true ||
2878
- (_rewrite === undefined && self[key] !== false)
2879
- ) {
2880
- assertValidHeaderValue(_value, _header);
2881
- self[key || _header] = normalizeValue(_value);
2882
- }
2883
- }
2884
-
2885
- const setHeaders = (headers, _rewrite) =>
2886
- utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
2910
+ var transitionalDefaults = {
2911
+ silentJSONParsing: true,
2912
+ forcedJSONParsing: true,
2913
+ clarifyTimeoutError: false,
2914
+ legacyInterceptorReqResOrdering: true,
2915
+ };
2887
2916
 
2888
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
2889
- setHeaders(header, valueOrRewrite);
2890
- } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2891
- setHeaders(parseHeaders(header), valueOrRewrite);
2892
- } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
2893
- let obj = {},
2894
- dest,
2895
- key;
2896
- for (const entry of header) {
2897
- if (!utils$1.isArray(entry)) {
2898
- throw TypeError('Object iterator must return a key-value pair');
2899
- }
2917
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
2900
2918
 
2901
- obj[(key = entry[0])] = (dest = obj[key])
2902
- ? utils$1.isArray(dest)
2903
- ? [...dest, entry[1]]
2904
- : [dest, entry[1]]
2905
- : entry[1];
2906
- }
2919
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
2907
2920
 
2908
- setHeaders(obj, valueOrRewrite);
2909
- } else {
2910
- header != null && setHeader(valueOrRewrite, header, rewrite);
2911
- }
2921
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
2912
2922
 
2913
- return this;
2914
- }
2923
+ var platform$1 = {
2924
+ isBrowser: true,
2925
+ classes: {
2926
+ URLSearchParams: URLSearchParams$1,
2927
+ FormData: FormData$1,
2928
+ Blob: Blob$1,
2929
+ },
2930
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
2931
+ };
2915
2932
 
2916
- get(header, parser) {
2917
- header = normalizeHeader(header);
2933
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2918
2934
 
2919
- if (header) {
2920
- const key = utils$1.findKey(this, header);
2935
+ const _navigator = (typeof navigator === 'object' && navigator) || undefined;
2921
2936
 
2922
- if (key) {
2923
- const value = this[key];
2937
+ /**
2938
+ * Determine if we're running in a standard browser environment
2939
+ *
2940
+ * This allows axios to run in a web worker, and react-native.
2941
+ * Both environments support XMLHttpRequest, but not fully standard globals.
2942
+ *
2943
+ * web workers:
2944
+ * typeof window -> undefined
2945
+ * typeof document -> undefined
2946
+ *
2947
+ * react-native:
2948
+ * navigator.product -> 'ReactNative'
2949
+ * nativescript
2950
+ * navigator.product -> 'NativeScript' or 'NS'
2951
+ *
2952
+ * @returns {boolean}
2953
+ */
2954
+ const hasStandardBrowserEnv =
2955
+ hasBrowserEnv &&
2956
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
2924
2957
 
2925
- if (!parser) {
2926
- return value;
2927
- }
2958
+ /**
2959
+ * Determine if we're running in a standard browser webWorker environment
2960
+ *
2961
+ * Although the `isStandardBrowserEnv` method indicates that
2962
+ * `allows axios to run in a web worker`, the WebWorker will still be
2963
+ * filtered out due to its judgment standard
2964
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
2965
+ * This leads to a problem when axios post `FormData` in webWorker
2966
+ */
2967
+ const hasStandardBrowserWebWorkerEnv = (() => {
2968
+ return (
2969
+ typeof WorkerGlobalScope !== 'undefined' &&
2970
+ // eslint-disable-next-line no-undef
2971
+ self instanceof WorkerGlobalScope &&
2972
+ typeof self.importScripts === 'function'
2973
+ );
2974
+ })();
2928
2975
 
2929
- if (parser === true) {
2930
- return parseTokens(value);
2931
- }
2976
+ const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
2932
2977
 
2933
- if (utils$1.isFunction(parser)) {
2934
- return parser.call(this, value, key);
2935
- }
2978
+ var utils = /*#__PURE__*/Object.freeze({
2979
+ __proto__: null,
2980
+ hasBrowserEnv: hasBrowserEnv,
2981
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
2982
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2983
+ navigator: _navigator,
2984
+ origin: origin
2985
+ });
2936
2986
 
2937
- if (utils$1.isRegExp(parser)) {
2938
- return parser.exec(value);
2939
- }
2987
+ var platform = {
2988
+ ...utils,
2989
+ ...platform$1,
2990
+ };
2940
2991
 
2941
- throw new TypeError('parser must be boolean|regexp|function');
2992
+ function toURLEncodedForm(data, options) {
2993
+ return toFormData(data, new platform.classes.URLSearchParams(), {
2994
+ visitor: function (value, key, path, helpers) {
2995
+ if (platform.isNode && utils$1.isBuffer(value)) {
2996
+ this.append(key, value.toString('base64'));
2997
+ return false;
2942
2998
  }
2943
- }
2944
- }
2945
-
2946
- has(header, matcher) {
2947
- header = normalizeHeader(header);
2948
2999
 
2949
- if (header) {
2950
- const key = utils$1.findKey(this, header);
3000
+ return helpers.defaultVisitor.apply(this, arguments);
3001
+ },
3002
+ ...options,
3003
+ });
3004
+ }
2951
3005
 
2952
- return !!(
2953
- key &&
2954
- this[key] !== undefined &&
2955
- (!matcher || matchHeaderValue(this, this[key], key, matcher))
2956
- );
2957
- }
3006
+ /**
3007
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
3008
+ *
3009
+ * @param {string} name - The name of the property to get.
3010
+ *
3011
+ * @returns An array of strings.
3012
+ */
3013
+ function parsePropPath(name) {
3014
+ // foo[x][y][z]
3015
+ // foo.x.y.z
3016
+ // foo-x-y-z
3017
+ // foo x y z
3018
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
3019
+ return match[0] === '[]' ? '' : match[1] || match[0];
3020
+ });
3021
+ }
2958
3022
 
2959
- return false;
3023
+ /**
3024
+ * Convert an array to an object.
3025
+ *
3026
+ * @param {Array<any>} arr - The array to convert to an object.
3027
+ *
3028
+ * @returns An object with the same keys and values as the array.
3029
+ */
3030
+ function arrayToObject(arr) {
3031
+ const obj = {};
3032
+ const keys = Object.keys(arr);
3033
+ let i;
3034
+ const len = keys.length;
3035
+ let key;
3036
+ for (i = 0; i < len; i++) {
3037
+ key = keys[i];
3038
+ obj[key] = arr[key];
2960
3039
  }
3040
+ return obj;
3041
+ }
2961
3042
 
2962
- delete(header, matcher) {
2963
- const self = this;
2964
- let deleted = false;
2965
-
2966
- function deleteHeader(_header) {
2967
- _header = normalizeHeader(_header);
3043
+ /**
3044
+ * It takes a FormData object and returns a JavaScript object
3045
+ *
3046
+ * @param {string} formData The FormData object to convert to JSON.
3047
+ *
3048
+ * @returns {Object<string, any> | null} The converted object.
3049
+ */
3050
+ function formDataToJSON(formData) {
3051
+ function buildPath(path, value, target, index) {
3052
+ let name = path[index++];
2968
3053
 
2969
- if (_header) {
2970
- const key = utils$1.findKey(self, _header);
3054
+ if (name === '__proto__') return true;
2971
3055
 
2972
- if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
2973
- delete self[key];
3056
+ const isNumericKey = Number.isFinite(+name);
3057
+ const isLast = index >= path.length;
3058
+ name = !name && utils$1.isArray(target) ? target.length : name;
2974
3059
 
2975
- deleted = true;
2976
- }
3060
+ if (isLast) {
3061
+ if (utils$1.hasOwnProp(target, name)) {
3062
+ target[name] = utils$1.isArray(target[name])
3063
+ ? target[name].concat(value)
3064
+ : [target[name], value];
3065
+ } else {
3066
+ target[name] = value;
2977
3067
  }
2978
- }
2979
3068
 
2980
- if (utils$1.isArray(header)) {
2981
- header.forEach(deleteHeader);
2982
- } else {
2983
- deleteHeader(header);
3069
+ return !isNumericKey;
2984
3070
  }
2985
3071
 
2986
- return deleted;
2987
- }
3072
+ if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
3073
+ target[name] = [];
3074
+ }
2988
3075
 
2989
- clear(matcher) {
2990
- const keys = Object.keys(this);
2991
- let i = keys.length;
2992
- let deleted = false;
3076
+ const result = buildPath(path, value, target[name], index);
2993
3077
 
2994
- while (i--) {
2995
- const key = keys[i];
2996
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2997
- delete this[key];
2998
- deleted = true;
2999
- }
3078
+ if (result && utils$1.isArray(target[name])) {
3079
+ target[name] = arrayToObject(target[name]);
3000
3080
  }
3001
3081
 
3002
- return deleted;
3082
+ return !isNumericKey;
3003
3083
  }
3004
3084
 
3005
- normalize(format) {
3006
- const self = this;
3007
- const headers = {};
3085
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
3086
+ const obj = {};
3008
3087
 
3009
- utils$1.forEach(this, (value, header) => {
3010
- const key = utils$1.findKey(headers, header);
3088
+ utils$1.forEachEntry(formData, (name, value) => {
3089
+ buildPath(parsePropPath(name), value, obj, 0);
3090
+ });
3011
3091
 
3012
- if (key) {
3013
- self[key] = normalizeValue(value);
3014
- delete self[header];
3015
- return;
3016
- }
3092
+ return obj;
3093
+ }
3017
3094
 
3018
- const normalized = format ? formatHeader(header) : String(header).trim();
3095
+ return null;
3096
+ }
3019
3097
 
3020
- if (normalized !== header) {
3021
- delete self[header];
3022
- }
3098
+ const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
3023
3099
 
3024
- self[normalized] = normalizeValue(value);
3100
+ /**
3101
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
3102
+ * of the input
3103
+ *
3104
+ * @param {any} rawValue - The value to be stringified.
3105
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
3106
+ * @param {Function} encoder - A function that takes a value and returns a string.
3107
+ *
3108
+ * @returns {string} A stringified version of the rawValue.
3109
+ */
3110
+ function stringifySafely(rawValue, parser, encoder) {
3111
+ if (utils$1.isString(rawValue)) {
3112
+ try {
3113
+ (parser || JSON.parse)(rawValue);
3114
+ return utils$1.trim(rawValue);
3115
+ } catch (e) {
3116
+ if (e.name !== 'SyntaxError') {
3117
+ throw e;
3118
+ }
3119
+ }
3120
+ }
3025
3121
 
3026
- headers[normalized] = true;
3027
- });
3122
+ return (encoder || JSON.stringify)(rawValue);
3123
+ }
3028
3124
 
3029
- return this;
3030
- }
3125
+ const defaults = {
3126
+ transitional: transitionalDefaults,
3031
3127
 
3032
- concat(...targets) {
3033
- return this.constructor.concat(this, ...targets);
3034
- }
3128
+ adapter: ['xhr', 'http', 'fetch'],
3035
3129
 
3036
- toJSON(asStrings) {
3037
- const obj = Object.create(null);
3130
+ transformRequest: [
3131
+ function transformRequest(data, headers) {
3132
+ const contentType = headers.getContentType() || '';
3133
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
3134
+ const isObjectPayload = utils$1.isObject(data);
3038
3135
 
3039
- utils$1.forEach(this, (value, header) => {
3040
- value != null &&
3041
- value !== false &&
3042
- (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
3043
- });
3136
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
3137
+ data = new FormData(data);
3138
+ }
3044
3139
 
3045
- return obj;
3046
- }
3140
+ const isFormData = utils$1.isFormData(data);
3047
3141
 
3048
- [Symbol.iterator]() {
3049
- return Object.entries(this.toJSON())[Symbol.iterator]();
3050
- }
3142
+ if (isFormData) {
3143
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
3144
+ }
3051
3145
 
3052
- toString() {
3053
- return Object.entries(this.toJSON())
3054
- .map(([header, value]) => header + ': ' + value)
3055
- .join('\n');
3056
- }
3146
+ if (
3147
+ utils$1.isArrayBuffer(data) ||
3148
+ utils$1.isBuffer(data) ||
3149
+ utils$1.isStream(data) ||
3150
+ utils$1.isFile(data) ||
3151
+ utils$1.isBlob(data) ||
3152
+ utils$1.isReadableStream(data)
3153
+ ) {
3154
+ return data;
3155
+ }
3156
+ if (utils$1.isArrayBufferView(data)) {
3157
+ return data.buffer;
3158
+ }
3159
+ if (utils$1.isURLSearchParams(data)) {
3160
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
3161
+ return data.toString();
3162
+ }
3057
3163
 
3058
- getSetCookie() {
3059
- return this.get('set-cookie') || [];
3060
- }
3164
+ let isFileList;
3061
3165
 
3062
- get [Symbol.toStringTag]() {
3063
- return 'AxiosHeaders';
3064
- }
3166
+ if (isObjectPayload) {
3167
+ const formSerializer = own(this, 'formSerializer');
3168
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
3169
+ return toURLEncodedForm(data, formSerializer).toString();
3170
+ }
3065
3171
 
3066
- static from(thing) {
3067
- return thing instanceof this ? thing : new this(thing);
3068
- }
3172
+ if (
3173
+ (isFileList = utils$1.isFileList(data)) ||
3174
+ contentType.indexOf('multipart/form-data') > -1
3175
+ ) {
3176
+ const env = own(this, 'env');
3177
+ const _FormData = env && env.FormData;
3069
3178
 
3070
- static concat(first, ...targets) {
3071
- const computed = new this(first);
3179
+ return toFormData(
3180
+ isFileList ? { 'files[]': data } : data,
3181
+ _FormData && new _FormData(),
3182
+ formSerializer
3183
+ );
3184
+ }
3185
+ }
3072
3186
 
3073
- targets.forEach((target) => computed.set(target));
3187
+ if (isObjectPayload || hasJSONContentType) {
3188
+ headers.setContentType('application/json', false);
3189
+ return stringifySafely(data);
3190
+ }
3074
3191
 
3075
- return computed;
3076
- }
3192
+ return data;
3193
+ },
3194
+ ],
3077
3195
 
3078
- static accessor(header) {
3079
- const internals =
3080
- (this[$internals] =
3081
- this[$internals] =
3082
- {
3083
- accessors: {},
3084
- });
3196
+ transformResponse: [
3197
+ function transformResponse(data) {
3198
+ const transitional = own(this, 'transitional') || defaults.transitional;
3199
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
3200
+ const responseType = own(this, 'responseType');
3201
+ const JSONRequested = responseType === 'json';
3085
3202
 
3086
- const accessors = internals.accessors;
3087
- const prototype = this.prototype;
3203
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
3204
+ return data;
3205
+ }
3088
3206
 
3089
- function defineAccessor(_header) {
3090
- const lHeader = normalizeHeader(_header);
3207
+ if (
3208
+ data &&
3209
+ utils$1.isString(data) &&
3210
+ ((forcedJSONParsing && !responseType) || JSONRequested)
3211
+ ) {
3212
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
3213
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
3091
3214
 
3092
- if (!accessors[lHeader]) {
3093
- buildAccessors(prototype, _header);
3094
- accessors[lHeader] = true;
3215
+ try {
3216
+ return JSON.parse(data, own(this, 'parseReviver'));
3217
+ } catch (e) {
3218
+ if (strictJSONParsing) {
3219
+ if (e.name === 'SyntaxError') {
3220
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
3221
+ }
3222
+ throw e;
3223
+ }
3224
+ }
3095
3225
  }
3096
- }
3097
3226
 
3098
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
3227
+ return data;
3228
+ },
3229
+ ],
3099
3230
 
3100
- return this;
3101
- }
3102
- }
3231
+ /**
3232
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
3233
+ * timeout is not created.
3234
+ */
3235
+ timeout: 0,
3103
3236
 
3104
- AxiosHeaders.accessor([
3105
- 'Content-Type',
3106
- 'Content-Length',
3107
- 'Accept',
3108
- 'Accept-Encoding',
3109
- 'User-Agent',
3110
- 'Authorization',
3111
- ]);
3237
+ xsrfCookieName: 'XSRF-TOKEN',
3238
+ xsrfHeaderName: 'X-XSRF-TOKEN',
3112
3239
 
3113
- // reserved names hotfix
3114
- utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
3115
- let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
3116
- return {
3117
- get: () => value,
3118
- set(headerValue) {
3119
- this[mapped] = headerValue;
3240
+ maxContentLength: -1,
3241
+ maxBodyLength: -1,
3242
+
3243
+ env: {
3244
+ FormData: platform.classes.FormData,
3245
+ Blob: platform.classes.Blob,
3246
+ },
3247
+
3248
+ validateStatus: function validateStatus(status) {
3249
+ return status >= 200 && status < 300;
3250
+ },
3251
+
3252
+ headers: {
3253
+ common: {
3254
+ Accept: 'application/json, text/plain, */*',
3255
+ 'Content-Type': undefined,
3120
3256
  },
3121
- };
3122
- });
3257
+ },
3258
+ };
3123
3259
 
3124
- utils$1.freezeMethods(AxiosHeaders);
3260
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
3261
+ defaults.headers[method] = {};
3262
+ });
3125
3263
 
3126
3264
  /**
3127
3265
  * Transform the data for a request or a response
@@ -3181,22 +3319,18 @@ function settle(resolve, reject, response) {
3181
3319
  if (!response.status || !validateStatus || validateStatus(response.status)) {
3182
3320
  resolve(response);
3183
3321
  } else {
3184
- reject(
3185
- new AxiosError(
3186
- 'Request failed with status code ' + response.status,
3187
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][
3188
- Math.floor(response.status / 100) - 4
3189
- ],
3190
- response.config,
3191
- response.request,
3192
- response
3193
- )
3194
- );
3322
+ reject(new AxiosError(
3323
+ 'Request failed with status code ' + response.status,
3324
+ response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE,
3325
+ response.config,
3326
+ response.request,
3327
+ response
3328
+ ));
3195
3329
  }
3196
3330
  }
3197
3331
 
3198
3332
  function parseProtocol(url) {
3199
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
3333
+ const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
3200
3334
  return (match && match[1]) || '';
3201
3335
  }
3202
3336
 
@@ -3300,13 +3434,16 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
3300
3434
  const _speedometer = speedometer(50, 250);
3301
3435
 
3302
3436
  return throttle((e) => {
3303
- const loaded = e.loaded;
3437
+ if (!e || typeof e.loaded !== 'number') {
3438
+ return;
3439
+ }
3440
+ const rawLoaded = e.loaded;
3304
3441
  const total = e.lengthComputable ? e.total : undefined;
3305
- const progressBytes = loaded - bytesNotified;
3442
+ const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
3443
+ const progressBytes = Math.max(0, loaded - bytesNotified);
3306
3444
  const rate = _speedometer(progressBytes);
3307
- const inRange = loaded <= total;
3308
3445
 
3309
- bytesNotified = loaded;
3446
+ bytesNotified = Math.max(bytesNotified, loaded);
3310
3447
 
3311
3448
  const data = {
3312
3449
  loaded,
@@ -3314,7 +3451,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
3314
3451
  progress: total ? loaded / total : undefined,
3315
3452
  bytes: progressBytes,
3316
3453
  rate: rate ? rate : undefined,
3317
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
3454
+ estimated: rate && total ? (total - loaded) / rate : undefined,
3318
3455
  event: e,
3319
3456
  lengthComputable: total != null,
3320
3457
  [isDownloadStream ? 'download' : 'upload']: true,
@@ -3387,8 +3524,20 @@ var cookies = platform.hasStandardBrowserEnv
3387
3524
 
3388
3525
  read(name) {
3389
3526
  if (typeof document === 'undefined') return null;
3390
- const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
3391
- return match ? decodeURIComponent(match[1]) : null;
3527
+ // Match name=value by splitting on the semicolon separator instead of building a
3528
+ // RegExp from `name` interpolating an unescaped string into a RegExp would let
3529
+ // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
3530
+ // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
3531
+ // "; ", so ignore optional whitespace before each cookie name.
3532
+ const cookies = document.cookie.split(';');
3533
+ for (let i = 0; i < cookies.length; i++) {
3534
+ const cookie = cookies[i].replace(/^\s+/, '');
3535
+ const eq = cookie.indexOf('=');
3536
+ if (eq !== -1 && cookie.slice(0, eq) === name) {
3537
+ return decodeURIComponent(cookie.slice(eq + 1));
3538
+ }
3539
+ }
3540
+ return null;
3392
3541
  },
3393
3542
 
3394
3543
  remove(name) {
@@ -3448,7 +3597,7 @@ function combineURLs(baseURL, relativeURL) {
3448
3597
  */
3449
3598
  function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
3450
3599
  let isRelativeUrl = !isAbsoluteURL(requestedURL);
3451
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
3600
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
3452
3601
  return combineURLs(baseURL, requestedURL);
3453
3602
  }
3454
3603
  return requestedURL;
@@ -3468,7 +3617,21 @@ const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing }
3468
3617
  function mergeConfig(config1, config2) {
3469
3618
  // eslint-disable-next-line no-param-reassign
3470
3619
  config2 = config2 || {};
3471
- const config = {};
3620
+
3621
+ // Use a null-prototype object so that downstream reads such as `config.auth`
3622
+ // or `config.baseURL` cannot inherit polluted values from Object.prototype.
3623
+ // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
3624
+ // ergonomics for user code that relies on it.
3625
+ const config = Object.create(null);
3626
+ Object.defineProperty(config, 'hasOwnProperty', {
3627
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
3628
+ // this data descriptor into an accessor descriptor on the way in.
3629
+ __proto__: null,
3630
+ value: Object.prototype.hasOwnProperty,
3631
+ enumerable: false,
3632
+ writable: true,
3633
+ configurable: true,
3634
+ });
3472
3635
 
3473
3636
  function getMergedValue(target, source, prop, caseless) {
3474
3637
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
@@ -3507,9 +3670,9 @@ function mergeConfig(config1, config2) {
3507
3670
 
3508
3671
  // eslint-disable-next-line consistent-return
3509
3672
  function mergeDirectKeys(a, b, prop) {
3510
- if (prop in config2) {
3673
+ if (utils$1.hasOwnProp(config2, prop)) {
3511
3674
  return getMergedValue(a, b);
3512
- } else if (prop in config1) {
3675
+ } else if (utils$1.hasOwnProp(config1, prop)) {
3513
3676
  return getMergedValue(undefined, a);
3514
3677
  }
3515
3678
  }
@@ -3541,6 +3704,7 @@ function mergeConfig(config1, config2) {
3541
3704
  httpsAgent: defaultToConfig2,
3542
3705
  cancelToken: defaultToConfig2,
3543
3706
  socketPath: defaultToConfig2,
3707
+ allowedSocketPaths: defaultToConfig2,
3544
3708
  responseEncoding: defaultToConfig2,
3545
3709
  validateStatus: mergeDirectKeys,
3546
3710
  headers: (a, b, prop) =>
@@ -3550,22 +3714,64 @@ function mergeConfig(config1, config2) {
3550
3714
  utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
3551
3715
  if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
3552
3716
  const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
3553
- const configValue = merge(config1[prop], config2[prop], prop);
3717
+ const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
3718
+ const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
3719
+ const configValue = merge(a, b, prop);
3554
3720
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3555
3721
  });
3556
3722
 
3557
3723
  return config;
3558
3724
  }
3559
3725
 
3726
+ const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
3727
+
3728
+ function setFormDataHeaders(headers, formHeaders, policy) {
3729
+ if (policy !== 'content-only') {
3730
+ headers.set(formHeaders);
3731
+ return;
3732
+ }
3733
+
3734
+ Object.entries(formHeaders).forEach(([key, val]) => {
3735
+ if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
3736
+ headers.set(key, val);
3737
+ }
3738
+ });
3739
+ }
3740
+
3741
+ /**
3742
+ * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
3743
+ * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
3744
+ *
3745
+ * @param {string} str The string to encode
3746
+ *
3747
+ * @returns {string} UTF-8 bytes as a Latin-1 string
3748
+ */
3749
+ const encodeUTF8 = (str) =>
3750
+ encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
3751
+ String.fromCharCode(parseInt(hex, 16))
3752
+ );
3753
+
3560
3754
  var resolveConfig = (config) => {
3561
3755
  const newConfig = mergeConfig({}, config);
3562
3756
 
3563
- let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3757
+ // Read only own properties to prevent prototype pollution gadgets
3758
+ // (e.g. Object.prototype.baseURL = 'https://evil.com').
3759
+ const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
3760
+
3761
+ const data = own('data');
3762
+ let withXSRFToken = own('withXSRFToken');
3763
+ const xsrfHeaderName = own('xsrfHeaderName');
3764
+ const xsrfCookieName = own('xsrfCookieName');
3765
+ let headers = own('headers');
3766
+ const auth = own('auth');
3767
+ const baseURL = own('baseURL');
3768
+ const allowAbsoluteUrls = own('allowAbsoluteUrls');
3769
+ const url = own('url');
3564
3770
 
3565
3771
  newConfig.headers = headers = AxiosHeaders.from(headers);
3566
3772
 
3567
3773
  newConfig.url = buildURL(
3568
- buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls),
3774
+ buildFullPath(baseURL, url, allowAbsoluteUrls),
3569
3775
  config.params,
3570
3776
  config.paramsSerializer
3571
3777
  );
@@ -3575,11 +3781,7 @@ var resolveConfig = (config) => {
3575
3781
  headers.set(
3576
3782
  'Authorization',
3577
3783
  'Basic ' +
3578
- btoa(
3579
- (auth.username || '') +
3580
- ':' +
3581
- (auth.password ? unescape(encodeURIComponent(auth.password)) : '')
3582
- )
3784
+ btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
3583
3785
  );
3584
3786
  }
3585
3787
 
@@ -3588,14 +3790,7 @@ var resolveConfig = (config) => {
3588
3790
  headers.setContentType(undefined); // browser handles it
3589
3791
  } else if (utils$1.isFunction(data.getHeaders)) {
3590
3792
  // Node.js FormData (like form-data package)
3591
- const formHeaders = data.getHeaders();
3592
- // Only set safe headers to avoid overwriting security headers
3593
- const allowedHeaders = ['content-type', 'content-length'];
3594
- Object.entries(formHeaders).forEach(([key, val]) => {
3595
- if (allowedHeaders.includes(key.toLowerCase())) {
3596
- headers.set(key, val);
3597
- }
3598
- });
3793
+ setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
3599
3794
  }
3600
3795
  }
3601
3796
 
@@ -3604,10 +3799,17 @@ var resolveConfig = (config) => {
3604
3799
  // Specifically not if we're in a web worker, or react-native.
3605
3800
 
3606
3801
  if (platform.hasStandardBrowserEnv) {
3607
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
3802
+ if (utils$1.isFunction(withXSRFToken)) {
3803
+ withXSRFToken = withXSRFToken(newConfig);
3804
+ }
3608
3805
 
3609
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
3610
- // Add xsrf header
3806
+ // Strict boolean check prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
3807
+ // and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
3808
+ // the XSRF token cross-origin.
3809
+ const shouldSendXSRF =
3810
+ withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
3811
+
3812
+ if (shouldSendXSRF) {
3611
3813
  const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
3612
3814
 
3613
3815
  if (xsrfValue) {
@@ -3701,7 +3903,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3701
3903
  // will return status as 0 even though it's a successful request
3702
3904
  if (
3703
3905
  request.status === 0 &&
3704
- !(request.responseURL && request.responseURL.indexOf('file:') === 0)
3906
+ !(request.responseURL && request.responseURL.startsWith('file:'))
3705
3907
  ) {
3706
3908
  return;
3707
3909
  }
@@ -3718,6 +3920,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3718
3920
  }
3719
3921
 
3720
3922
  reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
3923
+ done();
3721
3924
 
3722
3925
  // Clean up request
3723
3926
  request = null;
@@ -3733,6 +3936,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3733
3936
  // attach the underlying event for consumers who want details
3734
3937
  err.event = event || null;
3735
3938
  reject(err);
3939
+ done();
3736
3940
  request = null;
3737
3941
  };
3738
3942
 
@@ -3753,6 +3957,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3753
3957
  request
3754
3958
  )
3755
3959
  );
3960
+ done();
3756
3961
 
3757
3962
  // Clean up request
3758
3963
  request = null;
@@ -3763,7 +3968,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3763
3968
 
3764
3969
  // Add headers to the request
3765
3970
  if ('setRequestHeader' in request) {
3766
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
3971
+ utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
3767
3972
  request.setRequestHeader(key, val);
3768
3973
  });
3769
3974
  }
@@ -3802,6 +4007,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3802
4007
  }
3803
4008
  reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
3804
4009
  request.abort();
4010
+ done();
3805
4011
  request = null;
3806
4012
  };
3807
4013
 
@@ -3815,7 +4021,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3815
4021
 
3816
4022
  const protocol = parseProtocol(_config.url);
3817
4023
 
3818
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
4024
+ if (protocol && !platform.protocols.includes(protocol)) {
3819
4025
  reject(
3820
4026
  new AxiosError(
3821
4027
  'Unsupported protocol ' + protocol + ':',
@@ -3832,54 +4038,55 @@ var xhrAdapter = isXHRAdapterSupported &&
3832
4038
  };
3833
4039
 
3834
4040
  const composeSignals = (signals, timeout) => {
3835
- const { length } = (signals = signals ? signals.filter(Boolean) : []);
3836
-
3837
- if (timeout || length) {
3838
- let controller = new AbortController();
3839
-
3840
- let aborted;
3841
-
3842
- const onabort = function (reason) {
3843
- if (!aborted) {
3844
- aborted = true;
3845
- unsubscribe();
3846
- const err = reason instanceof Error ? reason : this.reason;
3847
- controller.abort(
3848
- err instanceof AxiosError
3849
- ? err
3850
- : new CanceledError(err instanceof Error ? err.message : err)
3851
- );
3852
- }
3853
- };
4041
+ signals = signals ? signals.filter(Boolean) : [];
3854
4042
 
3855
- let timer =
3856
- timeout &&
3857
- setTimeout(() => {
3858
- timer = null;
3859
- onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
3860
- }, timeout);
3861
-
3862
- const unsubscribe = () => {
3863
- if (signals) {
3864
- timer && clearTimeout(timer);
3865
- timer = null;
3866
- signals.forEach((signal) => {
3867
- signal.unsubscribe
3868
- ? signal.unsubscribe(onabort)
3869
- : signal.removeEventListener('abort', onabort);
3870
- });
3871
- signals = null;
3872
- }
3873
- };
4043
+ if (!timeout && !signals.length) {
4044
+ return;
4045
+ }
4046
+
4047
+ const controller = new AbortController();
4048
+
4049
+ let aborted = false;
4050
+
4051
+ const onabort = function (reason) {
4052
+ if (!aborted) {
4053
+ aborted = true;
4054
+ unsubscribe();
4055
+ const err = reason instanceof Error ? reason : this.reason;
4056
+ controller.abort(
4057
+ err instanceof AxiosError
4058
+ ? err
4059
+ : new CanceledError(err instanceof Error ? err.message : err)
4060
+ );
4061
+ }
4062
+ };
4063
+
4064
+ let timer =
4065
+ timeout &&
4066
+ setTimeout(() => {
4067
+ timer = null;
4068
+ onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
4069
+ }, timeout);
4070
+
4071
+ const unsubscribe = () => {
4072
+ if (!signals) { return; }
4073
+ timer && clearTimeout(timer);
4074
+ timer = null;
4075
+ signals.forEach((signal) => {
4076
+ signal.unsubscribe
4077
+ ? signal.unsubscribe(onabort)
4078
+ : signal.removeEventListener('abort', onabort);
4079
+ });
4080
+ signals = null;
4081
+ };
3874
4082
 
3875
- signals.forEach((signal) => signal.addEventListener('abort', onabort));
4083
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
3876
4084
 
3877
- const { signal } = controller;
4085
+ const { signal } = controller;
3878
4086
 
3879
- signal.unsubscribe = () => utils$1.asap(unsubscribe);
4087
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
3880
4088
 
3881
- return signal;
3882
- }
4089
+ return signal;
3883
4090
  };
3884
4091
 
3885
4092
  const streamChunk = function* (chunk, chunkSize) {
@@ -3972,16 +4179,112 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3972
4179
  );
3973
4180
  };
3974
4181
 
3975
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
4182
+ /**
4183
+ * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
4184
+ * - For base64: compute exact decoded size using length and padding;
4185
+ * handle %XX at the character-count level (no string allocation).
4186
+ * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
4187
+ *
4188
+ * @param {string} url
4189
+ * @returns {number}
4190
+ */
4191
+ function estimateDataURLDecodedBytes(url) {
4192
+ if (!url || typeof url !== 'string') return 0;
4193
+ if (!url.startsWith('data:')) return 0;
4194
+
4195
+ const comma = url.indexOf(',');
4196
+ if (comma < 0) return 0;
4197
+
4198
+ const meta = url.slice(5, comma);
4199
+ const body = url.slice(comma + 1);
4200
+ const isBase64 = /;base64/i.test(meta);
4201
+
4202
+ if (isBase64) {
4203
+ let effectiveLen = body.length;
4204
+ const len = body.length; // cache length
4205
+
4206
+ for (let i = 0; i < len; i++) {
4207
+ if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
4208
+ const a = body.charCodeAt(i + 1);
4209
+ const b = body.charCodeAt(i + 2);
4210
+ const isHex =
4211
+ ((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
4212
+ ((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
4213
+
4214
+ if (isHex) {
4215
+ effectiveLen -= 2;
4216
+ i += 2;
4217
+ }
4218
+ }
4219
+ }
3976
4220
 
3977
- const { isFunction } = utils$1;
4221
+ let pad = 0;
4222
+ let idx = len - 1;
4223
+
4224
+ const tailIsPct3D = (j) =>
4225
+ j >= 2 &&
4226
+ body.charCodeAt(j - 2) === 37 && // '%'
4227
+ body.charCodeAt(j - 1) === 51 && // '3'
4228
+ (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
4229
+
4230
+ if (idx >= 0) {
4231
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
4232
+ pad++;
4233
+ idx--;
4234
+ } else if (tailIsPct3D(idx)) {
4235
+ pad++;
4236
+ idx -= 3;
4237
+ }
4238
+ }
4239
+
4240
+ if (pad === 1 && idx >= 0) {
4241
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
4242
+ pad++;
4243
+ } else if (tailIsPct3D(idx)) {
4244
+ pad++;
4245
+ }
4246
+ }
4247
+
4248
+ const groups = Math.floor(effectiveLen / 4);
4249
+ const bytes = groups * 3 - (pad || 0);
4250
+ return bytes > 0 ? bytes : 0;
4251
+ }
4252
+
4253
+ if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
4254
+ return Buffer.byteLength(body, 'utf8');
4255
+ }
4256
+
4257
+ // Compute UTF-8 byte length directly from UTF-16 code units without allocating
4258
+ // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
4259
+ // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
4260
+ // but 3 UTF-8 bytes).
4261
+ let bytes = 0;
4262
+ for (let i = 0, len = body.length; i < len; i++) {
4263
+ const c = body.charCodeAt(i);
4264
+ if (c < 0x80) {
4265
+ bytes += 1;
4266
+ } else if (c < 0x800) {
4267
+ bytes += 2;
4268
+ } else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
4269
+ const next = body.charCodeAt(i + 1);
4270
+ if (next >= 0xdc00 && next <= 0xdfff) {
4271
+ bytes += 4;
4272
+ i++;
4273
+ } else {
4274
+ bytes += 3;
4275
+ }
4276
+ } else {
4277
+ bytes += 3;
4278
+ }
4279
+ }
4280
+ return bytes;
4281
+ }
4282
+
4283
+ const VERSION = "1.16.1";
3978
4284
 
3979
- const globalFetchAPI = (({ Request, Response }) => ({
3980
- Request,
3981
- Response,
3982
- }))(utils$1.global);
4285
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
3983
4286
 
3984
- const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
4287
+ const { isFunction } = utils$1;
3985
4288
 
3986
4289
  const test = (fn, ...args) => {
3987
4290
  try {
@@ -3992,11 +4295,20 @@ const test = (fn, ...args) => {
3992
4295
  };
3993
4296
 
3994
4297
  const factory = (env) => {
4298
+ const globalObject =
4299
+ utils$1.global !== undefined && utils$1.global !== null
4300
+ ? utils$1.global
4301
+ : globalThis;
4302
+ const { ReadableStream, TextEncoder } = globalObject;
4303
+
3995
4304
  env = utils$1.merge.call(
3996
4305
  {
3997
4306
  skipUndefined: true,
3998
4307
  },
3999
- globalFetchAPI,
4308
+ {
4309
+ Request: globalObject.Request,
4310
+ Response: globalObject.Response,
4311
+ },
4000
4312
  env
4001
4313
  );
4002
4314
 
@@ -4009,7 +4321,7 @@ const factory = (env) => {
4009
4321
  return false;
4010
4322
  }
4011
4323
 
4012
- const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
4324
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
4013
4325
 
4014
4326
  const encodeText =
4015
4327
  isFetchSupported &&
@@ -4026,18 +4338,20 @@ const factory = (env) => {
4026
4338
  test(() => {
4027
4339
  let duplexAccessed = false;
4028
4340
 
4029
- const body = new ReadableStream$1();
4030
-
4031
- const hasContentType = new Request(platform.origin, {
4032
- body,
4341
+ const request = new Request(platform.origin, {
4342
+ body: new ReadableStream(),
4033
4343
  method: 'POST',
4034
4344
  get duplex() {
4035
4345
  duplexAccessed = true;
4036
4346
  return 'half';
4037
4347
  },
4038
- }).headers.has('Content-Type');
4348
+ });
4039
4349
 
4040
- body.cancel();
4350
+ const hasContentType = request.headers.has('Content-Type');
4351
+
4352
+ if (request.body != null) {
4353
+ request.body.cancel();
4354
+ }
4041
4355
 
4042
4356
  return duplexAccessed && !hasContentType;
4043
4357
  });
@@ -4121,8 +4435,13 @@ const factory = (env) => {
4121
4435
  headers,
4122
4436
  withCredentials = 'same-origin',
4123
4437
  fetchOptions,
4438
+ maxContentLength,
4439
+ maxBodyLength,
4124
4440
  } = resolveConfig(config);
4125
4441
 
4442
+ const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
4443
+ const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
4444
+
4126
4445
  let _fetch = envFetch || fetch;
4127
4446
 
4128
4447
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
@@ -4144,6 +4463,41 @@ const factory = (env) => {
4144
4463
  let requestContentLength;
4145
4464
 
4146
4465
  try {
4466
+ // Enforce maxContentLength for data: URLs up-front so we never materialize
4467
+ // an oversized payload. The HTTP adapter applies the same check (see http.js
4468
+ // "if (protocol === 'data:')" branch).
4469
+ if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
4470
+ const estimated = estimateDataURLDecodedBytes(url);
4471
+ if (estimated > maxContentLength) {
4472
+ throw new AxiosError(
4473
+ 'maxContentLength size of ' + maxContentLength + ' exceeded',
4474
+ AxiosError.ERR_BAD_RESPONSE,
4475
+ config,
4476
+ request
4477
+ );
4478
+ }
4479
+ }
4480
+
4481
+ // Enforce maxBodyLength against the outbound request body before dispatch.
4482
+ // Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
4483
+ // maxBodyLength limit'). Skip when the body length cannot be determined
4484
+ // (e.g. a live ReadableStream supplied by the caller).
4485
+ if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
4486
+ const outboundLength = await resolveBodyLength(headers, data);
4487
+ if (
4488
+ typeof outboundLength === 'number' &&
4489
+ isFinite(outboundLength) &&
4490
+ outboundLength > maxBodyLength
4491
+ ) {
4492
+ throw new AxiosError(
4493
+ 'Request body larger than maxBodyLength limit',
4494
+ AxiosError.ERR_BAD_REQUEST,
4495
+ config,
4496
+ request
4497
+ );
4498
+ }
4499
+ }
4500
+
4147
4501
  if (
4148
4502
  onUploadProgress &&
4149
4503
  supportsRequestStream &&
@@ -4181,11 +4535,27 @@ const factory = (env) => {
4181
4535
  // see https://github.com/cloudflare/workerd/issues/902
4182
4536
  const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
4183
4537
 
4538
+ // If data is FormData and Content-Type is multipart/form-data without boundary,
4539
+ // delete it so fetch can set it correctly with the boundary
4540
+ if (utils$1.isFormData(data)) {
4541
+ const contentType = headers.getContentType();
4542
+ if (
4543
+ contentType &&
4544
+ /^multipart\/form-data/i.test(contentType) &&
4545
+ !/boundary=/i.test(contentType)
4546
+ ) {
4547
+ headers.delete('content-type');
4548
+ }
4549
+ }
4550
+
4551
+ // Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
4552
+ headers.set('User-Agent', 'axios/' + VERSION, false);
4553
+
4184
4554
  const resolvedOptions = {
4185
4555
  ...fetchOptions,
4186
4556
  signal: composedSignal,
4187
4557
  method: method.toUpperCase(),
4188
- headers: headers.normalize().toJSON(),
4558
+ headers: toByteStringHeaderObject(headers.normalize()),
4189
4559
  body: data,
4190
4560
  duplex: 'half',
4191
4561
  credentials: isCredentialsSupported ? withCredentials : undefined,
@@ -4197,10 +4567,28 @@ const factory = (env) => {
4197
4567
  ? _fetch(request, fetchOptions)
4198
4568
  : _fetch(url, resolvedOptions));
4199
4569
 
4570
+ // Cheap pre-check: if the server honestly declares a content-length that
4571
+ // already exceeds the cap, reject before we start streaming.
4572
+ if (hasMaxContentLength) {
4573
+ const declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
4574
+ if (declaredLength != null && declaredLength > maxContentLength) {
4575
+ throw new AxiosError(
4576
+ 'maxContentLength size of ' + maxContentLength + ' exceeded',
4577
+ AxiosError.ERR_BAD_RESPONSE,
4578
+ config,
4579
+ request
4580
+ );
4581
+ }
4582
+ }
4583
+
4200
4584
  const isStreamResponse =
4201
4585
  supportsResponseStream && (responseType === 'stream' || responseType === 'response');
4202
4586
 
4203
- if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
4587
+ if (
4588
+ supportsResponseStream &&
4589
+ response.body &&
4590
+ (onDownloadProgress || hasMaxContentLength || (isStreamResponse && unsubscribe))
4591
+ ) {
4204
4592
  const options = {};
4205
4593
 
4206
4594
  ['status', 'statusText', 'headers'].forEach((prop) => {
@@ -4217,8 +4605,24 @@ const factory = (env) => {
4217
4605
  )) ||
4218
4606
  [];
4219
4607
 
4608
+ let bytesRead = 0;
4609
+ const onChunkProgress = (loadedBytes) => {
4610
+ if (hasMaxContentLength) {
4611
+ bytesRead = loadedBytes;
4612
+ if (bytesRead > maxContentLength) {
4613
+ throw new AxiosError(
4614
+ 'maxContentLength size of ' + maxContentLength + ' exceeded',
4615
+ AxiosError.ERR_BAD_RESPONSE,
4616
+ config,
4617
+ request
4618
+ );
4619
+ }
4620
+ }
4621
+ onProgress && onProgress(loadedBytes);
4622
+ };
4623
+
4220
4624
  response = new Response(
4221
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
4625
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
4222
4626
  flush && flush();
4223
4627
  unsubscribe && unsubscribe();
4224
4628
  }),
@@ -4233,6 +4637,33 @@ const factory = (env) => {
4233
4637
  config
4234
4638
  );
4235
4639
 
4640
+ // Fallback enforcement for environments without ReadableStream support
4641
+ // (legacy runtimes). Detect materialized size from typed output; skip
4642
+ // streams/Response passthrough since the user will read those themselves.
4643
+ if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
4644
+ let materializedSize;
4645
+ if (responseData != null) {
4646
+ if (typeof responseData.byteLength === 'number') {
4647
+ materializedSize = responseData.byteLength;
4648
+ } else if (typeof responseData.size === 'number') {
4649
+ materializedSize = responseData.size;
4650
+ } else if (typeof responseData === 'string') {
4651
+ materializedSize =
4652
+ typeof TextEncoder === 'function'
4653
+ ? new TextEncoder().encode(responseData).byteLength
4654
+ : responseData.length;
4655
+ }
4656
+ }
4657
+ if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
4658
+ throw new AxiosError(
4659
+ 'maxContentLength size of ' + maxContentLength + ' exceeded',
4660
+ AxiosError.ERR_BAD_RESPONSE,
4661
+ config,
4662
+ request
4663
+ );
4664
+ }
4665
+ }
4666
+
4236
4667
  !isStreamResponse && unsubscribe && unsubscribe();
4237
4668
 
4238
4669
  return await new Promise((resolve, reject) => {
@@ -4248,6 +4679,17 @@ const factory = (env) => {
4248
4679
  } catch (err) {
4249
4680
  unsubscribe && unsubscribe();
4250
4681
 
4682
+ // Safari can surface fetch aborts as a DOMException-like object whose
4683
+ // branded getters throw. Prefer our composed signal reason before reading
4684
+ // the caught error, preserving timeout vs cancellation semantics.
4685
+ if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError) {
4686
+ const canceledError = composedSignal.reason;
4687
+ canceledError.config = config;
4688
+ request && (canceledError.request = request);
4689
+ err !== canceledError && (canceledError.cause = err);
4690
+ throw canceledError;
4691
+ }
4692
+
4251
4693
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
4252
4694
  throw Object.assign(
4253
4695
  new AxiosError(
@@ -4316,11 +4758,13 @@ const knownAdapters = {
4316
4758
  utils$1.forEach(knownAdapters, (fn, value) => {
4317
4759
  if (fn) {
4318
4760
  try {
4319
- Object.defineProperty(fn, 'name', { value });
4761
+ // Null-proto descriptors so a polluted Object.prototype.get cannot turn
4762
+ // these data descriptors into accessor descriptors on the way in.
4763
+ Object.defineProperty(fn, 'name', { __proto__: null, value });
4320
4764
  } catch (e) {
4321
4765
  // eslint-disable-next-line no-empty
4322
4766
  }
4323
- Object.defineProperty(fn, 'adapterName', { value });
4767
+ Object.defineProperty(fn, 'adapterName', { __proto__: null, value });
4324
4768
  }
4325
4769
  });
4326
4770
 
@@ -4462,8 +4906,15 @@ function dispatchRequest(config) {
4462
4906
  function onAdapterResolution(response) {
4463
4907
  throwIfCancellationRequested(config);
4464
4908
 
4465
- // Transform response data
4466
- response.data = transformData.call(config, config.transformResponse, response);
4909
+ // Expose the current response on config so that transformResponse can
4910
+ // attach it to any AxiosError it throws (e.g. on JSON parse failure).
4911
+ // We clean it up afterwards to avoid polluting the config object.
4912
+ config.response = response;
4913
+ try {
4914
+ response.data = transformData.call(config, config.transformResponse, response);
4915
+ } finally {
4916
+ delete config.response;
4917
+ }
4467
4918
 
4468
4919
  response.headers = AxiosHeaders.from(response.headers);
4469
4920
 
@@ -4475,11 +4926,16 @@ function dispatchRequest(config) {
4475
4926
 
4476
4927
  // Transform response data
4477
4928
  if (reason && reason.response) {
4478
- reason.response.data = transformData.call(
4479
- config,
4480
- config.transformResponse,
4481
- reason.response
4482
- );
4929
+ config.response = reason.response;
4930
+ try {
4931
+ reason.response.data = transformData.call(
4932
+ config,
4933
+ config.transformResponse,
4934
+ reason.response
4935
+ );
4936
+ } finally {
4937
+ delete config.response;
4938
+ }
4483
4939
  reason.response.headers = AxiosHeaders.from(reason.response.headers);
4484
4940
  }
4485
4941
  }
@@ -4489,8 +4945,6 @@ function dispatchRequest(config) {
4489
4945
  );
4490
4946
  }
4491
4947
 
4492
- const VERSION = "1.15.0";
4493
-
4494
4948
  const validators$1 = {};
4495
4949
 
4496
4950
  // eslint-disable-next-line func-names
@@ -4574,7 +5028,9 @@ function assertOptions(options, schema, allowUnknown) {
4574
5028
  let i = keys.length;
4575
5029
  while (i-- > 0) {
4576
5030
  const opt = keys[i];
4577
- const validator = schema[opt];
5031
+ // Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
5032
+ // a non-function validator and cause a TypeError.
5033
+ const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
4578
5034
  if (validator) {
4579
5035
  const value = options[opt];
4580
5036
  const result = value === undefined || validator(value, opt, options);
@@ -4733,7 +5189,7 @@ class Axios {
4733
5189
  let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
4734
5190
 
4735
5191
  headers &&
4736
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
5192
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
4737
5193
  delete headers[method];
4738
5194
  });
4739
5195
 
@@ -4836,7 +5292,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
4836
5292
  };
4837
5293
  });
4838
5294
 
4839
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
5295
+ utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
4840
5296
  function generateHTTPMethod(isForm) {
4841
5297
  return function httpMethod(url, data, config) {
4842
5298
  return this.request(
@@ -4856,7 +5312,11 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
4856
5312
 
4857
5313
  Axios.prototype[method] = generateHTTPMethod();
4858
5314
 
4859
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
5315
+ // QUERY is a safe/idempotent read method; multipart form bodies don't fit
5316
+ // its semantics, so no queryForm shorthand is generated.
5317
+ if (method !== 'query') {
5318
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
5319
+ }
4860
5320
  });
4861
5321
 
4862
5322
  /**