@zuplo/cli 6.70.71 → 6.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/node_modules/@zuplo/core/package.json +1 -1
  2. package/node_modules/@zuplo/graphql/package.json +1 -1
  3. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  4. package/node_modules/@zuplo/otel/package.json +1 -1
  5. package/node_modules/@zuplo/runtime/package.json +1 -1
  6. package/node_modules/axios/CHANGELOG.md +52 -1
  7. package/node_modules/axios/README.md +30 -2
  8. package/node_modules/axios/dist/axios.js +350 -134
  9. package/node_modules/axios/dist/axios.min.js +3 -3
  10. package/node_modules/axios/dist/axios.min.js.map +1 -1
  11. package/node_modules/axios/dist/browser/axios.cjs +355 -90
  12. package/node_modules/axios/dist/esm/axios.js +355 -90
  13. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  14. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  15. package/node_modules/axios/dist/node/axios.cjs +399 -104
  16. package/node_modules/axios/index.d.cts +2 -0
  17. package/node_modules/axios/index.d.ts +2 -0
  18. package/node_modules/axios/lib/adapters/fetch.js +113 -37
  19. package/node_modules/axios/lib/adapters/http.js +132 -43
  20. package/node_modules/axios/lib/core/Axios.js +3 -2
  21. package/node_modules/axios/lib/core/AxiosHeaders.js +10 -7
  22. package/node_modules/axios/lib/core/buildFullPath.js +29 -1
  23. package/node_modules/axios/lib/core/mergeConfig.js +34 -0
  24. package/node_modules/axios/lib/defaults/transitional.js +1 -0
  25. package/node_modules/axios/lib/env/data.js +1 -1
  26. package/node_modules/axios/lib/helpers/buildURL.js +5 -3
  27. package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +16 -11
  28. package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -3
  29. package/node_modules/axios/lib/helpers/resolveConfig.js +5 -3
  30. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +33 -1
  31. package/node_modules/axios/lib/helpers/toFormData.js +40 -10
  32. package/node_modules/axios/lib/utils.js +75 -11
  33. package/node_modules/axios/package.json +1 -1
  34. package/node_modules/form-data/CHANGELOG.md +29 -2
  35. package/node_modules/form-data/README.md +4 -4
  36. package/node_modules/form-data/lib/form_data.js +14 -2
  37. package/node_modules/form-data/package.json +7 -7
  38. package/package.json +6 -6
@@ -1,4 +1,4 @@
1
- /*! Axios v1.17.0 Copyright (c) 2026 Matt Zabriskie and contributors */
1
+ /*! Axios v1.18.0 Copyright (c) 2026 Matt Zabriskie and contributors */
2
2
  'use strict';
3
3
 
