axios 1.15.2 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Axios v1.15.2 Copyright (c) 2026 Matt Zabriskie and contributors */
1
+ /*! Axios v1.16.0 Copyright (c) 2026 Matt Zabriskie and contributors */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -745,9 +745,9 @@
745
745
  * also have a `name` and `type` attribute to specify filename and content type
746
746
  *
747
747
  * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
748
- *
748
+ *
749
749
  * @param {*} value The value to test
750
- *
750
+ *
751
751
  * @returns {boolean} True if value is a React Native Blob, otherwise false
752
752
  */
753
753
  var isReactNativeBlob = function isReactNativeBlob(value) {
@@ -757,9 +757,9 @@
757
757
  /**
758
758
  * Determine if environment is React Native
759
759
  * ReactNative `FormData` has a non-standard `getParts()` method
760
- *
760
+ *
761
761
  * @param {*} formData The formData to test
762
- *
762
+ *
763
763
  * @returns {boolean} True if environment is React Native, otherwise false
764
764
  */
765
765
  var isReactNative = function isReactNative(formData) {
@@ -780,7 +780,7 @@
780
780
  *
781
781
  * @param {*} val The value to test
782
782
  *
783
- * @returns {boolean} True if value is a File, otherwise false
783
+ * @returns {boolean} True if value is a FileList, otherwise false
784
784
  */
785
785
  var isFileList = kindOfTest('FileList');
786
786
 
@@ -814,7 +814,7 @@
814
814
  var isFormData = function isFormData(thing) {
815
815
  if (!thing) return false;
816
816
  if (FormDataCtor && thing instanceof FormDataCtor) return true;
817
- // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
817
+ // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
818
818
  var proto = getPrototypeOf(thing);
819
819
  if (!proto || proto === Object.prototype) return false;
820
820
  if (!isFunction$1(thing.append)) return false;
@@ -954,8 +954,7 @@
954
954
  *
955
955
  * @returns {Object} Result of all merge properties
956
956
  */
957
- function merge(/* obj1, obj2, obj3, ... */
958
- ) {
957
+ function merge() {
959
958
  var _ref2 = isContextDefined(this) && this || {},
960
959
  caseless = _ref2.caseless,
961
960
  skipUndefined = _ref2.skipUndefined;
@@ -966,8 +965,12 @@
966
965
  return;
967
966
  }
968
967
  var targetKey = caseless && findKey(result, key) || key;
969
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
970
- result[targetKey] = merge(result[targetKey], val);
968
+ // Read via own-prop only — a bare `result[targetKey]` walks the prototype
969
+ // chain, so a polluted Object.prototype value could surface here and get
970
+ // copied into the merged result.
971
+ var existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
972
+ if (isPlainObject(existing) && isPlainObject(val)) {
973
+ result[targetKey] = merge(existing, val);
971
974
  } else if (isPlainObject(val)) {
972
975
  result[targetKey] = merge({}, val);
973
976
  } else if (isArray(val)) {
@@ -976,8 +979,11 @@
976
979
  result[targetKey] = val;
977
980
  }
978
981
  };
979
- for (var i = 0, l = arguments.length; i < l; i++) {
980
- arguments[i] && forEach(arguments[i], assignValue);
982
+ for (var _len = arguments.length, objs = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
983
+ objs[_key2] = arguments[_key2];
984
+ }
985
+ for (var i = 0, l = objs.length; i < l; i++) {
986
+ objs[i] && forEach(objs[i], assignValue);
981
987
  }
982
988
  return result;
983
989
  }
@@ -999,6 +1005,9 @@
999
1005
  forEach(b, function (val, key) {
1000
1006
  if (thisArg && isFunction$1(val)) {
1001
1007
  Object.defineProperty(a, key, {
1008
+ // Null-proto descriptor so a polluted Object.prototype.get cannot
1009
+ // hijack defineProperty's accessor-vs-data resolution.
1010
+ __proto__: null,
1002
1011
  value: bind(val, thisArg),
1003
1012
  writable: true,
1004
1013
  enumerable: true,
@@ -1006,6 +1015,7 @@
1006
1015
  });
1007
1016
  } else {
1008
1017
  Object.defineProperty(a, key, {
1018
+ __proto__: null,
1009
1019
  value: val,
1010
1020
  writable: true,
1011
1021
  enumerable: true,
@@ -1044,12 +1054,14 @@
1044
1054
  var inherits = function inherits(constructor, superConstructor, props, descriptors) {
1045
1055
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
1046
1056
  Object.defineProperty(constructor.prototype, 'constructor', {
1057
+ __proto__: null,
1047
1058
  value: constructor,
1048
1059
  writable: true,
1049
1060
  enumerable: false,
1050
1061
  configurable: true
1051
1062
  });
1052
1063
  Object.defineProperty(constructor, 'super', {
1064
+ __proto__: null,
1053
1065
  value: superConstructor.prototype
1054
1066
  });
1055
1067
  props && Object.assign(constructor.prototype, props);
@@ -1220,7 +1232,7 @@
1220
1232
  var freezeMethods = function freezeMethods(obj) {
1221
1233
  reduceDescriptors(obj, function (descriptor, name) {
1222
1234
  // skip restricted props in strict mode
1223
- if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
1235
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
1224
1236
  return false;
1225
1237
  }
1226
1238
  var value = obj[name];
@@ -1432,1104 +1444,1179 @@
1432
1444
  isIterable: isIterable
1433
1445
  };
1434
1446
 
1435
- var AxiosError = /*#__PURE__*/function (_Error) {
1436
- /**
1437
- * Create an Error with the specified message, config, error code, request and response.
1438
- *
1439
- * @param {string} message The error message.
1440
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
1441
- * @param {Object} [config] The config.
1442
- * @param {Object} [request] The request.
1443
- * @param {Object} [response] The response.
1444
- *
1445
- * @returns {Error} The created error.
1446
- */
1447
- function AxiosError(message, code, config, request, response) {
1448
- var _this;
1449
- _classCallCheck(this, AxiosError);
1450
- _this = _callSuper(this, AxiosError, [message]);
1451
-
1452
- // Make message enumerable to maintain backward compatibility
1453
- // The native Error constructor sets message as non-enumerable,
1454
- // but axios < v1.13.3 had it as enumerable
1455
- Object.defineProperty(_this, 'message', {
1456
- value: message,
1457
- enumerable: true,
1458
- writable: true,
1459
- configurable: true
1460
- });
1461
- _this.name = 'AxiosError';
1462
- _this.isAxiosError = true;
1463
- code && (_this.code = code);
1464
- config && (_this.config = config);
1465
- request && (_this.request = request);
1466
- if (response) {
1467
- _this.response = response;
1468
- _this.status = response.status;
1469
- }
1470
- return _this;
1471
- }
1472
- _inherits(AxiosError, _Error);
1473
- return _createClass(AxiosError, [{
1474
- key: "toJSON",
1475
- value: function toJSON() {
1476
- return {
1477
- // Standard
1478
- message: this.message,
1479
- name: this.name,
1480
- // Microsoft
1481
- description: this.description,
1482
- number: this.number,
1483
- // Mozilla
1484
- fileName: this.fileName,
1485
- lineNumber: this.lineNumber,
1486
- columnNumber: this.columnNumber,
1487
- stack: this.stack,
1488
- // Axios
1489
- config: utils$1.toJSONObject(this.config),
1490
- code: this.code,
1491
- status: this.status
1492
- };
1493
- }
1494
- }], [{
1495
- key: "from",
1496
- value: function from(error, code, config, request, response, customProps) {
1497
- var axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1498
- axiosError.cause = error;
1499
- axiosError.name = error.name;
1500
-
1501
- // Preserve status from the original error if not already set from response
1502
- if (error.status != null && axiosError.status == null) {
1503
- axiosError.status = error.status;
1504
- }
1505
- customProps && Object.assign(axiosError, customProps);
1506
- return axiosError;
1507
- }
1508
- }]);
1509
- }(/*#__PURE__*/_wrapNativeSuper(Error)); // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1510
- AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1511
- AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1512
- AxiosError.ECONNABORTED = 'ECONNABORTED';
1513
- AxiosError.ETIMEDOUT = 'ETIMEDOUT';
1514
- AxiosError.ERR_NETWORK = 'ERR_NETWORK';
1515
- AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1516
- AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
1517
- AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1518
- AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1519
- AxiosError.ERR_CANCELED = 'ERR_CANCELED';
1520
- AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1521
- AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
1522
- AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
1523
-
1524
- // eslint-disable-next-line strict
1525
- var httpAdapter = null;
1526
-
1527
- /**
1528
- * Determines if the given thing is a array or js object.
1529
- *
1530
- * @param {string} thing - The object or array to be visited.
1531
- *
1532
- * @returns {boolean}
1533
- */
1534
- function isVisitable(thing) {
1535
- return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
1536
- }
1537
-
1538
- /**
1539
- * It removes the brackets from the end of a string
1540
- *
1541
- * @param {string} key - The key of the parameter.
1542
- *
1543
- * @returns {string} the key without the brackets.
1544
- */
1545
- function removeBrackets(key) {
1546
- return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1547
- }
1548
-
1549
- /**
1550
- * It takes a path, a key, and a boolean, and returns a string
1551
- *
1552
- * @param {string} path - The path to the current key.
1553
- * @param {string} key - The key of the current object being iterated over.
1554
- * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
1555
- *
1556
- * @returns {string} The path to the current key.
1557
- */
1558
- function renderKey(path, key, dots) {
1559
- if (!path) return key;
1560
- return path.concat(key).map(function each(token, i) {
1561
- // eslint-disable-next-line no-param-reassign
1562
- token = removeBrackets(token);
1563
- return !dots && i ? '[' + token + ']' : token;
1564
- }).join(dots ? '.' : '');
1565
- }
1566
-
1567
- /**
1568
- * If the array is an array and none of its elements are visitable, then it's a flat array.
1569
- *
1570
- * @param {Array<any>} arr - The array to check
1571
- *
1572
- * @returns {boolean}
1573
- */
1574
- function isFlatArray(arr) {
1575
- return utils$1.isArray(arr) && !arr.some(isVisitable);
1576
- }
1577
- var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1578
- return /^is[A-Z]/.test(prop);
1579
- });
1447
+ // RawAxiosHeaders whose duplicates are ignored by node
1448
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1449
+ var ignoreDuplicateOf = utils$1.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
1580
1450
 
1581
1451
  /**
1582
- * Convert a data object to FormData
1583
- *
1584
- * @param {Object} obj
1585
- * @param {?Object} [formData]
1586
- * @param {?Object} [options]
1587
- * @param {Function} [options.visitor]
1588
- * @param {Boolean} [options.metaTokens = true]
1589
- * @param {Boolean} [options.dots = false]
1590
- * @param {?Boolean} [options.indexes = false]
1452
+ * Parse headers into an object
1591
1453
  *
1592
- * @returns {Object}
1593
- **/
1594
-
1595
- /**
1596
- * It converts an object into a FormData object
1454
+ * ```
1455
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1456
+ * Content-Type: application/json
1457
+ * Connection: keep-alive
1458
+ * Transfer-Encoding: chunked
1459
+ * ```
1597
1460
  *
1598
- * @param {Object<any, any>} obj - The object to convert to form data.
1599
- * @param {string} formData - The FormData object to append to.
1600
- * @param {Object<string, any>} options
1461
+ * @param {String} rawHeaders Headers needing to be parsed
1601
1462
  *
1602
- * @returns
1463
+ * @returns {Object} Headers parsed into an object
1603
1464
  */
1604
- function toFormData(obj, formData, options) {
1605
- if (!utils$1.isObject(obj)) {
1606
- throw new TypeError('target must be an object');
1607
- }
1608
-
1609
- // eslint-disable-next-line no-param-reassign
1610
- formData = formData || new (FormData)();
1611
-
1612
- // eslint-disable-next-line no-param-reassign
1613
- options = utils$1.toFlatObject(options, {
1614
- metaTokens: true,
1615
- dots: false,
1616
- indexes: false
1617
- }, false, function defined(option, source) {
1618
- // eslint-disable-next-line no-eq-null,eqeqeq
1619
- return !utils$1.isUndefined(source[option]);
1620
- });
1621
- var metaTokens = options.metaTokens;
1622
- // eslint-disable-next-line no-use-before-define
1623
- var visitor = options.visitor || defaultVisitor;
1624
- var dots = options.dots;
1625
- var indexes = options.indexes;
1626
- var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1627
- var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
1628
- var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1629
- if (!utils$1.isFunction(visitor)) {
1630
- throw new TypeError('visitor must be a function');
1631
- }
1632
- function convertValue(value) {
1633
- if (value === null) return '';
1634
- if (utils$1.isDate(value)) {
1635
- return value.toISOString();
1636
- }
1637
- if (utils$1.isBoolean(value)) {
1638
- return value.toString();
1465
+ var parseHeaders = (function (rawHeaders) {
1466
+ var parsed = {};
1467
+ var key;
1468
+ var val;
1469
+ var i;
1470
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1471
+ i = line.indexOf(':');
1472
+ key = line.substring(0, i).trim().toLowerCase();
1473
+ val = line.substring(i + 1).trim();
1474
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1475
+ return;
1639
1476
  }
1640
- if (!useBlob && utils$1.isBlob(value)) {
1641
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1477
+ if (key === 'set-cookie') {
1478
+ if (parsed[key]) {
1479
+ parsed[key].push(val);
1480
+ } else {
1481
+ parsed[key] = [val];
1482
+ }
1483
+ } else {
1484
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1642
1485
  }
1643
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1644
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1486
+ });
1487
+ return parsed;
1488
+ });
1489
+
1490
+ var $internals = Symbol('internals');
1491
+ var INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
1492
+ function trimSPorHTAB(str) {
1493
+ var start = 0;
1494
+ var end = str.length;
1495
+ while (start < end) {
1496
+ var code = str.charCodeAt(start);
1497
+ if (code !== 0x09 && code !== 0x20) {
1498
+ break;
1645
1499
  }
1646
- return value;
1500
+ start += 1;
1647
1501
  }
1648
-
1649
- /**
1650
- * Default visitor.
1651
- *
1652
- * @param {*} value
1653
- * @param {String|Number} key
1654
- * @param {Array<String|Number>} path
1655
- * @this {FormData}
1656
- *
1657
- * @returns {boolean} return true to visit the each prop of the value recursively
1658
- */
1659
- function defaultVisitor(value, key, path) {
1660
- var arr = value;
1661
- if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
1662
- formData.append(renderKey(path, key, dots), convertValue(value));
1663
- return false;
1664
- }
1665
- if (value && !path && _typeof(value) === 'object') {
1666
- if (utils$1.endsWith(key, '{}')) {
1667
- // eslint-disable-next-line no-param-reassign
1668
- key = metaTokens ? key : key.slice(0, -2);
1669
- // eslint-disable-next-line no-param-reassign
1670
- value = JSON.stringify(value);
1671
- } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
1672
- // eslint-disable-next-line no-param-reassign
1673
- key = removeBrackets(key);
1674
- arr.forEach(function each(el, index) {
1675
- !(utils$1.isUndefined(el) || el === null) && formData.append(
1676
- // eslint-disable-next-line no-nested-ternary
1677
- indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
1678
- });
1679
- return false;
1680
- }
1681
- }
1682
- if (isVisitable(value)) {
1683
- return true;
1684
- }
1685
- formData.append(renderKey(path, key, dots), convertValue(value));
1686
- return false;
1687
- }
1688
- var stack = [];
1689
- var exposedHelpers = Object.assign(predicates, {
1690
- defaultVisitor: defaultVisitor,
1691
- convertValue: convertValue,
1692
- isVisitable: isVisitable
1693
- });
1694
- function build(value, path) {
1695
- var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1696
- if (utils$1.isUndefined(value)) return;
1697
- if (depth > maxDepth) {
1698
- throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
1699
- }
1700
- if (stack.indexOf(value) !== -1) {
1701
- throw Error('Circular reference detected in ' + path.join('.'));
1502
+ while (end > start) {
1503
+ var _code = str.charCodeAt(end - 1);
1504
+ if (_code !== 0x09 && _code !== 0x20) {
1505
+ break;
1702
1506
  }
1703
- stack.push(value);
1704
- utils$1.forEach(value, function each(el, key) {
1705
- var result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
1706
- if (result === true) {
1707
- build(el, path ? path.concat(key) : [key], depth + 1);
1708
- }
1709
- });
1710
- stack.pop();
1711
- }
1712
- if (!utils$1.isObject(obj)) {
1713
- throw new TypeError('data must be an object');
1507
+ end -= 1;
1714
1508
  }
1715
- build(obj);
1716
- return formData;
1509
+ return start === 0 && end === str.length ? str : str.slice(start, end);
1717
1510
  }
1718
-
1719
- /**
1720
- * It encodes a string by replacing all characters that are not in the unreserved set with
1721
- * their percent-encoded equivalents
1722
- *
1723
- * @param {string} str - The string to encode.
1724
- *
1725
- * @returns {string} The encoded string.
1726
- */
1727
- function encode$1(str) {
1728
- var charMap = {
1729
- '!': '%21',
1730
- "'": '%27',
1731
- '(': '%28',
1732
- ')': '%29',
1733
- '~': '%7E',
1734
- '%20': '+'
1735
- };
1736
- return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
1737
- return charMap[match];
1738
- });
1511
+ function normalizeHeader(header) {
1512
+ return header && String(header).trim().toLowerCase();
1739
1513
  }
1740
-
1741
- /**
1742
- * It takes a params object and converts it to a FormData object
1743
- *
1744
- * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1745
- * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1746
- *
1747
- * @returns {void}
1748
- */
1749
- function AxiosURLSearchParams(params, options) {
1750
- this._pairs = [];
1751
- params && toFormData(params, this, options);
1514
+ function sanitizeHeaderValue(str) {
1515
+ return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
1752
1516
  }
1753
- var prototype = AxiosURLSearchParams.prototype;
1754
- prototype.append = function append(name, value) {
1755
- this._pairs.push([name, value]);
1756
- };
1757
- prototype.toString = function toString(encoder) {
1758
- var _encode = encoder ? function (value) {
1759
- return encoder.call(this, value, encode$1);
1760
- } : encode$1;
1761
- return this._pairs.map(function each(pair) {
1762
- return _encode(pair[0]) + '=' + _encode(pair[1]);
1763
- }, '').join('&');
1764
- };
1765
-
1766
- /**
1767
- * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
1768
- * their plain counterparts (`:`, `$`, `,`, `+`).
1769
- *
1770
- * @param {string} val The value to be encoded.
1771
- *
1772
- * @returns {string} The encoded value.
1773
- */
1774
- function encode(val) {
1775
- return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
1517
+ function normalizeValue(value) {
1518
+ if (value === false || value == null) {
1519
+ return value;
1520
+ }
1521
+ return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
1776
1522
  }
1777
-
1778
- /**
1779
- * Build a URL by appending params to the end
1780
- *
1781
- * @param {string} url The base of the url (e.g., http://www.google.com)
1782
- * @param {object} [params] The params to be appended
1783
- * @param {?(object|Function)} options
1784
- *
1785
- * @returns {string} The formatted url
1786
- */
1787
- function buildURL(url, params, options) {
1788
- if (!params) {
1789
- return url;
1523
+ function parseTokens(str) {
1524
+ var tokens = Object.create(null);
1525
+ var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1526
+ var match;
1527
+ while (match = tokensRE.exec(str)) {
1528
+ tokens[match[1]] = match[2];
1790
1529
  }
1791
- var _encode = options && options.encode || encode;
1792
- var _options = utils$1.isFunction(options) ? {
1793
- serialize: options
1794
- } : options;
1795
- var serializeFn = _options && _options.serialize;
1796
- var serializedParams;
1797
- if (serializeFn) {
1798
- serializedParams = serializeFn(params, _options);
1799
- } else {
1800
- serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
1530
+ return tokens;
1531
+ }
1532
+ var isValidHeaderName = function isValidHeaderName(str) {
1533
+ return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1534
+ };
1535
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1536
+ if (utils$1.isFunction(filter)) {
1537
+ return filter.call(this, value, header);
1801
1538
  }
1802
- if (serializedParams) {
1803
- var hashmarkIndex = url.indexOf('#');
1804
- if (hashmarkIndex !== -1) {
1805
- url = url.slice(0, hashmarkIndex);
1806
- }
1807
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1539
+ if (isHeaderNameFilter) {
1540
+ value = header;
1541
+ }
1542
+ if (!utils$1.isString(value)) return;
1543
+ if (utils$1.isString(filter)) {
1544
+ return value.indexOf(filter) !== -1;
1545
+ }
1546
+ if (utils$1.isRegExp(filter)) {
1547
+ return filter.test(value);
1808
1548
  }
1809
- return url;
1810
1549
  }
1811
-
1812
- var InterceptorManager = /*#__PURE__*/function () {
1813
- function InterceptorManager() {
1814
- _classCallCheck(this, InterceptorManager);
1815
- this.handlers = [];
1550
+ function formatHeader(header) {
1551
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
1552
+ return _char.toUpperCase() + str;
1553
+ });
1554
+ }
1555
+ function buildAccessors(obj, header) {
1556
+ var accessorName = utils$1.toCamelCase(' ' + header);
1557
+ ['get', 'set', 'has'].forEach(function (methodName) {
1558
+ Object.defineProperty(obj, methodName + accessorName, {
1559
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
1560
+ // this data descriptor into an accessor descriptor on the way in.
1561
+ __proto__: null,
1562
+ value: function value(arg1, arg2, arg3) {
1563
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1564
+ },
1565
+ configurable: true
1566
+ });
1567
+ });
1568
+ }
1569
+ var AxiosHeaders = /*#__PURE__*/function () {
1570
+ function AxiosHeaders(headers) {
1571
+ _classCallCheck(this, AxiosHeaders);
1572
+ headers && this.set(headers);
1816
1573
  }
1817
-
1818
- /**
1819
- * Add a new interceptor to the stack
1820
- *
1821
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
1822
- * @param {Function} rejected The function to handle `reject` for a `Promise`
1823
- * @param {Object} options The options for the interceptor, synchronous and runWhen
1824
- *
1825
- * @return {Number} An ID used to remove interceptor later
1826
- */
1827
- return _createClass(InterceptorManager, [{
1828
- key: "use",
1829
- value: function use(fulfilled, rejected, options) {
1830
- this.handlers.push({
1831
- fulfilled: fulfilled,
1832
- rejected: rejected,
1833
- synchronous: options ? options.synchronous : false,
1834
- runWhen: options ? options.runWhen : null
1835
- });
1836
- return this.handlers.length - 1;
1837
- }
1838
-
1839
- /**
1840
- * Remove an interceptor from the stack
1841
- *
1842
- * @param {Number} id The ID that was returned by `use`
1843
- *
1844
- * @returns {void}
1845
- */
1846
- }, {
1847
- key: "eject",
1848
- value: function eject(id) {
1849
- if (this.handlers[id]) {
1850
- this.handlers[id] = null;
1851
- }
1852
- }
1853
-
1854
- /**
1855
- * Clear all interceptors from the stack
1856
- *
1857
- * @returns {void}
1858
- */
1859
- }, {
1574
+ return _createClass(AxiosHeaders, [{
1575
+ key: "set",
1576
+ value: function set(header, valueOrRewrite, rewrite) {
1577
+ var self = this;
1578
+ function setHeader(_value, _header, _rewrite) {
1579
+ var lHeader = normalizeHeader(_header);
1580
+ if (!lHeader) {
1581
+ throw new Error('header name must be a non-empty string');
1582
+ }
1583
+ var key = utils$1.findKey(self, lHeader);
1584
+ if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
1585
+ self[key || _header] = normalizeValue(_value);
1586
+ }
1587
+ }
1588
+ var setHeaders = function setHeaders(headers, _rewrite) {
1589
+ return utils$1.forEach(headers, function (_value, _header) {
1590
+ return setHeader(_value, _header, _rewrite);
1591
+ });
1592
+ };
1593
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1594
+ setHeaders(header, valueOrRewrite);
1595
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1596
+ setHeaders(parseHeaders(header), valueOrRewrite);
1597
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1598
+ var obj = {},
1599
+ dest,
1600
+ key;
1601
+ var _iterator = _createForOfIteratorHelper(header),
1602
+ _step;
1603
+ try {
1604
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1605
+ var entry = _step.value;
1606
+ if (!utils$1.isArray(entry)) {
1607
+ throw TypeError('Object iterator must return a key-value pair');
1608
+ }
1609
+ obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]] : entry[1];
1610
+ }
1611
+ } catch (err) {
1612
+ _iterator.e(err);
1613
+ } finally {
1614
+ _iterator.f();
1615
+ }
1616
+ setHeaders(obj, valueOrRewrite);
1617
+ } else {
1618
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1619
+ }
1620
+ return this;
1621
+ }
1622
+ }, {
1623
+ key: "get",
1624
+ value: function get(header, parser) {
1625
+ header = normalizeHeader(header);
1626
+ if (header) {
1627
+ var key = utils$1.findKey(this, header);
1628
+ if (key) {
1629
+ var value = this[key];
1630
+ if (!parser) {
1631
+ return value;
1632
+ }
1633
+ if (parser === true) {
1634
+ return parseTokens(value);
1635
+ }
1636
+ if (utils$1.isFunction(parser)) {
1637
+ return parser.call(this, value, key);
1638
+ }
1639
+ if (utils$1.isRegExp(parser)) {
1640
+ return parser.exec(value);
1641
+ }
1642
+ throw new TypeError('parser must be boolean|regexp|function');
1643
+ }
1644
+ }
1645
+ }
1646
+ }, {
1647
+ key: "has",
1648
+ value: function has(header, matcher) {
1649
+ header = normalizeHeader(header);
1650
+ if (header) {
1651
+ var key = utils$1.findKey(this, header);
1652
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1653
+ }
1654
+ return false;
1655
+ }
1656
+ }, {
1657
+ key: "delete",
1658
+ value: function _delete(header, matcher) {
1659
+ var self = this;
1660
+ var deleted = false;
1661
+ function deleteHeader(_header) {
1662
+ _header = normalizeHeader(_header);
1663
+ if (_header) {
1664
+ var key = utils$1.findKey(self, _header);
1665
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1666
+ delete self[key];
1667
+ deleted = true;
1668
+ }
1669
+ }
1670
+ }
1671
+ if (utils$1.isArray(header)) {
1672
+ header.forEach(deleteHeader);
1673
+ } else {
1674
+ deleteHeader(header);
1675
+ }
1676
+ return deleted;
1677
+ }
1678
+ }, {
1860
1679
  key: "clear",
1861
- value: function clear() {
1862
- if (this.handlers) {
1863
- this.handlers = [];
1680
+ value: function clear(matcher) {
1681
+ var keys = Object.keys(this);
1682
+ var i = keys.length;
1683
+ var deleted = false;
1684
+ while (i--) {
1685
+ var key = keys[i];
1686
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1687
+ delete this[key];
1688
+ deleted = true;
1689
+ }
1864
1690
  }
1691
+ return deleted;
1865
1692
  }
1866
-
1867
- /**
1868
- * Iterate over all the registered interceptors
1869
- *
1870
- * This method is particularly useful for skipping over any
1871
- * interceptors that may have become `null` calling `eject`.
1872
- *
1873
- * @param {Function} fn The function to call for each interceptor
1874
- *
1875
- * @returns {void}
1876
- */
1877
1693
  }, {
1878
- key: "forEach",
1879
- value: function forEach(fn) {
1880
- utils$1.forEach(this.handlers, function forEachHandler(h) {
1881
- if (h !== null) {
1882
- fn(h);
1694
+ key: "normalize",
1695
+ value: function normalize(format) {
1696
+ var self = this;
1697
+ var headers = {};
1698
+ utils$1.forEach(this, function (value, header) {
1699
+ var key = utils$1.findKey(headers, header);
1700
+ if (key) {
1701
+ self[key] = normalizeValue(value);
1702
+ delete self[header];
1703
+ return;
1704
+ }
1705
+ var normalized = format ? formatHeader(header) : String(header).trim();
1706
+ if (normalized !== header) {
1707
+ delete self[header];
1883
1708
  }
1709
+ self[normalized] = normalizeValue(value);
1710
+ headers[normalized] = true;
1711
+ });
1712
+ return this;
1713
+ }
1714
+ }, {
1715
+ key: "concat",
1716
+ value: function concat() {
1717
+ var _this$constructor;
1718
+ for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
1719
+ targets[_key] = arguments[_key];
1720
+ }
1721
+ return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
1722
+ }
1723
+ }, {
1724
+ key: "toJSON",
1725
+ value: function toJSON(asStrings) {
1726
+ var obj = Object.create(null);
1727
+ utils$1.forEach(this, function (value, header) {
1728
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1729
+ });
1730
+ return obj;
1731
+ }
1732
+ }, {
1733
+ key: Symbol.iterator,
1734
+ value: function value() {
1735
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1736
+ }
1737
+ }, {
1738
+ key: "toString",
1739
+ value: function toString() {
1740
+ return Object.entries(this.toJSON()).map(function (_ref) {
1741
+ var _ref2 = _slicedToArray(_ref, 2),
1742
+ header = _ref2[0],
1743
+ value = _ref2[1];
1744
+ return header + ': ' + value;
1745
+ }).join('\n');
1746
+ }
1747
+ }, {
1748
+ key: "getSetCookie",
1749
+ value: function getSetCookie() {
1750
+ return this.get('set-cookie') || [];
1751
+ }
1752
+ }, {
1753
+ key: Symbol.toStringTag,
1754
+ get: function get() {
1755
+ return 'AxiosHeaders';
1756
+ }
1757
+ }], [{
1758
+ key: "from",
1759
+ value: function from(thing) {
1760
+ return thing instanceof this ? thing : new this(thing);
1761
+ }
1762
+ }, {
1763
+ key: "concat",
1764
+ value: function concat(first) {
1765
+ var computed = new this(first);
1766
+ for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1767
+ targets[_key2 - 1] = arguments[_key2];
1768
+ }
1769
+ targets.forEach(function (target) {
1770
+ return computed.set(target);
1884
1771
  });
1772
+ return computed;
1773
+ }
1774
+ }, {
1775
+ key: "accessor",
1776
+ value: function accessor(header) {
1777
+ var internals = this[$internals] = this[$internals] = {
1778
+ accessors: {}
1779
+ };
1780
+ var accessors = internals.accessors;
1781
+ var prototype = this.prototype;
1782
+ function defineAccessor(_header) {
1783
+ var lHeader = normalizeHeader(_header);
1784
+ if (!accessors[lHeader]) {
1785
+ buildAccessors(prototype, _header);
1786
+ accessors[lHeader] = true;
1787
+ }
1788
+ }
1789
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1790
+ return this;
1885
1791
  }
1886
1792
  }]);
1887
1793
  }();
1794
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1888
1795
 
1889
- var transitionalDefaults = {
1890
- silentJSONParsing: true,
1891
- forcedJSONParsing: true,
1892
- clarifyTimeoutError: false,
1893
- legacyInterceptorReqResOrdering: true
1894
- };
1895
-
1896
- var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1897
-
1898
- var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1796
+ // reserved names hotfix
1797
+ utils$1.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
1798
+ var value = _ref3.value;
1799
+ var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1800
+ return {
1801
+ get: function get() {
1802
+ return value;
1803
+ },
1804
+ set: function set(headerValue) {
1805
+ this[mapped] = headerValue;
1806
+ }
1807
+ };
1808
+ });
1809
+ utils$1.freezeMethods(AxiosHeaders);
1899
1810
 
1900
- var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1811
+ var REDACTED = '[REDACTED ****]';
1812
+ function hasOwnOrPrototypeToJSON(source) {
1813
+ if (utils$1.hasOwnProp(source, 'toJSON')) {
1814
+ return true;
1815
+ }
1816
+ var prototype = Object.getPrototypeOf(source);
1817
+ while (prototype && prototype !== Object.prototype) {
1818
+ if (utils$1.hasOwnProp(prototype, 'toJSON')) {
1819
+ return true;
1820
+ }
1821
+ prototype = Object.getPrototypeOf(prototype);
1822
+ }
1823
+ return false;
1824
+ }
1901
1825
 
1902
- var platform$1 = {
1903
- isBrowser: true,
1904
- classes: {
1905
- URLSearchParams: URLSearchParams$1,
1906
- FormData: FormData$1,
1907
- Blob: Blob$1
1908
- },
1909
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1910
- };
1826
+ // Build a plain-object snapshot of `config` and replace the value of any key
1827
+ // (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
1828
+ // and AxiosHeaders, and short-circuits on circular references.
1829
+ function redactConfig(config, redactKeys) {
1830
+ var lowerKeys = new Set(redactKeys.map(function (k) {
1831
+ return String(k).toLowerCase();
1832
+ }));
1833
+ var seen = [];
1834
+ var _visit = function visit(source) {
1835
+ if (source === null || _typeof(source) !== 'object') return source;
1836
+ if (utils$1.isBuffer(source)) return source;
1837
+ if (seen.indexOf(source) !== -1) return undefined;
1838
+ if (source instanceof AxiosHeaders) {
1839
+ source = source.toJSON();
1840
+ }
1841
+ seen.push(source);
1842
+ var result;
1843
+ if (utils$1.isArray(source)) {
1844
+ result = [];
1845
+ source.forEach(function (v, i) {
1846
+ var reducedValue = _visit(v);
1847
+ if (!utils$1.isUndefined(reducedValue)) {
1848
+ result[i] = reducedValue;
1849
+ }
1850
+ });
1851
+ } else {
1852
+ if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
1853
+ seen.pop();
1854
+ return source;
1855
+ }
1856
+ result = Object.create(null);
1857
+ for (var _i = 0, _Object$entries = Object.entries(source); _i < _Object$entries.length; _i++) {
1858
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1859
+ key = _Object$entries$_i[0],
1860
+ value = _Object$entries$_i[1];
1861
+ var reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : _visit(value);
1862
+ if (!utils$1.isUndefined(reducedValue)) {
1863
+ result[key] = reducedValue;
1864
+ }
1865
+ }
1866
+ }
1867
+ seen.pop();
1868
+ return result;
1869
+ };
1870
+ return _visit(config);
1871
+ }
1872
+ var AxiosError = /*#__PURE__*/function (_Error) {
1873
+ /**
1874
+ * Create an Error with the specified message, config, error code, request and response.
1875
+ *
1876
+ * @param {string} message The error message.
1877
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
1878
+ * @param {Object} [config] The config.
1879
+ * @param {Object} [request] The request.
1880
+ * @param {Object} [response] The response.
1881
+ *
1882
+ * @returns {Error} The created error.
1883
+ */
1884
+ function AxiosError(message, code, config, request, response) {
1885
+ var _this;
1886
+ _classCallCheck(this, AxiosError);
1887
+ _this = _callSuper(this, AxiosError, [message]);
1911
1888
 
1912
- var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1913
- var _navigator = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator || undefined;
1889
+ // Make message enumerable to maintain backward compatibility
1890
+ // The native Error constructor sets message as non-enumerable,
1891
+ // but axios < v1.13.3 had it as enumerable
1892
+ Object.defineProperty(_this, 'message', {
1893
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
1894
+ // this data descriptor into an accessor descriptor on the way in.
1895
+ __proto__: null,
1896
+ value: message,
1897
+ enumerable: true,
1898
+ writable: true,
1899
+ configurable: true
1900
+ });
1901
+ _this.name = 'AxiosError';
1902
+ _this.isAxiosError = true;
1903
+ code && (_this.code = code);
1904
+ config && (_this.config = config);
1905
+ request && (_this.request = request);
1906
+ if (response) {
1907
+ _this.response = response;
1908
+ _this.status = response.status;
1909
+ }
1910
+ return _this;
1911
+ }
1912
+ _inherits(AxiosError, _Error);
1913
+ return _createClass(AxiosError, [{
1914
+ key: "toJSON",
1915
+ value: function toJSON() {
1916
+ // Opt-in redaction: when the request config carries a `redact` array, the
1917
+ // value of any matching key (case-insensitive, at any depth) is replaced
1918
+ // with REDACTED in the serialized snapshot. Undefined or empty leaves the
1919
+ // existing serialization behavior unchanged.
1920
+ var config = this.config;
1921
+ var redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
1922
+ var serializedConfig = utils$1.isArray(redactKeys) && redactKeys.length > 0 ? redactConfig(config, redactKeys) : utils$1.toJSONObject(config);
1923
+ return {
1924
+ // Standard
1925
+ message: this.message,
1926
+ name: this.name,
1927
+ // Microsoft
1928
+ description: this.description,
1929
+ number: this.number,
1930
+ // Mozilla
1931
+ fileName: this.fileName,
1932
+ lineNumber: this.lineNumber,
1933
+ columnNumber: this.columnNumber,
1934
+ stack: this.stack,
1935
+ // Axios
1936
+ config: serializedConfig,
1937
+ code: this.code,
1938
+ status: this.status
1939
+ };
1940
+ }
1941
+ }], [{
1942
+ key: "from",
1943
+ value: function from(error, code, config, request, response, customProps) {
1944
+ var axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1945
+ axiosError.cause = error;
1946
+ axiosError.name = error.name;
1947
+
1948
+ // Preserve status from the original error if not already set from response
1949
+ if (error.status != null && axiosError.status == null) {
1950
+ axiosError.status = error.status;
1951
+ }
1952
+ customProps && Object.assign(axiosError, customProps);
1953
+ return axiosError;
1954
+ }
1955
+ }]);
1956
+ }(/*#__PURE__*/_wrapNativeSuper(Error)); // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1957
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1958
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1959
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
1960
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
1961
+ AxiosError.ECONNREFUSED = 'ECONNREFUSED';
1962
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
1963
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1964
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
1965
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1966
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1967
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
1968
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1969
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
1970
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
1971
+
1972
+ // eslint-disable-next-line strict
1973
+ var httpAdapter = null;
1914
1974
 
1915
1975
  /**
1916
- * Determine if we're running in a standard browser environment
1917
- *
1918
- * This allows axios to run in a web worker, and react-native.
1919
- * Both environments support XMLHttpRequest, but not fully standard globals.
1920
- *
1921
- * web workers:
1922
- * typeof window -> undefined
1923
- * typeof document -> undefined
1976
+ * Determines if the given thing is a array or js object.
1924
1977
  *
1925
- * react-native:
1926
- * navigator.product -> 'ReactNative'
1927
- * nativescript
1928
- * navigator.product -> 'NativeScript' or 'NS'
1978
+ * @param {string} thing - The object or array to be visited.
1929
1979
  *
1930
1980
  * @returns {boolean}
1931
1981
  */
1932
- var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1982
+ function isVisitable(thing) {
1983
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
1984
+ }
1933
1985
 
1934
1986
  /**
1935
- * Determine if we're running in a standard browser webWorker environment
1987
+ * It removes the brackets from the end of a string
1936
1988
  *
1937
- * Although the `isStandardBrowserEnv` method indicates that
1938
- * `allows axios to run in a web worker`, the WebWorker will still be
1939
- * filtered out due to its judgment standard
1940
- * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1941
- * This leads to a problem when axios post `FormData` in webWorker
1989
+ * @param {string} key - The key of the parameter.
1990
+ *
1991
+ * @returns {string} the key without the brackets.
1942
1992
  */
1943
- var hasStandardBrowserWebWorkerEnv = function () {
1944
- return typeof WorkerGlobalScope !== 'undefined' &&
1945
- // eslint-disable-next-line no-undef
1946
- self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
1947
- }();
1948
- var origin = hasBrowserEnv && window.location.href || 'http://localhost';
1949
-
1950
- var utils = /*#__PURE__*/Object.freeze({
1951
- __proto__: null,
1952
- hasBrowserEnv: hasBrowserEnv,
1953
- hasStandardBrowserEnv: hasStandardBrowserEnv,
1954
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1955
- navigator: _navigator,
1956
- origin: origin
1957
- });
1958
-
1959
- var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
1960
-
1961
- function toURLEncodedForm(data, options) {
1962
- return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
1963
- visitor: function visitor(value, key, path, helpers) {
1964
- if (platform.isNode && utils$1.isBuffer(value)) {
1965
- this.append(key, value.toString('base64'));
1966
- return false;
1967
- }
1968
- return helpers.defaultVisitor.apply(this, arguments);
1969
- }
1970
- }, options));
1993
+ function removeBrackets(key) {
1994
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1971
1995
  }
1972
1996
 
1973
1997
  /**
1974
- * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1998
+ * It takes a path, a key, and a boolean, and returns a string
1975
1999
  *
1976
- * @param {string} name - The name of the property to get.
2000
+ * @param {string} path - The path to the current key.
2001
+ * @param {string} key - The key of the current object being iterated over.
2002
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
1977
2003
  *
1978
- * @returns An array of strings.
2004
+ * @returns {string} The path to the current key.
1979
2005
  */
1980
- function parsePropPath(name) {
1981
- // foo[x][y][z]
1982
- // foo.x.y.z
1983
- // foo-x-y-z
1984
- // foo x y z
1985
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
1986
- return match[0] === '[]' ? '' : match[1] || match[0];
1987
- });
2006
+ function renderKey(path, key, dots) {
2007
+ if (!path) return key;
2008
+ return path.concat(key).map(function each(token, i) {
2009
+ // eslint-disable-next-line no-param-reassign
2010
+ token = removeBrackets(token);
2011
+ return !dots && i ? '[' + token + ']' : token;
2012
+ }).join(dots ? '.' : '');
1988
2013
  }
1989
2014
 
1990
2015
  /**
1991
- * Convert an array to an object.
2016
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
1992
2017
  *
1993
- * @param {Array<any>} arr - The array to convert to an object.
2018
+ * @param {Array<any>} arr - The array to check
1994
2019
  *
1995
- * @returns An object with the same keys and values as the array.
2020
+ * @returns {boolean}
1996
2021
  */
1997
- function arrayToObject(arr) {
1998
- var obj = {};
1999
- var keys = Object.keys(arr);
2000
- var i;
2001
- var len = keys.length;
2002
- var key;
2003
- for (i = 0; i < len; i++) {
2004
- key = keys[i];
2005
- obj[key] = arr[key];
2006
- }
2007
- return obj;
2022
+ function isFlatArray(arr) {
2023
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
2008
2024
  }
2025
+ var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
2026
+ return /^is[A-Z]/.test(prop);
2027
+ });
2009
2028
 
2010
2029
  /**
2011
- * It takes a FormData object and returns a JavaScript object
2030
+ * Convert a data object to FormData
2012
2031
  *
2013
- * @param {string} formData The FormData object to convert to JSON.
2032
+ * @param {Object} obj
2033
+ * @param {?Object} [formData]
2034
+ * @param {?Object} [options]
2035
+ * @param {Function} [options.visitor]
2036
+ * @param {Boolean} [options.metaTokens = true]
2037
+ * @param {Boolean} [options.dots = false]
2038
+ * @param {?Boolean} [options.indexes = false]
2014
2039
  *
2015
- * @returns {Object<string, any> | null} The converted object.
2040
+ * @returns {Object}
2041
+ **/
2042
+
2043
+ /**
2044
+ * It converts an object into a FormData object
2045
+ *
2046
+ * @param {Object<any, any>} obj - The object to convert to form data.
2047
+ * @param {string} formData - The FormData object to append to.
2048
+ * @param {Object<string, any>} options
2049
+ *
2050
+ * @returns
2016
2051
  */
2017
- function formDataToJSON(formData) {
2018
- function buildPath(path, value, target, index) {
2019
- var name = path[index++];
2020
- if (name === '__proto__') return true;
2021
- var isNumericKey = Number.isFinite(+name);
2022
- var isLast = index >= path.length;
2023
- name = !name && utils$1.isArray(target) ? target.length : name;
2024
- if (isLast) {
2025
- if (utils$1.hasOwnProp(target, name)) {
2026
- target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
2027
- } else {
2028
- target[name] = value;
2029
- }
2030
- return !isNumericKey;
2031
- }
2032
- if (!target[name] || !utils$1.isObject(target[name])) {
2033
- target[name] = [];
2034
- }
2035
- var result = buildPath(path, value, target[name], index);
2036
- if (result && utils$1.isArray(target[name])) {
2037
- target[name] = arrayToObject(target[name]);
2038
- }
2039
- return !isNumericKey;
2040
- }
2041
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
2042
- var obj = {};
2043
- utils$1.forEachEntry(formData, function (name, value) {
2044
- buildPath(parsePropPath(name), value, obj, 0);
2045
- });
2046
- return obj;
2052
+ function toFormData(obj, formData, options) {
2053
+ if (!utils$1.isObject(obj)) {
2054
+ throw new TypeError('target must be an object');
2047
2055
  }
2048
- return null;
2049
- }
2050
2056
 
2051
- var own = function own(obj, key) {
2052
- return obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
2053
- };
2057
+ // eslint-disable-next-line no-param-reassign
2058
+ formData = formData || new (FormData)();
2054
2059
 
2055
- /**
2056
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2057
- * of the input
2058
- *
2059
- * @param {any} rawValue - The value to be stringified.
2060
- * @param {Function} parser - A function that parses a string into a JavaScript object.
2061
- * @param {Function} encoder - A function that takes a value and returns a string.
2062
- *
2063
- * @returns {string} A stringified version of the rawValue.
2064
- */
2065
- function stringifySafely(rawValue, parser, encoder) {
2066
- if (utils$1.isString(rawValue)) {
2067
- try {
2068
- (parser || JSON.parse)(rawValue);
2069
- return utils$1.trim(rawValue);
2070
- } catch (e) {
2071
- if (e.name !== 'SyntaxError') {
2072
- throw e;
2073
- }
2074
- }
2060
+ // eslint-disable-next-line no-param-reassign
2061
+ options = utils$1.toFlatObject(options, {
2062
+ metaTokens: true,
2063
+ dots: false,
2064
+ indexes: false
2065
+ }, false, function defined(option, source) {
2066
+ // eslint-disable-next-line no-eq-null,eqeqeq
2067
+ return !utils$1.isUndefined(source[option]);
2068
+ });
2069
+ var metaTokens = options.metaTokens;
2070
+ // eslint-disable-next-line no-use-before-define
2071
+ var visitor = options.visitor || defaultVisitor;
2072
+ var dots = options.dots;
2073
+ var indexes = options.indexes;
2074
+ var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
2075
+ var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
2076
+ var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
2077
+ if (!utils$1.isFunction(visitor)) {
2078
+ throw new TypeError('visitor must be a function');
2075
2079
  }
2076
- return (encoder || JSON.stringify)(rawValue);
2077
- }
2078
- var defaults = {
2079
- transitional: transitionalDefaults,
2080
- adapter: ['xhr', 'http', 'fetch'],
2081
- transformRequest: [function transformRequest(data, headers) {
2082
- var contentType = headers.getContentType() || '';
2083
- var hasJSONContentType = contentType.indexOf('application/json') > -1;
2084
- var isObjectPayload = utils$1.isObject(data);
2085
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
2086
- data = new FormData(data);
2080
+ function convertValue(value) {
2081
+ if (value === null) return '';
2082
+ if (utils$1.isDate(value)) {
2083
+ return value.toISOString();
2087
2084
  }
2088
- var isFormData = utils$1.isFormData(data);
2089
- if (isFormData) {
2090
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2085
+ if (utils$1.isBoolean(value)) {
2086
+ return value.toString();
2091
2087
  }
2092
- if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
2093
- return data;
2088
+ if (!useBlob && utils$1.isBlob(value)) {
2089
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
2094
2090
  }
2095
- if (utils$1.isArrayBufferView(data)) {
2096
- return data.buffer;
2091
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
2092
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
2097
2093
  }
2098
- if (utils$1.isURLSearchParams(data)) {
2099
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2100
- return data.toString();
2094
+ return value;
2095
+ }
2096
+
2097
+ /**
2098
+ * Default visitor.
2099
+ *
2100
+ * @param {*} value
2101
+ * @param {String|Number} key
2102
+ * @param {Array<String|Number>} path
2103
+ * @this {FormData}
2104
+ *
2105
+ * @returns {boolean} return true to visit the each prop of the value recursively
2106
+ */
2107
+ function defaultVisitor(value, key, path) {
2108
+ var arr = value;
2109
+ if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
2110
+ formData.append(renderKey(path, key, dots), convertValue(value));
2111
+ return false;
2101
2112
  }
2102
- var isFileList;
2103
- if (isObjectPayload) {
2104
- var formSerializer = own(this, 'formSerializer');
2105
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2106
- return toURLEncodedForm(data, formSerializer).toString();
2107
- }
2108
- if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
2109
- var env = own(this, 'env');
2110
- var _FormData = env && env.FormData;
2111
- return toFormData(isFileList ? {
2112
- 'files[]': data
2113
- } : data, _FormData && new _FormData(), formSerializer);
2113
+ if (value && !path && _typeof(value) === 'object') {
2114
+ if (utils$1.endsWith(key, '{}')) {
2115
+ // eslint-disable-next-line no-param-reassign
2116
+ key = metaTokens ? key : key.slice(0, -2);
2117
+ // eslint-disable-next-line no-param-reassign
2118
+ value = JSON.stringify(value);
2119
+ } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
2120
+ // eslint-disable-next-line no-param-reassign
2121
+ key = removeBrackets(key);
2122
+ arr.forEach(function each(el, index) {
2123
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
2124
+ // eslint-disable-next-line no-nested-ternary
2125
+ indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
2126
+ });
2127
+ return false;
2114
2128
  }
2115
2129
  }
2116
- if (isObjectPayload || hasJSONContentType) {
2117
- headers.setContentType('application/json', false);
2118
- return stringifySafely(data);
2119
- }
2120
- return data;
2121
- }],
2122
- transformResponse: [function transformResponse(data) {
2123
- var transitional = own(this, 'transitional') || defaults.transitional;
2124
- var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2125
- var responseType = own(this, 'responseType');
2126
- var JSONRequested = responseType === 'json';
2127
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2128
- return data;
2130
+ if (isVisitable(value)) {
2131
+ return true;
2129
2132
  }
2130
- if (data && utils$1.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
2131
- var silentJSONParsing = transitional && transitional.silentJSONParsing;
2132
- var strictJSONParsing = !silentJSONParsing && JSONRequested;
2133
- try {
2134
- return JSON.parse(data, own(this, 'parseReviver'));
2135
- } catch (e) {
2136
- if (strictJSONParsing) {
2137
- if (e.name === 'SyntaxError') {
2138
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
2139
- }
2140
- throw e;
2141
- }
2142
- }
2133
+ formData.append(renderKey(path, key, dots), convertValue(value));
2134
+ return false;
2135
+ }
2136
+ var stack = [];
2137
+ var exposedHelpers = Object.assign(predicates, {
2138
+ defaultVisitor: defaultVisitor,
2139
+ convertValue: convertValue,
2140
+ isVisitable: isVisitable
2141
+ });
2142
+ function build(value, path) {
2143
+ var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2144
+ if (utils$1.isUndefined(value)) return;
2145
+ if (depth > maxDepth) {
2146
+ throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
2143
2147
  }
2144
- return data;
2145
- }],
2146
- /**
2147
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
2148
- * timeout is not created.
2149
- */
2150
- timeout: 0,
2151
- xsrfCookieName: 'XSRF-TOKEN',
2152
- xsrfHeaderName: 'X-XSRF-TOKEN',
2153
- maxContentLength: -1,
2154
- maxBodyLength: -1,
2155
- env: {
2156
- FormData: platform.classes.FormData,
2157
- Blob: platform.classes.Blob
2158
- },
2159
- validateStatus: function validateStatus(status) {
2160
- return status >= 200 && status < 300;
2161
- },
2162
- headers: {
2163
- common: {
2164
- Accept: 'application/json, text/plain, */*',
2165
- 'Content-Type': undefined
2148
+ if (stack.indexOf(value) !== -1) {
2149
+ throw Error('Circular reference detected in ' + path.join('.'));
2166
2150
  }
2151
+ stack.push(value);
2152
+ utils$1.forEach(value, function each(el, key) {
2153
+ var result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
2154
+ if (result === true) {
2155
+ build(el, path ? path.concat(key) : [key], depth + 1);
2156
+ }
2157
+ });
2158
+ stack.pop();
2167
2159
  }
2168
- };
2169
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], function (method) {
2170
- defaults.headers[method] = {};
2171
- });
2172
-
2173
- // RawAxiosHeaders whose duplicates are ignored by node
2174
- // c.f. https://nodejs.org/api/http.html#http_message_headers
2175
- var ignoreDuplicateOf = utils$1.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
2160
+ if (!utils$1.isObject(obj)) {
2161
+ throw new TypeError('data must be an object');
2162
+ }
2163
+ build(obj);
2164
+ return formData;
2165
+ }
2176
2166
 
2177
2167
  /**
2178
- * Parse headers into an object
2179
- *
2180
- * ```
2181
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
2182
- * Content-Type: application/json
2183
- * Connection: keep-alive
2184
- * Transfer-Encoding: chunked
2185
- * ```
2168
+ * It encodes a string by replacing all characters that are not in the unreserved set with
2169
+ * their percent-encoded equivalents
2186
2170
  *
2187
- * @param {String} rawHeaders Headers needing to be parsed
2171
+ * @param {string} str - The string to encode.
2188
2172
  *
2189
- * @returns {Object} Headers parsed into an object
2173
+ * @returns {string} The encoded string.
2190
2174
  */
2191
- var parseHeaders = (function (rawHeaders) {
2192
- var parsed = {};
2193
- var key;
2194
- var val;
2195
- var i;
2196
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
2197
- i = line.indexOf(':');
2198
- key = line.substring(0, i).trim().toLowerCase();
2199
- val = line.substring(i + 1).trim();
2200
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
2201
- return;
2202
- }
2203
- if (key === 'set-cookie') {
2204
- if (parsed[key]) {
2205
- parsed[key].push(val);
2206
- } else {
2207
- parsed[key] = [val];
2208
- }
2209
- } else {
2210
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
2211
- }
2175
+ function encode$1(str) {
2176
+ var charMap = {
2177
+ '!': '%21',
2178
+ "'": '%27',
2179
+ '(': '%28',
2180
+ ')': '%29',
2181
+ '~': '%7E',
2182
+ '%20': '+'
2183
+ };
2184
+ return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
2185
+ return charMap[match];
2212
2186
  });
2213
- return parsed;
2214
- });
2215
-
2216
- var $internals = Symbol('internals');
2217
- var INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
2218
- function trimSPorHTAB(str) {
2219
- var start = 0;
2220
- var end = str.length;
2221
- while (start < end) {
2222
- var code = str.charCodeAt(start);
2223
- if (code !== 0x09 && code !== 0x20) {
2224
- break;
2225
- }
2226
- start += 1;
2227
- }
2228
- while (end > start) {
2229
- var _code = str.charCodeAt(end - 1);
2230
- if (_code !== 0x09 && _code !== 0x20) {
2231
- break;
2232
- }
2233
- end -= 1;
2234
- }
2235
- return start === 0 && end === str.length ? str : str.slice(start, end);
2236
- }
2237
- function normalizeHeader(header) {
2238
- return header && String(header).trim().toLowerCase();
2239
- }
2240
- function sanitizeHeaderValue(str) {
2241
- return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
2242
- }
2243
- function normalizeValue(value) {
2244
- if (value === false || value == null) {
2245
- return value;
2246
- }
2247
- return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
2248
2187
  }
2249
- function parseTokens(str) {
2250
- var tokens = Object.create(null);
2251
- var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
2252
- var match;
2253
- while (match = tokensRE.exec(str)) {
2254
- tokens[match[1]] = match[2];
2255
- }
2256
- return tokens;
2188
+
2189
+ /**
2190
+ * It takes a params object and converts it to a FormData object
2191
+ *
2192
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
2193
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
2194
+ *
2195
+ * @returns {void}
2196
+ */
2197
+ function AxiosURLSearchParams(params, options) {
2198
+ this._pairs = [];
2199
+ params && toFormData(params, this, options);
2257
2200
  }
2258
- var isValidHeaderName = function isValidHeaderName(str) {
2259
- return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2201
+ var prototype = AxiosURLSearchParams.prototype;
2202
+ prototype.append = function append(name, value) {
2203
+ this._pairs.push([name, value]);
2260
2204
  };
2261
- function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
2262
- if (utils$1.isFunction(filter)) {
2263
- return filter.call(this, value, header);
2264
- }
2265
- if (isHeaderNameFilter) {
2266
- value = header;
2205
+ prototype.toString = function toString(encoder) {
2206
+ var _encode = encoder ? function (value) {
2207
+ return encoder.call(this, value, encode$1);
2208
+ } : encode$1;
2209
+ return this._pairs.map(function each(pair) {
2210
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
2211
+ }, '').join('&');
2212
+ };
2213
+
2214
+ /**
2215
+ * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
2216
+ * their plain counterparts (`:`, `$`, `,`, `+`).
2217
+ *
2218
+ * @param {string} val The value to be encoded.
2219
+ *
2220
+ * @returns {string} The encoded value.
2221
+ */
2222
+ function encode(val) {
2223
+ return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
2224
+ }
2225
+
2226
+ /**
2227
+ * Build a URL by appending params to the end
2228
+ *
2229
+ * @param {string} url The base of the url (e.g., http://www.google.com)
2230
+ * @param {object} [params] The params to be appended
2231
+ * @param {?(object|Function)} options
2232
+ *
2233
+ * @returns {string} The formatted url
2234
+ */
2235
+ function buildURL(url, params, options) {
2236
+ if (!params) {
2237
+ return url;
2267
2238
  }
2268
- if (!utils$1.isString(value)) return;
2269
- if (utils$1.isString(filter)) {
2270
- return value.indexOf(filter) !== -1;
2239
+ var _encode = options && options.encode || encode;
2240
+ var _options = utils$1.isFunction(options) ? {
2241
+ serialize: options
2242
+ } : options;
2243
+ var serializeFn = _options && _options.serialize;
2244
+ var serializedParams;
2245
+ if (serializeFn) {
2246
+ serializedParams = serializeFn(params, _options);
2247
+ } else {
2248
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
2271
2249
  }
2272
- if (utils$1.isRegExp(filter)) {
2273
- return filter.test(value);
2250
+ if (serializedParams) {
2251
+ var hashmarkIndex = url.indexOf('#');
2252
+ if (hashmarkIndex !== -1) {
2253
+ url = url.slice(0, hashmarkIndex);
2254
+ }
2255
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
2274
2256
  }
2257
+ return url;
2275
2258
  }
2276
- function formatHeader(header) {
2277
- return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
2278
- return _char.toUpperCase() + str;
2279
- });
2280
- }
2281
- function buildAccessors(obj, header) {
2282
- var accessorName = utils$1.toCamelCase(' ' + header);
2283
- ['get', 'set', 'has'].forEach(function (methodName) {
2284
- Object.defineProperty(obj, methodName + accessorName, {
2285
- value: function value(arg1, arg2, arg3) {
2286
- return this[methodName].call(this, header, arg1, arg2, arg3);
2287
- },
2288
- configurable: true
2289
- });
2290
- });
2291
- }
2292
- var AxiosHeaders = /*#__PURE__*/function () {
2293
- function AxiosHeaders(headers) {
2294
- _classCallCheck(this, AxiosHeaders);
2295
- headers && this.set(headers);
2259
+
2260
+ var InterceptorManager = /*#__PURE__*/function () {
2261
+ function InterceptorManager() {
2262
+ _classCallCheck(this, InterceptorManager);
2263
+ this.handlers = [];
2296
2264
  }
2297
- return _createClass(AxiosHeaders, [{
2298
- key: "set",
2299
- value: function set(header, valueOrRewrite, rewrite) {
2300
- var self = this;
2301
- function setHeader(_value, _header, _rewrite) {
2302
- var lHeader = normalizeHeader(_header);
2303
- if (!lHeader) {
2304
- throw new Error('header name must be a non-empty string');
2305
- }
2306
- var key = utils$1.findKey(self, lHeader);
2307
- if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
2308
- self[key || _header] = normalizeValue(_value);
2309
- }
2310
- }
2311
- var setHeaders = function setHeaders(headers, _rewrite) {
2312
- return utils$1.forEach(headers, function (_value, _header) {
2313
- return setHeader(_value, _header, _rewrite);
2314
- });
2315
- };
2316
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
2317
- setHeaders(header, valueOrRewrite);
2318
- } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2319
- setHeaders(parseHeaders(header), valueOrRewrite);
2320
- } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
2321
- var obj = {},
2322
- dest,
2323
- key;
2324
- var _iterator = _createForOfIteratorHelper(header),
2325
- _step;
2326
- try {
2327
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2328
- var entry = _step.value;
2329
- if (!utils$1.isArray(entry)) {
2330
- throw TypeError('Object iterator must return a key-value pair');
2331
- }
2332
- obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]] : entry[1];
2333
- }
2334
- } catch (err) {
2335
- _iterator.e(err);
2336
- } finally {
2337
- _iterator.f();
2338
- }
2339
- setHeaders(obj, valueOrRewrite);
2340
- } else {
2341
- header != null && setHeader(valueOrRewrite, header, rewrite);
2265
+
2266
+ /**
2267
+ * Add a new interceptor to the stack
2268
+ *
2269
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
2270
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
2271
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
2272
+ *
2273
+ * @return {Number} An ID used to remove interceptor later
2274
+ */
2275
+ return _createClass(InterceptorManager, [{
2276
+ key: "use",
2277
+ value: function use(fulfilled, rejected, options) {
2278
+ this.handlers.push({
2279
+ fulfilled: fulfilled,
2280
+ rejected: rejected,
2281
+ synchronous: options ? options.synchronous : false,
2282
+ runWhen: options ? options.runWhen : null
2283
+ });
2284
+ return this.handlers.length - 1;
2285
+ }
2286
+
2287
+ /**
2288
+ * Remove an interceptor from the stack
2289
+ *
2290
+ * @param {Number} id The ID that was returned by `use`
2291
+ *
2292
+ * @returns {void}
2293
+ */
2294
+ }, {
2295
+ key: "eject",
2296
+ value: function eject(id) {
2297
+ if (this.handlers[id]) {
2298
+ this.handlers[id] = null;
2342
2299
  }
2343
- return this;
2344
2300
  }
2301
+
2302
+ /**
2303
+ * Clear all interceptors from the stack
2304
+ *
2305
+ * @returns {void}
2306
+ */
2345
2307
  }, {
2346
- key: "get",
2347
- value: function get(header, parser) {
2348
- header = normalizeHeader(header);
2349
- if (header) {
2350
- var key = utils$1.findKey(this, header);
2351
- if (key) {
2352
- var value = this[key];
2353
- if (!parser) {
2354
- return value;
2355
- }
2356
- if (parser === true) {
2357
- return parseTokens(value);
2358
- }
2359
- if (utils$1.isFunction(parser)) {
2360
- return parser.call(this, value, key);
2361
- }
2362
- if (utils$1.isRegExp(parser)) {
2363
- return parser.exec(value);
2364
- }
2365
- throw new TypeError('parser must be boolean|regexp|function');
2366
- }
2367
- }
2368
- }
2369
- }, {
2370
- key: "has",
2371
- value: function has(header, matcher) {
2372
- header = normalizeHeader(header);
2373
- if (header) {
2374
- var key = utils$1.findKey(this, header);
2375
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
2308
+ key: "clear",
2309
+ value: function clear() {
2310
+ if (this.handlers) {
2311
+ this.handlers = [];
2376
2312
  }
2377
- return false;
2378
2313
  }
2314
+
2315
+ /**
2316
+ * Iterate over all the registered interceptors
2317
+ *
2318
+ * This method is particularly useful for skipping over any
2319
+ * interceptors that may have become `null` calling `eject`.
2320
+ *
2321
+ * @param {Function} fn The function to call for each interceptor
2322
+ *
2323
+ * @returns {void}
2324
+ */
2379
2325
  }, {
2380
- key: "delete",
2381
- value: function _delete(header, matcher) {
2382
- var self = this;
2383
- var deleted = false;
2384
- function deleteHeader(_header) {
2385
- _header = normalizeHeader(_header);
2386
- if (_header) {
2387
- var key = utils$1.findKey(self, _header);
2388
- if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
2389
- delete self[key];
2390
- deleted = true;
2391
- }
2326
+ key: "forEach",
2327
+ value: function forEach(fn) {
2328
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
2329
+ if (h !== null) {
2330
+ fn(h);
2392
2331
  }
2332
+ });
2333
+ }
2334
+ }]);
2335
+ }();
2336
+
2337
+ var transitionalDefaults = {
2338
+ silentJSONParsing: true,
2339
+ forcedJSONParsing: true,
2340
+ clarifyTimeoutError: false,
2341
+ legacyInterceptorReqResOrdering: true
2342
+ };
2343
+
2344
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
2345
+
2346
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
2347
+
2348
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
2349
+
2350
+ var platform$1 = {
2351
+ isBrowser: true,
2352
+ classes: {
2353
+ URLSearchParams: URLSearchParams$1,
2354
+ FormData: FormData$1,
2355
+ Blob: Blob$1
2356
+ },
2357
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
2358
+ };
2359
+
2360
+ var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2361
+ var _navigator = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator || undefined;
2362
+
2363
+ /**
2364
+ * Determine if we're running in a standard browser environment
2365
+ *
2366
+ * This allows axios to run in a web worker, and react-native.
2367
+ * Both environments support XMLHttpRequest, but not fully standard globals.
2368
+ *
2369
+ * web workers:
2370
+ * typeof window -> undefined
2371
+ * typeof document -> undefined
2372
+ *
2373
+ * react-native:
2374
+ * navigator.product -> 'ReactNative'
2375
+ * nativescript
2376
+ * navigator.product -> 'NativeScript' or 'NS'
2377
+ *
2378
+ * @returns {boolean}
2379
+ */
2380
+ var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
2381
+
2382
+ /**
2383
+ * Determine if we're running in a standard browser webWorker environment
2384
+ *
2385
+ * Although the `isStandardBrowserEnv` method indicates that
2386
+ * `allows axios to run in a web worker`, the WebWorker will still be
2387
+ * filtered out due to its judgment standard
2388
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
2389
+ * This leads to a problem when axios post `FormData` in webWorker
2390
+ */
2391
+ var hasStandardBrowserWebWorkerEnv = function () {
2392
+ return typeof WorkerGlobalScope !== 'undefined' &&
2393
+ // eslint-disable-next-line no-undef
2394
+ self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
2395
+ }();
2396
+ var origin = hasBrowserEnv && window.location.href || 'http://localhost';
2397
+
2398
+ var utils = /*#__PURE__*/Object.freeze({
2399
+ __proto__: null,
2400
+ hasBrowserEnv: hasBrowserEnv,
2401
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
2402
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2403
+ navigator: _navigator,
2404
+ origin: origin
2405
+ });
2406
+
2407
+ var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
2408
+
2409
+ function toURLEncodedForm(data, options) {
2410
+ return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
2411
+ visitor: function visitor(value, key, path, helpers) {
2412
+ if (platform.isNode && utils$1.isBuffer(value)) {
2413
+ this.append(key, value.toString('base64'));
2414
+ return false;
2393
2415
  }
2394
- if (utils$1.isArray(header)) {
2395
- header.forEach(deleteHeader);
2416
+ return helpers.defaultVisitor.apply(this, arguments);
2417
+ }
2418
+ }, options));
2419
+ }
2420
+
2421
+ /**
2422
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
2423
+ *
2424
+ * @param {string} name - The name of the property to get.
2425
+ *
2426
+ * @returns An array of strings.
2427
+ */
2428
+ function parsePropPath(name) {
2429
+ // foo[x][y][z]
2430
+ // foo.x.y.z
2431
+ // foo-x-y-z
2432
+ // foo x y z
2433
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
2434
+ return match[0] === '[]' ? '' : match[1] || match[0];
2435
+ });
2436
+ }
2437
+
2438
+ /**
2439
+ * Convert an array to an object.
2440
+ *
2441
+ * @param {Array<any>} arr - The array to convert to an object.
2442
+ *
2443
+ * @returns An object with the same keys and values as the array.
2444
+ */
2445
+ function arrayToObject(arr) {
2446
+ var obj = {};
2447
+ var keys = Object.keys(arr);
2448
+ var i;
2449
+ var len = keys.length;
2450
+ var key;
2451
+ for (i = 0; i < len; i++) {
2452
+ key = keys[i];
2453
+ obj[key] = arr[key];
2454
+ }
2455
+ return obj;
2456
+ }
2457
+
2458
+ /**
2459
+ * It takes a FormData object and returns a JavaScript object
2460
+ *
2461
+ * @param {string} formData The FormData object to convert to JSON.
2462
+ *
2463
+ * @returns {Object<string, any> | null} The converted object.
2464
+ */
2465
+ function formDataToJSON(formData) {
2466
+ function buildPath(path, value, target, index) {
2467
+ var name = path[index++];
2468
+ if (name === '__proto__') return true;
2469
+ var isNumericKey = Number.isFinite(+name);
2470
+ var isLast = index >= path.length;
2471
+ name = !name && utils$1.isArray(target) ? target.length : name;
2472
+ if (isLast) {
2473
+ if (utils$1.hasOwnProp(target, name)) {
2474
+ target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
2396
2475
  } else {
2397
- deleteHeader(header);
2476
+ target[name] = value;
2398
2477
  }
2399
- return deleted;
2478
+ return !isNumericKey;
2400
2479
  }
2401
- }, {
2402
- key: "clear",
2403
- value: function clear(matcher) {
2404
- var keys = Object.keys(this);
2405
- var i = keys.length;
2406
- var deleted = false;
2407
- while (i--) {
2408
- var key = keys[i];
2409
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2410
- delete this[key];
2411
- deleted = true;
2412
- }
2413
- }
2414
- return deleted;
2480
+ if (!target[name] || !utils$1.isObject(target[name])) {
2481
+ target[name] = [];
2415
2482
  }
2416
- }, {
2417
- key: "normalize",
2418
- value: function normalize(format) {
2419
- var self = this;
2420
- var headers = {};
2421
- utils$1.forEach(this, function (value, header) {
2422
- var key = utils$1.findKey(headers, header);
2423
- if (key) {
2424
- self[key] = normalizeValue(value);
2425
- delete self[header];
2426
- return;
2427
- }
2428
- var normalized = format ? formatHeader(header) : String(header).trim();
2429
- if (normalized !== header) {
2430
- delete self[header];
2431
- }
2432
- self[normalized] = normalizeValue(value);
2433
- headers[normalized] = true;
2434
- });
2435
- return this;
2483
+ var result = buildPath(path, value, target[name], index);
2484
+ if (result && utils$1.isArray(target[name])) {
2485
+ target[name] = arrayToObject(target[name]);
2436
2486
  }
2437
- }, {
2438
- key: "concat",
2439
- value: function concat() {
2440
- var _this$constructor;
2441
- for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
2442
- targets[_key] = arguments[_key];
2487
+ return !isNumericKey;
2488
+ }
2489
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
2490
+ var obj = {};
2491
+ utils$1.forEachEntry(formData, function (name, value) {
2492
+ buildPath(parsePropPath(name), value, obj, 0);
2493
+ });
2494
+ return obj;
2495
+ }
2496
+ return null;
2497
+ }
2498
+
2499
+ var own = function own(obj, key) {
2500
+ return obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
2501
+ };
2502
+
2503
+ /**
2504
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2505
+ * of the input
2506
+ *
2507
+ * @param {any} rawValue - The value to be stringified.
2508
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
2509
+ * @param {Function} encoder - A function that takes a value and returns a string.
2510
+ *
2511
+ * @returns {string} A stringified version of the rawValue.
2512
+ */
2513
+ function stringifySafely(rawValue, parser, encoder) {
2514
+ if (utils$1.isString(rawValue)) {
2515
+ try {
2516
+ (parser || JSON.parse)(rawValue);
2517
+ return utils$1.trim(rawValue);
2518
+ } catch (e) {
2519
+ if (e.name !== 'SyntaxError') {
2520
+ throw e;
2443
2521
  }
2444
- return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
2445
2522
  }
2446
- }, {
2447
- key: "toJSON",
2448
- value: function toJSON(asStrings) {
2449
- var obj = Object.create(null);
2450
- utils$1.forEach(this, function (value, header) {
2451
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
2452
- });
2453
- return obj;
2523
+ }
2524
+ return (encoder || JSON.stringify)(rawValue);
2525
+ }
2526
+ var defaults = {
2527
+ transitional: transitionalDefaults,
2528
+ adapter: ['xhr', 'http', 'fetch'],
2529
+ transformRequest: [function transformRequest(data, headers) {
2530
+ var contentType = headers.getContentType() || '';
2531
+ var hasJSONContentType = contentType.indexOf('application/json') > -1;
2532
+ var isObjectPayload = utils$1.isObject(data);
2533
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
2534
+ data = new FormData(data);
2535
+ }
2536
+ var isFormData = utils$1.isFormData(data);
2537
+ if (isFormData) {
2538
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2454
2539
  }
2455
- }, {
2456
- key: Symbol.iterator,
2457
- value: function value() {
2458
- return Object.entries(this.toJSON())[Symbol.iterator]();
2540
+ if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
2541
+ return data;
2459
2542
  }
2460
- }, {
2461
- key: "toString",
2462
- value: function toString() {
2463
- return Object.entries(this.toJSON()).map(function (_ref) {
2464
- var _ref2 = _slicedToArray(_ref, 2),
2465
- header = _ref2[0],
2466
- value = _ref2[1];
2467
- return header + ': ' + value;
2468
- }).join('\n');
2543
+ if (utils$1.isArrayBufferView(data)) {
2544
+ return data.buffer;
2469
2545
  }
2470
- }, {
2471
- key: "getSetCookie",
2472
- value: function getSetCookie() {
2473
- return this.get('set-cookie') || [];
2546
+ if (utils$1.isURLSearchParams(data)) {
2547
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2548
+ return data.toString();
2474
2549
  }
2475
- }, {
2476
- key: Symbol.toStringTag,
2477
- get: function get() {
2478
- return 'AxiosHeaders';
2550
+ var isFileList;
2551
+ if (isObjectPayload) {
2552
+ var formSerializer = own(this, 'formSerializer');
2553
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2554
+ return toURLEncodedForm(data, formSerializer).toString();
2555
+ }
2556
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
2557
+ var env = own(this, 'env');
2558
+ var _FormData = env && env.FormData;
2559
+ return toFormData(isFileList ? {
2560
+ 'files[]': data
2561
+ } : data, _FormData && new _FormData(), formSerializer);
2562
+ }
2479
2563
  }
2480
- }], [{
2481
- key: "from",
2482
- value: function from(thing) {
2483
- return thing instanceof this ? thing : new this(thing);
2564
+ if (isObjectPayload || hasJSONContentType) {
2565
+ headers.setContentType('application/json', false);
2566
+ return stringifySafely(data);
2484
2567
  }
2485
- }, {
2486
- key: "concat",
2487
- value: function concat(first) {
2488
- var computed = new this(first);
2489
- for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2490
- targets[_key2 - 1] = arguments[_key2];
2491
- }
2492
- targets.forEach(function (target) {
2493
- return computed.set(target);
2494
- });
2495
- return computed;
2568
+ return data;
2569
+ }],
2570
+ transformResponse: [function transformResponse(data) {
2571
+ var transitional = own(this, 'transitional') || defaults.transitional;
2572
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2573
+ var responseType = own(this, 'responseType');
2574
+ var JSONRequested = responseType === 'json';
2575
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2576
+ return data;
2496
2577
  }
2497
- }, {
2498
- key: "accessor",
2499
- value: function accessor(header) {
2500
- var internals = this[$internals] = this[$internals] = {
2501
- accessors: {}
2502
- };
2503
- var accessors = internals.accessors;
2504
- var prototype = this.prototype;
2505
- function defineAccessor(_header) {
2506
- var lHeader = normalizeHeader(_header);
2507
- if (!accessors[lHeader]) {
2508
- buildAccessors(prototype, _header);
2509
- accessors[lHeader] = true;
2578
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
2579
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
2580
+ var strictJSONParsing = !silentJSONParsing && JSONRequested;
2581
+ try {
2582
+ return JSON.parse(data, own(this, 'parseReviver'));
2583
+ } catch (e) {
2584
+ if (strictJSONParsing) {
2585
+ if (e.name === 'SyntaxError') {
2586
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
2587
+ }
2588
+ throw e;
2510
2589
  }
2511
2590
  }
2512
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2513
- return this;
2514
2591
  }
2515
- }]);
2516
- }();
2517
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
2518
-
2519
- // reserved names hotfix
2520
- utils$1.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
2521
- var value = _ref3.value;
2522
- var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2523
- return {
2524
- get: function get() {
2525
- return value;
2526
- },
2527
- set: function set(headerValue) {
2528
- this[mapped] = headerValue;
2592
+ return data;
2593
+ }],
2594
+ /**
2595
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
2596
+ * timeout is not created.
2597
+ */
2598
+ timeout: 0,
2599
+ xsrfCookieName: 'XSRF-TOKEN',
2600
+ xsrfHeaderName: 'X-XSRF-TOKEN',
2601
+ maxContentLength: -1,
2602
+ maxBodyLength: -1,
2603
+ env: {
2604
+ FormData: platform.classes.FormData,
2605
+ Blob: platform.classes.Blob
2606
+ },
2607
+ validateStatus: function validateStatus(status) {
2608
+ return status >= 200 && status < 300;
2609
+ },
2610
+ headers: {
2611
+ common: {
2612
+ Accept: 'application/json, text/plain, */*',
2613
+ 'Content-Type': undefined
2529
2614
  }
2530
- };
2615
+ }
2616
+ };
2617
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], function (method) {
2618
+ defaults.headers[method] = {};
2531
2619
  });
2532
- utils$1.freezeMethods(AxiosHeaders);
2533
2620
 
2534
2621
  /**
2535
2622
  * Transform the data for a request or a response
@@ -2591,12 +2678,12 @@
2591
2678
  if (!response.status || !validateStatus || validateStatus(response.status)) {
2592
2679
  resolve(response);
2593
2680
  } else {
2594
- reject(new AxiosError('Request failed with status code ' + response.status, [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
2681
+ reject(new AxiosError('Request failed with status code ' + response.status, response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE, response.config, response.request, response));
2595
2682
  }
2596
2683
  }
2597
2684
 
2598
2685
  function parseProtocol(url) {
2599
- var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2686
+ var match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
2600
2687
  return match && match[1] || '';
2601
2688
  }
2602
2689
 
@@ -2764,8 +2851,20 @@
2764
2851
  },
2765
2852
  read: function read(name) {
2766
2853
  if (typeof document === 'undefined') return null;
2767
- var match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2768
- return match ? decodeURIComponent(match[1]) : null;
2854
+ // Match name=value by splitting on the semicolon separator instead of building a
2855
+ // RegExp from `name` interpolating an unescaped string into a RegExp would let
2856
+ // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
2857
+ // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
2858
+ // "; ", so ignore optional whitespace before each cookie name.
2859
+ var cookies = document.cookie.split(';');
2860
+ for (var i = 0; i < cookies.length; i++) {
2861
+ var cookie = cookies[i].replace(/^\s+/, '');
2862
+ var eq = cookie.indexOf('=');
2863
+ if (eq !== -1 && cookie.slice(0, eq) === name) {
2864
+ return decodeURIComponent(cookie.slice(eq + 1));
2865
+ }
2866
+ }
2867
+ return null;
2769
2868
  },
2770
2869
  remove: function remove(name) {
2771
2870
  this.write(name, '', Date.now() - 86400000, '/');
@@ -2845,11 +2944,14 @@
2845
2944
  config2 = config2 || {};
2846
2945
 
2847
2946
  // Use a null-prototype object so that downstream reads such as `config.auth`
2848
- // or `config.baseURL` cannot inherit polluted values from Object.prototype
2849
- // (see GHSA-q8qp-cvcw-x6jj). `hasOwnProperty` is restored as a non-enumerable
2850
- // own slot to preserve ergonomics for user code that relies on it.
2947
+ // or `config.baseURL` cannot inherit polluted values from Object.prototype.
2948
+ // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
2949
+ // ergonomics for user code that relies on it.
2851
2950
  var config = Object.create(null);
2852
2951
  Object.defineProperty(config, 'hasOwnProperty', {
2952
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
2953
+ // this data descriptor into an accessor descriptor on the way in.
2954
+ __proto__: null,
2853
2955
  value: Object.prototype.hasOwnProperty,
2854
2956
  enumerable: false,
2855
2957
  writable: true,
@@ -2944,11 +3046,40 @@
2944
3046
  return config;
2945
3047
  }
2946
3048
 
3049
+ var FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
3050
+ function setFormDataHeaders(headers, formHeaders, policy) {
3051
+ if (policy !== 'content-only') {
3052
+ headers.set(formHeaders);
3053
+ return;
3054
+ }
3055
+ Object.entries(formHeaders).forEach(function (_ref) {
3056
+ var _ref2 = _slicedToArray(_ref, 2),
3057
+ key = _ref2[0],
3058
+ val = _ref2[1];
3059
+ if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
3060
+ headers.set(key, val);
3061
+ }
3062
+ });
3063
+ }
3064
+
3065
+ /**
3066
+ * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
3067
+ * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
3068
+ *
3069
+ * @param {string} str The string to encode
3070
+ *
3071
+ * @returns {string} UTF-8 bytes as a Latin-1 string
3072
+ */
3073
+ var encodeUTF8 = function encodeUTF8(str) {
3074
+ return encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, function (_, hex) {
3075
+ return String.fromCharCode(parseInt(hex, 16));
3076
+ });
3077
+ };
2947
3078
  var resolveConfig = (function (config) {
2948
3079
  var newConfig = mergeConfig({}, config);
2949
3080
 
2950
3081
  // Read only own properties to prevent prototype pollution gadgets
2951
- // (e.g. Object.prototype.baseURL = 'https://evil.com'). See GHSA-q8qp-cvcw-x6jj.
3082
+ // (e.g. Object.prototype.baseURL = 'https://evil.com').
2952
3083
  var own = function own(key) {
2953
3084
  return utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined;
2954
3085
  };
@@ -2966,24 +3097,14 @@
2966
3097
 
2967
3098
  // HTTP basic authentication
2968
3099
  if (auth) {
2969
- headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')));
3100
+ headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : '')));
2970
3101
  }
2971
3102
  if (utils$1.isFormData(data)) {
2972
3103
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2973
3104
  headers.setContentType(undefined); // browser handles it
2974
3105
  } else if (utils$1.isFunction(data.getHeaders)) {
2975
3106
  // Node.js FormData (like form-data package)
2976
- var formHeaders = data.getHeaders();
2977
- // Only set safe headers to avoid overwriting security headers
2978
- var allowedHeaders = ['content-type', 'content-length'];
2979
- Object.entries(formHeaders).forEach(function (_ref) {
2980
- var _ref2 = _slicedToArray(_ref, 2),
2981
- key = _ref2[0],
2982
- val = _ref2[1];
2983
- if (allowedHeaders.includes(key.toLowerCase())) {
2984
- headers.set(key, val);
2985
- }
2986
- });
3107
+ setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
2987
3108
  }
2988
3109
  }
2989
3110
 
@@ -2998,7 +3119,7 @@
2998
3119
 
2999
3120
  // Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
3000
3121
  // and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
3001
- // the XSRF token cross-origin. See GHSA-xx6v-rp6x-q39c.
3122
+ // the XSRF token cross-origin.
3002
3123
  var shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
3003
3124
  if (shouldSendXSRF) {
3004
3125
  var xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
@@ -3074,7 +3195,7 @@
3074
3195
  // handled by onerror instead
3075
3196
  // With one exception: request that using file: protocol, most browsers
3076
3197
  // will return status as 0 even though it's a successful request
3077
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
3198
+ if (request.status === 0 && !(request.responseURL && request.responseURL.startsWith('file:'))) {
3078
3199
  return;
3079
3200
  }
3080
3201
  // readystate handler is calling before onerror or ontimeout handlers,
@@ -3089,6 +3210,7 @@
3089
3210
  return;
3090
3211
  }
3091
3212
  reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
3213
+ done();
3092
3214
 
3093
3215
  // Clean up request
3094
3216
  request = null;
@@ -3104,6 +3226,7 @@
3104
3226
  // attach the underlying event for consumers who want details
3105
3227
  err.event = event || null;
3106
3228
  reject(err);
3229
+ done();
3107
3230
  request = null;
3108
3231
  };
3109
3232
 
@@ -3115,6 +3238,7 @@
3115
3238
  timeoutErrorMessage = _config.timeoutErrorMessage;
3116
3239
  }
3117
3240
  reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
3241
+ done();
3118
3242
 
3119
3243
  // Clean up request
3120
3244
  request = null;
@@ -3167,6 +3291,7 @@
3167
3291
  }
3168
3292
  reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
3169
3293
  request.abort();
3294
+ done();
3170
3295
  request = null;
3171
3296
  };
