@kontent-ai/core-sdk 10.12.5 → 10.12.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +14 -14
- package/LICENSE.md +9 -9
- package/README.md +30 -30
- package/dist/cjs/sdk-info.generated.js +1 -1
- package/dist/es6/sdk-info.generated.js +1 -1
- package/dist/esnext/sdk-info.generated.js +1 -1
- package/dist/umd/kontent-core.umd.js +537 -124
- package/dist/umd/kontent-core.umd.js.map +1 -1
- package/dist/umd/kontent-core.umd.min.js +1 -1
- package/dist/umd/kontent-core.umd.min.js.LICENSE.txt +1 -1
- package/dist/umd/kontent-core.umd.min.js.map +1 -1
- package/dist/umd/report.json +1 -1
- package/dist/umd/report.min.json +1 -1
- package/dist/umd/stats.json +437 -437
- package/dist/umd/stats.min.json +445 -445
- package/lib/helpers/header.helper.ts +23 -23
- package/lib/helpers/headers-helper.ts +15 -15
- package/lib/helpers/index.ts +4 -4
- package/lib/helpers/retry-helper.ts +204 -204
- package/lib/helpers/url.helper.ts +26 -26
- package/lib/http/http.debugger.ts +21 -21
- package/lib/http/http.functions.ts +314 -314
- package/lib/http/http.models.ts +83 -83
- package/lib/http/http.service.ts +91 -91
- package/lib/http/ihttp.service.ts +20 -20
- package/lib/http/index.ts +6 -6
- package/lib/http/test-http.service.ts +70 -70
- package/lib/index.ts +4 -4
- package/lib/models/index.ts +3 -3
- package/lib/models/isdk-info.ts +15 -15
- package/lib/models/parameters.ts +25 -25
- package/lib/models/url.models.ts +3 -3
- package/lib/sdk-info.generated.ts +1 -1
- package/package.json +93 -93
|
@@ -899,7 +899,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
899
899
|
\***************************************************/
|
|
900
900
|
(module, __unused_webpack_exports, __webpack_require__) {
|
|
901
901
|
|
|
902
|
-
/*! Axios v1.
|
|
902
|
+
/*! Axios v1.18.1 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
903
903
|
|
|
904
904
|
|
|
905
905
|
/**
|
|
@@ -921,6 +921,57 @@ const { toString } = Object.prototype;
|
|
|
921
921
|
const { getPrototypeOf } = Object;
|
|
922
922
|
const { iterator, toStringTag } = Symbol;
|
|
923
923
|
|
|
924
|
+
/* Creating a function that will check if an object has a property. */
|
|
925
|
+
const hasOwnProperty = (
|
|
926
|
+
({ hasOwnProperty }) =>
|
|
927
|
+
(obj, prop) =>
|
|
928
|
+
hasOwnProperty.call(obj, prop)
|
|
929
|
+
)(Object.prototype);
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Walk the prototype chain (excluding the shared Object.prototype) looking for
|
|
933
|
+
* an own `prop`. This distinguishes genuine own/inherited members — including
|
|
934
|
+
* class accessors and template prototypes — from members injected via
|
|
935
|
+
* Object.prototype pollution (e.g. `Object.prototype.username = '...'`), which
|
|
936
|
+
* live on Object.prototype itself and are therefore never matched.
|
|
937
|
+
*
|
|
938
|
+
* @param {*} thing The value whose chain to inspect
|
|
939
|
+
* @param {string|symbol} prop The property key to look for
|
|
940
|
+
*
|
|
941
|
+
* @returns {boolean} True when `prop` is owned below Object.prototype
|
|
942
|
+
*/
|
|
943
|
+
const hasOwnInPrototypeChain = (thing, prop) => {
|
|
944
|
+
let obj = thing;
|
|
945
|
+
const seen = [];
|
|
946
|
+
|
|
947
|
+
while (obj != null && obj !== Object.prototype) {
|
|
948
|
+
if (seen.indexOf(obj) !== -1) {
|
|
949
|
+
return false;
|
|
950
|
+
}
|
|
951
|
+
seen.push(obj);
|
|
952
|
+
|
|
953
|
+
if (hasOwnProperty(obj, prop)) {
|
|
954
|
+
return true;
|
|
955
|
+
}
|
|
956
|
+
obj = getPrototypeOf(obj);
|
|
957
|
+
}
|
|
958
|
+
return false;
|
|
959
|
+
};
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
|
|
963
|
+
* properties and members inherited from a non-Object.prototype source (a class
|
|
964
|
+
* instance or template object) are honored; a value reachable only through a
|
|
965
|
+
* polluted Object.prototype is ignored and `undefined` is returned.
|
|
966
|
+
*
|
|
967
|
+
* @param {*} obj The source object
|
|
968
|
+
* @param {string|symbol} prop The property key to read
|
|
969
|
+
*
|
|
970
|
+
* @returns {*} The resolved value, or undefined when unsafe/absent
|
|
971
|
+
*/
|
|
972
|
+
const getSafeProp = (obj, prop) =>
|
|
973
|
+
obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
|
|
974
|
+
|
|
924
975
|
const kindOf = ((cache) => (thing) => {
|
|
925
976
|
const str = toString.call(thing);
|
|
926
977
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -1046,7 +1097,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
1046
1097
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
1047
1098
|
*/
|
|
1048
1099
|
const isPlainObject = (val) => {
|
|
1049
|
-
if (
|
|
1100
|
+
if (!isObject(val)) {
|
|
1050
1101
|
return false;
|
|
1051
1102
|
}
|
|
1052
1103
|
|
|
@@ -1054,9 +1105,12 @@ const isPlainObject = (val) => {
|
|
|
1054
1105
|
return (
|
|
1055
1106
|
(prototype === null ||
|
|
1056
1107
|
prototype === Object.prototype ||
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1108
|
+
getPrototypeOf(prototype) === null) &&
|
|
1109
|
+
// Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
|
|
1110
|
+
// Symbol.iterator as evidence the value is a tagged/iterable type rather
|
|
1111
|
+
// than a plain object, while ignoring keys injected onto Object.prototype.
|
|
1112
|
+
!hasOwnInPrototypeChain(val, toStringTag) &&
|
|
1113
|
+
!hasOwnInPrototypeChain(val, iterator)
|
|
1060
1114
|
);
|
|
1061
1115
|
};
|
|
1062
1116
|
|
|
@@ -1325,7 +1379,9 @@ function merge(...objs) {
|
|
|
1325
1379
|
return;
|
|
1326
1380
|
}
|
|
1327
1381
|
|
|
1328
|
-
|
|
1382
|
+
// findKey lowercases the key, so caseless lookup only applies to strings —
|
|
1383
|
+
// symbol keys are identity-matched.
|
|
1384
|
+
const targetKey = (caseless && typeof key === 'string' && findKey(result, key)) || key;
|
|
1329
1385
|
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
1330
1386
|
// chain, so a polluted Object.prototype value could surface here and get
|
|
1331
1387
|
// copied into the merged result.
|
|
@@ -1342,7 +1398,24 @@ function merge(...objs) {
|
|
|
1342
1398
|
};
|
|
1343
1399
|
|
|
1344
1400
|
for (let i = 0, l = objs.length; i < l; i++) {
|
|
1345
|
-
|
|
1401
|
+
const source = objs[i];
|
|
1402
|
+
if (!source || isBuffer(source)) {
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
forEach(source, assignValue);
|
|
1407
|
+
|
|
1408
|
+
if (typeof source !== 'object' || isArray(source)) {
|
|
1409
|
+
continue;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
const symbols = Object.getOwnPropertySymbols(source);
|
|
1413
|
+
for (let j = 0; j < symbols.length; j++) {
|
|
1414
|
+
const symbol = symbols[j];
|
|
1415
|
+
if (propertyIsEnumerable.call(source, symbol)) {
|
|
1416
|
+
assignValue(source[symbol], symbol);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1346
1419
|
}
|
|
1347
1420
|
return result;
|
|
1348
1421
|
}
|
|
@@ -1564,12 +1637,7 @@ const toCamelCase = (str) => {
|
|
|
1564
1637
|
});
|
|
1565
1638
|
};
|
|
1566
1639
|
|
|
1567
|
-
|
|
1568
|
-
const hasOwnProperty = (
|
|
1569
|
-
({ hasOwnProperty }) =>
|
|
1570
|
-
(obj, prop) =>
|
|
1571
|
-
hasOwnProperty.call(obj, prop)
|
|
1572
|
-
)(Object.prototype);
|
|
1640
|
+
const { propertyIsEnumerable } = Object.prototype;
|
|
1573
1641
|
|
|
1574
1642
|
/**
|
|
1575
1643
|
* Determine if a value is a RegExp object
|
|
@@ -1782,6 +1850,20 @@ const asap =
|
|
|
1782
1850
|
|
|
1783
1851
|
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
1784
1852
|
|
|
1853
|
+
/**
|
|
1854
|
+
* Determine if a value is iterable via an iterator that is NOT sourced solely
|
|
1855
|
+
* from a polluted Object.prototype. Use this instead of `isIterable` whenever
|
|
1856
|
+
* the iterable comes from untrusted input (e.g. user-supplied header sources),
|
|
1857
|
+
* so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
|
|
1858
|
+
* into an attacker-controlled entries iterator.
|
|
1859
|
+
*
|
|
1860
|
+
* @param {*} thing The value to test
|
|
1861
|
+
*
|
|
1862
|
+
* @returns {boolean} True if value has a non-polluted iterator
|
|
1863
|
+
*/
|
|
1864
|
+
const isSafeIterable = (thing) =>
|
|
1865
|
+
thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
|
|
1866
|
+
|
|
1785
1867
|
var utils$1 = {
|
|
1786
1868
|
isArray,
|
|
1787
1869
|
isArrayBuffer,
|
|
@@ -1826,6 +1908,8 @@ var utils$1 = {
|
|
|
1826
1908
|
isHTMLForm,
|
|
1827
1909
|
hasOwnProperty,
|
|
1828
1910
|
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
|
1911
|
+
hasOwnInPrototypeChain,
|
|
1912
|
+
getSafeProp,
|
|
1829
1913
|
reduceDescriptors,
|
|
1830
1914
|
freezeMethods,
|
|
1831
1915
|
toObjectSet,
|
|
@@ -1842,6 +1926,7 @@ var utils$1 = {
|
|
|
1842
1926
|
setImmediate: _setImmediate,
|
|
1843
1927
|
asap,
|
|
1844
1928
|
isIterable,
|
|
1929
|
+
isSafeIterable,
|
|
1845
1930
|
};
|
|
1846
1931
|
|
|
1847
1932
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
@@ -2052,7 +2137,7 @@ class AxiosHeaders {
|
|
|
2052
2137
|
const lHeader = normalizeHeader(_header);
|
|
2053
2138
|
|
|
2054
2139
|
if (!lHeader) {
|
|
2055
|
-
|
|
2140
|
+
return;
|
|
2056
2141
|
}
|
|
2057
2142
|
|
|
2058
2143
|
const key = utils$1.findKey(self, lHeader);
|
|
@@ -2074,20 +2159,23 @@ class AxiosHeaders {
|
|
|
2074
2159
|
setHeaders(header, valueOrRewrite);
|
|
2075
2160
|
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2076
2161
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
2077
|
-
} else if (utils$1.isObject(header) && utils$1.
|
|
2078
|
-
let obj =
|
|
2162
|
+
} else if (utils$1.isObject(header) && utils$1.isSafeIterable(header)) {
|
|
2163
|
+
let obj = Object.create(null),
|
|
2079
2164
|
dest,
|
|
2080
2165
|
key;
|
|
2081
2166
|
for (const entry of header) {
|
|
2082
2167
|
if (!utils$1.isArray(entry)) {
|
|
2083
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
2168
|
+
throw new TypeError('Object iterator must return a key-value pair');
|
|
2084
2169
|
}
|
|
2085
2170
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
: entry[1];
|
|
2171
|
+
key = entry[0];
|
|
2172
|
+
|
|
2173
|
+
if (utils$1.hasOwnProp(obj, key)) {
|
|
2174
|
+
dest = obj[key];
|
|
2175
|
+
obj[key] = utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]];
|
|
2176
|
+
} else {
|
|
2177
|
+
obj[key] = entry[1];
|
|
2178
|
+
}
|
|
2091
2179
|
}
|
|
2092
2180
|
|
|
2093
2181
|
setHeaders(obj, valueOrRewrite);
|
|
@@ -2380,7 +2468,19 @@ function redactConfig(config, redactKeys) {
|
|
|
2380
2468
|
class AxiosError extends Error {
|
|
2381
2469
|
static from(error, code, config, request, response, customProps) {
|
|
2382
2470
|
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
2383
|
-
|
|
2471
|
+
// Match native `Error` `cause` semantics: non-enumerable. The wrapped
|
|
2472
|
+
// error often carries circular internals (sockets, requests, agents), so
|
|
2473
|
+
// an enumerable `cause` makes structured loggers (pino/winston) and any
|
|
2474
|
+
// own-property walk throw "Converting circular structure to JSON".
|
|
2475
|
+
// Regression from #6982; see #7205. `__proto__: null` mirrors the
|
|
2476
|
+
// `message` descriptor below (prototype-pollution-safe descriptor).
|
|
2477
|
+
Object.defineProperty(axiosError, 'cause', {
|
|
2478
|
+
__proto__: null,
|
|
2479
|
+
value: error,
|
|
2480
|
+
writable: true,
|
|
2481
|
+
enumerable: false,
|
|
2482
|
+
configurable: true,
|
|
2483
|
+
});
|
|
2384
2484
|
axiosError.name = error.name;
|
|
2385
2485
|
|
|
2386
2486
|
// Preserve status from the original error if not already set from response
|
|
@@ -2481,6 +2581,10 @@ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
|
2481
2581
|
// eslint-disable-next-line strict
|
|
2482
2582
|
var httpAdapter = null;
|
|
2483
2583
|
|
|
2584
|
+
// Default nesting limit shared with the inverse transform (formDataToJSON) so
|
|
2585
|
+
// the FormData <-> JSON round-trip stays symmetric.
|
|
2586
|
+
const DEFAULT_FORM_DATA_MAX_DEPTH = 100;
|
|
2587
|
+
|
|
2484
2588
|
/**
|
|
2485
2589
|
* Determines if the given thing is a array or js object.
|
|
2486
2590
|
*
|
|
@@ -2591,8 +2695,9 @@ function toFormData(obj, formData, options) {
|
|
|
2591
2695
|
const dots = options.dots;
|
|
2592
2696
|
const indexes = options.indexes;
|
|
2593
2697
|
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
2594
|
-
const maxDepth = options.maxDepth === undefined ?
|
|
2698
|
+
const maxDepth = options.maxDepth === undefined ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
|
|
2595
2699
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
2700
|
+
const stack = [];
|
|
2596
2701
|
|
|
2597
2702
|
if (!utils$1.isFunction(visitor)) {
|
|
2598
2703
|
throw new TypeError('visitor must be a function');
|
|
@@ -2614,12 +2719,50 @@ function toFormData(obj, formData, options) {
|
|
|
2614
2719
|
}
|
|
2615
2720
|
|
|
2616
2721
|
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
2617
|
-
|
|
2722
|
+
if (useBlob && typeof _Blob === 'function') {
|
|
2723
|
+
return new _Blob([value]);
|
|
2724
|
+
}
|
|
2725
|
+
if (typeof Buffer !== 'undefined') {
|
|
2726
|
+
return Buffer.from(value);
|
|
2727
|
+
}
|
|
2728
|
+
throw new AxiosError('Blob is not supported. Use a Buffer instead.', AxiosError.ERR_NOT_SUPPORT);
|
|
2618
2729
|
}
|
|
2619
2730
|
|
|
2620
2731
|
return value;
|
|
2621
2732
|
}
|
|
2622
2733
|
|
|
2734
|
+
function throwIfMaxDepthExceeded(depth) {
|
|
2735
|
+
if (depth > maxDepth) {
|
|
2736
|
+
throw new AxiosError(
|
|
2737
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
2738
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2739
|
+
);
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
function stringifyWithDepthLimit(value, depth) {
|
|
2744
|
+
if (maxDepth === Infinity) {
|
|
2745
|
+
return JSON.stringify(value);
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
const ancestors = [];
|
|
2749
|
+
|
|
2750
|
+
return JSON.stringify(value, function limitDepth(_key, currentValue) {
|
|
2751
|
+
if (!utils$1.isObject(currentValue)) {
|
|
2752
|
+
return currentValue;
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
|
|
2756
|
+
ancestors.pop();
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
ancestors.push(currentValue);
|
|
2760
|
+
throwIfMaxDepthExceeded(depth + ancestors.length - 1);
|
|
2761
|
+
|
|
2762
|
+
return currentValue;
|
|
2763
|
+
});
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2623
2766
|
/**
|
|
2624
2767
|
* Default visitor.
|
|
2625
2768
|
*
|
|
@@ -2643,7 +2786,7 @@ function toFormData(obj, formData, options) {
|
|
|
2643
2786
|
// eslint-disable-next-line no-param-reassign
|
|
2644
2787
|
key = metaTokens ? key : key.slice(0, -2);
|
|
2645
2788
|
// eslint-disable-next-line no-param-reassign
|
|
2646
|
-
value =
|
|
2789
|
+
value = stringifyWithDepthLimit(value, 1);
|
|
2647
2790
|
} else if (
|
|
2648
2791
|
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
2649
2792
|
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
@@ -2676,8 +2819,6 @@ function toFormData(obj, formData, options) {
|
|
|
2676
2819
|
return false;
|
|
2677
2820
|
}
|
|
2678
2821
|
|
|
2679
|
-
const stack = [];
|
|
2680
|
-
|
|
2681
2822
|
const exposedHelpers = Object.assign(predicates, {
|
|
2682
2823
|
defaultVisitor,
|
|
2683
2824
|
convertValue,
|
|
@@ -2687,15 +2828,10 @@ function toFormData(obj, formData, options) {
|
|
|
2687
2828
|
function build(value, path, depth = 0) {
|
|
2688
2829
|
if (utils$1.isUndefined(value)) return;
|
|
2689
2830
|
|
|
2690
|
-
|
|
2691
|
-
throw new AxiosError(
|
|
2692
|
-
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
2693
|
-
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2694
|
-
);
|
|
2695
|
-
}
|
|
2831
|
+
throwIfMaxDepthExceeded(depth);
|
|
2696
2832
|
|
|
2697
2833
|
if (stack.indexOf(value) !== -1) {
|
|
2698
|
-
throw Error('Circular reference detected in ' + path.join('.'));
|
|
2834
|
+
throw new Error('Circular reference detected in ' + path.join('.'));
|
|
2699
2835
|
}
|
|
2700
2836
|
|
|
2701
2837
|
stack.push(value);
|
|
@@ -2766,9 +2902,7 @@ prototype.append = function append(name, value) {
|
|
|
2766
2902
|
|
|
2767
2903
|
prototype.toString = function toString(encoder) {
|
|
2768
2904
|
const _encode = encoder
|
|
2769
|
-
?
|
|
2770
|
-
return encoder.call(this, value, encode$1);
|
|
2771
|
-
}
|
|
2905
|
+
? (value) => encoder.call(this, value, encode$1)
|
|
2772
2906
|
: encode$1;
|
|
2773
2907
|
|
|
2774
2908
|
return this._pairs
|
|
@@ -2807,8 +2941,7 @@ function buildURL(url, params, options) {
|
|
|
2807
2941
|
if (!params) {
|
|
2808
2942
|
return url;
|
|
2809
2943
|
}
|
|
2810
|
-
|
|
2811
|
-
const _encode = (options && options.encode) || encode;
|
|
2944
|
+
url = url || '';
|
|
2812
2945
|
|
|
2813
2946
|
const _options = utils$1.isFunction(options)
|
|
2814
2947
|
? {
|
|
@@ -2816,7 +2949,11 @@ function buildURL(url, params, options) {
|
|
|
2816
2949
|
}
|
|
2817
2950
|
: options;
|
|
2818
2951
|
|
|
2819
|
-
|
|
2952
|
+
// Read serializer options pollution-safely: own properties and methods on a
|
|
2953
|
+
// class/template prototype are honored, but values injected onto a polluted
|
|
2954
|
+
// Object.prototype are ignored.
|
|
2955
|
+
const _encode = utils$1.getSafeProp(_options, 'encode') || encode;
|
|
2956
|
+
const serializeFn = utils$1.getSafeProp(_options, 'serialize');
|
|
2820
2957
|
|
|
2821
2958
|
let serializedParams;
|
|
2822
2959
|
|
|
@@ -2912,6 +3049,8 @@ var transitionalDefaults = {
|
|
|
2912
3049
|
forcedJSONParsing: true,
|
|
2913
3050
|
clarifyTimeoutError: false,
|
|
2914
3051
|
legacyInterceptorReqResOrdering: true,
|
|
3052
|
+
advertiseZstdAcceptEncoding: false,
|
|
3053
|
+
validateStatusUndefinedResolves: true,
|
|
2915
3054
|
};
|
|
2916
3055
|
|
|
2917
3056
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -3003,6 +3142,17 @@ function toURLEncodedForm(data, options) {
|
|
|
3003
3142
|
});
|
|
3004
3143
|
}
|
|
3005
3144
|
|
|
3145
|
+
const MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
|
|
3146
|
+
|
|
3147
|
+
function throwIfDepthExceeded(index) {
|
|
3148
|
+
if (index > MAX_DEPTH) {
|
|
3149
|
+
throw new AxiosError(
|
|
3150
|
+
'FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH,
|
|
3151
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
3152
|
+
);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
|
|
3006
3156
|
/**
|
|
3007
3157
|
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
3008
3158
|
*
|
|
@@ -3015,9 +3165,16 @@ function parsePropPath(name) {
|
|
|
3015
3165
|
// foo.x.y.z
|
|
3016
3166
|
// foo-x-y-z
|
|
3017
3167
|
// foo x y z
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3168
|
+
const path = [];
|
|
3169
|
+
const pattern = /\w+|\[(\w*)]/g;
|
|
3170
|
+
let match;
|
|
3171
|
+
|
|
3172
|
+
while ((match = pattern.exec(name)) !== null) {
|
|
3173
|
+
throwIfDepthExceeded(path.length);
|
|
3174
|
+
path.push(match[0] === '[]' ? '' : match[1] || match[0]);
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3177
|
+
return path;
|
|
3021
3178
|
}
|
|
3022
3179
|
|
|
3023
3180
|
/**
|
|
@@ -3049,6 +3206,8 @@ function arrayToObject(arr) {
|
|
|
3049
3206
|
*/
|
|
3050
3207
|
function formDataToJSON(formData) {
|
|
3051
3208
|
function buildPath(path, value, target, index) {
|
|
3209
|
+
throwIfDepthExceeded(index);
|
|
3210
|
+
|
|
3052
3211
|
let name = path[index++];
|
|
3053
3212
|
|
|
3054
3213
|
if (name === '__proto__') return true;
|
|
@@ -3534,7 +3693,11 @@ var cookies = platform.hasStandardBrowserEnv
|
|
|
3534
3693
|
const cookie = cookies[i].replace(/^\s+/, '');
|
|
3535
3694
|
const eq = cookie.indexOf('=');
|
|
3536
3695
|
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
3537
|
-
|
|
3696
|
+
try {
|
|
3697
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
3698
|
+
} catch (e) {
|
|
3699
|
+
return cookie.slice(eq + 1);
|
|
3700
|
+
}
|
|
3538
3701
|
}
|
|
3539
3702
|
}
|
|
3540
3703
|
return null;
|
|
@@ -3585,6 +3748,31 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
3585
3748
|
: baseURL;
|
|
3586
3749
|
}
|
|
3587
3750
|
|
|
3751
|
+
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
3752
|
+
const httpProtocolControlCharacters = /[\t\n\r]/g;
|
|
3753
|
+
|
|
3754
|
+
function stripLeadingC0ControlOrSpace(url) {
|
|
3755
|
+
let i = 0;
|
|
3756
|
+
while (i < url.length && url.charCodeAt(i) <= 0x20) {
|
|
3757
|
+
i++;
|
|
3758
|
+
}
|
|
3759
|
+
return url.slice(i);
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3762
|
+
function normalizeURLForProtocolCheck(url) {
|
|
3763
|
+
return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
function assertValidHttpProtocolURL(url, config) {
|
|
3767
|
+
if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
|
|
3768
|
+
throw new AxiosError(
|
|
3769
|
+
'Invalid URL: missing "//" after protocol',
|
|
3770
|
+
AxiosError.ERR_INVALID_URL,
|
|
3771
|
+
config
|
|
3772
|
+
);
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
|
|
3588
3776
|
/**
|
|
3589
3777
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
3590
3778
|
* only when the requestedURL is not already an absolute URL.
|
|
@@ -3595,9 +3783,11 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
3595
3783
|
*
|
|
3596
3784
|
* @returns {string} The combined full path
|
|
3597
3785
|
*/
|
|
3598
|
-
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
3786
|
+
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
3787
|
+
assertValidHttpProtocolURL(requestedURL, config);
|
|
3599
3788
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
3600
3789
|
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
3790
|
+
assertValidHttpProtocolURL(baseURL, config);
|
|
3601
3791
|
return combineURLs(baseURL, requestedURL);
|
|
3602
3792
|
}
|
|
3603
3793
|
return requestedURL;
|
|
@@ -3616,6 +3806,7 @@ const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing }
|
|
|
3616
3806
|
*/
|
|
3617
3807
|
function mergeConfig(config1, config2) {
|
|
3618
3808
|
// eslint-disable-next-line no-param-reassign
|
|
3809
|
+
config1 = config1 || {};
|
|
3619
3810
|
config2 = config2 || {};
|
|
3620
3811
|
|
|
3621
3812
|
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
@@ -3668,6 +3859,28 @@ function mergeConfig(config1, config2) {
|
|
|
3668
3859
|
}
|
|
3669
3860
|
}
|
|
3670
3861
|
|
|
3862
|
+
function getMergedTransitionalOption(prop) {
|
|
3863
|
+
const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
|
|
3864
|
+
|
|
3865
|
+
if (!utils$1.isUndefined(transitional2)) {
|
|
3866
|
+
if (utils$1.isPlainObject(transitional2)) {
|
|
3867
|
+
if (utils$1.hasOwnProp(transitional2, prop)) {
|
|
3868
|
+
return transitional2[prop];
|
|
3869
|
+
}
|
|
3870
|
+
} else {
|
|
3871
|
+
return undefined;
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
|
|
3875
|
+
const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
|
|
3876
|
+
|
|
3877
|
+
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
3878
|
+
return transitional1[prop];
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3881
|
+
return undefined;
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3671
3884
|
// eslint-disable-next-line consistent-return
|
|
3672
3885
|
function mergeDirectKeys(a, b, prop) {
|
|
3673
3886
|
if (utils$1.hasOwnProp(config2, prop)) {
|
|
@@ -3720,6 +3933,18 @@ function mergeConfig(config1, config2) {
|
|
|
3720
3933
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
3721
3934
|
});
|
|
3722
3935
|
|
|
3936
|
+
if (
|
|
3937
|
+
utils$1.hasOwnProp(config2, 'validateStatus') &&
|
|
3938
|
+
utils$1.isUndefined(config2.validateStatus) &&
|
|
3939
|
+
getMergedTransitionalOption('validateStatusUndefinedResolves') === false
|
|
3940
|
+
) {
|
|
3941
|
+
if (utils$1.hasOwnProp(config1, 'validateStatus')) {
|
|
3942
|
+
config.validateStatus = getMergedValue(undefined, config1.validateStatus);
|
|
3943
|
+
} else {
|
|
3944
|
+
delete config.validateStatus;
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
|
|
3723
3948
|
return config;
|
|
3724
3949
|
}
|
|
3725
3950
|
|
|
@@ -3731,7 +3956,7 @@ function setFormDataHeaders(headers, formHeaders, policy) {
|
|
|
3731
3956
|
return;
|
|
3732
3957
|
}
|
|
3733
3958
|
|
|
3734
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
3959
|
+
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
3735
3960
|
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
3736
3961
|
headers.set(key, val);
|
|
3737
3962
|
}
|
|
@@ -3746,12 +3971,12 @@ function setFormDataHeaders(headers, formHeaders, policy) {
|
|
|
3746
3971
|
*
|
|
3747
3972
|
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
3748
3973
|
*/
|
|
3749
|
-
const encodeUTF8 = (str) =>
|
|
3974
|
+
const encodeUTF8$1 = (str) =>
|
|
3750
3975
|
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
3751
3976
|
String.fromCharCode(parseInt(hex, 16))
|
|
3752
3977
|
);
|
|
3753
3978
|
|
|
3754
|
-
|
|
3979
|
+
function resolveConfig(config) {
|
|
3755
3980
|
const newConfig = mergeConfig({}, config);
|
|
3756
3981
|
|
|
3757
3982
|
// Read only own properties to prevent prototype pollution gadgets
|
|
@@ -3771,23 +3996,33 @@ var resolveConfig = (config) => {
|
|
|
3771
3996
|
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
3772
3997
|
|
|
3773
3998
|
newConfig.url = buildURL(
|
|
3774
|
-
buildFullPath(baseURL, url, allowAbsoluteUrls),
|
|
3775
|
-
|
|
3776
|
-
|
|
3999
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig),
|
|
4000
|
+
own('params'),
|
|
4001
|
+
own('paramsSerializer')
|
|
3777
4002
|
);
|
|
3778
4003
|
|
|
3779
4004
|
// HTTP basic authentication
|
|
3780
4005
|
if (auth) {
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
4006
|
+
const username = utils$1.getSafeProp(auth, 'username') || '';
|
|
4007
|
+
const password = utils$1.getSafeProp(auth, 'password') || '';
|
|
4008
|
+
|
|
4009
|
+
try {
|
|
4010
|
+
headers.set(
|
|
4011
|
+
'Authorization',
|
|
4012
|
+
'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : ''))
|
|
4013
|
+
);
|
|
4014
|
+
} catch (e) {
|
|
4015
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
4016
|
+
}
|
|
3786
4017
|
}
|
|
3787
4018
|
|
|
3788
4019
|
if (utils$1.isFormData(data)) {
|
|
3789
|
-
if (
|
|
3790
|
-
|
|
4020
|
+
if (
|
|
4021
|
+
platform.hasStandardBrowserEnv ||
|
|
4022
|
+
platform.hasStandardBrowserWebWorkerEnv ||
|
|
4023
|
+
utils$1.isReactNative(data)
|
|
4024
|
+
) {
|
|
4025
|
+
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
3791
4026
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
3792
4027
|
// Node.js FormData (like form-data package)
|
|
3793
4028
|
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
@@ -3819,7 +4054,7 @@ var resolveConfig = (config) => {
|
|
|
3819
4054
|
}
|
|
3820
4055
|
|
|
3821
4056
|
return newConfig;
|
|
3822
|
-
}
|
|
4057
|
+
}
|
|
3823
4058
|
|
|
3824
4059
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
3825
4060
|
|
|
@@ -4029,6 +4264,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
4029
4264
|
config
|
|
4030
4265
|
)
|
|
4031
4266
|
);
|
|
4267
|
+
done();
|
|
4032
4268
|
return;
|
|
4033
4269
|
}
|
|
4034
4270
|
|
|
@@ -4080,7 +4316,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
4080
4316
|
signals = null;
|
|
4081
4317
|
};
|
|
4082
4318
|
|
|
4083
|
-
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
4319
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort, { once: true }));
|
|
4084
4320
|
|
|
4085
4321
|
const { signal } = controller;
|
|
4086
4322
|
|
|
@@ -4183,11 +4419,19 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
4183
4419
|
* Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|
4184
4420
|
* - For base64: compute exact decoded size using length and padding;
|
|
4185
4421
|
* handle %XX at the character-count level (no string allocation).
|
|
4186
|
-
* - For non-base64:
|
|
4422
|
+
* - For non-base64: compute the exact percent-decoded UTF-8 byte length.
|
|
4187
4423
|
*
|
|
4188
4424
|
* @param {string} url
|
|
4189
4425
|
* @returns {number}
|
|
4190
4426
|
*/
|
|
4427
|
+
const isHexDigit = (charCode) =>
|
|
4428
|
+
(charCode >= 48 && charCode <= 57) ||
|
|
4429
|
+
(charCode >= 65 && charCode <= 70) ||
|
|
4430
|
+
(charCode >= 97 && charCode <= 102);
|
|
4431
|
+
|
|
4432
|
+
const isPercentEncodedByte = (str, i, len) =>
|
|
4433
|
+
i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
4434
|
+
|
|
4191
4435
|
function estimateDataURLDecodedBytes(url) {
|
|
4192
4436
|
if (!url || typeof url !== 'string') return 0;
|
|
4193
4437
|
if (!url.startsWith('data:')) return 0;
|
|
@@ -4207,9 +4451,7 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
4207
4451
|
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
4208
4452
|
const a = body.charCodeAt(i + 1);
|
|
4209
4453
|
const b = body.charCodeAt(i + 2);
|
|
4210
|
-
const isHex =
|
|
4211
|
-
((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
|
|
4212
|
-
((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
|
|
4454
|
+
const isHex = isHexDigit(a) && isHexDigit(b);
|
|
4213
4455
|
|
|
4214
4456
|
if (isHex) {
|
|
4215
4457
|
effectiveLen -= 2;
|
|
@@ -4250,18 +4492,17 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
4250
4492
|
return bytes > 0 ? bytes : 0;
|
|
4251
4493
|
}
|
|
4252
4494
|
|
|
4253
|
-
if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
|
|
4254
|
-
return Buffer.byteLength(body, 'utf8');
|
|
4255
|
-
}
|
|
4256
|
-
|
|
4257
4495
|
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
4258
4496
|
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
4259
|
-
//
|
|
4260
|
-
//
|
|
4497
|
+
// Valid %XX triplets count as one decoded byte; this matches the bytes that
|
|
4498
|
+
// decodeURIComponent(body) would produce before Buffer re-encodes the string.
|
|
4261
4499
|
let bytes = 0;
|
|
4262
4500
|
for (let i = 0, len = body.length; i < len; i++) {
|
|
4263
4501
|
const c = body.charCodeAt(i);
|
|
4264
|
-
if (c
|
|
4502
|
+
if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
4503
|
+
bytes += 1;
|
|
4504
|
+
i += 2;
|
|
4505
|
+
} else if (c < 0x80) {
|
|
4265
4506
|
bytes += 1;
|
|
4266
4507
|
} else if (c < 0x800) {
|
|
4267
4508
|
bytes += 2;
|
|
@@ -4280,12 +4521,41 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
4280
4521
|
return bytes;
|
|
4281
4522
|
}
|
|
4282
4523
|
|
|
4283
|
-
const VERSION = "1.
|
|
4524
|
+
const VERSION = "1.18.1";
|
|
4284
4525
|
|
|
4285
4526
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
4286
4527
|
|
|
4287
4528
|
const { isFunction } = utils$1;
|
|
4288
4529
|
|
|
4530
|
+
/**
|
|
4531
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
4532
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
4533
|
+
*
|
|
4534
|
+
* @param {string} str The string to encode
|
|
4535
|
+
*
|
|
4536
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
4537
|
+
*/
|
|
4538
|
+
const encodeUTF8 = (str) =>
|
|
4539
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
4540
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
4541
|
+
);
|
|
4542
|
+
|
|
4543
|
+
// Node's WHATWG URL parser returns `username` and `password` percent-encoded.
|
|
4544
|
+
// Decode before composing the `auth` option so credentials such as
|
|
4545
|
+
// `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
|
|
4546
|
+
// original value for malformed input so a bad encoding never throws.
|
|
4547
|
+
const decodeURIComponentSafe = (value) => {
|
|
4548
|
+
if (!utils$1.isString(value)) {
|
|
4549
|
+
return value;
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
try {
|
|
4553
|
+
return decodeURIComponent(value);
|
|
4554
|
+
} catch (error) {
|
|
4555
|
+
return value;
|
|
4556
|
+
}
|
|
4557
|
+
};
|
|
4558
|
+
|
|
4289
4559
|
const test = (fn, ...args) => {
|
|
4290
4560
|
try {
|
|
4291
4561
|
return !!fn(...args);
|
|
@@ -4294,6 +4564,15 @@ const test = (fn, ...args) => {
|
|
|
4294
4564
|
}
|
|
4295
4565
|
};
|
|
4296
4566
|
|
|
4567
|
+
const maybeWithAuthCredentials = (url) => {
|
|
4568
|
+
const protocolIndex = url.indexOf('://');
|
|
4569
|
+
let urlToCheck = url;
|
|
4570
|
+
if (protocolIndex !== -1) {
|
|
4571
|
+
urlToCheck = urlToCheck.slice(protocolIndex + 3);
|
|
4572
|
+
}
|
|
4573
|
+
return urlToCheck.includes('@') || urlToCheck.includes(':');
|
|
4574
|
+
};
|
|
4575
|
+
|
|
4297
4576
|
const factory = (env) => {
|
|
4298
4577
|
const globalObject =
|
|
4299
4578
|
utils$1.global !== undefined && utils$1.global !== null
|
|
@@ -4441,6 +4720,7 @@ const factory = (env) => {
|
|
|
4441
4720
|
|
|
4442
4721
|
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
4443
4722
|
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
4723
|
+
const own = (key) => (utils$1.hasOwnProp(config, key) ? config[key] : undefined);
|
|
4444
4724
|
|
|
4445
4725
|
let _fetch = envFetch || fetch;
|
|
4446
4726
|
|
|
@@ -4462,7 +4742,61 @@ const factory = (env) => {
|
|
|
4462
4742
|
|
|
4463
4743
|
let requestContentLength;
|
|
4464
4744
|
|
|
4745
|
+
// AxiosError we raise while the request body is being streamed. Captured
|
|
4746
|
+
// by identity so the catch block can surface it directly, regardless of
|
|
4747
|
+
// how the runtime wraps the resulting fetch rejection (undici exposes it
|
|
4748
|
+
// as `err.cause`; some browsers drop the original error entirely).
|
|
4749
|
+
let pendingBodyError = null;
|
|
4750
|
+
|
|
4751
|
+
const maxBodyLengthError = () =>
|
|
4752
|
+
new AxiosError(
|
|
4753
|
+
'Request body larger than maxBodyLength limit',
|
|
4754
|
+
AxiosError.ERR_BAD_REQUEST,
|
|
4755
|
+
config,
|
|
4756
|
+
request
|
|
4757
|
+
);
|
|
4758
|
+
|
|
4465
4759
|
try {
|
|
4760
|
+
// HTTP basic authentication
|
|
4761
|
+
let auth = undefined;
|
|
4762
|
+
const configAuth = own('auth');
|
|
4763
|
+
|
|
4764
|
+
if (configAuth) {
|
|
4765
|
+
const username = utils$1.getSafeProp(configAuth, 'username') || '';
|
|
4766
|
+
const password = utils$1.getSafeProp(configAuth, 'password') || '';
|
|
4767
|
+
auth = {
|
|
4768
|
+
username,
|
|
4769
|
+
password
|
|
4770
|
+
};
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
if (maybeWithAuthCredentials(url)) {
|
|
4774
|
+
const parsedURL = new URL(url, platform.origin);
|
|
4775
|
+
|
|
4776
|
+
if (!auth && (parsedURL.username || parsedURL.password)) {
|
|
4777
|
+
const urlUsername = decodeURIComponentSafe(parsedURL.username);
|
|
4778
|
+
const urlPassword = decodeURIComponentSafe(parsedURL.password);
|
|
4779
|
+
auth = {
|
|
4780
|
+
username: urlUsername,
|
|
4781
|
+
password: urlPassword
|
|
4782
|
+
};
|
|
4783
|
+
}
|
|
4784
|
+
|
|
4785
|
+
if (parsedURL.username || parsedURL.password) {
|
|
4786
|
+
parsedURL.username = '';
|
|
4787
|
+
parsedURL.password = '';
|
|
4788
|
+
url = parsedURL.href;
|
|
4789
|
+
}
|
|
4790
|
+
}
|
|
4791
|
+
|
|
4792
|
+
if (auth) {
|
|
4793
|
+
headers.delete('authorization');
|
|
4794
|
+
headers.set(
|
|
4795
|
+
'Authorization',
|
|
4796
|
+
'Basic ' + btoa(encodeUTF8((auth.username || '') + ':' + (auth.password || '')))
|
|
4797
|
+
);
|
|
4798
|
+
}
|
|
4799
|
+
|
|
4466
4800
|
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
4467
4801
|
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
4468
4802
|
// "if (protocol === 'data:')" branch).
|
|
@@ -4478,53 +4812,96 @@ const factory = (env) => {
|
|
|
4478
4812
|
}
|
|
4479
4813
|
}
|
|
4480
4814
|
|
|
4481
|
-
// Enforce maxBodyLength against
|
|
4482
|
-
//
|
|
4483
|
-
//
|
|
4484
|
-
//
|
|
4815
|
+
// Enforce maxBodyLength against known-size bodies before dispatch using
|
|
4816
|
+
// the body's *actual* size — never a caller-declared Content-Length,
|
|
4817
|
+
// which could under-report to slip an oversized body past the check.
|
|
4818
|
+
// Unknown-size streams return undefined here and are counted per-chunk
|
|
4819
|
+
// below as fetch consumes them.
|
|
4485
4820
|
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
4486
|
-
const outboundLength = await
|
|
4487
|
-
if (
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
throw new AxiosError(
|
|
4493
|
-
'Request body larger than maxBodyLength limit',
|
|
4494
|
-
AxiosError.ERR_BAD_REQUEST,
|
|
4495
|
-
config,
|
|
4496
|
-
request
|
|
4497
|
-
);
|
|
4821
|
+
const outboundLength = await getBodyLength(data);
|
|
4822
|
+
if (typeof outboundLength === 'number' && isFinite(outboundLength)) {
|
|
4823
|
+
requestContentLength = outboundLength;
|
|
4824
|
+
if (outboundLength > maxBodyLength) {
|
|
4825
|
+
throw maxBodyLengthError();
|
|
4826
|
+
}
|
|
4498
4827
|
}
|
|
4499
4828
|
}
|
|
4500
4829
|
|
|
4830
|
+
// A streamed body under maxBodyLength must be counted as fetch consumes
|
|
4831
|
+
// it; its size is never trusted from a caller-declared Content-Length.
|
|
4832
|
+
const mustEnforceStreamBody =
|
|
4833
|
+
hasMaxBodyLength && (utils$1.isReadableStream(data) || utils$1.isStream(data));
|
|
4834
|
+
|
|
4835
|
+
const trackRequestStream = (stream, onProgress, flush) =>
|
|
4836
|
+
trackStream(
|
|
4837
|
+
stream,
|
|
4838
|
+
DEFAULT_CHUNK_SIZE,
|
|
4839
|
+
(loadedBytes) => {
|
|
4840
|
+
if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
|
|
4841
|
+
throw (pendingBodyError = maxBodyLengthError());
|
|
4842
|
+
}
|
|
4843
|
+
onProgress && onProgress(loadedBytes);
|
|
4844
|
+
},
|
|
4845
|
+
flush
|
|
4846
|
+
);
|
|
4847
|
+
|
|
4501
4848
|
if (
|
|
4502
|
-
onUploadProgress &&
|
|
4503
4849
|
supportsRequestStream &&
|
|
4504
4850
|
method !== 'get' &&
|
|
4505
4851
|
method !== 'head' &&
|
|
4506
|
-
(
|
|
4852
|
+
(onUploadProgress || mustEnforceStreamBody)
|
|
4507
4853
|
) {
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4854
|
+
requestContentLength =
|
|
4855
|
+
requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
|
|
4856
|
+
|
|
4857
|
+
// A declared length of 0 is only trusted to skip the wrap when we are
|
|
4858
|
+
// not enforcing a stream limit (which must not rely on that header).
|
|
4859
|
+
if (requestContentLength !== 0 || mustEnforceStreamBody) {
|
|
4860
|
+
let _request = new Request(url, {
|
|
4861
|
+
method: 'POST',
|
|
4862
|
+
body: data,
|
|
4863
|
+
duplex: 'half',
|
|
4864
|
+
});
|
|
4513
4865
|
|
|
4514
|
-
|
|
4866
|
+
let contentTypeHeader;
|
|
4515
4867
|
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4868
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
4869
|
+
headers.setContentType(contentTypeHeader);
|
|
4870
|
+
}
|
|
4519
4871
|
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4872
|
+
if (_request.body) {
|
|
4873
|
+
const [onProgress, flush] =
|
|
4874
|
+
(onUploadProgress &&
|
|
4875
|
+
progressEventDecorator(
|
|
4876
|
+
requestContentLength,
|
|
4877
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
4878
|
+
)) ||
|
|
4879
|
+
[];
|
|
4525
4880
|
|
|
4526
|
-
|
|
4881
|
+
data = trackRequestStream(_request.body, onProgress, flush);
|
|
4882
|
+
}
|
|
4527
4883
|
}
|
|
4884
|
+
} else if (
|
|
4885
|
+
mustEnforceStreamBody &&
|
|
4886
|
+
!isRequestSupported &&
|
|
4887
|
+
isReadableStreamSupported &&
|
|
4888
|
+
method !== 'get' &&
|
|
4889
|
+
method !== 'head'
|
|
4890
|
+
) {
|
|
4891
|
+
data = trackRequestStream(data);
|
|
4892
|
+
} else if (
|
|
4893
|
+
mustEnforceStreamBody &&
|
|
4894
|
+
isRequestSupported &&
|
|
4895
|
+
!supportsRequestStream &&
|
|
4896
|
+
method !== 'get' &&
|
|
4897
|
+
method !== 'head'
|
|
4898
|
+
) {
|
|
4899
|
+
throw new AxiosError(
|
|
4900
|
+
'Stream request bodies are not supported by the current fetch implementation',
|
|
4901
|
+
AxiosError.ERR_NOT_SUPPORT,
|
|
4902
|
+
config,
|
|
4903
|
+
request
|
|
4904
|
+
);
|
|
4528
4905
|
}
|
|
4529
4906
|
|
|
4530
4907
|
if (!utils$1.isString(withCredentials)) {
|
|
@@ -4567,10 +4944,12 @@ const factory = (env) => {
|
|
|
4567
4944
|
? _fetch(request, fetchOptions)
|
|
4568
4945
|
: _fetch(url, resolvedOptions));
|
|
4569
4946
|
|
|
4947
|
+
const responseHeaders = AxiosHeaders.from(response.headers);
|
|
4948
|
+
|
|
4570
4949
|
// Cheap pre-check: if the server honestly declares a content-length that
|
|
4571
4950
|
// already exceeds the cap, reject before we start streaming.
|
|
4572
4951
|
if (hasMaxContentLength) {
|
|
4573
|
-
const declaredLength = utils$1.toFiniteNumber(
|
|
4952
|
+
const declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
4574
4953
|
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
4575
4954
|
throw new AxiosError(
|
|
4576
4955
|
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
@@ -4595,7 +4974,7 @@ const factory = (env) => {
|
|
|
4595
4974
|
options[prop] = response[prop];
|
|
4596
4975
|
});
|
|
4597
4976
|
|
|
4598
|
-
const responseContentLength = utils$1.toFiniteNumber(
|
|
4977
|
+
const responseContentLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
4599
4978
|
|
|
4600
4979
|
const [onProgress, flush] =
|
|
4601
4980
|
(onDownloadProgress &&
|
|
@@ -4686,23 +5065,55 @@ const factory = (env) => {
|
|
|
4686
5065
|
const canceledError = composedSignal.reason;
|
|
4687
5066
|
canceledError.config = config;
|
|
4688
5067
|
request && (canceledError.request = request);
|
|
4689
|
-
err !== canceledError
|
|
5068
|
+
if (err !== canceledError) {
|
|
5069
|
+
// Non-enumerable to match native Error `cause` semantics so loggers
|
|
5070
|
+
// don't recurse into circular fetch internals (see #7205).
|
|
5071
|
+
Object.defineProperty(canceledError, 'cause', {
|
|
5072
|
+
__proto__: null,
|
|
5073
|
+
value: err,
|
|
5074
|
+
writable: true,
|
|
5075
|
+
enumerable: false,
|
|
5076
|
+
configurable: true,
|
|
5077
|
+
});
|
|
5078
|
+
}
|
|
4690
5079
|
throw canceledError;
|
|
4691
5080
|
}
|
|
4692
5081
|
|
|
5082
|
+
// Surface a maxBodyLength violation we raised while the request body was
|
|
5083
|
+
// being streamed. Matching by identity (rather than reading
|
|
5084
|
+
// `err.cause.isAxiosError`) keeps the error deterministic across runtimes
|
|
5085
|
+
// and avoids both prototype-pollution reads and mis-attributing a foreign
|
|
5086
|
+
// AxiosError that merely happened to land in `err.cause`.
|
|
5087
|
+
if (pendingBodyError) {
|
|
5088
|
+
request && !pendingBodyError.request && (pendingBodyError.request = request);
|
|
5089
|
+
throw pendingBodyError;
|
|
5090
|
+
}
|
|
5091
|
+
|
|
5092
|
+
// Re-throw AxiosErrors we raised synchronously (data: URL / content-length
|
|
5093
|
+
// pre-checks, response size enforcement) without re-wrapping them.
|
|
5094
|
+
if (err instanceof AxiosError) {
|
|
5095
|
+
request && !err.request && (err.request = request);
|
|
5096
|
+
throw err;
|
|
5097
|
+
}
|
|
5098
|
+
|
|
4693
5099
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
err && err.response
|
|
4701
|
-
),
|
|
4702
|
-
{
|
|
4703
|
-
cause: err.cause || err,
|
|
4704
|
-
}
|
|
5100
|
+
const networkError = new AxiosError(
|
|
5101
|
+
'Network Error',
|
|
5102
|
+
AxiosError.ERR_NETWORK,
|
|
5103
|
+
config,
|
|
5104
|
+
request,
|
|
5105
|
+
err && err.response
|
|
4705
5106
|
);
|
|
5107
|
+
// Non-enumerable to match native Error `cause` semantics so loggers
|
|
5108
|
+
// don't recurse into circular fetch internals (see #7205).
|
|
5109
|
+
Object.defineProperty(networkError, 'cause', {
|
|
5110
|
+
__proto__: null,
|
|
5111
|
+
value: err.cause || err,
|
|
5112
|
+
writable: true,
|
|
5113
|
+
enumerable: false,
|
|
5114
|
+
configurable: true,
|
|
5115
|
+
});
|
|
5116
|
+
throw networkError;
|
|
4706
5117
|
}
|
|
4707
5118
|
|
|
4708
5119
|
throw AxiosError.from(err, err && err.code, config, request, err && err.response);
|
|
@@ -4840,7 +5251,7 @@ function getAdapter(adapters, config) {
|
|
|
4840
5251
|
|
|
4841
5252
|
throw new AxiosError(
|
|
4842
5253
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
4843
|
-
|
|
5254
|
+
AxiosError.ERR_NOT_SUPPORT
|
|
4844
5255
|
);
|
|
4845
5256
|
}
|
|
4846
5257
|
|
|
@@ -5021,7 +5432,7 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
5021
5432
|
*/
|
|
5022
5433
|
|
|
5023
5434
|
function assertOptions(options, schema, allowUnknown) {
|
|
5024
|
-
if (typeof options !== 'object') {
|
|
5435
|
+
if (typeof options !== 'object' || options === null) {
|
|
5025
5436
|
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
|
5026
5437
|
}
|
|
5027
5438
|
const keys = Object.keys(options);
|
|
@@ -5144,6 +5555,8 @@ class Axios {
|
|
|
5144
5555
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
5145
5556
|
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
5146
5557
|
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
5558
|
+
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
|
|
5559
|
+
validateStatusUndefinedResolves: validators.transitional(validators.boolean),
|
|
5147
5560
|
},
|
|
5148
5561
|
false
|
|
5149
5562
|
);
|
|
@@ -5273,7 +5686,7 @@ class Axios {
|
|
|
5273
5686
|
|
|
5274
5687
|
getUri(config) {
|
|
5275
5688
|
config = mergeConfig(this.defaults, config);
|
|
5276
|
-
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
5689
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
|
|
5277
5690
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
5278
5691
|
}
|
|
5279
5692
|
}
|
|
@@ -5286,7 +5699,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
5286
5699
|
mergeConfig(config || {}, {
|
|
5287
5700
|
method,
|
|
5288
5701
|
url,
|
|
5289
|
-
data: (config
|
|
5702
|
+
data: config && utils$1.hasOwnProp(config, 'data') ? config.data : undefined,
|
|
5290
5703
|
})
|
|
5291
5704
|
);
|
|
5292
5705
|
};
|