axios 0.31.0 → 0.32.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/AGENTS.md +38 -0
- package/CHANGELOG.md +10 -0
- package/CLAUDE.md +1 -0
- package/README.md +46 -7
- package/UPGRADE_GUIDE.md +2 -2
- package/dist/axios.js +328 -93
- 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 +328 -93
- 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 +4 -0
- package/lib/adapters/http.js +354 -69
- package/lib/adapters/xhr.js +106 -32
- package/lib/core/AxiosError.js +81 -5
- package/lib/core/dispatchRequest.js +10 -5
- package/lib/core/mergeConfig.js +21 -10
- package/lib/defaults/index.js +9 -3
- package/lib/env/data.js +1 -1
- package/lib/helpers/AxiosURLSearchParams.js +20 -12
- package/lib/helpers/cookies.js +15 -2
- package/lib/helpers/defaultRedactKeys.js +3 -0
- package/lib/helpers/shouldBypassProxy.js +55 -1
- package/lib/helpers/toFormData.js +14 -3
- package/lib/utils.js +51 -20
- package/package.json +2 -2
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.32.0 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);
|
|
@@ -52,8 +52,14 @@ function isUndefined(val) {
|
|
|
52
52
|
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
53
53
|
*/
|
|
54
54
|
function isBuffer(val) {
|
|
55
|
-
return
|
|
56
|
-
|
|
55
|
+
return (
|
|
56
|
+
val !== null &&
|
|
57
|
+
!isUndefined(val) &&
|
|
58
|
+
val.constructor !== null &&
|
|
59
|
+
!isUndefined(val.constructor) &&
|
|
60
|
+
typeof val.constructor.isBuffer === 'function' &&
|
|
61
|
+
val.constructor.isBuffer(val)
|
|
62
|
+
);
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
/**
|
|
@@ -65,7 +71,6 @@ function isBuffer(val) {
|
|
|
65
71
|
*/
|
|
66
72
|
var isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
67
73
|
|
|
68
|
-
|
|
69
74
|
/**
|
|
70
75
|
* Determine if a value is a view on an ArrayBuffer
|
|
71
76
|
*
|
|
@@ -74,10 +79,10 @@ var isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
|
74
79
|
*/
|
|
75
80
|
function isArrayBufferView(val) {
|
|
76
81
|
var result;
|
|
77
|
-
if (
|
|
82
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
78
83
|
result = ArrayBuffer.isView(val);
|
|
79
84
|
} else {
|
|
80
|
-
result =
|
|
85
|
+
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
81
86
|
}
|
|
82
87
|
return result;
|
|
83
88
|
}
|
|
@@ -209,8 +214,16 @@ function isStream(val) {
|
|
|
209
214
|
*/
|
|
210
215
|
function isFormData(thing) {
|
|
211
216
|
var pattern = '[object FormData]';
|
|
212
|
-
|
|
213
|
-
|
|
217
|
+
if (!thing) return false;
|
|
218
|
+
if (typeof FormData === 'function' && thing instanceof FormData) return true;
|
|
219
|
+
// Reject non-objects (strings, numbers, booleans) up front — Object.getPrototypeOf
|
|
220
|
+
// throws a TypeError on primitives in ES5 environments.
|
|
221
|
+
if (!isObject(thing)) return false;
|
|
222
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
223
|
+
var proto = Object.getPrototypeOf(thing);
|
|
224
|
+
if (!proto || proto === Object.prototype) return false;
|
|
225
|
+
if (!isFunction(thing.append)) return false;
|
|
226
|
+
return (
|
|
214
227
|
toString.call(thing) === pattern ||
|
|
215
228
|
(isFunction(thing.toString) && thing.toString() === pattern)
|
|
216
229
|
);
|
|
@@ -231,7 +244,9 @@ var isURLSearchParams = kindOfTest('URLSearchParams');
|
|
|
231
244
|
* @returns {String} The String freed of excess whitespace
|
|
232
245
|
*/
|
|
233
246
|
function trim(str) {
|
|
234
|
-
return str.trim
|
|
247
|
+
return str.trim
|
|
248
|
+
? str.trim()
|
|
249
|
+
: str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
235
250
|
}
|
|
236
251
|
|
|
237
252
|
/**
|
|
@@ -251,10 +266,11 @@ function trim(str) {
|
|
|
251
266
|
*/
|
|
252
267
|
function isStandardBrowserEnv() {
|
|
253
268
|
var product;
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
product === '
|
|
257
|
-
|
|
269
|
+
if (
|
|
270
|
+
typeof navigator !== 'undefined' &&
|
|
271
|
+
((product = navigator.product) === 'ReactNative' ||
|
|
272
|
+
product === 'NativeScript' ||
|
|
273
|
+
product === 'NS')
|
|
258
274
|
) {
|
|
259
275
|
return false;
|
|
260
276
|
}
|
|
@@ -319,14 +335,20 @@ function forEach(obj, fn) {
|
|
|
319
335
|
* @returns {Object} Result of all merge properties
|
|
320
336
|
*/
|
|
321
337
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
322
|
-
var result =
|
|
338
|
+
var result = Object.create(null);
|
|
323
339
|
function assignValue(val, key) {
|
|
340
|
+
var target;
|
|
341
|
+
|
|
324
342
|
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
325
343
|
return;
|
|
326
344
|
}
|
|
327
345
|
|
|
328
|
-
|
|
329
|
-
|
|
346
|
+
target = Object.prototype.hasOwnProperty.call(result, key)
|
|
347
|
+
? result[key]
|
|
348
|
+
: undefined;
|
|
349
|
+
|
|
350
|
+
if (isPlainObject(target) && isPlainObject(val)) {
|
|
351
|
+
result[key] = merge(target, val);
|
|
330
352
|
} else if (isPlainObject(val)) {
|
|
331
353
|
result[key] = merge({}, val);
|
|
332
354
|
} else if (isArray(val)) {
|
|
@@ -368,7 +390,7 @@ function extend(a, b, thisArg) {
|
|
|
368
390
|
* @return {string} content value without BOM
|
|
369
391
|
*/
|
|
370
392
|
function stripBOM(content) {
|
|
371
|
-
if (content.charCodeAt(0) ===
|
|
393
|
+
if (content.charCodeAt(0) === 0xfeff) {
|
|
372
394
|
content = content.slice(1);
|
|
373
395
|
}
|
|
374
396
|
return content;
|
|
@@ -383,7 +405,10 @@ function stripBOM(content) {
|
|
|
383
405
|
*/
|
|
384
406
|
|
|
385
407
|
function inherits(constructor, superConstructor, props, descriptors) {
|
|
386
|
-
constructor.prototype = Object.create(
|
|
408
|
+
constructor.prototype = Object.create(
|
|
409
|
+
superConstructor.prototype,
|
|
410
|
+
descriptors
|
|
411
|
+
);
|
|
387
412
|
constructor.prototype.constructor = constructor;
|
|
388
413
|
props && Object.assign(constructor.prototype, props);
|
|
389
414
|
}
|
|
@@ -412,13 +437,20 @@ function toFlatObject(sourceObj, destObj, filter, propFilter) {
|
|
|
412
437
|
i = props.length;
|
|
413
438
|
while (i-- > 0) {
|
|
414
439
|
prop = props[i];
|
|
415
|
-
if (
|
|
440
|
+
if (
|
|
441
|
+
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
442
|
+
!merged[prop]
|
|
443
|
+
) {
|
|
416
444
|
destObj[prop] = sourceObj[prop];
|
|
417
445
|
merged[prop] = true;
|
|
418
446
|
}
|
|
419
447
|
}
|
|
420
448
|
sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
|
|
421
|
-
} while (
|
|
449
|
+
} while (
|
|
450
|
+
sourceObj &&
|
|
451
|
+
(!filter || filter(sourceObj, destObj)) &&
|
|
452
|
+
sourceObj !== Object.prototype
|
|
453
|
+
);
|
|
422
454
|
|
|
423
455
|
return destObj;
|
|
424
456
|
}
|
|
@@ -440,7 +472,6 @@ function endsWith(str, searchString, position) {
|
|
|
440
472
|
return lastIndex !== -1 && lastIndex === position;
|
|
441
473
|
}
|
|
442
474
|
|
|
443
|
-
|
|
444
475
|
/**
|
|
445
476
|
* Returns new array from array like object or null if failed
|
|
446
477
|
* @param {*} [thing]
|
|
@@ -536,6 +567,82 @@ var utils = {
|
|
|
536
567
|
hasOwnProperty: hasOwnProperty
|
|
537
568
|
};
|
|
538
569
|
|
|
570
|
+
var defaultRedactKeys = ['authorization', 'proxy-authorization', 'cookie', 'set-cookie', 'x-api-key', 'password'];
|
|
571
|
+
|
|
572
|
+
var REDACTED_VALUE = '[REDACTED ****]';
|
|
573
|
+
|
|
574
|
+
function makeValueDescriptor(value) {
|
|
575
|
+
var descriptor = Object.create(null);
|
|
576
|
+
descriptor.value = value;
|
|
577
|
+
return descriptor;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function getRedactKeys(config) {
|
|
581
|
+
// An empty array is treated as "no override" so an upstream `redact: []` cannot
|
|
582
|
+
// silently disable redaction. To opt out, pass non-string values or unset keys.
|
|
583
|
+
var override = config && utils.isArray(config.redact) && config.redact.length ? config.redact : null;
|
|
584
|
+
var redact = override || defaultRedactKeys;
|
|
585
|
+
var keys = {};
|
|
586
|
+
|
|
587
|
+
utils.forEach(redact, function eachRedactKey(key) {
|
|
588
|
+
if (typeof key === 'string') {
|
|
589
|
+
keys[key.toLowerCase()] = true;
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
return keys;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function shouldRedact(key, keys) {
|
|
597
|
+
return typeof key === 'string' && keys[key.toLowerCase()];
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
var CIRCULAR_VALUE = '[Circular]';
|
|
601
|
+
|
|
602
|
+
function serializeConfigValue(value, keys, key, seen) {
|
|
603
|
+
var result;
|
|
604
|
+
|
|
605
|
+
if (shouldRedact(key, keys)) {
|
|
606
|
+
return REDACTED_VALUE;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
if (utils.isArray(value)) {
|
|
610
|
+
if (seen.indexOf(value) !== -1) {
|
|
611
|
+
return CIRCULAR_VALUE;
|
|
612
|
+
}
|
|
613
|
+
seen.push(value);
|
|
614
|
+
result = [];
|
|
615
|
+
utils.forEach(value, function eachArrayValue(item, index) {
|
|
616
|
+
result[index] = serializeConfigValue(item, keys, index, seen);
|
|
617
|
+
});
|
|
618
|
+
seen.pop();
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (utils.isPlainObject(value)) {
|
|
623
|
+
if (seen.indexOf(value) !== -1) {
|
|
624
|
+
return CIRCULAR_VALUE;
|
|
625
|
+
}
|
|
626
|
+
seen.push(value);
|
|
627
|
+
result = {};
|
|
628
|
+
utils.forEach(value, function eachObjectValue(item, itemKey) {
|
|
629
|
+
result[itemKey] = serializeConfigValue(item, keys, itemKey, seen);
|
|
630
|
+
});
|
|
631
|
+
seen.pop();
|
|
632
|
+
return result;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
return value;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function serializeConfig(config) {
|
|
639
|
+
if (!config) {
|
|
640
|
+
return config;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
return serializeConfigValue(config, getRedactKeys(config), undefined, []);
|
|
644
|
+
}
|
|
645
|
+
|
|
539
646
|
/**
|
|
540
647
|
* Create an Error with the specified message, config, error code, request and response.
|
|
541
648
|
*
|
|
@@ -578,7 +685,7 @@ utils.inherits(AxiosError, Error, {
|
|
|
578
685
|
columnNumber: this.columnNumber,
|
|
579
686
|
stack: this.stack,
|
|
580
687
|
// Axios
|
|
581
|
-
config: this.config,
|
|
688
|
+
config: serializeConfig(this.config),
|
|
582
689
|
code: this.code,
|
|
583
690
|
status: this.response && this.response.status ? this.response.status : null
|
|
584
691
|
};
|
|
@@ -586,7 +693,7 @@ utils.inherits(AxiosError, Error, {
|
|
|
586
693
|
});
|
|
587
694
|
|
|
588
695
|
var prototype$1 = AxiosError.prototype;
|
|
589
|
-
var descriptors =
|
|
696
|
+
var descriptors = Object.create(null);
|
|
590
697
|
|
|
591
698
|
[
|
|
592
699
|
'ERR_BAD_OPTION_VALUE',
|
|
@@ -600,14 +707,15 @@ var descriptors = {};
|
|
|
600
707
|
'ERR_BAD_REQUEST',
|
|
601
708
|
'ERR_CANCELED',
|
|
602
709
|
'ERR_NOT_SUPPORT',
|
|
603
|
-
'ERR_INVALID_URL'
|
|
710
|
+
'ERR_INVALID_URL',
|
|
711
|
+
'ERR_FORM_DATA_DEPTH_EXCEEDED'
|
|
604
712
|
// eslint-disable-next-line func-names
|
|
605
713
|
].forEach(function(code) {
|
|
606
|
-
descriptors[code] =
|
|
714
|
+
descriptors[code] = makeValueDescriptor(code);
|
|
607
715
|
});
|
|
608
716
|
|
|
609
717
|
Object.defineProperties(AxiosError, descriptors);
|
|
610
|
-
Object.defineProperty(prototype$1, 'isAxiosError',
|
|
718
|
+
Object.defineProperty(prototype$1, 'isAxiosError', makeValueDescriptor(true));
|
|
611
719
|
|
|
612
720
|
// eslint-disable-next-line func-names
|
|
613
721
|
AxiosError.from = function(error, code, config, request, response, customProps) {
|
|
@@ -701,6 +809,7 @@ function toFormData(obj, formData, options) {
|
|
|
701
809
|
var dots = options.dots;
|
|
702
810
|
var indexes = options.indexes;
|
|
703
811
|
var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
812
|
+
var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
704
813
|
var useBlob = _Blob && isSpecCompliant(formData);
|
|
705
814
|
|
|
706
815
|
if (!utils.isFunction(visitor)) {
|
|
@@ -777,9 +886,19 @@ function toFormData(obj, formData, options) {
|
|
|
777
886
|
isVisitable: isVisitable
|
|
778
887
|
});
|
|
779
888
|
|
|
780
|
-
function build(value, path) {
|
|
889
|
+
function build(value, path, depth) {
|
|
781
890
|
if (utils.isUndefined(value)) return;
|
|
782
891
|
|
|
892
|
+
// eslint-disable-next-line no-param-reassign
|
|
893
|
+
depth = depth || 0;
|
|
894
|
+
|
|
895
|
+
if (depth > maxDepth) {
|
|
896
|
+
throw new AxiosError_1(
|
|
897
|
+
'Maximum object depth of ' + maxDepth + ' exceeded (got ' + depth + ' levels)',
|
|
898
|
+
AxiosError_1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
|
|
783
902
|
if (stack.indexOf(value) !== -1) {
|
|
784
903
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
785
904
|
}
|
|
@@ -792,7 +911,7 @@ function toFormData(obj, formData, options) {
|
|
|
792
911
|
);
|
|
793
912
|
|
|
794
913
|
if (result === true) {
|
|
795
|
-
build(el, path ? path.concat(key) : [key]);
|
|
914
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
796
915
|
}
|
|
797
916
|
});
|
|
798
917
|
|
|
@@ -803,7 +922,7 @@ function toFormData(obj, formData, options) {
|
|
|
803
922
|
throw new TypeError('data must be an object');
|
|
804
923
|
}
|
|
805
924
|
|
|
806
|
-
build(obj);
|
|
925
|
+
build(obj, null, 0);
|
|
807
926
|
|
|
808
927
|
return formData;
|
|
809
928
|
}
|
|
@@ -811,18 +930,22 @@ function toFormData(obj, formData, options) {
|
|
|
811
930
|
var toFormData_1 = toFormData;
|
|
812
931
|
|
|
813
932
|
function encode$1(str) {
|
|
933
|
+
// Do not map `%00` back to a raw null byte: that reversed
|
|
934
|
+
// the safe percent-encoding from encodeURIComponent and enabled null byte injection.
|
|
814
935
|
var charMap = {
|
|
815
936
|
'!': '%21',
|
|
816
937
|
"'": '%27',
|
|
817
938
|
'(': '%28',
|
|
818
939
|
')': '%29',
|
|
819
940
|
'~': '%7E',
|
|
820
|
-
'%20': '+'
|
|
821
|
-
'%00': '\x00'
|
|
941
|
+
'%20': '+'
|
|
822
942
|
};
|
|
823
|
-
return encodeURIComponent(str).replace(
|
|
824
|
-
|
|
825
|
-
|
|
943
|
+
return encodeURIComponent(str).replace(
|
|
944
|
+
/[!'\(\)~]|%20/g,
|
|
945
|
+
function replacer(match) {
|
|
946
|
+
return charMap[match];
|
|
947
|
+
}
|
|
948
|
+
);
|
|
826
949
|
}
|
|
827
950
|
|
|
828
951
|
function AxiosURLSearchParams(params, options) {
|
|
@@ -838,13 +961,17 @@ prototype.append = function append(name, value) {
|
|
|
838
961
|
};
|
|
839
962
|
|
|
840
963
|
prototype.toString = function toString(encoder) {
|
|
841
|
-
var _encode = encoder
|
|
842
|
-
|
|
843
|
-
|
|
964
|
+
var _encode = encoder
|
|
965
|
+
? function(value) {
|
|
966
|
+
return encoder.call(this, value, encode$1);
|
|
967
|
+
}
|
|
968
|
+
: encode$1;
|
|
844
969
|
|
|
845
|
-
return this._pairs
|
|
846
|
-
|
|
847
|
-
|
|
970
|
+
return this._pairs
|
|
971
|
+
.map(function each(pair) {
|
|
972
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
973
|
+
}, '')
|
|
974
|
+
.join('&');
|
|
848
975
|
};
|
|
849
976
|
|
|
850
977
|
var AxiosURLSearchParams_1 = AxiosURLSearchParams;
|
|
@@ -1127,8 +1254,21 @@ var cookies = (
|
|
|
1127
1254
|
},
|
|
1128
1255
|
|
|
1129
1256
|
read: function read(name) {
|
|
1130
|
-
var
|
|
1131
|
-
|
|
1257
|
+
var nameEQ = name + '=';
|
|
1258
|
+
var cookies = document.cookie.split(';');
|
|
1259
|
+
var cookie;
|
|
1260
|
+
|
|
1261
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
1262
|
+
cookie = cookies[i];
|
|
1263
|
+
while (cookie.charAt(0) === ' ') {
|
|
1264
|
+
cookie = cookie.substring(1);
|
|
1265
|
+
}
|
|
1266
|
+
if (cookie.indexOf(nameEQ) === 0) {
|
|
1267
|
+
return decodeURIComponent(cookie.substring(nameEQ.length));
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
return null;
|
|
1132
1272
|
},
|
|
1133
1273
|
|
|
1134
1274
|
remove: function remove(name) {
|
|
@@ -1337,7 +1477,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1337
1477
|
var requestData = config.data;
|
|
1338
1478
|
var requestHeaders = config.headers;
|
|
1339
1479
|
var responseType = config.responseType;
|
|
1340
|
-
|
|
1480
|
+
// Guard against prototype pollution: only honor own properties.
|
|
1481
|
+
var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken')
|
|
1482
|
+
? config.withXSRFToken
|
|
1483
|
+
: undefined;
|
|
1341
1484
|
var onCanceled;
|
|
1342
1485
|
function done() {
|
|
1343
1486
|
if (config.cancelToken) {
|
|
@@ -1358,13 +1501,23 @@ var xhr = function xhrAdapter(config) {
|
|
|
1358
1501
|
// HTTP basic authentication
|
|
1359
1502
|
if (config.auth) {
|
|
1360
1503
|
var username = config.auth.username || '';
|
|
1361
|
-
var password = config.auth.password
|
|
1504
|
+
var password = config.auth.password
|
|
1505
|
+
? unescape(encodeURIComponent(config.auth.password))
|
|
1506
|
+
: '';
|
|
1362
1507
|
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
|
1363
1508
|
}
|
|
1364
1509
|
|
|
1365
|
-
var fullPath = buildFullPath(
|
|
1510
|
+
var fullPath = buildFullPath(
|
|
1511
|
+
config.baseURL,
|
|
1512
|
+
config.url,
|
|
1513
|
+
config.allowAbsoluteUrls
|
|
1514
|
+
);
|
|
1366
1515
|
|
|
1367
|
-
request.open(
|
|
1516
|
+
request.open(
|
|
1517
|
+
config.method.toUpperCase(),
|
|
1518
|
+
buildURL(fullPath, config.params, config.paramsSerializer),
|
|
1519
|
+
true
|
|
1520
|
+
);
|
|
1368
1521
|
|
|
1369
1522
|
// Set the request timeout in MS
|
|
1370
1523
|
request.timeout = config.timeout;
|
|
@@ -1374,9 +1527,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1374
1527
|
return;
|
|
1375
1528
|
}
|
|
1376
1529
|
// Prepare the response
|
|
1377
|
-
var responseHeaders =
|
|
1378
|
-
|
|
1379
|
-
|
|
1530
|
+
var responseHeaders =
|
|
1531
|
+
'getAllResponseHeaders' in request
|
|
1532
|
+
? parseHeaders(request.getAllResponseHeaders())
|
|
1533
|
+
: null;
|
|
1534
|
+
var responseData =
|
|
1535
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
1536
|
+
? request.responseText
|
|
1537
|
+
: request.response;
|
|
1380
1538
|
var response = {
|
|
1381
1539
|
data: responseData,
|
|
1382
1540
|
status: request.status,
|
|
@@ -1386,13 +1544,17 @@ var xhr = function xhrAdapter(config) {
|
|
|
1386
1544
|
request: request
|
|
1387
1545
|
};
|
|
1388
1546
|
|
|
1389
|
-
settle(
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1547
|
+
settle(
|
|
1548
|
+
function _resolve(value) {
|
|
1549
|
+
resolve(value);
|
|
1550
|
+
done();
|
|
1551
|
+
},
|
|
1552
|
+
function _reject(err) {
|
|
1553
|
+
reject(err);
|
|
1554
|
+
done();
|
|
1555
|
+
},
|
|
1556
|
+
response
|
|
1557
|
+
);
|
|
1396
1558
|
|
|
1397
1559
|
// Clean up request
|
|
1398
1560
|
request = null;
|
|
@@ -1412,7 +1574,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1412
1574
|
// handled by onerror instead
|
|
1413
1575
|
// With one exception: request that using file: protocol, most browsers
|
|
1414
1576
|
// will return status as 0 even though it's a successful request
|
|
1415
|
-
if (
|
|
1577
|
+
if (
|
|
1578
|
+
request.status === 0 &&
|
|
1579
|
+
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
|
1580
|
+
) {
|
|
1416
1581
|
return;
|
|
1417
1582
|
}
|
|
1418
1583
|
// readystate handler is calling before onerror or ontimeout handlers,
|
|
@@ -1427,7 +1592,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1427
1592
|
return;
|
|
1428
1593
|
}
|
|
1429
1594
|
|
|
1430
|
-
reject(
|
|
1595
|
+
reject(
|
|
1596
|
+
new AxiosError_1(
|
|
1597
|
+
'Request aborted',
|
|
1598
|
+
AxiosError_1.ECONNABORTED,
|
|
1599
|
+
config,
|
|
1600
|
+
request
|
|
1601
|
+
)
|
|
1602
|
+
);
|
|
1431
1603
|
|
|
1432
1604
|
// Clean up request
|
|
1433
1605
|
request = null;
|
|
@@ -1437,7 +1609,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1437
1609
|
request.onerror = function handleError() {
|
|
1438
1610
|
// Real errors are hidden from us by the browser
|
|
1439
1611
|
// onerror should only fire if it's a network error
|
|
1440
|
-
reject(
|
|
1612
|
+
reject(
|
|
1613
|
+
new AxiosError_1(
|
|
1614
|
+
'Network Error',
|
|
1615
|
+
AxiosError_1.ERR_NETWORK,
|
|
1616
|
+
config,
|
|
1617
|
+
request
|
|
1618
|
+
)
|
|
1619
|
+
);
|
|
1441
1620
|
|
|
1442
1621
|
// Clean up request
|
|
1443
1622
|
request = null;
|
|
@@ -1445,16 +1624,23 @@ var xhr = function xhrAdapter(config) {
|
|
|
1445
1624
|
|
|
1446
1625
|
// Handle timeout
|
|
1447
1626
|
request.ontimeout = function handleTimeout() {
|
|
1448
|
-
var timeoutErrorMessage = config.timeout
|
|
1627
|
+
var timeoutErrorMessage = config.timeout
|
|
1628
|
+
? 'timeout of ' + config.timeout + 'ms exceeded'
|
|
1629
|
+
: 'timeout exceeded';
|
|
1449
1630
|
var transitional$1 = config.transitional || transitional;
|
|
1450
1631
|
if (config.timeoutErrorMessage) {
|
|
1451
1632
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
1452
1633
|
}
|
|
1453
|
-
reject(
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1634
|
+
reject(
|
|
1635
|
+
new AxiosError_1(
|
|
1636
|
+
timeoutErrorMessage,
|
|
1637
|
+
transitional$1.clarifyTimeoutError
|
|
1638
|
+
? AxiosError_1.ETIMEDOUT
|
|
1639
|
+
: AxiosError_1.ECONNABORTED,
|
|
1640
|
+
config,
|
|
1641
|
+
request
|
|
1642
|
+
)
|
|
1643
|
+
);
|
|
1458
1644
|
|
|
1459
1645
|
// Clean up request
|
|
1460
1646
|
request = null;
|
|
@@ -1465,10 +1651,19 @@ var xhr = function xhrAdapter(config) {
|
|
|
1465
1651
|
// Specifically not if we're in a web worker, or react-native.
|
|
1466
1652
|
if (utils.isStandardBrowserEnv()) {
|
|
1467
1653
|
// Add xsrf header
|
|
1468
|
-
|
|
1469
|
-
|
|
1654
|
+
if (utils.isFunction(withXSRFToken)) {
|
|
1655
|
+
withXSRFToken = withXSRFToken(config);
|
|
1656
|
+
}
|
|
1657
|
+
// Strict boolean check: only `true` short-circuits the same-origin guard.
|
|
1658
|
+
if (
|
|
1659
|
+
withXSRFToken === true ||
|
|
1660
|
+
(withXSRFToken !== false && isURLSameOrigin(fullPath))
|
|
1661
|
+
) {
|
|
1470
1662
|
// Add xsrf header
|
|
1471
|
-
var xsrfValue =
|
|
1663
|
+
var xsrfValue =
|
|
1664
|
+
config.xsrfHeaderName &&
|
|
1665
|
+
config.xsrfCookieName &&
|
|
1666
|
+
cookies.read(config.xsrfCookieName);
|
|
1472
1667
|
if (xsrfValue) {
|
|
1473
1668
|
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
1474
1669
|
}
|
|
@@ -1478,7 +1673,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1478
1673
|
// Add headers to the request
|
|
1479
1674
|
if ('setRequestHeader' in request) {
|
|
1480
1675
|
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
1481
|
-
if (
|
|
1676
|
+
if (
|
|
1677
|
+
typeof requestData === 'undefined' &&
|
|
1678
|
+
key.toLowerCase() === 'content-type'
|
|
1679
|
+
) {
|
|
1482
1680
|
// Remove Content-Type if data is undefined
|
|
1483
1681
|
delete requestHeaders[key];
|
|
1484
1682
|
} else {
|
|
@@ -1515,30 +1713,46 @@ var xhr = function xhrAdapter(config) {
|
|
|
1515
1713
|
if (!request) {
|
|
1516
1714
|
return;
|
|
1517
1715
|
}
|
|
1518
|
-
reject(
|
|
1716
|
+
reject(
|
|
1717
|
+
!cancel || cancel.type
|
|
1718
|
+
? new CanceledError_1(null, config, request)
|
|
1719
|
+
: cancel
|
|
1720
|
+
);
|
|
1519
1721
|
request.abort();
|
|
1520
1722
|
request = null;
|
|
1521
1723
|
};
|
|
1522
1724
|
|
|
1523
1725
|
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
1524
1726
|
if (config.signal) {
|
|
1525
|
-
config.signal.aborted
|
|
1727
|
+
config.signal.aborted
|
|
1728
|
+
? onCanceled()
|
|
1729
|
+
: config.signal.addEventListener('abort', onCanceled);
|
|
1526
1730
|
}
|
|
1527
1731
|
}
|
|
1528
1732
|
|
|
1529
1733
|
// false, 0 (zero number), and '' (empty string) are valid JSON values
|
|
1530
|
-
if (
|
|
1734
|
+
if (
|
|
1735
|
+
!requestData &&
|
|
1736
|
+
requestData !== false &&
|
|
1737
|
+
requestData !== 0 &&
|
|
1738
|
+
requestData !== ''
|
|
1739
|
+
) {
|
|
1531
1740
|
requestData = null;
|
|
1532
1741
|
}
|
|
1533
1742
|
|
|
1534
1743
|
var protocol = parseProtocol(fullPath);
|
|
1535
1744
|
|
|
1536
1745
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
1537
|
-
reject(
|
|
1746
|
+
reject(
|
|
1747
|
+
new AxiosError_1(
|
|
1748
|
+
'Unsupported protocol ' + protocol + ':',
|
|
1749
|
+
AxiosError_1.ERR_BAD_REQUEST,
|
|
1750
|
+
config
|
|
1751
|
+
)
|
|
1752
|
+
);
|
|
1538
1753
|
return;
|
|
1539
1754
|
}
|
|
1540
1755
|
|
|
1541
|
-
|
|
1542
1756
|
// Send the request
|
|
1543
1757
|
request.send(requestData);
|
|
1544
1758
|
});
|
|
@@ -1624,17 +1838,20 @@ var defaults = {
|
|
|
1624
1838
|
var isFileList;
|
|
1625
1839
|
|
|
1626
1840
|
if (isObjectPayload) {
|
|
1841
|
+
var formSerializer = utils.hasOwnProperty(this, 'formSerializer') ? this.formSerializer : undefined;
|
|
1842
|
+
var envOption = utils.hasOwnProperty(this, 'env') ? this.env : undefined;
|
|
1843
|
+
|
|
1627
1844
|
if (contentType.indexOf('application/x-www-form-urlencoded') !== -1) {
|
|
1628
|
-
return toURLEncodedForm(data,
|
|
1845
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
1629
1846
|
}
|
|
1630
1847
|
|
|
1631
1848
|
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1632
|
-
var _FormData =
|
|
1849
|
+
var _FormData = envOption && envOption.FormData;
|
|
1633
1850
|
|
|
1634
1851
|
return toFormData_1(
|
|
1635
1852
|
isFileList ? {'files[]': data} : data,
|
|
1636
1853
|
_FormData && new _FormData(),
|
|
1637
|
-
|
|
1854
|
+
formSerializer
|
|
1638
1855
|
);
|
|
1639
1856
|
}
|
|
1640
1857
|
}
|
|
@@ -1683,6 +1900,8 @@ var defaults = {
|
|
|
1683
1900
|
maxContentLength: -1,
|
|
1684
1901
|
maxBodyLength: -1,
|
|
1685
1902
|
|
|
1903
|
+
redact: defaultRedactKeys.slice(),
|
|
1904
|
+
|
|
1686
1905
|
env: {
|
|
1687
1906
|
FormData: platform.classes.FormData,
|
|
1688
1907
|
Blob: platform.classes.Blob
|
|
@@ -1789,11 +2008,16 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
1789
2008
|
normalizeHeaderName(config.headers, 'Content-Type');
|
|
1790
2009
|
|
|
1791
2010
|
// Flatten headers
|
|
1792
|
-
config.headers
|
|
1793
|
-
config.headers.common
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
2011
|
+
var commonHeaders = utils.hasOwnProperty(config.headers, 'common') && config.headers.common
|
|
2012
|
+
? config.headers.common
|
|
2013
|
+
: {};
|
|
2014
|
+
var methodHeaders = config.method &&
|
|
2015
|
+
utils.hasOwnProperty(config.headers, config.method) &&
|
|
2016
|
+
config.headers[config.method]
|
|
2017
|
+
? config.headers[config.method]
|
|
2018
|
+
: {};
|
|
2019
|
+
|
|
2020
|
+
config.headers = utils.merge(commonHeaders, methodHeaders, config.headers);
|
|
1797
2021
|
|
|
1798
2022
|
utils.forEach(
|
|
1799
2023
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
@@ -1852,7 +2076,17 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
1852
2076
|
var mergeConfig = function mergeConfig(config1, config2) {
|
|
1853
2077
|
// eslint-disable-next-line no-param-reassign
|
|
1854
2078
|
config2 = config2 || {};
|
|
1855
|
-
|
|
2079
|
+
// Use a null-prototype object so a polluted Object.prototype cannot leak
|
|
2080
|
+
// values (e.g. transport, adapter) into the returned config via inheritance.
|
|
2081
|
+
var config = Object.create(null);
|
|
2082
|
+
|
|
2083
|
+
function getOwn(source, prop) {
|
|
2084
|
+
return utils.hasOwnProperty(source, prop) ? source[prop] : undefined;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
function hasOwn(source, prop) {
|
|
2088
|
+
return utils.hasOwnProperty(source, prop);
|
|
2089
|
+
}
|
|
1856
2090
|
|
|
1857
2091
|
function getMergedValue(target, source) {
|
|
1858
2092
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
@@ -1869,34 +2103,34 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1869
2103
|
|
|
1870
2104
|
// eslint-disable-next-line consistent-return
|
|
1871
2105
|
function mergeDeepProperties(prop) {
|
|
1872
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
1873
|
-
return getMergedValue(config1
|
|
1874
|
-
} else if (!utils.isUndefined(config1[prop])) {
|
|
2106
|
+
if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
|
|
2107
|
+
return getMergedValue(getOwn(config1, prop), config2[prop]);
|
|
2108
|
+
} else if (hasOwn(config1, prop) && !utils.isUndefined(config1[prop])) {
|
|
1875
2109
|
return getMergedValue(undefined, config1[prop]);
|
|
1876
2110
|
}
|
|
1877
2111
|
}
|
|
1878
2112
|
|
|
1879
2113
|
// eslint-disable-next-line consistent-return
|
|
1880
2114
|
function valueFromConfig2(prop) {
|
|
1881
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
2115
|
+
if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
|
|
1882
2116
|
return getMergedValue(undefined, config2[prop]);
|
|
1883
2117
|
}
|
|
1884
2118
|
}
|
|
1885
2119
|
|
|
1886
2120
|
// eslint-disable-next-line consistent-return
|
|
1887
2121
|
function defaultToConfig2(prop) {
|
|
1888
|
-
if (!utils.isUndefined(config2[prop])) {
|
|
2122
|
+
if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
|
|
1889
2123
|
return getMergedValue(undefined, config2[prop]);
|
|
1890
|
-
} else if (!utils.isUndefined(config1[prop])) {
|
|
2124
|
+
} else if (hasOwn(config1, prop) && !utils.isUndefined(config1[prop])) {
|
|
1891
2125
|
return getMergedValue(undefined, config1[prop]);
|
|
1892
2126
|
}
|
|
1893
2127
|
}
|
|
1894
2128
|
|
|
1895
2129
|
// eslint-disable-next-line consistent-return
|
|
1896
2130
|
function mergeDirectKeys(prop) {
|
|
1897
|
-
if (prop
|
|
1898
|
-
return getMergedValue(config1
|
|
1899
|
-
} else if (prop
|
|
2131
|
+
if (hasOwn(config2, prop)) {
|
|
2132
|
+
return getMergedValue(getOwn(config1, prop), config2[prop]);
|
|
2133
|
+
} else if (hasOwn(config1, prop)) {
|
|
1900
2134
|
return getMergedValue(undefined, config1[prop]);
|
|
1901
2135
|
}
|
|
1902
2136
|
}
|
|
@@ -1928,6 +2162,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1928
2162
|
'httpsAgent': defaultToConfig2,
|
|
1929
2163
|
'cancelToken': defaultToConfig2,
|
|
1930
2164
|
'socketPath': defaultToConfig2,
|
|
2165
|
+
'allowedSocketPaths': defaultToConfig2,
|
|
1931
2166
|
'responseEncoding': defaultToConfig2,
|
|
1932
2167
|
'validateStatus': mergeDirectKeys
|
|
1933
2168
|
};
|
|
@@ -1945,7 +2180,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1945
2180
|
};
|
|
1946
2181
|
|
|
1947
2182
|
var data = {
|
|
1948
|
-
"version": "0.
|
|
2183
|
+
"version": "0.32.0"
|
|
1949
2184
|
};
|
|
1950
2185
|
|
|
1951
2186
|
var VERSION = data.version;
|