axios 1.15.2 → 1.16.1

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +103 -6
  2. package/README.md +396 -25
  3. package/dist/axios.js +1455 -1109
  4. package/dist/axios.js.map +1 -1
  5. package/dist/axios.min.js +3 -3
  6. package/dist/axios.min.js.map +1 -1
  7. package/dist/browser/axios.cjs +1569 -1174
  8. package/dist/browser/axios.cjs.map +1 -1
  9. package/dist/esm/axios.js +1569 -1173
  10. package/dist/esm/axios.js.map +1 -1
  11. package/dist/esm/axios.min.js +2 -2
  12. package/dist/esm/axios.min.js.map +1 -1
  13. package/dist/node/axios.cjs +1395 -915
  14. package/dist/node/axios.cjs.map +1 -1
  15. package/index.d.cts +25 -13
  16. package/index.d.ts +21 -4
  17. package/index.js +2 -0
  18. package/lib/adapters/adapters.js +4 -2
  19. package/lib/adapters/fetch.js +131 -11
  20. package/lib/adapters/http.js +298 -69
  21. package/lib/adapters/xhr.js +8 -3
  22. package/lib/core/Axios.js +7 -3
  23. package/lib/core/AxiosError.js +86 -1
  24. package/lib/core/AxiosHeaders.js +4 -33
  25. package/lib/core/dispatchRequest.js +19 -7
  26. package/lib/core/mergeConfig.js +6 -3
  27. package/lib/core/settle.js +7 -11
  28. package/lib/defaults/index.js +1 -1
  29. package/lib/env/data.js +1 -1
  30. package/lib/helpers/buildURL.js +1 -1
  31. package/lib/helpers/composeSignals.js +48 -47
  32. package/lib/helpers/cookies.js +14 -2
  33. package/lib/helpers/estimateDataURLDecodedBytes.js +28 -1
  34. package/lib/helpers/formDataToJSON.js +1 -1
  35. package/lib/helpers/formDataToStream.js +1 -1
  36. package/lib/helpers/fromDataURI.js +18 -5
  37. package/lib/helpers/parseProtocol.js +1 -1
  38. package/lib/helpers/progressEventReducer.js +3 -0
  39. package/lib/helpers/resolveConfig.js +33 -17
  40. package/lib/helpers/sanitizeHeaderValue.js +60 -0
  41. package/lib/helpers/shouldBypassProxy.js +26 -1
  42. package/lib/helpers/validator.js +1 -1
  43. package/lib/utils.js +35 -22
  44. package/package.json +19 -24
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.1 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];
@@ -1279,10 +1291,10 @@
1279
1291
  * @returns {Object} The JSON-compatible object.
1280
1292
  */
1281
1293
  var toJSONObject = function toJSONObject(obj) {
1282
- var stack = new Array(10);
1283
- var _visit = function visit(source, i) {
1294
+ var visited = new WeakSet();
1295
+ var _visit = function visit(source) {
1284
1296
  if (isObject(source)) {
1285
- if (stack.indexOf(source) >= 0) {
1297
+ if (visited.has(source)) {
1286
1298
  return;
1287
1299
  }
1288
1300
 
@@ -1291,19 +1303,20 @@
1291
1303
  return source;
1292
1304
  }
1293
1305
  if (!('toJSON' in source)) {
1294
- stack[i] = source;
1306
+ // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
1307
+ visited.add(source);
1295
1308
  var target = isArray(source) ? [] : {};
1296
1309
  forEach(source, function (value, key) {
1297
- var reducedValue = _visit(value, i + 1);
1310
+ var reducedValue = _visit(value);
1298
1311
  !isUndefined(reducedValue) && (target[key] = reducedValue);
1299
1312
  });
1300
- stack[i] = undefined;
1313
+ visited["delete"](source);
1301
1314
  return target;
1302
1315
  }
1303
1316
  }
1304
1317
  return source;
1305
1318
  };
1306
- return _visit(obj, 0);
1319
+ return _visit(obj);
1307
1320
  };
1308
1321
 
1309
1322
  /**
@@ -1432,1104 +1445,1203 @@
1432
1445
  isIterable: isIterable
1433
1446
  };
1434
1447
 
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;
1448
+ // RawAxiosHeaders whose duplicates are ignored by node
1449
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1450
+ 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']);
1526
1451
 
1527
1452
  /**
1528
- * Determines if the given thing is a array or js object.
1529
- *
1530
- * @param {string} thing - The object or array to be visited.
1453
+ * Parse headers into an object
1531
1454
  *
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
1455
+ * ```
1456
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1457
+ * Content-Type: application/json
1458
+ * Connection: keep-alive
1459
+ * Transfer-Encoding: chunked
1460
+ * ```
1540
1461
  *
1541
- * @param {string} key - The key of the parameter.
1462
+ * @param {String} rawHeaders Headers needing to be parsed
1542
1463
  *
1543
- * @returns {string} the key without the brackets.
1464
+ * @returns {Object} Headers parsed into an object
1544
1465
  */
1545
- function removeBrackets(key) {
1546
- return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1547
- }
1466
+ var parseHeaders = (function (rawHeaders) {
1467
+ var parsed = {};
1468
+ var key;
1469
+ var val;
1470
+ var i;
1471
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1472
+ i = line.indexOf(':');
1473
+ key = line.substring(0, i).trim().toLowerCase();
1474
+ val = line.substring(i + 1).trim();
1475
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1476
+ return;
1477
+ }
1478
+ if (key === 'set-cookie') {
1479
+ if (parsed[key]) {
1480
+ parsed[key].push(val);
1481
+ } else {
1482
+ parsed[key] = [val];
1483
+ }
1484
+ } else {
1485
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1486
+ }
1487
+ });
1488
+ return parsed;
1489
+ });
1548
1490
 
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 ? '.' : '');
1491
+ function trimSPorHTAB(str) {
1492
+ var start = 0;
1493
+ var end = str.length;
1494
+ while (start < end) {
1495
+ var code = str.charCodeAt(start);
1496
+ if (code !== 0x09 && code !== 0x20) {
1497
+ break;
1498
+ }
1499
+ start += 1;
1500
+ }
1501
+ while (end > start) {
1502
+ var _code = str.charCodeAt(end - 1);
1503
+ if (_code !== 0x09 && _code !== 0x20) {
1504
+ break;
1505
+ }
1506
+ end -= 1;
1507
+ }
1508
+ return start === 0 && end === str.length ? str : str.slice(start, end);
1565
1509
  }
1566
1510
 
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);
1511
+ // The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
1512
+ // eslint-disable-next-line no-control-regex
1513
+ var INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+", 'g');
1514
+ // eslint-disable-next-line no-control-regex
1515
+ var INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+", 'g');
1516
+ function sanitizeValue(value, invalidChars) {
1517
+ if (utils$1.isArray(value)) {
1518
+ return value.map(function (item) {
1519
+ return sanitizeValue(item, invalidChars);
1520
+ });
1521
+ }
1522
+ return trimSPorHTAB(String(value).replace(invalidChars, ''));
1523
+ }
1524
+ var sanitizeHeaderValue = function sanitizeHeaderValue(value) {
1525
+ return sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
1526
+ };
1527
+ var sanitizeByteStringHeaderValue = function sanitizeByteStringHeaderValue(value) {
1528
+ return sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
1529
+ };
1530
+ function toByteStringHeaderObject(headers) {
1531
+ var byteStringHeaders = Object.create(null);
1532
+ utils$1.forEach(headers.toJSON(), function (value, header) {
1533
+ byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
1534
+ });
1535
+ return byteStringHeaders;
1576
1536
  }
1577
- var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1578
- return /^is[A-Z]/.test(prop);
1579
- });
1580
-
1581
- /**
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]
1591
- *
1592
- * @returns {Object}
1593
- **/
1594
1537
 
1595
- /**
1596
- * It converts an object into a FormData object
1597
- *
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
1601
- *
1602
- * @returns
1603
- */
1604
- function toFormData(obj, formData, options) {
1605
- if (!utils$1.isObject(obj)) {
1606
- throw new TypeError('target must be an object');
1538
+ var $internals = Symbol('internals');
1539
+ function normalizeHeader(header) {
1540
+ return header && String(header).trim().toLowerCase();
1541
+ }
1542
+ function normalizeValue(value) {
1543
+ if (value === false || value == null) {
1544
+ return value;
1607
1545
  }
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');
1546
+ return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
1547
+ }
1548
+ function parseTokens(str) {
1549
+ var tokens = Object.create(null);
1550
+ var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1551
+ var match;
1552
+ while (match = tokensRE.exec(str)) {
1553
+ tokens[match[1]] = match[2];
1631
1554
  }
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();
1639
- }
1640
- if (!useBlob && utils$1.isBlob(value)) {
1641
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1642
- }
1643
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1644
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1645
- }
1646
- return value;
1555
+ return tokens;
1556
+ }
1557
+ var isValidHeaderName = function isValidHeaderName(str) {
1558
+ return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1559
+ };
1560
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1561
+ if (utils$1.isFunction(filter)) {
1562
+ return filter.call(this, value, header);
1647
1563
  }
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;
1564
+ if (isHeaderNameFilter) {
1565
+ value = header;
1687
1566
  }
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('.'));
1702
- }
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();
1567
+ if (!utils$1.isString(value)) return;
1568
+ if (utils$1.isString(filter)) {
1569
+ return value.indexOf(filter) !== -1;
1711
1570
  }
1712
- if (!utils$1.isObject(obj)) {
1713
- throw new TypeError('data must be an object');
1571
+ if (utils$1.isRegExp(filter)) {
1572
+ return filter.test(value);
1714
1573
  }
1715
- build(obj);
1716
- return formData;
1717
1574
  }
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];
1575
+ function formatHeader(header) {
1576
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
1577
+ return _char.toUpperCase() + str;
1738
1578
  });