4
4
  /**
@@ -20,6 +20,57 @@ const { toString } = Object.prototype;
20
20
  const { getPrototypeOf } = Object;
21
21
  const { iterator, toStringTag } = Symbol;
22
22
 
23
+ /* Creating a function that will check if an object has a property. */
24
+ const hasOwnProperty = (
25
+ ({ hasOwnProperty }) =>
26
+ (obj, prop) =>
27
+ hasOwnProperty.call(obj, prop)
28
+ )(Object.prototype);
29
+
30
+ /**
31
+ * Walk the prototype chain (excluding the shared Object.prototype) looking for
32
+ * an own `prop`. This distinguishes genuine own/inherited members — including
33
+ * class accessors and template prototypes — from members injected via
34
+ * Object.prototype pollution (e.g. `Object.prototype.username = '...'`), which
35
+ * live on Object.prototype itself and are therefore never matched.
36
+ *
37
+ * @param {*} thing The value whose chain to inspect
38
+ * @param {string|symbol} prop The property key to look for
39
+ *
40
+ * @returns {boolean} True when `prop` is owned below Object.prototype
41
+ */
42
+ const hasOwnInPrototypeChain = (thing, prop) => {
43
+ let obj = thing;
44
+ const seen = [];
45
+
46
+ while (obj != null && obj !== Object.prototype) {
47
+ if (seen.indexOf(obj) !== -1) {
48
+ return false;
49
+ }
50
+ seen.push(obj);
51
+
52
+ if (hasOwnProperty(obj, prop)) {
53
+ return true;
54
+ }
55
+ obj = getPrototypeOf(obj);
56
+ }
57
+ return false;
58
+ };
59
+
60
+ /**
61
+ * Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
62
+ * properties and members inherited from a non-Object.prototype source (a class
63
+ * instance or template object) are honored; a value reachable only through a
64
+ * polluted Object.prototype is ignored and `undefined` is returned.
65
+ *
66
+ * @param {*} obj The source object
67
+ * @param {string|symbol} prop The property key to read
68
+ *
69
+ * @returns {*} The resolved value, or undefined when unsafe/absent
70
+ */
71
+ const getSafeProp = (obj, prop) =>
72
+ obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
73
+
23
74
  const kindOf = ((cache) => (thing) => {
24
75
  const str = toString.call(thing);
25
76
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -145,7 +196,7 @@ const isBoolean = (thing) => thing === true || thing === false;
145
196
  * @returns {boolean} True if value is a plain Object, otherwise false
146
197
  */
147
198
  const isPlainObject = (val) => {
148
- if (kindOf(val) !== 'object') {
199
+ if (!isObject(val)) {
149
200
  return false;
150
201
  }
151
202
 
@@ -153,9 +204,12 @@ const isPlainObject = (val) => {
153
204
  return (
154
205
  (prototype === null ||
155
206
  prototype === Object.prototype ||
156
- Object.getPrototypeOf(prototype) === null) &&
157
- !(toStringTag in val) &&
158
- !(iterator in val)
207
+ getPrototypeOf(prototype) === null) &&
208
+ // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
209
+ // Symbol.iterator as evidence the value is a tagged/iterable type rather
210
+ // than a plain object, while ignoring keys injected onto Object.prototype.
211
+ !hasOwnInPrototypeChain(val, toStringTag) &&
212
+ !hasOwnInPrototypeChain(val, iterator)
159
213
  );
160
214
  };
161
215
 
@@ -682,13 +736,6 @@ const toCamelCase = (str) => {
682
736
  });
683
737
  };
684
738
 
685
- /* Creating a function that will check if an object has a property. */
686
- const hasOwnProperty = (
687
- ({ hasOwnProperty }) =>
688
- (obj, prop) =>
689
- hasOwnProperty.call(obj, prop)
690
- )(Object.prototype);
691
-
692
739
  const { propertyIsEnumerable } = Object.prototype;
693
740
 
694
741
  /**
@@ -902,6 +949,20 @@ const asap =
902
949
 
903
950
  const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
904
951
 
952
+ /**
953
+ * Determine if a value is iterable via an iterator that is NOT sourced solely
954
+ * from a polluted Object.prototype. Use this instead of `isIterable` whenever
955
+ * the iterable comes from untrusted input (e.g. user-supplied header sources),
956
+ * so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
957
+ * into an attacker-controlled entries iterator.
958
+ *
959
+ * @param {*} thing The value to test
960
+ *
961
+ * @returns {boolean} True if value has a non-polluted iterator
962
+ */
963
+ const isSafeIterable = (thing) =>
964
+ thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
965
+
905
966
  var utils$1 = {
906
967
  isArray,
907
968
  isArrayBuffer,
@@ -946,6 +1007,8 @@ var utils$1 = {
946
1007
  isHTMLForm,
947
1008
  hasOwnProperty,
948
1009
  hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
1010
+ hasOwnInPrototypeChain,
1011
+ getSafeProp,
949
1012
  reduceDescriptors,
950
1013
  freezeMethods,
951
1014
  toObjectSet,
@@ -962,6 +1025,7 @@ var utils$1 = {
962
1025
  setImmediate: _setImmediate,
963
1026
  asap,
964
1027
  isIterable,
1028
+ isSafeIterable,
965
1029
  };
966
1030
 
967
1031
  // RawAxiosHeaders whose duplicates are ignored by node
@@ -1194,8 +1258,8 @@ class AxiosHeaders {
1194
1258
  setHeaders(header, valueOrRewrite);
1195
1259
  } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1196
1260
  setHeaders(parseHeaders(header), valueOrRewrite);
1197
- } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1198
- let obj = {},
1261
+ } else if (utils$1.isObject(header) && utils$1.isSafeIterable(header)) {
1262
+ let obj = Object.create(null),
1199
1263
  dest,
1200
1264
  key;
1201
1265
  for (const entry of header) {
@@ -1203,11 +1267,14 @@ class AxiosHeaders {
1203
1267
  throw new TypeError('Object iterator must return a key-value pair');
1204
1268
  }
1205
1269
 
1206
- obj[(key = entry[0])] = (dest = obj[key])
1207
- ? utils$1.isArray(dest)
1208
- ? [...dest, entry[1]]
1209
- : [dest, entry[1]]
1210
- : entry[1];
1270
+ key = entry[0];
1271
+
1272
+ if (utils$1.hasOwnProp(obj, key)) {
1273
+ dest = obj[key];
1274
+ obj[key] = utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]];
1275
+ } else {
1276
+ obj[key] = entry[1];
1277
+ }
1211
1278
  }
