contentful 11.12.0 → 11.12.2

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.
@@ -5,13 +5,13 @@ var require$$0$1 = require('stream');
5
5
  var require$$1$1 = require('path');
6
6
  var require$$3 = require('http');
7
7
  var require$$4 = require('https');
8
- var require$$0$2 = require('url');
8
+ var require$$5 = require('url');
9
9
  var require$$6 = require('fs');
10
10
  var require$$8 = require('crypto');
11
- var require$$6$1 = require('http2');
11
+ var require$$5$1 = require('http2');
12
12
  var require$$4$1 = require('assert');
13
- var require$$0$4 = require('tty');
14
- var require$$0$3 = require('os');
13
+ var require$$0$3 = require('tty');
14
+ var require$$0$2 = require('os');
15
15
  var require$$9 = require('zlib');
16
16
  var require$$11 = require('events');
17
17
  var process$1 = require('process');
@@ -12533,10 +12533,10 @@ var populate$1 = function (dst, src) {
12533
12533
 
12534
12534
  var CombinedStream = combined_stream;
12535
12535
  var util$1 = require$$1;
12536
- var path = require$$1$1;
12536
+ var path$1 = require$$1$1;
12537
12537
  var http$2 = require$$3;
12538
12538
  var https$2 = require$$4;
12539
- var parseUrl$2 = require$$0$2.parse;
12539
+ var parseUrl$2 = require$$5.parse;
12540
12540
  var fs = require$$6;
12541
12541
  var Stream = require$$0$1.Stream;
12542
12542
  var crypto$1 = require$$8;
@@ -12738,17 +12738,17 @@ FormData$2.prototype._getContentDisposition = function (value, options) {
12738
12738
  var filename;
12739
12739
  if (typeof options.filepath === 'string') {
12740
12740
  // custom filepath for relative paths
12741
- filename = path.normalize(options.filepath).replace(/\\/g, '/');
12741
+ filename = path$1.normalize(options.filepath).replace(/\\/g, '/');
12742
12742
  } else if (options.filename || value && (value.name || value.path)) {
12743
12743
  /*
12744
12744
  * custom filename take precedence
12745
12745
  * formidable and the browser add a name property
12746
12746
  * fs- and request- streams have path property
12747
12747
  */
12748
- filename = path.basename(options.filename || value && (value.name || value.path));
12748
+ filename = path$1.basename(options.filename || value && (value.name || value.path));
12749
12749
  } else if (value && value.readable && hasOwn$1(value, 'httpVersion')) {
12750
12750
  // or try http response
12751
- filename = path.basename(value.client._httpMessage.path || '');
12751
+ filename = path$1.basename(value.client._httpMessage.path || '');
12752
12752
  }
12753
12753
  if (filename) {
12754
12754
  return 'filename="' + filename + '"';
@@ -12982,101 +12982,6 @@ setToStringTag(FormData$2.prototype, 'FormData');
12982
12982
  // Public API
12983
12983
  var form_data = FormData$2;
12984
12984
 
12985
- var proxyFromEnv$1 = {};
12986
-
12987
- var parseUrl$1 = require$$0$2.parse;
12988
- var DEFAULT_PORTS = {
12989
- ftp: 21,
12990
- gopher: 70,
12991
- http: 80,
12992
- https: 443,
12993
- ws: 80,
12994
- wss: 443
12995
- };
12996
- var stringEndsWith = String.prototype.endsWith || function (s) {
12997
- return s.length <= this.length && this.indexOf(s, this.length - s.length) !== -1;
12998
- };
12999
-
13000
- /**
13001
- * @param {string|object} url - The URL, or the result from url.parse.
13002
- * @return {string} The URL of the proxy that should handle the request to the
13003
- * given URL. If no proxy is set, this will be an empty string.
13004
- */
13005
- function getProxyForUrl(url) {
13006
- var parsedUrl = typeof url === 'string' ? parseUrl$1(url) : url || {};
13007
- var proto = parsedUrl.protocol;
13008
- var hostname = parsedUrl.host;
13009
- var port = parsedUrl.port;
13010
- if (typeof hostname !== 'string' || !hostname || typeof proto !== 'string') {
13011
- return ''; // Don't proxy URLs without a valid scheme or host.
13012
- }
13013
- proto = proto.split(':', 1)[0];
13014
- // Stripping ports in this way instead of using parsedUrl.hostname to make
13015
- // sure that the brackets around IPv6 addresses are kept.
13016
- hostname = hostname.replace(/:\d*$/, '');
13017
- port = parseInt(port) || DEFAULT_PORTS[proto] || 0;
13018
- if (!shouldProxy(hostname, port)) {
13019
- return ''; // Don't proxy URLs that match NO_PROXY.
13020
- }
13021
- var proxy = getEnv('npm_config_' + proto + '_proxy') || getEnv(proto + '_proxy') || getEnv('npm_config_proxy') || getEnv('all_proxy');
13022
- if (proxy && proxy.indexOf('://') === -1) {
13023
- // Missing scheme in proxy, default to the requested URL's scheme.
13024
- proxy = proto + '://' + proxy;
13025
- }
13026
- return proxy;
13027
- }
13028
-
13029
- /**
13030
- * Determines whether a given URL should be proxied.
13031
- *
13032
- * @param {string} hostname - The host name of the URL.
13033
- * @param {number} port - The effective port of the URL.
13034
- * @returns {boolean} Whether the given URL should be proxied.
13035
- * @private
13036
- */
13037
- function shouldProxy(hostname, port) {
13038
- var NO_PROXY = (getEnv('npm_config_no_proxy') || getEnv('no_proxy')).toLowerCase();
13039
- if (!NO_PROXY) {
13040
- return true; // Always proxy if NO_PROXY is not set.
13041
- }
13042
- if (NO_PROXY === '*') {
13043
- return false; // Never proxy if wildcard is set.
13044
- }
13045
- return NO_PROXY.split(/[,\s]/).every(function (proxy) {
13046
- if (!proxy) {
13047
- return true; // Skip zero-length hosts.
13048
- }
13049
- var parsedProxy = proxy.match(/^(.+):(\d+)$/);
13050
- var parsedProxyHostname = parsedProxy ? parsedProxy[1] : proxy;
13051
- var parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
13052
- if (parsedProxyPort && parsedProxyPort !== port) {
13053
- return true; // Skip if ports don't match.
13054
- }
13055
- if (!/^[.*]/.test(parsedProxyHostname)) {
13056
- // No wildcards, so stop proxying if there is an exact match.
13057
- return hostname !== parsedProxyHostname;
13058
- }
13059
- if (parsedProxyHostname.charAt(0) === '*') {
13060
- // Remove leading wildcard.
13061
- parsedProxyHostname = parsedProxyHostname.slice(1);
13062
- }
13063
- // Stop proxying if the hostname ends with the no_proxy host.
13064
- return !stringEndsWith.call(hostname, parsedProxyHostname);
13065
- });
13066
- }
13067
-
13068
- /**
13069
- * Get the value for an environment variable.
13070
- *
13071
- * @param {string} key - The name of the environment variable.
13072
- * @return {string} The value of the environment variable.
13073
- * @private
13074
- */
13075
- function getEnv(key) {
13076
- return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
13077
- }
13078
- proxyFromEnv$1.getProxyForUrl = getProxyForUrl;
13079
-
13080
12985
  var followRedirects$1 = {exports: {}};
13081
12986
 
13082
12987
  var src = {exports: {}};
@@ -13732,7 +13637,7 @@ var hasRequiredSupportsColor;
13732
13637
  function requireSupportsColor() {
13733
13638
  if (hasRequiredSupportsColor) return supportsColor_1;
13734
13639
  hasRequiredSupportsColor = 1;
13735
- const os = require$$0$3;
13640
+ const os = require$$0$2;
13736
13641
  const hasFlag = requireHasFlag();
13737
13642
  const env = process.env;
13738
13643
  let forceColor;
@@ -13838,7 +13743,7 @@ function requireNode() {
13838
13743
  if (hasRequiredNode) return node.exports;
13839
13744
  hasRequiredNode = 1;
13840
13745
  (function (module, exports$1) {
13841
- const tty = require$$0$4;
13746
+ const tty = require$$0$3;
13842
13747
  const util = require$$1;
13843
13748
 
13844
13749
  /**
@@ -14039,7 +13944,7 @@ var debug_1 = function () {
14039
13944
  debug$1.apply(null, arguments);
14040
13945
  };
14041
13946
 
14042
- var url$1 = require$$0$2;
13947
+ var url$1 = require$$5;
14043
13948
  var URL$1 = url$1.URL;
14044
13949
  var http$1 = require$$3;
14045
13950
  var https$1 = require$$4;
@@ -14066,6 +13971,9 @@ try {
14066
13971
  useNativeURL = error.code === "ERR_INVALID_URL";
14067
13972
  }
14068
13973
 
13974
+ // HTTP headers to drop across HTTP/HTTPS and domain boundaries
13975
+ var sensitiveHeaders = ["Authorization", "Proxy-Authorization", "Cookie"];
13976
+
14069
13977
  // URL fields to preserve in copy operations
14070
13978
  var preservedUrlFields = ["auth", "host", "hostname", "href", "path", "pathname", "port", "protocol", "query", "search", "hash"];
14071
13979
 
@@ -14118,6 +14026,9 @@ function RedirectableRequest(options, responseCallback) {
14118
14026
  }
14119
14027
  };
14120
14028
 
14029
+ // Create filter for sensitive HTTP headers
14030
+ this._headerFilter = new RegExp("^(?:" + sensitiveHeaders.concat(options.sensitiveHeaders).map(escapeRegex).join("|") + ")$", "i");
14031
+
14121
14032
  // Perform the first request
14122
14033
  this._performRequest();
14123
14034
  }
@@ -14296,6 +14207,9 @@ RedirectableRequest.prototype._sanitizeOptions = function (options) {
14296
14207
  if (!options.headers) {
14297
14208
  options.headers = {};
14298
14209
  }
14210
+ if (!isArray$8(options.sensitiveHeaders)) {
14211
+ options.sensitiveHeaders = [];
14212
+ }
14299
14213
 
14300
14214
  // Since http.request treats host as an alias of hostname,
14301
14215
  // but the url module interprets host as hostname plus port,
@@ -14456,7 +14370,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
14456
14370
  var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
14457
14371
 
14458
14372
  // If the redirect is relative, carry over the host of the last request
14459
- var currentUrlParts = parseUrl(this._currentUrl);
14373
+ var currentUrlParts = parseUrl$1(this._currentUrl);
14460
14374
  var currentHost = currentHostHeader || currentUrlParts.host;
14461
14375
  var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url$1.format(Object.assign(currentUrlParts, {
14462
14376
  host: currentHost
@@ -14471,7 +14385,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
14471
14385
  // Drop confidential headers when redirecting to a less secure protocol
14472
14386
  // or to a different domain that is not a superdomain
14473
14387
  if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) {
14474
- removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
14388
+ removeMatchingHeaders(this._headerFilter, this._options.headers);
14475
14389
  }
14476
14390
 
14477
14391
  // Evaluate the beforeRedirect callback
@@ -14514,7 +14428,7 @@ function wrap(protocols) {
14514
14428
  if (isURL(input)) {
14515
14429
  input = spreadUrlObject(input);
14516
14430
  } else if (isString$4(input)) {
14517
- input = spreadUrlObject(parseUrl(input));
14431
+ input = spreadUrlObject(parseUrl$1(input));
14518
14432
  } else {
14519
14433
  callback = options;
14520
14434
  options = validateUrl(input);
@@ -14567,7 +14481,7 @@ function wrap(protocols) {
14567
14481
  return exports$1;
14568
14482
  }
14569
14483
  function noop$2() {/* empty */}
14570
- function parseUrl(input) {
14484
+ function parseUrl$1(input) {
14571
14485
  var parsed;
14572
14486
  // istanbul ignore else
14573
14487
  if (useNativeURL) {
@@ -14585,7 +14499,7 @@ function parseUrl(input) {
14585
14499
  }
14586
14500
  function resolveUrl(relative, base) {
14587
14501
  // istanbul ignore next
14588
- return useNativeURL ? new URL$1(relative, base) : parseUrl(url$1.resolve(base, relative));
14502
+ return useNativeURL ? new URL$1(relative, base) : parseUrl$1(url$1.resolve(base, relative));
14589
14503
  }
14590
14504
  function validateUrl(input) {
14591
14505
  if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
@@ -14666,6 +14580,9 @@ function isSubdomain(subdomain, domain) {
14666
14580
  var dot = subdomain.length - domain.length - 1;
14667
14581
  return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
14668
14582
  }
14583
+ function isArray$8(value) {
14584
+ return value instanceof Array;
14585
+ }
14669
14586
  function isString$4(value) {
14670
14587
  return typeof value === "string" || value instanceof String;
14671
14588
  }
@@ -14678,6 +14595,9 @@ function isBuffer$2(value) {
14678
14595
  function isURL(value) {
14679
14596
  return URL$1 && value instanceof URL$1;
14680
14597
  }
14598
+ function escapeRegex(regex) {
14599
+ return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
14600
+ }
14681
14601
 
14682
14602
  // Exports
14683
14603
  followRedirects$1.exports = wrap({
@@ -14687,34 +14607,18 @@ followRedirects$1.exports = wrap({
14687
14607
  followRedirects$1.exports.wrap = wrap;
14688
14608
  var followRedirectsExports = followRedirects$1.exports;
14689
14609
 
14690
- const FormData$1 = form_data;
14691
- const crypto = require$$8;
14692
- const url = require$$0$2;
14693
- const proxyFromEnv = proxyFromEnv$1;
14694
- const http = require$$3;
14695
- const https = require$$4;
14696
- const http2 = require$$6$1;
14697
- const util = require$$1;
14698
- const followRedirects = followRedirectsExports;
14699
- const zlib = require$$9;
14700
- const stream = require$$0$1;
14701
- const events = require$$11;
14702
- function _interopDefaultLegacy(e) {
14703
- return e && typeof e === 'object' && 'default' in e ? e : {
14704
- 'default': e
14705
- };
14706
- }
14707
- const FormData__default = /*#__PURE__*/_interopDefaultLegacy(FormData$1);
14708
- const crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
14709
- const url__default = /*#__PURE__*/_interopDefaultLegacy(url);
14710
- const proxyFromEnv__default = /*#__PURE__*/_interopDefaultLegacy(proxyFromEnv);
14711
- const http__default = /*#__PURE__*/_interopDefaultLegacy(http);
14712
- const https__default = /*#__PURE__*/_interopDefaultLegacy(https);
14713
- const http2__default = /*#__PURE__*/_interopDefaultLegacy(http2);
14714
- const util__default = /*#__PURE__*/_interopDefaultLegacy(util);
14715
- const followRedirects__default = /*#__PURE__*/_interopDefaultLegacy(followRedirects);
14716
- const zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
14717
- const stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
14610
+ var FormData$1 = form_data;
14611
+ var crypto = require$$8;
14612
+ var url = require$$5;
14613
+ var http = require$$3;
14614
+ var https = require$$4;
14615
+ var http2 = require$$5$1;
14616
+ var util = require$$1;
14617
+ var path = require$$1$1;
14618
+ var followRedirects = followRedirectsExports;
14619
+ var zlib = require$$9;
14620
+ var stream = require$$0$1;
14621
+ var events = require$$11;
14718
14622
 
14719
14623
  /**
14720
14624
  * Create a bound version of a function with a specified `this` context
@@ -14910,9 +14814,9 @@ const isFile = kindOfTest('File');
14910
14814
  * also have a `name` and `type` attribute to specify filename and content type
14911
14815
  *
14912
14816
  * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
14913
- *
14817
+ *
14914
14818
  * @param {*} value The value to test
14915
- *
14819
+ *
14916
14820
  * @returns {boolean} True if value is a React Native Blob, otherwise false
14917
14821
  */
14918
14822
  const isReactNativeBlob = value => {
@@ -14922,9 +14826,9 @@ const isReactNativeBlob = value => {
14922
14826
  /**
14923
14827
  * Determine if environment is React Native
14924
14828
  * ReactNative `FormData` has a non-standard `getParts()` method
14925
- *
14829
+ *
14926
14830
  * @param {*} formData The formData to test
14927
- *
14831
+ *
14928
14832
  * @returns {boolean} True if environment is React Native, otherwise false
14929
14833
  */
14930
14834
  const isReactNative$1 = formData => formData && typeof formData.getParts !== 'undefined';
@@ -14943,7 +14847,7 @@ const isBlob = kindOfTest('Blob');
14943
14847
  *
14944
14848
  * @param {*} val The value to test
14945
14849
  *
14946
- * @returns {boolean} True if value is a File, otherwise false
14850
+ * @returns {boolean} True if value is a FileList, otherwise false
14947
14851
  */
14948
14852
  const isFileList = kindOfTest('FileList');
14949
14853
 
@@ -14973,10 +14877,16 @@ function getGlobal() {
14973
14877
  const G$1 = getGlobal();
14974
14878
  const FormDataCtor = typeof G$1.FormData !== 'undefined' ? G$1.FormData : undefined;
14975
14879
  const isFormData = thing => {
14976
- let kind;
14977
- return thing && (FormDataCtor && thing instanceof FormDataCtor || isFunction$1(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
14880
+ if (!thing) return false;
14881
+ if (FormDataCtor && thing instanceof FormDataCtor) return true;
14882
+ // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
14883
+ const proto = getPrototypeOf$1(thing);
14884
+ if (!proto || proto === Object.prototype) return false;
14885
+ if (!isFunction$1(thing.append)) return false;
14886
+ const kind = kindOf(thing);
14887
+ return kind === 'formdata' ||
14978
14888
  // detect form-data instance
14979
- kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]'));
14889
+ kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]';
14980
14890
  };
14981
14891
 
14982
14892
  /**
@@ -15101,8 +15011,7 @@ const isContextDefined = context => !isUndefined(context) && context !== _global
15101
15011
  *
15102
15012
  * @returns {Object} Result of all merge properties
15103
15013
  */
15104
- function merge$1(/* obj1, obj2, obj3, ... */
15105
- ) {
15014
+ function merge$1(...objs) {
15106
15015
  const {
15107
15016
  caseless,
15108
15017
  skipUndefined
@@ -15114,8 +15023,12 @@ function merge$1(/* obj1, obj2, obj3, ... */
15114
15023
  return;
15115
15024
  }
15116
15025
  const targetKey = caseless && findKey(result, key) || key;
15117
- if (isPlainObject$2(result[targetKey]) && isPlainObject$2(val)) {
15118
- result[targetKey] = merge$1(result[targetKey], val);
15026
+ // Read via own-prop only — a bare `result[targetKey]` walks the prototype
15027
+ // chain, so a polluted Object.prototype value could surface here and get
15028
+ // copied into the merged result.
15029
+ const existing = hasOwnProperty$3(result, targetKey) ? result[targetKey] : undefined;
15030
+ if (isPlainObject$2(existing) && isPlainObject$2(val)) {
15031
+ result[targetKey] = merge$1(existing, val);
15119
15032
  } else if (isPlainObject$2(val)) {
15120
15033
  result[targetKey] = merge$1({}, val);
15121
15034
  } else if (isArray$7(val)) {
@@ -15124,8 +15037,8 @@ function merge$1(/* obj1, obj2, obj3, ... */
15124
15037
  result[targetKey] = val;
15125
15038
  }
15126
15039
  };
15127
- for (let i = 0, l = arguments.length; i < l; i++) {
15128
- arguments[i] && forEach(arguments[i], assignValue);
15040
+ for (let i = 0, l = objs.length; i < l; i++) {
15041
+ objs[i] && forEach(objs[i], assignValue);
15129
15042
  }
15130
15043
  return result;
15131
15044
  }
@@ -15147,6 +15060,9 @@ const extend = (a, b, thisArg, {
15147
15060
  forEach(b, (val, key) => {
15148
15061
  if (thisArg && isFunction$1(val)) {
15149
15062
  Object.defineProperty(a, key, {
15063
+ // Null-proto descriptor so a polluted Object.prototype.get cannot
15064
+ // hijack defineProperty's accessor-vs-data resolution.
15065
+ __proto__: null,
15150
15066
  value: bind(val, thisArg),
15151
15067
  writable: true,
15152
15068
  enumerable: true,
@@ -15154,6 +15070,7 @@ const extend = (a, b, thisArg, {
15154
15070
  });
15155
15071
  } else {
15156
15072
  Object.defineProperty(a, key, {
15073
+ __proto__: null,
15157
15074
  value: val,
15158
15075
  writable: true,
15159
15076
  enumerable: true,
@@ -15192,12 +15109,14 @@ const stripBOM = content => {
15192
15109
  const inherits = (constructor, superConstructor, props, descriptors) => {
15193
15110
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
15194
15111
  Object.defineProperty(constructor.prototype, 'constructor', {
15112
+ __proto__: null,
15195
15113
  value: constructor,
15196
15114
  writable: true,
15197
15115
  enumerable: false,
15198
15116
  configurable: true
15199
15117
  });
15200
15118
  Object.defineProperty(constructor, 'super', {
15119
+ __proto__: null,
15201
15120
  value: superConstructor.prototype
15202
15121
  });
15203
15122
  props && Object.assign(constructor.prototype, props);
@@ -15365,7 +15284,7 @@ const reduceDescriptors = (obj, reducer) => {
15365
15284
  const freezeMethods = obj => {
15366
15285
  reduceDescriptors(obj, (descriptor, name) => {
15367
15286
  // skip restricted props in strict mode
15368
- if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
15287
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
15369
15288
  return false;
15370
15289
  }
15371
15290
  const value = obj[name];
@@ -15509,7 +15428,7 @@ const asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global
15509
15428
  // *********************
15510
15429
 
15511
15430
  const isIterable = thing => thing != null && isFunction$1(thing[iterator]);
15512
- const utils$1$1 = {
15431
+ var utils$1$1 = {
15513
15432
  isArray: isArray$7,
15514
15433
  isArrayBuffer,
15515
15434
  isBuffer: isBuffer$1,
@@ -15571,355 +15490,726 @@ const utils$1$1 = {
15571
15490
  asap,
15572
15491
  isIterable
15573
15492
  };
15574
- class AxiosError extends Error {
15575
- static from(error, code, config, request, response, customProps) {
15576
- const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
15577
- axiosError.cause = error;
15578
- axiosError.name = error.name;
15579
-
15580
- // Preserve status from the original error if not already set from response
15581
- if (error.status != null && axiosError.status == null) {
15582
- axiosError.status = error.status;
15583
- }
15584
- customProps && Object.assign(axiosError, customProps);
15585
- return axiosError;
15586
- }
15587
-
15588
- /**
15589
- * Create an Error with the specified message, config, error code, request and response.
15590
- *
15591
- * @param {string} message The error message.
15592
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
15593
- * @param {Object} [config] The config.
15594
- * @param {Object} [request] The request.
15595
- * @param {Object} [response] The response.
15596
- *
15597
- * @returns {Error} The created error.
15598
- */
15599
- constructor(message, code, config, request, response) {
15600
- super(message);
15601
-
15602
- // Make message enumerable to maintain backward compatibility
15603
- // The native Error constructor sets message as non-enumerable,
15604
- // but axios < v1.13.3 had it as enumerable
15605
- Object.defineProperty(this, 'message', {
15606
- value: message,
15607
- enumerable: true,
15608
- writable: true,
15609
- configurable: true
15610
- });
15611
- this.name = 'AxiosError';
15612
- this.isAxiosError = true;
15613
- code && (this.code = code);
15614
- config && (this.config = config);
15615
- request && (this.request = request);
15616
- if (response) {
15617
- this.response = response;
15618
- this.status = response.status;
15619
- }
15620
- }
15621
- toJSON() {
15622
- return {
15623
- // Standard
15624
- message: this.message,
15625
- name: this.name,
15626
- // Microsoft
15627
- description: this.description,
15628
- number: this.number,
15629
- // Mozilla
15630
- fileName: this.fileName,
15631
- lineNumber: this.lineNumber,
15632
- columnNumber: this.columnNumber,
15633
- stack: this.stack,
15634
- // Axios
15635
- config: utils$1$1.toJSONObject(this.config),
15636
- code: this.code,
15637
- status: this.status
15638
- };
15639
- }
15640
- }
15641
15493
 
15642
- // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
15643
- AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
15644
- AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
15645
- AxiosError.ECONNABORTED = 'ECONNABORTED';
15646
- AxiosError.ETIMEDOUT = 'ETIMEDOUT';
15647
- AxiosError.ERR_NETWORK = 'ERR_NETWORK';
15648
- AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
15649
- AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
15650
- AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
15651
- AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
15652
- AxiosError.ERR_CANCELED = 'ERR_CANCELED';
15653
- AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
15654
- AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
15655
- const AxiosError$1 = AxiosError;
15494
+ // RawAxiosHeaders whose duplicates are ignored by node
15495
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
15496
+ const ignoreDuplicateOf = utils$1$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']);
15656
15497
 
15657
15498
  /**
15658
- * Determines if the given thing is a array or js object.
15659
- *
15660
- * @param {string} thing - The object or array to be visited.
15499
+ * Parse headers into an object
15661
15500
  *
15662
- * @returns {boolean}
15663
- */
15664
- function isVisitable(thing) {
15665
- return utils$1$1.isPlainObject(thing) || utils$1$1.isArray(thing);
15666
- }
15667
-
15668
- /**
15669
- * It removes the brackets from the end of a string
15501
+ * ```
15502
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
15503
+ * Content-Type: application/json
15504
+ * Connection: keep-alive
15505
+ * Transfer-Encoding: chunked
15506
+ * ```
15670
15507
  *
15671
- * @param {string} key - The key of the parameter.
15508
+ * @param {String} rawHeaders Headers needing to be parsed
15672
15509
  *
15673
- * @returns {string} the key without the brackets.
15510
+ * @returns {Object} Headers parsed into an object
15674
15511
  */
15675
- function removeBrackets(key) {
15676
- return utils$1$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
15512
+ var parseHeaders = rawHeaders => {
15513
+ const parsed = {};
15514
+ let key;
15515
+ let val;
15516
+ let i;
15517
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
15518
+ i = line.indexOf(':');
15519
+ key = line.substring(0, i).trim().toLowerCase();
15520
+ val = line.substring(i + 1).trim();
15521
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
15522
+ return;
15523
+ }
15524
+ if (key === 'set-cookie') {
15525
+ if (parsed[key]) {
15526
+ parsed[key].push(val);
15527
+ } else {
15528
+ parsed[key] = [val];
15529
+ }
15530
+ } else {
15531
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
15532
+ }
15533
+ });
15534
+ return parsed;
15535
+ };
15536
+ const $internals = Symbol('internals');
15537
+ const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
15538
+ function trimSPorHTAB(str) {
15539
+ let start = 0;
15540
+ let end = str.length;
15541
+ while (start < end) {
15542
+ const code = str.charCodeAt(start);
15543
+ if (code !== 0x09 && code !== 0x20) {
15544
+ break;
15545
+ }
15546
+ start += 1;
15547
+ }
15548
+ while (end > start) {
15549
+ const code = str.charCodeAt(end - 1);
15550
+ if (code !== 0x09 && code !== 0x20) {
15551
+ break;
15552
+ }
15553
+ end -= 1;
15554
+ }
15555
+ return start === 0 && end === str.length ? str : str.slice(start, end);
15677
15556
  }
15678
-
15679
- /**
15680
- * It takes a path, a key, and a boolean, and returns a string
15681
- *
15682
- * @param {string} path - The path to the current key.
15683
- * @param {string} key - The key of the current object being iterated over.
15684
- * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
15685
- *
15686
- * @returns {string} The path to the current key.
15687
- */
15688
- function renderKey(path, key, dots) {
15689
- if (!path) return key;
15690
- return path.concat(key).map(function each(token, i) {
15691
- // eslint-disable-next-line no-param-reassign
15692
- token = removeBrackets(token);
15693
- return !dots && i ? '[' + token + ']' : token;
15694
- }).join(dots ? '.' : '');
15557
+ function normalizeHeader(header) {
15558
+ return header && String(header).trim().toLowerCase();
15695
15559
  }
15696
-
15697
- /**
15698
- * If the array is an array and none of its elements are visitable, then it's a flat array.
15699
- *
15700
- * @param {Array<any>} arr - The array to check
15701
- *
15702
- * @returns {boolean}
15703
- */
15704
- function isFlatArray(arr) {
15705
- return utils$1$1.isArray(arr) && !arr.some(isVisitable);
15560
+ function sanitizeHeaderValue(str) {
15561
+ return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
15706
15562
  }
15707
- const predicates = utils$1$1.toFlatObject(utils$1$1, {}, null, function filter(prop) {
15708
- return /^is[A-Z]/.test(prop);
15709
- });
15710
-
15711
- /**
15712
- * Convert a data object to FormData
15713
- *
15714
- * @param {Object} obj
15715
- * @param {?Object} [formData]
15716
- * @param {?Object} [options]
15717
- * @param {Function} [options.visitor]
15718
- * @param {Boolean} [options.metaTokens = true]
15719
- * @param {Boolean} [options.dots = false]
15720
- * @param {?Boolean} [options.indexes = false]
15721
- *
15722
- * @returns {Object}
15723
- **/
15724
-
15725
- /**
15726
- * It converts an object into a FormData object
15727
- *
15728
- * @param {Object<any, any>} obj - The object to convert to form data.
15729
- * @param {string} formData - The FormData object to append to.
15730
- * @param {Object<string, any>} options
15731
- *
15732
- * @returns
15733
- */
15734
- function toFormData(obj, formData, options) {
15735
- if (!utils$1$1.isObject(obj)) {
15736
- throw new TypeError('target must be an object');
15563
+ function normalizeValue(value) {
15564
+ if (value === false || value == null) {
15565
+ return value;
15737
15566
  }
15738
-
15739
- // eslint-disable-next-line no-param-reassign
15740
- formData = formData || new (FormData__default["default"] || FormData)();
15741
-
15742
- // eslint-disable-next-line no-param-reassign
15743
- options = utils$1$1.toFlatObject(options, {
15744
- metaTokens: true,
15745
- dots: false,
15746
- indexes: false
15747
- }, false, function defined(option, source) {
15748
- // eslint-disable-next-line no-eq-null,eqeqeq
15749
- return !utils$1$1.isUndefined(source[option]);
15567
+ return utils$1$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
15568
+ }
15569
+ function parseTokens(str) {
15570
+ const tokens = Object.create(null);
15571
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
15572
+ let match;
15573
+ while (match = tokensRE.exec(str)) {
15574
+ tokens[match[1]] = match[2];
15575
+ }
15576
+ return tokens;
15577
+ }
15578
+ const isValidHeaderName = str => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
15579
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
15580
+ if (utils$1$1.isFunction(filter)) {
15581
+ return filter.call(this, value, header);
15582
+ }
15583
+ if (isHeaderNameFilter) {
15584
+ value = header;
15585
+ }
15586
+ if (!utils$1$1.isString(value)) return;
15587
+ if (utils$1$1.isString(filter)) {
15588
+ return value.indexOf(filter) !== -1;
15589
+ }
15590
+ if (utils$1$1.isRegExp(filter)) {
15591
+ return filter.test(value);
15592
+ }
15593
+ }
15594
+ function formatHeader(header) {
15595
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
15596
+ return char.toUpperCase() + str;
15750
15597
  });
15751
- const metaTokens = options.metaTokens;
15752
- // eslint-disable-next-line no-use-before-define
15753
- const visitor = options.visitor || defaultVisitor;
15754
- const dots = options.dots;
15755
- const indexes = options.indexes;
15756
- const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
15757
- const useBlob = _Blob && utils$1$1.isSpecCompliantForm(formData);
15758
- if (!utils$1$1.isFunction(visitor)) {
15759
- throw new TypeError('visitor must be a function');
15598
+ }
15599
+ function buildAccessors(obj, header) {
15600
+ const accessorName = utils$1$1.toCamelCase(' ' + header);
15601
+ ['get', 'set', 'has'].forEach(methodName => {
15602
+ Object.defineProperty(obj, methodName + accessorName, {
15603
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
15604
+ // this data descriptor into an accessor descriptor on the way in.
15605
+ __proto__: null,
15606
+ value: function (arg1, arg2, arg3) {
15607
+ return this[methodName].call(this, header, arg1, arg2, arg3);
15608
+ },
15609
+ configurable: true
15610
+ });
15611
+ });
15612
+ }
15613
+ class AxiosHeaders {
15614
+ constructor(headers) {
15615
+ headers && this.set(headers);
15760
15616
  }
15761
- function convertValue(value) {
15762
- if (value === null) return '';
15763
- if (utils$1$1.isDate(value)) {
15764
- return value.toISOString();
15765
- }
15766
- if (utils$1$1.isBoolean(value)) {
15767
- return value.toString();
15768
- }
15769
- if (!useBlob && utils$1$1.isBlob(value)) {
15770
- throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
15617
+ set(header, valueOrRewrite, rewrite) {
15618
+ const self = this;
15619
+ function setHeader(_value, _header, _rewrite) {
15620
+ const lHeader = normalizeHeader(_header);
15621
+ if (!lHeader) {
15622
+ throw new Error('header name must be a non-empty string');
15623
+ }
15624
+ const key = utils$1$1.findKey(self, lHeader);
15625
+ if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
15626
+ self[key || _header] = normalizeValue(_value);
15627
+ }
15771
15628
  }
15772
- if (utils$1$1.isArrayBuffer(value) || utils$1$1.isTypedArray(value)) {
15773
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
15629
+ const setHeaders = (headers, _rewrite) => utils$1$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
15630
+ if (utils$1$1.isPlainObject(header) || header instanceof this.constructor) {
15631
+ setHeaders(header, valueOrRewrite);
15632
+ } else if (utils$1$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
15633
+ setHeaders(parseHeaders(header), valueOrRewrite);
15634
+ } else if (utils$1$1.isObject(header) && utils$1$1.isIterable(header)) {
15635
+ let obj = {},
15636
+ dest,
15637
+ key;
15638
+ for (const entry of header) {
15639
+ if (!utils$1$1.isArray(entry)) {
15640
+ throw TypeError('Object iterator must return a key-value pair');
15641
+ }
15642
+ obj[key = entry[0]] = (dest = obj[key]) ? utils$1$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
15643
+ }
15644
+ setHeaders(obj, valueOrRewrite);
15645
+ } else {
15646
+ header != null && setHeader(valueOrRewrite, header, rewrite);
15774
15647
  }
15775
- return value;
15648
+ return this;
15776
15649
  }
15777
-
15778
- /**
15779
- * Default visitor.
15780
- *
15781
- * @param {*} value
15782
- * @param {String|Number} key
15783
- * @param {Array<String|Number>} path
15784
- * @this {FormData}
15785
- *
15786
- * @returns {boolean} return true to visit the each prop of the value recursively
15787
- */
15788
- function defaultVisitor(value, key, path) {
15789
- let arr = value;
15790
- if (utils$1$1.isReactNative(formData) && utils$1$1.isReactNativeBlob(value)) {
15791
- formData.append(renderKey(path, key, dots), convertValue(value));
15792
- return false;
15793
- }
15794
- if (value && !path && typeof value === 'object') {
15795
- if (utils$1$1.endsWith(key, '{}')) {
15796
- // eslint-disable-next-line no-param-reassign
15797
- key = metaTokens ? key : key.slice(0, -2);
15798
- // eslint-disable-next-line no-param-reassign
15799
- value = JSON.stringify(value);
15800
- } else if (utils$1$1.isArray(value) && isFlatArray(value) || (utils$1$1.isFileList(value) || utils$1$1.endsWith(key, '[]')) && (arr = utils$1$1.toArray(value))) {
15801
- // eslint-disable-next-line no-param-reassign
15802
- key = removeBrackets(key);
15803
- arr.forEach(function each(el, index) {
15804
- !(utils$1$1.isUndefined(el) || el === null) && formData.append(
15805
- // eslint-disable-next-line no-nested-ternary
15806
- indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
15807
- });
15808
- return false;
15650
+ get(header, parser) {
15651
+ header = normalizeHeader(header);
15652
+ if (header) {
15653
+ const key = utils$1$1.findKey(this, header);
15654
+ if (key) {
15655
+ const value = this[key];
15656
+ if (!parser) {
15657
+ return value;
15658
+ }
15659
+ if (parser === true) {
15660
+ return parseTokens(value);
15661
+ }
15662
+ if (utils$1$1.isFunction(parser)) {
15663
+ return parser.call(this, value, key);
15664
+ }
15665
+ if (utils$1$1.isRegExp(parser)) {
15666
+ return parser.exec(value);
15667
+ }
15668
+ throw new TypeError('parser must be boolean|regexp|function');
15809
15669
  }
15810
15670
  }
15811
- if (isVisitable(value)) {
15812
- return true;
15671
+ }
15672
+ has(header, matcher) {
15673
+ header = normalizeHeader(header);
15674
+ if (header) {
15675
+ const key = utils$1$1.findKey(this, header);
15676
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
15813
15677
  }
15814
- formData.append(renderKey(path, key, dots), convertValue(value));
15815
15678
  return false;
15816
15679
  }
15817
- const stack = [];
15818
- const exposedHelpers = Object.assign(predicates, {
15819
- defaultVisitor,
15820
- convertValue,
15821
- isVisitable
15822
- });
15823
- function build(value, path) {
15824
- if (utils$1$1.isUndefined(value)) return;
15825
- if (stack.indexOf(value) !== -1) {
15826
- throw Error('Circular reference detected in ' + path.join('.'));
15827
- }
15828
- stack.push(value);
15829
- utils$1$1.forEach(value, function each(el, key) {
15830
- const result = !(utils$1$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1$1.isString(key) ? key.trim() : key, path, exposedHelpers);
15831
- if (result === true) {
15832
- build(el, path ? path.concat(key) : [key]);
15680
+ delete(header, matcher) {
15681
+ const self = this;
15682
+ let deleted = false;
15683
+ function deleteHeader(_header) {
15684
+ _header = normalizeHeader(_header);
15685
+ if (_header) {
15686
+ const key = utils$1$1.findKey(self, _header);
15687
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
15688
+ delete self[key];
15689
+ deleted = true;
15690
+ }
15833
15691
  }
15834
- });
15835
- stack.pop();
15692
+ }
15693
+ if (utils$1$1.isArray(header)) {
15694
+ header.forEach(deleteHeader);
15695
+ } else {
15696
+ deleteHeader(header);
15697
+ }
15698
+ return deleted;
15836
15699
  }
15837
- if (!utils$1$1.isObject(obj)) {
15838
- throw new TypeError('data must be an object');
15700
+ clear(matcher) {
15701
+ const keys = Object.keys(this);
15702
+ let i = keys.length;
15703
+ let deleted = false;
15704
+ while (i--) {
15705
+ const key = keys[i];
15706
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
15707
+ delete this[key];
15708
+ deleted = true;
15709
+ }
15710
+ }
15711
+ return deleted;
15712
+ }
15713
+ normalize(format) {
15714
+ const self = this;
15715
+ const headers = {};
15716
+ utils$1$1.forEach(this, (value, header) => {
15717
+ const key = utils$1$1.findKey(headers, header);
15718
+ if (key) {
15719
+ self[key] = normalizeValue(value);
15720
+ delete self[header];
15721
+ return;
15722
+ }
15723
+ const normalized = format ? formatHeader(header) : String(header).trim();
15724
+ if (normalized !== header) {
15725
+ delete self[header];
15726
+ }
15727
+ self[normalized] = normalizeValue(value);
15728
+ headers[normalized] = true;
15729
+ });
15730
+ return this;
15731
+ }
15732
+ concat(...targets) {
15733
+ return this.constructor.concat(this, ...targets);
15734
+ }
15735
+ toJSON(asStrings) {
15736
+ const obj = Object.create(null);
15737
+ utils$1$1.forEach(this, (value, header) => {
15738
+ value != null && value !== false && (obj[header] = asStrings && utils$1$1.isArray(value) ? value.join(', ') : value);
15739
+ });
15740
+ return obj;
15741
+ }
15742
+ [Symbol.iterator]() {
15743
+ return Object.entries(this.toJSON())[Symbol.iterator]();
15744
+ }
15745
+ toString() {
15746
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
15747
+ }
15748
+ getSetCookie() {
15749
+ return this.get('set-cookie') || [];
15750
+ }
15751
+ get [Symbol.toStringTag]() {
15752
+ return 'AxiosHeaders';
15753
+ }
15754
+ static from(thing) {
15755
+ return thing instanceof this ? thing : new this(thing);
15756
+ }
15757
+ static concat(first, ...targets) {
15758
+ const computed = new this(first);
15759
+ targets.forEach(target => computed.set(target));
15760
+ return computed;
15761
+ }
15762
+ static accessor(header) {
15763
+ const internals = this[$internals] = this[$internals] = {
15764
+ accessors: {}
15765
+ };
15766
+ const accessors = internals.accessors;
15767
+ const prototype = this.prototype;
15768
+ function defineAccessor(_header) {
15769
+ const lHeader = normalizeHeader(_header);
15770
+ if (!accessors[lHeader]) {
15771
+ buildAccessors(prototype, _header);
15772
+ accessors[lHeader] = true;
15773
+ }
15774
+ }
15775
+ utils$1$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
15776
+ return this;
15777
+ }
15778
+ }
15779
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
15780
+
15781
+ // reserved names hotfix
15782
+ utils$1$1.reduceDescriptors(AxiosHeaders.prototype, ({
15783
+ value
15784
+ }, key) => {
15785
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
15786
+ return {
15787
+ get: () => value,
15788
+ set(headerValue) {
15789
+ this[mapped] = headerValue;
15790
+ }
15791
+ };
15792
+ });
15793
+ utils$1$1.freezeMethods(AxiosHeaders);
15794
+ const REDACTED = '[REDACTED ****]';
15795
+ function hasOwnOrPrototypeToJSON(source) {
15796
+ if (utils$1$1.hasOwnProp(source, 'toJSON')) {
15797
+ return true;
15798
+ }
15799
+ let prototype = Object.getPrototypeOf(source);
15800
+ while (prototype && prototype !== Object.prototype) {
15801
+ if (utils$1$1.hasOwnProp(prototype, 'toJSON')) {
15802
+ return true;
15803
+ }
15804
+ prototype = Object.getPrototypeOf(prototype);
15805
+ }
15806
+ return false;
15807
+ }
15808
+
15809
+ // Build a plain-object snapshot of `config` and replace the value of any key
15810
+ // (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
15811
+ // and AxiosHeaders, and short-circuits on circular references.
15812
+ function redactConfig(config, redactKeys) {
15813
+ const lowerKeys = new Set(redactKeys.map(k => String(k).toLowerCase()));
15814
+ const seen = [];
15815
+ const visit = source => {
15816
+ if (source === null || typeof source !== 'object') return source;
15817
+ if (utils$1$1.isBuffer(source)) return source;
15818
+ if (seen.indexOf(source) !== -1) return undefined;
15819
+ if (source instanceof AxiosHeaders) {
15820
+ source = source.toJSON();
15821
+ }
15822
+ seen.push(source);
15823
+ let result;
15824
+ if (utils$1$1.isArray(source)) {
15825
+ result = [];
15826
+ source.forEach((v, i) => {
15827
+ const reducedValue = visit(v);
15828
+ if (!utils$1$1.isUndefined(reducedValue)) {
15829
+ result[i] = reducedValue;
15830
+ }
15831
+ });
15832
+ } else {
15833
+ if (!utils$1$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
15834
+ seen.pop();
15835
+ return source;
15836
+ }
15837
+ result = Object.create(null);
15838
+ for (const [key, value] of Object.entries(source)) {
15839
+ const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
15840
+ if (!utils$1$1.isUndefined(reducedValue)) {
15841
+ result[key] = reducedValue;
15842
+ }
15843
+ }
15844
+ }
15845
+ seen.pop();
15846
+ return result;
15847
+ };
15848
+ return visit(config);
15849
+ }
15850
+ class AxiosError extends Error {
15851
+ static from(error, code, config, request, response, customProps) {
15852
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
15853
+ axiosError.cause = error;
15854
+ axiosError.name = error.name;
15855
+
15856
+ // Preserve status from the original error if not already set from response
15857
+ if (error.status != null && axiosError.status == null) {
15858
+ axiosError.status = error.status;
15859
+ }
15860
+ customProps && Object.assign(axiosError, customProps);
15861
+ return axiosError;
15862
+ }
15863
+
15864
+ /**
15865
+ * Create an Error with the specified message, config, error code, request and response.
15866
+ *
15867
+ * @param {string} message The error message.
15868
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
15869
+ * @param {Object} [config] The config.
15870
+ * @param {Object} [request] The request.
15871
+ * @param {Object} [response] The response.
15872
+ *
15873
+ * @returns {Error} The created error.
15874
+ */
15875
+ constructor(message, code, config, request, response) {
15876
+ super(message);
15877
+
15878
+ // Make message enumerable to maintain backward compatibility
15879
+ // The native Error constructor sets message as non-enumerable,
15880
+ // but axios < v1.13.3 had it as enumerable
15881
+ Object.defineProperty(this, 'message', {
15882
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
15883
+ // this data descriptor into an accessor descriptor on the way in.
15884
+ __proto__: null,
15885
+ value: message,
15886
+ enumerable: true,
15887
+ writable: true,
15888
+ configurable: true
15889
+ });
15890
+ this.name = 'AxiosError';
15891
+ this.isAxiosError = true;
15892
+ code && (this.code = code);
15893
+ config && (this.config = config);
15894
+ request && (this.request = request);
15895
+ if (response) {
15896
+ this.response = response;
15897
+ this.status = response.status;
15898
+ }
15899
+ }
15900
+ toJSON() {
15901
+ // Opt-in redaction: when the request config carries a `redact` array, the
15902
+ // value of any matching key (case-insensitive, at any depth) is replaced
15903
+ // with REDACTED in the serialized snapshot. Undefined or empty leaves the
15904
+ // existing serialization behavior unchanged.
15905
+ const config = this.config;
15906
+ const redactKeys = config && utils$1$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
15907
+ const serializedConfig = utils$1$1.isArray(redactKeys) && redactKeys.length > 0 ? redactConfig(config, redactKeys) : utils$1$1.toJSONObject(config);
15908
+ return {
15909
+ // Standard
15910
+ message: this.message,
15911
+ name: this.name,
15912
+ // Microsoft
15913
+ description: this.description,
15914
+ number: this.number,
15915
+ // Mozilla
15916
+ fileName: this.fileName,
15917
+ lineNumber: this.lineNumber,
15918
+ columnNumber: this.columnNumber,
15919
+ stack: this.stack,
15920
+ // Axios
15921
+ config: serializedConfig,
15922
+ code: this.code,
15923
+ status: this.status
15924
+ };
15839
15925
  }
15840
- build(obj);
15841
- return formData;
15842
15926
  }
15843
15927
 
15928
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
15929
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
15930
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
15931
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
15932
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
15933
+ AxiosError.ECONNREFUSED = 'ECONNREFUSED';
15934
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
15935
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
15936
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
15937
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
15938
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
15939
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
15940
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
15941
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
15942
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
15943
+
15844
15944
  /**
15845
- * It encodes a string by replacing all characters that are not in the unreserved set with
15846
- * their percent-encoded equivalents
15945
+ * Determines if the given thing is a array or js object.
15847
15946
  *
15848
- * @param {string} str - The string to encode.
15947
+ * @param {string} thing - The object or array to be visited.
15849
15948
  *
15850
- * @returns {string} The encoded string.
15949
+ * @returns {boolean}
15851
15950
  */
15852
- function encode$1(str) {
15853
- const charMap = {
15854
- '!': '%21',
15855
- "'": '%27',
15856
- '(': '%28',
15857
- ')': '%29',
15858
- '~': '%7E',
15859
- '%20': '+',
15860
- '%00': '\x00'
15861
- };
15862
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
15863
- return charMap[match];
15864
- });
15951
+ function isVisitable(thing) {
15952
+ return utils$1$1.isPlainObject(thing) || utils$1$1.isArray(thing);
15865
15953
  }
15866
15954
 
15867
15955
  /**
15868
- * It takes a params object and converts it to a FormData object
15956
+ * It removes the brackets from the end of a string
15869
15957
  *
15870
- * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
15871
- * @param {Object<string, any>} options - The options object passed to the Axios constructor.
15958
+ * @param {string} key - The key of the parameter.
15872
15959
  *
15873
- * @returns {void}
15960
+ * @returns {string} the key without the brackets.
15874
15961
  */
15875
- function AxiosURLSearchParams(params, options) {
15876
- this._pairs = [];
15877
- params && toFormData(params, this, options);
15962
+ function removeBrackets(key) {
15963
+ return utils$1$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
15878
15964
  }
15879
- const prototype = AxiosURLSearchParams.prototype;
15880
- prototype.append = function append(name, value) {
15881
- this._pairs.push([name, value]);
15882
- };
15883
- prototype.toString = function toString(encoder) {
15884
- const _encode = encoder ? function (value) {
15885
- return encoder.call(this, value, encode$1);
15886
- } : encode$1;
15887
- return this._pairs.map(function each(pair) {
15888
- return _encode(pair[0]) + '=' + _encode(pair[1]);
15889
- }, '').join('&');
15890
- };
15891
15965
 
15892
15966
  /**
15893
- * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
15894
- * URI encoded counterparts
15967
+ * It takes a path, a key, and a boolean, and returns a string
15895
15968
  *
15896
- * @param {string} val The value to be encoded.
15969
+ * @param {string} path - The path to the current key.
15970
+ * @param {string} key - The key of the current object being iterated over.
15971
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
15897
15972
  *
15898
- * @returns {string} The encoded value.
15973
+ * @returns {string} The path to the current key.
15899
15974
  */
15900
- function encode$2(val) {
15901
- return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
15975
+ function renderKey(path, key, dots) {
15976
+ if (!path) return key;
15977
+ return path.concat(key).map(function each(token, i) {
15978
+ // eslint-disable-next-line no-param-reassign
15979
+ token = removeBrackets(token);
15980
+ return !dots && i ? '[' + token + ']' : token;
15981
+ }).join(dots ? '.' : '');
15902
15982
  }
15903
15983
 
15904
15984
  /**
15905
- * Build a URL by appending params to the end
15985
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
15906
15986
  *
15907
- * @param {string} url The base of the url (e.g., http://www.google.com)
15908
- * @param {object} [params] The params to be appended
15909
- * @param {?(object|Function)} options
15987
+ * @param {Array<any>} arr - The array to check
15910
15988
  *
15911
- * @returns {string} The formatted url
15989
+ * @returns {boolean}
15912
15990
  */
15913
- function buildURL(url, params, options) {
15914
- if (!params) {
15915
- return url;
15916
- }
15917
- const _encode = options && options.encode || encode$2;
15918
- const _options = utils$1$1.isFunction(options) ? {
15919
- serialize: options
15920
- } : options;
15921
- const serializeFn = _options && _options.serialize;
15922
- let serializedParams;
15991
+ function isFlatArray(arr) {
15992
+ return utils$1$1.isArray(arr) && !arr.some(isVisitable);
15993
+ }
15994
+ const predicates = utils$1$1.toFlatObject(utils$1$1, {}, null, function filter(prop) {
15995
+ return /^is[A-Z]/.test(prop);
15996
+ });
15997
+
15998
+ /**
15999
+ * Convert a data object to FormData
16000
+ *
16001
+ * @param {Object} obj
16002
+ * @param {?Object} [formData]
16003
+ * @param {?Object} [options]
16004
+ * @param {Function} [options.visitor]
16005
+ * @param {Boolean} [options.metaTokens = true]
16006
+ * @param {Boolean} [options.dots = false]
16007
+ * @param {?Boolean} [options.indexes = false]
16008
+ *
16009
+ * @returns {Object}
16010
+ **/
16011
+
16012
+ /**
16013
+ * It converts an object into a FormData object
16014
+ *
16015
+ * @param {Object<any, any>} obj - The object to convert to form data.
16016
+ * @param {string} formData - The FormData object to append to.
16017
+ * @param {Object<string, any>} options
16018
+ *
16019
+ * @returns
16020
+ */
16021
+ function toFormData(obj, formData, options) {
16022
+ if (!utils$1$1.isObject(obj)) {
16023
+ throw new TypeError('target must be an object');
16024
+ }
16025
+
16026
+ // eslint-disable-next-line no-param-reassign
16027
+ formData = formData || new (FormData$1 || FormData)();
16028
+
16029
+ // eslint-disable-next-line no-param-reassign
16030
+ options = utils$1$1.toFlatObject(options, {
16031
+ metaTokens: true,
16032
+ dots: false,
16033
+ indexes: false
16034
+ }, false, function defined(option, source) {
16035
+ // eslint-disable-next-line no-eq-null,eqeqeq
16036
+ return !utils$1$1.isUndefined(source[option]);
16037
+ });
16038
+ const metaTokens = options.metaTokens;
16039
+ // eslint-disable-next-line no-use-before-define
16040
+ const visitor = options.visitor || defaultVisitor;
16041
+ const dots = options.dots;
16042
+ const indexes = options.indexes;
16043
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
16044
+ const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
16045
+ const useBlob = _Blob && utils$1$1.isSpecCompliantForm(formData);
16046
+ if (!utils$1$1.isFunction(visitor)) {
16047
+ throw new TypeError('visitor must be a function');
16048
+ }
16049
+ function convertValue(value) {
16050
+ if (value === null) return '';
16051
+ if (utils$1$1.isDate(value)) {
16052
+ return value.toISOString();
16053
+ }
16054
+ if (utils$1$1.isBoolean(value)) {
16055
+ return value.toString();
16056
+ }
16057
+ if (!useBlob && utils$1$1.isBlob(value)) {
16058
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
16059
+ }
16060
+ if (utils$1$1.isArrayBuffer(value) || utils$1$1.isTypedArray(value)) {
16061
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
16062
+ }
16063
+ return value;
16064
+ }
16065
+
16066
+ /**
16067
+ * Default visitor.
16068
+ *
16069
+ * @param {*} value
16070
+ * @param {String|Number} key
16071
+ * @param {Array<String|Number>} path
16072
+ * @this {FormData}
16073
+ *
16074
+ * @returns {boolean} return true to visit the each prop of the value recursively
16075
+ */
16076
+ function defaultVisitor(value, key, path) {
16077
+ let arr = value;
16078
+ if (utils$1$1.isReactNative(formData) && utils$1$1.isReactNativeBlob(value)) {
16079
+ formData.append(renderKey(path, key, dots), convertValue(value));
16080
+ return false;
16081
+ }
16082
+ if (value && !path && typeof value === 'object') {
16083
+ if (utils$1$1.endsWith(key, '{}')) {
16084
+ // eslint-disable-next-line no-param-reassign
16085
+ key = metaTokens ? key : key.slice(0, -2);
16086
+ // eslint-disable-next-line no-param-reassign
16087
+ value = JSON.stringify(value);
16088
+ } else if (utils$1$1.isArray(value) && isFlatArray(value) || (utils$1$1.isFileList(value) || utils$1$1.endsWith(key, '[]')) && (arr = utils$1$1.toArray(value))) {
16089
+ // eslint-disable-next-line no-param-reassign
16090
+ key = removeBrackets(key);
16091
+ arr.forEach(function each(el, index) {
16092
+ !(utils$1$1.isUndefined(el) || el === null) && formData.append(
16093
+ // eslint-disable-next-line no-nested-ternary
16094
+ indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
16095
+ });
16096
+ return false;
16097
+ }
16098
+ }
16099
+ if (isVisitable(value)) {
16100
+ return true;
16101
+ }
16102
+ formData.append(renderKey(path, key, dots), convertValue(value));
16103
+ return false;
16104
+ }
16105
+ const stack = [];
16106
+ const exposedHelpers = Object.assign(predicates, {
16107
+ defaultVisitor,
16108
+ convertValue,
16109
+ isVisitable
16110
+ });
16111
+ function build(value, path, depth = 0) {
16112
+ if (utils$1$1.isUndefined(value)) return;
16113
+ if (depth > maxDepth) {
16114
+ throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
16115
+ }
16116
+ if (stack.indexOf(value) !== -1) {
16117
+ throw Error('Circular reference detected in ' + path.join('.'));
16118
+ }
16119
+ stack.push(value);
16120
+ utils$1$1.forEach(value, function each(el, key) {
16121
+ const result = !(utils$1$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1$1.isString(key) ? key.trim() : key, path, exposedHelpers);
16122
+ if (result === true) {
16123
+ build(el, path ? path.concat(key) : [key], depth + 1);
16124
+ }
16125
+ });
16126
+ stack.pop();
16127
+ }
16128
+ if (!utils$1$1.isObject(obj)) {
16129
+ throw new TypeError('data must be an object');
16130
+ }
16131
+ build(obj);
16132
+ return formData;
16133
+ }
16134
+
16135
+ /**
16136
+ * It encodes a string by replacing all characters that are not in the unreserved set with
16137
+ * their percent-encoded equivalents
16138
+ *
16139
+ * @param {string} str - The string to encode.
16140
+ *
16141
+ * @returns {string} The encoded string.
16142
+ */
16143
+ function encode$1(str) {
16144
+ const charMap = {
16145
+ '!': '%21',
16146
+ "'": '%27',
16147
+ '(': '%28',
16148
+ ')': '%29',
16149
+ '~': '%7E',
16150
+ '%20': '+'
16151
+ };
16152
+ return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
16153
+ return charMap[match];
16154
+ });
16155
+ }
16156
+
16157
+ /**
16158
+ * It takes a params object and converts it to a FormData object
16159
+ *
16160
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
16161
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
16162
+ *
16163
+ * @returns {void}
16164
+ */
16165
+ function AxiosURLSearchParams(params, options) {
16166
+ this._pairs = [];
16167
+ params && toFormData(params, this, options);
16168
+ }
16169
+ const prototype = AxiosURLSearchParams.prototype;
16170
+ prototype.append = function append(name, value) {
16171
+ this._pairs.push([name, value]);
16172
+ };
16173
+ prototype.toString = function toString(encoder) {
16174
+ const _encode = encoder ? function (value) {
16175
+ return encoder.call(this, value, encode$1);
16176
+ } : encode$1;
16177
+ return this._pairs.map(function each(pair) {
16178
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
16179
+ }, '').join('&');
16180
+ };
16181
+
16182
+ /**
16183
+ * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
16184
+ * their plain counterparts (`:`, `$`, `,`, `+`).
16185
+ *
16186
+ * @param {string} val The value to be encoded.
16187
+ *
16188
+ * @returns {string} The encoded value.
16189
+ */
16190
+ function encode$2(val) {
16191
+ return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
16192
+ }
16193
+
16194
+ /**
16195
+ * Build a URL by appending params to the end
16196
+ *
16197
+ * @param {string} url The base of the url (e.g., http://www.google.com)
16198
+ * @param {object} [params] The params to be appended
16199
+ * @param {?(object|Function)} options
16200
+ *
16201
+ * @returns {string} The formatted url
16202
+ */
16203
+ function buildURL(url, params, options) {
16204
+ if (!params) {
16205
+ return url;
16206
+ }
16207
+ const _encode = options && options.encode || encode$2;
16208
+ const _options = utils$1$1.isFunction(options) ? {
16209
+ serialize: options
16210
+ } : options;
16211
+ const serializeFn = _options && _options.serialize;
16212
+ let serializedParams;
15923
16213
  if (serializeFn) {
15924
16214
  serializedParams = serializeFn(params, _options);
15925
16215
  } else {
@@ -16000,14 +16290,13 @@ class InterceptorManager {
16000
16290
  });
16001
16291
  }
16002
16292
  }
16003
- const InterceptorManager$1 = InterceptorManager;
16004
- const transitionalDefaults = {
16293
+ var transitionalDefaults = {
16005
16294
  silentJSONParsing: true,
16006
16295
  forcedJSONParsing: true,
16007
16296
  clarifyTimeoutError: false,
16008
16297
  legacyInterceptorReqResOrdering: true
16009
16298
  };
16010
- const URLSearchParams$1 = url__default["default"].URLSearchParams;
16299
+ var URLSearchParams$1 = url.URLSearchParams;
16011
16300
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
16012
16301
  const DIGIT = '0123456789';
16013
16302
  const ALPHABET = {
@@ -16021,17 +16310,17 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
16021
16310
  length
16022
16311
  } = alphabet;
16023
16312
  const randomValues = new Uint32Array(size);
16024
- crypto__default["default"].randomFillSync(randomValues);
16313
+ crypto.randomFillSync(randomValues);
16025
16314
  for (let i = 0; i < size; i++) {
16026
16315
  str += alphabet[randomValues[i] % length];
16027
16316
  }
16028
16317
  return str;
16029
16318
  };
16030
- const platform$1 = {
16319
+ var platform$1 = {
16031
16320
  isNode: true,
16032
16321
  classes: {
16033
16322
  URLSearchParams: URLSearchParams$1,
16034
- FormData: FormData__default["default"],
16323
+ FormData: FormData$1,
16035
16324
  Blob: typeof Blob !== 'undefined' && Blob || null
16036
16325
  },
16037
16326
  ALPHABET,
@@ -16075,15 +16364,15 @@ const hasStandardBrowserWebWorkerEnv = (() => {
16075
16364
  self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
16076
16365
  })();
16077
16366
  const origin = hasBrowserEnv && window.location.href || 'http://localhost';
16078
- const utils$3 = /*#__PURE__*/Object.freeze({
16367
+ var utils$3 = /*#__PURE__*/Object.freeze({
16079
16368
  __proto__: null,
16080
16369
  hasBrowserEnv: hasBrowserEnv,
16081
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
16082
16370
  hasStandardBrowserEnv: hasStandardBrowserEnv,
16371
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
16083
16372
  navigator: _navigator,
16084
16373
  origin: origin
16085
16374
  });
16086
- const platform = _objectSpread2(_objectSpread2({}, utils$3), platform$1);
16375
+ var platform = _objectSpread2(_objectSpread2({}, utils$3), platform$1);
16087
16376
  function toURLEncodedForm(data, options) {
16088
16377
  return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
16089
16378
  visitor: function (value, key, path, helpers) {
@@ -16145,426 +16434,153 @@ function formDataToJSON(formData) {
16145
16434
  let name = path[index++];
16146
16435
  if (name === '__proto__') return true;
16147
16436
  const isNumericKey = Number.isFinite(+name);
16148
- const isLast = index >= path.length;
16149
- name = !name && utils$1$1.isArray(target) ? target.length : name;
16150
- if (isLast) {
16151
- if (utils$1$1.hasOwnProp(target, name)) {
16152
- target[name] = [target[name], value];
16153
- } else {
16154
- target[name] = value;
16155
- }
16156
- return !isNumericKey;
16157
- }
16158
- if (!target[name] || !utils$1$1.isObject(target[name])) {
16159
- target[name] = [];
16160
- }
16161
- const result = buildPath(path, value, target[name], index);
16162
- if (result && utils$1$1.isArray(target[name])) {
16163
- target[name] = arrayToObject$1(target[name]);
16164
- }
16165
- return !isNumericKey;
16166
- }
16167
- if (utils$1$1.isFormData(formData) && utils$1$1.isFunction(formData.entries)) {
16168
- const obj = {};
16169
- utils$1$1.forEachEntry(formData, (name, value) => {
16170
- buildPath(parsePropPath(name), value, obj, 0);
16171
- });
16172
- return obj;
16173
- }
16174
- return null;
16175
- }
16176
-
16177
- /**
16178
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
16179
- * of the input
16180
- *
16181
- * @param {any} rawValue - The value to be stringified.
16182
- * @param {Function} parser - A function that parses a string into a JavaScript object.
16183
- * @param {Function} encoder - A function that takes a value and returns a string.
16184
- *
16185
- * @returns {string} A stringified version of the rawValue.
16186
- */
16187
- function stringifySafely(rawValue, parser, encoder) {
16188
- if (utils$1$1.isString(rawValue)) {
16189
- try {
16190
- (parser || JSON.parse)(rawValue);
16191
- return utils$1$1.trim(rawValue);
16192
- } catch (e) {
16193
- if (e.name !== 'SyntaxError') {
16194
- throw e;
16195
- }
16196
- }
16197
- }
16198
- return (encoder || JSON.stringify)(rawValue);
16199
- }
16200
- const defaults$2 = {
16201
- transitional: transitionalDefaults,
16202
- adapter: ['xhr', 'http', 'fetch'],
16203
- transformRequest: [function transformRequest(data, headers) {
16204
- const contentType = headers.getContentType() || '';
16205
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
16206
- const isObjectPayload = utils$1$1.isObject(data);
16207
- if (isObjectPayload && utils$1$1.isHTMLForm(data)) {
16208
- data = new FormData(data);
16209
- }
16210
- const isFormData = utils$1$1.isFormData(data);
16211
- if (isFormData) {
16212
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
16213
- }
16214
- if (utils$1$1.isArrayBuffer(data) || utils$1$1.isBuffer(data) || utils$1$1.isStream(data) || utils$1$1.isFile(data) || utils$1$1.isBlob(data) || utils$1$1.isReadableStream(data)) {
16215
- return data;
16216
- }
16217
- if (utils$1$1.isArrayBufferView(data)) {
16218
- return data.buffer;
16219
- }
16220
- if (utils$1$1.isURLSearchParams(data)) {
16221
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
16222
- return data.toString();
16223
- }
16224
- let isFileList;
16225
- if (isObjectPayload) {
16226
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
16227
- return toURLEncodedForm(data, this.formSerializer).toString();
16228
- }
16229
- if ((isFileList = utils$1$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
16230
- const _FormData = this.env && this.env.FormData;
16231
- return toFormData(isFileList ? {
16232
- 'files[]': data
16233
- } : data, _FormData && new _FormData(), this.formSerializer);
16234
- }
16235
- }
16236
- if (isObjectPayload || hasJSONContentType) {
16237
- headers.setContentType('application/json', false);
16238
- return stringifySafely(data);
16239
- }
16240
- return data;
16241
- }],
16242
- transformResponse: [function transformResponse(data) {
16243
- const transitional = this.transitional || defaults$2.transitional;
16244
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
16245
- const JSONRequested = this.responseType === 'json';
16246
- if (utils$1$1.isResponse(data) || utils$1$1.isReadableStream(data)) {
16247
- return data;
16248
- }
16249
- if (data && utils$1$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
16250
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
16251
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
16252
- try {
16253
- return JSON.parse(data, this.parseReviver);
16254
- } catch (e) {
16255
- if (strictJSONParsing) {
16256
- if (e.name === 'SyntaxError') {
16257
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
16258
- }
16259
- throw e;
16260
- }
16261
- }
16262
- }
16263
- return data;
16264
- }],
16265
- /**
16266
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
16267
- * timeout is not created.
16268
- */
16269
- timeout: 0,
16270
- xsrfCookieName: 'XSRF-TOKEN',
16271
- xsrfHeaderName: 'X-XSRF-TOKEN',
16272
- maxContentLength: -1,
16273
- maxBodyLength: -1,
16274
- env: {
16275
- FormData: platform.classes.FormData,
16276
- Blob: platform.classes.Blob
16277
- },
16278
- validateStatus: function validateStatus(status) {
16279
- return status >= 200 && status < 300;
16280
- },
16281
- headers: {
16282
- common: {
16283
- Accept: 'application/json, text/plain, */*',
16284
- 'Content-Type': undefined
16285
- }
16286
- }
16287
- };
16288
- utils$1$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], method => {
16289
- defaults$2.headers[method] = {};
16290
- });
16291
- const defaults$1$1 = defaults$2;
16292
-
16293
- // RawAxiosHeaders whose duplicates are ignored by node
16294
- // c.f. https://nodejs.org/api/http.html#http_message_headers
16295
- const ignoreDuplicateOf = utils$1$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']);
16296
-
16297
- /**
16298
- * Parse headers into an object
16299
- *
16300
- * ```
16301
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
16302
- * Content-Type: application/json
16303
- * Connection: keep-alive
16304
- * Transfer-Encoding: chunked
16305
- * ```
16306
- *
16307
- * @param {String} rawHeaders Headers needing to be parsed
16308
- *
16309
- * @returns {Object} Headers parsed into an object
16310
- */
16311
- const parseHeaders = rawHeaders => {
16312
- const parsed = {};
16313
- let key;
16314
- let val;
16315
- let i;
16316
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
16317
- i = line.indexOf(':');
16318
- key = line.substring(0, i).trim().toLowerCase();
16319
- val = line.substring(i + 1).trim();
16320
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
16321
- return;
16322
- }
16323
- if (key === 'set-cookie') {
16324
- if (parsed[key]) {
16325
- parsed[key].push(val);
16326
- } else {
16327
- parsed[key] = [val];
16328
- }
16329
- } else {
16330
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
16331
- }
16332
- });
16333
- return parsed;
16334
- };
16335
- const $internals = Symbol('internals');
16336
- function normalizeHeader(header) {
16337
- return header && String(header).trim().toLowerCase();
16338
- }
16339
- function normalizeValue(value) {
16340
- if (value === false || value == null) {
16341
- return value;
16342
- }
16343
- return utils$1$1.isArray(value) ? value.map(normalizeValue) : String(value);
16344
- }
16345
- function parseTokens(str) {
16346
- const tokens = Object.create(null);
16347
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
16348
- let match;
16349
- while (match = tokensRE.exec(str)) {
16350
- tokens[match[1]] = match[2];
16351
- }
16352
- return tokens;
16353
- }
16354
- const isValidHeaderName = str => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
16355
- function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
16356
- if (utils$1$1.isFunction(filter)) {
16357
- return filter.call(this, value, header);
16358
- }
16359
- if (isHeaderNameFilter) {
16360
- value = header;
16361
- }
16362
- if (!utils$1$1.isString(value)) return;
16363
- if (utils$1$1.isString(filter)) {
16364
- return value.indexOf(filter) !== -1;
16365
- }
16366
- if (utils$1$1.isRegExp(filter)) {
16367
- return filter.test(value);
16368
- }
16369
- }
16370
- function formatHeader(header) {
16371
- return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
16372
- return char.toUpperCase() + str;
16373
- });
16374
- }
16375
- function buildAccessors(obj, header) {
16376
- const accessorName = utils$1$1.toCamelCase(' ' + header);
16377
- ['get', 'set', 'has'].forEach(methodName => {
16378
- Object.defineProperty(obj, methodName + accessorName, {
16379
- value: function (arg1, arg2, arg3) {
16380
- return this[methodName].call(this, header, arg1, arg2, arg3);
16381
- },
16382
- configurable: true
16383
- });
16384
- });
16385
- }
16386
- class AxiosHeaders {
16387
- constructor(headers) {
16388
- headers && this.set(headers);
16389
- }
16390
- set(header, valueOrRewrite, rewrite) {
16391
- const self = this;
16392
- function setHeader(_value, _header, _rewrite) {
16393
- const lHeader = normalizeHeader(_header);
16394
- if (!lHeader) {
16395
- throw new Error('header name must be a non-empty string');
16396
- }
16397
- const key = utils$1$1.findKey(self, lHeader);
16398
- if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
16399
- self[key || _header] = normalizeValue(_value);
16400
- }
16401
- }
16402
- const setHeaders = (headers, _rewrite) => utils$1$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
16403
- if (utils$1$1.isPlainObject(header) || header instanceof this.constructor) {
16404
- setHeaders(header, valueOrRewrite);
16405
- } else if (utils$1$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
16406
- setHeaders(parseHeaders(header), valueOrRewrite);
16407
- } else if (utils$1$1.isObject(header) && utils$1$1.isIterable(header)) {
16408
- let obj = {},
16409
- dest,
16410
- key;
16411
- for (const entry of header) {
16412
- if (!utils$1$1.isArray(entry)) {
16413
- throw TypeError('Object iterator must return a key-value pair');
16414
- }
16415
- obj[key = entry[0]] = (dest = obj[key]) ? utils$1$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
16416
- }
16417
- setHeaders(obj, valueOrRewrite);
16418
- } else {
16419
- header != null && setHeader(valueOrRewrite, header, rewrite);
16420
- }
16421
- return this;
16422
- }
16423
- get(header, parser) {
16424
- header = normalizeHeader(header);
16425
- if (header) {
16426
- const key = utils$1$1.findKey(this, header);
16427
- if (key) {
16428
- const value = this[key];
16429
- if (!parser) {
16430
- return value;
16431
- }
16432
- if (parser === true) {
16433
- return parseTokens(value);
16434
- }
16435
- if (utils$1$1.isFunction(parser)) {
16436
- return parser.call(this, value, key);
16437
- }
16438
- if (utils$1$1.isRegExp(parser)) {
16439
- return parser.exec(value);
16440
- }
16441
- throw new TypeError('parser must be boolean|regexp|function');
16442
- }
16443
- }
16444
- }
16445
- has(header, matcher) {
16446
- header = normalizeHeader(header);
16447
- if (header) {
16448
- const key = utils$1$1.findKey(this, header);
16449
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
16450
- }
16451
- return false;
16452
- }
16453
- delete(header, matcher) {
16454
- const self = this;
16455
- let deleted = false;
16456
- function deleteHeader(_header) {
16457
- _header = normalizeHeader(_header);
16458
- if (_header) {
16459
- const key = utils$1$1.findKey(self, _header);
16460
- if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
16461
- delete self[key];
16462
- deleted = true;
16463
- }
16464
- }
16465
- }
16466
- if (utils$1$1.isArray(header)) {
16467
- header.forEach(deleteHeader);
16468
- } else {
16469
- deleteHeader(header);
16470
- }
16471
- return deleted;
16472
- }
16473
- clear(matcher) {
16474
- const keys = Object.keys(this);
16475
- let i = keys.length;
16476
- let deleted = false;
16477
- while (i--) {
16478
- const key = keys[i];
16479
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
16480
- delete this[key];
16481
- deleted = true;
16482
- }
16483
- }
16484
- return deleted;
16485
- }
16486
- normalize(format) {
16487
- const self = this;
16488
- const headers = {};
16489
- utils$1$1.forEach(this, (value, header) => {
16490
- const key = utils$1$1.findKey(headers, header);
16491
- if (key) {
16492
- self[key] = normalizeValue(value);
16493
- delete self[header];
16494
- return;
16495
- }
16496
- const normalized = format ? formatHeader(header) : String(header).trim();
16497
- if (normalized !== header) {
16498
- delete self[header];
16437
+ const isLast = index >= path.length;
16438
+ name = !name && utils$1$1.isArray(target) ? target.length : name;
16439
+ if (isLast) {
16440
+ if (utils$1$1.hasOwnProp(target, name)) {
16441
+ target[name] = utils$1$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
16442
+ } else {
16443
+ target[name] = value;
16499
16444
  }
16500
- self[normalized] = normalizeValue(value);
16501
- headers[normalized] = true;
16502
- });
16503
- return this;
16504
- }
16505
- concat(...targets) {
16506
- return this.constructor.concat(this, ...targets);
16445
+ return !isNumericKey;
16446
+ }
16447
+ if (!target[name] || !utils$1$1.isObject(target[name])) {
16448
+ target[name] = [];
16449
+ }
16450
+ const result = buildPath(path, value, target[name], index);
16451
+ if (result && utils$1$1.isArray(target[name])) {
16452
+ target[name] = arrayToObject$1(target[name]);
16453
+ }
16454
+ return !isNumericKey;
16507
16455
  }
16508
- toJSON(asStrings) {
16509
- const obj = Object.create(null);
16510
- utils$1$1.forEach(this, (value, header) => {
16511
- value != null && value !== false && (obj[header] = asStrings && utils$1$1.isArray(value) ? value.join(', ') : value);
16456
+ if (utils$1$1.isFormData(formData) && utils$1$1.isFunction(formData.entries)) {
16457
+ const obj = {};
16458
+ utils$1$1.forEachEntry(formData, (name, value) => {
16459
+ buildPath(parsePropPath(name), value, obj, 0);
16512
16460
  });
16513
16461
  return obj;
16514
16462
  }
16515
- [Symbol.iterator]() {
16516
- return Object.entries(this.toJSON())[Symbol.iterator]();
16517
- }
16518
- toString() {
16519
- return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
16520
- }
16521
- getSetCookie() {
16522
- return this.get('set-cookie') || [];
16523
- }
16524
- get [Symbol.toStringTag]() {
16525
- return 'AxiosHeaders';
16526
- }
16527
- static from(thing) {
16528
- return thing instanceof this ? thing : new this(thing);
16529
- }
16530
- static concat(first, ...targets) {
16531
- const computed = new this(first);
16532
- targets.forEach(target => computed.set(target));
16533
- return computed;
16534
- }
16535
- static accessor(header) {
16536
- const internals = this[$internals] = this[$internals] = {
16537
- accessors: {}
16538
- };
16539
- const accessors = internals.accessors;
16540
- const prototype = this.prototype;
16541
- function defineAccessor(_header) {
16542
- const lHeader = normalizeHeader(_header);
16543
- if (!accessors[lHeader]) {
16544
- buildAccessors(prototype, _header);
16545
- accessors[lHeader] = true;
16463
+ return null;
16464
+ }
16465
+ const own = (obj, key) => obj != null && utils$1$1.hasOwnProp(obj, key) ? obj[key] : undefined;
16466
+
16467
+ /**
16468
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
16469
+ * of the input
16470
+ *
16471
+ * @param {any} rawValue - The value to be stringified.
16472
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
16473
+ * @param {Function} encoder - A function that takes a value and returns a string.
16474
+ *
16475
+ * @returns {string} A stringified version of the rawValue.
16476
+ */
16477
+ function stringifySafely(rawValue, parser, encoder) {
16478
+ if (utils$1$1.isString(rawValue)) {
16479
+ try {
16480
+ (parser || JSON.parse)(rawValue);
16481
+ return utils$1$1.trim(rawValue);
16482
+ } catch (e) {
16483
+ if (e.name !== 'SyntaxError') {
16484
+ throw e;
16546
16485
  }
16547
16486
  }
16548
- utils$1$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
16549
- return this;
16550
16487
  }
16488
+ return (encoder || JSON.stringify)(rawValue);
16551
16489
  }
16552
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
16553
-
16554
- // reserved names hotfix
16555
- utils$1$1.reduceDescriptors(AxiosHeaders.prototype, ({
16556
- value
16557
- }, key) => {
16558
- let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
16559
- return {
16560
- get: () => value,
16561
- set(headerValue) {
16562
- this[mapped] = headerValue;
16490
+ const defaults$2 = {
16491
+ transitional: transitionalDefaults,
16492
+ adapter: ['xhr', 'http', 'fetch'],
16493
+ transformRequest: [function transformRequest(data, headers) {
16494
+ const contentType = headers.getContentType() || '';
16495
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
16496
+ const isObjectPayload = utils$1$1.isObject(data);
16497
+ if (isObjectPayload && utils$1$1.isHTMLForm(data)) {
16498
+ data = new FormData(data);
16563
16499
  }
16564
- };
16500
+ const isFormData = utils$1$1.isFormData(data);
16501
+ if (isFormData) {
16502
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
16503
+ }
16504
+ if (utils$1$1.isArrayBuffer(data) || utils$1$1.isBuffer(data) || utils$1$1.isStream(data) || utils$1$1.isFile(data) || utils$1$1.isBlob(data) || utils$1$1.isReadableStream(data)) {
16505
+ return data;
16506
+ }
16507
+ if (utils$1$1.isArrayBufferView(data)) {
16508
+ return data.buffer;
16509
+ }
16510
+ if (utils$1$1.isURLSearchParams(data)) {
16511
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
16512
+ return data.toString();
16513
+ }
16514
+ let isFileList;
16515
+ if (isObjectPayload) {
16516
+ const formSerializer = own(this, 'formSerializer');
16517
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
16518
+ return toURLEncodedForm(data, formSerializer).toString();
16519
+ }
16520
+ if ((isFileList = utils$1$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
16521
+ const env = own(this, 'env');
16522
+ const _FormData = env && env.FormData;
16523
+ return toFormData(isFileList ? {
16524
+ 'files[]': data
16525
+ } : data, _FormData && new _FormData(), formSerializer);
16526
+ }
16527
+ }
16528
+ if (isObjectPayload || hasJSONContentType) {
16529
+ headers.setContentType('application/json', false);
16530
+ return stringifySafely(data);
16531
+ }
16532
+ return data;
16533
+ }],
16534
+ transformResponse: [function transformResponse(data) {
16535
+ const transitional = own(this, 'transitional') || defaults$2.transitional;
16536
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
16537
+ const responseType = own(this, 'responseType');
16538
+ const JSONRequested = responseType === 'json';
16539
+ if (utils$1$1.isResponse(data) || utils$1$1.isReadableStream(data)) {
16540
+ return data;
16541
+ }
16542
+ if (data && utils$1$1.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
16543
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
16544
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
16545
+ try {
16546
+ return JSON.parse(data, own(this, 'parseReviver'));
16547
+ } catch (e) {
16548
+ if (strictJSONParsing) {
16549
+ if (e.name === 'SyntaxError') {
16550
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
16551
+ }
16552
+ throw e;
16553
+ }
16554
+ }
16555
+ }
16556
+ return data;
16557
+ }],
16558
+ /**
16559
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
16560
+ * timeout is not created.
16561
+ */
16562
+ timeout: 0,
16563
+ xsrfCookieName: 'XSRF-TOKEN',
16564
+ xsrfHeaderName: 'X-XSRF-TOKEN',
16565
+ maxContentLength: -1,
16566
+ maxBodyLength: -1,
16567
+ env: {
16568
+ FormData: platform.classes.FormData,
16569
+ Blob: platform.classes.Blob
16570
+ },
16571
+ validateStatus: function validateStatus(status) {
16572
+ return status >= 200 && status < 300;
16573
+ },
16574
+ headers: {
16575
+ common: {
16576
+ Accept: 'application/json, text/plain, */*',
16577
+ 'Content-Type': undefined
16578
+ }
16579
+ }
16580
+ };
16581
+ utils$1$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], method => {
16582
+ defaults$2.headers[method] = {};
16565
16583
  });
16566
- utils$1$1.freezeMethods(AxiosHeaders);
16567
- const AxiosHeaders$1 = AxiosHeaders;
16568
16584
 
16569
16585
  /**
16570
16586
  * Transform the data for a request or a response
@@ -16575,9 +16591,9 @@ const AxiosHeaders$1 = AxiosHeaders;
16575
16591
  * @returns {*} The resulting transformed data
16576
16592
  */
16577
16593
  function transformData(fns, response) {
16578
- const config = this || defaults$1$1;
16594
+ const config = this || defaults$2;
16579
16595
  const context = response || config;
16580
- const headers = AxiosHeaders$1.from(context.headers);
16596
+ const headers = AxiosHeaders.from(context.headers);
16581
16597
  let data = context.data;
16582
16598
  utils$1$1.forEach(fns, function transform(fn) {
16583
16599
  data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
@@ -16588,7 +16604,7 @@ function transformData(fns, response) {
16588
16604
  function isCancel(value) {
16589
16605
  return !!(value && value.__CANCEL__);
16590
16606
  }
16591
- class CanceledError extends AxiosError$1 {
16607
+ class CanceledError extends AxiosError {
16592
16608
  /**
16593
16609
  * A `CanceledError` is an object that is thrown when an operation is canceled.
16594
16610
  *
@@ -16599,12 +16615,11 @@ class CanceledError extends AxiosError$1 {
16599
16615
  * @returns {CanceledError} The created error.
16600
16616
  */
16601
16617
  constructor(message, config, request) {
16602
- super(message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
16618
+ super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
16603
16619
  this.name = 'CanceledError';
16604
16620
  this.__CANCEL__ = true;
16605
16621
  }
16606
16622
  }
16607
- const CanceledError$1 = CanceledError;
16608
16623
 
16609
16624
  /**
16610
16625
  * Resolve or reject a Promise based on response status.
@@ -16620,59 +16635,154 @@ function settle(resolve, reject, response) {
16620
16635
  if (!response.status || !validateStatus || validateStatus(response.status)) {
16621
16636
  resolve(response);
16622
16637
  } else {
16623
- reject(new AxiosError$1('Request failed with status code ' + response.status, [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
16638
+ 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));
16639
+ }
16640
+ }
16641
+
16642
+ /**
16643
+ * Determines whether the specified URL is absolute
16644
+ *
16645
+ * @param {string} url The URL to test
16646
+ *
16647
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
16648
+ */
16649
+ function isAbsoluteURL(url) {
16650
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
16651
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
16652
+ // by any combination of letters, digits, plus, period, or hyphen.
16653
+ if (typeof url !== 'string') {
16654
+ return false;
16655
+ }
16656
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
16657
+ }
16658
+
16659
+ /**
16660
+ * Creates a new URL by combining the specified URLs
16661
+ *
16662
+ * @param {string} baseURL The base URL
16663
+ * @param {string} relativeURL The relative URL
16664
+ *
16665
+ * @returns {string} The combined URL
16666
+ */
16667
+ function combineURLs(baseURL, relativeURL) {
16668
+ return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
16669
+ }
16670
+
16671
+ /**
16672
+ * Creates a new URL by combining the baseURL with the requestedURL,
16673
+ * only when the requestedURL is not already an absolute URL.
16674
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
16675
+ *
16676
+ * @param {string} baseURL The base URL
16677
+ * @param {string} requestedURL Absolute or relative URL to combine
16678
+ *
16679
+ * @returns {string} The combined full path
16680
+ */
16681
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
16682
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
16683
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
16684
+ return combineURLs(baseURL, requestedURL);
16685
+ }
16686
+ return requestedURL;
16687
+ }
16688
+ var DEFAULT_PORTS$1 = {
16689
+ ftp: 21,
16690
+ gopher: 70,
16691
+ http: 80,
16692
+ https: 443,
16693
+ ws: 80,
16694
+ wss: 443
16695
+ };
16696
+ function parseUrl(urlString) {
16697
+ try {
16698
+ return new URL(urlString);
16699
+ } catch (_unused) {
16700
+ return null;
16701
+ }
16702
+ }
16703
+
16704
+ /**
16705
+ * @param {string|object|URL} url - The URL as a string or URL instance, or a
16706
+ * compatible object (such as the result from legacy url.parse).
16707
+ * @return {string} The URL of the proxy that should handle the request to the
16708
+ * given URL. If no proxy is set, this will be an empty string.
16709
+ */
16710
+ function getProxyForUrl(url) {
16711
+ var parsedUrl = (typeof url === 'string' ? parseUrl(url) : url) || {};
16712
+ var proto = parsedUrl.protocol;
16713
+ var hostname = parsedUrl.host;
16714
+ var port = parsedUrl.port;
16715
+ if (typeof hostname !== 'string' || !hostname || typeof proto !== 'string') {
16716
+ return ''; // Don't proxy URLs without a valid scheme or host.
16717
+ }
16718
+ proto = proto.split(':', 1)[0];
16719
+ // Stripping ports in this way instead of using parsedUrl.hostname to make
16720
+ // sure that the brackets around IPv6 addresses are kept.
16721
+ hostname = hostname.replace(/:\d*$/, '');
16722
+ port = parseInt(port) || DEFAULT_PORTS$1[proto] || 0;
16723
+ if (!shouldProxy(hostname, port)) {
16724
+ return ''; // Don't proxy URLs that match NO_PROXY.
16624
16725
  }
16625
- }
16626
-
16627
- /**
16628
- * Determines whether the specified URL is absolute
16629
- *
16630
- * @param {string} url The URL to test
16631
- *
16632
- * @returns {boolean} True if the specified URL is absolute, otherwise false
16633
- */
16634
- function isAbsoluteURL(url) {
16635
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
16636
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
16637
- // by any combination of letters, digits, plus, period, or hyphen.
16638
- if (typeof url !== 'string') {
16639
- return false;
16726
+ var proxy = getEnv(proto + '_proxy') || getEnv('all_proxy');
16727
+ if (proxy && proxy.indexOf('://') === -1) {
16728
+ // Missing scheme in proxy, default to the requested URL's scheme.
16729
+ proxy = proto + '://' + proxy;
16640
16730
  }
16641
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
16731
+ return proxy;
16642
16732
  }
16643
16733
 
16644
16734
  /**
16645
- * Creates a new URL by combining the specified URLs
16646
- *
16647
- * @param {string} baseURL The base URL
16648
- * @param {string} relativeURL The relative URL
16735
+ * Determines whether a given URL should be proxied.
16649
16736
  *
16650
- * @returns {string} The combined URL
16737
+ * @param {string} hostname - The host name of the URL.
16738
+ * @param {number} port - The effective port of the URL.
16739
+ * @returns {boolean} Whether the given URL should be proxied.
16740
+ * @private
16651
16741
  */
16652
- function combineURLs(baseURL, relativeURL) {
16653
- return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
16742
+ function shouldProxy(hostname, port) {
16743
+ var NO_PROXY = getEnv('no_proxy').toLowerCase();
16744
+ if (!NO_PROXY) {
16745
+ return true; // Always proxy if NO_PROXY is not set.
16746
+ }
16747
+ if (NO_PROXY === '*') {
16748
+ return false; // Never proxy if wildcard is set.
16749
+ }
16750
+ return NO_PROXY.split(/[,\s]/).every(function (proxy) {
16751
+ if (!proxy) {
16752
+ return true; // Skip zero-length hosts.
16753
+ }
16754
+ var parsedProxy = proxy.match(/^(.+):(\d+)$/);
16755
+ var parsedProxyHostname = parsedProxy ? parsedProxy[1] : proxy;
16756
+ var parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
16757
+ if (parsedProxyPort && parsedProxyPort !== port) {
16758
+ return true; // Skip if ports don't match.
16759
+ }
16760
+ if (!/^[.*]/.test(parsedProxyHostname)) {
16761
+ // No wildcards, so stop proxying if there is an exact match.
16762
+ return hostname !== parsedProxyHostname;
16763
+ }
16764
+ if (parsedProxyHostname.charAt(0) === '*') {
16765
+ // Remove leading wildcard.
16766
+ parsedProxyHostname = parsedProxyHostname.slice(1);
16767
+ }
16768
+ // Stop proxying if the hostname ends with the no_proxy host.
16769
+ return !hostname.endsWith(parsedProxyHostname);
16770
+ });
16654
16771
  }
16655
16772
 
16656
16773
  /**
16657
- * Creates a new URL by combining the baseURL with the requestedURL,
16658
- * only when the requestedURL is not already an absolute URL.
16659
- * If the requestURL is absolute, this function returns the requestedURL untouched.
16660
- *
16661
- * @param {string} baseURL The base URL
16662
- * @param {string} requestedURL Absolute or relative URL to combine
16774
+ * Get the value for an environment variable.
16663
16775
  *
16664
- * @returns {string} The combined full path
16776
+ * @param {string} key - The name of the environment variable.
16777
+ * @return {string} The value of the environment variable.
16778
+ * @private
16665
16779
  */
16666
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
16667
- let isRelativeUrl = !isAbsoluteURL(requestedURL);
16668
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
16669
- return combineURLs(baseURL, requestedURL);
16670
- }
16671
- return requestedURL;
16780
+ function getEnv(key) {
16781
+ return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
16672
16782
  }
16673
- const VERSION = "1.13.6";
16783
+ const VERSION = "1.16.0";
16674
16784
  function parseProtocol(url) {
16675
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
16785
+ const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
16676
16786
  return match && match[1] || '';
16677
16787
  }
16678
16788
  const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
@@ -16697,7 +16807,7 @@ function fromDataURI(uri, asBlob, options) {
16697
16807
  uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
16698
16808
  const match = DATA_URL_PATTERN.exec(uri);
16699
16809
  if (!match) {
16700
- throw new AxiosError$1('Invalid URL', AxiosError$1.ERR_INVALID_URL);
16810
+ throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
16701
16811
  }
16702
16812
  const mime = match[1];
16703
16813
  const isBase64 = match[2];
@@ -16705,7 +16815,7 @@ function fromDataURI(uri, asBlob, options) {
16705
16815
  const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
16706
16816
  if (asBlob) {
16707
16817
  if (!_Blob) {
16708
- throw new AxiosError$1('Blob is not supported', AxiosError$1.ERR_NOT_SUPPORT);
16818
+ throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
16709
16819
  }
16710
16820
  return new _Blob([buffer], {
16711
16821
  type: mime
@@ -16713,10 +16823,10 @@ function fromDataURI(uri, asBlob, options) {
16713
16823
  }
16714
16824
  return buffer;
16715
16825
  }
16716
- throw new AxiosError$1('Unsupported protocol ' + protocol, AxiosError$1.ERR_NOT_SUPPORT);
16826
+ throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
16717
16827
  }
16718
16828
  const kInternals = Symbol('internals');
16719
- class AxiosTransformStream extends stream__default["default"].Transform {
16829
+ class AxiosTransformStream extends stream.Transform {
16720
16830
  constructor(options) {
16721
16831
  options = utils$1$1.toFlatObject(options, {
16722
16832
  maxRate: 0,
@@ -16827,7 +16937,6 @@ class AxiosTransformStream extends stream__default["default"].Transform {
16827
16937
  });
16828
16938
  }
16829
16939
  }
16830
- const AxiosTransformStream$1 = AxiosTransformStream;
16831
16940
  const {
16832
16941
  asyncIterator
16833
16942
  } = Symbol;
@@ -16847,9 +16956,8 @@ const readBlob = /*#__PURE__*/function () {
16847
16956
  return _ref.apply(this, arguments);
16848
16957
  };
16849
16958
  }();
16850
- const readBlob$1 = readBlob;
16851
16959
  const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
16852
- const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util__default["default"].TextEncoder();
16960
+ const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util.TextEncoder();
16853
16961
  const CRLF = '\r\n';
16854
16962
  const CRLF_BYTES = textEncoder.encode(CRLF);
16855
16963
  const CRLF_BYTES_COUNT = 2;
@@ -16863,7 +16971,8 @@ class FormDataPart {
16863
16971
  if (isStringValue) {
16864
16972
  value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
16865
16973
  } else {
16866
- headers += `Content-Type: ${value.type || 'application/octet-stream'}${CRLF}`;
16974
+ const safeType = String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
16975
+ headers += `Content-Type: ${safeType}${CRLF}`;
16867
16976
  }
16868
16977
  this.headers = textEncoder.encode(headers + CRLF);
16869
16978
  this.contentLength = isStringValue ? value.byteLength : value.size;
@@ -16881,7 +16990,7 @@ class FormDataPart {
16881
16990
  if (utils$1$1.isTypedArray(value)) {
16882
16991
  yield value;
16883
16992
  } else {
16884
- yield* _asyncGeneratorDelegate(_asyncIterator(readBlob$1(value)));
16993
+ yield* _asyncGeneratorDelegate(_asyncIterator(readBlob(value)));
16885
16994
  }
16886
16995
  yield CRLF_BYTES;
16887
16996
  })();
@@ -16904,7 +17013,7 @@ const formDataToStream = (form, headersHandler, options) => {
16904
17013
  throw TypeError('FormData instance required');
16905
17014
  }
16906
17015
  if (boundary.length < 1 || boundary.length > 70) {
16907
- throw Error('boundary must be 10-70 characters long');
17016
+ throw Error('boundary must be 1-70 characters long');
16908
17017
  }
16909
17018
  const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
16910
17019
  const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
@@ -16931,8 +17040,7 @@ const formDataToStream = (form, headersHandler, options) => {
16931
17040
  yield footerBytes;
16932
17041
  })());
16933
17042
  };
16934
- const formDataToStream$1 = formDataToStream;
16935
- class ZlibHeaderTransformStream extends stream__default["default"].Transform {
17043
+ class ZlibHeaderTransformStream extends stream.Transform {
16936
17044
  __transform(chunk, encoding, callback) {
16937
17045
  this.push(chunk);
16938
17046
  callback();
@@ -16953,7 +17061,6 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform {
16953
17061
  this.__transform(chunk, encoding, callback);
16954
17062
  }
16955
17063
  }
16956
- const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
16957
17064
  const callbackify = (fn, reducer) => {
16958
17065
  return utils$1$1.isAsyncFn(fn) ? function (...args) {
16959
17066
  const cb = args.pop();
@@ -16966,7 +17073,143 @@ const callbackify = (fn, reducer) => {
16966
17073
  }, cb);
16967
17074
  } : fn;
16968
17075
  };
16969
- const callbackify$1 = callbackify;
17076
+ const LOOPBACK_HOSTNAMES = new Set(['localhost']);
17077
+ const isIPv4Loopback = host => {
17078
+ const parts = host.split('.');
17079
+ if (parts.length !== 4) return false;
17080
+ if (parts[0] !== '127') return false;
17081
+ return parts.every(p => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
17082
+ };
17083
+ const isIPv6Loopback = host => {
17084
+ // Collapse all-zero groups: any form of ::1 / 0:0:...:0:1
17085
+ // First, strip any leading "::" by normalising with Set lookup of common forms,
17086
+ // then fall back to structural check.
17087
+ if (host === '::1') return true;
17088
+
17089
+ // Check IPv4-mapped IPv6 loopback: ::ffff:<v4-loopback> or ::ffff:<hex-v4-loopback>
17090
+ // Node's URL parser normalises ::ffff:127.0.0.1 → ::ffff:7f00:1
17091
+ const v4MappedDotted = host.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
17092
+ if (v4MappedDotted) return isIPv4Loopback(v4MappedDotted[1]);
17093
+ const v4MappedHex = host.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);
17094
+ if (v4MappedHex) {
17095
+ const high = parseInt(v4MappedHex[1], 16);
17096
+ // High 16 bits must start with 127 (0x7f) — i.e. 0x7f00..0x7fff
17097
+ return high >= 0x7f00 && high <= 0x7fff;
17098
+ }
17099
+
17100
+ // Full-form ::1 variants: any number of zero groups followed by trailing 1
17101
+ // e.g. 0:0:0:0:0:0:0:1, 0000:...:0001
17102
+ const groups = host.split(':');
17103
+ if (groups.length === 8) {
17104
+ for (let i = 0; i < 7; i++) {
17105
+ if (!/^0+$/.test(groups[i])) return false;
17106
+ }
17107
+ return /^0*1$/.test(groups[7]);
17108
+ }
17109
+ return false;
17110
+ };
17111
+ const isLoopback = host => {
17112
+ if (!host) return false;
17113
+ if (LOOPBACK_HOSTNAMES.has(host)) return true;
17114
+ if (isIPv4Loopback(host)) return true;
17115
+ return isIPv6Loopback(host);
17116
+ };
17117
+ const DEFAULT_PORTS = {
17118
+ http: 80,
17119
+ https: 443,
17120
+ ws: 80,
17121
+ wss: 443,
17122
+ ftp: 21
17123
+ };
17124
+ const parseNoProxyEntry = entry => {
17125
+ let entryHost = entry;
17126
+ let entryPort = 0;
17127
+ if (entryHost.charAt(0) === '[') {
17128
+ const bracketIndex = entryHost.indexOf(']');
17129
+ if (bracketIndex !== -1) {
17130
+ const host = entryHost.slice(1, bracketIndex);
17131
+ const rest = entryHost.slice(bracketIndex + 1);
17132
+ if (rest.charAt(0) === ':' && /^\d+$/.test(rest.slice(1))) {
17133
+ entryPort = Number.parseInt(rest.slice(1), 10);
17134
+ }
17135
+ return [host, entryPort];
17136
+ }
17137
+ }
17138
+ const firstColon = entryHost.indexOf(':');
17139
+ const lastColon = entryHost.lastIndexOf(':');
17140
+ if (firstColon !== -1 && firstColon === lastColon && /^\d+$/.test(entryHost.slice(lastColon + 1))) {
17141
+ entryPort = Number.parseInt(entryHost.slice(lastColon + 1), 10);
17142
+ entryHost = entryHost.slice(0, lastColon);
17143
+ }
17144
+ return [entryHost, entryPort];
17145
+ };
17146
+
17147
+ // Convert IPv4-mapped IPv6 (::ffff:0:0/96 prefix) to IPv4 dotted form so both
17148
+ // sides of a NO_PROXY comparison see the same canonical address. Without this,
17149
+ // `NO_PROXY=192.168.1.5` would not match a request to `http://[::ffff:192.168.1.5]/`
17150
+ // (Node's URL parser normalises that to `[::ffff:c0a8:105]`), and vice-versa,
17151
+ // allowing the proxy-bypass policy to be circumvented by using the alternate
17152
+ // representation. Returns the input unchanged when not IPv4-mapped.
17153
+ const IPV4_MAPPED_DOTTED_RE = /^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:(\d+\.\d+\.\d+\.\d+)$/i;
17154
+ const IPV4_MAPPED_HEX_RE = /^(?:::|(?:0{1,4}:){1,4}:|(?:0{1,4}:){5})ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i;
17155
+ const unmapIPv4MappedIPv6 = host => {
17156
+ if (typeof host !== 'string' || host.indexOf(':') === -1) return host;
17157
+ const dotted = host.match(IPV4_MAPPED_DOTTED_RE);
17158
+ if (dotted) return dotted[1];
17159
+ const hex = host.match(IPV4_MAPPED_HEX_RE);
17160
+ if (hex) {
17161
+ const high = parseInt(hex[1], 16);
17162
+ const low = parseInt(hex[2], 16);
17163
+ return `${high >> 8}.${high & 0xff}.${low >> 8}.${low & 0xff}`;
17164
+ }
17165
+ return host;
17166
+ };
17167
+ const normalizeNoProxyHost = hostname => {
17168
+ if (!hostname) {
17169
+ return hostname;
17170
+ }
17171
+ if (hostname.charAt(0) === '[' && hostname.charAt(hostname.length - 1) === ']') {
17172
+ hostname = hostname.slice(1, -1);
17173
+ }
17174
+ return unmapIPv4MappedIPv6(hostname.replace(/\.+$/, ''));
17175
+ };
17176
+ function shouldBypassProxy(location) {
17177
+ let parsed;
17178
+ try {
17179
+ parsed = new URL(location);
17180
+ } catch (_err) {
17181
+ return false;
17182
+ }
17183
+ const noProxy = (process.env.no_proxy || process.env.NO_PROXY || '').toLowerCase();
17184
+ if (!noProxy) {
17185
+ return false;
17186
+ }
17187
+ if (noProxy === '*') {
17188
+ return true;
17189
+ }
17190
+ const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS[parsed.protocol.split(':', 1)[0]] || 0;
17191
+ const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
17192
+ return noProxy.split(/[\s,]+/).some(entry => {
17193
+ if (!entry) {
17194
+ return false;
17195
+ }
17196
+ let [entryHost, entryPort] = parseNoProxyEntry(entry);
17197
+ entryHost = normalizeNoProxyHost(entryHost);
17198
+ if (!entryHost) {
17199
+ return false;
17200
+ }
17201
+ if (entryPort && entryPort !== port) {
17202
+ return false;
17203
+ }
17204
+ if (entryHost.charAt(0) === '*') {
17205
+ entryHost = entryHost.slice(1);
17206
+ }
17207
+ if (entryHost.charAt(0) === '.') {
17208
+ return hostname.endsWith(entryHost);
17209
+ }
17210
+ return hostname === entryHost || isLoopback(hostname) && isLoopback(entryHost);
17211
+ });
17212
+ }
16970
17213
 
16971
17214
  /**
16972
17215
  * Calculate data maxRate
@@ -17050,19 +17293,19 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
17050
17293
  let bytesNotified = 0;
17051
17294
  const _speedometer = speedometer(50, 250);
17052
17295
  return throttle(e => {
17053
- const loaded = e.loaded;
17296
+ const rawLoaded = e.loaded;
17054
17297
  const total = e.lengthComputable ? e.total : undefined;
17055
- const progressBytes = loaded - bytesNotified;
17298
+ const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
17299
+ const progressBytes = Math.max(0, loaded - bytesNotified);
17056
17300
  const rate = _speedometer(progressBytes);
17057
- const inRange = loaded <= total;
17058
- bytesNotified = loaded;
17301
+ bytesNotified = Math.max(bytesNotified, loaded);
17059
17302
  const data = {
17060
17303
  loaded,
17061
17304
  total,
17062
17305
  progress: total ? loaded / total : undefined,
17063
17306
  bytes: progressBytes,
17064
17307
  rate: rate ? rate : undefined,
17065
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
17308
+ estimated: rate && total ? (total - loaded) / rate : undefined,
17066
17309
  event: e,
17067
17310
  lengthComputable: total != null,
17068
17311
  [isDownloadStream ? 'download' : 'upload']: true
@@ -17140,25 +17383,84 @@ function estimateDataURLDecodedBytes(url) {
17140
17383
  const bytes = groups * 3 - (pad || 0);
17141
17384
  return bytes > 0 ? bytes : 0;
17142
17385
  }
17143
- return Buffer.byteLength(body, 'utf8');
17386
+ if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
17387
+ return Buffer.byteLength(body, 'utf8');
17388
+ }
17389
+
17390
+ // Compute UTF-8 byte length directly from UTF-16 code units without allocating
17391
+ // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
17392
+ // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
17393
+ // but 3 UTF-8 bytes).
17394
+ let bytes = 0;
17395
+ for (let i = 0, len = body.length; i < len; i++) {
17396
+ const c = body.charCodeAt(i);
17397
+ if (c < 0x80) {
17398
+ bytes += 1;
17399
+ } else if (c < 0x800) {
17400
+ bytes += 2;
17401
+ } else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
17402
+ const next = body.charCodeAt(i + 1);
17403
+ if (next >= 0xdc00 && next <= 0xdfff) {
17404
+ bytes += 4;
17405
+ i++;
17406
+ } else {
17407
+ bytes += 3;
17408
+ }
17409
+ } else {
17410
+ bytes += 3;
17411
+ }
17412
+ }
17413
+ return bytes;
17144
17414
  }
17145
17415
  const zlibOptions = {
17146
- flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
17147
- finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
17416
+ flush: zlib.constants.Z_SYNC_FLUSH,
17417
+ finishFlush: zlib.constants.Z_SYNC_FLUSH
17148
17418
  };
17149
17419
  const brotliOptions = {
17150
- flush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH,
17151
- finishFlush: zlib__default["default"].constants.BROTLI_OPERATION_FLUSH
17420
+ flush: zlib.constants.BROTLI_OPERATION_FLUSH,
17421
+ finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
17152
17422
  };
17153
- const isBrotliSupported = utils$1$1.isFunction(zlib__default["default"].createBrotliDecompress);
17423
+ const isBrotliSupported = utils$1$1.isFunction(zlib.createBrotliDecompress);
17154
17424
  const {
17155
17425
  http: httpFollow,
17156
17426
  https: httpsFollow
17157
- } = followRedirects__default["default"];
17427
+ } = followRedirects;
17158
17428
  const isHttps = /https:?/;
17429
+ const FORM_DATA_CONTENT_HEADERS$1 = ['content-type', 'content-length'];
17430
+ function setFormDataHeaders$1(headers, formHeaders, policy) {
17431
+ if (policy !== 'content-only') {
17432
+ headers.set(formHeaders);
17433
+ return;
17434
+ }
17435
+ Object.entries(formHeaders).forEach(([key, val]) => {
17436
+ if (FORM_DATA_CONTENT_HEADERS$1.includes(key.toLowerCase())) {
17437
+ headers.set(key, val);
17438
+ }
17439
+ });
17440
+ }
17441
+
17442
+ // Symbols used to bind a single 'error' listener to a pooled socket and track
17443
+ // the request currently owning that socket across keep-alive reuse (issue #10780).
17444
+ const kAxiosSocketListener = Symbol('axios.http.socketListener');
17445
+ const kAxiosCurrentReq = Symbol('axios.http.currentReq');
17159
17446
  const supportedProtocols = platform.protocols.map(protocol => {
17160
17447
  return protocol + ':';
17161
17448
  });
17449
+
17450
+ // Node's WHATWG URL parser returns `username` and `password` percent-encoded.
17451
+ // Decode before composing the `auth` option so credentials such as
17452
+ // `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
17453
+ // original value for malformed input so a bad encoding never throws.
17454
+ const decodeURIComponentSafe = value => {
17455
+ if (!utils$1$1.isString(value)) {
17456
+ return value;
17457
+ }
17458
+ try {
17459
+ return decodeURIComponent(value);
17460
+ } catch (error) {
17461
+ return value;
17462
+ }
17463
+ };
17162
17464
  const flushOnFinish = (stream, [throttled, flush]) => {
17163
17465
  stream.on('end', flush).on('error', flush);
17164
17466
  return throttled;
@@ -17176,12 +17478,12 @@ class Http2Sessions {
17176
17478
  let len = authoritySessions.length;
17177
17479
  for (let i = 0; i < len; i++) {
17178
17480
  const [sessionHandle, sessionOptions] = authoritySessions[i];
17179
- if (!sessionHandle.destroyed && !sessionHandle.closed && util__default["default"].isDeepStrictEqual(sessionOptions, options)) {
17481
+ if (!sessionHandle.destroyed && !sessionHandle.closed && util.isDeepStrictEqual(sessionOptions, options)) {
17180
17482
  return sessionHandle;
17181
17483
  }
17182
17484
  }
17183
17485
  }
17184
- const session = http2__default["default"].connect(authority, options);
17486
+ const session = http2.connect(authority, options);
17185
17487
  let removed;
17186
17488
  const removeSession = () => {
17187
17489
  if (removed) {
@@ -17198,6 +17500,9 @@ class Http2Sessions {
17198
17500
  } else {
17199
17501
  entries.splice(i, 1);
17200
17502
  }
17503
+ if (!session.closed) {
17504
+ session.close();
17505
+ }
17201
17506
  return;
17202
17507
  }
17203
17508
  }
@@ -17243,12 +17548,12 @@ const http2Sessions = new Http2Sessions();
17243
17548
  *
17244
17549
  * @returns {Object<string, any>}
17245
17550
  */
17246
- function dispatchBeforeRedirect(options, responseDetails) {
17551
+ function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
17247
17552
  if (options.beforeRedirects.proxy) {
17248
17553
  options.beforeRedirects.proxy(options);
17249
17554
  }
17250
17555
  if (options.beforeRedirects.config) {
17251
- options.beforeRedirects.config(options, responseDetails);
17556
+ options.beforeRedirects.config(options, responseDetails, requestDetails);
17252
17557
  }
17253
17558
  }
17254
17559
 
@@ -17261,47 +17566,90 @@ function dispatchBeforeRedirect(options, responseDetails) {
17261
17566
  *
17262
17567
  * @returns {http.ClientRequestArgs}
17263
17568
  */
17264
- function setProxy(options, configProxy, location) {
17569
+ function setProxy(options, configProxy, location, isRedirect) {
17265
17570
  let proxy = configProxy;
17266
17571
  if (!proxy && proxy !== false) {
17267
- const proxyUrl = proxyFromEnv__default["default"].getProxyForUrl(location);
17572
+ const proxyUrl = getProxyForUrl(location);
17268
17573
  if (proxyUrl) {
17269
- proxy = new URL(proxyUrl);
17574
+ if (!shouldBypassProxy(location)) {
17575
+ proxy = new URL(proxyUrl);
17576
+ }
17577
+ }
17578
+ }
17579
+ // On redirect re-invocation, strip any stale Proxy-Authorization header carried
17580
+ // over from the prior request (e.g. new target no longer uses a proxy, or uses
17581
+ // a different proxy). Skip on the initial request so user-supplied headers are
17582
+ // preserved. Header names are case-insensitive, so remove every case variant.
17583
+ if (isRedirect && options.headers) {
17584
+ for (const name of Object.keys(options.headers)) {
17585
+ if (name.toLowerCase() === 'proxy-authorization') {
17586
+ delete options.headers[name];
17587
+ }
17270
17588
  }
17271
17589
  }
17272
17590
  if (proxy) {
17591
+ // Read proxy fields without traversing the prototype chain. URL instances expose
17592
+ // username/password/hostname/host/port/protocol via getters on URL.prototype (so
17593
+ // direct reads are shielded), but plain object proxies — and the `auth` field
17594
+ // (which URL does not expose) — must be guarded so a polluted Object.prototype
17595
+ // (e.g. Object.prototype.auth = { username, password }) cannot inject
17596
+ // attacker-controlled credentials into the Proxy-Authorization header or
17597
+ // redirect proxying to an attacker-controlled host.
17598
+ const isProxyURL = proxy instanceof URL;
17599
+ const readProxyField = key => isProxyURL || utils$1$1.hasOwnProp(proxy, key) ? proxy[key] : undefined;
17600
+ const proxyUsername = readProxyField('username');
17601
+ const proxyPassword = readProxyField('password');
17602
+ let proxyAuth = utils$1$1.hasOwnProp(proxy, 'auth') ? proxy.auth : undefined;
17603
+
17273
17604
  // Basic proxy authorization
17274
- if (proxy.username) {
17275
- proxy.auth = (proxy.username || '') + ':' + (proxy.password || '');
17276
- }
17277
- if (proxy.auth) {
17278
- // Support proxy auth object form
17279
- const validProxyAuth = Boolean(proxy.auth.username || proxy.auth.password);
17605
+ if (proxyUsername) {
17606
+ proxyAuth = (proxyUsername || '') + ':' + (proxyPassword || '');
17607
+ }
17608
+ if (proxyAuth) {
17609
+ // Support proxy auth object form. Read sub-fields via own-prop checks so a
17610
+ // plain object inheriting from polluted Object.prototype cannot leak creds.
17611
+ const authIsObject = typeof proxyAuth === 'object';
17612
+ const authUsername = authIsObject && utils$1$1.hasOwnProp(proxyAuth, 'username') ? proxyAuth.username : undefined;
17613
+ const authPassword = authIsObject && utils$1$1.hasOwnProp(proxyAuth, 'password') ? proxyAuth.password : undefined;
17614
+ const validProxyAuth = Boolean(authUsername || authPassword);
17280
17615
  if (validProxyAuth) {
17281
- proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
17282
- } else if (typeof proxy.auth === 'object') {
17283
- throw new AxiosError$1('Invalid proxy authorization', AxiosError$1.ERR_BAD_OPTION, {
17616
+ proxyAuth = (authUsername || '') + ':' + (authPassword || '');
17617
+ } else if (authIsObject) {
17618
+ throw new AxiosError('Invalid proxy authorization', AxiosError.ERR_BAD_OPTION, {
17284
17619
  proxy
17285
17620
  });
17286
17621
  }
17287
- const base64 = Buffer.from(proxy.auth, 'utf8').toString('base64');
17622
+ const base64 = Buffer.from(proxyAuth, 'utf8').toString('base64');
17288
17623
  options.headers['Proxy-Authorization'] = 'Basic ' + base64;
17289
17624
  }
17290
- options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
17291
- const proxyHost = proxy.hostname || proxy.host;
17625
+
17626
+ // Preserve a user-supplied Host header (case-insensitive) so callers can override
17627
+ // the value forwarded to the proxy; otherwise default to the request URL's host.
17628
+ let hasUserHostHeader = false;
17629
+ for (const name of Object.keys(options.headers)) {
17630
+ if (name.toLowerCase() === 'host') {
17631
+ hasUserHostHeader = true;
17632
+ break;
17633
+ }
17634
+ }
17635
+ if (!hasUserHostHeader) {
17636
+ options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
17637
+ }
17638
+ const proxyHost = readProxyField('hostname') || readProxyField('host');
17292
17639
  options.hostname = proxyHost;
17293
17640
  // Replace 'host' since options is not a URL object
17294
17641
  options.host = proxyHost;
17295
- options.port = proxy.port;
17642
+ options.port = readProxyField('port');
17296
17643
  options.path = location;
17297
- if (proxy.protocol) {
17298
- options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
17644
+ const proxyProtocol = readProxyField('protocol');
17645
+ if (proxyProtocol) {
17646
+ options.protocol = proxyProtocol.includes(':') ? proxyProtocol : `${proxyProtocol}:`;
17299
17647
  }
17300
17648
  }
17301
17649
  options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
17302
17650
  // Configure proxy for redirected request, passing the original config proxy to apply
17303
17651
  // the exact same logic as if the redirected request was performed by axios directly.
17304
- setProxy(redirectOptions, configProxy, redirectOptions.href);
17652
+ setProxy(redirectOptions, configProxy, redirectOptions.href, true);
17305
17653
  };
17306
17654
  }
17307
17655
  const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1$1.kindOf(process) === 'process';
@@ -17357,7 +17705,7 @@ const http2Transport = {
17357
17705
  HTTP2_HEADER_METHOD,
17358
17706
  HTTP2_HEADER_PATH,
17359
17707
  HTTP2_HEADER_STATUS
17360
- } = http2__default["default"].constants;
17708
+ } = http2.constants;
17361
17709
  const http2Headers = {
17362
17710
  [HTTP2_HEADER_SCHEME]: options.protocol.replace(':', ''),
17363
17711
  [HTTP2_HEADER_METHOD]: options.method,
@@ -17382,23 +17730,22 @@ const http2Transport = {
17382
17730
  };
17383
17731
 
17384
17732
  /*eslint consistent-return:0*/
17385
- const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17733
+ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17386
17734
  return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
17387
- let {
17388
- data,
17389
- lookup,
17390
- family,
17391
- httpVersion = 1,
17392
- http2Options
17393
- } = config;
17394
- const {
17395
- responseType,
17396
- responseEncoding
17397
- } = config;
17735
+ const own = key => utils$1$1.hasOwnProp(config, key) ? config[key] : undefined;
17736
+ let data = own('data');
17737
+ let lookup = own('lookup');
17738
+ let family = own('family');
17739
+ let httpVersion = own('httpVersion');
17740
+ if (httpVersion === undefined) httpVersion = 1;
17741
+ let http2Options = own('http2Options');
17742
+ const responseType = own('responseType');
17743
+ const responseEncoding = own('responseEncoding');
17398
17744
  const method = config.method.toUpperCase();
17399
17745
  let isDone;
17400
17746
  let rejected = false;
17401
17747
  let req;
17748
+ let connectPhaseTimer;
17402
17749
  httpVersion = +httpVersion;
17403
17750
  if (Number.isNaN(httpVersion)) {
17404
17751
  throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
@@ -17408,7 +17755,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17408
17755
  }
17409
17756
  const isHttp2 = httpVersion === 2;
17410
17757
  if (lookup) {
17411
- const _lookup = callbackify$1(lookup, value => utils$1$1.isArray(value) ? value : [value]);
17758
+ const _lookup = callbackify(lookup, value => utils$1$1.isArray(value) ? value : [value]);
17412
17759
  // hotfix to support opt.all option which is required for node 20.x
17413
17760
  lookup = (hostname, opt, cb) => {
17414
17761
  _lookup(hostname, opt, (err, arg0, arg1) => {
@@ -17423,13 +17770,28 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17423
17770
  const abortEmitter = new events.EventEmitter();
17424
17771
  function abort(reason) {
17425
17772
  try {
17426
- abortEmitter.emit('abort', !reason || reason.type ? new CanceledError$1(null, config, req) : reason);
17773
+ abortEmitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
17427
17774
  } catch (err) {
17428
17775
  console.warn('emit error', err);
17429
17776
  }
17430
17777
  }
17778
+ function clearConnectPhaseTimer() {
17779
+ if (connectPhaseTimer) {
17780
+ clearTimeout(connectPhaseTimer);
17781
+ connectPhaseTimer = null;
17782
+ }
17783
+ }
17784
+ function createTimeoutError() {
17785
+ let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
17786
+ const transitional = config.transitional || transitionalDefaults;
17787
+ if (config.timeoutErrorMessage) {
17788
+ timeoutErrorMessage = config.timeoutErrorMessage;
17789
+ }
17790
+ return new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, req);
17791
+ }
17431
17792
  abortEmitter.once('abort', reject);
17432
17793
  const onFinished = () => {
17794
+ clearConnectPhaseTimer();
17433
17795
  if (config.cancelToken) {
17434
17796
  config.cancelToken.unsubscribe(abort);
17435
17797
  }
@@ -17446,6 +17808,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17446
17808
  }
17447
17809
  onDone((response, isRejected) => {
17448
17810
  isDone = true;
17811
+ clearConnectPhaseTimer();
17449
17812
  if (isRejected) {
17450
17813
  rejected = true;
17451
17814
  onFinished();
@@ -17454,8 +17817,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17454
17817
  const {
17455
17818
  data
17456
17819
  } = response;
17457
- if (data instanceof stream__default["default"].Readable || data instanceof stream__default["default"].Duplex) {
17458
- const offListeners = stream__default["default"].finished(data, () => {
17820
+ if (data instanceof stream.Readable || data instanceof stream.Duplex) {
17821
+ const offListeners = stream.finished(data, () => {
17459
17822
  offListeners();
17460
17823
  onFinished();
17461
17824
  });
@@ -17475,7 +17838,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17475
17838
  const dataUrl = String(config.url || fullPath || '');
17476
17839
  const estimated = estimateDataURLDecodedBytes(dataUrl);
17477
17840
  if (estimated > config.maxContentLength) {
17478
- return reject(new AxiosError$1('maxContentLength size of ' + config.maxContentLength + ' exceeded', AxiosError$1.ERR_BAD_RESPONSE, config));
17841
+ return reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config));
17479
17842
  }
17480
17843
  }
17481
17844
  let convertedData;
@@ -17492,7 +17855,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17492
17855
  Blob: config.env && config.env.Blob
17493
17856
  });
17494
17857
  } catch (err) {
17495
- throw AxiosError$1.from(err, AxiosError$1.ERR_BAD_REQUEST, config);
17858
+ throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
17496
17859
  }
17497
17860
  if (responseType === 'text') {
17498
17861
  convertedData = convertedData.toString(responseEncoding);
@@ -17500,20 +17863,20 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17500
17863
  convertedData = utils$1$1.stripBOM(convertedData);
17501
17864
  }
17502
17865
  } else if (responseType === 'stream') {
17503
- convertedData = stream__default["default"].Readable.from(convertedData);
17866
+ convertedData = stream.Readable.from(convertedData);
17504
17867
  }
17505
17868
  return settle(resolve, reject, {
17506
17869
  data: convertedData,
17507
17870
  status: 200,
17508
17871
  statusText: 'OK',
17509
- headers: new AxiosHeaders$1(),
17872
+ headers: new AxiosHeaders(),
17510
17873
  config
17511
17874
  });
17512
17875
  }
17513
17876
  if (supportedProtocols.indexOf(protocol) === -1) {
17514
- return reject(new AxiosError$1('Unsupported protocol ' + protocol, AxiosError$1.ERR_BAD_REQUEST, config));
17877
+ return reject(new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_BAD_REQUEST, config));
17515
17878
  }
17516
- const headers = AxiosHeaders$1.from(config.headers).normalize();
17879
+ const headers = AxiosHeaders.from(config.headers).normalize();
17517
17880
 
17518
17881
  // Set User-Agent (required by some servers)
17519
17882
  // See https://github.com/axios/axios/issues/69
@@ -17531,18 +17894,18 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17531
17894
  // support for spec compliant FormData objects
17532
17895
  if (utils$1$1.isSpecCompliantForm(data)) {
17533
17896
  const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
17534
- data = formDataToStream$1(data, formHeaders => {
17897
+ data = formDataToStream(data, formHeaders => {
17535
17898
  headers.set(formHeaders);
17536
17899
  }, {
17537
17900
  tag: `axios-${VERSION}-boundary`,
17538
17901
  boundary: userBoundary && userBoundary[1] || undefined
17539
17902
  });
17540
17903
  // support for https://www.npmjs.com/package/form-data api
17541
- } else if (utils$1$1.isFormData(data) && utils$1$1.isFunction(data.getHeaders)) {
17542
- headers.set(data.getHeaders());
17904
+ } else if (utils$1$1.isFormData(data) && utils$1$1.isFunction(data.getHeaders) && data.getHeaders !== Object.prototype.getHeaders) {
17905
+ setFormDataHeaders$1(headers, data.getHeaders(), own('formDataHeaderPolicy'));
17543
17906
  if (!headers.hasContentLength()) {
17544
17907
  try {
17545
- const knownLength = await util__default["default"].promisify(data.getLength).call(data);
17908
+ const knownLength = await util.promisify(data.getLength).call(data);
17546
17909
  Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
17547
17910
  /*eslint no-empty:0*/
17548
17911
  } catch (e) {}
@@ -17550,20 +17913,20 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17550
17913
  } else if (utils$1$1.isBlob(data) || utils$1$1.isFile(data)) {
17551
17914
  data.size && headers.setContentType(data.type || 'application/octet-stream');
17552
17915
  headers.setContentLength(data.size || 0);
17553
- data = stream__default["default"].Readable.from(readBlob$1(data));
17916
+ data = stream.Readable.from(readBlob(data));
17554
17917
  } else if (data && !utils$1$1.isStream(data)) {
17555
17918
  if (Buffer.isBuffer(data)) ;else if (utils$1$1.isArrayBuffer(data)) {
17556
17919
  data = Buffer.from(new Uint8Array(data));
17557
17920
  } else if (utils$1$1.isString(data)) {
17558
17921
  data = Buffer.from(data, 'utf-8');
17559
17922
  } else {
17560
- return reject(new AxiosError$1('Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', AxiosError$1.ERR_BAD_REQUEST, config));
17923
+ return reject(new AxiosError('Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', AxiosError.ERR_BAD_REQUEST, config));
17561
17924
  }
17562
17925
 
17563
17926
  // Add Content-Length header if data exists
17564
17927
  headers.setContentLength(data.length, false);
17565
17928
  if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
17566
- return reject(new AxiosError$1('Request body larger than maxBodyLength limit', AxiosError$1.ERR_BAD_REQUEST, config));
17929
+ return reject(new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config));
17567
17930
  }
17568
17931
  }
17569
17932
  const contentLength = utils$1$1.toFiniteNumber(headers.getContentLength());
@@ -17575,11 +17938,11 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17575
17938
  }
17576
17939
  if (data && (onUploadProgress || maxUploadRate)) {
17577
17940
  if (!utils$1$1.isStream(data)) {
17578
- data = stream__default["default"].Readable.from(data, {
17941
+ data = stream.Readable.from(data, {
17579
17942
  objectMode: false
17580
17943
  });
17581
17944
  }
17582
- data = stream__default["default"].pipeline([data, new AxiosTransformStream$1({
17945
+ data = stream.pipeline([data, new AxiosTransformStream({
17583
17946
  maxRate: utils$1$1.toFiniteNumber(maxUploadRate)
17584
17947
  })], utils$1$1.noop);
17585
17948
  onUploadProgress && data.on('progress', flushOnFinish(data, progressEventDecorator(contentLength, progressEventReducer(asyncDecorator(onUploadProgress), false, 3))));
@@ -17587,20 +17950,21 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17587
17950
 
17588
17951
  // HTTP basic authentication
17589
17952
  let auth = undefined;
17590
- if (config.auth) {
17591
- const username = config.auth.username || '';
17592
- const password = config.auth.password || '';
17953
+ const configAuth = own('auth');
17954
+ if (configAuth) {
17955
+ const username = configAuth.username || '';
17956
+ const password = configAuth.password || '';
17593
17957
  auth = username + ':' + password;
17594
17958
  }
17595
17959
  if (!auth && parsed.username) {
17596
- const urlUsername = parsed.username;
17597
- const urlPassword = parsed.password;
17960
+ const urlUsername = decodeURIComponentSafe(parsed.username);
17961
+ const urlPassword = decodeURIComponentSafe(parsed.password);
17598
17962
  auth = urlUsername + ':' + urlPassword;
17599
17963
  }
17600
17964
  auth && headers.delete('authorization');
17601
- let path;
17965
+ let path$1;
17602
17966
  try {
17603
- path = buildURL(parsed.pathname + parsed.search, config.params, config.paramsSerializer).replace(/^\?/, '');
17967
+ path$1 = buildURL(parsed.pathname + parsed.search, config.params, config.paramsSerializer).replace(/^\?/, '');
17604
17968
  } catch (err) {
17605
17969
  const customErr = new Error(err.message);
17606
17970
  customErr.config = config;
@@ -17609,8 +17973,11 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17609
17973
  return reject(customErr);
17610
17974
  }
17611
17975
  headers.set('Accept-Encoding', 'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false);
17612
- const options = {
17613
- path,
17976
+
17977
+ // Null-prototype to block prototype pollution gadgets on properties read
17978
+ // directly by Node's http.request (e.g. insecureHTTPParser, lookup).
17979
+ const options = Object.assign(Object.create(null), {
17980
+ path: path$1,
17614
17981
  method: method,
17615
17982
  headers: headers.toJSON(),
17616
17983
  agents: {
@@ -17621,13 +17988,24 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17621
17988
  protocol,
17622
17989
  family,
17623
17990
  beforeRedirect: dispatchBeforeRedirect,
17624
- beforeRedirects: {},
17991
+ beforeRedirects: Object.create(null),
17625
17992
  http2Options
17626
- };
17993
+ });
17627
17994
 
17628
17995
  // cacheable-lookup integration hotfix
17629
17996
  !utils$1$1.isUndefined(lookup) && (options.lookup = lookup);
17630
17997
  if (config.socketPath) {
17998
+ if (typeof config.socketPath !== 'string') {
17999
+ return reject(new AxiosError('socketPath must be a string', AxiosError.ERR_BAD_OPTION_VALUE, config));
18000
+ }
18001
+ if (config.allowedSocketPaths != null) {
18002
+ const allowed = Array.isArray(config.allowedSocketPaths) ? config.allowedSocketPaths : [config.allowedSocketPaths];
18003
+ const resolvedSocket = path.resolve(config.socketPath);
18004
+ const isAllowed = allowed.some(entry => typeof entry === 'string' && path.resolve(entry) === resolvedSocket);
18005
+ if (!isAllowed) {
18006
+ return reject(new AxiosError(`socketPath "${config.socketPath}" is not permitted by allowedSocketPaths`, AxiosError.ERR_BAD_OPTION_VALUE, config));
18007
+ }
18008
+ }
17631
18009
  options.socketPath = config.socketPath;
17632
18010
  } else {
17633
18011
  options.hostname = parsed.hostname.startsWith('[') ? parsed.hostname.slice(1, -1) : parsed.hostname;
@@ -17635,21 +18013,25 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17635
18013
  setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
17636
18014
  }
17637
18015
  let transport;
18016
+ let isNativeTransport = false;
17638
18017
  const isHttpsRequest = isHttps.test(options.protocol);
17639
18018
  options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
17640
18019
  if (isHttp2) {
17641
18020
  transport = http2Transport;
17642
18021
  } else {
17643
- if (config.transport) {
17644
- transport = config.transport;
18022
+ const configTransport = own('transport');
18023
+ if (configTransport) {
18024
+ transport = configTransport;
17645
18025
  } else if (config.maxRedirects === 0) {
17646
- transport = isHttpsRequest ? https__default["default"] : http__default["default"];
18026
+ transport = isHttpsRequest ? https : http;
18027
+ isNativeTransport = true;
17647
18028
  } else {
17648
18029
  if (config.maxRedirects) {
17649
18030
  options.maxRedirects = config.maxRedirects;
17650
18031
  }
17651
- if (config.beforeRedirect) {
17652
- options.beforeRedirects.config = config.beforeRedirect;
18032
+ const configBeforeRedirect = own('beforeRedirect');
18033
+ if (configBeforeRedirect) {
18034
+ options.beforeRedirects.config = configBeforeRedirect;
17653
18035
  }
17654
18036
  transport = isHttpsRequest ? httpsFollow : httpFollow;
17655
18037
  }
@@ -17660,17 +18042,20 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17660
18042
  // follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
17661
18043
  options.maxBodyLength = Infinity;
17662
18044
  }
17663
- if (config.insecureHTTPParser) {
17664
- options.insecureHTTPParser = config.insecureHTTPParser;
17665
- }
18045
+
18046
+ // Always set an explicit own value so a polluted
18047
+ // Object.prototype.insecureHTTPParser cannot enable the lenient parser
18048
+ // through Node's internal options copy
18049
+ options.insecureHTTPParser = Boolean(own('insecureHTTPParser'));
17666
18050
 
17667
18051
  // Create the request
17668
18052
  req = transport.request(options, function handleResponse(res) {
18053
+ clearConnectPhaseTimer();
17669
18054
  if (req.destroyed) return;
17670
18055
  const streams = [res];
17671
18056
  const responseLength = utils$1$1.toFiniteNumber(res.headers['content-length']);
17672
18057
  if (onDownloadProgress || maxDownloadRate) {
17673
- const transformStream = new AxiosTransformStream$1({
18058
+ const transformStream = new AxiosTransformStream({
17674
18059
  maxRate: utils$1$1.toFiniteNumber(maxDownloadRate)
17675
18060
  });
17676
18061
  onDownloadProgress && transformStream.on('progress', flushOnFinish(transformStream, progressEventDecorator(responseLength, progressEventReducer(asyncDecorator(onDownloadProgress), true, 3))));
@@ -17697,36 +18082,82 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17697
18082
  case 'compress':
17698
18083
  case 'x-compress':
17699
18084
  // add the unzipper to the body stream processing pipeline
17700
- streams.push(zlib__default["default"].createUnzip(zlibOptions));
18085
+ streams.push(zlib.createUnzip(zlibOptions));
17701
18086
 
17702
18087
  // remove the content-encoding in order to not confuse downstream operations
17703
18088
  delete res.headers['content-encoding'];
17704
18089
  break;
17705
18090
  case 'deflate':
17706
- streams.push(new ZlibHeaderTransformStream$1());
18091
+ streams.push(new ZlibHeaderTransformStream());
17707
18092
 
17708
18093
  // add the unzipper to the body stream processing pipeline
17709
- streams.push(zlib__default["default"].createUnzip(zlibOptions));
18094
+ streams.push(zlib.createUnzip(zlibOptions));
17710
18095
 
17711
18096
  // remove the content-encoding in order to not confuse downstream operations
17712
18097
  delete res.headers['content-encoding'];
17713
18098
  break;
17714
18099
  case 'br':
17715
18100
  if (isBrotliSupported) {
17716
- streams.push(zlib__default["default"].createBrotliDecompress(brotliOptions));
18101
+ streams.push(zlib.createBrotliDecompress(brotliOptions));
17717
18102
  delete res.headers['content-encoding'];
17718
18103
  }
17719
18104
  }
17720
18105
  }
17721
- responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils$1$1.noop) : streams[0];
18106
+ responseStream = streams.length > 1 ? stream.pipeline(streams, utils$1$1.noop) : streams[0];
17722
18107
  const response = {
17723
18108
  status: res.statusCode,
17724
18109
  statusText: res.statusMessage,
17725
- headers: new AxiosHeaders$1(res.headers),
18110
+ headers: new AxiosHeaders(res.headers),
17726
18111
  config,
17727
18112
  request: lastRequest
17728
18113
  };
17729
18114
  if (responseType === 'stream') {
18115
+ // Enforce maxContentLength on streamed responses; previously this
18116
+ // was applied only to buffered responses.
18117
+ if (config.maxContentLength > -1) {
18118
+ const limit = config.maxContentLength;
18119
+ const source = responseStream;
18120
+ function enforceMaxContentLength() {
18121
+ return _enforceMaxContentLength.apply(this, arguments);
18122
+ }
18123
+ function _enforceMaxContentLength() {
18124
+ _enforceMaxContentLength = _wrapAsyncGenerator(function* () {
18125
+ let totalResponseBytes = 0;
18126
+ var _iteratorAbruptCompletion = false;
18127
+ var _didIteratorError = false;
18128
+ var _iteratorError;
18129
+ try {
18130
+ for (var _iterator2 = _asyncIterator(source), _step; _iteratorAbruptCompletion = !(_step = yield _awaitAsyncGenerator(_iterator2.next())).done; _iteratorAbruptCompletion = false) {
18131
+ const chunk = _step.value;
18132
+ {
18133
+ totalResponseBytes += chunk.length;
18134
+ if (totalResponseBytes > limit) {
18135
+ throw new AxiosError('maxContentLength size of ' + limit + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, lastRequest);
18136
+ }
18137
+ yield chunk;
18138
+ }
18139
+ }
18140
+ } catch (err) {
18141
+ _didIteratorError = true;
18142
+ _iteratorError = err;
18143
+ } finally {
18144
+ try {
18145
+ if (_iteratorAbruptCompletion && _iterator2.return != null) {
18146
+ yield _awaitAsyncGenerator(_iterator2.return());
18147
+ }
18148
+ } finally {
18149
+ if (_didIteratorError) {
18150
+ throw _iteratorError;
18151
+ }
18152
+ }
18153
+ }
18154
+ });
18155
+ return _enforceMaxContentLength.apply(this, arguments);
18156
+ }
18157
+ responseStream = stream.Readable.from(enforceMaxContentLength(), {
18158
+ objectMode: false
18159
+ });
18160
+ }
17730
18161
  response.data = responseStream;
17731
18162
  settle(resolve, reject, response);
17732
18163
  } else {
@@ -17741,20 +18172,20 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17741
18172
  // stream.destroy() emit aborted event before calling reject() on Node.js v16
17742
18173
  rejected = true;
17743
18174
  responseStream.destroy();
17744
- abort(new AxiosError$1('maxContentLength size of ' + config.maxContentLength + ' exceeded', AxiosError$1.ERR_BAD_RESPONSE, config, lastRequest));
18175
+ abort(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
17745
18176
  }
17746
18177
  });
17747
18178
  responseStream.on('aborted', function handlerStreamAborted() {
17748
18179
  if (rejected) {
17749
18180
  return;
17750
18181
  }
17751
- const err = new AxiosError$1('stream has been aborted', AxiosError$1.ERR_BAD_RESPONSE, config, lastRequest);
18182
+ const err = new AxiosError('stream has been aborted', AxiosError.ERR_BAD_RESPONSE, config, lastRequest, response);
17752
18183
  responseStream.destroy(err);
17753
18184
  reject(err);
17754
18185
  });
17755
18186
  responseStream.on('error', function handleStreamError(err) {
17756
- if (req.destroyed) return;
17757
- reject(AxiosError$1.from(err, null, config, lastRequest));
18187
+ if (rejected) return;
18188
+ reject(AxiosError.from(err, null, config, lastRequest, response));
17758
18189
  });
17759
18190
  responseStream.on('end', function handleStreamEnd() {
17760
18191
  try {
@@ -17767,7 +18198,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17767
18198
  }
17768
18199
  response.data = responseData;
17769
18200
  } catch (err) {
17770
- return reject(AxiosError$1.from(err, null, config, response.request, response));
18201
+ return reject(AxiosError.from(err, null, config, response.request, response));
17771
18202
  }
17772
18203
  settle(resolve, reject, response);
17773
18204
  });
@@ -17789,13 +18220,48 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17789
18220
 
17790
18221
  // Handle errors
17791
18222
  req.on('error', function handleRequestError(err) {
17792
- reject(AxiosError$1.from(err, null, config, req));
18223
+ reject(AxiosError.from(err, null, config, req));
17793
18224
  });
17794
18225
 
17795
18226
  // set tcp keep alive to prevent drop connection by peer
18227
+ // Track every socket bound to this outer RedirectableRequest so a single
18228
+ // 'close' listener can release ownership on all of them. follow-redirects
18229
+ // re-emits the 'socket' event for each hop's native request onto the same
18230
+ // outer request, so attaching per-request listeners inside this handler
18231
+ // would accumulate across hops and trigger MaxListenersExceededWarning at
18232
+ // >= 11 redirects. Clearing only the last-bound socket would leave stale
18233
+ // kAxiosCurrentReq refs on earlier hop sockets returned to the keep-alive
18234
+ // pool, causing an idle-pool 'error' to be attributed to a closed req.
18235
+ const boundSockets = new Set();
17796
18236
  req.on('socket', function handleRequestSocket(socket) {
17797
18237
  // default interval of sending ack packet is 1 minute
17798
18238
  socket.setKeepAlive(true, 1000 * 60);
18239
+
18240
+ // Install a single 'error' listener per socket (not per request) to avoid
18241
+ // accumulating listeners on pooled keep-alive sockets that get reassigned
18242
+ // to new requests before the previous request's 'close' fires (issue #10780).
18243
+ // The listener is bound to the socket's currently-active request via a
18244
+ // symbol, which is swapped as the socket is reassigned.
18245
+ if (!socket[kAxiosSocketListener]) {
18246
+ socket.on('error', function handleSocketError(err) {
18247
+ const current = socket[kAxiosCurrentReq];
18248
+ if (current && !current.destroyed) {
18249
+ current.destroy(err);
18250
+ }
18251
+ });
18252
+ socket[kAxiosSocketListener] = true;
18253
+ }
18254
+ socket[kAxiosCurrentReq] = req;
18255
+ boundSockets.add(socket);
18256
+ });
18257
+ req.once('close', function clearCurrentReq() {
18258
+ clearConnectPhaseTimer();
18259
+ for (const socket of boundSockets) {
18260
+ if (socket[kAxiosCurrentReq] === req) {
18261
+ socket[kAxiosCurrentReq] = null;
18262
+ }
18263
+ }
18264
+ boundSockets.clear();
17799
18265
  });
17800
18266
 
17801
18267
  // Handle request timeout
@@ -17803,24 +18269,26 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17803
18269
  // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
17804
18270
  const timeout = parseInt(config.timeout, 10);
17805
18271
  if (Number.isNaN(timeout)) {
17806
- abort(new AxiosError$1('error trying to parse `config.timeout` to int', AxiosError$1.ERR_BAD_OPTION_VALUE, config, req));
18272
+ abort(new AxiosError('error trying to parse `config.timeout` to int', AxiosError.ERR_BAD_OPTION_VALUE, config, req));
17807
18273
  return;
17808
18274
  }
18275
+ const handleTimeout = function handleTimeout() {
18276
+ if (isDone) return;
18277
+ abort(createTimeoutError());
18278
+ };
18279
+ if (isNativeTransport && timeout > 0) {
18280
+ // Native ClientRequest#setTimeout starts from the socket lifecycle and
18281
+ // may not fire while TCP connect is still pending. Mirror the
18282
+ // follow-redirects wall-clock timer for the maxRedirects === 0 path.
18283
+ connectPhaseTimer = setTimeout(handleTimeout, timeout);
18284
+ }
17809
18285
 
17810
18286
  // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
17811
18287
  // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
17812
18288
  // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
17813
18289
  // And then these socket which be hang up will devouring CPU little by little.
17814
18290
  // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
17815
- req.setTimeout(timeout, function handleRequestTimeout() {
17816
- if (isDone) return;
17817
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
17818
- const transitional = config.transitional || transitionalDefaults;
17819
- if (config.timeoutErrorMessage) {
17820
- timeoutErrorMessage = config.timeoutErrorMessage;
17821
- }
17822
- abort(new AxiosError$1(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED, config, req));
17823
- });
18291
+ req.setTimeout(timeout, handleTimeout);
17824
18292
  } else {
17825
18293
  // explicitly reset the socket timeout value for a possible `keep-alive` request
17826
18294
  req.setTimeout(0);
@@ -17839,21 +18307,42 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17839
18307
  });
17840
18308
  data.on('close', () => {
17841
18309
  if (!ended && !errored) {
17842
- abort(new CanceledError$1('Request stream has been aborted', config, req));
18310
+ abort(new CanceledError('Request stream has been aborted', config, req));
17843
18311
  }
17844
18312
  });
17845
- data.pipe(req);
18313
+
18314
+ // Enforce maxBodyLength for streamed uploads on the native http/https
18315
+ // transport (maxRedirects === 0); follow-redirects enforces it on the
18316
+ // other path.
18317
+ let uploadStream = data;
18318
+ if (config.maxBodyLength > -1 && config.maxRedirects === 0) {
18319
+ const limit = config.maxBodyLength;
18320
+ let bytesSent = 0;
18321
+ uploadStream = stream.pipeline([data, new stream.Transform({
18322
+ transform(chunk, _enc, cb) {
18323
+ bytesSent += chunk.length;
18324
+ if (bytesSent > limit) {
18325
+ return cb(new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, req));
18326
+ }
18327
+ cb(null, chunk);
18328
+ }
18329
+ })], utils$1$1.noop);
18330
+ uploadStream.on('error', err => {
18331
+ if (!req.destroyed) req.destroy(err);
18332
+ });
18333
+ }
18334
+ uploadStream.pipe(req);
17846
18335
  } else {
17847
18336
  data && req.write(data);
17848
18337
  req.end();
17849
18338
  }
17850
18339
  });
17851
18340
  };
17852
- const isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => url => {
18341
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => url => {
17853
18342
  url = new URL(url, platform.origin);
17854
18343
  return origin.protocol === url.protocol && origin.host === url.host && (isMSIE || origin.port === url.port);
17855
18344
  })(new URL(platform.origin), platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)) : () => true;
17856
- const cookies = platform.hasStandardBrowserEnv ?
18345
+ var cookies = platform.hasStandardBrowserEnv ?
17857
18346
  // Standard browser envs support document.cookie
17858
18347
  {
17859
18348
  write(name, value, expires, path, domain, secure, sameSite) {
@@ -17878,8 +18367,20 @@ const cookies = platform.hasStandardBrowserEnv ?
17878
18367
  },
17879
18368
  read(name) {
17880
18369
  if (typeof document === 'undefined') return null;
17881
- const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
17882
- return match ? decodeURIComponent(match[1]) : null;
18370
+ // Match name=value by splitting on the semicolon separator instead of building a
18371
+ // RegExp from `name` interpolating an unescaped string into a RegExp would let
18372
+ // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
18373
+ // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
18374
+ // "; ", so ignore optional whitespace before each cookie name.
18375
+ const cookies = document.cookie.split(';');
18376
+ for (let i = 0; i < cookies.length; i++) {
18377
+ const cookie = cookies[i].replace(/^\s+/, '');
18378
+ const eq = cookie.indexOf('=');
18379
+ if (eq !== -1 && cookie.slice(0, eq) === name) {
18380
+ return decodeURIComponent(cookie.slice(eq + 1));
18381
+ }
18382
+ }
18383
+ return null;
17883
18384
  },
17884
18385
  remove(name) {
17885
18386
  this.write(name, '', Date.now() - 86400000, '/');
@@ -17893,7 +18394,7 @@ const cookies = platform.hasStandardBrowserEnv ?
17893
18394
  },
17894
18395
  remove() {}
17895
18396
  };
17896
- const headersToObject = thing => thing instanceof AxiosHeaders$1 ? _objectSpread2({}, thing) : thing;
18397
+ const headersToObject = thing => thing instanceof AxiosHeaders ? _objectSpread2({}, thing) : thing;
17897
18398
 
17898
18399
  /**
17899
18400
  * Config-specific merge-function which creates a new config-object
@@ -17907,7 +18408,21 @@ const headersToObject = thing => thing instanceof AxiosHeaders$1 ? _objectSpread
17907
18408
  function mergeConfig(config1, config2) {
17908
18409
  // eslint-disable-next-line no-param-reassign
17909
18410
  config2 = config2 || {};
17910
- const config = {};
18411
+
18412
+ // Use a null-prototype object so that downstream reads such as `config.auth`
18413
+ // or `config.baseURL` cannot inherit polluted values from Object.prototype.
18414
+ // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
18415
+ // ergonomics for user code that relies on it.
18416
+ const config = Object.create(null);
18417
+ Object.defineProperty(config, 'hasOwnProperty', {
18418
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
18419
+ // this data descriptor into an accessor descriptor on the way in.
18420
+ __proto__: null,
18421
+ value: Object.prototype.hasOwnProperty,
18422
+ enumerable: false,
18423
+ writable: true,
18424
+ configurable: true
18425
+ });
17911
18426
  function getMergedValue(target, source, prop, caseless) {
17912
18427
  if (utils$1$1.isPlainObject(target) && utils$1$1.isPlainObject(source)) {
17913
18428
  return utils$1$1.merge.call({
@@ -17946,9 +18461,9 @@ function mergeConfig(config1, config2) {
17946
18461
 
17947
18462
  // eslint-disable-next-line consistent-return
17948
18463
  function mergeDirectKeys(a, b, prop) {
17949
- if (prop in config2) {
18464
+ if (utils$1$1.hasOwnProp(config2, prop)) {
17950
18465
  return getMergedValue(a, b);
17951
- } else if (prop in config1) {
18466
+ } else if (utils$1$1.hasOwnProp(config1, prop)) {
17952
18467
  return getMergedValue(undefined, a);
17953
18468
  }
17954
18469
  }
@@ -17979,6 +18494,7 @@ function mergeConfig(config1, config2) {
17979
18494
  httpsAgent: defaultToConfig2,
17980
18495
  cancelToken: defaultToConfig2,
17981
18496
  socketPath: defaultToConfig2,
18497
+ allowedSocketPaths: defaultToConfig2,
17982
18498
  responseEncoding: defaultToConfig2,
17983
18499
  validateStatus: mergeDirectKeys,
17984
18500
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
@@ -17986,41 +18502,63 @@ function mergeConfig(config1, config2) {
17986
18502
  utils$1$1.forEach(Object.keys(_objectSpread2(_objectSpread2({}, config1), config2)), function computeConfigValue(prop) {
17987
18503
  if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
17988
18504
  const merge = utils$1$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
17989
- const configValue = merge(config1[prop], config2[prop], prop);
18505
+ const a = utils$1$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
18506
+ const b = utils$1$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
18507
+ const configValue = merge(a, b, prop);
17990
18508
  utils$1$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
17991
18509
  });
17992
18510
  return config;
17993
18511
  }
17994
- const resolveConfig = config => {
18512
+ const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
18513
+ function setFormDataHeaders(headers, formHeaders, policy) {
18514
+ if (policy !== 'content-only') {
18515
+ headers.set(formHeaders);
18516
+ return;
18517
+ }
18518
+ Object.entries(formHeaders).forEach(([key, val]) => {
18519
+ if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
18520
+ headers.set(key, val);
18521
+ }
18522
+ });
18523
+ }
18524
+
18525
+ /**
18526
+ * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
18527
+ * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
18528
+ *
18529
+ * @param {string} str The string to encode
18530
+ *
18531
+ * @returns {string} UTF-8 bytes as a Latin-1 string
18532
+ */
18533
+ const encodeUTF8 = str => encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
18534
+ var resolveConfig = config => {
17995
18535
  const newConfig = mergeConfig({}, config);
17996
- let {
17997
- data,
17998
- withXSRFToken,
17999
- xsrfHeaderName,
18000
- xsrfCookieName,
18001
- headers,
18002
- auth
18003
- } = newConfig;
18004
- newConfig.headers = headers = AxiosHeaders$1.from(headers);
18005
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
18536
+
18537
+ // Read only own properties to prevent prototype pollution gadgets
18538
+ // (e.g. Object.prototype.baseURL = 'https://evil.com').
18539
+ const own = key => utils$1$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined;
18540
+ const data = own('data');
18541
+ let withXSRFToken = own('withXSRFToken');
18542
+ const xsrfHeaderName = own('xsrfHeaderName');
18543
+ const xsrfCookieName = own('xsrfCookieName');
18544
+ let headers = own('headers');
18545
+ const auth = own('auth');
18546
+ const baseURL = own('baseURL');
18547
+ const allowAbsoluteUrls = own('allowAbsoluteUrls');
18548
+ const url = own('url');
18549
+ newConfig.headers = headers = AxiosHeaders.from(headers);
18550
+ newConfig.url = buildURL(buildFullPath(baseURL, url, allowAbsoluteUrls), config.params, config.paramsSerializer);
18006
18551
 
18007
18552
  // HTTP basic authentication
18008
18553
  if (auth) {
18009
- headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : '')));
18554
+ headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : '')));
18010
18555
  }
18011
18556
  if (utils$1$1.isFormData(data)) {
18012
18557
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
18013
18558
  headers.setContentType(undefined); // browser handles it
18014
18559
  } else if (utils$1$1.isFunction(data.getHeaders)) {
18015
18560
  // Node.js FormData (like form-data package)
18016
- const formHeaders = data.getHeaders();
18017
- // Only set safe headers to avoid overwriting security headers
18018
- const allowedHeaders = ['content-type', 'content-length'];
18019
- Object.entries(formHeaders).forEach(([key, val]) => {
18020
- if (allowedHeaders.includes(key.toLowerCase())) {
18021
- headers.set(key, val);
18022
- }
18023
- });
18561
+ setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
18024
18562
  }
18025
18563
  }
18026
18564
 
@@ -18029,9 +18567,15 @@ const resolveConfig = config => {
18029
18567
  // Specifically not if we're in a web worker, or react-native.
18030
18568
 
18031
18569
  if (platform.hasStandardBrowserEnv) {
18032
- withXSRFToken && utils$1$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
18033
- if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
18034
- // Add xsrf header
18570
+ if (utils$1$1.isFunction(withXSRFToken)) {
18571
+ withXSRFToken = withXSRFToken(newConfig);
18572
+ }
18573
+
18574
+ // Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
18575
+ // and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
18576
+ // the XSRF token cross-origin.
18577
+ const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
18578
+ if (shouldSendXSRF) {
18035
18579
  const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
18036
18580
  if (xsrfValue) {
18037
18581
  headers.set(xsrfHeaderName, xsrfValue);
@@ -18041,11 +18585,11 @@ const resolveConfig = config => {
18041
18585
  return newConfig;
18042
18586
  };
18043
18587
  const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
18044
- const xhrAdapter = isXHRAdapterSupported && function (config) {
18588
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
18045
18589
  return new Promise(function dispatchXhrRequest(resolve, reject) {
18046
18590
  const _config = resolveConfig(config);
18047
18591
  let requestData = _config.data;
18048
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
18592
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
18049
18593
  let {
18050
18594
  responseType,
18051
18595
  onUploadProgress,
@@ -18071,7 +18615,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
18071
18615
  return;
18072
18616
  }
18073
18617
  // Prepare the response
18074
- const responseHeaders = AxiosHeaders$1.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
18618
+ const responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
18075
18619
  const responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
18076
18620
  const response = {
18077
18621
  data: responseData,
@@ -18106,7 +18650,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
18106
18650
  // handled by onerror instead
18107
18651
  // With one exception: request that using file: protocol, most browsers
18108
18652
  // will return status as 0 even though it's a successful request
18109
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
18653
+ if (request.status === 0 && !(request.responseURL && request.responseURL.startsWith('file:'))) {
18110
18654
  return;
18111
18655
  }
18112
18656
  // readystate handler is calling before onerror or ontimeout handlers,
@@ -18120,7 +18664,8 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
18120
18664
  if (!request) {
18121
18665
  return;
18122
18666
  }
18123
- reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
18667
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
18668
+ done();
18124
18669
 
18125
18670
  // Clean up request
18126
18671
  request = null;
@@ -18132,10 +18677,11 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
18132
18677
  // (message may be empty; when present, surface it)
18133
18678
  // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
18134
18679
  const msg = event && event.message ? event.message : 'Network Error';
18135
- const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
18680
+ const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
18136
18681
  // attach the underlying event for consumers who want details
18137
18682
  err.event = event || null;
18138
18683
  reject(err);
18684
+ done();
18139
18685
  request = null;
18140
18686
  };
18141
18687
 
@@ -18146,7 +18692,8 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
18146
18692
  if (_config.timeoutErrorMessage) {
18147
18693
  timeoutErrorMessage = _config.timeoutErrorMessage;
18148
18694
  }
18149
- reject(new AxiosError$1(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED, config, request));
18695
+ reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
18696
+ done();
18150
18697
 
18151
18698
  // Clean up request
18152
18699
  request = null;
@@ -18191,8 +18738,9 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
18191
18738
  if (!request) {
18192
18739
  return;
18193
18740
  }
18194
- reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
18741
+ reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
18195
18742
  request.abort();
18743
+ done();
18196
18744
  request = null;
18197
18745
  };
18198
18746
  _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
@@ -18201,8 +18749,8 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
18201
18749
  }
18202
18750
  }
18203
18751
  const protocol = parseProtocol(_config.url);
18204
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
18205
- reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
18752
+ if (protocol && !platform.protocols.includes(protocol)) {
18753
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
18206
18754
  return;
18207
18755
  }
18208
18756
 
@@ -18222,12 +18770,12 @@ const composeSignals = (signals, timeout) => {
18222
18770
  aborted = true;
18223
18771
  unsubscribe();
18224
18772
  const err = reason instanceof Error ? reason : this.reason;
18225
- controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
18773
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
18226
18774
  }
18227
18775
  };
18228
18776
  let timer = timeout && setTimeout(() => {
18229
18777
  timer = null;
18230
- onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
18778
+ onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
18231
18779
  }, timeout);
18232
18780
  const unsubscribe = () => {
18233
18781
  if (signals) {
@@ -18247,10 +18795,9 @@ const composeSignals = (signals, timeout) => {
18247
18795
  return signal;
18248
18796
  }
18249
18797
  };
18250
- const composeSignals$1 = composeSignals;
18251
18798
  const streamChunk = function* (chunk, chunkSize) {
18252
18799
  let len = chunk.byteLength;
18253
- if (!chunkSize || len < chunkSize) {
18800
+ if (len < chunkSize) {
18254
18801
  yield chunk;
18255
18802
  return;
18256
18803
  }
@@ -18264,27 +18811,27 @@ const streamChunk = function* (chunk, chunkSize) {
18264
18811
  };
18265
18812
  const readBytes = /*#__PURE__*/function () {
18266
18813
  var _ref3 = _wrapAsyncGenerator(function* (iterable, chunkSize) {
18267
- var _iteratorAbruptCompletion = false;
18268
- var _didIteratorError = false;
18269
- var _iteratorError;
18814
+ var _iteratorAbruptCompletion2 = false;
18815
+ var _didIteratorError2 = false;
18816
+ var _iteratorError2;
18270
18817
  try {
18271
- for (var _iterator2 = _asyncIterator(readStream(iterable)), _step; _iteratorAbruptCompletion = !(_step = yield _awaitAsyncGenerator(_iterator2.next())).done; _iteratorAbruptCompletion = false) {
18272
- const chunk = _step.value;
18818
+ for (var _iterator3 = _asyncIterator(readStream(iterable)), _step2; _iteratorAbruptCompletion2 = !(_step2 = yield _awaitAsyncGenerator(_iterator3.next())).done; _iteratorAbruptCompletion2 = false) {
18819
+ const chunk = _step2.value;
18273
18820
  {
18274
18821
  yield* _asyncGeneratorDelegate(_asyncIterator(streamChunk(chunk, chunkSize)), _awaitAsyncGenerator);
18275
18822
  }
18276
18823
  }
18277
18824
  } catch (err) {
18278
- _didIteratorError = true;
18279
- _iteratorError = err;
18825
+ _didIteratorError2 = true;
18826
+ _iteratorError2 = err;
18280
18827
  } finally {
18281
18828
  try {
18282
- if (_iteratorAbruptCompletion && _iterator2.return != null) {
18283
- yield _awaitAsyncGenerator(_iterator2.return());
18829
+ if (_iteratorAbruptCompletion2 && _iterator3.return != null) {
18830
+ yield _awaitAsyncGenerator(_iterator3.return());
18284
18831
  }
18285
18832
  } finally {
18286
- if (_didIteratorError) {
18287
- throw _iteratorError;
18833
+ if (_didIteratorError2) {
18834
+ throw _iteratorError2;
18288
18835
  }
18289
18836
  }
18290
18837
  }
@@ -18364,17 +18911,6 @@ const DEFAULT_CHUNK_SIZE = 64 * 1024;
18364
18911
  const {
18365
18912
  isFunction
18366
18913
  } = utils$1$1;
18367
- const globalFetchAPI = (({
18368
- Request,
18369
- Response
18370
- }) => ({
18371
- Request,
18372
- Response
18373
- }))(utils$1$1.global);
18374
- const {
18375
- ReadableStream: ReadableStream$1,
18376
- TextEncoder: TextEncoder$1
18377
- } = utils$1$1.global;
18378
18914
  const test = (fn, ...args) => {
18379
18915
  try {
18380
18916
  return !!fn(...args);
@@ -18383,9 +18919,18 @@ const test = (fn, ...args) => {
18383
18919
  }
18384
18920
  };
18385
18921
  const factory = env => {
18922
+ var _utils$global;
18923
+ const globalObject = (_utils$global = utils$1$1.global) !== null && _utils$global !== void 0 ? _utils$global : globalThis;
18924
+ const {
18925
+ ReadableStream,
18926
+ TextEncoder
18927
+ } = globalObject;
18386
18928
  env = utils$1$1.merge.call({
18387
18929
  skipUndefined: true
18388
- }, globalFetchAPI, env);
18930
+ }, {
18931
+ Request: globalObject.Request,
18932
+ Response: globalObject.Response
18933
+ }, env);
18389
18934
  const {
18390
18935
  fetch: envFetch,
18391
18936
  Request,
@@ -18397,18 +18942,22 @@ const factory = env => {
18397
18942
  if (!isFetchSupported) {
18398
18943
  return false;
18399
18944
  }
18400
- const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
18401
- const encodeText = isFetchSupported && (typeof TextEncoder$1 === 'function' ? (encoder => str => encoder.encode(str))(new TextEncoder$1()) : async str => new Uint8Array(await new Request(str).arrayBuffer()));
18945
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
18946
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? (encoder => str => encoder.encode(str))(new TextEncoder()) : async str => new Uint8Array(await new Request(str).arrayBuffer()));
18402
18947
  const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
18403
18948
  let duplexAccessed = false;
18404
- const hasContentType = new Request(platform.origin, {
18405
- body: new ReadableStream$1(),
18949
+ const request = new Request(platform.origin, {
18950
+ body: new ReadableStream(),
18406
18951
  method: 'POST',
18407
18952
  get duplex() {
18408
18953
  duplexAccessed = true;
18409
18954
  return 'half';
18410
18955
  }
18411
- }).headers.has('Content-Type');
18956
+ });
18957
+ const hasContentType = request.headers.has('Content-Type');
18958
+ if (request.body != null) {
18959
+ request.body.cancel();
18960
+ }
18412
18961
  return duplexAccessed && !hasContentType;
18413
18962
  });
18414
18963
  const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1$1.isReadableStream(new Response('').body));
@@ -18422,7 +18971,7 @@ const factory = env => {
18422
18971
  if (method) {
18423
18972
  return method.call(res);
18424
18973
  }
18425
- throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
18974
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
18426
18975
  });
18427
18976
  });
18428
18977
  })();
@@ -18467,17 +19016,41 @@ const factory = env => {
18467
19016
  responseType,
18468
19017
  headers,
18469
19018
  withCredentials = 'same-origin',
18470
- fetchOptions
19019
+ fetchOptions,
19020
+ maxContentLength,
19021
+ maxBodyLength
18471
19022
  } = resolveConfig(config);
19023
+ const hasMaxContentLength = utils$1$1.isNumber(maxContentLength) && maxContentLength > -1;
19024
+ const hasMaxBodyLength = utils$1$1.isNumber(maxBodyLength) && maxBodyLength > -1;
18472
19025
  let _fetch = envFetch || fetch;
18473
19026
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
18474
- let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
19027
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
18475
19028
  let request = null;
18476
19029
  const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
18477
19030
  composedSignal.unsubscribe();
18478
19031
  });
18479
19032
  let requestContentLength;
18480
19033
  try {
19034
+ // Enforce maxContentLength for data: URLs up-front so we never materialize
19035
+ // an oversized payload. The HTTP adapter applies the same check (see http.js
19036
+ // "if (protocol === 'data:')" branch).
19037
+ if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
19038
+ const estimated = estimateDataURLDecodedBytes(url);
19039
+ if (estimated > maxContentLength) {
19040
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
19041
+ }
19042
+ }
19043
+
19044
+ // Enforce maxBodyLength against the outbound request body before dispatch.
19045
+ // Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
19046
+ // maxBodyLength limit'). Skip when the body length cannot be determined
19047
+ // (e.g. a live ReadableStream supplied by the caller).
19048
+ if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
19049
+ const outboundLength = await resolveBodyLength(headers, data);
19050
+ if (typeof outboundLength === 'number' && isFinite(outboundLength) && outboundLength > maxBodyLength) {
19051
+ throw new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
19052
+ }
19053
+ }
18481
19054
  if (onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
18482
19055
  let _request = new Request(url, {
18483
19056
  method: 'POST',
@@ -18500,6 +19073,18 @@ const factory = env => {
18500
19073
  // Cloudflare Workers throws when credentials are defined
18501
19074
  // see https://github.com/cloudflare/workerd/issues/902
18502
19075
  const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
19076
+
19077
+ // If data is FormData and Content-Type is multipart/form-data without boundary,
19078
+ // delete it so fetch can set it correctly with the boundary
19079
+ if (utils$1$1.isFormData(data)) {
19080
+ const contentType = headers.getContentType();
19081
+ if (contentType && /^multipart\/form-data/i.test(contentType) && !/boundary=/i.test(contentType)) {
19082
+ headers.delete('content-type');
19083
+ }
19084
+ }
19085
+
19086
+ // Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
19087
+ headers.set('User-Agent', 'axios/' + VERSION, false);
18503
19088
  const resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
18504
19089
  signal: composedSignal,
18505
19090
  method: method.toUpperCase(),
@@ -18510,26 +19095,64 @@ const factory = env => {
18510
19095
  });
18511
19096
  request = isRequestSupported && new Request(url, resolvedOptions);
18512
19097
  let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
19098
+
19099
+ // Cheap pre-check: if the server honestly declares a content-length that
19100
+ // already exceeds the cap, reject before we start streaming.
19101
+ if (hasMaxContentLength) {
19102
+ const declaredLength = utils$1$1.toFiniteNumber(response.headers.get('content-length'));
19103
+ if (declaredLength != null && declaredLength > maxContentLength) {
19104
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
19105
+ }
19106
+ }
18513
19107
  const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
18514
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
19108
+ if (supportsResponseStream && response.body && (onDownloadProgress || hasMaxContentLength || isStreamResponse && unsubscribe)) {
18515
19109
  const options = {};
18516
19110
  ['status', 'statusText', 'headers'].forEach(prop => {
18517
19111
  options[prop] = response[prop];
18518
19112
  });
18519
19113
  const responseContentLength = utils$1$1.toFiniteNumber(response.headers.get('content-length'));
18520
19114
  const [onProgress, flush] = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [];
18521
- response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
19115
+ let bytesRead = 0;
19116
+ const onChunkProgress = loadedBytes => {
19117
+ if (hasMaxContentLength) {
19118
+ bytesRead = loadedBytes;
19119
+ if (bytesRead > maxContentLength) {
19120
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
19121
+ }
19122
+ }
19123
+ onProgress && onProgress(loadedBytes);
19124
+ };
19125
+ response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
18522
19126
  flush && flush();
18523
19127
  unsubscribe && unsubscribe();
18524
19128
  }), options);
18525
19129
  }
18526
19130
  responseType = responseType || 'text';
18527
19131
  let responseData = await resolvers[utils$1$1.findKey(resolvers, responseType) || 'text'](response, config);
19132
+
19133
+ // Fallback enforcement for environments without ReadableStream support
19134
+ // (legacy runtimes). Detect materialized size from typed output; skip
19135
+ // streams/Response passthrough since the user will read those themselves.
19136
+ if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
19137
+ let materializedSize;
19138
+ if (responseData != null) {
19139
+ if (typeof responseData.byteLength === 'number') {
19140
+ materializedSize = responseData.byteLength;
19141
+ } else if (typeof responseData.size === 'number') {
19142
+ materializedSize = responseData.size;
19143
+ } else if (typeof responseData === 'string') {
19144
+ materializedSize = typeof TextEncoder === 'function' ? new TextEncoder().encode(responseData).byteLength : responseData.length;
19145
+ }
19146
+ }
19147
+ if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
19148
+ throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
19149
+ }
19150
+ }
18528
19151
  !isStreamResponse && unsubscribe && unsubscribe();
18529
19152
  return await new Promise((resolve, reject) => {
18530
19153
  settle(resolve, reject, {
18531
19154
  data: responseData,
18532
- headers: AxiosHeaders$1.from(response.headers),
19155
+ headers: AxiosHeaders.from(response.headers),
18533
19156
  status: response.status,
18534
19157
  statusText: response.statusText,
18535
19158
  config,
@@ -18538,12 +19161,23 @@ const factory = env => {
18538
19161
  });
18539
19162
  } catch (err) {
18540
19163
  unsubscribe && unsubscribe();
19164
+
19165
+ // Safari can surface fetch aborts as a DOMException-like object whose
19166
+ // branded getters throw. Prefer our composed signal reason before reading
19167
+ // the caught error, preserving timeout vs cancellation semantics.
19168
+ if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError) {
19169
+ const canceledError = composedSignal.reason;
19170
+ canceledError.config = config;
19171
+ request && (canceledError.request = request);
19172
+ err !== canceledError && (canceledError.cause = err);
19173
+ throw canceledError;
19174
+ }
18541
19175
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
18542
- throw Object.assign(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request, err && err.response), {
19176
+ throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response), {
18543
19177
  cause: err.cause || err
18544
19178
  });
18545
19179
  }
18546
- throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
19180
+ throw AxiosError.from(err, err && err.code, config, request, err && err.response);
18547
19181
  }
18548
19182
  };
18549
19183
  };
@@ -18592,13 +19226,17 @@ const knownAdapters = {
18592
19226
  utils$1$1.forEach(knownAdapters, (fn, value) => {
18593
19227
  if (fn) {
18594
19228
  try {
19229
+ // Null-proto descriptors so a polluted Object.prototype.get cannot turn
19230
+ // these data descriptors into accessor descriptors on the way in.
18595
19231
  Object.defineProperty(fn, 'name', {
19232
+ __proto__: null,
18596
19233
  value
18597
19234
  });
18598
19235
  } catch (e) {
18599
19236
  // eslint-disable-next-line no-empty
18600
19237
  }
18601
19238
  Object.defineProperty(fn, 'adapterName', {
19239
+ __proto__: null,
18602
19240
  value
18603
19241
  });
18604
19242
  }
@@ -18645,7 +19283,7 @@ function getAdapter(adapters, config) {
18645
19283
  if (!isResolvedHandle(nameOrAdapter)) {
18646
19284
  adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
18647
19285
  if (adapter === undefined) {
18648
- throw new AxiosError$1(`Unknown adapter '${id}'`);
19286
+ throw new AxiosError(`Unknown adapter '${id}'`);
18649
19287
  }
18650
19288
  }
18651
19289
  if (adapter && (utils$1$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
@@ -18656,7 +19294,7 @@ function getAdapter(adapters, config) {
18656
19294
  if (!adapter) {
18657
19295
  const reasons = Object.entries(rejectedReasons).map(([id, state]) => `adapter ${id} ` + (state === false ? 'is not supported by the environment' : 'is not available in the build'));
18658
19296
  let s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
18659
- throw new AxiosError$1(`There is no suitable adapter to dispatch the request ` + s, 'ERR_NOT_SUPPORT');
19297
+ throw new AxiosError(`There is no suitable adapter to dispatch the request ` + s, 'ERR_NOT_SUPPORT');
18660
19298
  }
18661
19299
  return adapter;
18662
19300
  }
@@ -18664,7 +19302,7 @@ function getAdapter(adapters, config) {
18664
19302
  /**
18665
19303
  * Exports Axios adapters and utility to resolve an adapter
18666
19304
  */
18667
- const adapters = {
19305
+ var adapters = {
18668
19306
  /**
18669
19307
  * Resolve an adapter from a list of adapter names or functions.
18670
19308
  * @type {Function}
@@ -18689,7 +19327,7 @@ function throwIfCancellationRequested(config) {
18689
19327
  config.cancelToken.throwIfRequested();
18690
19328
  }
18691
19329
  if (config.signal && config.signal.aborted) {
18692
- throw new CanceledError$1(null, config);
19330
+ throw new CanceledError(null, config);
18693
19331
  }
18694
19332
  }
18695
19333
 
@@ -18702,20 +19340,27 @@ function throwIfCancellationRequested(config) {
18702
19340
  */
18703
19341
  function dispatchRequest(config) {
18704
19342
  throwIfCancellationRequested(config);
18705
- config.headers = AxiosHeaders$1.from(config.headers);
19343
+ config.headers = AxiosHeaders.from(config.headers);
18706
19344
 
18707
19345
  // Transform request data
18708
19346
  config.data = transformData.call(config, config.transformRequest);
18709
19347
  if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
18710
19348
  config.headers.setContentType('application/x-www-form-urlencoded', false);
18711
19349
  }
18712
- const adapter = adapters.getAdapter(config.adapter || defaults$1$1.adapter, config);
19350
+ const adapter = adapters.getAdapter(config.adapter || defaults$2.adapter, config);
18713
19351
  return adapter(config).then(function onAdapterResolution(response) {
18714
19352
  throwIfCancellationRequested(config);
18715
19353
 
18716
- // Transform response data
18717
- response.data = transformData.call(config, config.transformResponse, response);
18718
- response.headers = AxiosHeaders$1.from(response.headers);
19354
+ // Expose the current response on config so that transformResponse can
19355
+ // attach it to any AxiosError it throws (e.g. on JSON parse failure).
19356
+ // We clean it up afterwards to avoid polluting the config object.
19357
+ config.response = response;
19358
+ try {
19359
+ response.data = transformData.call(config, config.transformResponse, response);
19360
+ } finally {
19361
+ delete config.response;
19362
+ }
19363
+ response.headers = AxiosHeaders.from(response.headers);
18719
19364
  return response;
18720
19365
  }, function onAdapterRejection(reason) {
18721
19366
  if (!isCancel(reason)) {
@@ -18723,8 +19368,13 @@ function dispatchRequest(config) {
18723
19368
 
18724
19369
  // Transform response data
18725
19370
  if (reason && reason.response) {
18726
- reason.response.data = transformData.call(config, config.transformResponse, reason.response);
18727
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
19371
+ config.response = reason.response;
19372
+ try {
19373
+ reason.response.data = transformData.call(config, config.transformResponse, reason.response);
19374
+ } finally {
19375
+ delete config.response;
19376
+ }
19377
+ reason.response.headers = AxiosHeaders.from(reason.response.headers);
18728
19378
  }
18729
19379
  }
18730
19380
  return Promise.reject(reason);
@@ -18757,7 +19407,7 @@ validators$1.transitional = function transitional(validator, version, message) {
18757
19407
  // eslint-disable-next-line func-names
18758
19408
  return (value, opt, opts) => {
18759
19409
  if (validator === false) {
18760
- throw new AxiosError$1(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError$1.ERR_DEPRECATED);
19410
+ throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
18761
19411
  }
18762
19412
  if (version && !deprecatedWarnings[opt]) {
18763
19413
  deprecatedWarnings[opt] = true;
@@ -18787,27 +19437,29 @@ validators$1.spelling = function spelling(correctSpelling) {
18787
19437
 
18788
19438
  function assertOptions(options, schema, allowUnknown) {
18789
19439
  if (typeof options !== 'object') {
18790
- throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
19440
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
18791
19441
  }
18792
19442
  const keys = Object.keys(options);
18793
19443
  let i = keys.length;
18794
19444
  while (i-- > 0) {
18795
19445
  const opt = keys[i];
18796
- const validator = schema[opt];
19446
+ // Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
19447
+ // a non-function validator and cause a TypeError.
19448
+ const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
18797
19449
  if (validator) {
18798
19450
  const value = options[opt];
18799
19451
  const result = value === undefined || validator(value, opt, options);
18800
19452
  if (result !== true) {
18801
- throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
19453
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
18802
19454
  }
18803
19455
  continue;
18804
19456
  }
18805
19457
  if (allowUnknown !== true) {
18806
- throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
19458
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
18807
19459
  }
18808
19460
  }
18809
19461
  }
18810
- const validator = {
19462
+ var validator = {
18811
19463
  assertOptions,
18812
19464
  validators: validators$1
18813
19465
  };
@@ -18824,8 +19476,8 @@ class Axios {
18824
19476
  constructor(instanceConfig) {
18825
19477
  this.defaults = instanceConfig || {};
18826
19478
  this.interceptors = {
18827
- request: new InterceptorManager$1(),
18828
- response: new InterceptorManager$1()
19479
+ request: new InterceptorManager(),
19480
+ response: new InterceptorManager()
18829
19481
  };
18830
19482
  }
18831
19483
 
@@ -18846,13 +19498,24 @@ class Axios {
18846
19498
  Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
18847
19499
 
18848
19500
  // slice off the Error: ... line
18849
- const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
19501
+ const stack = (() => {
19502
+ if (!dummy.stack) {
19503
+ return '';
19504
+ }
19505
+ const firstNewlineIndex = dummy.stack.indexOf('\n');
19506
+ return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
19507
+ })();
18850
19508
  try {
18851
19509
  if (!err.stack) {
18852
19510
  err.stack = stack;
18853
19511
  // match without the 2 top stack lines
18854
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
18855
- err.stack += '\n' + stack;
19512
+ } else if (stack) {
19513
+ const firstNewlineIndex = stack.indexOf('\n');
19514
+ const secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
19515
+ const stackWithoutTwoTopLines = secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
19516
+ if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
19517
+ err.stack += '\n' + stack;
19518
+ }
18856
19519
  }
18857
19520
  } catch (e) {
18858
19521
  // ignore the case where "stack" is an un-writable property
@@ -18913,10 +19576,10 @@ class Axios {
18913
19576
 
18914
19577
  // Flatten headers
18915
19578
  let contextHeaders = headers && utils$1$1.merge(headers.common, headers[config.method]);
18916
- headers && utils$1$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], method => {
19579
+ headers && utils$1$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], method => {
18917
19580
  delete headers[method];
18918
19581
  });
18919
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
19582
+ config.headers = AxiosHeaders.concat(contextHeaders, headers);
18920
19583
 
18921
19584
  // filter out skipped interceptors
18922
19585
  const requestInterceptorChain = [];
@@ -18994,9 +19657,7 @@ utils$1$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNo
18994
19657
  }));
18995
19658
  };
18996
19659
  });
18997
- utils$1$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
18998
- /*eslint func-names:0*/
18999
-
19660
+ utils$1$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
19000
19661
  function generateHTTPMethod(isForm) {
19001
19662
  return function httpMethod(url, data, config) {
19002
19663
  return this.request(mergeConfig(config || {}, {
@@ -19010,9 +19671,13 @@ utils$1$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(metho
19010
19671
  };
19011
19672
  }
19012
19673
  Axios.prototype[method] = generateHTTPMethod();
19013
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
19674
+
19675
+ // QUERY is a safe/idempotent read method; multipart form bodies don't fit
19676
+ // its semantics, so no queryForm shorthand is generated.
19677
+ if (method !== 'query') {
19678
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
19679
+ }
19014
19680
  });
19015
- const Axios$1 = Axios;
19016
19681
 
19017
19682
  /**
19018
19683
  * A `CancelToken` is an object that can be used to request cancellation of an operation.
@@ -19060,7 +19725,7 @@ class CancelToken {
19060
19725
  // Cancellation has already been requested
19061
19726
  return;
19062
19727
  }
19063
- token.reason = new CanceledError$1(message, config, request);
19728
+ token.reason = new CanceledError(message, config, request);
19064
19729
  resolvePromise(token.reason);
19065
19730
  });
19066
19731
  }
@@ -19128,7 +19793,6 @@ class CancelToken {
19128
19793
  };
19129
19794
  }
19130
19795
  }
19131
- const CancelToken$1 = CancelToken;
19132
19796
 
19133
19797
  /**
19134
19798
  * Syntactic sugar for invoking a function and expanding an array for arguments.
@@ -19241,7 +19905,6 @@ const HttpStatusCode = {
19241
19905
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
19242
19906
  HttpStatusCode[value] = key;
19243
19907
  });
19244
- const HttpStatusCode$1 = HttpStatusCode;
19245
19908
 
19246
19909
  /**
19247
19910
  * Create an instance of Axios
@@ -19251,11 +19914,11 @@ const HttpStatusCode$1 = HttpStatusCode;
19251
19914
  * @returns {Axios} A new instance of Axios
19252
19915
  */
19253
19916
  function createInstance(defaultConfig) {
19254
- const context = new Axios$1(defaultConfig);
19255
- const instance = bind(Axios$1.prototype.request, context);
19917
+ const context = new Axios(defaultConfig);
19918
+ const instance = bind(Axios.prototype.request, context);
19256
19919
 
19257
19920
  // Copy axios.prototype to instance
19258
- utils$1$1.extend(instance, Axios$1.prototype, context, {
19921
+ utils$1$1.extend(instance, Axios.prototype, context, {
19259
19922
  allOwnKeys: true
19260
19923
  });
19261
19924
 
@@ -19272,20 +19935,20 @@ function createInstance(defaultConfig) {
19272
19935
  }
19273
19936
 
19274
19937
  // Create the default instance to be exported
19275
- const axios = createInstance(defaults$1$1);
19938
+ const axios = createInstance(defaults$2);
19276
19939
 
19277
19940
  // Expose Axios class to allow class inheritance
19278
- axios.Axios = Axios$1;
19941
+ axios.Axios = Axios;
19279
19942
 
19280
19943
  // Expose Cancel & CancelToken
19281
- axios.CanceledError = CanceledError$1;
19282
- axios.CancelToken = CancelToken$1;
19944
+ axios.CanceledError = CanceledError;
19945
+ axios.CancelToken = CancelToken;
19283
19946
  axios.isCancel = isCancel;
19284
19947
  axios.VERSION = VERSION;
19285
19948
  axios.toFormData = toFormData;
19286
19949
 
19287
19950
  // Expose AxiosError class
19288
- axios.AxiosError = AxiosError$1;
19951
+ axios.AxiosError = AxiosError;
19289
19952
 
19290
19953
  // alias for CanceledError for backward compatibility
19291
19954
  axios.Cancel = axios.CanceledError;
@@ -19301,10 +19964,10 @@ axios.isAxiosError = isAxiosError;
19301
19964
 
19302
19965
  // Expose mergeConfig
19303
19966
  axios.mergeConfig = mergeConfig;
19304
- axios.AxiosHeaders = AxiosHeaders$1;
19967
+ axios.AxiosHeaders = AxiosHeaders;
19305
19968
  axios.formToJSON = thing => formDataToJSON(utils$1$1.isHTMLForm(thing) ? new FormData(thing) : thing);
19306
19969
  axios.getAdapter = adapters.getAdapter;
19307
- axios.HttpStatusCode = HttpStatusCode$1;
19970
+ axios.HttpStatusCode = HttpStatusCode;
19308
19971
  axios.default = axios;
19309
19972
  var axios_1 = axios;
19310
19973
  var axios$1 = /*@__PURE__*/getDefaultExportFromCjs(axios_1);
@@ -22906,7 +23569,7 @@ var resolveResponse = function resolveResponse(response, options) {
22906
23569
  }
22907
23570
  var responseClone = index(response);
22908
23571
  var allIncludes = Object.keys(responseClone.includes || {}).reduce(function (all, type) {
22909
- return [].concat(_toConsumableArray(all), _toConsumableArray(response.includes[type]));
23572
+ return [].concat(_toConsumableArray(all), _toConsumableArray(responseClone.includes[type]));
22910
23573
  }, []);
22911
23574
  var allEntries = [].concat(_toConsumableArray(responseClone.items), _toConsumableArray(allIncludes)).filter(function (entity) {
22912
23575
  return Boolean(entity.sys);