1739
1579
  }
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);
1752
- }
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, '+');
1580
+ function buildAccessors(obj, header) {
1581
+ var accessorName = utils$1.toCamelCase(' ' + header);
1582
+ ['get', 'set', 'has'].forEach(function (methodName) {
1583
+ Object.defineProperty(obj, methodName + accessorName, {
1584
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
1585
+ // this data descriptor into an accessor descriptor on the way in.
1586
+ __proto__: null,
1587
+ value: function value(arg1, arg2, arg3) {
1588
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1589
+ },
1590
+ configurable: true
1591
+ });
1592
+ });
1776
1593
  }
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;
1790
- }
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);
1594
+ var AxiosHeaders = /*#__PURE__*/function () {
1595
+ function AxiosHeaders(headers) {
1596
+ _classCallCheck(this, AxiosHeaders);
1597
+ headers && this.set(headers);
1801
1598
  }
1802
- if (serializedParams) {
1803
- var hashmarkIndex = url.indexOf('#');
1804
- if (hashmarkIndex !== -1) {
1805
- url = url.slice(0, hashmarkIndex);
1599
+ return _createClass(AxiosHeaders, [{
1600
+ key: "set",
1601
+ value: function set(header, valueOrRewrite, rewrite) {
1602
+ var self = this;
1603
+ function setHeader(_value, _header, _rewrite) {
1604
+ var lHeader = normalizeHeader(_header);
1605
+ if (!lHeader) {
1606
+ throw new Error('header name must be a non-empty string');
1607
+ }
1608
+ var key = utils$1.findKey(self, lHeader);
1609
+ if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
1610
+ self[key || _header] = normalizeValue(_value);
1611
+ }
1612
+ }
1613
+ var setHeaders = function setHeaders(headers, _rewrite) {
1614
+ return utils$1.forEach(headers, function (_value, _header) {
1615
+ return setHeader(_value, _header, _rewrite);
1616
+ });
1617
+ };
1618
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1619
+ setHeaders(header, valueOrRewrite);
1620
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1621
+ setHeaders(parseHeaders(header), valueOrRewrite);
1622
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1623
+ var obj = {},
1624
+ dest,
1625
+ key;
1626
+ var _iterator = _createForOfIteratorHelper(header),
1627
+ _step;
1628
+ try {
1629
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1630
+ var entry = _step.value;
1631
+ if (!utils$1.isArray(entry)) {
1632
+ throw TypeError('Object iterator must return a key-value pair');
1633
+ }
1634
+ obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]] : entry[1];
1635
+ }
1636
+ } catch (err) {
1637
+ _iterator.e(err);
1638
+ } finally {
1639
+ _iterator.f();
1640
+ }
1641
+ setHeaders(obj, valueOrRewrite);
1642
+ } else {
1643
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1644
+ }
1645
+ return this;
1806
1646
  }
1807
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1808
- }
1809
- return url;
1810
- }
1811
-
1812
- var InterceptorManager = /*#__PURE__*/function () {
1813
- function InterceptorManager() {
1814
- _classCallCheck(this, InterceptorManager);
1815
- this.handlers = [];
1816
- }
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;
1647
+ }, {
1648
+ key: "get",
1649
+ value: function get(header, parser) {
1650
+ header = normalizeHeader(header);
1651
+ if (header) {
1652
+ var key = utils$1.findKey(this, header);
1653
+ if (key) {
1654
+ var value = this[key];
1655
+ if (!parser) {
1656
+ return value;
1657
+ }
1658
+ if (parser === true) {
1659
+ return parseTokens(value);
1660
+ }
1661
+ if (utils$1.isFunction(parser)) {
1662
+ return parser.call(this, value, key);
1663
+ }
1664
+ if (utils$1.isRegExp(parser)) {
1665
+ return parser.exec(value);
1666
+ }
1667
+ throw new TypeError('parser must be boolean|regexp|function');
1668
+ }
1669
+ }
1837
1670
  }
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
1671
  }, {
1847
- key: "eject",
1848
- value: function eject(id) {
1849
- if (this.handlers[id]) {
1850
- this.handlers[id] = null;
1672
+ key: "has",
1673
+ value: function has(header, matcher) {
1674
+ header = normalizeHeader(header);
1675
+ if (header) {
1676
+ var key = utils$1.findKey(this, header);
1677
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1851
1678
  }
1679
+ return false;
1680
+ }
1681
+ }, {
1682
+ key: "delete",
1683
+ value: function _delete(header, matcher) {
1684
+ var self = this;
1685
+ var deleted = false;
1686
+ function deleteHeader(_header) {
1687
+ _header = normalizeHeader(_header);
1688
+ if (_header) {
1689
+ var key = utils$1.findKey(self, _header);
1690
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1691
+ delete self[key];
1692
+ deleted = true;
1693
+ }
1694
+ }
1695
+ }
1696
+ if (utils$1.isArray(header)) {
1697
+ header.forEach(deleteHeader);
1698
+ } else {
1699
+ deleteHeader(header);
1700
+ }
1701
+ return deleted;
1852
1702
  }
1853
-
1854
- /**
1855
- * Clear all interceptors from the stack
1856
- *
1857
- * @returns {void}
1858
- */
1859
1703
  }, {
1860
1704
  key: "clear",
1861
- value: function clear() {
1862
- if (this.handlers) {
1863
- this.handlers = [];
1705
+ value: function clear(matcher) {
1706
+ var keys = Object.keys(this);
1707
+ var i = keys.length;
1708
+ var deleted = false;
1709
+ while (i--) {
1710
+ var key = keys[i];
1711
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1712
+ delete this[key];
1713
+ deleted = true;
1714
+ }
1864
1715
  }
1716
+ return deleted;
1865
1717
  }
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
1718
  }, {
1878
- key: "forEach",
1879
- value: function forEach(fn) {
1880
- utils$1.forEach(this.handlers, function forEachHandler(h) {
1881
- if (h !== null) {
1882
- fn(h);
1719
+ key: "normalize",
1720
+ value: function normalize(format) {
1721
+ var self = this;
1722
+ var headers = {};
1723
+ utils$1.forEach(this, function (value, header) {
1724
+ var key = utils$1.findKey(headers, header);
1725
+ if (key) {
1726
+ self[key] = normalizeValue(value);
1727
+ delete self[header];
1728
+ return;
1883
1729
  }
1730
+ var normalized = format ? formatHeader(header) : String(header).trim();
1731
+ if (normalized !== header) {
1732
+ delete self[header];
1733
+ }
1734
+ self[normalized] = normalizeValue(value);
1735
+ headers[normalized] = true;
1736
+ });
1737
+ return this;
1738
+ }
1739
+ }, {
1740
+ key: "concat",
1741
+ value: function concat() {
1742
+ var _this$constructor;
1743
+ for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
1744
+ targets[_key] = arguments[_key];
1745
+ }
1746
+ return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
1747
+ }
1748
+ }, {
1749
+ key: "toJSON",
1750
+ value: function toJSON(asStrings) {
1751
+ var obj = Object.create(null);
1752
+ utils$1.forEach(this, function (value, header) {
1753
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1754
+ });
1755
+ return obj;
1756
+ }
1757
+ }, {
1758
+ key: Symbol.iterator,
1759
+ value: function value() {
1760
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1761
+ }
1762
+ }, {
1763
+ key: "toString",
1764
+ value: function toString() {
1765
+ return Object.entries(this.toJSON()).map(function (_ref) {
1766
+ var _ref2 = _slicedToArray(_ref, 2),
1767
+ header = _ref2[0],
1768
+ value = _ref2[1];
1769
+ return header + ': ' + value;
1770
+ }).join('\n');
1771
+ }
1772
+ }, {
1773
+ key: "getSetCookie",
1774
+ value: function getSetCookie() {
1775
+ return this.get('set-cookie') || [];
1776
+ }
1777
+ }, {
1778
+ key: Symbol.toStringTag,
1779
+ get: function get() {
1780
+ return 'AxiosHeaders';
1781
+ }
1782
+ }], [{
1783
+ key: "from",
1784
+ value: function from(thing) {
1785
+ return thing instanceof this ? thing : new this(thing);
1786
+ }
1787
+ }, {
1788
+ key: "concat",
1789
+ value: function concat(first) {
1790
+ var computed = new this(first);
1791
+ for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1792
+ targets[_key2 - 1] = arguments[_key2];
1793
+ }
1794
+ targets.forEach(function (target) {
1795
+ return computed.set(target);
1884
1796
  });
1797
+ return computed;
1798
+ }
1799
+ }, {
1800
+ key: "accessor",
1801
+ value: function accessor(header) {
1802
+ var internals = this[$internals] = this[$internals] = {
1803
+ accessors: {}
1804
+ };
1805
+ var accessors = internals.accessors;
1806
+ var prototype = this.prototype;
1807
+ function defineAccessor(_header) {
1808
+ var lHeader = normalizeHeader(_header);
1809
+ if (!accessors[lHeader]) {
1810
+ buildAccessors(prototype, _header);
1811
+ accessors[lHeader] = true;
1812
+ }
1813
+ }
1814
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1815
+ return this;
1885
1816
  }
1886
1817
  }]);
1887
1818
  }();
1819
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1888
1820
 
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;
1821
+ // reserved names hotfix
1822
+ utils$1.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
1823
+ var value = _ref3.value;
1824
+ var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1825
+ return {
1826
+ get: function get() {
1827
+ return value;
1828
+ },
1829
+ set: function set(headerValue) {
1830
+ this[mapped] = headerValue;
1831
+ }
1832
+ };
1833
+ });
1834
+ utils$1.freezeMethods(AxiosHeaders);
1899
1835
 