1212
1279
 
1213
1280
  setHeaders(obj, valueOrRewrite);
@@ -1601,6 +1668,10 @@ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
1601
1668
  // eslint-disable-next-line strict
1602
1669
  var httpAdapter = null;
1603
1670
 
1671
+ // Default nesting limit shared with the inverse transform (formDataToJSON) so
1672
+ // the FormData <-> JSON round-trip stays symmetric.
1673
+ const DEFAULT_FORM_DATA_MAX_DEPTH = 100;
1674
+
1604
1675
  /**
1605
1676
  * Determines if the given thing is a array or js object.
1606
1677
  *
@@ -1711,8 +1782,9 @@ function toFormData(obj, formData, options) {
1711
1782
  const dots = options.dots;
1712
1783
  const indexes = options.indexes;
1713
1784
  const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
1714
- const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
1785
+ const maxDepth = options.maxDepth === undefined ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
1715
1786
  const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1787
+ const stack = [];
1716
1788
 
1717
1789
  if (!utils$1.isFunction(visitor)) {
1718
1790
  throw new TypeError('visitor must be a function');
@@ -1740,6 +1812,38 @@ function toFormData(obj, formData, options) {
1740
1812
  return value;
1741
1813
  }
1742
1814
 
1815
+ function throwIfMaxDepthExceeded(depth) {
1816
+ if (depth > maxDepth) {
1817
+ throw new AxiosError(
1818
+ 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
1819
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
1820
+ );
1821
+ }
1822
+ }
1823
+
1824
+ function stringifyWithDepthLimit(value, depth) {
1825
+ if (maxDepth === Infinity) {
1826
+ return JSON.stringify(value);
1827
+ }
1828
+
1829
+ const ancestors = [];
1830
+
1831
+ return JSON.stringify(value, function limitDepth(_key, currentValue) {
1832
+ if (!utils$1.isObject(currentValue)) {
1833
+ return currentValue;
1834
+ }
1835
+
1836
+ while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
1837
+ ancestors.pop();
1838
+ }
1839
+
1840
+ ancestors.push(currentValue);
1841
+ throwIfMaxDepthExceeded(depth + ancestors.length - 1);
1842
+
1843
+ return currentValue;
1844
+ });
1845
+ }
1846
+
1743
1847
  /**
1744
1848
  * Default visitor.
1745
1849
  *
@@ -1763,7 +1867,7 @@ function toFormData(obj, formData, options) {
1763
1867
  // eslint-disable-next-line no-param-reassign
1764
1868
  key = metaTokens ? key : key.slice(0, -2);
1765
1869
  // eslint-disable-next-line no-param-reassign
1766
- value = JSON.stringify(value);
1870
+ value = stringifyWithDepthLimit(value, 1);
1767
1871
  } else if (
1768
1872
  (utils$1.isArray(value) && isFlatArray(value)) ||
1769
1873
  ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
@@ -1796,8 +1900,6 @@ function toFormData(obj, formData, options) {
1796
1900
  return false;
1797
1901
  }
1798
1902
 
1799
- const stack = [];
1800
-
1801
1903
  const exposedHelpers = Object.assign(predicates, {
1802
1904
  defaultVisitor,
1803
1905
  convertValue,
@@ -1807,12 +1909,7 @@ function toFormData(obj, formData, options) {
1807
1909
  function build(value, path, depth = 0) {
1808
1910
  if (utils$1.isUndefined(value)) return;
1809
1911
 
1810
- if (depth > maxDepth) {
1811
- throw new AxiosError(
1812
- 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
1813
- AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
1814
- );
1815
- }
1912
+ throwIfMaxDepthExceeded(depth);
1816
1913
 
1817
1914
  if (stack.indexOf(value) !== -1) {
1818
1915
  throw new Error('Circular reference detected in ' + path.join('.'));
@@ -1928,15 +2025,17 @@ function buildURL(url, params, options) {
1928
2025
  return url;
1929
2026
  }
1930
2027
 
1931
- const _encode = (options && options.encode) || encode;
1932
-
1933
2028
  const _options = utils$1.isFunction(options)
1934
2029
  ? {
1935
2030
  serialize: options,
1936
2031
  }
1937
2032
  : options;
1938
2033
 
1939
- const serializeFn = _options && _options.serialize;
2034
+ // Read serializer options pollution-safely: own properties and methods on a
2035
+ // class/template prototype are honored, but values injected onto a polluted
2036
+ // Object.prototype are ignored.
2037
+ const _encode = utils$1.getSafeProp(_options, 'encode') || encode;
2038
+ const serializeFn = utils$1.getSafeProp(_options, 'serialize');
1940
2039
 
1941
2040
  let serializedParams;
1942
2041
 
@@ -2033,6 +2132,7 @@ var transitionalDefaults = {
2033
2132
  clarifyTimeoutError: false,
2034
2133
  legacyInterceptorReqResOrdering: true,
2035
2134
  advertiseZstdAcceptEncoding: false,
2135
+ validateStatusUndefinedResolves: true,
2036
2136
  };
2037
2137
 
2038
2138
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -2124,6 +2224,17 @@ function toURLEncodedForm(data, options) {
2124
2224
  });
2125
2225
  }
2126
2226
 
2227
+ const MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
2228
+
2229
+ function throwIfDepthExceeded(index) {
2230
+ if (index > MAX_DEPTH) {
2231
+ throw new AxiosError(
2232
+ 'FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH,
2233
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
2234
+ );
2235
+ }
2236
+ }
2237
+
2127
2238
  /**
2128
2239
  * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
2129
2240
  *
@@ -2136,9 +2247,16 @@ function parsePropPath(name) {
2136
2247
  // foo.x.y.z
2137
2248
  // foo-x-y-z
2138
2249
  // foo x y z
2139
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
2140
- return match[0] === '[]' ? '' : match[1] || match[0];
2141
- });
2250
+ const path = [];
2251
+ const pattern = /\w+|\[(\w*)]/g;
2252
+ let match;
2253
+
2254
+ while ((match = pattern.exec(name)) !== null) {
2255
+ throwIfDepthExceeded(path.length);
2256
+ path.push(match[0] === '[]' ? '' : match[1] || match[0]);
2257
+ }
2258
+
2259
+ return path;
2142
2260
  }
2143
2261
 
2144
2262
  /**
@@ -2170,6 +2288,8 @@ function arrayToObject(arr) {
2170
2288
  */