3172
3297
  _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
@@ -3175,7 +3300,7 @@
3175
3300
  }
3176
3301
  }
3177
3302
  var protocol = parseProtocol(_config.url);
3178
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
3303
+ if (protocol && !platform.protocols.includes(protocol)) {
3179
3304
  reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
3180
3305
  return;
3181
3306
  }
@@ -3427,19 +3552,102 @@
3427
3552
  });
3428
3553
  };
3429
3554
 
3555
+ /**
3556
+ * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
3557
+ * - For base64: compute exact decoded size using length and padding;
3558
+ * handle %XX at the character-count level (no string allocation).
3559
+ * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
3560
+ *
3561
+ * @param {string} url
3562
+ * @returns {number}
3563
+ */
3564
+ function estimateDataURLDecodedBytes(url) {
3565
+ if (!url || typeof url !== 'string') return 0;
3566
+ if (!url.startsWith('data:')) return 0;
3567
+ var comma = url.indexOf(',');
3568
+ if (comma < 0) return 0;
3569
+ var meta = url.slice(5, comma);
3570
+ var body = url.slice(comma + 1);
3571
+ var isBase64 = /;base64/i.test(meta);
3572
+ if (isBase64) {
3573
+ var effectiveLen = body.length;
3574
+ var len = body.length; // cache length
3575
+
3576
+ for (var i = 0; i < len; i++) {
3577
+ if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
3578
+ var a = body.charCodeAt(i + 1);
3579
+ var b = body.charCodeAt(i + 2);
3580
+ var isHex = (a >= 48 && a <= 57 || a >= 65 && a <= 70 || a >= 97 && a <= 102) && (b >= 48 && b <= 57 || b >= 65 && b <= 70 || b >= 97 && b <= 102);
3581
+ if (isHex) {
3582
+ effectiveLen -= 2;
3583
+ i += 2;
3584
+ }
3585
+ }
3586
+ }
3587
+ var pad = 0;
3588
+ var idx = len - 1;
3589
+ var tailIsPct3D = function tailIsPct3D(j) {
3590
+ return j >= 2 && body.charCodeAt(j - 2) === 37 &&
3591
+ // '%'
3592
+ body.charCodeAt(j - 1) === 51 && (
3593
+ // '3'
3594
+ body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
3595
+ }; // 'D' or 'd'
3596
+
3597
+ if (idx >= 0) {
3598
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
3599
+ pad++;
3600
+ idx--;
3601
+ } else if (tailIsPct3D(idx)) {
3602
+ pad++;
3603
+ idx -= 3;
3604
+ }
3605
+ }
3606
+ if (pad === 1 && idx >= 0) {
3607
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
3608
+ pad++;
3609
+ } else if (tailIsPct3D(idx)) {
3610
+ pad++;
3611
+ }
3612
+ }
3613
+ var groups = Math.floor(effectiveLen / 4);
3614
+ var _bytes = groups * 3 - (pad || 0);
3615
+ return _bytes > 0 ? _bytes : 0;
3616
+ }
3617
+ if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
3618
+ return Buffer.byteLength(body, 'utf8');
3619
+ }
3620
+
3621
+ // Compute UTF-8 byte length directly from UTF-16 code units without allocating
3622
+ // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
3623
+ // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
3624
+ // but 3 UTF-8 bytes).
3625
+ var bytes = 0;
3626
+ for (var _i = 0, _len = body.length; _i < _len; _i++) {
3627
+ var c = body.charCodeAt(_i);
3628
+ if (c < 0x80) {
3629
+ bytes += 1;
3630
+ } else if (c < 0x800) {
3631
+ bytes += 2;
3632
+ } else if (c >= 0xd800 && c <= 0xdbff && _i + 1 < _len) {
3633
+ var next = body.charCodeAt(_i + 1);
3634
+ if (next >= 0xdc00 && next <= 0xdfff) {
3635
+ bytes += 4;
3636
+ _i++;
3637
+ } else {
3638
+ bytes += 3;
3639
+ }
3640
+ } else {
3641
+ bytes += 3;
3642
+ }
3643
+ }
3644
+ return bytes;
3645
+ }
3646
+
3647
+ var VERSION = "1.16.0";
3648
+
3430
3649
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
3431
3650
  var isFunction = utils$1.isFunction;