1900
- var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1836
+ var REDACTED = '[REDACTED ****]';
1837
+ function hasOwnOrPrototypeToJSON(source) {
1838
+ if (utils$1.hasOwnProp(source, 'toJSON')) {
1839
+ return true;
1840
+ }
1841
+ var prototype = Object.getPrototypeOf(source);
1842
+ while (prototype && prototype !== Object.prototype) {
1843
+ if (utils$1.hasOwnProp(prototype, 'toJSON')) {
1844
+ return true;
1845
+ }
1846
+ prototype = Object.getPrototypeOf(prototype);
1847
+ }
1848
+ return false;
1849
+ }
1901
1850
 
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
- };
1851
+ // Build a plain-object snapshot of `config` and replace the value of any key
1852
+ // (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
1853
+ // and AxiosHeaders, and short-circuits on circular references.
1854
+ function redactConfig(config, redactKeys) {
1855
+ var lowerKeys = new Set(redactKeys.map(function (k) {
1856
+ return String(k).toLowerCase();
1857
+ }));
1858
+ var seen = [];
1859
+ var _visit = function visit(source) {
1860
+ if (source === null || _typeof(source) !== 'object') return source;
1861
+ if (utils$1.isBuffer(source)) return source;
1862
+ if (seen.indexOf(source) !== -1) return undefined;
1863
+ if (source instanceof AxiosHeaders) {
1864
+ source = source.toJSON();
1865
+ }
1866
+ seen.push(source);
1867
+ var result;
1868
+ if (utils$1.isArray(source)) {
1869
+ result = [];
1870
+ source.forEach(function (v, i) {
1871
+ var reducedValue = _visit(v);
1872
+ if (!utils$1.isUndefined(reducedValue)) {
1873
+ result[i] = reducedValue;
1874
+ }
1875
+ });
1876
+ } else {
1877
+ if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
1878
+ seen.pop();
1879
+ return source;
1880
+ }
1881
+ result = Object.create(null);
1882
+ for (var _i = 0, _Object$entries = Object.entries(source); _i < _Object$entries.length; _i++) {
1883
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
1884
+ key = _Object$entries$_i[0],
1885
+ value = _Object$entries$_i[1];
1886
+ var reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : _visit(value);
1887
+ if (!utils$1.isUndefined(reducedValue)) {
1888
+ result[key] = reducedValue;
1889
+ }
1890
+ }
1891
+ }
1892
+ seen.pop();
1893
+ return result;
1894
+ };
1895
+ return _visit(config);
1896
+ }
1897
+ var AxiosError = /*#__PURE__*/function (_Error) {
1898
+ /**
1899
+ * Create an Error with the specified message, config, error code, request and response.
1900
+ *
1901
+ * @param {string} message The error message.
1902
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
1903
+ * @param {Object} [config] The config.
1904
+ * @param {Object} [request] The request.
1905
+ * @param {Object} [response] The response.
1906
+ *
1907
+ * @returns {Error} The created error.
1908
+ */
1909
+ function AxiosError(message, code, config, request, response) {
1910
+ var _this;
1911
+ _classCallCheck(this, AxiosError);
1912
+ _this = _callSuper(this, AxiosError, [message]);
1911
1913
 
1912
- var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1913
- var _navigator = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator || undefined;
1914
+ // Make message enumerable to maintain backward compatibility
1915
+ // The native Error constructor sets message as non-enumerable,
1916
+ // but axios < v1.13.3 had it as enumerable
1917
+ Object.defineProperty(_this, 'message', {
1918
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
1919
+ // this data descriptor into an accessor descriptor on the way in.
1920
+ __proto__: null,
1921
+ value: message,
1922
+ enumerable: true,
1923
+ writable: true,
1924
+ configurable: true
1925
+ });
1926
+ _this.name = 'AxiosError';
1927
+ _this.isAxiosError = true;
1928
+ code && (_this.code = code);
1929
+ config && (_this.config = config);
1930
+ request && (_this.request = request);
1931
+ if (response) {
1932
+ _this.response = response;
1933
+ _this.status = response.status;
1934
+ }
1935
+ return _this;
1936
+ }
1937
+ _inherits(AxiosError, _Error);
1938
+ return _createClass(AxiosError, [{
1939
+ key: "toJSON",
1940
+ value: function toJSON() {
1941
+ // Opt-in redaction: when the request config carries a `redact` array, the
1942
+ // value of any matching key (case-insensitive, at any depth) is replaced
1943
+ // with REDACTED in the serialized snapshot. Undefined or empty leaves the
1944
+ // existing serialization behavior unchanged.
1945
+ var config = this.config;
1946
+ var redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
1947
+ var serializedConfig = utils$1.isArray(redactKeys) && redactKeys.length > 0 ? redactConfig(config, redactKeys) : utils$1.toJSONObject(config);
1948
+ return {
1949
+ // Standard
1950
+ message: this.message,
1951
+ name: this.name,
1952
+ // Microsoft
1953
+ description: this.description,
1954
+ number: this.number,
1955
+ // Mozilla
1956
+ fileName: this.fileName,
1957
+ lineNumber: this.lineNumber,
1958
+ columnNumber: this.columnNumber,
1959
+ stack: this.stack,
1960
+ // Axios
1961
+ config: serializedConfig,
1962
+ code: this.code,
1963
+ status: this.status
1964
+ };
1965
+ }
1966
+ }], [{
1967
+ key: "from",
1968
+ value: function from(error, code, config, request, response, customProps) {
1969
+ var axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1970
+ axiosError.cause = error;
1971
+ axiosError.name = error.name;
1972
+
1973
+ // Preserve status from the original error if not already set from response
1974
+ if (error.status != null && axiosError.status == null) {
1975
+ axiosError.status = error.status;
1976
+ }
1977
+ customProps && Object.assign(axiosError, customProps);
1978
+ return axiosError;
1979
+ }
1980
+ }]);
1981
+ }(/*#__PURE__*/_wrapNativeSuper(Error)); // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1982
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1983
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1984
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
1985
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
1986
+ AxiosError.ECONNREFUSED = 'ECONNREFUSED';
1987
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
1988
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1989
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
1990
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1991
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1992
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
1993
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1994
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
1995
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
1996
+
1997
+ // eslint-disable-next-line strict
1998
+ var httpAdapter = null;
1914
1999
 
1915
2000
  /**
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
2001
+ * Determines if the given thing is a array or js object.
1924
2002
  *
1925
- * react-native:
1926
- * navigator.product -> 'ReactNative'
1927
- * nativescript
1928
- * navigator.product -> 'NativeScript' or 'NS'
2003
+ * @param {string} thing - The object or array to be visited.
1929
2004
  *
1930
2005
  * @returns {boolean}
1931
2006
  */
1932
- var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1933
-
1934
- /**
1935
- * Determine if we're running in a standard browser webWorker environment
1936
- *
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
1942
- */
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));
2007
+ function isVisitable(thing) {
2008
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
1971
2009
  }
1972
2010
 
1973
2011
  /**
1974
- * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
2012
+ * It removes the brackets from the end of a string
1975
2013
  *
1976
- * @param {string} name - The name of the property to get.
2014
+ * @param {string} key - The key of the parameter.
1977
2015
  *
1978
- * @returns An array of strings.
2016
+ * @returns {string} the key without the brackets.
1979
2017
  */
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
- });
2018
+ function removeBrackets(key) {
2019
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1988
2020
  }
1989
2021
 
1990
2022
  /**
1991
- * Convert an array to an object.
2023
+ * It takes a path, a key, and a boolean, and returns a string
1992
2024
  *
1993
- * @param {Array<any>} arr - The array to convert to an object.
2025
+ * @param {string} path - The path to the current key.
2026
+ * @param {string} key - The key of the current object being iterated over.
2027
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
1994
2028
  *
1995
- * @returns An object with the same keys and values as the array.
2029
+ * @returns {string} The path to the current key.
1996
2030
  */
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;
2031
+ function renderKey(path, key, dots) {
2032
+ if (!path) return key;
2033
+ return path.concat(key).map(function each(token, i) {
2034
+ // eslint-disable-next-line no-param-reassign
2035
+ token = removeBrackets(token);
2036
+ return !dots && i ? '[' + token + ']' : token;
2037
+ }).join(dots ? '.' : '');
2008
2038
  }
2009
2039
 
2010
2040
  /**
2011
- * It takes a FormData object and returns a JavaScript object
2041
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
2012
2042
  *
2013
- * @param {string} formData The FormData object to convert to JSON.
2043
+ * @param {Array<any>} arr - The array to check
2014
2044
  *
2015
- * @returns {Object<string, any> | null} The converted object.
2045
+ * @returns {boolean}
2016
2046
  */
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;
2047
- }
2048
- return null;
2047
+ function isFlatArray(arr) {
2048
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
2049
2049
  }
2050
-
2051
- var own = function own(obj, key) {
2052
- return obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
2053
- };
2050
+ var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
2051
+ return /^is[A-Z]/.test(prop);
2052
+ });
2054
2053
 