2171
2289
  function formDataToJSON(formData) {
2172
2290
  function buildPath(path, value, target, index) {
2291
+ throwIfDepthExceeded(index);
2292
+
2173
2293
  let name = path[index++];
2174
2294
 
2175
2295
  if (name === '__proto__') return true;
@@ -2706,6 +2826,31 @@ function combineURLs(baseURL, relativeURL) {
2706
2826
  : baseURL;
2707
2827
  }
2708
2828
 
2829
+ const malformedHttpProtocol = /^https?:(?!\/\/)/i;
2830
+ const httpProtocolControlCharacters = /[\t\n\r]/g;
2831
+
2832
+ function stripLeadingC0ControlOrSpace(url) {
2833
+ let i = 0;
2834
+ while (i < url.length && url.charCodeAt(i) <= 0x20) {
2835
+ i++;
2836
+ }
2837
+ return url.slice(i);
2838
+ }
2839
+
2840
+ function normalizeURLForProtocolCheck(url) {
2841
+ return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
2842
+ }
2843
+
2844
+ function assertValidHttpProtocolURL(url, config) {
2845
+ if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
2846
+ throw new AxiosError(
2847
+ 'Invalid URL: missing "//" after protocol',
2848
+ AxiosError.ERR_INVALID_URL,
2849
+ config
2850
+ );
2851
+ }
2852
+ }
2853
+
2709
2854
  /**
2710
2855
  * Creates a new URL by combining the baseURL with the requestedURL,
2711
2856
  * only when the requestedURL is not already an absolute URL.
@@ -2716,9 +2861,11 @@ function combineURLs(baseURL, relativeURL) {
2716
2861
  *
2717
2862
  * @returns {string} The combined full path
2718
2863
  */
2719
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2864
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
2865
+ assertValidHttpProtocolURL(requestedURL, config);
2720
2866
  let isRelativeUrl = !isAbsoluteURL(requestedURL);
2721
2867
  if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
2868
+ assertValidHttpProtocolURL(baseURL, config);
2722
2869
  return combineURLs(baseURL, requestedURL);
2723
2870
  }