3432
- var globalFetchAPI = function (_ref) {
3433
- var Request = _ref.Request,
3434
- Response = _ref.Response;
3435
- return {
3436
- Request: Request,
3437
- Response: Response
3438
- };
3439
- }(utils$1.global);
3440
- var _utils$global = utils$1.global,
3441
- ReadableStream$1 = _utils$global.ReadableStream,
3442
- TextEncoder = _utils$global.TextEncoder;
3443
3651
  var test = function test(fn) {
3444
3652
  try {
3445
3653
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -3451,9 +3659,16 @@
3451
3659
  }
3452
3660
  };
3453
3661
  var factory = function factory(env) {
3662
+ var _utils$global;
3663
+ var globalObject = (_utils$global = utils$1.global) !== null && _utils$global !== void 0 ? _utils$global : globalThis;
3664
+ var ReadableStream = globalObject.ReadableStream,
3665
+ TextEncoder = globalObject.TextEncoder;
3454
3666
  env = utils$1.merge.call({
3455
3667
  skipUndefined: true
3456
- }, globalFetchAPI, env);
3668
+ }, {
3669
+ Request: globalObject.Request,
3670
+ Response: globalObject.Response
3671
+ }, env);
3457
3672
  var _env = env,
3458
3673
  envFetch = _env.fetch,