2055
2054
  /**
2056
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2057
- * of the input
2055
+ * Convert a data object to FormData
2058
2056
  *
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.
2057
+ * @param {Object} obj
2058
+ * @param {?Object} [formData]
2059
+ * @param {?Object} [options]
2060
+ * @param {Function} [options.visitor]
2061
+ * @param {Boolean} [options.metaTokens = true]
2062
+ * @param {Boolean} [options.dots = false]
2063
+ * @param {?Boolean} [options.indexes = false]
2062
2064
  *
2063
- * @returns {string} A stringified version of the rawValue.
2065
+ * @returns {Object}
2066
+ **/
2067
+
2068
+ /**
2069
+ * It converts an object into a FormData object
2070
+ *
2071
+ * @param {Object<any, any>} obj - The object to convert to form data.
2072
+ * @param {string} formData - The FormData object to append to.
2073
+ * @param {Object<string, any>} options
2074
+ *
2075
+ * @returns
2064
2076
  */
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
- }
2077
+ function toFormData(obj, formData, options) {
2078
+ if (!utils$1.isObject(obj)) {
2079
+ throw new TypeError('target must be an object');
2075
2080
  }
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);
2081
+
2082
+ // eslint-disable-next-line no-param-reassign
2083
+ formData = formData || new (FormData)();
2084
+
2085
+ // eslint-disable-next-line no-param-reassign
2086
+ options = utils$1.toFlatObject(options, {
2087
+ metaTokens: true,
2088
+ dots: false,
2089
+ indexes: false
2090
+ }, false, function defined(option, source) {
2091
+ // eslint-disable-next-line no-eq-null,eqeqeq
2092
+ return !utils$1.isUndefined(source[option]);
2093
+ });
2094
+ var metaTokens = options.metaTokens;
2095
+ // eslint-disable-next-line no-use-before-define
2096
+ var visitor = options.visitor || defaultVisitor;
2097
+ var dots = options.dots;
2098
+ var indexes = options.indexes;
2099
+ var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
2100
+ var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
2101
+ var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
2102
+ if (!utils$1.isFunction(visitor)) {
2103
+ throw new TypeError('visitor must be a function');
2104
+ }
2105
+ function convertValue(value) {
2106
+ if (value === null) return '';
2107
+ if (utils$1.isDate(value)) {
2108
+ return value.toISOString();
2087
2109
  }
2088
- var isFormData = utils$1.isFormData(data);
2089
- if (isFormData) {
2090
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2110
+ if (utils$1.isBoolean(value)) {
2111
+ return value.toString();
2091
2112
  }
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;
2113
+ if (!useBlob && utils$1.isBlob(value)) {
2114
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
2094
2115
  }
2095
- if (utils$1.isArrayBufferView(data)) {
2096
- return data.buffer;
2116
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
2117
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
2097
2118
  }
2098
- if (utils$1.isURLSearchParams(data)) {
2099
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2100
- return data.toString();
2119
+ return value;
2120
+ }
2121
+
2122
+ /**
2123
+ * Default visitor.
2124
+ *
2125
+ * @param {*} value
2126
+ * @param {String|Number} key
2127
+ * @param {Array<String|Number>} path
2128
+ * @this {FormData}
2129
+ *
2130
+ * @returns {boolean} return true to visit the each prop of the value recursively
2131
+ */
2132
+ function defaultVisitor(value, key, path) {
2133
+ var arr = value;
2134
+ if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
2135
+ formData.append(renderKey(path, key, dots), convertValue(value));
2136
+ return false;
2101
2137
  }
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);
2138
+ if (value && !path && _typeof(value) === 'object') {
2139
+ if (utils$1.endsWith(key, '{}')) {
2140
+ // eslint-disable-next-line no-param-reassign
2141
+ key = metaTokens ? key : key.slice(0, -2);
2142
+ // eslint-disable-next-line no-param-reassign
2143
+ value = JSON.stringify(value);
2144
+ } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
2145
+ // eslint-disable-next-line no-param-reassign
2146
+ key = removeBrackets(key);
2147
+ arr.forEach(function each(el, index) {
2148
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
2149
+ // eslint-disable-next-line no-nested-ternary
2150
+ indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
2151
+ });
2152
+ return false;
2114
2153
  }
2115
2154
  }
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;
2155
+ if (isVisitable(value)) {
2156
+ return true;
2129
2157
  }
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
- }
2158
+ formData.append(renderKey(path, key, dots), convertValue(value));
2159
+ return false;
2160
+ }
2161
+ var stack = [];
2162
+ var exposedHelpers = Object.assign(predicates, {
2163
+ defaultVisitor: defaultVisitor,
2164
+ convertValue: convertValue,
2165
+ isVisitable: isVisitable
2166
+ });
2167
+ function build(value, path) {
2168
+ var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2169
+ if (utils$1.isUndefined(value)) return;
2170
+ if (depth > maxDepth) {
2171
+ throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
2143
2172
  }
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
2173
+ if (stack.indexOf(value) !== -1) {
2174
+ throw Error('Circular reference detected in ' + path.join('.'));
2166
2175
  }
2176
+ stack.push(value);
2177
+ utils$1.forEach(value, function each(el, key) {
2178
+ var result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
2179
+ if (result === true) {
2180
+ build(el, path ? path.concat(key) : [key], depth + 1);
2181
+ }
2182
+ });
2183
+ stack.pop();
2167
2184
  }
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']);
2185
+ if (!utils$1.isObject(obj)) {
2186
+ throw new TypeError('data must be an object');
2187
+ }
2188
+ build(obj);
2189
+ return formData;
2190
+ }
2176
2191
 
2177
2192
  /**
2178
- * Parse headers into an object
2193
+ * It encodes a string by replacing all characters that are not in the unreserved set with
2194
+ * their percent-encoded equivalents
2179
2195
  *
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
- * ```
2196
+ * @param {string} str - The string to encode.
2186
2197
  *
2187
- * @param {String} rawHeaders Headers needing to be parsed
2198
+ * @returns {string} The encoded string.
2199
+ */
2200
+ function encode$1(str) {
2201
+ var charMap = {
2202
+ '!': '%21',
2203
+ "'": '%27',
2204
+ '(': '%28',
2205
+ ')': '%29',
2206
+ '~': '%7E',
2207
+ '%20': '+'
2208
+ };
2209
+ return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
2210
+ return charMap[match];
2211
+ });
2212
+ }
2213
+
2214
+ /**
2215
+ * It takes a params object and converts it to a FormData object
2188
2216
  *
2189
- * @returns {Object} Headers parsed into an object
2217
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
2218
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
2219
+ *
2220
+ * @returns {void}
2190
2221
  */
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
- }
2212
- });
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
- }
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;
2222
+ function AxiosURLSearchParams(params, options) {
2223
+ this._pairs = [];
2224
+ params && toFormData(params, this, options);
2257
2225
  }
2258
- var isValidHeaderName = function isValidHeaderName(str) {
2259
- return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2226
+ var prototype = AxiosURLSearchParams.prototype;
2227
+ prototype.append = function append(name, value) {
2228
+ this._pairs.push([name, value]);
2260
2229
  };
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;
2230
+ prototype.toString = function toString(encoder) {
2231
+ var _encode = encoder ? function (value) {
2232
+ return encoder.call(this, value, encode$1);
2233
+ } : encode$1;
2234
+ return this._pairs.map(function each(pair) {
2235
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
2236
+ }, '').join('&');
2237
+ };
2238
+
2239
+ /**
2240
+ * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
2241
+ * their plain counterparts (`:`, `$`, `,`, `+`).
2242
+ *
2243
+ * @param {string} val The value to be encoded.
2244
+ *
2245
+ * @returns {string} The encoded value.
2246
+ */
2247
+ function encode(val) {
2248
+ return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
2249
+ }
2250
+
2251
+ /**
2252
+ * Build a URL by appending params to the end
2253
+ *
2254
+ * @param {string} url The base of the url (e.g., http://www.google.com)
2255
+ * @param {object} [params] The params to be appended
2256
+ * @param {?(object|Function)} options
2257
+ *
2258
+ * @returns {string} The formatted url
2259
+ */
2260
+ function buildURL(url, params, options) {
2261
+ if (!params) {
2262
+ return url;
2267
2263
  }
2268
- if (!utils$1.isString(value)) return;
2269
- if (utils$1.isString(filter)) {
2270
- return value.indexOf(filter) !== -1;
2264
+ var _encode = options && options.encode || encode;
2265
+ var _options = utils$1.isFunction(options) ? {
2266
+ serialize: options
2267
+ } : options;
2268
+ var serializeFn = _options && _options.serialize;
2269
+ var serializedParams;
2270
+ if (serializeFn) {
2271
+ serializedParams = serializeFn(params, _options);
2272
+ } else {
2273
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
2271
2274
  }
2272
- if (utils$1.isRegExp(filter)) {
2273
- return filter.test(value);
2275
+ if (serializedParams) {
2276
+ var hashmarkIndex = url.indexOf('#');
2277
+ if (hashmarkIndex !== -1) {
2278
+ url = url.slice(0, hashmarkIndex);
2279
+ }
2280
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
2274
2281
  }
2282
+ return url;
2275
2283
  }
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);
2284
+
2285
+ var InterceptorManager = /*#__PURE__*/function () {
2286
+ function InterceptorManager() {
2287
+ _classCallCheck(this, InterceptorManager);
2288
+ this.handlers = [];
2296
2289
  }
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);
2342
- }
2343
- return this;
2290
+
2291
+ /**
2292
+ * Add a new interceptor to the stack
2293
+ *
2294
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
2295
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
2296
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
2297
+ *
2298
+ * @return {Number} An ID used to remove interceptor later
2299
+ */
2300
+ return _createClass(InterceptorManager, [{
2301
+ key: "use",
2302
+ value: function use(fulfilled, rejected, options) {
2303
+ this.handlers.push({
2304
+ fulfilled: fulfilled,
2305
+ rejected: rejected,
2306
+ synchronous: options ? options.synchronous : false,
2307
+ runWhen: options ? options.runWhen : null
2308
+ });
2309
+ return this.handlers.length - 1;
2344
2310
  }
2311
+
2312
+ /**
2313
+ * Remove an interceptor from the stack
2314
+ *
2315
+ * @param {Number} id The ID that was returned by `use`
2316
+ *
2317
+ * @returns {void}
2318
+ */
2345
2319
  }, {
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
- }
2320
+ key: "eject",
2321
+ value: function eject(id) {
2322
+ if (this.handlers[id]) {
2323
+ this.handlers[id] = null;
2367
2324
  }
2368
2325
  }
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)));
2376
- }
2377
- return false;
2378
- }
2379
- }, {
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
- }
2392
- }
2393
- }
2394
- if (utils$1.isArray(header)) {
2395
- header.forEach(deleteHeader);
2396
- } else {
2397
- deleteHeader(header);
2398
- }
2399
- return deleted;
2400
- }
2326
+
2327
+ /**
2328
+ * Clear all interceptors from the stack
2329
+ *
2330
+ * @returns {void}
2331
+ */
2401
2332
  }, {
2402
2333
  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
- }
2334
+ value: function clear() {
2335
+ if (this.handlers) {
2336
+ this.handlers = [];
2413
2337
  }
2414
- return deleted;
2415
2338
  }
2339
+
2340
+ /**
2341
+ * Iterate over all the registered interceptors
2342
+ *
2343
+ * This method is particularly useful for skipping over any
2344
+ * interceptors that may have become `null` calling `eject`.
2345
+ *
2346
+ * @param {Function} fn The function to call for each interceptor
2347
+ *
2348
+ * @returns {void}
2349
+ */
2416
2350
  }, {
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];
2351
+ key: "forEach",
2352
+ value: function forEach(fn) {
2353
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
2354
+ if (h !== null) {
2355
+ fn(h);
2431
2356
  }
2432
- self[normalized] = normalizeValue(value);
2433
- headers[normalized] = true;
2434
2357
  });