2724
2871
  return requestedURL;
@@ -2789,6 +2936,28 @@ function mergeConfig(config1, config2) {
2789
2936
  }
2790
2937
  }
2791
2938
 
2939
+ function getMergedTransitionalOption(prop) {
2940
+ const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
2941
+
2942
+ if (!utils$1.isUndefined(transitional2)) {
2943
+ if (utils$1.isPlainObject(transitional2)) {
2944
+ if (utils$1.hasOwnProp(transitional2, prop)) {
2945
+ return transitional2[prop];
2946
+ }
2947
+ } else {
2948
+ return undefined;
2949
+ }
2950
+ }
2951
+
2952
+ const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
2953
+
2954
+ if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
2955
+ return transitional1[prop];
2956
+ }
2957
+
2958
+ return undefined;
2959
+ }
2960
+
2792
2961
  // eslint-disable-next-line consistent-return
2793
2962
  function mergeDirectKeys(a, b, prop) {
2794
2963
  if (utils$1.hasOwnProp(config2, prop)) {
@@ -2841,6 +3010,18 @@ function mergeConfig(config1, config2) {
2841
3010
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2842
3011
  });
2843
3012
 
3013
+ if (
3014
+ utils$1.hasOwnProp(config2, 'validateStatus') &&
3015
+ utils$1.isUndefined(config2.validateStatus) &&
3016
+ getMergedTransitionalOption('validateStatusUndefinedResolves') === false
3017
+ ) {
3018
+ if (utils$1.hasOwnProp(config1, 'validateStatus')) {
3019
+ config.validateStatus = getMergedValue(undefined, config1.validateStatus);
3020
+ } else {
3021
+ delete config.validateStatus;
3022
+ }
3023
+ }
3024
+
2844
3025
  return config;
2845
3026
  }
2846
3027
 
@@ -2892,17 +3073,19 @@ function resolveConfig(config) {
2892
3073
  newConfig.headers = headers = AxiosHeaders.from(headers);
2893
3074
 
2894
3075
  newConfig.url = buildURL(
2895
- buildFullPath(baseURL, url, allowAbsoluteUrls),
3076
+ buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig),
2896
3077
  own('params'),
2897
3078
  own('paramsSerializer')
2898
3079
  );
2899
3080
 
2900
3081
  // HTTP basic authentication
2901
3082
  if (auth) {
3083
+ const username = utils$1.getSafeProp(auth, 'username') || '';
3084
+ const password = utils$1.getSafeProp(auth, 'password') || '';
3085
+
2902
3086
  headers.set(
2903
3087
  'Authorization',
2904
- 'Basic ' +
2905
- btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8$1(auth.password) : ''))
3088
+ 'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : ''))
2906
3089
  );
2907
3090
  }
2908
3091
 
@@ -3308,11 +3491,19 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3308
3491
  * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
3309
3492
  * - For base64: compute exact decoded size using length and padding;
