axios 1.18.1 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/axios.js +352 -92
- package/dist/axios.min.js +3 -3
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +420 -97
- package/dist/esm/axios.js +420 -97
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +474 -114
- package/index.d.cts +98 -74
- package/index.d.ts +96 -68
- package/lib/adapters/http.js +7 -18
- package/lib/core/Axios.js +24 -6
- package/lib/core/AxiosError.js +33 -2
- package/lib/core/AxiosHeaders.js +124 -1
- package/lib/core/buildFullPath.js +45 -7
- package/lib/core/mergeConfig.js +18 -3
- package/lib/core/setFormDataHeaders.js +27 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/HttpStatusCode.js +1 -0
- package/lib/helpers/combineURLs.js +11 -3
- package/lib/helpers/composeSignals.js +12 -1
- package/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
- package/lib/helpers/formDataToJSON.js +11 -5
- package/lib/helpers/parseHeaders.js +5 -3
- package/lib/helpers/progressEventReducer.js +3 -3
- package/lib/helpers/resolveConfig.js +1 -15
- package/lib/helpers/shouldBypassProxy.js +120 -1
- package/lib/helpers/toFormData.js +3 -2
- package/lib/platform/node/classes/Buffer.js +11 -0
- package/lib/utils.js +17 -5
- package/package.json +21 -19
package/dist/browser/axios.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Axios v1.
|
|
1
|
+
/*! Axios v1.19.0 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -294,6 +294,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
294
294
|
* @returns {boolean} True if value is a FileList, otherwise false
|
|
295
295
|
*/
|
|
296
296
|
const isFileList = kindOfTest('FileList');
|
|
297
|
+
const isSet = kindOfTest('Set');
|
|
297
298
|
|
|
298
299
|
/**
|
|
299
300
|
* Determine if a value is a Stream
|
|
@@ -859,12 +860,23 @@ const toJSONObject = (obj) => {
|
|
|
859
860
|
if (!('toJSON' in source)) {
|
|
860
861
|
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
861
862
|
visited.add(source);
|
|
862
|
-
const target = isArray(source) ? [] : {};
|
|
863
863
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
864
|
+
let target;
|
|
865
|
+
|
|
866
|
+
if (isSet(source)) {
|
|
867
|
+
target = [];
|
|
868
|
+
for (const value of source) {
|
|
869
|
+
const reducedValue = visit(value);
|
|
870
|
+
!isUndefined(reducedValue) && target.push(reducedValue);
|
|
871
|
+
}
|
|
872
|
+
} else {
|
|
873
|
+
target = isArray(source) ? [] : {};
|
|
874
|
+
|
|
875
|
+
forEach(source, (value, key) => {
|
|
876
|
+
const reducedValue = visit(value);
|
|
877
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
878
|
+
});
|
|
879
|
+
}
|
|
868
880
|
|
|
869
881
|
visited.delete(source);
|
|
870
882
|
|
|
@@ -1076,18 +1088,20 @@ var parseHeaders = (rawHeaders) => {
|
|
|
1076
1088
|
key = line.substring(0, i).trim().toLowerCase();
|
|
1077
1089
|
val = line.substring(i + 1).trim();
|
|
1078
1090
|
|
|
1079
|
-
|
|
1091
|
+
const hasKey = utils$1.hasOwnProp(parsed, key);
|
|
1092
|
+
|
|
1093
|
+
if (!key || (hasKey && utils$1.hasOwnProp(ignoreDuplicateOf, key))) {
|
|
1080
1094
|
return;
|
|
1081
1095
|
}
|
|
1082
1096
|
|
|
1083
1097
|
if (key === 'set-cookie') {
|
|
1084
|
-
if (
|
|
1098
|
+
if (hasKey) {
|
|
1085
1099
|
parsed[key].push(val);
|
|
1086
1100
|
} else {
|
|
1087
1101
|
parsed[key] = [val];
|
|
1088
1102
|
}
|
|
1089
1103
|
} else {
|
|
1090
|
-
parsed[key] =
|
|
1104
|
+
parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
|
|
1091
1105
|
}
|
|
1092
1106
|
});
|
|
1093
1107
|
|
|
@@ -1177,6 +1191,124 @@ function parseTokens(str) {
|
|
|
1177
1191
|
return tokens;
|
|
1178
1192
|
}
|
|
1179
1193
|
|
|
1194
|
+
const parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
1195
|
+
|
|
1196
|
+
function trimOWS(value) {
|
|
1197
|
+
let start = 0;
|
|
1198
|
+
let end = value.length;
|
|
1199
|
+
|
|
1200
|
+
while (start < end) {
|
|
1201
|
+
const code = value.charCodeAt(start);
|
|
1202
|
+
|
|
1203
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
start += 1;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
while (end > start) {
|
|
1211
|
+
const code = value.charCodeAt(end - 1);
|
|
1212
|
+
|
|
1213
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
end -= 1;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
function decodeQuotedString(value) {
|
|
1224
|
+
const last = value.length - 1;
|
|
1225
|
+
|
|
1226
|
+
if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
|
|
1227
|
+
return value;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
let decoded = '';
|
|
1231
|
+
|
|
1232
|
+
for (let i = 1; i < last; i++) {
|
|
1233
|
+
const code = value.charCodeAt(i);
|
|
1234
|
+
|
|
1235
|
+
if (code === 0x22) {
|
|
1236
|
+
return value;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
if (code === 0x5c) {
|
|
1240
|
+
i += 1;
|
|
1241
|
+
|
|
1242
|
+
if (i >= last) {
|
|
1243
|
+
return value;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
decoded += value[i];
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
return decoded;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function parseParameters(value) {
|
|
1254
|
+
const parameters = Object.create(null);
|
|
1255
|
+
const str = String(value);
|
|
1256
|
+
let start = 0;
|
|
1257
|
+
let quoted = false;
|
|
1258
|
+
let escaped = false;
|
|
1259
|
+
|
|
1260
|
+
function parseParameter(end) {
|
|
1261
|
+
const part = trimOWS(str.slice(start, end));
|
|
1262
|
+
const equals = part.indexOf('=');
|
|
1263
|
+
|
|
1264
|
+
if (equals < 1) {
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
const name = trimOWS(part.slice(0, equals));
|
|
1269
|
+
|
|
1270
|
+
if (!parameterNameRE.test(name)) {
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
const normalizedName = name.toLowerCase();
|
|
1275
|
+
|
|
1276
|
+
if (
|
|
1277
|
+
normalizedName === '__proto__' ||
|
|
1278
|
+
normalizedName === 'constructor' ||
|
|
1279
|
+
normalizedName === 'prototype'
|
|
1280
|
+
) {
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
const parameterValue = trimOWS(part.slice(equals + 1));
|
|
1285
|
+
parameters[normalizedName] = decodeQuotedString(parameterValue);
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
for (let i = 0; i < str.length; i++) {
|
|
1289
|
+
const code = str.charCodeAt(i);
|
|
1290
|
+
|
|
1291
|
+
if (quoted) {
|
|
1292
|
+
if (escaped) {
|
|
1293
|
+
escaped = false;
|
|
1294
|
+
} else if (code === 0x5c) {
|
|
1295
|
+
escaped = true;
|
|
1296
|
+
} else if (code === 0x22) {
|
|
1297
|
+
quoted = false;
|
|
1298
|
+
}
|
|
1299
|
+
} else if (code === 0x22) {
|
|
1300
|
+
quoted = true;
|
|
1301
|
+
} else if (code === 0x2c || code === 0x3b) {
|
|
1302
|
+
parseParameter(i);
|
|
1303
|
+
start = i + 1;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
parseParameter(str.length);
|
|
1308
|
+
|
|
1309
|
+
return parameters;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1180
1312
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1181
1313
|
|
|
1182
1314
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
@@ -1428,7 +1560,8 @@ class AxiosHeaders {
|
|
|
1428
1560
|
}
|
|
1429
1561
|
|
|
1430
1562
|
getSetCookie() {
|
|
1431
|
-
|
|
1563
|
+
const value = this.get('set-cookie');
|
|
1564
|
+
return utils$1.isArray(value) ? value : value == null || value === false ? [] : [value];
|
|
1432
1565
|
}
|
|
1433
1566
|
|
|
1434
1567
|
get [Symbol.toStringTag]() {
|
|
@@ -1439,6 +1572,10 @@ class AxiosHeaders {
|
|
|
1439
1572
|
return thing instanceof this ? thing : new this(thing);
|
|
1440
1573
|
}
|
|
1441
1574
|
|
|
1575
|
+
static parseParameters(value) {
|
|
1576
|
+
return parseParameters(value);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1442
1579
|
static concat(first, ...targets) {
|
|
1443
1580
|
const computed = new this(first);
|
|
1444
1581
|
|
|
@@ -1564,9 +1701,40 @@ function redactConfig(config, redactKeys) {
|
|
|
1564
1701
|
return visit(config);
|
|
1565
1702
|
}
|
|
1566
1703
|
|
|
1704
|
+
function stringifySafely$1(value) {
|
|
1705
|
+
try {
|
|
1706
|
+
return String(value);
|
|
1707
|
+
} catch (err) {
|
|
1708
|
+
return '';
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
function aggregateErrorMessage(error) {
|
|
1713
|
+
const message = error.errors
|
|
1714
|
+
.map((entry) => {
|
|
1715
|
+
try {
|
|
1716
|
+
return entry && entry.message ? stringifySafely$1(entry.message) : stringifySafely$1(entry);
|
|
1717
|
+
} catch (err) {
|
|
1718
|
+
return '';
|
|
1719
|
+
}
|
|
1720
|
+
})
|
|
1721
|
+
.filter(Boolean)
|
|
1722
|
+
.join('; ');
|
|
1723
|
+
|
|
1724
|
+
return message || error.name || 'AggregateError';
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1567
1727
|
class AxiosError extends Error {
|
|
1568
1728
|
static from(error, code, config, request, response, customProps) {
|
|
1569
|
-
|
|
1729
|
+
// `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
|
|
1730
|
+
// failures) has an empty `message`; its detail lives in `errors[]`. Without
|
|
1731
|
+
// this, the wrapped error surfaces with a blank message (see #6721).
|
|
1732
|
+
let message = error.message;
|
|
1733
|
+
if (!message && utils$1.isArray(error.errors) && error.errors.length) {
|
|
1734
|
+
message = aggregateErrorMessage(error);
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
const axiosError = new AxiosError(message, code || error.code, config, request, response);
|
|
1570
1738
|
// Match native `Error` `cause` semantics: non-enumerable. The wrapped
|
|
1571
1739
|
// error often carries circular internals (sockets, requests, agents), so
|
|
1572
1740
|
// an enumerable `cause` makes structured loggers (pino/winston) and any
|
|
@@ -1821,9 +1989,6 @@ function toFormData(obj, formData, options) {
|
|
|
1821
1989
|
if (useBlob && typeof _Blob === 'function') {
|
|
1822
1990
|
return new _Blob([value]);
|
|
1823
1991
|
}
|
|
1824
|
-
if (typeof Buffer !== 'undefined') {
|
|
1825
|
-
return Buffer.from(value);
|
|
1826
|
-
}
|
|
1827
1992
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.', AxiosError.ERR_NOT_SUPPORT);
|
|
1828
1993
|
}
|
|
1829
1994
|
|
|
@@ -2260,12 +2425,18 @@ function throwIfDepthExceeded(index) {
|
|
|
2260
2425
|
* @returns An array of strings.
|
|
2261
2426
|
*/
|
|
2262
2427
|
function parsePropPath(name) {
|
|
2263
|
-
// foo[x][y][z]
|
|
2264
|
-
// foo.x.y.z
|
|
2265
|
-
//
|
|
2266
|
-
//
|
|
2428
|
+
// foo[x][y][z] -> ['foo', 'x', 'y', 'z']
|
|
2429
|
+
// foo.x.y.z -> ['foo', 'x', 'y', 'z']
|
|
2430
|
+
// A path is split on `.` and on `[...]` groups. A segment — whether written
|
|
2431
|
+
// in dot notation or captured inside brackets — may contain any character
|
|
2432
|
+
// except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
|
|
2433
|
+
// literal instead of being split (#5402). `.`, `[` and `]` keep their existing
|
|
2434
|
+
// meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
|
|
2435
|
+
// Excluding `[` from the bracket group also makes the match fail fast at the
|
|
2436
|
+
// next `[`, so a malformed name cannot rescan to the end of the string from
|
|
2437
|
+
// every unmatched `[` — parsing stays linear in the length of the name.
|
|
2267
2438
|
const path = [];
|
|
2268
|
-
const pattern =
|
|
2439
|
+
const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
|
|
2269
2440
|
let match;
|
|
2270
2441
|
|
|
2271
2442
|
while ((match = pattern.exec(name)) !== null) {
|
|
@@ -2697,7 +2868,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2697
2868
|
}
|
|
2698
2869
|
const rawLoaded = e.loaded;
|
|
2699
2870
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2700
|
-
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
2871
|
+
const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
|
|
2701
2872
|
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
2702
2873
|
const rate = _speedometer(progressBytes);
|
|
2703
2874
|
|
|
@@ -2734,9 +2905,9 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
2734
2905
|
};
|
|
2735
2906
|
|
|
2736
2907
|
const asyncDecorator =
|
|
2737
|
-
(fn) =>
|
|
2908
|
+
(fn, scheduler = utils$1.asap) =>
|
|
2738
2909
|
(...args) =>
|
|
2739
|
-
|
|
2910
|
+
scheduler(() => fn(...args));
|
|
2740
2911
|
|
|
2741
2912
|
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2742
2913
|
? ((origin, isMSIE) => (url) => {
|
|
@@ -2842,9 +3013,17 @@ function isAbsoluteURL(url) {
|
|
|
2842
3013
|
* @returns {string} The combined URL
|
|
2843
3014
|
*/
|
|
2844
3015
|
function combineURLs(baseURL, relativeURL) {
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
3016
|
+
if (!relativeURL) {
|
|
3017
|
+
return baseURL;
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
let end = baseURL.length;
|
|
3021
|
+
|
|
3022
|
+
while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
|
|
3023
|
+
end--;
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
|
|
2848
3027
|
}
|
|
2849
3028
|
|
|
2850
3029
|
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
@@ -2862,13 +3041,51 @@ function normalizeURLForProtocolCheck(url) {
|
|
|
2862
3041
|
return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
|
|
2863
3042
|
}
|
|
2864
3043
|
|
|
3044
|
+
// Redact the parts of a URL that can carry secrets before it is embedded in an
|
|
3045
|
+
// error message. AxiosError.toJSON() serializes `message` verbatim and errors
|
|
3046
|
+
// are commonly logged, while the opt-in `config.redact` model only cleans
|
|
3047
|
+
// config keys — it cannot reach the message. Redact only the genuinely
|
|
3048
|
+
// sensitive substrings — userinfo (credentials), query parameter values and
|
|
3049
|
+
// fragment contents — with the same REDACTED marker the config redaction uses,
|
|
3050
|
+
// while keeping the scheme, host, path and parameter names so the offending
|
|
3051
|
+
// request stays accurately identifiable.
|
|
3052
|
+
function redactFragment(fragment) {
|
|
3053
|
+
if (!fragment) {
|
|
3054
|
+
return fragment;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = '') => {
|
|
3058
|
+
return `${separator}${parameterName}${REDACTED}`;
|
|
3059
|
+
});
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
function redactSensitiveURLParts(url) {
|
|
3063
|
+
const redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
|
|
3064
|
+
const fragmentIndex = redactedURL.indexOf('#');
|
|
3065
|
+
const urlWithoutFragment =
|
|
3066
|
+
fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
|
|
3067
|
+
const redactedURLWithoutFragment = urlWithoutFragment.replace(
|
|
3068
|
+
/([?&][^=&#]*=)[^&#]*/g,
|
|
3069
|
+
`$1${REDACTED}`
|
|
3070
|
+
);
|
|
3071
|
+
|
|
3072
|
+
if (fragmentIndex === -1) {
|
|
3073
|
+
return redactedURLWithoutFragment;
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
|
|
3077
|
+
}
|
|
3078
|
+
|
|
2865
3079
|
function assertValidHttpProtocolURL(url, config) {
|
|
2866
|
-
if (typeof url === 'string'
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
AxiosError
|
|
2870
|
-
|
|
2871
|
-
|
|
3080
|
+
if (typeof url === 'string') {
|
|
3081
|
+
const normalizedURL = normalizeURLForProtocolCheck(url);
|
|
3082
|
+
if (malformedHttpProtocol.test(normalizedURL)) {
|
|
3083
|
+
throw new AxiosError(
|
|
3084
|
+
`Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
|
|
3085
|
+
AxiosError.ERR_INVALID_URL,
|
|
3086
|
+
config
|
|
3087
|
+
);
|
|
3088
|
+
}
|
|
2872
3089
|
}
|
|
2873
3090
|
}
|
|
2874
3091
|
|
|
@@ -2894,6 +3111,17 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
|
2894
3111
|
|
|
2895
3112
|
const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing } : thing);
|
|
2896
3113
|
|
|
3114
|
+
const ownEnumerableKeys = (thing) => {
|
|
3115
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
3116
|
+
return Object.keys(thing).concat(
|
|
3117
|
+
Object.getOwnPropertySymbols(thing).filter(
|
|
3118
|
+
(symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
|
|
3119
|
+
)
|
|
3120
|
+
);
|
|
3121
|
+
}
|
|
3122
|
+
return Object.keys(thing);
|
|
3123
|
+
};
|
|
3124
|
+
|
|
2897
3125
|
/**
|
|
2898
3126
|
* Config-specific merge-function which creates a new config-object
|
|
2899
3127
|
* by merging two configuration objects together.
|
|
@@ -2959,7 +3187,9 @@ function mergeConfig(config1, config2) {
|
|
|
2959
3187
|
}
|
|
2960
3188
|
|
|
2961
3189
|
function getMergedTransitionalOption(prop) {
|
|
2962
|
-
const transitional2 = utils$1.hasOwnProp(config2, 'transitional')
|
|
3190
|
+
const transitional2 = utils$1.hasOwnProp(config2, 'transitional')
|
|
3191
|
+
? config2.transitional
|
|
3192
|
+
: undefined;
|
|
2963
3193
|
|
|
2964
3194
|
if (!utils$1.isUndefined(transitional2)) {
|
|
2965
3195
|
if (utils$1.isPlainObject(transitional2)) {
|
|
@@ -2971,7 +3201,9 @@ function mergeConfig(config1, config2) {
|
|
|
2971
3201
|
}
|
|
2972
3202
|
}
|
|
2973
3203
|
|
|
2974
|
-
const transitional1 = utils$1.hasOwnProp(config1, 'transitional')
|
|
3204
|
+
const transitional1 = utils$1.hasOwnProp(config1, 'transitional')
|
|
3205
|
+
? config1.transitional
|
|
3206
|
+
: undefined;
|
|
2975
3207
|
|
|
2976
3208
|
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
2977
3209
|
return transitional1[prop];
|
|
@@ -3023,7 +3255,7 @@ function mergeConfig(config1, config2) {
|
|
|
3023
3255
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
3024
3256
|
};
|
|
3025
3257
|
|
|
3026
|
-
utils$1.forEach(
|
|
3258
|
+
utils$1.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
3027
3259
|
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
3028
3260
|
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
3029
3261
|
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
@@ -3049,6 +3281,17 @@ function mergeConfig(config1, config2) {
|
|
|
3049
3281
|
|
|
3050
3282
|
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
3051
3283
|
|
|
3284
|
+
/**
|
|
3285
|
+
* Apply the headers generated by a FormData implementation to the request headers,
|
|
3286
|
+
* honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
|
|
3287
|
+
* content-* headers; otherwise merge all of them.
|
|
3288
|
+
*
|
|
3289
|
+
* @param {AxiosHeaders} headers - the request headers to mutate
|
|
3290
|
+
* @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
|
|
3291
|
+
* @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
|
|
3292
|
+
*
|
|
3293
|
+
* @returns {void}
|
|
3294
|
+
*/
|
|
3052
3295
|
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
3053
3296
|
if (policy !== 'content-only') {
|
|
3054
3297
|
headers.set(formHeaders);
|
|
@@ -3415,7 +3658,18 @@ const composeSignals = (signals, timeout) => {
|
|
|
3415
3658
|
signals = null;
|
|
3416
3659
|
};
|
|
3417
3660
|
|
|
3418
|
-
signals.forEach((signal) =>
|
|
3661
|
+
signals.forEach((signal) => {
|
|
3662
|
+
if (aborted) {
|
|
3663
|
+
return;
|
|
3664
|
+
}
|
|
3665
|
+
|
|
3666
|
+
if (signal.aborted) {
|
|
3667
|
+
onabort.call(signal);
|
|
3668
|
+
return;
|
|
3669
|
+
}
|
|
3670
|
+
|
|
3671
|
+
signal.addEventListener('abort', onabort, { once: true });
|
|
3672
|
+
});
|
|
3419
3673
|
|
|
3420
3674
|
const { signal } = controller;
|
|
3421
3675
|
|
|
@@ -3515,13 +3769,11 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3515
3769
|
};
|
|
3516
3770
|
|
|
3517
3771
|
/**
|
|
3518
|
-
* Estimate
|
|
3519
|
-
* -
|
|
3520
|
-
*
|
|
3521
|
-
*
|
|
3522
|
-
*
|
|
3523
|
-
* @param {string} url
|
|
3524
|
-
* @returns {number}
|
|
3772
|
+
* Estimate data: URL byte lengths *without* allocating large buffers.
|
|
3773
|
+
* - Fetch percent-decodes a base64 body before decoding it.
|
|
3774
|
+
* - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
|
|
3775
|
+
* raw body, including ignored characters and content after padding.
|
|
3776
|
+
* - Non-base64 data is percent-decoded and then encoded as UTF-8.
|
|
3525
3777
|
*/
|
|
3526
3778
|
const isHexDigit = (charCode) =>
|
|
3527
3779
|
(charCode >= 48 && charCode <= 57) ||
|
|
@@ -3531,7 +3783,89 @@ const isHexDigit = (charCode) =>
|
|
|
3531
3783
|
const isPercentEncodedByte = (str, i, len) =>
|
|
3532
3784
|
i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
3533
3785
|
|
|
3534
|
-
|
|
3786
|
+
const hexValue = (charCode) => (charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55);
|
|
3787
|
+
|
|
3788
|
+
const isBase64Char = (charCode) =>
|
|
3789
|
+
(charCode >= 65 && charCode <= 90) || // A-Z
|
|
3790
|
+
(charCode >= 97 && charCode <= 122) || // a-z
|
|
3791
|
+
(charCode >= 48 && charCode <= 57) || // 0-9
|
|
3792
|
+
charCode === 43 || // +
|
|
3793
|
+
charCode === 47 || // /
|
|
3794
|
+
charCode === 45 || // - (base64url)
|
|
3795
|
+
charCode === 95; // _ (base64url)
|
|
3796
|
+
|
|
3797
|
+
const isBase64Whitespace = (charCode) =>
|
|
3798
|
+
charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
|
|
3799
|
+
|
|
3800
|
+
const base64Bytes = (significant) => {
|
|
3801
|
+
const groups = Math.floor(significant / 4);
|
|
3802
|
+
const remainder = significant % 4;
|
|
3803
|
+
return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
|
|
3804
|
+
};
|
|
3805
|
+
|
|
3806
|
+
// Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
|
|
3807
|
+
// upper bound even when Buffer.from later ignores characters or stops at '='.
|
|
3808
|
+
const estimateBase64BufferAllocation = (body) => {
|
|
3809
|
+
const len = body.length;
|
|
3810
|
+
let padding = 0;
|
|
3811
|
+
|
|
3812
|
+
if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
|
|
3813
|
+
padding++;
|
|
3814
|
+
|
|
3815
|
+
if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
|
|
3816
|
+
padding++;
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
|
|
3820
|
+
return Math.floor(((len - padding) * 3) / 4);
|
|
3821
|
+
};
|
|
3822
|
+
|
|
3823
|
+
const estimatePercentDecodedBase64Bytes = (body) => {
|
|
3824
|
+
const len = body.length;
|
|
3825
|
+
let significant = 0;
|
|
3826
|
+
let padding = 0;
|
|
3827
|
+
let invalid = false;
|
|
3828
|
+
|
|
3829
|
+
for (let i = 0; i < len; i++) {
|
|
3830
|
+
let code = body.charCodeAt(i);
|
|
3831
|
+
|
|
3832
|
+
if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
3833
|
+
code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
|
|
3834
|
+
i += 2;
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
if (isBase64Whitespace(code)) {
|
|
3838
|
+
continue;
|
|
3839
|
+
}
|
|
3840
|
+
|
|
3841
|
+
if (code === 61 /* '=' */) {
|
|
3842
|
+
padding++;
|
|
3843
|
+
continue;
|
|
3844
|
+
}
|
|
3845
|
+
|
|
3846
|
+
if (!isBase64Char(code) || padding > 0) {
|
|
3847
|
+
invalid = true;
|
|
3848
|
+
continue;
|
|
3849
|
+
}
|
|
3850
|
+
|
|
3851
|
+
significant++;
|
|
3852
|
+
}
|
|
3853
|
+
|
|
3854
|
+
// Fetch rejects malformed forgiving-base64 input. Returning the raw-size
|
|
3855
|
+
// allocation bound keeps that invalid input from becoming a pre-check bypass.
|
|
3856
|
+
if (
|
|
3857
|
+
invalid ||
|
|
3858
|
+
padding > 2 ||
|
|
3859
|
+
(padding > 0 && (significant + padding) % 4 !== 0) ||
|
|
3860
|
+
significant % 4 === 1
|
|
3861
|
+
) {
|
|
3862
|
+
return estimateBase64BufferAllocation(body);
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
return base64Bytes(significant);
|
|
3866
|
+
};
|
|
3867
|
+
|
|
3868
|
+
const estimateDataURLBytes = (url, estimateBase64) => {
|
|
3535
3869
|
if (!url || typeof url !== 'string') return 0;
|
|
3536
3870
|
if (!url.startsWith('data:')) return 0;
|
|
3537
3871
|
|
|
@@ -3543,52 +3877,7 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
3543
3877
|
const isBase64 = /;base64/i.test(meta);
|
|
3544
3878
|
|
|
3545
3879
|
if (isBase64) {
|
|
3546
|
-
|
|
3547
|
-
const len = body.length; // cache length
|
|
3548
|
-
|
|
3549
|
-
for (let i = 0; i < len; i++) {
|
|
3550
|
-
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
3551
|
-
const a = body.charCodeAt(i + 1);
|
|
3552
|
-
const b = body.charCodeAt(i + 2);
|
|
3553
|
-
const isHex = isHexDigit(a) && isHexDigit(b);
|
|
3554
|
-
|
|
3555
|
-
if (isHex) {
|
|
3556
|
-
effectiveLen -= 2;
|
|
3557
|
-
i += 2;
|
|
3558
|
-
}
|
|
3559
|
-
}
|
|
3560
|
-
}
|
|
3561
|
-
|
|
3562
|
-
let pad = 0;
|
|
3563
|
-
let idx = len - 1;
|
|
3564
|
-
|
|
3565
|
-
const tailIsPct3D = (j) =>
|
|
3566
|
-
j >= 2 &&
|
|
3567
|
-
body.charCodeAt(j - 2) === 37 && // '%'
|
|
3568
|
-
body.charCodeAt(j - 1) === 51 && // '3'
|
|
3569
|
-
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
|
|
3570
|
-
|
|
3571
|
-
if (idx >= 0) {
|
|
3572
|
-
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
3573
|
-
pad++;
|
|
3574
|
-
idx--;
|
|
3575
|
-
} else if (tailIsPct3D(idx)) {
|
|
3576
|
-
pad++;
|
|
3577
|
-
idx -= 3;
|
|
3578
|
-
}
|
|
3579
|
-
}
|
|
3580
|
-
|
|
3581
|
-
if (pad === 1 && idx >= 0) {
|
|
3582
|
-
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
3583
|
-
pad++;
|
|
3584
|
-
} else if (tailIsPct3D(idx)) {
|
|
3585
|
-
pad++;
|
|
3586
|
-
}
|
|
3587
|
-
}
|
|
3588
|
-
|
|
3589
|
-
const groups = Math.floor(effectiveLen / 4);
|
|
3590
|
-
const bytes = groups * 3 - (pad || 0);
|
|
3591
|
-
return bytes > 0 ? bytes : 0;
|
|
3880
|
+
return estimateBase64(body);
|
|
3592
3881
|
}
|
|
3593
3882
|
|
|
3594
3883
|
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
@@ -3618,9 +3907,25 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
3618
3907
|
}
|
|
3619
3908
|
}
|
|
3620
3909
|
return bytes;
|
|
3910
|
+
};
|
|
3911
|
+
|
|
3912
|
+
/**
|
|
3913
|
+
* Estimate the percent-decoded payload size used by Fetch data: URLs.
|
|
3914
|
+
*
|
|
3915
|
+
* @param {string} url
|
|
3916
|
+
* @returns {number}
|
|
3917
|
+
*/
|
|
3918
|
+
function estimateDataURLDecodedBytes(url) {
|
|
3919
|
+
// Fetch removes URL fragments before processing a data: URL.
|
|
3920
|
+
const fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
|
|
3921
|
+
|
|
3922
|
+
return estimateDataURLBytes(
|
|
3923
|
+
fragmentIndex === -1 ? url : url.slice(0, fragmentIndex),
|
|
3924
|
+
estimatePercentDecodedBase64Bytes
|
|
3925
|
+
);
|
|
3621
3926
|
}
|
|
3622
3927
|
|
|
3623
|
-
const VERSION = "1.
|
|
3928
|
+
const VERSION = "1.19.0";
|
|
3624
3929
|
|
|
3625
3930
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3626
3931
|
|
|
@@ -4760,17 +5065,35 @@ class Axios {
|
|
|
4760
5065
|
const onFulfilled = requestInterceptorChain[i++];
|
|
4761
5066
|
const onRejected = requestInterceptorChain[i++];
|
|
4762
5067
|
try {
|
|
4763
|
-
newConfig = onFulfilled(newConfig);
|
|
5068
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
4764
5069
|
} catch (error) {
|
|
4765
|
-
onRejected
|
|
5070
|
+
if (!onRejected) {
|
|
5071
|
+
promise = Promise.reject(error);
|
|
5072
|
+
break;
|
|
5073
|
+
}
|
|
5074
|
+
|
|
5075
|
+
try {
|
|
5076
|
+
const rejectedResult = onRejected.call(this, error);
|
|
5077
|
+
|
|
5078
|
+
if (utils$1.isThenable(rejectedResult)) {
|
|
5079
|
+
promise = Promise.resolve(rejectedResult).then(() =>
|
|
5080
|
+
dispatchRequest.call(this, newConfig)
|
|
5081
|
+
);
|
|
5082
|
+
}
|
|
5083
|
+
} catch (rejectedError) {
|
|
5084
|
+
promise = Promise.reject(rejectedError);
|
|
5085
|
+
}
|
|
5086
|
+
|
|
4766
5087
|
break;
|
|
4767
5088
|
}
|
|
4768
5089
|
}
|
|
4769
5090
|
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
5091
|
+
if (!promise) {
|
|
5092
|
+
try {
|
|
5093
|
+
promise = dispatchRequest.call(this, newConfig);
|
|
5094
|
+
} catch (error) {
|
|
5095
|
+
promise = Promise.reject(error);
|
|
5096
|
+
}
|
|
4774
5097
|
}
|
|
4775
5098
|
|
|
4776
5099
|
i = 0;
|
|
@@ -5063,6 +5386,7 @@ const HttpStatusCode = {
|
|
|
5063
5386
|
LoopDetected: 508,
|
|
5064
5387
|
NotExtended: 510,
|
|
5065
5388
|
NetworkAuthenticationRequired: 511,
|
|
5389
|
+
WebServerReturnsAnUnknownError: 520,
|
|
5066
5390
|
WebServerIsDown: 521,
|
|
5067
5391
|
ConnectionTimedOut: 522,
|
|
5068
5392
|
OriginIsUnreachable: 523,
|
|
@@ -5143,4 +5467,3 @@ axios.HttpStatusCode = HttpStatusCode;
|
|
|
5143
5467
|
axios.default = axios;
|
|
5144
5468
|
|
|
5145
5469
|
module.exports = axios;
|
|
5146
|
-
//# sourceMappingURL=axios.cjs.map
|