axios 0.31.1 → 0.33.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 +147 -1
- package/CLAUDE.md +1 -0
- package/README.md +24 -4
- package/dist/axios.js +338 -86
- 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 +338 -86
- 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 +3 -0
- package/lib/adapters/http.js +298 -85
- package/lib/adapters/xhr.js +111 -36
- package/lib/core/Axios.js +4 -2
- package/lib/core/AxiosError.js +79 -4
- package/lib/core/dispatchRequest.js +10 -5
- package/lib/core/mergeConfig.js +1 -0
- package/lib/defaults/index.js +3 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/AxiosURLSearchParams.js +18 -11
- package/lib/helpers/buildURL.js +11 -3
- package/lib/helpers/cookies.js +15 -2
- package/lib/helpers/defaultRedactKeys.js +3 -0
- package/lib/helpers/formDataToJSON.js +18 -1
- package/lib/helpers/shouldBypassProxy.js +56 -2
- package/lib/helpers/toFormData.js +24 -2
- package/lib/utils.js +46 -21
- package/package.json +1 -1
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.33.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
|
}
|
|
@@ -214,12 +219,14 @@ function isFormData(thing) {
|
|
|
214
219
|
// Reject non-objects (strings, numbers, booleans) up front — Object.getPrototypeOf
|
|
215
220
|
// throws a TypeError on primitives in ES5 environments.
|
|
216
221
|
if (!isObject(thing)) return false;
|
|
217
|
-
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData
|
|
222
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
218
223
|
var proto = Object.getPrototypeOf(thing);
|
|
219
224
|
if (!proto || proto === Object.prototype) return false;
|
|
220
225
|
if (!isFunction(thing.append)) return false;
|
|
221
|
-
return
|
|
222
|
-
|
|
226
|
+
return (
|
|
227
|
+
toString.call(thing) === pattern ||
|
|
228
|
+
(isFunction(thing.toString) && thing.toString() === pattern)
|
|
229
|
+
);
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
/**
|
|
@@ -237,7 +244,9 @@ var isURLSearchParams = kindOfTest('URLSearchParams');
|
|
|
237
244
|
* @returns {String} The String freed of excess whitespace
|
|
238
245
|
*/
|
|
239
246
|
function trim(str) {
|
|
240
|
-
return str.trim
|
|
247
|
+
return str.trim
|
|
248
|
+
? str.trim()
|
|
249
|
+
: str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
241
250
|
}
|
|
242
251
|
|
|
243
252
|
/**
|
|
@@ -257,10 +266,11 @@ function trim(str) {
|
|
|
257
266
|
*/
|
|
258
267
|
function isStandardBrowserEnv() {
|
|
259
268
|
var product;
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
product === '
|
|
263
|
-
|
|
269
|
+
if (
|
|
270
|
+
typeof navigator !== 'undefined' &&
|
|
271
|
+
((product = navigator.product) === 'ReactNative' ||
|
|
272
|
+
product === 'NativeScript' ||
|
|
273
|
+
product === 'NS')
|
|
264
274
|
) {
|
|
265
275
|
return false;
|
|
266
276
|
}
|
|
@@ -325,14 +335,20 @@ function forEach(obj, fn) {
|
|
|
325
335
|
* @returns {Object} Result of all merge properties
|
|
326
336
|
*/
|
|
327
337
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
328
|
-
var result =
|
|
338
|
+
var result = Object.create(null);
|
|
329
339
|
function assignValue(val, key) {
|
|
340
|
+
var target;
|
|
341
|
+
|
|
330
342
|
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
331
343
|
return;
|
|
332
344
|
}
|
|
333
345
|
|
|
334
|
-
|
|
335
|
-
|
|
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);
|
|
336
352
|
} else if (isPlainObject(val)) {
|
|
337
353
|
result[key] = merge({}, val);
|
|
338
354
|
} else if (isArray(val)) {
|
|
@@ -374,7 +390,7 @@ function extend(a, b, thisArg) {
|
|
|
374
390
|
* @return {string} content value without BOM
|
|
375
391
|
*/
|
|
376
392
|
function stripBOM(content) {
|
|
377
|
-
if (content.charCodeAt(0) ===
|
|
393
|
+
if (content.charCodeAt(0) === 0xfeff) {
|
|
378
394
|
content = content.slice(1);
|
|
379
395
|
}
|
|
380
396
|
return content;
|
|
@@ -389,7 +405,10 @@ function stripBOM(content) {
|
|
|
389
405
|
*/
|
|
390
406
|
|
|
391
407
|
function inherits(constructor, superConstructor, props, descriptors) {
|
|
392
|
-
constructor.prototype = Object.create(
|
|
408
|
+
constructor.prototype = Object.create(
|
|
409
|
+
superConstructor.prototype,
|
|
410
|
+
descriptors
|
|
411
|
+
);
|
|
393
412
|
constructor.prototype.constructor = constructor;
|
|
394
413
|
props && Object.assign(constructor.prototype, props);
|
|
395
414
|
}
|
|
@@ -418,13 +437,20 @@ function toFlatObject(sourceObj, destObj, filter, propFilter) {
|
|
|
418
437
|
i = props.length;
|
|
419
438
|
while (i-- > 0) {
|
|
420
439
|
prop = props[i];
|
|
421
|
-
if (
|
|
440
|
+
if (
|
|
441
|
+
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
442
|
+
!merged[prop]
|
|
443
|
+
) {
|
|
422
444
|
destObj[prop] = sourceObj[prop];
|
|
423
445
|
merged[prop] = true;
|
|
424
446
|
}
|
|
425
447
|
}
|
|
426
448
|
sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
|
|
427
|
-
} while (
|
|
449
|
+
} while (
|
|
450
|
+
sourceObj &&
|
|
451
|
+
(!filter || filter(sourceObj, destObj)) &&
|
|
452
|
+
sourceObj !== Object.prototype
|
|
453
|
+
);
|
|
428
454
|
|
|
429
455
|
return destObj;
|
|
430
456
|
}
|
|
@@ -446,7 +472,6 @@ function endsWith(str, searchString, position) {
|
|
|
446
472
|
return lastIndex !== -1 && lastIndex === position;
|
|
447
473
|
}
|
|
448
474
|
|
|
449
|
-
|
|
450
475
|
/**
|
|
451
476
|
* Returns new array from array like object or null if failed
|
|
452
477
|
* @param {*} [thing]
|
|
@@ -542,6 +567,82 @@ var utils = {
|
|
|
542
567
|
hasOwnProperty: hasOwnProperty
|
|
543
568
|
};
|
|
544
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
|
+
|
|
545
646
|
/**
|
|
546
647
|
* Create an Error with the specified message, config, error code, request and response.
|
|
547
648
|
*
|
|
@@ -584,7 +685,7 @@ utils.inherits(AxiosError, Error, {
|
|
|
584
685
|
columnNumber: this.columnNumber,
|
|
585
686
|
stack: this.stack,
|
|
586
687
|
// Axios
|
|
587
|
-
config: this.config,
|
|
688
|
+
config: serializeConfig(this.config),
|
|
588
689
|
code: this.code,
|
|
589
690
|
status: this.response && this.response.status ? this.response.status : null
|
|
590
691
|
};
|
|
@@ -592,7 +693,7 @@ utils.inherits(AxiosError, Error, {
|
|
|
592
693
|
});
|
|
593
694
|
|
|
594
695
|
var prototype$1 = AxiosError.prototype;
|
|
595
|
-
var descriptors =
|
|
696
|
+
var descriptors = Object.create(null);
|
|
596
697
|
|
|
597
698
|
[
|
|
598
699
|
'ERR_BAD_OPTION_VALUE',
|
|
@@ -610,11 +711,11 @@ var descriptors = {};
|
|
|
610
711
|
'ERR_FORM_DATA_DEPTH_EXCEEDED'
|
|
611
712
|
// eslint-disable-next-line func-names
|
|
612
713
|
].forEach(function(code) {
|
|
613
|
-
descriptors[code] =
|
|
714
|
+
descriptors[code] = makeValueDescriptor(code);
|
|
614
715
|
});
|
|
615
716
|
|
|
616
717
|
Object.defineProperties(AxiosError, descriptors);
|
|
617
|
-
Object.defineProperty(prototype$1, 'isAxiosError',
|
|
718
|
+
Object.defineProperty(prototype$1, 'isAxiosError', makeValueDescriptor(true));
|
|
618
719
|
|
|
619
720
|
// eslint-disable-next-line func-names
|
|
620
721
|
AxiosError.from = function(error, code, config, request, response, customProps) {
|
|
@@ -733,6 +834,29 @@ function toFormData(obj, formData, options) {
|
|
|
733
834
|
return value;
|
|
734
835
|
}
|
|
735
836
|
|
|
837
|
+
var stack = [];
|
|
838
|
+
|
|
839
|
+
function assertValueDepth(value, depth) {
|
|
840
|
+
if (depth > maxDepth) {
|
|
841
|
+
throw new AxiosError_1(
|
|
842
|
+
'Maximum object depth of ' + maxDepth + ' exceeded (got ' + depth + ' levels)',
|
|
843
|
+
AxiosError_1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
if (!utils.isObject(value) || stack.indexOf(value) !== -1) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
stack.push(value);
|
|
852
|
+
|
|
853
|
+
utils.forEach(value, function each(el) {
|
|
854
|
+
assertValueDepth(el, depth + 1);
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
stack.pop();
|
|
858
|
+
}
|
|
859
|
+
|
|
736
860
|
/**
|
|
737
861
|
*
|
|
738
862
|
* @param {*} value
|
|
@@ -748,6 +872,7 @@ function toFormData(obj, formData, options) {
|
|
|
748
872
|
if (utils.endsWith(key, '{}')) {
|
|
749
873
|
// eslint-disable-next-line no-param-reassign
|
|
750
874
|
key = metaTokens ? key : key.slice(0, -2);
|
|
875
|
+
assertValueDepth(value, 1);
|
|
751
876
|
// eslint-disable-next-line no-param-reassign
|
|
752
877
|
value = JSON.stringify(value);
|
|
753
878
|
} else if (
|
|
@@ -777,8 +902,6 @@ function toFormData(obj, formData, options) {
|
|
|
777
902
|
return false;
|
|
778
903
|
}
|
|
779
904
|
|
|
780
|
-
var stack = [];
|
|
781
|
-
|
|
782
905
|
var exposedHelpers = Object.assign(predicates, {
|
|
783
906
|
defaultVisitor: defaultVisitor,
|
|
784
907
|
convertValue: convertValue,
|
|
@@ -829,7 +952,7 @@ function toFormData(obj, formData, options) {
|
|
|
829
952
|
var toFormData_1 = toFormData;
|
|
830
953
|
|
|
831
954
|
function encode$1(str) {
|
|
832
|
-
// Do not map `%00` back to a raw null byte
|
|
955
|
+
// Do not map `%00` back to a raw null byte: that reversed
|
|
833
956
|
// the safe percent-encoding from encodeURIComponent and enabled null byte injection.
|
|
834
957
|
var charMap = {
|
|
835
958
|
'!': '%21',
|
|
@@ -839,9 +962,12 @@ function encode$1(str) {
|
|
|
839
962
|
'~': '%7E',
|
|
840
963
|
'%20': '+'
|
|
841
964
|
};
|
|
842
|
-
return encodeURIComponent(str).replace(
|
|
843
|
-
|
|
844
|
-
|
|
965
|
+
return encodeURIComponent(str).replace(
|
|
966
|
+
/[!'\(\)~]|%20/g,
|
|
967
|
+
function replacer(match) {
|
|
968
|
+
return charMap[match];
|
|
969
|
+
}
|
|
970
|
+
);
|
|
845
971
|
}
|
|
846
972
|
|
|
847
973
|
function AxiosURLSearchParams(params, options) {
|
|
@@ -857,13 +983,17 @@ prototype.append = function append(name, value) {
|
|
|
857
983
|
};
|
|
858
984
|
|
|
859
985
|
prototype.toString = function toString(encoder) {
|
|
860
|
-
var _encode = encoder
|
|
861
|
-
|
|
862
|
-
|
|
986
|
+
var _encode = encoder
|
|
987
|
+
? function(value) {
|
|
988
|
+
return encoder.call(this, value, encode$1);
|
|
989
|
+
}
|
|
990
|
+
: encode$1;
|
|
863
991
|
|
|
864
|
-
return this._pairs
|
|
865
|
-
|
|
866
|
-
|
|
992
|
+
return this._pairs
|
|
993
|
+
.map(function each(pair) {
|
|
994
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
995
|
+
}, '')
|
|
996
|
+
.join('&');
|
|
867
997
|
};
|
|
868
998
|
|
|
869
999
|
var AxiosURLSearchParams_1 = AxiosURLSearchParams;
|
|
@@ -898,9 +1028,17 @@ var buildURL = function buildURL(url, params, options) {
|
|
|
898
1028
|
url = url.slice(0, hashmarkIndex);
|
|
899
1029
|
}
|
|
900
1030
|
|
|
901
|
-
var _encode =
|
|
1031
|
+
var _encode = encode;
|
|
1032
|
+
var serializeFn;
|
|
902
1033
|
|
|
903
|
-
|
|
1034
|
+
if (options) {
|
|
1035
|
+
if (utils.isFunction(options)) {
|
|
1036
|
+
serializeFn = options;
|
|
1037
|
+
} else {
|
|
1038
|
+
_encode = utils.hasOwnProperty(options, 'encode') && options.encode || encode;
|
|
1039
|
+
serializeFn = utils.hasOwnProperty(options, 'serialize') ? options.serialize : undefined;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
904
1042
|
|
|
905
1043
|
var serializedParams;
|
|
906
1044
|
|
|
@@ -1023,6 +1161,19 @@ var toURLEncodedForm = function toURLEncodedForm(data, options) {
|
|
|
1023
1161
|
}, options));
|
|
1024
1162
|
};
|
|
1025
1163
|
|
|
1164
|
+
var MAX_FORM_DATA_TO_JSON_DEPTH = 100;
|
|
1165
|
+
|
|
1166
|
+
function assertPathDepth(path) {
|
|
1167
|
+
var depth = path.length - 1;
|
|
1168
|
+
|
|
1169
|
+
if (depth > MAX_FORM_DATA_TO_JSON_DEPTH) {
|
|
1170
|
+
throw new AxiosError_1(
|
|
1171
|
+
'Maximum object depth of ' + MAX_FORM_DATA_TO_JSON_DEPTH + ' exceeded (got ' + depth + ' levels)',
|
|
1172
|
+
AxiosError_1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1173
|
+
);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1026
1177
|
function parsePropPath(name) {
|
|
1027
1178
|
// foo[x][y][z]
|
|
1028
1179
|
// foo.x.y.z
|
|
@@ -1083,7 +1234,10 @@ function formDataToJSON(formData) {
|
|
|
1083
1234
|
var obj = {};
|
|
1084
1235
|
|
|
1085
1236
|
utils.forEachEntry(formData, function(name, value) {
|
|
1086
|
-
|
|
1237
|
+
var path = parsePropPath(name);
|
|
1238
|
+
|
|
1239
|
+
assertPathDepth(path);
|
|
1240
|
+
buildPath(path, value, obj, 0);
|
|
1087
1241
|
});
|
|
1088
1242
|
|
|
1089
1243
|
return obj;
|
|
@@ -1146,8 +1300,21 @@ var cookies = (
|
|
|
1146
1300
|
},
|
|
1147
1301
|
|
|
1148
1302
|
read: function read(name) {
|
|
1149
|
-
var
|
|
1150
|
-
|
|
1303
|
+
var nameEQ = name + '=';
|
|
1304
|
+
var cookies = document.cookie.split(';');
|
|
1305
|
+
var cookie;
|
|
1306
|
+
|
|
1307
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
1308
|
+
cookie = cookies[i];
|
|
1309
|
+
while (cookie.charAt(0) === ' ') {
|
|
1310
|
+
cookie = cookie.substring(1);
|
|
1311
|
+
}
|
|
1312
|
+
if (cookie.indexOf(nameEQ) === 0) {
|
|
1313
|
+
return decodeURIComponent(cookie.substring(nameEQ.length));
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
return null;
|
|
1151
1318
|
},
|
|
1152
1319
|
|
|
1153
1320
|
remove: function remove(name) {
|
|
@@ -1356,8 +1523,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1356
1523
|
var requestData = config.data;
|
|
1357
1524
|
var requestHeaders = config.headers;
|
|
1358
1525
|
var responseType = config.responseType;
|
|
1359
|
-
// Guard against prototype pollution
|
|
1360
|
-
var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken')
|
|
1526
|
+
// Guard against prototype pollution: only honor own properties.
|
|
1527
|
+
var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken')
|
|
1528
|
+
? config.withXSRFToken
|
|
1529
|
+
: undefined;
|
|
1361
1530
|
var onCanceled;
|
|
1362
1531
|
function done() {
|
|
1363
1532
|
if (config.cancelToken) {
|
|
@@ -1376,15 +1545,30 @@ var xhr = function xhrAdapter(config) {
|
|
|
1376
1545
|
var request = new XMLHttpRequest();
|
|
1377
1546
|
|
|
1378
1547
|
// HTTP basic authentication
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
var
|
|
1548
|
+
var configAuth = utils.hasOwnProperty(config, 'auth') ? config.auth : undefined;
|
|
1549
|
+
if (configAuth) {
|
|
1550
|
+
var username = utils.hasOwnProperty(configAuth, 'username') ? configAuth.username || '' : '';
|
|
1551
|
+
var password = utils.hasOwnProperty(configAuth, 'password') && configAuth.password
|
|
1552
|
+
? unescape(encodeURIComponent(configAuth.password))
|
|
1553
|
+
: '';
|
|
1382
1554
|
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
|
1383
1555
|
}
|
|
1384
1556
|
|
|
1385
|
-
var fullPath = buildFullPath(
|
|
1557
|
+
var fullPath = buildFullPath(
|
|
1558
|
+
config.baseURL,
|
|
1559
|
+
config.url,
|
|
1560
|
+
config.allowAbsoluteUrls
|
|
1561
|
+
);
|
|
1386
1562
|
|
|
1387
|
-
request.open(
|
|
1563
|
+
request.open(
|
|
1564
|
+
config.method.toUpperCase(),
|
|
1565
|
+
buildURL(
|
|
1566
|
+
fullPath,
|
|
1567
|
+
config.params,
|
|
1568
|
+
utils.hasOwnProperty(config, 'paramsSerializer') ? config.paramsSerializer : undefined
|
|
1569
|
+
),
|
|
1570
|
+
true
|
|
1571
|
+
);
|
|
1388
1572
|
|
|
1389
1573
|
// Set the request timeout in MS
|
|
1390
1574
|
request.timeout = config.timeout;
|
|
@@ -1394,9 +1578,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1394
1578
|
return;
|
|
1395
1579
|
}
|
|
1396
1580
|
// Prepare the response
|
|
1397
|
-
var responseHeaders =
|
|
1398
|
-
|
|
1399
|
-
|
|
1581
|
+
var responseHeaders =
|
|
1582
|
+
'getAllResponseHeaders' in request
|
|
1583
|
+
? parseHeaders(request.getAllResponseHeaders())
|
|
1584
|
+
: null;
|
|
1585
|
+
var responseData =
|
|
1586
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
1587
|
+
? request.responseText
|
|
1588
|
+
: request.response;
|
|
1400
1589
|
var response = {
|
|
1401
1590
|
data: responseData,
|
|
1402
1591
|
status: request.status,
|
|
@@ -1406,13 +1595,17 @@ var xhr = function xhrAdapter(config) {
|
|
|
1406
1595
|
request: request
|
|
1407
1596
|
};
|
|
1408
1597
|
|
|
1409
|
-
settle(
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1598
|
+
settle(
|
|
1599
|
+
function _resolve(value) {
|
|
1600
|
+
resolve(value);
|
|
1601
|
+
done();
|
|
1602
|
+
},
|
|
1603
|
+
function _reject(err) {
|
|
1604
|
+
reject(err);
|
|
1605
|
+
done();
|
|
1606
|
+
},
|
|
1607
|
+
response
|
|
1608
|
+
);
|
|
1416
1609
|
|
|
1417
1610
|
// Clean up request
|
|
1418
1611
|
request = null;
|
|
@@ -1432,7 +1625,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1432
1625
|
// handled by onerror instead
|
|
1433
1626
|
// With one exception: request that using file: protocol, most browsers
|
|
1434
1627
|
// will return status as 0 even though it's a successful request
|
|
1435
|
-
if (
|
|
1628
|
+
if (
|
|
1629
|
+
request.status === 0 &&
|
|
1630
|
+
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
|
1631
|
+
) {
|
|
1436
1632
|
return;
|
|
1437
1633
|
}
|
|
1438
1634
|
// readystate handler is calling before onerror or ontimeout handlers,
|
|
@@ -1447,7 +1643,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1447
1643
|
return;
|
|
1448
1644
|
}
|
|
1449
1645
|
|
|
1450
|
-
reject(
|
|
1646
|
+
reject(
|
|
1647
|
+
new AxiosError_1(
|
|
1648
|
+
'Request aborted',
|
|
1649
|
+
AxiosError_1.ECONNABORTED,
|
|
1650
|
+
config,
|
|
1651
|
+
request
|
|
1652
|
+
)
|
|
1653
|
+
);
|
|
1451
1654
|
|
|
1452
1655
|
// Clean up request
|
|
1453
1656
|
request = null;
|
|
@@ -1457,7 +1660,14 @@ var xhr = function xhrAdapter(config) {
|
|
|
1457
1660
|
request.onerror = function handleError() {
|
|
1458
1661
|
// Real errors are hidden from us by the browser
|
|
1459
1662
|
// onerror should only fire if it's a network error
|
|
1460
|
-
reject(
|
|
1663
|
+
reject(
|
|
1664
|
+
new AxiosError_1(
|
|
1665
|
+
'Network Error',
|
|
1666
|
+
AxiosError_1.ERR_NETWORK,
|
|
1667
|
+
config,
|
|
1668
|
+
request
|
|
1669
|
+
)
|
|
1670
|
+
);
|
|
1461
1671
|
|
|
1462
1672
|
// Clean up request
|
|
1463
1673
|
request = null;
|
|
@@ -1465,16 +1675,23 @@ var xhr = function xhrAdapter(config) {
|
|
|
1465
1675
|
|
|
1466
1676
|
// Handle timeout
|
|
1467
1677
|
request.ontimeout = function handleTimeout() {
|
|
1468
|
-
var timeoutErrorMessage = config.timeout
|
|
1678
|
+
var timeoutErrorMessage = config.timeout
|
|
1679
|
+
? 'timeout of ' + config.timeout + 'ms exceeded'
|
|
1680
|
+
: 'timeout exceeded';
|
|
1469
1681
|
var transitional$1 = config.transitional || transitional;
|
|
1470
1682
|
if (config.timeoutErrorMessage) {
|
|
1471
1683
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
1472
1684
|
}
|
|
1473
|
-
reject(
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1685
|
+
reject(
|
|
1686
|
+
new AxiosError_1(
|
|
1687
|
+
timeoutErrorMessage,
|
|
1688
|
+
transitional$1.clarifyTimeoutError
|
|
1689
|
+
? AxiosError_1.ETIMEDOUT
|
|
1690
|
+
: AxiosError_1.ECONNABORTED,
|
|
1691
|
+
config,
|
|
1692
|
+
request
|
|
1693
|
+
)
|
|
1694
|
+
);
|
|
1478
1695
|
|
|
1479
1696
|
// Clean up request
|
|
1480
1697
|
request = null;
|
|
@@ -1488,10 +1705,16 @@ var xhr = function xhrAdapter(config) {
|
|
|
1488
1705
|
if (utils.isFunction(withXSRFToken)) {
|
|
1489
1706
|
withXSRFToken = withXSRFToken(config);
|
|
1490
1707
|
}
|
|
1491
|
-
// Strict boolean check
|
|
1492
|
-
if (
|
|
1708
|
+
// Strict boolean check: only `true` short-circuits the same-origin guard.
|
|
1709
|
+
if (
|
|
1710
|
+
withXSRFToken === true ||
|
|
1711
|
+
(withXSRFToken !== false && isURLSameOrigin(fullPath))
|
|
1712
|
+
) {
|
|
1493
1713
|
// Add xsrf header
|
|
1494
|
-
var xsrfValue =
|
|
1714
|
+
var xsrfValue =
|
|
1715
|
+
config.xsrfHeaderName &&
|
|
1716
|
+
config.xsrfCookieName &&
|
|
1717
|
+
cookies.read(config.xsrfCookieName);
|
|
1495
1718
|
if (xsrfValue) {
|
|
1496
1719
|
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
1497
1720
|
}
|
|
@@ -1501,7 +1724,10 @@ var xhr = function xhrAdapter(config) {
|
|
|
1501
1724
|
// Add headers to the request
|
|
1502
1725
|
if ('setRequestHeader' in request) {
|
|
1503
1726
|
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
|
1504
|
-
if (
|
|
1727
|
+
if (
|
|
1728
|
+
typeof requestData === 'undefined' &&
|
|
1729
|
+
key.toLowerCase() === 'content-type'
|
|
1730
|
+
) {
|
|
1505
1731
|
// Remove Content-Type if data is undefined
|
|
1506
1732
|
delete requestHeaders[key];
|
|
1507
1733
|
} else {
|
|
@@ -1538,30 +1764,46 @@ var xhr = function xhrAdapter(config) {
|
|
|
1538
1764
|
if (!request) {
|
|
1539
1765
|
return;
|
|
1540
1766
|
}
|
|
1541
|
-
reject(
|
|
1767
|
+
reject(
|
|
1768
|
+
!cancel || cancel.type
|
|
1769
|
+
? new CanceledError_1(null, config, request)
|
|
1770
|
+
: cancel
|
|
1771
|
+
);
|
|
1542
1772
|
request.abort();
|
|
1543
1773
|
request = null;
|
|
1544
1774
|
};
|
|
1545
1775
|
|
|
1546
1776
|
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
1547
1777
|
if (config.signal) {
|
|
1548
|
-
config.signal.aborted
|
|
1778
|
+
config.signal.aborted
|
|
1779
|
+
? onCanceled()
|
|
1780
|
+
: config.signal.addEventListener('abort', onCanceled);
|
|
1549
1781
|
}
|
|
1550
1782
|
}
|
|
1551
1783
|
|
|
1552
1784
|
// false, 0 (zero number), and '' (empty string) are valid JSON values
|
|
1553
|
-
if (
|
|
1785
|
+
if (
|
|
1786
|
+
!requestData &&
|
|
1787
|
+
requestData !== false &&
|
|
1788
|
+
requestData !== 0 &&
|
|
1789
|
+
requestData !== ''
|
|
1790
|
+
) {
|
|
1554
1791
|
requestData = null;
|
|
1555
1792
|
}
|
|
1556
1793
|
|
|
1557
1794
|
var protocol = parseProtocol(fullPath);
|
|
1558
1795
|
|
|
1559
1796
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
1560
|
-
reject(
|
|
1797
|
+
reject(
|
|
1798
|
+
new AxiosError_1(
|
|
1799
|
+
'Unsupported protocol ' + protocol + ':',
|
|
1800
|
+
AxiosError_1.ERR_BAD_REQUEST,
|
|
1801
|
+
config
|
|
1802
|
+
)
|
|
1803
|
+
);
|
|
1561
1804
|
return;
|
|
1562
1805
|
}
|
|
1563
1806
|
|
|
1564
|
-
|
|
1565
1807
|
// Send the request
|
|
1566
1808
|
request.send(requestData);
|
|
1567
1809
|
});
|
|
@@ -1709,6 +1951,8 @@ var defaults = {
|
|
|
1709
1951
|
maxContentLength: -1,
|
|
1710
1952
|
maxBodyLength: -1,
|
|
1711
1953
|
|
|
1954
|
+
redact: defaultRedactKeys.slice(),
|
|
1955
|
+
|
|
1712
1956
|
env: {
|
|
1713
1957
|
FormData: platform.classes.FormData,
|
|
1714
1958
|
Blob: platform.classes.Blob
|
|
@@ -1815,11 +2059,16 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
1815
2059
|
normalizeHeaderName(config.headers, 'Content-Type');
|
|
1816
2060
|
|
|
1817
2061
|
// Flatten headers
|
|
1818
|
-
config.headers
|
|
1819
|
-
config.headers.common
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
2062
|
+
var commonHeaders = utils.hasOwnProperty(config.headers, 'common') && config.headers.common
|
|
2063
|
+
? config.headers.common
|
|
2064
|
+
: {};
|
|
2065
|
+
var methodHeaders = config.method &&
|
|
2066
|
+
utils.hasOwnProperty(config.headers, config.method) &&
|
|
2067
|
+
config.headers[config.method]
|
|
2068
|
+
? config.headers[config.method]
|
|
2069
|
+
: {};
|
|
2070
|
+
|
|
2071
|
+
config.headers = utils.merge(commonHeaders, methodHeaders, config.headers);
|
|
1823
2072
|
|
|
1824
2073
|
utils.forEach(
|
|
1825
2074
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
@@ -1964,6 +2213,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1964
2213
|
'httpsAgent': defaultToConfig2,
|
|
1965
2214
|
'cancelToken': defaultToConfig2,
|
|
1966
2215
|
'socketPath': defaultToConfig2,
|
|
2216
|
+
'allowedSocketPaths': defaultToConfig2,
|
|
1967
2217
|
'responseEncoding': defaultToConfig2,
|
|
1968
2218
|
'validateStatus': mergeDirectKeys
|
|
1969
2219
|
};
|
|
@@ -1981,7 +2231,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
1981
2231
|
};
|
|
1982
2232
|
|
|
1983
2233
|
var data = {
|
|
1984
|
-
"version": "0.
|
|
2234
|
+
"version": "0.33.0"
|
|
1985
2235
|
};
|
|
1986
2236
|
|
|
1987
2237
|
var VERSION = data.version;
|
|
@@ -2205,10 +2455,12 @@ Axios.prototype.getUri = function getUri(config) {
|
|
|
2205
2455
|
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
2206
2456
|
/*eslint func-names:0*/
|
|
2207
2457
|
Axios.prototype[method] = function(url, config) {
|
|
2208
|
-
|
|
2458
|
+
var requestConfig = config || {};
|
|
2459
|
+
|
|
2460
|
+
return this.request(mergeConfig(requestConfig, {
|
|
2209
2461
|
method: method,
|
|
2210
2462
|
url: url,
|
|
2211
|
-
data: (
|
|
2463
|
+
data: utils.hasOwnProperty(requestConfig, 'data') ? requestConfig.data : undefined
|
|
2212
2464
|
}));
|
|
2213
2465
|
};
|
|
2214
2466
|
});
|