axios 0.31.0 → 0.31.1
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 +26 -7
- package/UPGRADE_GUIDE.md +2 -2
- package/dist/axios.js +66 -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 +66 -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/index.d.ts +1 -0
- package/lib/adapters/http.js +82 -6
- package/lib/adapters/xhr.js +7 -3
- package/lib/core/AxiosError.js +2 -1
- package/lib/core/mergeConfig.js +20 -10
- package/lib/defaults/index.js +6 -3
- package/lib/env/data.js +1 -1
- package/lib/helpers/AxiosURLSearchParams.js +4 -3
- package/lib/helpers/toFormData.js +14 -3
- package/lib/utils.js +11 -5
- package/package.json +2 -2
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.31.
|
|
1
|
+
// axios v0.31.1 Copyright (c) 2026 Matt Zabriskie
|
|
2
2
|
var bind = function bind(fn, thisArg) {
|
|
3
3
|
return function wrap() {
|
|
4
4
|
return fn.apply(thisArg, arguments);
|
|
@@ -209,11 +209,17 @@ function isStream(val) {
|
|
|
209
209
|
*/
|
|
210
210
|
function isFormData(thing) {
|
|
211
211
|
var pattern = '[object FormData]';
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
);
|
|
212
|
+
if (!thing) return false;
|
|
213
|
+
if (typeof FormData === 'function' && thing instanceof FormData) return true;
|
|
214
|
+
// Reject non-objects (strings, numbers, booleans) up front — Object.getPrototypeOf
|
|
215
|
+
// throws a TypeError on primitives in ES5 environments.
|
|
216
|
+
if (!isObject(thing)) return false;
|
|
217
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
|
|
218
|
+
var proto = Object.getPrototypeOf(thing);
|
|
219
|
+
if (!proto || proto === Object.prototype) return false;
|
|
220
|
+
if (!isFunction(thing.append)) return false;
|
|
221
|
+
return toString.call(thing) === pattern ||
|
|
222
|
+
(isFunction(thing.toString) && thing.toString() === pattern);
|
|
217
223
|
}
|
|
218
224
|
|
|
219
225
|
/**
|
|
@@ -600,7 +606,8 @@ var descriptors = {};
|
|
|
600
606
|
'ERR_BAD_REQUEST',
|
|
601
607
|
'ERR_CANCELED',
|
|
602
608
|
'ERR_NOT_SUPPORT',
|
|
603
|
-
'ERR_INVALID_URL'
|
|
609
|
+
'ERR_INVALID_URL',
|
|
610
|
+
'ERR_FORM_DATA_DEPTH_EXCEEDED'
|
|
604
611
|
// eslint-disable-next-line func-names
|
|
605
612
|
].forEach(function(code) {
|
|
606
613
|
descriptors[code] = {value: code};
|
|
@@ -701,6 +708,7 @@ function toFormData(obj, formData, options) {
|
|
|
701
708
|
var dots = options.dots;
|
|
702
709
|
var indexes = options.indexes;
|
|
703
710
|
var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
711
|
+
var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
704
712
|
var useBlob = _Blob && isSpecCompliant(formData);
|
|
705
713
|
|
|
706
714
|
if (!utils.isFunction(visitor)) {
|
|
@@ -777,9 +785,19 @@ function toFormData(obj, formData, options) {
|
|
|
777
785
|
isVisitable: isVisitable
|
|
778
786
|
});
|
|
779
787
|
|
|
780
|
-
function build(value, path) {
|
|
788
|
+
function build(value, path, depth) {
|
|
781
789
|
if (utils.isUndefined(value)) return;
|
|
782
790
|
|
|
791
|
+
// eslint-disable-next-line no-param-reassign
|
|
792
|
+
depth = depth || 0;
|
|
793
|
+
|
|
794
|
+
if (depth > maxDepth) {
|
|
795
|
+
throw new AxiosError_1(
|
|
796
|
+
'Maximum object depth of ' + maxDepth + ' exceeded (got ' + depth + ' levels)',
|
|
797
|
+
AxiosError_1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
|
|
783
801
|
if (stack.indexOf(value) !== -1) {
|
|
784
802
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
785
803
|
}
|
|
@@ -792,7 +810,7 @@ function toFormData(obj, formData, options) {
|
|
|
792
810
|
);
|
|
793
811
|
|
|
794
812
|
if (result === true) {
|
|
795
|
-
build(el, path ? path.concat(key) : [key]);
|
|
813
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
796
814
|
}
|
|
797
815
|
});
|
|
798
816
|
|
|
@@ -803,7 +821,7 @@ function toFormData(obj, formData, options) {
|
|
|
803
821
|
throw new TypeError('data must be an object');
|
|
804
822
|
}
|
|
805
823
|
|
|
806
|
-
build(obj);
|
|
824
|
+
build(obj, null, 0);
|
|
807
825
|
|
|
808
826
|
return formData;
|
|
809
827
|
}
|
|
@@ -811,16 +829,17 @@ function toFormData(obj, formData, options) {
|
|
|
811
829
|
var toFormData_1 = toFormData;
|
|
812
830
|
|
|
813
831
|
function encode$1(str) {
|
|
832
|
+
// Do not map `%00` back to a raw null byte (GHSA-xhjh-pmcv-23jw): that reversed
|
|
833
|
+
// the safe percent-encoding from encodeURIComponent and enabled null byte injection.
|
|
814
834
|
var charMap = {
|
|
815
835
|
'!': '%21',
|
|
816
836
|
"'": '%27',
|
|
817
837
|
'(': '%28',
|
|
818
838
|
')': '%29',
|
|
819
839
|
'~': '%7E',
|
|
820
|
-
'%20': '+'
|
|
821
|
-
'%00': '\x00'
|
|
840
|
+
'%20': '+'
|
|
822
841
|
};
|
|
823
|
-
return encodeURIComponent(str).replace(/[!'\(\)~]|%20
|
|
842
|
+
return encodeURIComponent(str).replace(/[!'\(\)~]|%20/g, function replacer(match) {
|
|
824
843
|
return charMap[match];
|
|
825
844
|
});
|
|
826
845
|
}
|
|
@@ -1337,7 +1356,8 @@ var xhr = function xhrAdapter(config) {
|
|
|
1337
1356
|
var requestData = config.data;
|
|
1338
1357
|
var requestHeaders = config.headers;
|
|
1339
1358
|
var responseType = config.responseType;
|
|
1340
|
-
|
|
1359
|
+
// Guard against prototype pollution (GHSA-xx6v-rp6x-q39c): only honor own properties.
|
|
1360
|
+
var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken') ? config.withXSRFToken : undefined;
|
|
1341
1361
|
var onCanceled;
|
|
1342
1362
|
function done() {
|
|
1343
1363
|
if (config.cancelToken) {
|
|
@@ -1465,8 +1485,11 @@ var xhr = function xhrAdapter(config) {
|
|
|
1465
1485
|
// Specifically not if we're in a web worker, or react-native.
|
|
1466
1486
|
if (utils.isStandardBrowserEnv()) {
|
|
1467
1487
|
// Add xsrf header
|
|
1468
|
-
|
|
1469
|
-
|
|
1488
|
+
if (utils.isFunction(withXSRFToken)) {
|
|
1489
|
+
withXSRFToken = withXSRFToken(config);
|
|
1490
|
+
}
|
|
1491
|
+
// Strict boolean check (GHSA-xx6v-rp6x-q39c): only `true` short-circuits the same-origin guard.
|
|
1492
|
+
if (withXSRFToken === true || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
|
|
1470
1493
|
// Add xsrf header
|
|
1471
1494
|
var xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
|
1472
1495
|
if (xsrfValue) {
|
|
@@ -1624,17 +1647,20 @@ var defaults = {
|
|
|
1624
1647
|
var isFileList;
|
|
1625
1648
|
|
|
1626
1649
|
if (isObjectPayload) {
|
|
1650
|
+
var formSerializer = utils.hasOwnProperty(this, 'formSerializer') ? this.formSerializer : undefined;
|
|
1651
|
+
var envOption = utils.hasOwnProperty(this, 'env') ? this.env : undefined;
|
|
1652
|
+
|
|
1627
1653
|
if (contentType.indexOf('application/x-www-form-urlencoded') !== -1) {
|
|
1628
|
-
return toURLEncodedForm(data,
|
|
1654
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
1629
1655
|
}
|
|
1630
1656
|
|
|
1631
1657
|
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1632
|
-
var _FormData =
|
|
1658
|
+
var _FormData = envOption && envOption.FormData;
|
|
1633
1659
|
|
|
1634
1660
|
return toFormData_1(
|
|
1635
1661
|
isFileList ? {'files[]': data} : data,
|
|
1636
1662
|
_FormData && new _FormData(),
|
|
1637
|
-
|
|
1663
|
+
formSerializer
|
|
1638
1664
|
);
|
|
1639
1665
|
}
|
|
1640
1666
|
}
|
|
@@ -1852,7 +1878,17 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
1852
1878
|
var mergeConfig = function mergeConfig(config1, config2) {
|
|
1853
1879
|
// eslint-disable-next-line no-param-reassign
|
|
1854
1880
|
config2 = config2 || {};
|
|
1855
|
-
|
|
1881
|
+
// Use a null-prototype object so a polluted Object.prototype cannot leak
|
|
1882
|
+
// values (e.g. transport, adapter) into the returned config via inheritance.
|
|
1883
|
+
var config = Object.create(null);
|
|
1884
|
+
|
|
1885
|
+
function getOwn(source, prop) {
|
|
1886
|
+
return utils.hasOwnProperty(source, prop) ? source[prop] : undefined;
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
function hasOwn(source, prop) {
|
|
1890
|
+
return utils.hasOwnProperty(source, prop);
|
|
1891
|
+
}
|
|
1856
1892
|
|
|
1857
1893
|
function getMergedValue(target, source) {
|
|
1858
1894
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
@@ -1869,34 +1905,34 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1869
1905
|
|
|
1870
1906
|
// eslint-disable-next-line consistent-return
|
|
1871
1907
|
function mergeDeepProperties(prop) {
|
|
1872
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
1873
|
-
return getMergedValue(config1
|
|
1874
|
-
} else if (!utils.isUndefined(config1[prop])) {
|
|
1908
|
+
if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
|
|
1909
|
+
return getMergedValue(getOwn(config1, prop), config2[prop]);
|
|
1910
|
+
} else if (hasOwn(config1, prop) && !utils.isUndefined(config1[prop])) {
|
|
1875
1911
|
return getMergedValue(undefined, config1[prop]);
|
|
1876
1912
|
}
|
|
1877
1913
|
}
|
|
1878
1914
|
|
|
1879
1915
|
// eslint-disable-next-line consistent-return
|
|
1880
1916
|
function valueFromConfig2(prop) {
|
|
1881
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
1917
|
+
if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
|
|
1882
1918
|
return getMergedValue(undefined, config2[prop]);
|
|
1883
1919
|
}
|
|
1884
1920
|
}
|
|
1885
1921
|
|
|
1886
1922
|
// eslint-disable-next-line consistent-return
|
|
1887
1923
|
function defaultToConfig2(prop) {
|
|
1888
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
1924
|
+
if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
|
|
1889
1925
|
return getMergedValue(undefined, config2[prop]);
|
|
1890
|
-
} else if (!utils.isUndefined(config1[prop])) {
|
|
1926
|
+
} else if (hasOwn(config1, prop) && !utils.isUndefined(config1[prop])) {
|
|
1891
1927
|
return getMergedValue(undefined, config1[prop]);
|
|
1892
1928
|
}
|
|
1893
1929
|
}
|
|
1894
1930
|
|
|
1895
1931
|
// eslint-disable-next-line consistent-return
|
|
1896
1932
|
function mergeDirectKeys(prop) {
|
|
1897
|
-
if (prop
|
|
1898
|
-
return getMergedValue(config1
|
|
1899
|
-
} else if (prop
|
|
1933
|
+
if (hasOwn(config2, prop)) {
|
|
1934
|
+
return getMergedValue(getOwn(config1, prop), config2[prop]);
|
|
1935
|
+
} else if (hasOwn(config1, prop)) {
|
|
1900
1936
|
return getMergedValue(undefined, config1[prop]);
|
|
1901
1937
|
}
|
|
1902
1938
|
}
|
|
@@ -1945,7 +1981,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1945
1981
|
};
|
|
1946
1982
|
|
|
1947
1983
|
var data = {
|
|
1948
|
-
"version": "0.31.
|
|
1984
|
+
"version": "0.31.1"
|
|
1949
1985
|
};
|
|
1950
1986
|
|
|
1951
1987
|
var VERSION = data.version;
|