3310
3493
  * handle %XX at the character-count level (no string allocation).
3311
- * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
3494
+ * - For non-base64: compute the exact percent-decoded UTF-8 byte length.
3312
3495
  *
3313
3496
  * @param {string} url
3314
3497
  * @returns {number}
3315
3498
  */
3499
+ const isHexDigit = (charCode) =>
3500
+ (charCode >= 48 && charCode <= 57) ||
3501
+ (charCode >= 65 && charCode <= 70) ||
3502
+ (charCode >= 97 && charCode <= 102);
3503
+
3504
+ const isPercentEncodedByte = (str, i, len) =>
3505
+ i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
3506
+
3316
3507
  function estimateDataURLDecodedBytes(url) {
3317
3508
  if (!url || typeof url !== 'string') return 0;
3318
3509
  if (!url.startsWith('data:')) return 0;
@@ -3332,9 +3523,7 @@ function estimateDataURLDecodedBytes(url) {
3332
3523
  if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
3333
3524
  const a = body.charCodeAt(i + 1);
3334
3525
  const b = body.charCodeAt(i + 2);
3335
- const isHex =
3336
- ((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
3337
- ((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
3526
+ const isHex = isHexDigit(a) && isHexDigit(b);
3338
3527
 
3339
3528
  if (isHex) {
3340
3529
  effectiveLen -= 2;
@@ -3375,18 +3564,17 @@ function estimateDataURLDecodedBytes(url) {
3375
3564
  return bytes > 0 ? bytes : 0;
3376
3565
  }
3377
3566
 
3378
- if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
3379
- return Buffer.byteLength(body, 'utf8');
3380
- }
3381
-
3382
3567
  // Compute UTF-8 byte length directly from UTF-16 code units without allocating
3383
3568
  // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
3384
- // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
3385
- // but 3 UTF-8 bytes).
3569
+ // Valid %XX triplets count as one decoded byte; this matches the bytes that
3570
+ // decodeURIComponent(body) would produce before Buffer re-encodes the string.
3386
3571
  let bytes = 0;
3387
3572
  for (let i = 0, len = body.length; i < len; i++) {
3388
3573
  const c = body.charCodeAt(i);
3389
- if (c < 0x80) {
3574
+ if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
3575
+ bytes += 1;
3576
+ i += 2;
3577
+ } else if (c < 0x80) {
3390
3578
  bytes += 1;
3391
3579
  } else if (c < 0x800) {
3392
3580
  bytes += 2;
@@ -3405,7 +3593,7 @@ function estimateDataURLDecodedBytes(url) {
3405
3593
  return bytes;
3406
3594
  }
3407
3595
 
3408
- const VERSION = "1.17.0";
3596
+ const VERSION = "1.18.0";
3409
3597
 
3410
3598
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
3411
3599
 
@@ -3626,14 +3814,28 @@ const factory = (env) => {
3626
3814
 
3627
3815
  let requestContentLength;
3628
3816
 
3817
+ // AxiosError we raise while the request body is being streamed. Captured
3818
+ // by identity so the catch block can surface it directly, regardless of
3819
+ // how the runtime wraps the resulting fetch rejection (undici exposes it
3820
+ // as `err.cause`; some browsers drop the original error entirely).
3821
+ let pendingBodyError = null;
3822
+
3823
+ const maxBodyLengthError = () =>
3824
+ new AxiosError(
3825
+ 'Request body larger than maxBodyLength limit',
3826
+ AxiosError.ERR_BAD_REQUEST,
3827
+ config,
3828
+ request
3829
+ );
3830
+
3629
3831
  try {
3630
3832
  // HTTP basic authentication
3631
3833
  let auth = undefined;
3632
3834
  const configAuth = own('auth');
3633
3835
 
3634
3836
  if (configAuth) {
3635
- const username = configAuth.username || '';
3636
- const password = configAuth.password || '';
3837
+ const username = utils$1.getSafeProp(configAuth, 'username') || '';
3838
+ const password = utils$1.getSafeProp(configAuth, 'password') || '';
3637
3839
  auth = {
3638
3840
  username,
3639
3841
  password
@@ -3682,53 +3884,96 @@ const factory = (env) => {
3682
3884
  }
3683
3885
  }
3684
3886
 
3685
- // Enforce maxBodyLength against the outbound request body before dispatch.
3686
- // Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
3687
- // maxBodyLength limit'). Skip when the body length cannot be determined
3688
- // (e.g. a live ReadableStream supplied by the caller).
3887
+ // Enforce maxBodyLength against known-size bodies before dispatch using
3888
+ // the body's *actual* size never a caller-declared Content-Length,
3889
+ // which could under-report to slip an oversized body past the check.
3890
+ // Unknown-size streams return undefined here and are counted per-chunk
3891
+ // below as fetch consumes them.
3689
3892
  if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
3690
- const outboundLength = await resolveBodyLength(headers, data);
3691
- if (
3692
- typeof outboundLength === 'number' &&
3693
- isFinite(outboundLength) &&
3694
- outboundLength > maxBodyLength
3695
- ) {
3696
- throw new AxiosError(
3697
- 'Request body larger than maxBodyLength limit',
3698
- AxiosError.ERR_BAD_REQUEST,
3699
- config,
3700
- request
3701
- );
3893
+ const outboundLength = await getBodyLength(data);
3894
+ if (typeof outboundLength === 'number' && isFinite(outboundLength)) {
3895
+ requestContentLength = outboundLength;
3896
+ if (outboundLength > maxBodyLength) {
3897
+ throw maxBodyLengthError();
3898
+ }
3702
3899
  }
3703
3900
  }
3704
3901
 
3902
+ // A streamed body under maxBodyLength must be counted as fetch consumes
3903
+ // it; its size is never trusted from a caller-declared Content-Length.
3904
+ const mustEnforceStreamBody =
3905
+ hasMaxBodyLength && (utils$1.isReadableStream(data) || utils$1.isStream(data));
3906
+
3907
+ const trackRequestStream = (stream, onProgress, flush) =>
3908
+ trackStream(
3909
+ stream,
3910
+ DEFAULT_CHUNK_SIZE,
3911
+ (loadedBytes) => {
3912
+ if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
3913
+ throw (pendingBodyError = maxBodyLengthError());
3914
+ }
3915
+ onProgress && onProgress(loadedBytes);
3916
+ },
3917
+ flush
3918
+ );
3919
+
3705
3920
  if (
3706
- onUploadProgress &&
3707
3921
  supportsRequestStream &&
3708
3922
  method !== 'get' &&
3709
3923
  method !== 'head' &&
3710
- (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3924
+ (onUploadProgress || mustEnforceStreamBody)
3711
3925
  ) {
3712
- let _request = new Request(url, {
3713
- method: 'POST',
3714
- body: data,
3715
- duplex: 'half',
3716
- });
3926
+ requestContentLength =
3927
+ requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
3928
+
3929
+ // A declared length of 0 is only trusted to skip the wrap when we are
3930
+ // not enforcing a stream limit (which must not rely on that header).
3931
+ if (requestContentLength !== 0 || mustEnforceStreamBody) {
3932
+ let _request = new Request(url, {
3933
+ method: 'POST',
3934
+ body: data,
3935
+ duplex: 'half',
3936
+ });
3717
3937
 
3718
- let contentTypeHeader;
3938
+ let contentTypeHeader;
3719
3939
 
3720
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3721
- headers.setContentType(contentTypeHeader);
3722
- }
3940
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3941
+ headers.setContentType(contentTypeHeader);
3942
+ }
3723
3943
 
3724
- if (_request.body) {
3725
- const [onProgress, flush] = progressEventDecorator(
3726
- requestContentLength,
3727
- progressEventReducer(asyncDecorator(onUploadProgress))
3728
- );
3944
+ if (_request.body) {
3945
+ const [onProgress, flush] =
3946
+ (onUploadProgress &&
3947
+ progressEventDecorator(
3948
+ requestContentLength,
3949
+ progressEventReducer(asyncDecorator(onUploadProgress))
3950
+ )) ||
3951
+ [];
3729
3952
 
3730
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3953
+ data = trackRequestStream(_request.body, onProgress, flush);
3954
+ }
3731
3955
  }
3956
+ } else if (
3957
+ mustEnforceStreamBody &&
3958
+ !isRequestSupported &&
3959
+ isReadableStreamSupported &&
3960
+ method !== 'get' &&
3961
+ method !== 'head'
3962
+ ) {
3963
+ data = trackRequestStream(data);
3964
+ } else if (
3965
+ mustEnforceStreamBody &&
3966
+ isRequestSupported &&
3967
+ !supportsRequestStream &&
3968
+ method !== 'get' &&
3969
+ method !== 'head'
3970
+ ) {
3971
+ throw new AxiosError(
3972
+ 'Stream request bodies are not supported by the current fetch implementation',
3973
+ AxiosError.ERR_NOT_SUPPORT,
3974
+ config,
3975
+ request
3976
+ );
3732
3977
  }
3733
3978
 
3734
3979
  if (!utils$1.isString(withCredentials)) {
@@ -3771,10 +4016,12 @@ const factory = (env) => {
3771
4016
  ? _fetch(request, fetchOptions)
3772
4017
  : _fetch(url, resolvedOptions));
3773
4018
 
4019
+ const responseHeaders = AxiosHeaders.from(response.headers);
4020
+
3774
4021
  // Cheap pre-check: if the server honestly declares a content-length that
3775
4022
  // already exceeds the cap, reject before we start streaming.
3776
4023
  if (hasMaxContentLength) {
3777
- const declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
4024
+ const declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
3778
4025
  if (declaredLength != null && declaredLength > maxContentLength) {
3779
4026
  throw new AxiosError(
3780
4027
  'maxContentLength size of ' + maxContentLength + ' exceeded',
@@ -3799,7 +4046,7 @@ const factory = (env) => {
3799
4046
  options[prop] = response[prop];
3800
4047
  });
3801
4048
 
3802
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
4049
+ const responseContentLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
3803
4050
 
3804
4051
  const [onProgress, flush] =
3805
4052
  (onDownloadProgress &&
@@ -3894,6 +4141,23 @@ const factory = (env) => {
3894
4141
  throw canceledError;
3895
4142
  }
3896
4143
 
4144
+ // Surface a maxBodyLength violation we raised while the request body was
4145
+ // being streamed. Matching by identity (rather than reading
4146
+ // `err.cause.isAxiosError`) keeps the error deterministic across runtimes
4147
+ // and avoids both prototype-pollution reads and mis-attributing a foreign
4148
+ // AxiosError that merely happened to land in `err.cause`.
4149
+ if (pendingBodyError) {
4150
+ request && !pendingBodyError.request && (pendingBodyError.request = request);
4151
+ throw pendingBodyError;
4152
+ }
4153
+
4154
+ // Re-throw AxiosErrors we raised synchronously (data: URL / content-length
4155
+ // pre-checks, response size enforcement) without re-wrapping them.
4156
+ if (err instanceof AxiosError) {
4157
+ request && !err.request && (err.request = request);
4158
+ throw err;
4159
+ }
4160
+
3897
4161
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3898
4162
  throw Object.assign(
3899
4163
  new AxiosError(
@@ -4349,6 +4613,7 @@ class Axios {
4349
4613
  clarifyTimeoutError: validators.transitional(validators.boolean),
4350
4614
  legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
4351
4615
  advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
4616
+ validateStatusUndefinedResolves: validators.transitional(validators.boolean),
4352
4617
  },
4353
4618
  false
4354
4619
  );
@@ -4478,7 +4743,7 @@ class Axios {
4478
4743
 
4479
4744
  getUri(config) {
4480
4745
  config = mergeConfig(this.defaults, config);
4481
- const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
4746
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
4482
4747
  return buildURL(fullPath, config.params, config.paramsSerializer);
4483
4748
  }
4484
4749
  }
@@ -4491,7 +4756,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
4491
4756
  mergeConfig(config || {}, {
4492
4757
  method,
4493
4758
  url,
4494
- data: (config || {}).data,
4759
+ data: config && utils$1.hasOwnProp(config, 'data') ? config.data : undefined,
4495
4760
  })
4496
4761
  );
4497
4762
  };