3459
3674
  Request = _env.Request,
@@ -3464,13 +3679,13 @@
3464
3679
  if (!isFetchSupported) {
3465
3680
  return false;
3466
3681
  }
3467
- var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
3682
+ var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
3468
3683
  var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
3469
3684
  return function (str) {
3470
3685
  return encoder.encode(str);
3471
3686
  };
3472
3687
  }(new TextEncoder()) : (/*#__PURE__*/function () {
3473
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(str) {
3688
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(str) {
3474
3689
  var _t, _t2;
3475
3690
  return _regenerator().w(function (_context) {
3476
3691
  while (1) switch (_context.n) {
@@ -3485,13 +3700,13 @@
3485
3700
  }, _callee);
3486
3701
  }));
3487
3702
  return function (_x) {
3488
- return _ref2.apply(this, arguments);
3703
+ return _ref.apply(this, arguments);
3489
3704
  };
3490
3705
  }()));
3491
3706
  var supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(function () {
3492
3707
  var duplexAccessed = false;
3493
3708
  var request = new Request(platform.origin, {
3494
- body: new ReadableStream$1(),
3709
+ body: new ReadableStream(),
3495
3710
  method: 'POST',
3496
3711
  get duplex() {
3497
3712
  duplexAccessed = true;
@@ -3524,7 +3739,7 @@
3524
3739
  });
3525
3740
  }();
3526
3741
  var getBodyLength = /*#__PURE__*/function () {
3527
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
3742
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
3528
3743
  var _request;
3529
3744
  return _regenerator().w(function (_context2) {
3530
3745
  while (1) switch (_context2.n) {
@@ -3577,11 +3792,11 @@
3577
3792
  }, _callee2);
3578
3793
  }));
3579
3794
  return function getBodyLength(_x2) {
3580
- return _ref3.apply(this, arguments);
3795
+ return _ref2.apply(this, arguments);
3581
3796
  };
3582
3797
  }();