2435
- return this;
2436
2358
  }
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];
2359
+ }]);
2360
+ }();
2361
+
2362
+ var transitionalDefaults = {
2363
+ silentJSONParsing: true,
2364
+ forcedJSONParsing: true,
2365
+ clarifyTimeoutError: false,
2366
+ legacyInterceptorReqResOrdering: true
2367
+ };
2368
+
2369
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
2370
+
2371
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
2372
+
2373
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
2374
+
2375
+ var platform$1 = {
2376
+ isBrowser: true,
2377
+ classes: {
2378
+ URLSearchParams: URLSearchParams$1,
2379
+ FormData: FormData$1,
2380
+ Blob: Blob$1
2381
+ },
2382
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
2383
+ };
2384
+
2385
+ var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2386
+ var _navigator = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator || undefined;
2387
+
2388
+ /**
2389
+ * Determine if we're running in a standard browser environment
2390
+ *
2391
+ * This allows axios to run in a web worker, and react-native.
2392
+ * Both environments support XMLHttpRequest, but not fully standard globals.
2393
+ *
2394
+ * web workers:
2395
+ * typeof window -> undefined
2396
+ * typeof document -> undefined
2397
+ *
2398
+ * react-native:
2399
+ * navigator.product -> 'ReactNative'
2400
+ * nativescript
2401
+ * navigator.product -> 'NativeScript' or 'NS'
2402
+ *
2403
+ * @returns {boolean}
2404
+ */
2405
+ var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
2406
+
2407
+ /**
2408
+ * Determine if we're running in a standard browser webWorker environment
2409
+ *
2410
+ * Although the `isStandardBrowserEnv` method indicates that
2411
+ * `allows axios to run in a web worker`, the WebWorker will still be
2412
+ * filtered out due to its judgment standard
2413
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
2414
+ * This leads to a problem when axios post `FormData` in webWorker
2415
+ */
2416
+ var hasStandardBrowserWebWorkerEnv = function () {
2417
+ return typeof WorkerGlobalScope !== 'undefined' &&
2418
+ // eslint-disable-next-line no-undef
2419
+ self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
2420
+ }();
2421
+ var origin = hasBrowserEnv && window.location.href || 'http://localhost';
2422
+
2423
+ var utils = /*#__PURE__*/Object.freeze({
2424
+ __proto__: null,
2425
+ hasBrowserEnv: hasBrowserEnv,
2426
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
2427
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2428
+ navigator: _navigator,
2429
+ origin: origin
2430
+ });
2431
+
2432
+ var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
2433
+
2434
+ function toURLEncodedForm(data, options) {
2435
+ return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
2436
+ visitor: function visitor(value, key, path, helpers) {
2437
+ if (platform.isNode && utils$1.isBuffer(value)) {
2438
+ this.append(key, value.toString('base64'));
2439
+ return false;
2443
2440
  }
2444
- return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
2441
+ return helpers.defaultVisitor.apply(this, arguments);
2445
2442
  }
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;
2443
+ }, options));
2444
+ }
2445
+
2446
+ /**
2447
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
2448
+ *
2449
+ * @param {string} name - The name of the property to get.
2450
+ *
2451
+ * @returns An array of strings.
2452
+ */
2453
+ function parsePropPath(name) {
2454
+ // foo[x][y][z]
2455
+ // foo.x.y.z
2456
+ // foo-x-y-z
2457
+ // foo x y z
2458
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
2459
+ return match[0] === '[]' ? '' : match[1] || match[0];
2460
+ });
2461
+ }
2462
+
2463
+ /**
2464
+ * Convert an array to an object.
2465
+ *
2466
+ * @param {Array<any>} arr - The array to convert to an object.
2467
+ *
2468
+ * @returns An object with the same keys and values as the array.
2469
+ */
2470
+ function arrayToObject(arr) {
2471
+ var obj = {};
2472
+ var keys = Object.keys(arr);
2473
+ var i;
2474
+ var len = keys.length;
2475
+ var key;
2476
+ for (i = 0; i < len; i++) {
2477
+ key = keys[i];
2478
+ obj[key] = arr[key];
2479
+ }
2480
+ return obj;
2481
+ }
2482
+
2483
+ /**
2484
+ * It takes a FormData object and returns a JavaScript object
2485
+ *
2486
+ * @param {string} formData The FormData object to convert to JSON.
2487
+ *
2488
+ * @returns {Object<string, any> | null} The converted object.
2489
+ */
2490
+ function formDataToJSON(formData) {
2491
+ function buildPath(path, value, target, index) {
2492
+ var name = path[index++];
2493
+ if (name === '__proto__') return true;
2494
+ var isNumericKey = Number.isFinite(+name);
2495
+ var isLast = index >= path.length;
2496
+ name = !name && utils$1.isArray(target) ? target.length : name;
2497
+ if (isLast) {
2498
+ if (utils$1.hasOwnProp(target, name)) {
2499
+ target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
2500
+ } else {
2501
+ target[name] = value;
2502
+ }
2503
+ return !isNumericKey;
2454
2504
  }
2455
- }, {
2456
- key: Symbol.iterator,
2457
- value: function value() {
2458
- return Object.entries(this.toJSON())[Symbol.iterator]();
2505
+ if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
2506
+ target[name] = [];
2459
2507
  }
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');
2508
+ var result = buildPath(path, value, target[name], index);
2509
+ if (result && utils$1.isArray(target[name])) {
2510
+ target[name] = arrayToObject(target[name]);
2511
+ }
2512
+ return !isNumericKey;
2513
+ }
2514
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
2515
+ var obj = {};
2516
+ utils$1.forEachEntry(formData, function (name, value) {
2517
+ buildPath(parsePropPath(name), value, obj, 0);
2518
+ });
2519
+ return obj;
2520
+ }
2521
+ return null;
2522
+ }
2523
+
2524
+ var own = function own(obj, key) {
2525
+ return obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
2526
+ };
2527
+
2528
+ /**
2529
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2530
+ * of the input
2531
+ *
2532
+ * @param {any} rawValue - The value to be stringified.
2533
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
2534
+ * @param {Function} encoder - A function that takes a value and returns a string.
2535
+ *
2536
+ * @returns {string} A stringified version of the rawValue.
2537
+ */
2538
+ function stringifySafely(rawValue, parser, encoder) {
2539
+ if (utils$1.isString(rawValue)) {
2540
+ try {
2541
+ (parser || JSON.parse)(rawValue);
2542
+ return utils$1.trim(rawValue);
2543
+ } catch (e) {
2544
+ if (e.name !== 'SyntaxError') {
2545
+ throw e;
2546
+ }
2547
+ }
2548
+ }
2549
+ return (encoder || JSON.stringify)(rawValue);
2550
+ }
2551
+ var defaults = {
2552
+ transitional: transitionalDefaults,
2553
+ adapter: ['xhr', 'http', 'fetch'],
2554
+ transformRequest: [function transformRequest(data, headers) {
2555
+ var contentType = headers.getContentType() || '';
2556
+ var hasJSONContentType = contentType.indexOf('application/json') > -1;
2557
+ var isObjectPayload = utils$1.isObject(data);
2558
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
2559
+ data = new FormData(data);
2469
2560
  }
2470
- }, {
2471
- key: "getSetCookie",
2472
- value: function getSetCookie() {
2473
- return this.get('set-cookie') || [];
2561
+ var isFormData = utils$1.isFormData(data);
2562
+ if (isFormData) {
2563
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2474
2564
  }
2475
- }, {
2476
- key: Symbol.toStringTag,
2477
- get: function get() {
2478
- return 'AxiosHeaders';
2565
+ 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)) {
2566
+ return data;
2479
2567
  }
2480
- }], [{
2481
- key: "from",
2482
- value: function from(thing) {
2483
- return thing instanceof this ? thing : new this(thing);
2568
+ if (utils$1.isArrayBufferView(data)) {
2569
+ return data.buffer;
2484
2570
  }
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];
2571
+ if (utils$1.isURLSearchParams(data)) {
2572
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2573
+ return data.toString();
2574
+ }
2575
+ var isFileList;
2576
+ if (isObjectPayload) {
2577
+ var formSerializer = own(this, 'formSerializer');
2578
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2579
+ return toURLEncodedForm(data, formSerializer).toString();
2580
+ }
2581
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
2582
+ var env = own(this, 'env');
2583
+ var _FormData = env && env.FormData;
2584
+ return toFormData(isFileList ? {
2585
+ 'files[]': data
2586
+ } : data, _FormData && new _FormData(), formSerializer);
2491
2587
  }
2492
- targets.forEach(function (target) {
2493
- return computed.set(target);
2494
- });
2495
- return computed;
2496
2588
  }
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;
2589
+ if (isObjectPayload || hasJSONContentType) {
2590
+ headers.setContentType('application/json', false);
2591
+ return stringifySafely(data);
2592
+ }
2593
+ return data;
2594
+ }],
2595
+ transformResponse: [function transformResponse(data) {
2596
+ var transitional = own(this, 'transitional') || defaults.transitional;
2597
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2598
+ var responseType = own(this, 'responseType');
2599
+ var JSONRequested = responseType === 'json';
2600
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2601
+ return data;
2602
+ }
2603
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
2604
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
2605
+ var strictJSONParsing = !silentJSONParsing && JSONRequested;
2606
+ try {
2607
+ return JSON.parse(data, own(this, 'parseReviver'));
2608
+ } catch (e) {
2609
+ if (strictJSONParsing) {
2610
+ if (e.name === 'SyntaxError') {
2611
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
2612
+ }
2613
+ throw e;
2510
2614
  }
2511
2615
  }
2512
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2513
- return this;
2514
2616
  }
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;
2617
+ return data;
2618
+ }],
2619
+ /**
2620
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
2621
+ * timeout is not created.
2622
+ */
2623
+ timeout: 0,
2624
+ xsrfCookieName: 'XSRF-TOKEN',
2625
+ xsrfHeaderName: 'X-XSRF-TOKEN',
2626
+ maxContentLength: -1,
2627
+ maxBodyLength: -1,
2628
+ env: {
2629
+ FormData: platform.classes.FormData,
2630
+ Blob: platform.classes.Blob
2631
+ },
2632
+ validateStatus: function validateStatus(status) {
2633
+ return status >= 200 && status < 300;
2634
+ },
2635
+ headers: {
2636
+ common: {
2637
+ Accept: 'application/json, text/plain, */*',
2638
+ 'Content-Type': undefined
2529
2639
  }
2530
- };
2640
+ }
2641
+ };
2642
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], function (method) {
2643
+ defaults.headers[method] = {};
2531
2644
  });
