axios 0.34.0 → 0.36.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 +4 -0
- package/dist/axios.js +258 -30
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/esm/axios.js +258 -30
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/lib/adapters/http.js +191 -36
- package/lib/core/Axios.js +29 -14
- package/lib/core/InterceptorManager.js +2 -2
- package/lib/core/mergeConfig.js +3 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/assertParamsDepth.js +100 -0
- package/lib/helpers/combineURLs.js +15 -3
- package/lib/helpers/estimateDataURLDecodedBytes.js +3 -3
- package/lib/helpers/formDataToJSON.js +40 -3
- package/lib/helpers/getDirectAgent.js +85 -0
- package/lib/helpers/proxyFromEnv.js +152 -0
- package/lib/helpers/shouldBypassProxy.js +17 -1
- package/lib/helpers/toFormData.js +4 -4
- package/lib/utils.js +68 -2
- package/package.json +17 -18
package/README.md
CHANGED
|
@@ -476,6 +476,10 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
476
476
|
// Use this when config can include partially user-controlled input.
|
|
477
477
|
// Set to a string or array of strings. An empty array denies all socket paths.
|
|
478
478
|
// Set to `null` on a request to clear an instance-level allowlist.
|
|
479
|
+
// Paths are compared after resolving `.` and `..` segments (symlinks are not
|
|
480
|
+
// followed), and the request connects to that normalized path, so `..` cannot
|
|
481
|
+
// step out through a symlinked directory. Windows named pipes and Linux
|
|
482
|
+
// abstract socket names (leading `\0`) are compared exactly as given.
|
|
479
483
|
allowedSocketPaths: null, // default
|
|
480
484
|
|
|
481
485
|
// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
|
package/dist/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.36.0 Copyright (c) 2026 Matt Zabriskie
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -517,10 +517,75 @@
|
|
|
517
517
|
if (!thing) return null;
|
|
518
518
|
if (isArray(thing)) return thing;
|
|
519
519
|
var i = thing.length;
|
|
520
|
-
if (
|
|
520
|
+
if (typeof i !== 'number' || i < 0 || i > 0xffffffff || Math.floor(i) !== i) return null;
|
|
521
|
+
|
|
522
|
+
// Legacy FileList hosts expose indexed reads without reflecting their keys.
|
|
523
|
+
if (isFileList(thing)) {
|
|
524
|
+
var files = [];
|
|
525
|
+
while (i-- > 0) {
|
|
526
|
+
var file = thing[i];
|
|
527
|
+
if (file === null || isUndefined(file)) return null;
|
|
528
|
+
defineOwnProperty(files, i, file);
|
|
529
|
+
}
|
|
530
|
+
return files;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Count actual indexes, including hidden collection properties, before
|
|
534
|
+
// allocating from the declared length. Box primitives for ES5 object APIs.
|
|
535
|
+
var source = Object(thing);
|
|
536
|
+
var indexes = Object.create(null);
|
|
537
|
+
var count = 0;
|
|
538
|
+
var seen = [];
|
|
539
|
+
var owns = Object.prototype.hasOwnProperty;
|
|
540
|
+
|
|
541
|
+
while (source && count < i) {
|
|
542
|
+
if (seen.indexOf(source) !== -1) return null;
|
|
543
|
+
defineOwnProperty(seen, seen.length, source);
|
|
544
|
+
|
|
545
|
+
if (source === Object.prototype) break;
|
|
546
|
+
|
|
547
|
+
var prototype = Object.getPrototypeOf(source);
|
|
548
|
+
if (prototype === null) {
|
|
549
|
+
var constructorDescriptor = Object.getOwnPropertyDescriptor(source, 'constructor');
|
|
550
|
+
var constructorValue = constructorDescriptor && owns.call(constructorDescriptor, 'value') &&
|
|
551
|
+
constructorDescriptor.value;
|
|
552
|
+
var constructorPrototype = typeof constructorValue === 'function' &&
|
|
553
|
+
Object.getOwnPropertyDescriptor(constructorValue, 'prototype');
|
|
554
|
+
|
|
555
|
+
// Recognize another realm's Object.prototype without excluding
|
|
556
|
+
// application-defined null-prototype parents or invoking accessors.
|
|
557
|
+
if (
|
|
558
|
+
constructorPrototype && owns.call(constructorPrototype, 'value') &&
|
|
559
|
+
constructorPrototype.value === source &&
|
|
560
|
+
Function.prototype.toString.call(constructorValue) === Function.prototype.toString.call(Object)
|
|
561
|
+
) {
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
var keys = Object.getOwnPropertyNames(source);
|
|
567
|
+
for (var j = 0; j < keys.length; j++) {
|
|
568
|
+
var key = keys[j];
|
|
569
|
+
var index = +key;
|
|
570
|
+
if (
|
|
571
|
+
index >= 0 &&
|
|
572
|
+
index < i &&
|
|
573
|
+
Math.floor(index) === index &&
|
|
574
|
+
String(index) === key &&
|
|
575
|
+
owns.call(source, key) &&
|
|
576
|
+
!indexes[key]
|
|
577
|
+
) {
|
|
578
|
+
indexes[key] = true;
|
|
579
|
+
count++;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
source = prototype;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (count !== i) return null;
|
|
521
586
|
var arr = new Array(i);
|
|
522
587
|
while (i-- > 0) {
|
|
523
|
-
arr
|
|
588
|
+
defineOwnProperty(arr, i, thing[i]);
|
|
524
589
|
}
|
|
525
590
|
return arr;
|
|
526
591
|
}
|
|
@@ -590,6 +655,7 @@
|
|
|
590
655
|
trim: trim,
|
|
591
656
|
stripBOM: stripBOM,
|
|
592
657
|
inherits: inherits,
|
|
658
|
+
defineOwnProperty: defineOwnProperty,
|
|
593
659
|
toFlatObject: toFlatObject,
|
|
594
660
|
kindOf: kindOf,
|
|
595
661
|
kindOfTest: kindOfTest,
|
|
@@ -911,7 +977,7 @@
|
|
|
911
977
|
return;
|
|
912
978
|
}
|
|
913
979
|
|
|
914
|
-
stack.
|
|
980
|
+
utils.defineOwnProperty(stack, stack.length, value);
|
|
915
981
|
|
|
916
982
|
utils.forEach(value, function each(el) {
|
|
917
983
|
assertValueDepth(el, depth + 1);
|
|
@@ -940,8 +1006,8 @@
|
|
|
940
1006
|
value = JSON.stringify(value);
|
|
941
1007
|
} else if (
|
|
942
1008
|
(utils.isArray(value) && isFlatArray(value)) ||
|
|
943
|
-
(utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
|
|
944
|
-
|
|
1009
|
+
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)))
|
|
1010
|
+
) {
|
|
945
1011
|
// eslint-disable-next-line no-param-reassign
|
|
946
1012
|
key = removeBrackets(key);
|
|
947
1013
|
|
|
@@ -988,7 +1054,7 @@
|
|
|
988
1054
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
989
1055
|
}
|
|
990
1056
|
|
|
991
|
-
stack.
|
|
1057
|
+
utils.defineOwnProperty(stack, stack.length, value);
|
|
992
1058
|
|
|
993
1059
|
utils.forEach(value, function each(el, key) {
|
|
994
1060
|
var result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
|
@@ -1136,8 +1202,8 @@
|
|
|
1136
1202
|
this.handlers.push({
|
|
1137
1203
|
fulfilled: fulfilled,
|
|
1138
1204
|
rejected: rejected,
|
|
1139
|
-
synchronous: options ? options.synchronous : false,
|
|
1140
|
-
runWhen: options ? options.runWhen : null
|
|
1205
|
+
synchronous: options && utils.hasOwnProperty(options, 'synchronous') ? options.synchronous : false,
|
|
1206
|
+
runWhen: options && utils.hasOwnProperty(options, 'runWhen') ? options.runWhen : null
|
|
1141
1207
|
});
|
|
1142
1208
|
return this.handlers.length - 1;
|
|
1143
1209
|
};
|
|
@@ -1260,13 +1326,50 @@
|
|
|
1260
1326
|
return obj;
|
|
1261
1327
|
}
|
|
1262
1328
|
|
|
1329
|
+
function normalizeArray(value) {
|
|
1330
|
+
if (!utils.isArray(value)) return value;
|
|
1331
|
+
|
|
1332
|
+
var keys = Object.keys(value);
|
|
1333
|
+
if (keys.length !== value.length) return arrayToObject(value);
|
|
1334
|
+
|
|
1335
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1336
|
+
var index = +keys[i];
|
|
1337
|
+
if (
|
|
1338
|
+
index < 0 || index >= value.length ||
|
|
1339
|
+
Math.floor(index) !== index || String(index) !== keys[i]
|
|
1340
|
+
) {
|
|
1341
|
+
return arrayToObject(value);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
return value;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
function normalizeArrays(obj) {
|
|
1349
|
+
var pending = [obj];
|
|
1350
|
+
function normalizeEntry(target, key) {
|
|
1351
|
+
var value = target[key] = normalizeArray(target[key]);
|
|
1352
|
+
if (utils.isArray(value) || utils.isPlainObject(value)) {
|
|
1353
|
+
pending.push(value);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
while (pending.length) {
|
|
1357
|
+
var target = pending.pop();
|
|
1358
|
+
var keys = Object.keys(target);
|
|
1359
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1360
|
+
normalizeEntry(target, keys[i]);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
return obj;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1263
1366
|
function formDataToJSON(formData) {
|
|
1264
1367
|
function buildPath(path, value, target, index) {
|
|
1265
1368
|
var name = path[index++];
|
|
1266
1369
|
|
|
1267
1370
|
if (name === '__proto__') return true;
|
|
1268
1371
|
|
|
1269
|
-
var isNumericKey =
|
|
1372
|
+
var isNumericKey = isFinite(+name);
|
|
1270
1373
|
var isLast = index >= path.length;
|
|
1271
1374
|
name = !name && utils.isArray(target) ? target.length : name;
|
|
1272
1375
|
|
|
@@ -1280,7 +1383,7 @@
|
|
|
1280
1383
|
return !isNumericKey;
|
|
1281
1384
|
}
|
|
1282
1385
|
|
|
1283
|
-
if (!target
|
|
1386
|
+
if (!utils.hasOwnProperty(target, name) || !utils.isObject(target[name])) {
|
|
1284
1387
|
target[name] = [];
|
|
1285
1388
|
}
|
|
1286
1389
|
|
|
@@ -1303,7 +1406,7 @@
|
|
|
1303
1406
|
buildPath(path, value, obj, 0);
|
|
1304
1407
|
});
|
|
1305
1408
|
|
|
1306
|
-
return obj;
|
|
1409
|
+
return normalizeArrays(obj);
|
|
1307
1410
|
}
|
|
1308
1411
|
|
|
1309
1412
|
return null;
|
|
@@ -1417,9 +1520,21 @@
|
|
|
1417
1520
|
* @returns {string} The combined URL
|
|
1418
1521
|
*/
|
|
1419
1522
|
var combineURLs = function combineURLs(baseURL, relativeURL) {
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1523
|
+
if (!relativeURL) {
|
|
1524
|
+
return baseURL;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
var base = baseURL.replace(/\/?\/$/, '');
|
|
1528
|
+
|
|
1529
|
+
if (/^\/*$/.test(base)) {
|
|
1530
|
+
// A base made only of slashes points at the root of the current origin.
|
|
1531
|
+
// Drop leading slashes, backslashes, tabs and newlines from the relative
|
|
1532
|
+
// URL as well: URL parsers ignore tabs and newlines and treat '\' as '/',
|
|
1533
|
+
// so leaving them would turn the result into a protocol-relative URL.
|
|
1534
|
+
return '/' + relativeURL.replace(/^[\/\\\t\n\r]+/, '');
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
return base + '/' + relativeURL.replace(/^\/+/, '');
|
|
1423
1538
|
};
|
|
1424
1539
|
|
|
1425
1540
|
/**
|
|
@@ -2197,6 +2312,102 @@
|
|
|
2197
2312
|
});
|
|
2198
2313
|
};
|
|
2199
2314
|
|
|
2315
|
+
// Match numeric array reads without scanning unoccupied slots or metadata.
|
|
2316
|
+
function arrayIndexes(array) {
|
|
2317
|
+
var length = array.length;
|
|
2318
|
+
var indexes = Object.create(null);
|
|
2319
|
+
var keys = [];
|
|
2320
|
+
var source = array;
|
|
2321
|
+
var fast = array;
|
|
2322
|
+
while (source) {
|
|
2323
|
+
var names = Object.getOwnPropertyNames(source);
|
|
2324
|
+
for (var i = 0; i < names.length; i++) {
|
|
2325
|
+
var key = names[i];
|
|
2326
|
+
var index = +key;
|
|
2327
|
+
if (index >= 0 && index < length && Math.floor(index) === index &&
|
|
2328
|
+
String(index) === key && !indexes[key]) {
|
|
2329
|
+
indexes[key] = true;
|
|
2330
|
+
keys.push(key);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
source = Object.getPrototypeOf(source);
|
|
2334
|
+
// Detect unusual cyclic prototype chains with constant memory.
|
|
2335
|
+
fast = fast && Object.getPrototypeOf(fast);
|
|
2336
|
+
fast = fast && Object.getPrototypeOf(fast);
|
|
2337
|
+
if (source && source === fast) {
|
|
2338
|
+
throw new AxiosError_1('Circular prototype chain in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
return keys.sort(function(a, b) { return a - b; });
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
var assertParamsDepth = function assertParamsDepth(params) {
|
|
2345
|
+
if (!utils.isObject(params)) return;
|
|
2346
|
+
var pending = [{ value: params, depth: 0, complete: false }];
|
|
2347
|
+
var ancestors = [];
|
|
2348
|
+
var visited = null;
|
|
2349
|
+
if (typeof WeakMap === 'function') {
|
|
2350
|
+
visited = new WeakMap();
|
|
2351
|
+
} else if (typeof Map === 'function') {
|
|
2352
|
+
visited = new Map();
|
|
2353
|
+
}
|
|
2354
|
+
// Older runtimes can only compare immutable object identities by scanning.
|
|
2355
|
+
// Keep that scan bounded; recently completed subgraphs avoid repeated work,
|
|
2356
|
+
// while evicted shared subgraphs may be visited again.
|
|
2357
|
+
var cacheSize = 128;
|
|
2358
|
+
var visitedValues = [];
|
|
2359
|
+
var visitedDepths = [];
|
|
2360
|
+
var nextCacheIndex = 0;
|
|
2361
|
+
while (pending.length) {
|
|
2362
|
+
var entry = pending.pop();
|
|
2363
|
+
var value = entry.value;
|
|
2364
|
+
var index;
|
|
2365
|
+
if (entry.complete) {
|
|
2366
|
+
ancestors.pop();
|
|
2367
|
+
if (visited) {
|
|
2368
|
+
visited.set(value, entry.depth);
|
|
2369
|
+
} else {
|
|
2370
|
+
index = visitedValues.indexOf(value);
|
|
2371
|
+
if (index === -1) {
|
|
2372
|
+
index = nextCacheIndex;
|
|
2373
|
+
nextCacheIndex = (nextCacheIndex + 1) % cacheSize;
|
|
2374
|
+
}
|
|
2375
|
+
visitedValues[index] = value;
|
|
2376
|
+
visitedDepths[index] = entry.depth;
|
|
2377
|
+
}
|
|
2378
|
+
continue;
|
|
2379
|
+
}
|
|
2380
|
+
// The serializer enumerates any object at its root, then recursively
|
|
2381
|
+
// visits only plain objects and arrays below that root.
|
|
2382
|
+
if (entry.depth === 0 ? !utils.isObject(value) :
|
|
2383
|
+
!utils.isPlainObject(value) && !utils.isArray(value)) {
|
|
2384
|
+
continue;
|
|
2385
|
+
}
|
|
2386
|
+
if (entry.depth > 100) {
|
|
2387
|
+
throw new AxiosError_1('params exceed the maximum depth of 100', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2388
|
+
}
|
|
2389
|
+
// The depth cap bounds this ancestry scan independently of params width.
|
|
2390
|
+
if (ancestors.indexOf(value) !== -1) {
|
|
2391
|
+
throw new AxiosError_1('Circular reference detected in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2392
|
+
}
|
|
2393
|
+
if (visited) {
|
|
2394
|
+
if (visited.has(value) && visited.get(value) >= entry.depth) continue;
|
|
2395
|
+
} else {
|
|
2396
|
+
index = visitedValues.indexOf(value);
|
|
2397
|
+
if (index !== -1 && visitedDepths[index] >= entry.depth) continue;
|
|
2398
|
+
}
|
|
2399
|
+
ancestors.push(value);
|
|
2400
|
+
pending.push({ value: value, depth: entry.depth, complete: true });
|
|
2401
|
+
var keys = utils.isArray(value) ? arrayIndexes(value) : Object.keys(value);
|
|
2402
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2403
|
+
var key = keys[i];
|
|
2404
|
+
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
|
|
2405
|
+
pending.push({ value: value[key], depth: entry.depth + 1, complete: false });
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2200
2411
|
/**
|
|
2201
2412
|
* Config-specific merge-function which creates a new config-object
|
|
2202
2413
|
* by merging two configuration objects together.
|
|
@@ -2208,6 +2419,8 @@
|
|
|
2208
2419
|
var mergeConfig = function mergeConfig(config1, config2) {
|
|
2209
2420
|
// eslint-disable-next-line no-param-reassign
|
|
2210
2421
|
config2 = config2 || {};
|
|
2422
|
+
assertParamsDepth(utils.hasOwnProperty(config1, 'params') ? config1.params : undefined);
|
|
2423
|
+
assertParamsDepth(utils.hasOwnProperty(config2, 'params') ? config2.params : undefined);
|
|
2211
2424
|
// Use a null-prototype object so a polluted Object.prototype cannot leak
|
|
2212
2425
|
// values (e.g. transport, adapter) into the returned config via inheritance.
|
|
2213
2426
|
var config = Object.create(null);
|
|
@@ -2319,7 +2532,7 @@
|
|
|
2319
2532
|
};
|
|
2320
2533
|
|
|
2321
2534
|
var data = {
|
|
2322
|
-
"version": "0.
|
|
2535
|
+
"version": "0.36.0"
|
|
2323
2536
|
};
|
|
2324
2537
|
|
|
2325
2538
|
var VERSION = data.version;
|
|
@@ -2487,7 +2700,11 @@
|
|
|
2487
2700
|
config = configOrUrl || {};
|
|
2488
2701
|
}
|
|
2489
2702
|
|
|
2490
|
-
|
|
2703
|
+
try {
|
|
2704
|
+
config = mergeConfig(this.defaults, config);
|
|
2705
|
+
} catch (error) {
|
|
2706
|
+
return Promise.reject(error);
|
|
2707
|
+
}
|
|
2491
2708
|
var caller = config.captureCallerStack === true ? captureCallerStack(request) : null;
|
|
2492
2709
|
|
|
2493
2710
|
// Set config.method. The merged config is null-prototype, but instance
|
|
@@ -2613,11 +2830,16 @@
|
|
|
2613
2830
|
Axios.prototype[method] = function(url, config) {
|
|
2614
2831
|
var requestConfig = config || {};
|
|
2615
2832
|
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2833
|
+
try {
|
|
2834
|
+
requestConfig = mergeConfig(requestConfig, {
|
|
2835
|
+
method: method,
|
|
2836
|
+
url: url,
|
|
2837
|
+
data: utils.hasOwnProperty(requestConfig, 'data') ? requestConfig.data : undefined
|
|
2838
|
+
});
|
|
2839
|
+
} catch (error) {
|
|
2840
|
+
return Promise.reject(error);
|
|
2841
|
+
}
|
|
2842
|
+
return this.request(requestConfig);
|
|
2621
2843
|
};
|
|
2622
2844
|
});
|
|
2623
2845
|
|
|
@@ -2626,14 +2848,20 @@
|
|
|
2626
2848
|
|
|
2627
2849
|
function generateHTTPMethod(isForm) {
|
|
2628
2850
|
return function httpMethod(url, data, config) {
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2851
|
+
var requestConfig;
|
|
2852
|
+
try {
|
|
2853
|
+
requestConfig = mergeConfig(config || {}, {
|
|
2854
|
+
method: method,
|
|
2855
|
+
headers: isForm ? {
|
|
2856
|
+
'Content-Type': 'multipart/form-data'
|
|
2857
|
+
} : {},
|
|
2858
|
+
url: url,
|
|
2859
|
+
data: data
|
|
2860
|
+
});
|
|
2861
|
+
} catch (error) {
|
|
2862
|
+
return Promise.reject(error);
|
|
2863
|
+
}
|
|
2864
|
+
return this.request(requestConfig);
|
|
2637
2865
|
};
|
|
2638
2866
|
}
|
|
2639
2867
|
|