3583
3798
  var resolveBodyLength = /*#__PURE__*/function () {
3584
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(headers, body) {
3799
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(headers, body) {
3585
3800
  var length;
3586
3801
  return _regenerator().w(function (_context3) {
3587
3802
  while (1) switch (_context3.n) {
@@ -3592,16 +3807,18 @@
3592
3807
  }, _callee3);
3593
3808
  }));
3594
3809
  return function resolveBodyLength(_x3, _x4) {
3595
- return _ref4.apply(this, arguments);
3810
+ return _ref3.apply(this, arguments);
3596
3811
  };
3597
3812
  }();
3598
3813
  return /*#__PURE__*/function () {
3599
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(config) {
3600
- var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, _fetch, composedSignal, request, unsubscribe, requestContentLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, contentType, resolvedOptions, response, isStreamResponse, options, responseContentLength, _ref6, _ref7, _onProgress, _flush, responseData, _t3, _t4, _t5;
3814
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(config) {
3815
+ var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, maxContentLength, maxBodyLength, hasMaxContentLength, hasMaxBodyLength, _fetch, composedSignal, request, unsubscribe, requestContentLength, estimated, outboundLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, contentType, resolvedOptions, response, declaredLength, isStreamResponse, options, responseContentLength, _ref5, _ref6, _onProgress, _flush, bytesRead, onChunkProgress, responseData, materializedSize, canceledError, _t3, _t4, _t5;
3601
3816
  return _regenerator().w(function (_context4) {
3602
3817
  while (1) switch (_context4.p = _context4.n) {
3603
3818
  case 0:
3604
- _resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions;
3819
+ _resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions, maxContentLength = _resolveConfig.maxContentLength, maxBodyLength = _resolveConfig.maxBodyLength;
3820
+ hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
3821
+ hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
3605
3822
  _fetch = envFetch || fetch;
3606
3823
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3607
3824
  composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
@@ -3610,19 +3827,44 @@
3610
3827
  composedSignal.unsubscribe();
3611
3828
  };
3612
3829
  _context4.p = 1;
3830
+ if (!(hasMaxContentLength && typeof url === 'string' && url.startsWith('data:'))) {
3831
+ _context4.n = 2;
3832
+ break;
3833
+ }
3834
+ estimated = estimateDataURLDecodedBytes(url);
3835
+ if (!(estimated > maxContentLength)) {
3836
+ _context4.n = 2;
3837
+ break;
3838
+ }
3839
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3840
+ case 2:
3841
+ if (!(hasMaxBodyLength && method !== 'get' && method !== 'head')) {
3842
+ _context4.n = 4;
3843
+ break;
3844
+ }
3845
+ _context4.n = 3;
3846
+ return resolveBodyLength(headers, data);
3847
+ case 3:
3848
+ outboundLength = _context4.v;
3849
+ if (!(typeof outboundLength === 'number' && isFinite(outboundLength) && outboundLength > maxBodyLength)) {
3850
+ _context4.n = 4;
3851
+ break;
3852
+ }
3853
+ throw new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
3854
+ case 4:
3613
3855
  _t3 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
3614
3856
  if (!_t3) {
3615
- _context4.n = 3;
3857
+ _context4.n = 6;
3616
3858
  break;
3617
3859
  }
3618
- _context4.n = 2;
3860
+ _context4.n = 5;
3619
3861
  return resolveBodyLength(headers, data);
3620
- case 2:
3862
+ case 5:
3621
3863
  _t4 = requestContentLength = _context4.v;
3622
3864
  _t3 = _t4 !== 0;
3623
- case 3:
3865
+ case 6:
3624
3866
  if (!_t3) {
3625
- _context4.n = 4;
3867
+ _context4.n = 7;
3626
3868
  break;
3627
3869
  }
3628
3870
  _request = new Request(url, {
@@ -3637,7 +3879,7 @@
3637
3879
  _progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
3638
3880
  data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3639
3881
  }
3640
- case 4:
3882
+ case 7:
3641
3883
  if (!utils$1.isString(withCredentials)) {
3642
3884
  withCredentials = withCredentials ? 'include' : 'omit';
3643
3885
  }
@@ -3652,6 +3894,9 @@
3652
3894
  headers["delete"]('content-type');
3653
3895
  }
3654
3896
  }
3897
+
3898
+ // Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
3899
+ headers.set('User-Agent', 'axios/' + VERSION, false);
3655
3900
  resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
3656
3901
  signal: composedSignal,
3657
3902
  method: method.toUpperCase(),
@@ -3661,30 +3906,70 @@
3661
3906
  credentials: isCredentialsSupported ? withCredentials : undefined
3662
3907
  });
3663
3908
  request = isRequestSupported && new Request(url, resolvedOptions);
3664
- _context4.n = 5;
3909
+ _context4.n = 8;
3665
3910
  return isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions);
3666
- case 5:
3911
+ case 8:
3667
3912
  response = _context4.v;
3913
+ if (!hasMaxContentLength) {
3914
+ _context4.n = 9;
3915
+ break;
3916
+ }
3917
+ declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3918
+ if (!(declaredLength != null && declaredLength > maxContentLength)) {
3919
+ _context4.n = 9;
3920
+ break;
3921
+ }
3922
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3923
+ case 9:
3668
3924
  isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3669
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
3925
+ if (supportsResponseStream && response.body && (onDownloadProgress || hasMaxContentLength || isStreamResponse && unsubscribe)) {
3670
3926
  options = {};
3671
3927
  ['status', 'statusText', 'headers'].forEach(function (prop) {
3672
3928
  options[prop] = response[prop];
3673
3929
  });
3674
3930
  responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3675
- _ref6 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref7 = _slicedToArray(_ref6, 2), _onProgress = _ref7[0], _flush = _ref7[1];
3676
- response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, _onProgress, function () {
3931
+ _ref5 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref6 = _slicedToArray(_ref5, 2), _onProgress = _ref6[0], _flush = _ref6[1];
3932
+ bytesRead = 0;
3933
+ onChunkProgress = function onChunkProgress(loadedBytes) {
3934
+ if (hasMaxContentLength) {
3935
+ bytesRead = loadedBytes;
3936
+ if (bytesRead > maxContentLength) {
3937
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3938
+ }
3939
+ }
3940
+ _onProgress && _onProgress(loadedBytes);
3941
+ };
3942
+ response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, function () {
3677
3943
  _flush && _flush();
3678
3944
  unsubscribe && unsubscribe();
3679
3945
  }), options);
3680
3946
  }