2532
- utils$1.freezeMethods(AxiosHeaders);
2533
2645
 
2534
2646
  /**
2535
2647
  * Transform the data for a request or a response
@@ -2591,12 +2703,12 @@
2591
2703
  if (!response.status || !validateStatus || validateStatus(response.status)) {
2592
2704
  resolve(response);
2593
2705
  } 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));
2706
+ 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
2707
  }
2596
2708
  }
2597
2709
 
2598
2710
  function parseProtocol(url) {
2599
- var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2711
+ var match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
2600
2712
  return match && match[1] || '';
2601
2713
  }
2602
2714
 
@@ -2690,6 +2802,9 @@
2690
2802
  var bytesNotified = 0;
2691
2803
  var _speedometer = speedometer(50, 250);
2692
2804
  return throttle(function (e) {
2805
+ if (!e || typeof e.loaded !== 'number') {
2806
+ return;
2807
+ }
2693
2808
  var rawLoaded = e.loaded;
2694
2809
  var total = e.lengthComputable ? e.total : undefined;
2695
2810
  var loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
@@ -2764,8 +2879,20 @@
2764
2879
  },
2765
2880
  read: function read(name) {
2766
2881
  if (typeof document === 'undefined') return null;
2767
- var match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2768
- return match ? decodeURIComponent(match[1]) : null;
2882
+ // Match name=value by splitting on the semicolon separator instead of building a
2883
+ // RegExp from `name` interpolating an unescaped string into a RegExp would let
2884
+ // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
2885
+ // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
2886
+ // "; ", so ignore optional whitespace before each cookie name.
2887
+ var cookies = document.cookie.split(';');
2888
+ for (var i = 0; i < cookies.length; i++) {
2889
+ var cookie = cookies[i].replace(/^\s+/, '');
2890
+ var eq = cookie.indexOf('=');
2891
+ if (eq !== -1 && cookie.slice(0, eq) === name) {
2892
+ return decodeURIComponent(cookie.slice(eq + 1));
2893
+ }
2894
+ }
2895
+ return null;
2769
2896
  },
2770
2897
  remove: function remove(name) {
2771
2898
  this.write(name, '', Date.now() - 86400000, '/');
@@ -2845,11 +2972,14 @@
2845
2972
  config2 = config2 || {};
2846
2973
 
2847
2974
  // 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.
2975
+ // or `config.baseURL` cannot inherit polluted values from Object.prototype.
2976
+ // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
2977
+ // ergonomics for user code that relies on it.
2851
2978
  var config = Object.create(null);
2852
2979
  Object.defineProperty(config, 'hasOwnProperty', {
2980
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
2981
+ // this data descriptor into an accessor descriptor on the way in.
2982
+ __proto__: null,
2853
2983
  value: Object.prototype.hasOwnProperty,
2854
2984
  enumerable: false,
2855
2985
  writable: true,
@@ -2944,11 +3074,40 @@
2944
3074
  return config;
2945
3075
  }
2946
3076
 
3077
+ var FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
3078
+ function setFormDataHeaders(headers, formHeaders, policy) {
3079
+ if (policy !== 'content-only') {
3080
+ headers.set(formHeaders);
3081
+ return;
3082
+ }
3083
+ Object.entries(formHeaders).forEach(function (_ref) {
3084
+ var _ref2 = _slicedToArray(_ref, 2),
3085
+ key = _ref2[0],
3086
+ val = _ref2[1];
3087
+ if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
3088
+ headers.set(key, val);
3089
+ }
3090
+ });
3091
+ }
3092
+
3093
+ /**
3094
+ * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
3095
+ * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
3096
+ *
3097
+ * @param {string} str The string to encode
3098
+ *
3099
+ * @returns {string} UTF-8 bytes as a Latin-1 string
3100
+ */
3101
+ var encodeUTF8 = function encodeUTF8(str) {
3102
+ return encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, function (_, hex) {
3103
+ return String.fromCharCode(parseInt(hex, 16));
3104
+ });
3105
+ };
2947
3106
  var resolveConfig = (function (config) {
2948
3107
  var newConfig = mergeConfig({}, config);
2949
3108
 
2950
3109
  // Read only own properties to prevent prototype pollution gadgets
2951
- // (e.g. Object.prototype.baseURL = 'https://evil.com'). See GHSA-q8qp-cvcw-x6jj.
3110
+ // (e.g. Object.prototype.baseURL = 'https://evil.com').
2952
3111
  var own = function own(key) {
2953
3112
  return utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined;
2954
3113
  };
@@ -2966,24 +3125,14 @@
2966
3125
 
2967
3126
  // HTTP basic authentication
2968
3127
  if (auth) {
2969
- headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')));
3128
+ headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : '')));
2970
3129
  }
2971
3130
  if (utils$1.isFormData(data)) {
2972
3131
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2973
3132
  headers.setContentType(undefined); // browser handles it
2974
3133
  } else if (utils$1.isFunction(data.getHeaders)) {
2975
3134
  // 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
- });
3135
+ setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
2987
3136
  }
2988
3137
  }
2989
3138
 
@@ -2998,7 +3147,7 @@
2998
3147
 
2999
3148
  // Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
3000
3149
  // 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.
3150
+ // the XSRF token cross-origin.
3002
3151
  var shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
3003
3152
  if (shouldSendXSRF) {
3004
3153
  var xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
@@ -3074,7 +3223,7 @@
3074
3223
  // handled by onerror instead
3075
3224
  // With one exception: request that using file: protocol, most browsers
3076
3225
  // will return status as 0 even though it's a successful request
3077
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
3226
+ if (request.status === 0 && !(request.responseURL && request.responseURL.startsWith('file:'))) {
3078
3227
  return;
3079
3228
  }
3080
3229
  // readystate handler is calling before onerror or ontimeout handlers,
@@ -3089,6 +3238,7 @@
3089
3238
  return;
3090
3239
  }
3091
3240
  reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
3241
+ done();
3092
3242
 
3093
3243
  // Clean up request
3094
3244
  request = null;
@@ -3104,6 +3254,7 @@
3104
3254
  // attach the underlying event for consumers who want details
3105
3255
  err.event = event || null;
3106
3256
  reject(err);
3257
+ done();
3107
3258
  request = null;
3108
3259
  };
3109
3260
 
@@ -3115,6 +3266,7 @@
3115
3266
  timeoutErrorMessage = _config.timeoutErrorMessage;
3116
3267
  }
3117
3268
  reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
3269
+ done();
3118
3270
 
3119
3271
  // Clean up request
3120
3272
  request = null;
@@ -3125,7 +3277,7 @@
3125
3277
 
3126
3278
  // Add headers to the request
3127
3279
  if ('setRequestHeader' in request) {
3128
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
3280
+ utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
3129
3281
  request.setRequestHeader(key, val);
3130
3282
  });
3131
3283
  }
@@ -3167,6 +3319,7 @@
3167
3319
  }
3168
3320
  reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
3169
3321
  request.abort();
3322
+ done();
3170
3323
  request = null;
3171
3324
  };
3172
3325
  _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
@@ -3175,7 +3328,7 @@
3175
3328
  }
3176
3329
  }
3177
3330
  var protocol = parseProtocol(_config.url);
3178
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
3331
+ if (protocol && !platform.protocols.includes(protocol)) {
3179
3332
  reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
3180
3333
  return;
3181
3334
  }
@@ -3186,42 +3339,43 @@
3186
3339
  };
3187
3340
 
3188
3341
  var composeSignals = function composeSignals(signals, timeout) {
3189
- var _signals = signals = signals ? signals.filter(Boolean) : [],
3190
- length = _signals.length;
3191
- if (timeout || length) {
3192
- var controller = new AbortController();
3193
- var aborted;
3194
- var onabort = function onabort(reason) {
3195
- if (!aborted) {
3196
- aborted = true;
3197
- unsubscribe();
3198
- var err = reason instanceof Error ? reason : this.reason;
3199
- controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3200
- }
3201
- };
3202
- var timer = timeout && setTimeout(function () {
3203
- timer = null;
3204
- onabort(new AxiosError("timeout of ".concat(timeout, "ms exceeded"), AxiosError.ETIMEDOUT));
3205
- }, timeout);
3206
- var unsubscribe = function unsubscribe() {
3207
- if (signals) {
3208
- timer && clearTimeout(timer);
3209
- timer = null;
3210
- signals.forEach(function (signal) {
3211
- signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
3212
- });
3213
- signals = null;
3214
- }
3215
- };
3342
+ signals = signals ? signals.filter(Boolean) : [];
3343
+ if (!timeout && !signals.length) {
3344
+ return;
3345
+ }
3346
+ var controller = new AbortController();
3347
+ var aborted = false;
3348
+ var onabort = function onabort(reason) {
3349
+ if (!aborted) {
3350
+ aborted = true;
3351
+ unsubscribe();
3352
+ var err = reason instanceof Error ? reason : this.reason;
3353
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3354
+ }
3355
+ };
3356
+ var timer = timeout && setTimeout(function () {
3357
+ timer = null;
3358
+ onabort(new AxiosError("timeout of ".concat(timeout, "ms exceeded"), AxiosError.ETIMEDOUT));
3359
+ }, timeout);
3360
+ var unsubscribe = function unsubscribe() {
3361
+ if (!signals) {
3362
+ return;
3363
+ }
3364
+ timer && clearTimeout(timer);
3365
+ timer = null;
3216
3366
  signals.forEach(function (signal) {
3217
- return signal.addEventListener('abort', onabort);
3367
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
3218
3368
  });
3219
- var signal = controller.signal;
3220
- signal.unsubscribe = function () {
3221
- return utils$1.asap(unsubscribe);
3222
- };
3223
- return signal;
3224
- }
3369
+ signals = null;
3370
+ };
3371
+ signals.forEach(function (signal) {
3372
+ return signal.addEventListener('abort', onabort);
3373
+ });
3374
+ var signal = controller.signal;
3375
+ signal.unsubscribe = function () {
3376
+ return utils$1.asap(unsubscribe);
3377
+ };
3378
+ return signal;
3225
3379
  };