3681
3947
  responseType = responseType || 'text';
3682
- _context4.n = 6;
3948
+ _context4.n = 10;
3683
3949
  return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3684
- case 6:
3950
+ case 10:
3685
3951
  responseData = _context4.v;
3952
+ if (!(hasMaxContentLength && !supportsResponseStream && !isStreamResponse)) {
3953
+ _context4.n = 11;
3954
+ break;
3955
+ }
3956
+ if (responseData != null) {
3957
+ if (typeof responseData.byteLength === 'number') {
3958
+ materializedSize = responseData.byteLength;
3959
+ } else if (typeof responseData.size === 'number') {
3960
+ materializedSize = responseData.size;
3961
+ } else if (typeof responseData === 'string') {
3962
+ materializedSize = typeof TextEncoder === 'function' ? new TextEncoder().encode(responseData).byteLength : responseData.length;
3963
+ }
3964
+ }
3965
+ if (!(typeof materializedSize === 'number' && materializedSize > maxContentLength)) {
3966
+ _context4.n = 11;
3967
+ break;
3968
+ }
3969
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3970
+ case 11:
3686
3971
  !isStreamResponse && unsubscribe && unsubscribe();
3687
- _context4.n = 7;
3972
+ _context4.n = 12;
3688
3973
  return new Promise(function (resolve, reject) {
3689
3974
  settle(resolve, reject, {
3690
3975
  data: responseData,
@@ -3695,28 +3980,42 @@
3695
3980
  request: request
3696
3981
  });
3697
3982
  });
3698
- case 7:
3983
+ case 12:
3699
3984
  return _context4.a(2, _context4.v);
3700
- case 8:
3701
- _context4.p = 8;
3985
+ case 13:
3986
+ _context4.p = 13;
3702
3987
  _t5 = _context4.v;
3703
3988
  unsubscribe && unsubscribe();
3989
+
3990
+ // Safari can surface fetch aborts as a DOMException-like object whose
3991
+ // branded getters throw. Prefer our composed signal reason before reading
3992
+ // the caught error, preserving timeout vs cancellation semantics.
3993
+ if (!(composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError)) {
3994
+ _context4.n = 14;
3995
+ break;
3996
+ }
3997
+ canceledError = composedSignal.reason;
3998
+ canceledError.config = config;
3999
+ request && (canceledError.request = request);
4000
+ _t5 !== canceledError && (canceledError.cause = _t5);
4001
+ throw canceledError;
4002
+ case 14:
3704
4003
  if (!(_t5 && _t5.name === 'TypeError' && /Load failed|fetch/i.test(_t5.message))) {
3705
- _context4.n = 9;
4004
+ _context4.n = 15;
3706
4005
  break;
3707
4006
  }
3708
4007
  throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, _t5 && _t5.response), {
3709
4008
  cause: _t5.cause || _t5
3710
4009
  });