3226
3380
 
3227
3381
  var streamChunk = /*#__PURE__*/_regenerator().m(function streamChunk(chunk, chunkSize) {
@@ -3427,19 +3581,102 @@
3427
3581
  });
3428
3582
  };
3429
3583
 
3584
+ /**
3585
+ * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
3586
+ * - For base64: compute exact decoded size using length and padding;
3587
+ * handle %XX at the character-count level (no string allocation).
3588
+ * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
3589
+ *
3590
+ * @param {string} url
3591
+ * @returns {number}
3592
+ */
3593
+ function estimateDataURLDecodedBytes(url) {
3594
+ if (!url || typeof url !== 'string') return 0;
3595
+ if (!url.startsWith('data:')) return 0;
3596
+ var comma = url.indexOf(',');
3597
+ if (comma < 0) return 0;
3598
+ var meta = url.slice(5, comma);
3599
+ var body = url.slice(comma + 1);
3600
+ var isBase64 = /;base64/i.test(meta);
3601
+ if (isBase64) {
3602
+ var effectiveLen = body.length;
3603
+ var len = body.length; // cache length
3604
+
3605
+ for (var i = 0; i < len; i++) {
3606
+ if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
3607
+ var a = body.charCodeAt(i + 1);
3608
+ var b = body.charCodeAt(i + 2);
3609
+ 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);
3610
+ if (isHex) {
3611
+ effectiveLen -= 2;
3612
+ i += 2;
3613
+ }
3614
+ }
3615
+ }
3616
+ var pad = 0;
3617
+ var idx = len - 1;
3618
+ var tailIsPct3D = function tailIsPct3D(j) {
3619
+ return j >= 2 && body.charCodeAt(j - 2) === 37 &&
3620
+ // '%'
3621
+ body.charCodeAt(j - 1) === 51 && (
3622
+ // '3'
3623
+ body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
3624
+ }; // 'D' or 'd'
3625
+
3626
+ if (idx >= 0) {
3627
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
3628
+ pad++;
3629
+ idx--;
3630
+ } else if (tailIsPct3D(idx)) {
3631
+ pad++;
3632
+ idx -= 3;
3633
+ }
3634
+ }
3635
+ if (pad === 1 && idx >= 0) {
3636
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
3637
+ pad++;
3638
+ } else if (tailIsPct3D(idx)) {
3639
+ pad++;
3640
+ }
3641
+ }
3642
+ var groups = Math.floor(effectiveLen / 4);
3643
+ var _bytes = groups * 3 - (pad || 0);
3644
+ return _bytes > 0 ? _bytes : 0;
3645
+ }
3646
+ if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
3647
+ return Buffer.byteLength(body, 'utf8');
3648
+ }
3649
+
3650
+ // Compute UTF-8 byte length directly from UTF-16 code units without allocating
3651
+ // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
3652
+ // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
3653
+ // but 3 UTF-8 bytes).
3654
+ var bytes = 0;
3655
+ for (var _i = 0, _len = body.length; _i < _len; _i++) {
3656
+ var c = body.charCodeAt(_i);
3657
+ if (c < 0x80) {
3658
+ bytes += 1;
3659
+ } else if (c < 0x800) {
3660
+ bytes += 2;
3661
+ } else if (c >= 0xd800 && c <= 0xdbff && _i + 1 < _len) {
3662
+ var next = body.charCodeAt(_i + 1);
3663
+ if (next >= 0xdc00 && next <= 0xdfff) {
3664
+ bytes += 4;
3665
+ _i++;
3666
+ } else {
3667
+ bytes += 3;
3668
+ }
3669
+ } else {
3670
+ bytes += 3;
3671
+ }
3672
+ }
3673
+ return bytes;
3674
+ }
3675
+
3676
+ var VERSION = "1.16.1";
3677
+
3430
3678
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
3431
3679
  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
3680
  var test = function test(fn) {
3444
3681
  try {
3445
3682
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -3451,9 +3688,15 @@
3451
3688
  }
3452
3689
  };
3453
3690
  var factory = function factory(env) {
3691
+ var globalObject = utils$1.global !== undefined && utils$1.global !== null ? utils$1.global : globalThis;
3692
+ var ReadableStream = globalObject.ReadableStream,
3693
+ TextEncoder = globalObject.TextEncoder;
3454
3694
  env = utils$1.merge.call({
3455
3695
  skipUndefined: true
3456
- }, globalFetchAPI, env);
3696
+ }, {
3697
+ Request: globalObject.Request,
3698
+ Response: globalObject.Response
3699
+ }, env);
3457
3700
  var _env = env,
3458
3701
  envFetch = _env.fetch,
3459
3702
  Request = _env.Request,
@@ -3464,13 +3707,13 @@
3464
3707
  if (!isFetchSupported) {
3465
3708
  return false;
3466
3709
  }
3467
- var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
3710
+ var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
3468
3711
  var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
3469
3712
  return function (str) {
3470
3713
  return encoder.encode(str);
3471
3714
  };
3472
3715
  }(new TextEncoder()) : (/*#__PURE__*/function () {
3473
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(str) {
3716
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(str) {
3474
3717
  var _t, _t2;
3475
3718
  return _regenerator().w(function (_context) {
3476
3719
  while (1) switch (_context.n) {
@@ -3485,13 +3728,13 @@
3485
3728
  }, _callee);
3486
3729
  }));
3487
3730
  return function (_x) {
3488
- return _ref2.apply(this, arguments);
3731
+ return _ref.apply(this, arguments);
3489
3732
  };
3490
3733
  }()));
3491
3734
  var supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(function () {
3492
3735
  var duplexAccessed = false;
3493
3736
  var request = new Request(platform.origin, {
3494
- body: new ReadableStream$1(),
3737
+ body: new ReadableStream(),
3495
3738
  method: 'POST',
3496
3739
  get duplex() {
3497
3740
  duplexAccessed = true;
@@ -3524,7 +3767,7 @@
3524
3767
  });
3525
3768
  }();
3526
3769
  var getBodyLength = /*#__PURE__*/function () {
3527
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
3770
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
3528
3771
  var _request;
3529
3772
  return _regenerator().w(function (_context2) {
3530
3773
  while (1) switch (_context2.n) {
@@ -3577,11 +3820,11 @@
3577
3820
  }, _callee2);
3578
3821
  }));
3579
3822
  return function getBodyLength(_x2) {
3580
- return _ref3.apply(this, arguments);
3823
+ return _ref2.apply(this, arguments);
3581
3824
  };
3582
3825
  }();
3583
3826
  var resolveBodyLength = /*#__PURE__*/function () {
3584
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(headers, body) {
3827
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(headers, body) {
3585
3828
  var length;
3586
3829
  return _regenerator().w(function (_context3) {
3587
3830
  while (1) switch (_context3.n) {
@@ -3592,16 +3835,18 @@
3592
3835
  }, _callee3);
3593
3836
  }));
3594
3837
  return function resolveBodyLength(_x3, _x4) {
3595
- return _ref4.apply(this, arguments);
3838
+ return _ref3.apply(this, arguments);
3596
3839
  };
3597
3840
  }();
3598
3841
  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;
3842
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(config) {
3843
+ 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
3844
  return _regenerator().w(function (_context4) {
3602
3845
  while (1) switch (_context4.p = _context4.n) {
3603
3846
  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;
3847
+ _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;
3848
+ hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
3849
+ hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
3605
3850
  _fetch = envFetch || fetch;
3606
3851
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3607
3852
  composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
@@ -3610,19 +3855,44 @@
3610
3855
  composedSignal.unsubscribe();
3611
3856
  };
3612
3857
  _context4.p = 1;
3858
+ if (!(hasMaxContentLength && typeof url === 'string' && url.startsWith('data:'))) {
3859
+ _context4.n = 2;
3860
+ break;
3861
+ }
3862
+ estimated = estimateDataURLDecodedBytes(url);
3863
+ if (!(estimated > maxContentLength)) {
3864
+ _context4.n = 2;
3865
+ break;
3866
+ }
3867
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3868
+ case 2:
3869
+ if (!(hasMaxBodyLength && method !== 'get' && method !== 'head')) {
3870
+ _context4.n = 4;
3871
+ break;
3872
+ }
3873
+ _context4.n = 3;
3874
+ return resolveBodyLength(headers, data);
3875
+ case 3:
3876
+ outboundLength = _context4.v;
3877
+ if (!(typeof outboundLength === 'number' && isFinite(outboundLength) && outboundLength > maxBodyLength)) {
3878
+ _context4.n = 4;
3879
+ break;
3880
+ }
3881
+ throw new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
3882
+ case 4:
3613
3883
  _t3 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
3614
3884
  if (!_t3) {
3615
- _context4.n = 3;
3885
+ _context4.n = 6;
3616
3886
  break;
3617
3887
  }
3618
- _context4.n = 2;
3888
+ _context4.n = 5;
3619
3889
  return resolveBodyLength(headers, data);
3620
- case 2:
3890
+ case 5:
3621
3891
  _t4 = requestContentLength = _context4.v;
3622
3892
  _t3 = _t4 !== 0;
3623
- case 3:
3893
+ case 6:
3624
3894
  if (!_t3) {
3625
- _context4.n = 4;
3895
+ _context4.n = 7;
3626
3896
  break;
3627
3897
  }
3628
3898
  _request = new Request(url, {
@@ -3637,7 +3907,7 @@
3637
3907
  _progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
3638
3908
  data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3639
3909
  }
3640
- case 4:
3910
+ case 7:
3641
3911
  if (!utils$1.isString(withCredentials)) {
3642
3912
  withCredentials = withCredentials ? 'include' : 'omit';
3643
3913
  }
@@ -3652,39 +3922,82 @@
3652
3922
  headers["delete"]('content-type');
3653
3923
  }
3654
3924
  }
3925
+
3926
+ // Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
3927
+ headers.set('User-Agent', 'axios/' + VERSION, false);
3655
3928
  resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
3656
3929
  signal: composedSignal,
3657
3930
  method: method.toUpperCase(),
3658
- headers: headers.normalize().toJSON(),
3931
+ headers: toByteStringHeaderObject(headers.normalize()),
3659
3932
  body: data,
3660
3933
  duplex: 'half',
3661
3934
  credentials: isCredentialsSupported ? withCredentials : undefined
3662
3935
  });