3711
- case 9:
4010
+ case 15:
3712
4011
  throw AxiosError.from(_t5, _t5 && _t5.code, config, request, _t5 && _t5.response);
3713
- case 10:
4012
+ case 16:
3714
4013
  return _context4.a(2);
3715
4014
  }
3716
- }, _callee4, null, [[1, 8]]);
4015
+ }, _callee4, null, [[1, 13]]);
3717
4016
  }));
3718
4017
  return function (_x5) {
3719
- return _ref5.apply(this, arguments);
4018
+ return _ref4.apply(this, arguments);
3720
4019
  };
3721
4020
  }();
3722
4021
  };
@@ -3763,13 +4062,17 @@
3763
4062
  utils$1.forEach(knownAdapters, function (fn, value) {
3764
4063
  if (fn) {
3765
4064
  try {
4065
+ // Null-proto descriptors so a polluted Object.prototype.get cannot turn
4066
+ // these data descriptors into accessor descriptors on the way in.
3766
4067
  Object.defineProperty(fn, 'name', {
4068
+ __proto__: null,
3767
4069
  value: value
3768
4070
  });
3769
4071
  } catch (e) {
3770
4072
  // eslint-disable-next-line no-empty
3771
4073
  }
3772
4074
  Object.defineProperty(fn, 'adapterName', {
4075
+ __proto__: null,
3773
4076
  value: value
3774
4077
  });
3775
4078
  }
@@ -3892,8 +4195,15 @@
3892
4195
  return adapter(config).then(function onAdapterResolution(response) {
3893
4196
  throwIfCancellationRequested(config);
3894
4197
 
3895
- // Transform response data
3896
- response.data = transformData.call(config, config.transformResponse, response);
4198
+ // Expose the current response on config so that transformResponse can
4199
+ // attach it to any AxiosError it throws (e.g. on JSON parse failure).
4200
+ // We clean it up afterwards to avoid polluting the config object.
4201
+ config.response = response;
4202
+ try {
4203
+ response.data = transformData.call(config, config.transformResponse, response);
4204
+ } finally {
4205
+ delete config.response;
4206
+ }
3897
4207
  response.headers = AxiosHeaders.from(response.headers);
3898
4208
  return response;
3899
4209
  }, function onAdapterRejection(reason) {
@@ -3902,7 +4212,12 @@
3902
4212
 
3903
4213
  // Transform response data
3904
4214
  if (reason && reason.response) {
3905
- reason.response.data = transformData.call(config, config.transformResponse, reason.response);
4215
+ config.response = reason.response;
4216
+ try {
4217
+ reason.response.data = transformData.call(config, config.transformResponse, reason.response);
4218
+ } finally {
4219
+ delete config.response;
4220
+ }
3906
4221
  reason.response.headers = AxiosHeaders.from(reason.response.headers);
3907
4222
  }
3908
4223
  }
@@ -3910,8 +4225,6 @@
3910
4225
  });
3911
4226
  }
3912
4227
 
3913
- var VERSION = "1.15.2";
3914
-
3915
4228
  var validators$1 = {};
3916
4229
 
3917
4230
  // eslint-disable-next-line func-names
@@ -3976,7 +4289,7 @@
3976
4289
  while (i-- > 0) {
3977
4290
  var opt = keys[i];
3978
4291
  // Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
3979
- // a non-function validator and cause a TypeError. See GHSA-q8qp-cvcw-x6jj.
4292
+ // a non-function validator and cause a TypeError.
3980
4293
  var validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
3981
4294
  if (validator) {
3982
4295
  var value = options[opt];
@@ -4131,7 +4444,7 @@
4131
4444
 
4132
4445
  // Flatten headers
4133
4446
  var contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
4134
- headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
4447
+ headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], function (method) {
4135
4448
  delete headers[method];
4136
4449
  });
4137
4450
  config.headers = AxiosHeaders.concat(contextHeaders, headers);
@@ -4213,7 +4526,7 @@
4213
4526
  }));
4214
4527
  };
4215
4528
  });
4216
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
4529
+ utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
4217
4530
  function generateHTTPMethod(isForm) {
4218
4531
  return function httpMethod(url, data, config) {
4219
4532
  return this.request(mergeConfig(config || {}, {
@@ -4227,7 +4540,12 @@
4227
4540
  };
4228
4541
  }
4229
4542
  Axios.prototype[method] = generateHTTPMethod();
4230
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
4543
+
4544
+ // QUERY is a safe/idempotent read method; multipart form bodies don't fit
4545
+ // its semantics, so no queryForm shorthand is generated.
4546
+ if (method !== 'query') {
4547
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
4548
+ }
4231
4549
  });
4232
4550
 
4233
4551
  /**