3663
3936
  request = isRequestSupported && new Request(url, resolvedOptions);
3664
- _context4.n = 5;
3937
+ _context4.n = 8;
3665
3938
  return isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions);
3666
- case 5:
3939
+ case 8:
3667
3940
  response = _context4.v;
3941
+ if (!hasMaxContentLength) {
3942
+ _context4.n = 9;
3943
+ break;
3944
+ }
3945
+ declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3946
+ if (!(declaredLength != null && declaredLength > maxContentLength)) {
3947
+ _context4.n = 9;
3948
+ break;
3949
+ }
3950
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3951
+ case 9:
3668
3952
  isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3669
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
3953
+ if (supportsResponseStream && response.body && (onDownloadProgress || hasMaxContentLength || isStreamResponse && unsubscribe)) {
3670
3954
  options = {};
3671
3955
  ['status', 'statusText', 'headers'].forEach(function (prop) {
3672
3956
  options[prop] = response[prop];
3673
3957
  });
3674
3958
  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 () {
3959
+ _ref5 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref6 = _slicedToArray(_ref5, 2), _onProgress = _ref6[0], _flush = _ref6[1];
3960
+ bytesRead = 0;
3961
+ onChunkProgress = function onChunkProgress(loadedBytes) {
3962
+ if (hasMaxContentLength) {
3963
+ bytesRead = loadedBytes;
3964
+ if (bytesRead > maxContentLength) {
3965
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3966
+ }
3967
+ }
3968
+ _onProgress && _onProgress(loadedBytes);
3969
+ };
3970
+ response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, function () {
3677
3971
  _flush && _flush();
3678
3972
  unsubscribe && unsubscribe();
3679
3973
  }), options);
3680
3974
  }
3681
3975
  responseType = responseType || 'text';
3682
- _context4.n = 6;
3976
+ _context4.n = 10;
3683
3977
  return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3684
- case 6:
3978
+ case 10:
3685
3979
  responseData = _context4.v;
3980
+ if (!(hasMaxContentLength && !supportsResponseStream && !isStreamResponse)) {
3981
+ _context4.n = 11;
3982
+ break;
3983
+ }
3984
+ if (responseData != null) {
3985
+ if (typeof responseData.byteLength === 'number') {
3986
+ materializedSize = responseData.byteLength;
3987
+ } else if (typeof responseData.size === 'number') {
3988
+ materializedSize = responseData.size;
3989
+ } else if (typeof responseData === 'string') {
3990
+ materializedSize = typeof TextEncoder === 'function' ? new TextEncoder().encode(responseData).byteLength : responseData.length;
3991
+ }
3992
+ }
3993
+ if (!(typeof materializedSize === 'number' && materializedSize > maxContentLength)) {
3994
+ _context4.n = 11;
3995
+ break;
3996
+ }
3997
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3998
+ case 11:
3686
3999
  !isStreamResponse && unsubscribe && unsubscribe();
3687
- _context4.n = 7;
4000
+ _context4.n = 12;
3688
4001
  return new Promise(function (resolve, reject) {
3689
4002
  settle(resolve, reject, {
3690
4003
  data: responseData,
@@ -3695,28 +4008,42 @@
3695
4008
  request: request
3696
4009
  });
3697
4010
  });
3698
- case 7:
4011
+ case 12:
3699
4012
  return _context4.a(2, _context4.v);
3700
- case 8:
3701
- _context4.p = 8;
4013
+ case 13:
4014
+ _context4.p = 13;
3702
4015
  _t5 = _context4.v;
3703
4016
  unsubscribe && unsubscribe();
4017
+
4018
+ // Safari can surface fetch aborts as a DOMException-like object whose
4019
+ // branded getters throw. Prefer our composed signal reason before reading
4020
+ // the caught error, preserving timeout vs cancellation semantics.
4021
+ if (!(composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError)) {
4022
+ _context4.n = 14;
4023
+ break;
4024
+ }
4025
+ canceledError = composedSignal.reason;
4026
+ canceledError.config = config;
4027
+ request && (canceledError.request = request);
4028
+ _t5 !== canceledError && (canceledError.cause = _t5);
4029
+ throw canceledError;
4030
+ case 14:
3704
4031
  if (!(_t5 && _t5.name === 'TypeError' && /Load failed|fetch/i.test(_t5.message))) {
3705
- _context4.n = 9;
4032
+ _context4.n = 15;
3706
4033
  break;
3707
4034
  }
3708
4035
  throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, _t5 && _t5.response), {
3709
4036
  cause: _t5.cause || _t5
3710
4037
  });
3711
- case 9:
4038
+ case 15:
3712
4039
  throw AxiosError.from(_t5, _t5 && _t5.code, config, request, _t5 && _t5.response);
3713
- case 10:
4040
+ case 16:
3714
4041
  return _context4.a(2);
3715
4042
  }
3716
- }, _callee4, null, [[1, 8]]);
4043
+ }, _callee4, null, [[1, 13]]);
3717
4044
  }));
3718
4045
  return function (_x5) {
3719
- return _ref5.apply(this, arguments);
4046
+ return _ref4.apply(this, arguments);
3720
4047
  };
3721
4048
  }();
3722
4049
  };
@@ -3763,13 +4090,17 @@
3763
4090
  utils$1.forEach(knownAdapters, function (fn, value) {
3764
4091
  if (fn) {
3765
4092
  try {
4093
+ // Null-proto descriptors so a polluted Object.prototype.get cannot turn
4094
+ // these data descriptors into accessor descriptors on the way in.
3766
4095
  Object.defineProperty(fn, 'name', {
4096
+ __proto__: null,
3767
4097
  value: value
3768
4098
  });
3769
4099
  } catch (e) {
3770
4100
  // eslint-disable-next-line no-empty
3771
4101
  }
3772
4102
  Object.defineProperty(fn, 'adapterName', {
4103
+ __proto__: null,
3773
4104
  value: value
3774
4105
  });
3775
4106
  }
@@ -3892,8 +4223,15 @@
3892
4223
  return adapter(config).then(function onAdapterResolution(response) {
3893
4224
  throwIfCancellationRequested(config);
3894
4225
 
3895
- // Transform response data
3896
- response.data = transformData.call(config, config.transformResponse, response);
4226
+ // Expose the current response on config so that transformResponse can
4227
+ // attach it to any AxiosError it throws (e.g. on JSON parse failure).
4228
+ // We clean it up afterwards to avoid polluting the config object.
4229
+ config.response = response;
4230
+ try {
4231
+ response.data = transformData.call(config, config.transformResponse, response);
4232
+ } finally {
4233
+ delete config.response;
4234
+ }
3897
4235
  response.headers = AxiosHeaders.from(response.headers);
3898
4236
  return response;
3899
4237
  }, function onAdapterRejection(reason) {
@@ -3902,7 +4240,12 @@
3902
4240
 
3903
4241
  // Transform response data
3904
4242
  if (reason && reason.response) {
3905
- reason.response.data = transformData.call(config, config.transformResponse, reason.response);
4243
+ config.response = reason.response;
4244
+ try {
4245
+ reason.response.data = transformData.call(config, config.transformResponse, reason.response);
4246
+ } finally {
4247
+ delete config.response;
4248
+ }
3906
4249
  reason.response.headers = AxiosHeaders.from(reason.response.headers);
3907
4250
  }
3908
4251
  }
@@ -3910,8 +4253,6 @@
3910
4253
  });
3911
4254
  }
3912
4255
 
3913
- var VERSION = "1.15.2";
3914
-
3915
4256
  var validators$1 = {};
3916
4257
 
3917
4258
  // eslint-disable-next-line func-names
@@ -3976,7 +4317,7 @@
3976
4317
  while (i-- > 0) {
3977
4318
  var opt = keys[i];
3978
4319
  // Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
3979
- // a non-function validator and cause a TypeError. See GHSA-q8qp-cvcw-x6jj.
4320
+ // a non-function validator and cause a TypeError.
3980
4321
  var validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
3981
4322
  if (validator) {
3982
4323
  var value = options[opt];
@@ -4131,7 +4472,7 @@
4131
4472
 
4132
4473
  // Flatten headers
4133
4474
  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) {
4475
+ headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], function (method) {
4135
4476
  delete headers[method];
4136
4477
  });
4137
4478
  config.headers = AxiosHeaders.concat(contextHeaders, headers);
@@ -4213,7 +4554,7 @@
4213
4554
  }));
4214
4555
  };
4215
4556
  });
4216
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
4557
+ utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
4217
4558
  function generateHTTPMethod(isForm) {
4218
4559
  return function httpMethod(url, data, config) {
4219
4560
  return this.request(mergeConfig(config || {}, {
@@ -4227,7 +4568,12 @@
4227
4568
  };
4228
4569
  }
4229
4570
  Axios.prototype[method] = generateHTTPMethod();
4230
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
4571
+
4572
+ // QUERY is a safe/idempotent read method; multipart form bodies don't fit
4573
+ // its semantics, so no queryForm shorthand is generated.
4574
+ if (method !== 'query') {
4575
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
4576
+ }
4231
4577
  });
4232
4578
 
4233
4579
  /**