@vritti/quantum-ui 0.4.2 → 0.4.4
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/dist/DropdownMenu.js +59 -25
- package/dist/DropdownMenu.js.map +1 -1
- package/dist/OfferingSelector.js +21 -0
- package/dist/OfferingSelector.js.map +1 -0
- package/dist/OfferingVariantSelector.js +24 -0
- package/dist/OfferingVariantSelector.js.map +1 -0
- package/dist/Sidebar.js +1 -1
- package/dist/Switch.js +23 -6
- package/dist/Switch.js.map +1 -1
- package/dist/assets/quantum-ui.css +122 -103
- package/dist/components/TokenInput.js +3 -4
- package/dist/components/TokenInput.js.map +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/lib/components/DropdownMenu/types.d.ts +4 -0
- package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -1
- package/dist/lib/components/Switch/Switch.d.ts +2 -0
- package/dist/lib/components/Switch/Switch.d.ts.map +1 -1
- package/dist/lib/components/TokenInput/TokenInput.d.ts.map +1 -1
- package/dist/lib/selects/index.d.ts +2 -0
- package/dist/lib/selects/index.d.ts.map +1 -1
- package/dist/lib/selects/offering/OfferingSelector.d.ts +4 -0
- package/dist/lib/selects/offering/OfferingSelector.d.ts.map +1 -0
- package/dist/lib/selects/offering/index.d.ts +2 -0
- package/dist/lib/selects/offering/index.d.ts.map +1 -0
- package/dist/lib/selects/offering-variant/OfferingVariantSelector.d.ts +6 -0
- package/dist/lib/selects/offering-variant/OfferingVariantSelector.d.ts.map +1 -0
- package/dist/lib/selects/offering-variant/index.d.ts +2 -0
- package/dist/lib/selects/offering-variant/index.d.ts.map +1 -0
- package/dist/lib/utils/zod.d.ts +5 -0
- package/dist/lib/utils/zod.d.ts.map +1 -1
- package/dist/lodash.js +38 -27
- package/dist/lodash.js.map +1 -1
- package/dist/selects/offering-variant.js +2 -0
- package/dist/selects/offering-variant.js.map +1 -0
- package/dist/selects/offering.js +2 -0
- package/dist/selects/offering.js.map +1 -0
- package/dist/useDataTable.js +4906 -2439
- package/dist/useDataTable.js.map +1 -1
- package/dist/utils/axios.js +2825 -1215
- package/dist/utils/axios.js.map +1 -1
- package/dist/utils/zod.js +14 -2
- package/dist/utils/zod.js.map +1 -1
- package/package.json +23 -15
package/dist/utils/axios.js
CHANGED
|
@@ -20,6 +20,179 @@ const { toString } = Object.prototype;
|
|
|
20
20
|
const { getPrototypeOf } = Object;
|
|
21
21
|
const { iterator, toStringTag } = Symbol;
|
|
22
22
|
|
|
23
|
+
/* Creating a function that will check if an object has a property. */
|
|
24
|
+
const hasOwnProperty = (
|
|
25
|
+
({ hasOwnProperty }) =>
|
|
26
|
+
(obj, prop) =>
|
|
27
|
+
hasOwnProperty.call(obj, prop)
|
|
28
|
+
)(Object.prototype);
|
|
29
|
+
|
|
30
|
+
const isUnsafeObjectKey = (prop) =>
|
|
31
|
+
typeof prop === 'string' &&
|
|
32
|
+
(prop === '__proto__' || prop === 'constructor' || prop === 'prototype');
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Determine whether an inherited object must be treated as a shared-prototype
|
|
36
|
+
* boundary. Cross-realm Object.prototype objects cannot be distinguished
|
|
37
|
+
* reliably from application-created null-prototype objects because their
|
|
38
|
+
* properties are mutable, so all inherited terminal prototypes are excluded
|
|
39
|
+
* as a fail-closed boundary. A null-prototype source still keeps its own
|
|
40
|
+
* properties, as produced by mergeConfig and other safe materialization paths.
|
|
41
|
+
*
|
|
42
|
+
* @param {*} obj The object to inspect
|
|
43
|
+
* @param {*} prototype The object's prototype
|
|
44
|
+
* @param {boolean} source Whether obj is the original traversal source
|
|
45
|
+
*
|
|
46
|
+
* @returns {boolean} True when obj is a safe prototype traversal boundary
|
|
47
|
+
*/
|
|
48
|
+
const isPrototypeBoundary = (obj, prototype, source) =>
|
|
49
|
+
obj === Object.prototype || (!source && prototype === null);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Determine whether an object can retain its identity through code paths that
|
|
53
|
+
* add, replace, and remove config properties without bypassing unsafe-key
|
|
54
|
+
* filtering. Immutable objects, unsafe-key-bearing objects, and objects with
|
|
55
|
+
* accessor or restricted data properties must be materialized instead.
|
|
56
|
+
*
|
|
57
|
+
* @param {*} obj The object to inspect
|
|
58
|
+
*
|
|
59
|
+
* @returns {boolean} True when every own property is safe and fully mutable
|
|
60
|
+
*/
|
|
61
|
+
const isSafeAndFullyMutable = (obj) => {
|
|
62
|
+
if (!Object.isExtensible(obj)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const props = Object.getOwnPropertyNames(obj);
|
|
67
|
+
|
|
68
|
+
if (Object.getOwnPropertySymbols) {
|
|
69
|
+
props.push(...Object.getOwnPropertySymbols(obj));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return props.every((prop) => {
|
|
73
|
+
if (isUnsafeObjectKey(prop)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
78
|
+
|
|
79
|
+
return !!descriptor && descriptor.configurable && descriptor.writable === true;
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Walk the prototype chain (excluding the source realm's Object.prototype)
|
|
85
|
+
* looking for an own `prop`. This distinguishes genuine own/inherited members
|
|
86
|
+
* — including class accessors and template prototypes — from members injected
|
|
87
|
+
* via Object.prototype pollution (e.g. `Object.prototype.username = '...'`),
|
|
88
|
+
* which live on Object.prototype itself and are therefore never matched.
|
|
89
|
+
*
|
|
90
|
+
* @param {*} thing The value whose chain to inspect
|
|
91
|
+
* @param {string|symbol} prop The property key to look for
|
|
92
|
+
*
|
|
93
|
+
* @returns {boolean} True when `prop` is owned below Object.prototype
|
|
94
|
+
*/
|
|
95
|
+
const hasOwnInPrototypeChain = (thing, prop) => {
|
|
96
|
+
let obj = thing;
|
|
97
|
+
const seen = [];
|
|
98
|
+
|
|
99
|
+
while (obj != null) {
|
|
100
|
+
if (seen.indexOf(obj) !== -1) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
seen.push(obj);
|
|
104
|
+
|
|
105
|
+
const prototype = getPrototypeOf(obj);
|
|
106
|
+
|
|
107
|
+
if (isPrototypeBoundary(obj, prototype, obj === thing)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (hasOwnProperty(obj, prop)) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
obj = prototype;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
|
|
121
|
+
* properties and members inherited from a non-Object.prototype source (a class
|
|
122
|
+
* instance or template object) are honored; a value reachable only through a
|
|
123
|
+
* polluted Object.prototype is ignored and `undefined` is returned.
|
|
124
|
+
*
|
|
125
|
+
* @param {*} obj The source object
|
|
126
|
+
* @param {string|symbol} prop The property key to read
|
|
127
|
+
*
|
|
128
|
+
* @returns {*} The resolved value, or undefined when unsafe/absent
|
|
129
|
+
*/
|
|
130
|
+
const getSafeProp = (obj, prop) =>
|
|
131
|
+
obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Flatten an object and its application-defined prototype chain into a
|
|
135
|
+
* null-prototype object. Members inherited only from the source realm's
|
|
136
|
+
* Object.prototype are deliberately excluded, while class/template members
|
|
137
|
+
* below that boundary are preserved.
|
|
138
|
+
*
|
|
139
|
+
* @param {*} thing The value to flatten
|
|
140
|
+
*
|
|
141
|
+
* @returns {*} A null-prototype copy, or the original value when it is already
|
|
142
|
+
* structurally safe or is not an object
|
|
143
|
+
*/
|
|
144
|
+
const toSafeFlatObject = (thing) => {
|
|
145
|
+
if (thing == null || (typeof thing !== 'object' && typeof thing !== 'function')) {
|
|
146
|
+
return thing;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const sourcePrototype = getPrototypeOf(thing);
|
|
150
|
+
|
|
151
|
+
if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
|
|
152
|
+
return thing;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const result = Object.create(null);
|
|
156
|
+
const merged = Object.create(null);
|
|
157
|
+
const seen = [];
|
|
158
|
+
let current = thing;
|
|
159
|
+
|
|
160
|
+
while (current != null) {
|
|
161
|
+
if (seen.indexOf(current) !== -1) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
seen.push(current);
|
|
166
|
+
|
|
167
|
+
const prototype = current === thing ? sourcePrototype : getPrototypeOf(current);
|
|
168
|
+
|
|
169
|
+
if (isPrototypeBoundary(current, prototype, current === thing)) {
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const props = Object.getOwnPropertyNames(current);
|
|
174
|
+
|
|
175
|
+
if (Object.getOwnPropertySymbols) {
|
|
176
|
+
props.push(...Object.getOwnPropertySymbols(current));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
for (const prop of props) {
|
|
180
|
+
if (isUnsafeObjectKey(prop)) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (!hasOwnProperty(merged, prop)) {
|
|
185
|
+
result[prop] = thing[prop];
|
|
186
|
+
merged[prop] = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
current = prototype;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return result;
|
|
194
|
+
};
|
|
195
|
+
|
|
23
196
|
const kindOf = ((cache) => (thing) => {
|
|
24
197
|
const str = toString.call(thing);
|
|
25
198
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -145,17 +318,18 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
145
318
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
146
319
|
*/
|
|
147
320
|
const isPlainObject = (val) => {
|
|
148
|
-
if (
|
|
321
|
+
if (!isObject(val)) {
|
|
149
322
|
return false;
|
|
150
323
|
}
|
|
151
324
|
|
|
152
325
|
const prototype = getPrototypeOf(val);
|
|
153
326
|
return (
|
|
154
|
-
(prototype === null ||
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
!(
|
|
327
|
+
(prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) &&
|
|
328
|
+
// Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
|
|
329
|
+
// evidence the value is tagged/iterable, while ignoring members reachable
|
|
330
|
+
// only through shared or terminal prototype boundaries.
|
|
331
|
+
!hasOwnInPrototypeChain(val, toStringTag) &&
|
|
332
|
+
!hasOwnInPrototypeChain(val, iterator)
|
|
159
333
|
);
|
|
160
334
|
};
|
|
161
335
|
|
|
@@ -204,9 +378,9 @@ const isFile = kindOfTest('File');
|
|
|
204
378
|
* also have a `name` and `type` attribute to specify filename and content type
|
|
205
379
|
*
|
|
206
380
|
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
207
|
-
*
|
|
381
|
+
*
|
|
208
382
|
* @param {*} value The value to test
|
|
209
|
-
*
|
|
383
|
+
*
|
|
210
384
|
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
211
385
|
*/
|
|
212
386
|
const isReactNativeBlob = (value) => {
|
|
@@ -216,9 +390,9 @@ const isReactNativeBlob = (value) => {
|
|
|
216
390
|
/**
|
|
217
391
|
* Determine if environment is React Native
|
|
218
392
|
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
219
|
-
*
|
|
393
|
+
*
|
|
220
394
|
* @param {*} formData The formData to test
|
|
221
|
-
*
|
|
395
|
+
*
|
|
222
396
|
* @returns {boolean} True if environment is React Native, otherwise false
|
|
223
397
|
*/
|
|
224
398
|
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
@@ -237,9 +411,10 @@ const isBlob = kindOfTest('Blob');
|
|
|
237
411
|
*
|
|
238
412
|
* @param {*} val The value to test
|
|
239
413
|
*
|
|
240
|
-
* @returns {boolean} True if value is a
|
|
414
|
+
* @returns {boolean} True if value is a FileList, otherwise false
|
|
241
415
|
*/
|
|
242
416
|
const isFileList = kindOfTest('FileList');
|
|
417
|
+
const isSet = kindOfTest('Set');
|
|
243
418
|
|
|
244
419
|
/**
|
|
245
420
|
* Determine if a value is a Stream
|
|
@@ -269,15 +444,17 @@ const G = getGlobal();
|
|
|
269
444
|
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
270
445
|
|
|
271
446
|
const isFormData = (thing) => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
447
|
+
if (!thing) return false;
|
|
448
|
+
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
449
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
450
|
+
const proto = getPrototypeOf(thing);
|
|
451
|
+
if (!proto || proto === Object.prototype) return false;
|
|
452
|
+
if (!isFunction$1(thing.append)) return false;
|
|
453
|
+
const kind = kindOf(thing);
|
|
454
|
+
return (
|
|
455
|
+
kind === 'formdata' ||
|
|
456
|
+
// detect form-data instance
|
|
457
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
281
458
|
);
|
|
282
459
|
};
|
|
283
460
|
|
|
@@ -413,7 +590,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
413
590
|
*
|
|
414
591
|
* @returns {Object} Result of all merge properties
|
|
415
592
|
*/
|
|
416
|
-
function merge(
|
|
593
|
+
function merge(...objs) {
|
|
417
594
|
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
418
595
|
const result = {};
|
|
419
596
|
const assignValue = (val, key) => {
|
|
@@ -422,9 +599,15 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
422
599
|
return;
|
|
423
600
|
}
|
|
424
601
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
602
|
+
// findKey lowercases the key, so caseless lookup only applies to strings —
|
|
603
|
+
// symbol keys are identity-matched.
|
|
604
|
+
const targetKey = (caseless && typeof key === 'string' && findKey(result, key)) || key;
|
|
605
|
+
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
606
|
+
// chain, so a polluted Object.prototype value could surface here and get
|
|
607
|
+
// copied into the merged result.
|
|
608
|
+
const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
|
|
609
|
+
if (isPlainObject(existing) && isPlainObject(val)) {
|
|
610
|
+
result[targetKey] = merge(existing, val);
|
|
428
611
|
} else if (isPlainObject(val)) {
|
|
429
612
|
result[targetKey] = merge({}, val);
|
|
430
613
|
} else if (isArray(val)) {
|
|
@@ -434,8 +617,25 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
434
617
|
}
|
|
435
618
|
};
|
|
436
619
|
|
|
437
|
-
for (let i = 0, l =
|
|
438
|
-
|
|
620
|
+
for (let i = 0, l = objs.length; i < l; i++) {
|
|
621
|
+
const source = objs[i];
|
|
622
|
+
if (!source || isBuffer(source)) {
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
forEach(source, assignValue);
|
|
627
|
+
|
|
628
|
+
if (typeof source !== 'object' || isArray(source)) {
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const symbols = Object.getOwnPropertySymbols(source);
|
|
633
|
+
for (let j = 0; j < symbols.length; j++) {
|
|
634
|
+
const symbol = symbols[j];
|
|
635
|
+
if (propertyIsEnumerable.call(source, symbol)) {
|
|
636
|
+
assignValue(source[symbol], symbol);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
439
639
|
}
|
|
440
640
|
return result;
|
|
441
641
|
}
|
|
@@ -457,6 +657,9 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
457
657
|
(val, key) => {
|
|
458
658
|
if (thisArg && isFunction$1(val)) {
|
|
459
659
|
Object.defineProperty(a, key, {
|
|
660
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot
|
|
661
|
+
// hijack defineProperty's accessor-vs-data resolution.
|
|
662
|
+
__proto__: null,
|
|
460
663
|
value: bind(val, thisArg),
|
|
461
664
|
writable: true,
|
|
462
665
|
enumerable: true,
|
|
@@ -464,6 +667,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
464
667
|
});
|
|
465
668
|
} else {
|
|
466
669
|
Object.defineProperty(a, key, {
|
|
670
|
+
__proto__: null,
|
|
467
671
|
value: val,
|
|
468
672
|
writable: true,
|
|
469
673
|
enumerable: true,
|
|
@@ -502,12 +706,14 @@ const stripBOM = (content) => {
|
|
|
502
706
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
503
707
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
504
708
|
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
709
|
+
__proto__: null,
|
|
505
710
|
value: constructor,
|
|
506
711
|
writable: true,
|
|
507
712
|
enumerable: false,
|
|
508
713
|
configurable: true,
|
|
509
714
|
});
|
|
510
715
|
Object.defineProperty(constructor, 'super', {
|
|
716
|
+
__proto__: null,
|
|
511
717
|
value: superConstructor.prototype,
|
|
512
718
|
});
|
|
513
719
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -651,12 +857,7 @@ const toCamelCase = (str) => {
|
|
|
651
857
|
});
|
|
652
858
|
};
|
|
653
859
|
|
|
654
|
-
|
|
655
|
-
const hasOwnProperty = (
|
|
656
|
-
({ hasOwnProperty }) =>
|
|
657
|
-
(obj, prop) =>
|
|
658
|
-
hasOwnProperty.call(obj, prop)
|
|
659
|
-
)(Object.prototype);
|
|
860
|
+
const { propertyIsEnumerable } = Object.prototype;
|
|
660
861
|
|
|
661
862
|
/**
|
|
662
863
|
* Determine if a value is a RegExp object
|
|
@@ -689,7 +890,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
689
890
|
const freezeMethods = (obj) => {
|
|
690
891
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
691
892
|
// skip restricted props in strict mode
|
|
692
|
-
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].
|
|
893
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
|
693
894
|
return false;
|
|
694
895
|
}
|
|
695
896
|
|
|
@@ -763,11 +964,11 @@ function isSpecCompliantForm(thing) {
|
|
|
763
964
|
* @returns {Object} The JSON-compatible object.
|
|
764
965
|
*/
|
|
765
966
|
const toJSONObject = (obj) => {
|
|
766
|
-
const
|
|
967
|
+
const visited = new WeakSet();
|
|
767
968
|
|
|
768
|
-
const visit = (source
|
|
969
|
+
const visit = (source) => {
|
|
769
970
|
if (isObject(source)) {
|
|
770
|
-
if (
|
|
971
|
+
if (visited.has(source)) {
|
|
771
972
|
return;
|
|
772
973
|
}
|
|
773
974
|
|
|
@@ -777,15 +978,27 @@ const toJSONObject = (obj) => {
|
|
|
777
978
|
}
|
|
778
979
|
|
|
779
980
|
if (!('toJSON' in source)) {
|
|
780
|
-
|
|
781
|
-
|
|
981
|
+
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
982
|
+
visited.add(source);
|
|
782
983
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
984
|
+
let target;
|
|
985
|
+
|
|
986
|
+
if (isSet(source)) {
|
|
987
|
+
target = [];
|
|
988
|
+
for (const value of source) {
|
|
989
|
+
const reducedValue = visit(value);
|
|
990
|
+
!isUndefined(reducedValue) && target.push(reducedValue);
|
|
991
|
+
}
|
|
992
|
+
} else {
|
|
993
|
+
target = isArray(source) ? [] : {};
|
|
994
|
+
|
|
995
|
+
forEach(source, (value, key) => {
|
|
996
|
+
const reducedValue = visit(value);
|
|
997
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
998
|
+
});
|
|
999
|
+
}
|
|
787
1000
|
|
|
788
|
-
|
|
1001
|
+
visited.delete(source);
|
|
789
1002
|
|
|
790
1003
|
return target;
|
|
791
1004
|
}
|
|
@@ -794,7 +1007,7 @@ const toJSONObject = (obj) => {
|
|
|
794
1007
|
return source;
|
|
795
1008
|
};
|
|
796
1009
|
|
|
797
|
-
return visit(obj
|
|
1010
|
+
return visit(obj);
|
|
798
1011
|
};
|
|
799
1012
|
|
|
800
1013
|
/**
|
|
@@ -868,6 +1081,20 @@ const asap =
|
|
|
868
1081
|
|
|
869
1082
|
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
870
1083
|
|
|
1084
|
+
/**
|
|
1085
|
+
* Determine if a value is iterable via an iterator that is NOT sourced solely
|
|
1086
|
+
* from a polluted Object.prototype. Use this instead of `isIterable` whenever
|
|
1087
|
+
* the iterable comes from untrusted input (e.g. user-supplied header sources),
|
|
1088
|
+
* so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
|
|
1089
|
+
* into an attacker-controlled entries iterator.
|
|
1090
|
+
*
|
|
1091
|
+
* @param {*} thing The value to test
|
|
1092
|
+
*
|
|
1093
|
+
* @returns {boolean} True if value has a non-polluted iterator
|
|
1094
|
+
*/
|
|
1095
|
+
const isSafeIterable = (thing) =>
|
|
1096
|
+
thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
|
|
1097
|
+
|
|
871
1098
|
const utils$1 = {
|
|
872
1099
|
isArray,
|
|
873
1100
|
isArrayBuffer,
|
|
@@ -912,6 +1139,9 @@ const utils$1 = {
|
|
|
912
1139
|
isHTMLForm,
|
|
913
1140
|
hasOwnProperty,
|
|
914
1141
|
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
|
1142
|
+
hasOwnInPrototypeChain,
|
|
1143
|
+
getSafeProp,
|
|
1144
|
+
toSafeFlatObject,
|
|
915
1145
|
reduceDescriptors,
|
|
916
1146
|
freezeMethods,
|
|
917
1147
|
toObjectSet,
|
|
@@ -928,1266 +1158,1765 @@ const utils$1 = {
|
|
|
928
1158
|
setImmediate: _setImmediate,
|
|
929
1159
|
asap,
|
|
930
1160
|
isIterable,
|
|
1161
|
+
isSafeIterable,
|
|
931
1162
|
};
|
|
932
1163
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1164
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1165
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1166
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1167
|
+
'age',
|
|
1168
|
+
'authorization',
|
|
1169
|
+
'content-length',
|
|
1170
|
+
'content-type',
|
|
1171
|
+
'etag',
|
|
1172
|
+
'expires',
|
|
1173
|
+
'from',
|
|
1174
|
+
'host',
|
|
1175
|
+
'if-modified-since',
|
|
1176
|
+
'if-unmodified-since',
|
|
1177
|
+
'last-modified',
|
|
1178
|
+
'location',
|
|
1179
|
+
'max-forwards',
|
|
1180
|
+
'proxy-authorization',
|
|
1181
|
+
'referer',
|
|
1182
|
+
'retry-after',
|
|
1183
|
+
'user-agent',
|
|
1184
|
+
]);
|
|
938
1185
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1186
|
+
/**
|
|
1187
|
+
* Parse headers into an object
|
|
1188
|
+
*
|
|
1189
|
+
* ```
|
|
1190
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
1191
|
+
* Content-Type: application/json
|
|
1192
|
+
* Connection: keep-alive
|
|
1193
|
+
* Transfer-Encoding: chunked
|
|
1194
|
+
* ```
|
|
1195
|
+
*
|
|
1196
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
|
1197
|
+
*
|
|
1198
|
+
* @returns {Object} Headers parsed into an object
|
|
1199
|
+
*/
|
|
1200
|
+
const parseHeaders = (rawHeaders) => {
|
|
1201
|
+
const parsed = {};
|
|
1202
|
+
let key;
|
|
1203
|
+
let val;
|
|
1204
|
+
let i;
|
|
943
1205
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1206
|
+
rawHeaders &&
|
|
1207
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
1208
|
+
i = line.indexOf(':');
|
|
1209
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1210
|
+
val = line.substring(i + 1).trim();
|
|
947
1211
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
// Make message enumerable to maintain backward compatibility
|
|
963
|
-
// The native Error constructor sets message as non-enumerable,
|
|
964
|
-
// but axios < v1.13.3 had it as enumerable
|
|
965
|
-
Object.defineProperty(this, 'message', {
|
|
966
|
-
value: message,
|
|
967
|
-
enumerable: true,
|
|
968
|
-
writable: true,
|
|
969
|
-
configurable: true
|
|
970
|
-
});
|
|
971
|
-
|
|
972
|
-
this.name = 'AxiosError';
|
|
973
|
-
this.isAxiosError = true;
|
|
974
|
-
code && (this.code = code);
|
|
975
|
-
config && (this.config = config);
|
|
976
|
-
request && (this.request = request);
|
|
977
|
-
if (response) {
|
|
978
|
-
this.response = response;
|
|
979
|
-
this.status = response.status;
|
|
1212
|
+
const hasKey = utils$1.hasOwnProp(parsed, key);
|
|
1213
|
+
|
|
1214
|
+
if (!key || (hasKey && utils$1.hasOwnProp(ignoreDuplicateOf, key))) {
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
if (key === 'set-cookie') {
|
|
1219
|
+
if (hasKey) {
|
|
1220
|
+
parsed[key].push(val);
|
|
1221
|
+
} else {
|
|
1222
|
+
parsed[key] = [val];
|
|
1223
|
+
}
|
|
1224
|
+
} else {
|
|
1225
|
+
parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
|
|
980
1226
|
}
|
|
1227
|
+
});
|
|
1228
|
+
|
|
1229
|
+
return parsed;
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
function trimSPorHTAB(str) {
|
|
1233
|
+
let start = 0;
|
|
1234
|
+
let end = str.length;
|
|
1235
|
+
|
|
1236
|
+
while (start < end) {
|
|
1237
|
+
const code = str.charCodeAt(start);
|
|
1238
|
+
|
|
1239
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1240
|
+
break;
|
|
981
1241
|
}
|
|
982
1242
|
|
|
983
|
-
|
|
984
|
-
return {
|
|
985
|
-
// Standard
|
|
986
|
-
message: this.message,
|
|
987
|
-
name: this.name,
|
|
988
|
-
// Microsoft
|
|
989
|
-
description: this.description,
|
|
990
|
-
number: this.number,
|
|
991
|
-
// Mozilla
|
|
992
|
-
fileName: this.fileName,
|
|
993
|
-
lineNumber: this.lineNumber,
|
|
994
|
-
columnNumber: this.columnNumber,
|
|
995
|
-
stack: this.stack,
|
|
996
|
-
// Axios
|
|
997
|
-
config: utils$1.toJSONObject(this.config),
|
|
998
|
-
code: this.code,
|
|
999
|
-
status: this.status,
|
|
1000
|
-
};
|
|
1243
|
+
start += 1;
|
|
1001
1244
|
}
|
|
1002
|
-
};
|
|
1003
1245
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1007
|
-
AxiosError$1.ECONNABORTED = 'ECONNABORTED';
|
|
1008
|
-
AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';
|
|
1009
|
-
AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';
|
|
1010
|
-
AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1011
|
-
AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1012
|
-
AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1013
|
-
AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1014
|
-
AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
|
|
1015
|
-
AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1016
|
-
AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1246
|
+
while (end > start) {
|
|
1247
|
+
const code = str.charCodeAt(end - 1);
|
|
1017
1248
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1249
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1020
1252
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
*
|
|
1026
|
-
* @returns {boolean}
|
|
1027
|
-
*/
|
|
1028
|
-
function isVisitable(thing) {
|
|
1029
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1253
|
+
end -= 1;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
1030
1257
|
}
|
|
1031
1258
|
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1259
|
+
// The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
|
|
1260
|
+
// eslint-disable-next-line no-control-regex
|
|
1261
|
+
const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
|
|
1262
|
+
// eslint-disable-next-line no-control-regex
|
|
1263
|
+
const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
|
|
1264
|
+
|
|
1265
|
+
function sanitizeValue(value, invalidChars) {
|
|
1266
|
+
if (utils$1.isArray(value)) {
|
|
1267
|
+
return value.map((item) => sanitizeValue(item, invalidChars));
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
return trimSPorHTAB(String(value).replace(invalidChars, ''));
|
|
1041
1271
|
}
|
|
1042
1272
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
// eslint-disable-next-line no-param-reassign
|
|
1058
|
-
token = removeBrackets(token);
|
|
1059
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
1060
|
-
})
|
|
1061
|
-
.join(dots ? '.' : '');
|
|
1273
|
+
const sanitizeHeaderValue = (value) =>
|
|
1274
|
+
sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
|
|
1275
|
+
|
|
1276
|
+
const sanitizeByteStringHeaderValue = (value) =>
|
|
1277
|
+
sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
|
|
1278
|
+
|
|
1279
|
+
function toByteStringHeaderObject(headers) {
|
|
1280
|
+
const byteStringHeaders = Object.create(null);
|
|
1281
|
+
|
|
1282
|
+
utils$1.forEach(headers.toJSON(), (value, header) => {
|
|
1283
|
+
byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
|
|
1284
|
+
});
|
|
1285
|
+
|
|
1286
|
+
return byteStringHeaders;
|
|
1062
1287
|
}
|
|
1063
1288
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
*
|
|
1069
|
-
* @returns {boolean}
|
|
1070
|
-
*/
|
|
1071
|
-
function isFlatArray(arr) {
|
|
1072
|
-
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
1289
|
+
const $internals$1 = Symbol('internals');
|
|
1290
|
+
|
|
1291
|
+
function normalizeHeader(header) {
|
|
1292
|
+
return header && String(header).trim().toLowerCase();
|
|
1073
1293
|
}
|
|
1074
1294
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1295
|
+
function normalizeValue(value) {
|
|
1296
|
+
if (value === false || value == null) {
|
|
1297
|
+
return value;
|
|
1298
|
+
}
|
|
1078
1299
|
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
*
|
|
1082
|
-
* @param {Object} obj
|
|
1083
|
-
* @param {?Object} [formData]
|
|
1084
|
-
* @param {?Object} [options]
|
|
1085
|
-
* @param {Function} [options.visitor]
|
|
1086
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
1087
|
-
* @param {Boolean} [options.dots = false]
|
|
1088
|
-
* @param {?Boolean} [options.indexes = false]
|
|
1089
|
-
*
|
|
1090
|
-
* @returns {Object}
|
|
1091
|
-
**/
|
|
1300
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
1301
|
+
}
|
|
1092
1302
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
*
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
* @returns
|
|
1101
|
-
*/
|
|
1102
|
-
function toFormData$1(obj, formData, options) {
|
|
1103
|
-
if (!utils$1.isObject(obj)) {
|
|
1104
|
-
throw new TypeError('target must be an object');
|
|
1303
|
+
function parseTokens(str) {
|
|
1304
|
+
const tokens = Object.create(null);
|
|
1305
|
+
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
1306
|
+
let match;
|
|
1307
|
+
|
|
1308
|
+
while ((match = tokensRE.exec(str))) {
|
|
1309
|
+
tokens[match[1]] = match[2];
|
|
1105
1310
|
}
|
|
1106
1311
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1312
|
+
return tokens;
|
|
1313
|
+
}
|
|
1109
1314
|
|
|
1110
|
-
|
|
1111
|
-
options = utils$1.toFlatObject(
|
|
1112
|
-
options,
|
|
1113
|
-
{
|
|
1114
|
-
metaTokens: true,
|
|
1115
|
-
dots: false,
|
|
1116
|
-
indexes: false,
|
|
1117
|
-
},
|
|
1118
|
-
false,
|
|
1119
|
-
function defined(option, source) {
|
|
1120
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1121
|
-
return !utils$1.isUndefined(source[option]);
|
|
1122
|
-
}
|
|
1123
|
-
);
|
|
1315
|
+
const parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
1124
1316
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
const dots = options.dots;
|
|
1129
|
-
const indexes = options.indexes;
|
|
1130
|
-
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1131
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1317
|
+
function trimOWS(value) {
|
|
1318
|
+
let start = 0;
|
|
1319
|
+
let end = value.length;
|
|
1132
1320
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1321
|
+
while (start < end) {
|
|
1322
|
+
const code = value.charCodeAt(start);
|
|
1323
|
+
|
|
1324
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1325
|
+
break;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
start += 1;
|
|
1135
1329
|
}
|
|
1136
1330
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1331
|
+
while (end > start) {
|
|
1332
|
+
const code = value.charCodeAt(end - 1);
|
|
1139
1333
|
|
|
1140
|
-
if (
|
|
1141
|
-
|
|
1334
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1335
|
+
break;
|
|
1142
1336
|
}
|
|
1143
1337
|
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
}
|
|
1338
|
+
end -= 1;
|
|
1339
|
+
}
|
|
1147
1340
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1341
|
+
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
1342
|
+
}
|
|
1151
1343
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
}
|
|
1344
|
+
function decodeQuotedString(value) {
|
|
1345
|
+
const last = value.length - 1;
|
|
1155
1346
|
|
|
1347
|
+
if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
|
|
1156
1348
|
return value;
|
|
1157
1349
|
}
|
|
1158
1350
|
|
|
1159
|
-
|
|
1160
|
-
* Default visitor.
|
|
1161
|
-
*
|
|
1162
|
-
* @param {*} value
|
|
1163
|
-
* @param {String|Number} key
|
|
1164
|
-
* @param {Array<String|Number>} path
|
|
1165
|
-
* @this {FormData}
|
|
1166
|
-
*
|
|
1167
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
1168
|
-
*/
|
|
1169
|
-
function defaultVisitor(value, key, path) {
|
|
1170
|
-
let arr = value;
|
|
1351
|
+
let decoded = '';
|
|
1171
1352
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1353
|
+
for (let i = 1; i < last; i++) {
|
|
1354
|
+
const code = value.charCodeAt(i);
|
|
1355
|
+
|
|
1356
|
+
if (code === 0x22) {
|
|
1357
|
+
return value;
|
|
1175
1358
|
}
|
|
1176
1359
|
|
|
1177
|
-
if (
|
|
1178
|
-
|
|
1179
|
-
// eslint-disable-next-line no-param-reassign
|
|
1180
|
-
key = metaTokens ? key : key.slice(0, -2);
|
|
1181
|
-
// eslint-disable-next-line no-param-reassign
|
|
1182
|
-
value = JSON.stringify(value);
|
|
1183
|
-
} else if (
|
|
1184
|
-
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1185
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1186
|
-
) {
|
|
1187
|
-
// eslint-disable-next-line no-param-reassign
|
|
1188
|
-
key = removeBrackets(key);
|
|
1360
|
+
if (code === 0x5c) {
|
|
1361
|
+
i += 1;
|
|
1189
1362
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
formData.append(
|
|
1193
|
-
// eslint-disable-next-line no-nested-ternary
|
|
1194
|
-
indexes === true
|
|
1195
|
-
? renderKey([key], index, dots)
|
|
1196
|
-
: indexes === null
|
|
1197
|
-
? key
|
|
1198
|
-
: key + '[]',
|
|
1199
|
-
convertValue(el)
|
|
1200
|
-
);
|
|
1201
|
-
});
|
|
1202
|
-
return false;
|
|
1363
|
+
if (i >= last) {
|
|
1364
|
+
return value;
|
|
1203
1365
|
}
|
|
1204
1366
|
}
|
|
1205
1367
|
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1368
|
+
decoded += value[i];
|
|
1369
|
+
}
|
|
1209
1370
|
|
|
1210
|
-
|
|
1371
|
+
return decoded;
|
|
1372
|
+
}
|
|
1211
1373
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1374
|
+
function parseParameters(value) {
|
|
1375
|
+
const parameters = Object.create(null);
|
|
1376
|
+
const str = String(value);
|
|
1377
|
+
let start = 0;
|
|
1378
|
+
let quoted = false;
|
|
1379
|
+
let escaped = false;
|
|
1214
1380
|
|
|
1215
|
-
|
|
1381
|
+
function parseParameter(end) {
|
|
1382
|
+
const part = trimOWS(str.slice(start, end));
|
|
1383
|
+
const equals = part.indexOf('=');
|
|
1216
1384
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
isVisitable,
|
|
1221
|
-
});
|
|
1385
|
+
if (equals < 1) {
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1222
1388
|
|
|
1223
|
-
|
|
1224
|
-
if (utils$1.isUndefined(value)) return;
|
|
1389
|
+
const name = trimOWS(part.slice(0, equals));
|
|
1225
1390
|
|
|
1226
|
-
if (
|
|
1227
|
-
|
|
1391
|
+
if (!parameterNameRE.test(name)) {
|
|
1392
|
+
return;
|
|
1228
1393
|
}
|
|
1229
1394
|
|
|
1230
|
-
|
|
1395
|
+
const normalizedName = name.toLowerCase();
|
|
1231
1396
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1397
|
+
if (
|
|
1398
|
+
normalizedName === '__proto__' ||
|
|
1399
|
+
normalizedName === 'constructor' ||
|
|
1400
|
+
normalizedName === 'prototype'
|
|
1401
|
+
) {
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1236
1404
|
|
|
1237
|
-
|
|
1238
|
-
|
|
1405
|
+
const parameterValue = trimOWS(part.slice(equals + 1));
|
|
1406
|
+
parameters[normalizedName] = decodeQuotedString(parameterValue);
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
for (let i = 0; i < str.length; i++) {
|
|
1410
|
+
const code = str.charCodeAt(i);
|
|
1411
|
+
|
|
1412
|
+
if (quoted) {
|
|
1413
|
+
if (escaped) {
|
|
1414
|
+
escaped = false;
|
|
1415
|
+
} else if (code === 0x5c) {
|
|
1416
|
+
escaped = true;
|
|
1417
|
+
} else if (code === 0x22) {
|
|
1418
|
+
quoted = false;
|
|
1239
1419
|
}
|
|
1240
|
-
})
|
|
1420
|
+
} else if (code === 0x22) {
|
|
1421
|
+
quoted = true;
|
|
1422
|
+
} else if (code === 0x2c || code === 0x3b) {
|
|
1423
|
+
parseParameter(i);
|
|
1424
|
+
start = i + 1;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1241
1427
|
|
|
1242
|
-
|
|
1428
|
+
parseParameter(str.length);
|
|
1429
|
+
|
|
1430
|
+
return parameters;
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1434
|
+
|
|
1435
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1436
|
+
if (utils$1.isFunction(filter)) {
|
|
1437
|
+
return filter.call(this, value, header);
|
|
1243
1438
|
}
|
|
1244
1439
|
|
|
1245
|
-
if (
|
|
1246
|
-
|
|
1440
|
+
if (isHeaderNameFilter) {
|
|
1441
|
+
value = header;
|
|
1247
1442
|
}
|
|
1248
1443
|
|
|
1249
|
-
|
|
1444
|
+
if (!utils$1.isString(value)) return;
|
|
1250
1445
|
|
|
1251
|
-
|
|
1446
|
+
if (utils$1.isString(filter)) {
|
|
1447
|
+
return value.indexOf(filter) !== -1;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
if (utils$1.isRegExp(filter)) {
|
|
1451
|
+
return filter.test(value);
|
|
1452
|
+
}
|
|
1252
1453
|
}
|
|
1253
1454
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
*/
|
|
1262
|
-
function encode$1(str) {
|
|
1263
|
-
const charMap = {
|
|
1264
|
-
'!': '%21',
|
|
1265
|
-
"'": '%27',
|
|
1266
|
-
'(': '%28',
|
|
1267
|
-
')': '%29',
|
|
1268
|
-
'~': '%7E',
|
|
1269
|
-
'%20': '+',
|
|
1270
|
-
'%00': '\x00',
|
|
1271
|
-
};
|
|
1272
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
1273
|
-
return charMap[match];
|
|
1274
|
-
});
|
|
1455
|
+
function formatHeader(header) {
|
|
1456
|
+
return header
|
|
1457
|
+
.trim()
|
|
1458
|
+
.toLowerCase()
|
|
1459
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1460
|
+
return char.toUpperCase() + str;
|
|
1461
|
+
});
|
|
1275
1462
|
}
|
|
1276
1463
|
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
*
|
|
1280
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
1281
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
1282
|
-
*
|
|
1283
|
-
* @returns {void}
|
|
1284
|
-
*/
|
|
1285
|
-
function AxiosURLSearchParams(params, options) {
|
|
1286
|
-
this._pairs = [];
|
|
1464
|
+
function buildAccessors(obj, header) {
|
|
1465
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1287
1466
|
|
|
1288
|
-
|
|
1467
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
1468
|
+
Object.defineProperty(obj, methodName + accessorName, {
|
|
1469
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1470
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1471
|
+
__proto__: null,
|
|
1472
|
+
value: function (arg1, arg2, arg3) {
|
|
1473
|
+
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1474
|
+
},
|
|
1475
|
+
configurable: true,
|
|
1476
|
+
});
|
|
1477
|
+
});
|
|
1289
1478
|
}
|
|
1290
1479
|
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
};
|
|
1480
|
+
let AxiosHeaders$1 = class AxiosHeaders {
|
|
1481
|
+
constructor(headers) {
|
|
1482
|
+
headers && this.set(headers);
|
|
1483
|
+
}
|
|
1296
1484
|
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1485
|
+
set(header, valueOrRewrite, rewrite) {
|
|
1486
|
+
const self = this;
|
|
1487
|
+
|
|
1488
|
+
function setHeader(_value, _header, _rewrite) {
|
|
1489
|
+
const lHeader = normalizeHeader(_header);
|
|
1490
|
+
|
|
1491
|
+
if (!lHeader) {
|
|
1492
|
+
return;
|
|
1301
1493
|
}
|
|
1302
|
-
: encode$1;
|
|
1303
1494
|
|
|
1304
|
-
|
|
1305
|
-
.map(function each(pair) {
|
|
1306
|
-
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1307
|
-
}, '')
|
|
1308
|
-
.join('&');
|
|
1309
|
-
};
|
|
1495
|
+
const key = utils$1.findKey(self, lHeader);
|
|
1310
1496
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
return encodeURIComponent(val)
|
|
1321
|
-
.replace(/%3A/gi, ':')
|
|
1322
|
-
.replace(/%24/g, '$')
|
|
1323
|
-
.replace(/%2C/gi, ',')
|
|
1324
|
-
.replace(/%20/g, '+');
|
|
1325
|
-
}
|
|
1497
|
+
if (
|
|
1498
|
+
!key ||
|
|
1499
|
+
self[key] === undefined ||
|
|
1500
|
+
_rewrite === true ||
|
|
1501
|
+
(_rewrite === undefined && self[key] !== false)
|
|
1502
|
+
) {
|
|
1503
|
+
self[key || _header] = normalizeValue(_value);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1326
1506
|
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1507
|
+
const setHeaders = (headers, _rewrite) =>
|
|
1508
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1509
|
+
|
|
1510
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1511
|
+
setHeaders(header, valueOrRewrite);
|
|
1512
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1513
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1514
|
+
} else if (utils$1.isObject(header) && utils$1.isSafeIterable(header)) {
|
|
1515
|
+
let obj = Object.create(null),
|
|
1516
|
+
dest,
|
|
1517
|
+
key;
|
|
1518
|
+
for (const entry of header) {
|
|
1519
|
+
if (!utils$1.isArray(entry)) {
|
|
1520
|
+
throw new TypeError('Object iterator must return a key-value pair');
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
key = entry[0];
|
|
1524
|
+
|
|
1525
|
+
if (utils$1.hasOwnProp(obj, key)) {
|
|
1526
|
+
dest = obj[key];
|
|
1527
|
+
obj[key] = utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]];
|
|
1528
|
+
} else {
|
|
1529
|
+
obj[key] = entry[1];
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
setHeaders(obj, valueOrRewrite);
|
|
1534
|
+
} else {
|
|
1535
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
return this;
|
|
1339
1539
|
}
|
|
1340
1540
|
|
|
1341
|
-
|
|
1541
|
+
get(header, parser) {
|
|
1542
|
+
header = normalizeHeader(header);
|
|
1342
1543
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1544
|
+
if (header) {
|
|
1545
|
+
const key = utils$1.findKey(this, header);
|
|
1546
|
+
|
|
1547
|
+
if (key) {
|
|
1548
|
+
const value = this[key];
|
|
1549
|
+
|
|
1550
|
+
if (!parser) {
|
|
1551
|
+
return value;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
if (parser === true) {
|
|
1555
|
+
return parseTokens(value);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
if (utils$1.isFunction(parser)) {
|
|
1559
|
+
return parser.call(this, value, key);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
if (utils$1.isRegExp(parser)) {
|
|
1563
|
+
return parser.exec(value);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
|
1346
1567
|
}
|
|
1347
|
-
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1348
1570
|
|
|
1349
|
-
|
|
1571
|
+
has(header, matcher) {
|
|
1572
|
+
header = normalizeHeader(header);
|
|
1350
1573
|
|
|
1351
|
-
|
|
1574
|
+
if (header) {
|
|
1575
|
+
const key = utils$1.findKey(this, header);
|
|
1352
1576
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1577
|
+
return !!(
|
|
1578
|
+
key &&
|
|
1579
|
+
this[key] !== undefined &&
|
|
1580
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
return false;
|
|
1359
1585
|
}
|
|
1360
1586
|
|
|
1361
|
-
|
|
1362
|
-
const
|
|
1587
|
+
delete(header, matcher) {
|
|
1588
|
+
const self = this;
|
|
1589
|
+
let deleted = false;
|
|
1363
1590
|
|
|
1364
|
-
|
|
1365
|
-
|
|
1591
|
+
function deleteHeader(_header) {
|
|
1592
|
+
_header = normalizeHeader(_header);
|
|
1593
|
+
|
|
1594
|
+
if (_header) {
|
|
1595
|
+
const key = utils$1.findKey(self, _header);
|
|
1596
|
+
|
|
1597
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1598
|
+
delete self[key];
|
|
1599
|
+
|
|
1600
|
+
deleted = true;
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1366
1603
|
}
|
|
1367
|
-
|
|
1604
|
+
|
|
1605
|
+
if (utils$1.isArray(header)) {
|
|
1606
|
+
header.forEach(deleteHeader);
|
|
1607
|
+
} else {
|
|
1608
|
+
deleteHeader(header);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
return deleted;
|
|
1368
1612
|
}
|
|
1369
1613
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1614
|
+
clear(matcher) {
|
|
1615
|
+
const keys = Object.keys(this);
|
|
1616
|
+
let i = keys.length;
|
|
1617
|
+
let deleted = false;
|
|
1372
1618
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1619
|
+
while (i--) {
|
|
1620
|
+
const key = keys[i];
|
|
1621
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
1622
|
+
delete this[key];
|
|
1623
|
+
deleted = true;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
return deleted;
|
|
1376
1628
|
}
|
|
1377
1629
|
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1630
|
+
normalize(format) {
|
|
1631
|
+
const self = this;
|
|
1632
|
+
const headers = {};
|
|
1633
|
+
|
|
1634
|
+
utils$1.forEach(this, (value, header) => {
|
|
1635
|
+
const key = utils$1.findKey(headers, header);
|
|
1636
|
+
|
|
1637
|
+
if (key) {
|
|
1638
|
+
self[key] = normalizeValue(value);
|
|
1639
|
+
delete self[header];
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
1644
|
+
|
|
1645
|
+
if (normalized !== header) {
|
|
1646
|
+
delete self[header];
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
self[normalized] = normalizeValue(value);
|
|
1650
|
+
|
|
1651
|
+
headers[normalized] = true;
|
|
1393
1652
|
});
|
|
1394
|
-
|
|
1653
|
+
|
|
1654
|
+
return this;
|
|
1395
1655
|
}
|
|
1396
1656
|
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1657
|
+
concat(...targets) {
|
|
1658
|
+
return this.constructor.concat(this, ...targets);
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
toJSON(asStrings) {
|
|
1662
|
+
const obj = Object.create(null);
|
|
1663
|
+
|
|
1664
|
+
utils$1.forEach(this, (value, header) => {
|
|
1665
|
+
value != null &&
|
|
1666
|
+
value !== false &&
|
|
1667
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
1668
|
+
});
|
|
1669
|
+
|
|
1670
|
+
return obj;
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
[Symbol.iterator]() {
|
|
1674
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
toString() {
|
|
1678
|
+
return Object.entries(this.toJSON())
|
|
1679
|
+
.map(([header, value]) => header + ': ' + value)
|
|
1680
|
+
.join('\n');
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
getSetCookie() {
|
|
1684
|
+
const value = this.get('set-cookie');
|
|
1685
|
+
return utils$1.isArray(value) ? value : value == null || value === false ? [] : [value];
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
get [Symbol.toStringTag]() {
|
|
1689
|
+
return 'AxiosHeaders';
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
static from(thing) {
|
|
1693
|
+
return thing instanceof this ? thing : new this(thing);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
static parseParameters(value) {
|
|
1697
|
+
return parseParameters(value);
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
static concat(first, ...targets) {
|
|
1701
|
+
const computed = new this(first);
|
|
1702
|
+
|
|
1703
|
+
targets.forEach((target) => computed.set(target));
|
|
1704
|
+
|
|
1705
|
+
return computed;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
static accessor(header) {
|
|
1709
|
+
const internals =
|
|
1710
|
+
(this[$internals$1] =
|
|
1711
|
+
this[$internals$1] =
|
|
1712
|
+
{
|
|
1713
|
+
accessors: {},
|
|
1714
|
+
});
|
|
1715
|
+
|
|
1716
|
+
const accessors = internals.accessors;
|
|
1717
|
+
const prototype = this.prototype;
|
|
1718
|
+
|
|
1719
|
+
function defineAccessor(_header) {
|
|
1720
|
+
const lHeader = normalizeHeader(_header);
|
|
1721
|
+
|
|
1722
|
+
if (!accessors[lHeader]) {
|
|
1723
|
+
buildAccessors(prototype, _header);
|
|
1724
|
+
accessors[lHeader] = true;
|
|
1725
|
+
}
|
|
1407
1726
|
}
|
|
1727
|
+
|
|
1728
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1729
|
+
|
|
1730
|
+
return this;
|
|
1408
1731
|
}
|
|
1732
|
+
};
|
|
1409
1733
|
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1734
|
+
AxiosHeaders$1.accessor([
|
|
1735
|
+
'Content-Type',
|
|
1736
|
+
'Content-Length',
|
|
1737
|
+
'Accept',
|
|
1738
|
+
'Accept-Encoding',
|
|
1739
|
+
'User-Agent',
|
|
1740
|
+
'Authorization',
|
|
1741
|
+
]);
|
|
1742
|
+
|
|
1743
|
+
// reserved names hotfix
|
|
1744
|
+
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
1745
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
1746
|
+
return {
|
|
1747
|
+
get: () => value,
|
|
1748
|
+
set(headerValue) {
|
|
1749
|
+
this[mapped] = headerValue;
|
|
1750
|
+
},
|
|
1751
|
+
};
|
|
1752
|
+
});
|
|
1753
|
+
|
|
1754
|
+
utils$1.freezeMethods(AxiosHeaders$1);
|
|
1755
|
+
|
|
1756
|
+
const REDACTED = '[REDACTED ****]';
|
|
1757
|
+
|
|
1758
|
+
function hasOwnOrPrototypeToJSON(source) {
|
|
1759
|
+
if (utils$1.hasOwnProp(source, 'toJSON')) {
|
|
1760
|
+
return true;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
let prototype = Object.getPrototypeOf(source);
|
|
1764
|
+
|
|
1765
|
+
while (prototype && prototype !== Object.prototype) {
|
|
1766
|
+
if (utils$1.hasOwnProp(prototype, 'toJSON')) {
|
|
1767
|
+
return true;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
return false;
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
// Build a plain-object snapshot of `config` and replace the value of any key
|
|
1777
|
+
// (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|
1778
|
+
// and AxiosHeaders, and short-circuits on circular references.
|
|
1779
|
+
function redactConfig(config, redactKeys) {
|
|
1780
|
+
const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
|
|
1781
|
+
const seen = [];
|
|
1782
|
+
|
|
1783
|
+
const visit = (source) => {
|
|
1784
|
+
if (source === null || typeof source !== 'object') return source;
|
|
1785
|
+
if (utils$1.isBuffer(source)) return source;
|
|
1786
|
+
if (seen.indexOf(source) !== -1) return undefined;
|
|
1787
|
+
|
|
1788
|
+
if (source instanceof AxiosHeaders$1) {
|
|
1789
|
+
source = source.toJSON();
|
|
1418
1790
|
}
|
|
1791
|
+
|
|
1792
|
+
seen.push(source);
|
|
1793
|
+
|
|
1794
|
+
let result;
|
|
1795
|
+
if (utils$1.isArray(source)) {
|
|
1796
|
+
result = [];
|
|
1797
|
+
source.forEach((v, i) => {
|
|
1798
|
+
const reducedValue = visit(v);
|
|
1799
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1800
|
+
result[i] = reducedValue;
|
|
1801
|
+
}
|
|
1802
|
+
});
|
|
1803
|
+
} else {
|
|
1804
|
+
if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|
1805
|
+
seen.pop();
|
|
1806
|
+
return source;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
result = Object.create(null);
|
|
1810
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1811
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
|
|
1812
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1813
|
+
result[key] = reducedValue;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
seen.pop();
|
|
1819
|
+
return result;
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1822
|
+
return visit(config);
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
function stringifySafely$1(value) {
|
|
1826
|
+
try {
|
|
1827
|
+
return String(value);
|
|
1828
|
+
} catch (err) {
|
|
1829
|
+
return '';
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
function aggregateErrorMessage(error) {
|
|
1834
|
+
const message = error.errors
|
|
1835
|
+
.map((entry) => {
|
|
1836
|
+
try {
|
|
1837
|
+
return entry && entry.message ? stringifySafely$1(entry.message) : stringifySafely$1(entry);
|
|
1838
|
+
} catch (err) {
|
|
1839
|
+
return '';
|
|
1840
|
+
}
|
|
1841
|
+
})
|
|
1842
|
+
.filter(Boolean)
|
|
1843
|
+
.join('; ');
|
|
1844
|
+
|
|
1845
|
+
return message || error.name || 'AggregateError';
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
let AxiosError$1 = class AxiosError extends Error {
|
|
1849
|
+
static from(error, code, config, request, response, customProps) {
|
|
1850
|
+
// `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
|
|
1851
|
+
// failures) has an empty `message`; its detail lives in `errors[]`. Without
|
|
1852
|
+
// this, the wrapped error surfaces with a blank message (see #6721).
|
|
1853
|
+
let message = error.message;
|
|
1854
|
+
if (!message && utils$1.isArray(error.errors) && error.errors.length) {
|
|
1855
|
+
message = aggregateErrorMessage(error);
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
const axiosError = new AxiosError(message, code || error.code, config, request, response);
|
|
1859
|
+
// Match native `Error` `cause` semantics: non-enumerable. The wrapped
|
|
1860
|
+
// error often carries circular internals (sockets, requests, agents), so
|
|
1861
|
+
// an enumerable `cause` makes structured loggers (pino/winston) and any
|
|
1862
|
+
// own-property walk throw "Converting circular structure to JSON".
|
|
1863
|
+
// Regression from #6982; see #7205. `__proto__: null` mirrors the
|
|
1864
|
+
// `message` descriptor below (prototype-pollution-safe descriptor).
|
|
1865
|
+
Object.defineProperty(axiosError, 'cause', {
|
|
1866
|
+
__proto__: null,
|
|
1867
|
+
value: error,
|
|
1868
|
+
writable: true,
|
|
1869
|
+
enumerable: false,
|
|
1870
|
+
configurable: true,
|
|
1871
|
+
});
|
|
1872
|
+
axiosError.name = error.name;
|
|
1873
|
+
|
|
1874
|
+
// Preserve status from the original error if not already set from response
|
|
1875
|
+
if (error.status != null && axiosError.status == null) {
|
|
1876
|
+
axiosError.status = error.status;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1880
|
+
return axiosError;
|
|
1419
1881
|
}
|
|
1420
1882
|
|
|
1421
1883
|
/**
|
|
1422
|
-
*
|
|
1884
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1423
1885
|
*
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1886
|
+
* @param {string} message The error message.
|
|
1887
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1888
|
+
* @param {Object} [config] The config.
|
|
1889
|
+
* @param {Object} [request] The request.
|
|
1890
|
+
* @param {Object} [response] The response.
|
|
1426
1891
|
*
|
|
1427
|
-
* @
|
|
1428
|
-
*
|
|
1429
|
-
* @returns {void}
|
|
1892
|
+
* @returns {Error} The created error.
|
|
1430
1893
|
*/
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1894
|
+
constructor(message, code, config, request, response) {
|
|
1895
|
+
super(message);
|
|
1896
|
+
|
|
1897
|
+
// Make message enumerable to maintain backward compatibility
|
|
1898
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1899
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1900
|
+
Object.defineProperty(this, 'message', {
|
|
1901
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1902
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1903
|
+
__proto__: null,
|
|
1904
|
+
value: message,
|
|
1905
|
+
enumerable: true,
|
|
1906
|
+
writable: true,
|
|
1907
|
+
configurable: true,
|
|
1436
1908
|
});
|
|
1909
|
+
|
|
1910
|
+
this.name = 'AxiosError';
|
|
1911
|
+
this.isAxiosError = true;
|
|
1912
|
+
code && (this.code = code);
|
|
1913
|
+
config && (this.config = config);
|
|
1914
|
+
request && (this.request = request);
|
|
1915
|
+
if (response) {
|
|
1916
|
+
this.response = response;
|
|
1917
|
+
this.status = response.status;
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
toJSON() {
|
|
1922
|
+
// Opt-in redaction: when the request config carries a `redact` array, the
|
|
1923
|
+
// value of any matching key (case-insensitive, at any depth) is replaced
|
|
1924
|
+
// with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|
1925
|
+
// existing serialization behavior unchanged.
|
|
1926
|
+
const config = this.config;
|
|
1927
|
+
const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|
1928
|
+
const serializedConfig =
|
|
1929
|
+
utils$1.isArray(redactKeys) && redactKeys.length > 0
|
|
1930
|
+
? redactConfig(config, redactKeys)
|
|
1931
|
+
: utils$1.toJSONObject(config);
|
|
1932
|
+
|
|
1933
|
+
return {
|
|
1934
|
+
// Standard
|
|
1935
|
+
message: this.message,
|
|
1936
|
+
name: this.name,
|
|
1937
|
+
// Microsoft
|
|
1938
|
+
description: this.description,
|
|
1939
|
+
number: this.number,
|
|
1940
|
+
// Mozilla
|
|
1941
|
+
fileName: this.fileName,
|
|
1942
|
+
lineNumber: this.lineNumber,
|
|
1943
|
+
columnNumber: this.columnNumber,
|
|
1944
|
+
stack: this.stack,
|
|
1945
|
+
// Axios
|
|
1946
|
+
config: serializedConfig,
|
|
1947
|
+
code: this.code,
|
|
1948
|
+
status: this.status,
|
|
1949
|
+
};
|
|
1437
1950
|
}
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
const transitionalDefaults = {
|
|
1441
|
-
silentJSONParsing: true,
|
|
1442
|
-
forcedJSONParsing: true,
|
|
1443
|
-
clarifyTimeoutError: false,
|
|
1444
|
-
legacyInterceptorReqResOrdering: true,
|
|
1445
1951
|
};
|
|
1446
1952
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1953
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
1954
|
+
AxiosError$1.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
1955
|
+
AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1956
|
+
AxiosError$1.ECONNABORTED = 'ECONNABORTED';
|
|
1957
|
+
AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';
|
|
1958
|
+
AxiosError$1.ECONNREFUSED = 'ECONNREFUSED';
|
|
1959
|
+
AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';
|
|
1960
|
+
AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1961
|
+
AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1962
|
+
AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1963
|
+
AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1964
|
+
AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
|
|
1965
|
+
AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1966
|
+
AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1967
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1462
1968
|
|
|
1463
|
-
|
|
1969
|
+
// eslint-disable-next-line strict
|
|
1970
|
+
const httpAdapter = null;
|
|
1464
1971
|
|
|
1465
|
-
|
|
1972
|
+
// Default nesting limit shared with the inverse transform (formDataToJSON) so
|
|
1973
|
+
// the FormData <-> JSON round-trip stays symmetric.
|
|
1974
|
+
const DEFAULT_FORM_DATA_MAX_DEPTH = 100;
|
|
1466
1975
|
|
|
1467
1976
|
/**
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
* This allows axios to run in a web worker, and react-native.
|
|
1471
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
1472
|
-
*
|
|
1473
|
-
* web workers:
|
|
1474
|
-
* typeof window -> undefined
|
|
1475
|
-
* typeof document -> undefined
|
|
1977
|
+
* Determines if the given thing is a array or js object.
|
|
1476
1978
|
*
|
|
1477
|
-
*
|
|
1478
|
-
* navigator.product -> 'ReactNative'
|
|
1479
|
-
* nativescript
|
|
1480
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
1979
|
+
* @param {string} thing - The object or array to be visited.
|
|
1481
1980
|
*
|
|
1482
1981
|
* @returns {boolean}
|
|
1483
1982
|
*/
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1983
|
+
function isVisitable(thing) {
|
|
1984
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1985
|
+
}
|
|
1487
1986
|
|
|
1488
1987
|
/**
|
|
1489
|
-
*
|
|
1988
|
+
* It removes the brackets from the end of a string
|
|
1490
1989
|
*
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1494
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
1495
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
1990
|
+
* @param {string} key - The key of the parameter.
|
|
1991
|
+
*
|
|
1992
|
+
* @returns {string} the key without the brackets.
|
|
1496
1993
|
*/
|
|
1497
|
-
|
|
1498
|
-
return (
|
|
1499
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
|
1500
|
-
// eslint-disable-next-line no-undef
|
|
1501
|
-
self instanceof WorkerGlobalScope &&
|
|
1502
|
-
typeof self.importScripts === 'function'
|
|
1503
|
-
);
|
|
1504
|
-
})();
|
|
1505
|
-
|
|
1506
|
-
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
1507
|
-
|
|
1508
|
-
const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
1509
|
-
__proto__: null,
|
|
1510
|
-
hasBrowserEnv,
|
|
1511
|
-
hasStandardBrowserEnv,
|
|
1512
|
-
hasStandardBrowserWebWorkerEnv,
|
|
1513
|
-
navigator: _navigator,
|
|
1514
|
-
origin
|
|
1515
|
-
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1516
|
-
|
|
1517
|
-
const platform = {
|
|
1518
|
-
...utils,
|
|
1519
|
-
...platform$1,
|
|
1520
|
-
};
|
|
1521
|
-
|
|
1522
|
-
function toURLEncodedForm(data, options) {
|
|
1523
|
-
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
1524
|
-
visitor: function (value, key, path, helpers) {
|
|
1525
|
-
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1526
|
-
this.append(key, value.toString('base64'));
|
|
1527
|
-
return false;
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
return helpers.defaultVisitor.apply(this, arguments);
|
|
1531
|
-
},
|
|
1532
|
-
...options,
|
|
1533
|
-
});
|
|
1994
|
+
function removeBrackets(key) {
|
|
1995
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1534
1996
|
}
|
|
1535
1997
|
|
|
1536
1998
|
/**
|
|
1537
|
-
* It takes a
|
|
1999
|
+
* It takes a path, a key, and a boolean, and returns a string
|
|
1538
2000
|
*
|
|
1539
|
-
* @param {string}
|
|
2001
|
+
* @param {string} path - The path to the current key.
|
|
2002
|
+
* @param {string} key - The key of the current object being iterated over.
|
|
2003
|
+
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
1540
2004
|
*
|
|
1541
|
-
* @returns
|
|
2005
|
+
* @returns {string} The path to the current key.
|
|
1542
2006
|
*/
|
|
1543
|
-
function
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
2007
|
+
function renderKey(path, key, dots) {
|
|
2008
|
+
if (!path) return key;
|
|
2009
|
+
return path
|
|
2010
|
+
.concat(key)
|
|
2011
|
+
.map(function each(token, i) {
|
|
2012
|
+
// eslint-disable-next-line no-param-reassign
|
|
2013
|
+
token = removeBrackets(token);
|
|
2014
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
2015
|
+
})
|
|
2016
|
+
.join(dots ? '.' : '');
|
|
1551
2017
|
}
|
|
1552
2018
|
|
|
1553
2019
|
/**
|
|
1554
|
-
*
|
|
2020
|
+
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
1555
2021
|
*
|
|
1556
|
-
* @param {Array<any>} arr - The array to
|
|
2022
|
+
* @param {Array<any>} arr - The array to check
|
|
1557
2023
|
*
|
|
1558
|
-
* @returns
|
|
2024
|
+
* @returns {boolean}
|
|
1559
2025
|
*/
|
|
1560
|
-
function
|
|
1561
|
-
|
|
1562
|
-
const keys = Object.keys(arr);
|
|
1563
|
-
let i;
|
|
1564
|
-
const len = keys.length;
|
|
1565
|
-
let key;
|
|
1566
|
-
for (i = 0; i < len; i++) {
|
|
1567
|
-
key = keys[i];
|
|
1568
|
-
obj[key] = arr[key];
|
|
1569
|
-
}
|
|
1570
|
-
return obj;
|
|
2026
|
+
function isFlatArray(arr) {
|
|
2027
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
1571
2028
|
}
|
|
1572
2029
|
|
|
2030
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
2031
|
+
return /^is[A-Z]/.test(prop);
|
|
2032
|
+
});
|
|
2033
|
+
|
|
1573
2034
|
/**
|
|
1574
|
-
*
|
|
2035
|
+
* Convert a data object to FormData
|
|
1575
2036
|
*
|
|
1576
|
-
* @param {
|
|
2037
|
+
* @param {Object} obj
|
|
2038
|
+
* @param {?Object} [formData]
|
|
2039
|
+
* @param {?Object} [options]
|
|
2040
|
+
* @param {Function} [options.visitor]
|
|
2041
|
+
* @param {Boolean} [options.metaTokens = true]
|
|
2042
|
+
* @param {Boolean} [options.dots = false]
|
|
2043
|
+
* @param {?Boolean} [options.indexes = false]
|
|
1577
2044
|
*
|
|
1578
|
-
* @returns {Object
|
|
2045
|
+
* @returns {Object}
|
|
2046
|
+
**/
|
|
2047
|
+
|
|
2048
|
+
/**
|
|
2049
|
+
* It converts an object into a FormData object
|
|
2050
|
+
*
|
|
2051
|
+
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
2052
|
+
* @param {string} formData - The FormData object to append to.
|
|
2053
|
+
* @param {Object<string, any>} options
|
|
2054
|
+
*
|
|
2055
|
+
* @returns
|
|
1579
2056
|
*/
|
|
1580
|
-
function
|
|
1581
|
-
|
|
1582
|
-
|
|
2057
|
+
function toFormData$1(obj, formData, options) {
|
|
2058
|
+
if (!utils$1.isObject(obj)) {
|
|
2059
|
+
throw new TypeError('target must be an object');
|
|
2060
|
+
}
|
|
1583
2061
|
|
|
1584
|
-
|
|
2062
|
+
// eslint-disable-next-line no-param-reassign
|
|
2063
|
+
formData = formData || new (FormData)();
|
|
1585
2064
|
|
|
1586
|
-
|
|
1587
|
-
const
|
|
1588
|
-
|
|
2065
|
+
const option = (name, fallback) => {
|
|
2066
|
+
const value = utils$1.getSafeProp(options, name);
|
|
2067
|
+
return utils$1.isUndefined(value) ? fallback : value;
|
|
2068
|
+
};
|
|
1589
2069
|
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
2070
|
+
const metaTokens = option('metaTokens', true);
|
|
2071
|
+
// eslint-disable-next-line no-use-before-define
|
|
2072
|
+
const visitor = option('visitor') || defaultVisitor;
|
|
2073
|
+
const dots = option('dots', false);
|
|
2074
|
+
const indexes = option('indexes', false);
|
|
2075
|
+
const _Blob = option('Blob') || (typeof Blob !== 'undefined' && Blob);
|
|
2076
|
+
const maxDepth = option('maxDepth', DEFAULT_FORM_DATA_MAX_DEPTH);
|
|
2077
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
2078
|
+
const stack = [];
|
|
1596
2079
|
|
|
1597
|
-
|
|
2080
|
+
if (!utils$1.isFunction(visitor)) {
|
|
2081
|
+
throw new TypeError('visitor must be a function');
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
function convertValue(value) {
|
|
2085
|
+
if (value === null) return '';
|
|
2086
|
+
|
|
2087
|
+
if (utils$1.isDate(value)) {
|
|
2088
|
+
return value.toISOString();
|
|
1598
2089
|
}
|
|
1599
2090
|
|
|
1600
|
-
if (
|
|
1601
|
-
|
|
2091
|
+
if (utils$1.isBoolean(value)) {
|
|
2092
|
+
return value.toString();
|
|
1602
2093
|
}
|
|
1603
2094
|
|
|
1604
|
-
|
|
2095
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
2096
|
+
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
2097
|
+
}
|
|
1605
2098
|
|
|
1606
|
-
if (
|
|
1607
|
-
|
|
2099
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
2100
|
+
if (useBlob && typeof _Blob === 'function') {
|
|
2101
|
+
return new _Blob([value]);
|
|
2102
|
+
}
|
|
2103
|
+
throw new AxiosError$1(
|
|
2104
|
+
'Blob is not supported. Use a Buffer instead.',
|
|
2105
|
+
AxiosError$1.ERR_NOT_SUPPORT
|
|
2106
|
+
);
|
|
1608
2107
|
}
|
|
1609
2108
|
|
|
1610
|
-
return
|
|
2109
|
+
return value;
|
|
1611
2110
|
}
|
|
1612
2111
|
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
return obj;
|
|
2112
|
+
function throwIfMaxDepthExceeded(depth) {
|
|
2113
|
+
if (depth > maxDepth) {
|
|
2114
|
+
throw new AxiosError$1(
|
|
2115
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
2116
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2117
|
+
);
|
|
2118
|
+
}
|
|
1621
2119
|
}
|
|
1622
2120
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
/**
|
|
1627
|
-
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1628
|
-
* of the input
|
|
1629
|
-
*
|
|
1630
|
-
* @param {any} rawValue - The value to be stringified.
|
|
1631
|
-
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
1632
|
-
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
1633
|
-
*
|
|
1634
|
-
* @returns {string} A stringified version of the rawValue.
|
|
1635
|
-
*/
|
|
1636
|
-
function stringifySafely(rawValue, parser, encoder) {
|
|
1637
|
-
if (utils$1.isString(rawValue)) {
|
|
1638
|
-
try {
|
|
1639
|
-
(parser || JSON.parse)(rawValue);
|
|
1640
|
-
return utils$1.trim(rawValue);
|
|
1641
|
-
} catch (e) {
|
|
1642
|
-
if (e.name !== 'SyntaxError') {
|
|
1643
|
-
throw e;
|
|
1644
|
-
}
|
|
2121
|
+
function stringifyWithDepthLimit(value, depth) {
|
|
2122
|
+
if (maxDepth === Infinity) {
|
|
2123
|
+
return JSON.stringify(value);
|
|
1645
2124
|
}
|
|
1646
|
-
}
|
|
1647
2125
|
|
|
1648
|
-
|
|
1649
|
-
}
|
|
2126
|
+
const ancestors = [];
|
|
1650
2127
|
|
|
1651
|
-
|
|
1652
|
-
|
|
2128
|
+
return JSON.stringify(value, function limitDepth(_key, currentValue) {
|
|
2129
|
+
if (!utils$1.isObject(currentValue)) {
|
|
2130
|
+
return currentValue;
|
|
2131
|
+
}
|
|
1653
2132
|
|
|
1654
|
-
|
|
2133
|
+
while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
|
|
2134
|
+
ancestors.pop();
|
|
2135
|
+
}
|
|
1655
2136
|
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
const contentType = headers.getContentType() || '';
|
|
1659
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1660
|
-
const isObjectPayload = utils$1.isObject(data);
|
|
2137
|
+
ancestors.push(currentValue);
|
|
2138
|
+
throwIfMaxDepthExceeded(depth + ancestors.length - 1);
|
|
1661
2139
|
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
2140
|
+
return currentValue;
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
1665
2143
|
|
|
1666
|
-
|
|
2144
|
+
/**
|
|
2145
|
+
* Default visitor.
|
|
2146
|
+
*
|
|
2147
|
+
* @param {*} value
|
|
2148
|
+
* @param {String|Number} key
|
|
2149
|
+
* @param {Array<String|Number>} path
|
|
2150
|
+
* @this {FormData}
|
|
2151
|
+
*
|
|
2152
|
+
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
2153
|
+
*/
|
|
2154
|
+
function defaultVisitor(value, key, path) {
|
|
2155
|
+
let arr = value;
|
|
1667
2156
|
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
2157
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
2158
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
2159
|
+
return false;
|
|
2160
|
+
}
|
|
1671
2161
|
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
2162
|
+
if (value && !path && typeof value === 'object') {
|
|
2163
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
2164
|
+
// eslint-disable-next-line no-param-reassign
|
|
2165
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
2166
|
+
// eslint-disable-next-line no-param-reassign
|
|
2167
|
+
value = stringifyWithDepthLimit(value, 1);
|
|
2168
|
+
} else if (
|
|
2169
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
2170
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1679
2171
|
) {
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
2172
|
+
// eslint-disable-next-line no-param-reassign
|
|
2173
|
+
key = removeBrackets(key);
|
|
2174
|
+
|
|
2175
|
+
arr.forEach(function each(el, index) {
|
|
2176
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
2177
|
+
formData.append(
|
|
2178
|
+
// eslint-disable-next-line no-nested-ternary
|
|
2179
|
+
indexes === true
|
|
2180
|
+
? renderKey([key], index, dots)
|
|
2181
|
+
: indexes === null
|
|
2182
|
+
? key
|
|
2183
|
+
: key + '[]',
|
|
2184
|
+
convertValue(el)
|
|
2185
|
+
);
|
|
2186
|
+
});
|
|
2187
|
+
return false;
|
|
1688
2188
|
}
|
|
2189
|
+
}
|
|
1689
2190
|
|
|
1690
|
-
|
|
2191
|
+
if (isVisitable(value)) {
|
|
2192
|
+
return true;
|
|
2193
|
+
}
|
|
1691
2194
|
|
|
1692
|
-
|
|
1693
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1694
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1695
|
-
}
|
|
2195
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1696
2196
|
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
contentType.indexOf('multipart/form-data') > -1
|
|
1700
|
-
) {
|
|
1701
|
-
const _FormData = this.env && this.env.FormData;
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
1702
2199
|
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
2200
|
+
const exposedHelpers = Object.assign(predicates, {
|
|
2201
|
+
defaultVisitor,
|
|
2202
|
+
convertValue,
|
|
2203
|
+
isVisitable,
|
|
2204
|
+
});
|
|
1710
2205
|
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
return stringifySafely(data);
|
|
1714
|
-
}
|
|
2206
|
+
function build(value, path, depth = 0) {
|
|
2207
|
+
if (utils$1.isUndefined(value)) return;
|
|
1715
2208
|
|
|
1716
|
-
|
|
1717
|
-
},
|
|
1718
|
-
],
|
|
2209
|
+
throwIfMaxDepthExceeded(depth);
|
|
1719
2210
|
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1724
|
-
const JSONRequested = this.responseType === 'json';
|
|
2211
|
+
if (stack.indexOf(value) !== -1) {
|
|
2212
|
+
throw new Error('Circular reference detected in ' + path.join('.'));
|
|
2213
|
+
}
|
|
1725
2214
|
|
|
1726
|
-
|
|
1727
|
-
return data;
|
|
1728
|
-
}
|
|
2215
|
+
stack.push(value);
|
|
1729
2216
|
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
utils$1.
|
|
1733
|
-
((
|
|
1734
|
-
) {
|
|
1735
|
-
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1736
|
-
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
2217
|
+
utils$1.forEach(value, function each(el, key) {
|
|
2218
|
+
const result =
|
|
2219
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
2220
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1737
2221
|
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
} catch (e) {
|
|
1741
|
-
if (strictJSONParsing) {
|
|
1742
|
-
if (e.name === 'SyntaxError') {
|
|
1743
|
-
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
1744
|
-
}
|
|
1745
|
-
throw e;
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
2222
|
+
if (result === true) {
|
|
2223
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
1748
2224
|
}
|
|
2225
|
+
});
|
|
1749
2226
|
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
],
|
|
2227
|
+
stack.pop();
|
|
2228
|
+
}
|
|
1753
2229
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
*/
|
|
1758
|
-
timeout: 0,
|
|
2230
|
+
if (!utils$1.isObject(obj)) {
|
|
2231
|
+
throw new TypeError('data must be an object');
|
|
2232
|
+
}
|
|
1759
2233
|
|
|
1760
|
-
|
|
1761
|
-
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
2234
|
+
build(obj);
|
|
1762
2235
|
|
|
1763
|
-
|
|
1764
|
-
|
|
2236
|
+
return formData;
|
|
2237
|
+
}
|
|
1765
2238
|
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
2239
|
+
/**
|
|
2240
|
+
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
2241
|
+
* their percent-encoded equivalents
|
|
2242
|
+
*
|
|
2243
|
+
* @param {string} str - The string to encode.
|
|
2244
|
+
*
|
|
2245
|
+
* @returns {string} The encoded string.
|
|
2246
|
+
*/
|
|
2247
|
+
function encode$1(str) {
|
|
2248
|
+
const charMap = {
|
|
2249
|
+
'!': '%21',
|
|
2250
|
+
"'": '%27',
|
|
2251
|
+
'(': '%28',
|
|
2252
|
+
')': '%29',
|
|
2253
|
+
'~': '%7E',
|
|
2254
|
+
'%20': '+',
|
|
2255
|
+
};
|
|
2256
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
2257
|
+
return charMap[match];
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
1770
2260
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
2261
|
+
/**
|
|
2262
|
+
* It takes a params object and converts it to a FormData object
|
|
2263
|
+
*
|
|
2264
|
+
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
2265
|
+
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
2266
|
+
*
|
|
2267
|
+
* @returns {void}
|
|
2268
|
+
*/
|
|
2269
|
+
function AxiosURLSearchParams(params, options) {
|
|
2270
|
+
this._pairs = [];
|
|
1774
2271
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
2272
|
+
params && toFormData$1(params, this, options);
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
2276
|
+
|
|
2277
|
+
prototype.append = function append(name, value) {
|
|
2278
|
+
this._pairs.push([name, value]);
|
|
1781
2279
|
};
|
|
1782
2280
|
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
2281
|
+
prototype.toString = function toString(encoder) {
|
|
2282
|
+
const _encode = encoder
|
|
2283
|
+
? (value) => encoder.call(this, value, encode$1)
|
|
2284
|
+
: encode$1;
|
|
1786
2285
|
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
'content-type',
|
|
1794
|
-
'etag',
|
|
1795
|
-
'expires',
|
|
1796
|
-
'from',
|
|
1797
|
-
'host',
|
|
1798
|
-
'if-modified-since',
|
|
1799
|
-
'if-unmodified-since',
|
|
1800
|
-
'last-modified',
|
|
1801
|
-
'location',
|
|
1802
|
-
'max-forwards',
|
|
1803
|
-
'proxy-authorization',
|
|
1804
|
-
'referer',
|
|
1805
|
-
'retry-after',
|
|
1806
|
-
'user-agent',
|
|
1807
|
-
]);
|
|
2286
|
+
return this._pairs
|
|
2287
|
+
.map(function each(pair) {
|
|
2288
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
2289
|
+
}, '')
|
|
2290
|
+
.join('&');
|
|
2291
|
+
};
|
|
1808
2292
|
|
|
1809
2293
|
/**
|
|
1810
|
-
*
|
|
2294
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
2295
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1811
2296
|
*
|
|
1812
|
-
*
|
|
1813
|
-
*
|
|
1814
|
-
*
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
2297
|
+
* @param {string} val The value to be encoded.
|
|
2298
|
+
*
|
|
2299
|
+
* @returns {string} The encoded value.
|
|
2300
|
+
*/
|
|
2301
|
+
function encode(val) {
|
|
2302
|
+
return encodeURIComponent(val)
|
|
2303
|
+
.replace(/%3A/gi, ':')
|
|
2304
|
+
.replace(/%24/g, '$')
|
|
2305
|
+
.replace(/%2C/gi, ',')
|
|
2306
|
+
.replace(/%20/g, '+');
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
/**
|
|
2310
|
+
* Build a URL by appending params to the end
|
|
1818
2311
|
*
|
|
1819
|
-
* @param {
|
|
2312
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
2313
|
+
* @param {object} [params] The params to be appended
|
|
2314
|
+
* @param {?(object|Function)} options
|
|
1820
2315
|
*
|
|
1821
|
-
* @returns {
|
|
2316
|
+
* @returns {string} The formatted url
|
|
1822
2317
|
*/
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
rawHeaders &&
|
|
1830
|
-
rawHeaders.split('\n').forEach(function parser(line) {
|
|
1831
|
-
i = line.indexOf(':');
|
|
1832
|
-
key = line.substring(0, i).trim().toLowerCase();
|
|
1833
|
-
val = line.substring(i + 1).trim();
|
|
2318
|
+
function buildURL(url, params, options) {
|
|
2319
|
+
if (!params) {
|
|
2320
|
+
return url;
|
|
2321
|
+
}
|
|
2322
|
+
url = url || '';
|
|
1834
2323
|
|
|
1835
|
-
|
|
1836
|
-
|
|
2324
|
+
const _options = utils$1.isFunction(options)
|
|
2325
|
+
? {
|
|
2326
|
+
serialize: options,
|
|
1837
2327
|
}
|
|
2328
|
+
: options;
|
|
1838
2329
|
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
}
|
|
1845
|
-
} else {
|
|
1846
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1847
|
-
}
|
|
1848
|
-
});
|
|
2330
|
+
// Read serializer options pollution-safely: own properties and methods on a
|
|
2331
|
+
// class/template prototype are honored, but values injected onto a polluted
|
|
2332
|
+
// Object.prototype are ignored.
|
|
2333
|
+
const _encode = utils$1.getSafeProp(_options, 'encode') || encode;
|
|
2334
|
+
const serializeFn = utils$1.getSafeProp(_options, 'serialize');
|
|
1849
2335
|
|
|
1850
|
-
|
|
1851
|
-
|
|
2336
|
+
let serializedParams;
|
|
2337
|
+
|
|
2338
|
+
if (serializeFn) {
|
|
2339
|
+
serializedParams = serializeFn(params, _options);
|
|
2340
|
+
} else {
|
|
2341
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
2342
|
+
? params.toString()
|
|
2343
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
if (serializedParams) {
|
|
2347
|
+
const hashmarkIndex = url.indexOf('#');
|
|
2348
|
+
|
|
2349
|
+
if (hashmarkIndex !== -1) {
|
|
2350
|
+
url = url.slice(0, hashmarkIndex);
|
|
2351
|
+
}
|
|
2352
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
return url;
|
|
2356
|
+
}
|
|
1852
2357
|
|
|
1853
2358
|
const $internals = Symbol('internals');
|
|
1854
2359
|
|
|
1855
|
-
|
|
1856
|
-
|
|
2360
|
+
// `handlers` is public and may be replaced with a nullish value by user code;
|
|
2361
|
+
// `clear()` has always tolerated that. Treat it as an empty stack rather than
|
|
2362
|
+
// dereferencing it.
|
|
2363
|
+
function countHandlers(handlers) {
|
|
2364
|
+
return handlers ? handlers.length : 0;
|
|
1857
2365
|
}
|
|
1858
2366
|
|
|
1859
|
-
function
|
|
1860
|
-
if (
|
|
1861
|
-
return
|
|
2367
|
+
function trimHandlers(handlers) {
|
|
2368
|
+
if (!handlers) {
|
|
2369
|
+
return;
|
|
1862
2370
|
}
|
|
1863
2371
|
|
|
1864
|
-
|
|
2372
|
+
while (handlers.length && handlers[handlers.length - 1] === null) {
|
|
2373
|
+
handlers.pop();
|
|
2374
|
+
}
|
|
1865
2375
|
}
|
|
1866
2376
|
|
|
1867
|
-
function
|
|
1868
|
-
const
|
|
1869
|
-
const
|
|
1870
|
-
let match;
|
|
2377
|
+
function syncHandlerEntries(manager, internals) {
|
|
2378
|
+
const handlers = manager.handlers;
|
|
2379
|
+
const length = countHandlers(handlers);
|
|
1871
2380
|
|
|
1872
|
-
|
|
1873
|
-
|
|
2381
|
+
if (handlers !== internals.handlersRef) {
|
|
2382
|
+
internals.handlersRef = handlers;
|
|
2383
|
+
internals.handlerEntries.clear();
|
|
2384
|
+
} else if (length !== internals.handlersLength) {
|
|
2385
|
+
if (!length) {
|
|
2386
|
+
internals.handlerEntries.clear();
|
|
2387
|
+
} else {
|
|
2388
|
+
internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
|
|
2389
|
+
if (handlers[entry.index] !== entry.handler) {
|
|
2390
|
+
internals.handlerEntries.delete(id);
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
1874
2394
|
}
|
|
1875
2395
|
|
|
1876
|
-
|
|
2396
|
+
internals.handlersLength = length;
|
|
1877
2397
|
}
|
|
1878
2398
|
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
2399
|
+
class InterceptorManager {
|
|
2400
|
+
constructor() {
|
|
2401
|
+
this.handlers = [];
|
|
2402
|
+
this[$internals] = {
|
|
2403
|
+
handlersRef: this.handlers,
|
|
2404
|
+
handlersLength: this.handlers.length,
|
|
2405
|
+
handlerEntries: new Map(),
|
|
2406
|
+
iterationDepth: 0,
|
|
2407
|
+
nextId: 0,
|
|
2408
|
+
};
|
|
1884
2409
|
}
|
|
1885
2410
|
|
|
1886
|
-
|
|
1887
|
-
|
|
2411
|
+
/**
|
|
2412
|
+
* Add a new interceptor to the stack
|
|
2413
|
+
*
|
|
2414
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
2415
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
2416
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
2417
|
+
*
|
|
2418
|
+
* @return {Number} An ID used to remove interceptor later
|
|
2419
|
+
*/
|
|
2420
|
+
use(fulfilled, rejected, options) {
|
|
2421
|
+
const handler = {
|
|
2422
|
+
fulfilled,
|
|
2423
|
+
rejected,
|
|
2424
|
+
synchronous: options ? options.synchronous : false,
|
|
2425
|
+
runWhen: options ? options.runWhen : null,
|
|
2426
|
+
};
|
|
2427
|
+
const internals = this[$internals];
|
|
2428
|
+
|
|
2429
|
+
if (this.handlers == null) {
|
|
2430
|
+
this.handlers = [];
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
syncHandlerEntries(this, internals);
|
|
2434
|
+
|
|
2435
|
+
const id = internals.nextId++;
|
|
2436
|
+
|
|
2437
|
+
this.handlers.push(handler);
|
|
2438
|
+
internals.handlerEntries.set(id, {
|
|
2439
|
+
handler,
|
|
2440
|
+
index: this.handlers.length - 1,
|
|
2441
|
+
});
|
|
2442
|
+
internals.handlersLength = this.handlers.length;
|
|
2443
|
+
|
|
2444
|
+
return id;
|
|
1888
2445
|
}
|
|
1889
2446
|
|
|
1890
|
-
|
|
2447
|
+
/**
|
|
2448
|
+
* Remove an interceptor from the stack
|
|
2449
|
+
*
|
|
2450
|
+
* @param {Number} id The ID that was returned by `use`
|
|
2451
|
+
*
|
|
2452
|
+
* @returns {void}
|
|
2453
|
+
*/
|
|
2454
|
+
eject(id) {
|
|
2455
|
+
const internals = this[$internals];
|
|
1891
2456
|
|
|
1892
|
-
|
|
1893
|
-
|
|
2457
|
+
syncHandlerEntries(this, internals);
|
|
2458
|
+
|
|
2459
|
+
const entry = internals.handlerEntries.get(id);
|
|
2460
|
+
|
|
2461
|
+
if (entry) {
|
|
2462
|
+
internals.handlerEntries.delete(id);
|
|
2463
|
+
|
|
2464
|
+
// Ignore IDs invalidated by clear or direct replacement of handlers.
|
|
2465
|
+
if (this.handlers[entry.index] !== entry.handler) {
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
this.handlers[entry.index] = null;
|
|
2470
|
+
|
|
2471
|
+
// Do not reuse an index while forEach is walking its length snapshot.
|
|
2472
|
+
if (!internals.iterationDepth) {
|
|
2473
|
+
trimHandlers(this.handlers);
|
|
2474
|
+
internals.handlersLength = this.handlers.length;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
1894
2477
|
}
|
|
1895
2478
|
|
|
1896
|
-
|
|
1897
|
-
|
|
2479
|
+
/**
|
|
2480
|
+
* Clear all interceptors from the stack
|
|
2481
|
+
*
|
|
2482
|
+
* @returns {void}
|
|
2483
|
+
*/
|
|
2484
|
+
clear() {
|
|
2485
|
+
if (this.handlers) {
|
|
2486
|
+
this.handlers = [];
|
|
2487
|
+
syncHandlerEntries(this, this[$internals]);
|
|
2488
|
+
}
|
|
1898
2489
|
}
|
|
1899
|
-
}
|
|
1900
2490
|
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
2491
|
+
/**
|
|
2492
|
+
* Iterate over all the registered interceptors
|
|
2493
|
+
*
|
|
2494
|
+
* This method is particularly useful for skipping over any
|
|
2495
|
+
* interceptors that may have become `null` calling `eject`.
|
|
2496
|
+
*
|
|
2497
|
+
* @param {Function} fn The function to call for each interceptor
|
|
2498
|
+
*
|
|
2499
|
+
* @returns {void}
|
|
2500
|
+
*/
|
|
2501
|
+
forEach(fn) {
|
|
2502
|
+
const internals = this[$internals];
|
|
1909
2503
|
|
|
1910
|
-
|
|
1911
|
-
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
2504
|
+
syncHandlerEntries(this, internals);
|
|
1912
2505
|
|
|
1913
|
-
|
|
1914
|
-
Object.defineProperty(obj, methodName + accessorName, {
|
|
1915
|
-
value: function (arg1, arg2, arg3) {
|
|
1916
|
-
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1917
|
-
},
|
|
1918
|
-
configurable: true,
|
|
1919
|
-
});
|
|
1920
|
-
});
|
|
1921
|
-
}
|
|
2506
|
+
internals.iterationDepth++;
|
|
1922
2507
|
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2508
|
+
try {
|
|
2509
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
2510
|
+
if (h !== null) {
|
|
2511
|
+
fn(h);
|
|
2512
|
+
}
|
|
2513
|
+
});
|
|
2514
|
+
} finally {
|
|
2515
|
+
if (!--internals.iterationDepth) {
|
|
2516
|
+
syncHandlerEntries(this, internals);
|
|
2517
|
+
trimHandlers(this.handlers);
|
|
2518
|
+
internals.handlersLength = countHandlers(this.handlers);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
1926
2521
|
}
|
|
2522
|
+
}
|
|
1927
2523
|
|
|
1928
|
-
|
|
1929
|
-
|
|
2524
|
+
const transitionalDefaults = {
|
|
2525
|
+
silentJSONParsing: true,
|
|
2526
|
+
forcedJSONParsing: true,
|
|
2527
|
+
clarifyTimeoutError: false,
|
|
2528
|
+
legacyInterceptorReqResOrdering: true,
|
|
2529
|
+
advertiseZstdAcceptEncoding: false,
|
|
2530
|
+
validateStatusUndefinedResolves: true,
|
|
2531
|
+
};
|
|
1930
2532
|
|
|
1931
|
-
|
|
1932
|
-
|
|
2533
|
+
const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
2534
|
+
|
|
2535
|
+
const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
2536
|
+
|
|
2537
|
+
const Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
2538
|
+
|
|
2539
|
+
const platform$1 = {
|
|
2540
|
+
isBrowser: true,
|
|
2541
|
+
classes: {
|
|
2542
|
+
URLSearchParams: URLSearchParams$1,
|
|
2543
|
+
FormData: FormData$1,
|
|
2544
|
+
Blob: Blob$1,
|
|
2545
|
+
},
|
|
2546
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
2547
|
+
};
|
|
2548
|
+
|
|
2549
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2550
|
+
|
|
2551
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
2552
|
+
|
|
2553
|
+
/**
|
|
2554
|
+
* Determine if we're running in a standard browser environment
|
|
2555
|
+
*
|
|
2556
|
+
* This allows axios to run in a web worker, and react-native.
|
|
2557
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
2558
|
+
*
|
|
2559
|
+
* web workers:
|
|
2560
|
+
* typeof window -> undefined
|
|
2561
|
+
* typeof document -> undefined
|
|
2562
|
+
*
|
|
2563
|
+
* react-native:
|
|
2564
|
+
* navigator.product -> 'ReactNative'
|
|
2565
|
+
* nativescript
|
|
2566
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
|
2567
|
+
*
|
|
2568
|
+
* @returns {boolean}
|
|
2569
|
+
*/
|
|
2570
|
+
const hasStandardBrowserEnv =
|
|
2571
|
+
hasBrowserEnv &&
|
|
2572
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* Determine if we're running in a standard browser webWorker environment
|
|
2576
|
+
*
|
|
2577
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
|
2578
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
2579
|
+
* filtered out due to its judgment standard
|
|
2580
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
2581
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
|
2582
|
+
*/
|
|
2583
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
2584
|
+
return (
|
|
2585
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
|
2586
|
+
// eslint-disable-next-line no-undef
|
|
2587
|
+
self instanceof WorkerGlobalScope &&
|
|
2588
|
+
typeof self.importScripts === 'function'
|
|
2589
|
+
);
|
|
2590
|
+
})();
|
|
1933
2591
|
|
|
1934
|
-
|
|
1935
|
-
throw new Error('header name must be a non-empty string');
|
|
1936
|
-
}
|
|
2592
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
1937
2593
|
|
|
1938
|
-
|
|
2594
|
+
const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
2595
|
+
__proto__: null,
|
|
2596
|
+
hasBrowserEnv,
|
|
2597
|
+
hasStandardBrowserEnv,
|
|
2598
|
+
hasStandardBrowserWebWorkerEnv,
|
|
2599
|
+
navigator: _navigator,
|
|
2600
|
+
origin
|
|
2601
|
+
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1939
2602
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
2603
|
+
const platform = {
|
|
2604
|
+
...utils,
|
|
2605
|
+
...platform$1,
|
|
2606
|
+
};
|
|
2607
|
+
|
|
2608
|
+
function toURLEncodedForm(data, options) {
|
|
2609
|
+
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
2610
|
+
visitor: function (value, key, path, helpers) {
|
|
2611
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
2612
|
+
this.append(key, value.toString('base64'));
|
|
2613
|
+
return false;
|
|
1947
2614
|
}
|
|
1948
|
-
}
|
|
1949
2615
|
|
|
1950
|
-
|
|
1951
|
-
|
|
2616
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
2617
|
+
},
|
|
2618
|
+
...options,
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
1952
2621
|
|
|
1953
|
-
|
|
1954
|
-
setHeaders(header, valueOrRewrite);
|
|
1955
|
-
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1956
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1957
|
-
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1958
|
-
let obj = {},
|
|
1959
|
-
dest,
|
|
1960
|
-
key;
|
|
1961
|
-
for (const entry of header) {
|
|
1962
|
-
if (!utils$1.isArray(entry)) {
|
|
1963
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
1964
|
-
}
|
|
2622
|
+
const MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
|
|
1965
2623
|
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
2624
|
+
function throwIfDepthExceeded(index) {
|
|
2625
|
+
if (index > MAX_DEPTH) {
|
|
2626
|
+
throw new AxiosError$1(
|
|
2627
|
+
'FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH,
|
|
2628
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
2629
|
+
);
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
1972
2632
|
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
2633
|
+
/**
|
|
2634
|
+
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
2635
|
+
*
|
|
2636
|
+
* @param {string} name - The name of the property to get.
|
|
2637
|
+
*
|
|
2638
|
+
* @returns An array of strings.
|
|
2639
|
+
*/
|
|
2640
|
+
function parsePropPath(name) {
|
|
2641
|
+
// foo[x][y][z] -> ['foo', 'x', 'y', 'z']
|
|
2642
|
+
// foo.x.y.z -> ['foo', 'x', 'y', 'z']
|
|
2643
|
+
// A path is split on `.` and on `[...]` groups. A segment — whether written
|
|
2644
|
+
// in dot notation or captured inside brackets — may contain any character
|
|
2645
|
+
// except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
|
|
2646
|
+
// literal instead of being split (#5402). `.`, `[` and `]` keep their existing
|
|
2647
|
+
// meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
|
|
2648
|
+
// Excluding `[` from the bracket group also makes the match fail fast at the
|
|
2649
|
+
// next `[`, so a malformed name cannot rescan to the end of the string from
|
|
2650
|
+
// every unmatched `[` — parsing stays linear in the length of the name.
|
|
2651
|
+
const path = [];
|
|
2652
|
+
const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
|
|
2653
|
+
let match;
|
|
1977
2654
|
|
|
1978
|
-
|
|
2655
|
+
while ((match = pattern.exec(name)) !== null) {
|
|
2656
|
+
throwIfDepthExceeded(path.length);
|
|
2657
|
+
path.push(match[0] === '[]' ? '' : match[1] || match[0]);
|
|
1979
2658
|
}
|
|
1980
2659
|
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
if (header) {
|
|
1985
|
-
const key = utils$1.findKey(this, header);
|
|
2660
|
+
return path;
|
|
2661
|
+
}
|
|
1986
2662
|
|
|
1987
|
-
|
|
1988
|
-
|
|
2663
|
+
/**
|
|
2664
|
+
* Convert an array to an object.
|
|
2665
|
+
*
|
|
2666
|
+
* @param {Array<any>} arr - The array to convert to an object.
|
|
2667
|
+
*
|
|
2668
|
+
* @returns An object with the same keys and values as the array.
|
|
2669
|
+
*/
|
|
2670
|
+
function arrayToObject(arr) {
|
|
2671
|
+
const obj = {};
|
|
2672
|
+
const keys = Object.keys(arr);
|
|
2673
|
+
let i;
|
|
2674
|
+
const len = keys.length;
|
|
2675
|
+
let key;
|
|
2676
|
+
for (i = 0; i < len; i++) {
|
|
2677
|
+
key = keys[i];
|
|
2678
|
+
obj[key] = arr[key];
|
|
2679
|
+
}
|
|
2680
|
+
return obj;
|
|
2681
|
+
}
|
|
1989
2682
|
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2683
|
+
/**
|
|
2684
|
+
* It takes a FormData object and returns a JavaScript object
|
|
2685
|
+
*
|
|
2686
|
+
* @param {string} formData The FormData object to convert to JSON.
|
|
2687
|
+
*
|
|
2688
|
+
* @returns {Object<string, any> | null} The converted object.
|
|
2689
|
+
*/
|
|
2690
|
+
function formDataToJSON(formData) {
|
|
2691
|
+
function buildPath(path, value, target, index) {
|
|
2692
|
+
throwIfDepthExceeded(index);
|
|
1993
2693
|
|
|
1994
|
-
|
|
1995
|
-
return parseTokens(value);
|
|
1996
|
-
}
|
|
2694
|
+
let name = path[index++];
|
|
1997
2695
|
|
|
1998
|
-
|
|
1999
|
-
return parser.call(this, value, key);
|
|
2000
|
-
}
|
|
2696
|
+
if (name === '__proto__') return true;
|
|
2001
2697
|
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2698
|
+
const isNumericKey = Number.isFinite(+name);
|
|
2699
|
+
const isLast = index >= path.length;
|
|
2700
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
2005
2701
|
|
|
2006
|
-
|
|
2702
|
+
if (isLast) {
|
|
2703
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
2704
|
+
target[name] = utils$1.isArray(target[name])
|
|
2705
|
+
? target[name].concat(value)
|
|
2706
|
+
: [target[name], value];
|
|
2707
|
+
} else {
|
|
2708
|
+
target[name] = value;
|
|
2007
2709
|
}
|
|
2710
|
+
|
|
2711
|
+
return !isNumericKey;
|
|
2008
2712
|
}
|
|
2009
|
-
}
|
|
2010
2713
|
|
|
2011
|
-
|
|
2012
|
-
|
|
2714
|
+
if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
|
|
2715
|
+
target[name] = [];
|
|
2716
|
+
}
|
|
2013
2717
|
|
|
2014
|
-
|
|
2015
|
-
const key = utils$1.findKey(this, header);
|
|
2718
|
+
const result = buildPath(path, value, target[name], index);
|
|
2016
2719
|
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
this[key] !== undefined &&
|
|
2020
|
-
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2021
|
-
);
|
|
2720
|
+
if (result && utils$1.isArray(target[name])) {
|
|
2721
|
+
target[name] = arrayToObject(target[name]);
|
|
2022
2722
|
}
|
|
2023
2723
|
|
|
2024
|
-
return
|
|
2724
|
+
return !isNumericKey;
|
|
2025
2725
|
}
|
|
2026
2726
|
|
|
2027
|
-
|
|
2028
|
-
const
|
|
2029
|
-
let deleted = false;
|
|
2030
|
-
|
|
2031
|
-
function deleteHeader(_header) {
|
|
2032
|
-
_header = normalizeHeader(_header);
|
|
2033
|
-
|
|
2034
|
-
if (_header) {
|
|
2035
|
-
const key = utils$1.findKey(self, _header);
|
|
2727
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
2728
|
+
const obj = {};
|
|
2036
2729
|
|
|
2037
|
-
|
|
2038
|
-
|
|
2730
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
2731
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
2732
|
+
});
|
|
2039
2733
|
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2734
|
+
return obj;
|
|
2735
|
+
}
|
|
2044
2736
|
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
} else {
|
|
2048
|
-
deleteHeader(header);
|
|
2049
|
-
}
|
|
2737
|
+
return null;
|
|
2738
|
+
}
|
|
2050
2739
|
|
|
2051
|
-
|
|
2052
|
-
|
|
2740
|
+
const methodList = Object.freeze([
|
|
2741
|
+
'get',
|
|
2742
|
+
'delete',
|
|
2743
|
+
'head',
|
|
2744
|
+
'options',
|
|
2745
|
+
'post',
|
|
2746
|
+
'put',
|
|
2747
|
+
'patch',
|
|
2748
|
+
'purge',
|
|
2749
|
+
'link',
|
|
2750
|
+
'unlink',
|
|
2751
|
+
'query',
|
|
2752
|
+
]);
|
|
2053
2753
|
|
|
2054
|
-
|
|
2055
|
-
const keys = Object.keys(this);
|
|
2056
|
-
let i = keys.length;
|
|
2057
|
-
let deleted = false;
|
|
2754
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
2058
2755
|
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2756
|
+
/**
|
|
2757
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
2758
|
+
* of the input
|
|
2759
|
+
*
|
|
2760
|
+
* @param {any} rawValue - The value to be stringified.
|
|
2761
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
2762
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
2763
|
+
*
|
|
2764
|
+
* @returns {string} A stringified version of the rawValue.
|
|
2765
|
+
*/
|
|
2766
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
2767
|
+
if (utils$1.isString(rawValue)) {
|
|
2768
|
+
try {
|
|
2769
|
+
(parser || JSON.parse)(rawValue);
|
|
2770
|
+
return utils$1.trim(rawValue);
|
|
2771
|
+
} catch (e) {
|
|
2772
|
+
if (e.name !== 'SyntaxError') {
|
|
2773
|
+
throw e;
|
|
2064
2774
|
}
|
|
2065
2775
|
}
|
|
2066
|
-
|
|
2067
|
-
return deleted;
|
|
2068
2776
|
}
|
|
2069
2777
|
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
const headers = {};
|
|
2778
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
2779
|
+
}
|
|
2073
2780
|
|
|
2074
|
-
|
|
2075
|
-
|
|
2781
|
+
const defaults = {
|
|
2782
|
+
transitional: transitionalDefaults,
|
|
2076
2783
|
|
|
2077
|
-
|
|
2078
|
-
self[key] = normalizeValue(value);
|
|
2079
|
-
delete self[header];
|
|
2080
|
-
return;
|
|
2081
|
-
}
|
|
2784
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
2082
2785
|
|
|
2083
|
-
|
|
2786
|
+
transformRequest: [
|
|
2787
|
+
function transformRequest(data, headers) {
|
|
2788
|
+
const contentType = headers.getContentType() || '';
|
|
2789
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
2790
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
2084
2791
|
|
|
2085
|
-
if (
|
|
2086
|
-
|
|
2792
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
2793
|
+
data = new FormData(data);
|
|
2087
2794
|
}
|
|
2088
2795
|
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
headers[normalized] = true;
|
|
2092
|
-
});
|
|
2796
|
+
const isFormData = utils$1.isFormData(data);
|
|
2093
2797
|
|
|
2094
|
-
|
|
2095
|
-
|
|
2798
|
+
if (isFormData) {
|
|
2799
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
2800
|
+
}
|
|
2096
2801
|
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2802
|
+
if (
|
|
2803
|
+
utils$1.isArrayBuffer(data) ||
|
|
2804
|
+
utils$1.isBuffer(data) ||
|
|
2805
|
+
utils$1.isStream(data) ||
|
|
2806
|
+
utils$1.isFile(data) ||
|
|
2807
|
+
utils$1.isBlob(data) ||
|
|
2808
|
+
utils$1.isReadableStream(data)
|
|
2809
|
+
) {
|
|
2810
|
+
return data;
|
|
2811
|
+
}
|
|
2812
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
2813
|
+
return data.buffer;
|
|
2814
|
+
}
|
|
2815
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
2816
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
2817
|
+
return data.toString();
|
|
2818
|
+
}
|
|
2100
2819
|
|
|
2101
|
-
|
|
2102
|
-
const obj = Object.create(null);
|
|
2820
|
+
let isFileList;
|
|
2103
2821
|
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2822
|
+
if (isObjectPayload) {
|
|
2823
|
+
const formSerializer = own(this, 'formSerializer');
|
|
2824
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
2825
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
2826
|
+
}
|
|
2109
2827
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2828
|
+
if (
|
|
2829
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
2830
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
2831
|
+
) {
|
|
2832
|
+
const env = own(this, 'env');
|
|
2833
|
+
const _FormData = env && env.FormData;
|
|
2112
2834
|
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2835
|
+
return toFormData$1(
|
|
2836
|
+
isFileList ? { 'files[]': data } : data,
|
|
2837
|
+
_FormData && new _FormData(),
|
|
2838
|
+
formSerializer
|
|
2839
|
+
);
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2116
2842
|
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
}
|
|
2843
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
2844
|
+
headers.setContentType('application/json', false);
|
|
2845
|
+
return stringifySafely(data);
|
|
2846
|
+
}
|
|
2122
2847
|
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2848
|
+
return data;
|
|
2849
|
+
},
|
|
2850
|
+
],
|
|
2126
2851
|
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2852
|
+
transformResponse: [
|
|
2853
|
+
function transformResponse(data) {
|
|
2854
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
2855
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
2856
|
+
const responseType = own(this, 'responseType');
|
|
2857
|
+
const JSONRequested = responseType === 'json';
|
|
2130
2858
|
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2859
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
2860
|
+
return data;
|
|
2861
|
+
}
|
|
2134
2862
|
|
|
2135
|
-
|
|
2136
|
-
|
|
2863
|
+
if (
|
|
2864
|
+
data &&
|
|
2865
|
+
utils$1.isString(data) &&
|
|
2866
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
2867
|
+
) {
|
|
2868
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2869
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
2137
2870
|
|
|
2138
|
-
|
|
2871
|
+
try {
|
|
2872
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
2873
|
+
} catch (e) {
|
|
2874
|
+
if (strictJSONParsing) {
|
|
2875
|
+
if (e.name === 'SyntaxError') {
|
|
2876
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
2877
|
+
}
|
|
2878
|
+
throw e;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2139
2882
|
|
|
2140
|
-
|
|
2141
|
-
|
|
2883
|
+
return data;
|
|
2884
|
+
},
|
|
2885
|
+
],
|
|
2142
2886
|
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
accessors: {},
|
|
2149
|
-
});
|
|
2887
|
+
/**
|
|
2888
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
2889
|
+
* timeout is not created.
|
|
2890
|
+
*/
|
|
2891
|
+
timeout: 0,
|
|
2150
2892
|
|
|
2151
|
-
|
|
2152
|
-
|
|
2893
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
2894
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
2153
2895
|
|
|
2154
|
-
|
|
2155
|
-
|
|
2896
|
+
maxContentLength: -1,
|
|
2897
|
+
maxBodyLength: -1,
|
|
2156
2898
|
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
}
|
|
2899
|
+
env: {
|
|
2900
|
+
FormData: platform.classes.FormData,
|
|
2901
|
+
Blob: platform.classes.Blob,
|
|
2902
|
+
},
|
|
2162
2903
|
|
|
2163
|
-
|
|
2904
|
+
validateStatus: function validateStatus(status) {
|
|
2905
|
+
return status >= 200 && status < 300;
|
|
2906
|
+
},
|
|
2164
2907
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2908
|
+
headers: {
|
|
2909
|
+
common: {
|
|
2910
|
+
Accept: 'application/json, text/plain, */*',
|
|
2911
|
+
'Content-Type': undefined,
|
|
2912
|
+
},
|
|
2913
|
+
},
|
|
2167
2914
|
};
|
|
2168
2915
|
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
'Content-Length',
|
|
2172
|
-
'Accept',
|
|
2173
|
-
'Accept-Encoding',
|
|
2174
|
-
'User-Agent',
|
|
2175
|
-
'Authorization',
|
|
2176
|
-
]);
|
|
2177
|
-
|
|
2178
|
-
// reserved names hotfix
|
|
2179
|
-
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
2180
|
-
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2181
|
-
return {
|
|
2182
|
-
get: () => value,
|
|
2183
|
-
set(headerValue) {
|
|
2184
|
-
this[mapped] = headerValue;
|
|
2185
|
-
},
|
|
2186
|
-
};
|
|
2916
|
+
utils$1.forEach(methodList, (method) => {
|
|
2917
|
+
defaults.headers[method] = {};
|
|
2187
2918
|
});
|
|
2188
2919
|
|
|
2189
|
-
utils$1.freezeMethods(AxiosHeaders$1);
|
|
2190
|
-
|
|
2191
2920
|
/**
|
|
2192
2921
|
* Transform the data for a request or a response
|
|
2193
2922
|
*
|
|
@@ -2246,22 +2975,41 @@ function settle(resolve, reject, response) {
|
|
|
2246
2975
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2247
2976
|
resolve(response);
|
|
2248
2977
|
} else {
|
|
2249
|
-
reject(
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2978
|
+
reject(new AxiosError$1(
|
|
2979
|
+
'Request failed with status code ' + response.status,
|
|
2980
|
+
response.status >= 400 && response.status < 500 ? AxiosError$1.ERR_BAD_REQUEST : AxiosError$1.ERR_BAD_RESPONSE,
|
|
2981
|
+
response.config,
|
|
2982
|
+
response.request,
|
|
2983
|
+
response
|
|
2984
|
+
));
|
|
2985
|
+
}
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
const urlParserControlCharacters = /[\t\n\r]/g;
|
|
2989
|
+
|
|
2990
|
+
/**
|
|
2991
|
+
* Match WHATWG URL preprocessing before checking a URL's protocol.
|
|
2992
|
+
*
|
|
2993
|
+
* @param {string} url
|
|
2994
|
+
*
|
|
2995
|
+
* @returns {string}
|
|
2996
|
+
*/
|
|
2997
|
+
function normalizeURLForProtocolCheck(url) {
|
|
2998
|
+
if (typeof url !== 'string') {
|
|
2999
|
+
return url;
|
|
2260
3000
|
}
|
|
3001
|
+
|
|
3002
|
+
let start = 0;
|
|
3003
|
+
|
|
3004
|
+
while (start < url.length && url.charCodeAt(start) <= 0x20) {
|
|
3005
|
+
start++;
|
|
3006
|
+
}
|
|
3007
|
+
|
|
3008
|
+
return url.slice(start).replace(urlParserControlCharacters, '');
|
|
2261
3009
|
}
|
|
2262
3010
|
|
|
2263
3011
|
function parseProtocol(url) {
|
|
2264
|
-
const match = /^([-+\w]{1,25})(
|
|
3012
|
+
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
2265
3013
|
return (match && match[1]) || '';
|
|
2266
3014
|
}
|
|
2267
3015
|
|
|
@@ -2321,7 +3069,7 @@ function speedometer(samplesCount, min) {
|
|
|
2321
3069
|
* Throttle decorator
|
|
2322
3070
|
* @param {Function} fn
|
|
2323
3071
|
* @param {Number} freq
|
|
2324
|
-
* @return {Function}
|
|
3072
|
+
* @return {Array<Function>}
|
|
2325
3073
|
*/
|
|
2326
3074
|
function throttle(fn, freq) {
|
|
2327
3075
|
let timestamp = 0;
|
|
@@ -2356,8 +3104,9 @@ function throttle(fn, freq) {
|
|
|
2356
3104
|
};
|
|
2357
3105
|
|
|
2358
3106
|
const flush = () => lastArgs && invoke(lastArgs);
|
|
3107
|
+
const flushWith = (...args) => invoke(args);
|
|
2359
3108
|
|
|
2360
|
-
return [throttled, flush];
|
|
3109
|
+
return [throttled, flush, flushWith];
|
|
2361
3110
|
}
|
|
2362
3111
|
|
|
2363
3112
|
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
@@ -2365,13 +3114,16 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2365
3114
|
const _speedometer = speedometer(50, 250);
|
|
2366
3115
|
|
|
2367
3116
|
return throttle((e) => {
|
|
2368
|
-
|
|
3117
|
+
if (!e || !utils$1.isNumber(e.loaded)) {
|
|
3118
|
+
return;
|
|
3119
|
+
}
|
|
3120
|
+
const rawLoaded = e.loaded;
|
|
2369
3121
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2370
|
-
const
|
|
3122
|
+
const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
|
|
3123
|
+
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
2371
3124
|
const rate = _speedometer(progressBytes);
|
|
2372
|
-
const inRange = loaded <= total;
|
|
2373
3125
|
|
|
2374
|
-
bytesNotified = loaded;
|
|
3126
|
+
bytesNotified = Math.max(bytesNotified, loaded);
|
|
2375
3127
|
|
|
2376
3128
|
const data = {
|
|
2377
3129
|
loaded,
|
|
@@ -2379,7 +3131,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2379
3131
|
progress: total ? loaded / total : undefined,
|
|
2380
3132
|
bytes: progressBytes,
|
|
2381
3133
|
rate: rate ? rate : undefined,
|
|
2382
|
-
estimated: rate && total
|
|
3134
|
+
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
2383
3135
|
event: e,
|
|
2384
3136
|
lengthComputable: total != null,
|
|
2385
3137
|
[isDownloadStream ? 'download' : 'upload']: true,
|
|
@@ -2404,9 +3156,9 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
2404
3156
|
};
|
|
2405
3157
|
|
|
2406
3158
|
const asyncDecorator =
|
|
2407
|
-
(fn) =>
|
|
3159
|
+
(fn, scheduler = utils$1.asap) =>
|
|
2408
3160
|
(...args) =>
|
|
2409
|
-
|
|
3161
|
+
scheduler(() => fn(...args));
|
|
2410
3162
|
|
|
2411
3163
|
const isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2412
3164
|
? ((origin, isMSIE) => (url) => {
|
|
@@ -2452,8 +3204,24 @@ const cookies = platform.hasStandardBrowserEnv
|
|
|
2452
3204
|
|
|
2453
3205
|
read(name) {
|
|
2454
3206
|
if (typeof document === 'undefined') return null;
|
|
2455
|
-
|
|
2456
|
-
|
|
3207
|
+
// Match name=value by splitting on the semicolon separator instead of building a
|
|
3208
|
+
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
3209
|
+
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
3210
|
+
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
3211
|
+
// "; ", so ignore optional whitespace before each cookie name.
|
|
3212
|
+
const cookies = document.cookie.split(';');
|
|
3213
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
3214
|
+
const cookie = cookies[i].replace(/^\s+/, '');
|
|
3215
|
+
const eq = cookie.indexOf('=');
|
|
3216
|
+
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
3217
|
+
try {
|
|
3218
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
3219
|
+
} catch (e) {
|
|
3220
|
+
return cookie.slice(eq + 1);
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
return null;
|
|
2457
3225
|
},
|
|
2458
3226
|
|
|
2459
3227
|
remove(name) {
|
|
@@ -2496,9 +3264,67 @@ function isAbsoluteURL(url) {
|
|
|
2496
3264
|
* @returns {string} The combined URL
|
|
2497
3265
|
*/
|
|
2498
3266
|
function combineURLs(baseURL, relativeURL) {
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
3267
|
+
if (!relativeURL) {
|
|
3268
|
+
return baseURL;
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
let end = baseURL.length;
|
|
3272
|
+
|
|
3273
|
+
while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
|
|
3274
|
+
end--;
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
|
|
3278
|
+
}
|
|
3279
|
+
|
|
3280
|
+
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
3281
|
+
|
|
3282
|
+
// Redact the parts of a URL that can carry secrets before it is embedded in an
|
|
3283
|
+
// error message. AxiosError.toJSON() serializes `message` verbatim and errors
|
|
3284
|
+
// are commonly logged, while the opt-in `config.redact` model only cleans
|
|
3285
|
+
// config keys — it cannot reach the message. Redact only the genuinely
|
|
3286
|
+
// sensitive substrings — userinfo (credentials), query parameter values and
|
|
3287
|
+
// fragment contents — with the same REDACTED marker the config redaction uses,
|
|
3288
|
+
// while keeping the scheme, host, path and parameter names so the offending
|
|
3289
|
+
// request stays accurately identifiable.
|
|
3290
|
+
function redactFragment(fragment) {
|
|
3291
|
+
if (!fragment) {
|
|
3292
|
+
return fragment;
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3295
|
+
return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = '') => {
|
|
3296
|
+
return `${separator}${parameterName}${REDACTED}`;
|
|
3297
|
+
});
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
function redactSensitiveURLParts(url) {
|
|
3301
|
+
const redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
|
|
3302
|
+
const fragmentIndex = redactedURL.indexOf('#');
|
|
3303
|
+
const urlWithoutFragment =
|
|
3304
|
+
fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
|
|
3305
|
+
const redactedURLWithoutFragment = urlWithoutFragment.replace(
|
|
3306
|
+
/([?&][^=&#]*=)[^&#]*/g,
|
|
3307
|
+
`$1${REDACTED}`
|
|
3308
|
+
);
|
|
3309
|
+
|
|
3310
|
+
if (fragmentIndex === -1) {
|
|
3311
|
+
return redactedURLWithoutFragment;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
function assertValidHttpProtocolURL(url, config) {
|
|
3318
|
+
if (typeof url === 'string') {
|
|
3319
|
+
const normalizedURL = normalizeURLForProtocolCheck(url);
|
|
3320
|
+
if (malformedHttpProtocol.test(normalizedURL)) {
|
|
3321
|
+
throw new AxiosError$1(
|
|
3322
|
+
`Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
|
|
3323
|
+
AxiosError$1.ERR_INVALID_URL,
|
|
3324
|
+
config
|
|
3325
|
+
);
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
2502
3328
|
}
|
|
2503
3329
|
|
|
2504
3330
|
/**
|
|
@@ -2511,9 +3337,11 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
2511
3337
|
*
|
|
2512
3338
|
* @returns {string} The combined full path
|
|
2513
3339
|
*/
|
|
2514
|
-
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
3340
|
+
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
3341
|
+
assertValidHttpProtocolURL(requestedURL, config);
|
|
2515
3342
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2516
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls
|
|
3343
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
3344
|
+
assertValidHttpProtocolURL(baseURL, config);
|
|
2517
3345
|
return combineURLs(baseURL, requestedURL);
|
|
2518
3346
|
}
|
|
2519
3347
|
return requestedURL;
|
|
@@ -2521,6 +3349,17 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
|
2521
3349
|
|
|
2522
3350
|
const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
|
|
2523
3351
|
|
|
3352
|
+
const ownEnumerableKeys = (thing) => {
|
|
3353
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
3354
|
+
return Object.keys(thing).concat(
|
|
3355
|
+
Object.getOwnPropertySymbols(thing).filter(
|
|
3356
|
+
(symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
|
|
3357
|
+
)
|
|
3358
|
+
);
|
|
3359
|
+
}
|
|
3360
|
+
return Object.keys(thing);
|
|
3361
|
+
};
|
|
3362
|
+
|
|
2524
3363
|
/**
|
|
2525
3364
|
* Config-specific merge-function which creates a new config-object
|
|
2526
3365
|
* by merging two configuration objects together.
|
|
@@ -2532,8 +3371,23 @@ const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing
|
|
|
2532
3371
|
*/
|
|
2533
3372
|
function mergeConfig$1(config1, config2) {
|
|
2534
3373
|
// eslint-disable-next-line no-param-reassign
|
|
3374
|
+
config1 = config1 || {};
|
|
2535
3375
|
config2 = config2 || {};
|
|
2536
|
-
|
|
3376
|
+
|
|
3377
|
+
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
3378
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype.
|
|
3379
|
+
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
3380
|
+
// ergonomics for user code that relies on it.
|
|
3381
|
+
const config = Object.create(null);
|
|
3382
|
+
Object.defineProperty(config, 'hasOwnProperty', {
|
|
3383
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
3384
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
3385
|
+
__proto__: null,
|
|
3386
|
+
value: Object.prototype.hasOwnProperty,
|
|
3387
|
+
enumerable: false,
|
|
3388
|
+
writable: true,
|
|
3389
|
+
configurable: true,
|
|
3390
|
+
});
|
|
2537
3391
|
|
|
2538
3392
|
function getMergedValue(target, source, prop, caseless) {
|
|
2539
3393
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
@@ -2570,11 +3424,37 @@ function mergeConfig$1(config1, config2) {
|
|
|
2570
3424
|
}
|
|
2571
3425
|
}
|
|
2572
3426
|
|
|
3427
|
+
function getMergedTransitionalOption(prop) {
|
|
3428
|
+
const transitional2 = utils$1.hasOwnProp(config2, 'transitional')
|
|
3429
|
+
? config2.transitional
|
|
3430
|
+
: undefined;
|
|
3431
|
+
|
|
3432
|
+
if (!utils$1.isUndefined(transitional2)) {
|
|
3433
|
+
if (utils$1.isPlainObject(transitional2)) {
|
|
3434
|
+
if (utils$1.hasOwnProp(transitional2, prop)) {
|
|
3435
|
+
return transitional2[prop];
|
|
3436
|
+
}
|
|
3437
|
+
} else {
|
|
3438
|
+
return undefined;
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
|
|
3442
|
+
const transitional1 = utils$1.hasOwnProp(config1, 'transitional')
|
|
3443
|
+
? config1.transitional
|
|
3444
|
+
: undefined;
|
|
3445
|
+
|
|
3446
|
+
if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
|
|
3447
|
+
return transitional1[prop];
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
return undefined;
|
|
3451
|
+
}
|
|
3452
|
+
|
|
2573
3453
|
// eslint-disable-next-line consistent-return
|
|
2574
3454
|
function mergeDirectKeys(a, b, prop) {
|
|
2575
|
-
if (prop
|
|
3455
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
2576
3456
|
return getMergedValue(a, b);
|
|
2577
|
-
} else if (prop
|
|
3457
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
2578
3458
|
return getMergedValue(undefined, a);
|
|
2579
3459
|
}
|
|
2580
3460
|
}
|
|
@@ -2588,7 +3468,7 @@ function mergeConfig$1(config1, config2) {
|
|
|
2588
3468
|
transformResponse: defaultToConfig2,
|
|
2589
3469
|
paramsSerializer: defaultToConfig2,
|
|
2590
3470
|
timeout: defaultToConfig2,
|
|
2591
|
-
|
|
3471
|
+
timeoutErrorMessage: defaultToConfig2,
|
|
2592
3472
|
withCredentials: defaultToConfig2,
|
|
2593
3473
|
withXSRFToken: defaultToConfig2,
|
|
2594
3474
|
adapter: defaultToConfig2,
|
|
@@ -2606,61 +3486,128 @@ function mergeConfig$1(config1, config2) {
|
|
|
2606
3486
|
httpsAgent: defaultToConfig2,
|
|
2607
3487
|
cancelToken: defaultToConfig2,
|
|
2608
3488
|
socketPath: defaultToConfig2,
|
|
3489
|
+
allowedSocketPaths: defaultToConfig2,
|
|
2609
3490
|
responseEncoding: defaultToConfig2,
|
|
2610
3491
|
validateStatus: mergeDirectKeys,
|
|
2611
3492
|
headers: (a, b, prop) =>
|
|
2612
3493
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2613
3494
|
};
|
|
2614
3495
|
|
|
2615
|
-
utils$1.forEach(
|
|
3496
|
+
utils$1.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
2616
3497
|
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
2617
3498
|
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
2618
|
-
const
|
|
3499
|
+
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
3500
|
+
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
3501
|
+
const configValue = merge(a, b, prop);
|
|
2619
3502
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2620
3503
|
});
|
|
2621
3504
|
|
|
3505
|
+
if (
|
|
3506
|
+
utils$1.hasOwnProp(config2, 'validateStatus') &&
|
|
3507
|
+
utils$1.isUndefined(config2.validateStatus) &&
|
|
3508
|
+
getMergedTransitionalOption('validateStatusUndefinedResolves') === false
|
|
3509
|
+
) {
|
|
3510
|
+
if (utils$1.hasOwnProp(config1, 'validateStatus')) {
|
|
3511
|
+
config.validateStatus = getMergedValue(undefined, config1.validateStatus);
|
|
3512
|
+
} else {
|
|
3513
|
+
delete config.validateStatus;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
|
|
2622
3517
|
return config;
|
|
2623
3518
|
}
|
|
2624
3519
|
|
|
2625
|
-
const
|
|
3520
|
+
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
3521
|
+
|
|
3522
|
+
/**
|
|
3523
|
+
* Apply the headers generated by a FormData implementation to the request headers,
|
|
3524
|
+
* honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
|
|
3525
|
+
* content-* headers; otherwise merge all of them.
|
|
3526
|
+
*
|
|
3527
|
+
* @param {AxiosHeaders} headers - the request headers to mutate
|
|
3528
|
+
* @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
|
|
3529
|
+
* @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
|
|
3530
|
+
*
|
|
3531
|
+
* @returns {void}
|
|
3532
|
+
*/
|
|
3533
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
3534
|
+
if (policy !== 'content-only') {
|
|
3535
|
+
headers.set(formHeaders);
|
|
3536
|
+
return;
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
3540
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
3541
|
+
headers.set(key, val);
|
|
3542
|
+
}
|
|
3543
|
+
});
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3546
|
+
/**
|
|
3547
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
3548
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
3549
|
+
*
|
|
3550
|
+
* @param {string} str The string to encode
|
|
3551
|
+
*
|
|
3552
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
3553
|
+
*/
|
|
3554
|
+
const encodeUTF8$1 = (str) =>
|
|
3555
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
3556
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
3557
|
+
);
|
|
3558
|
+
|
|
3559
|
+
function resolveConfig(config) {
|
|
2626
3560
|
const newConfig = mergeConfig$1({}, config);
|
|
2627
3561
|
|
|
2628
|
-
|
|
3562
|
+
// Read only own properties to prevent prototype pollution gadgets
|
|
3563
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
3564
|
+
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
3565
|
+
|
|
3566
|
+
const data = own('data');
|
|
3567
|
+
let withXSRFToken = own('withXSRFToken');
|
|
3568
|
+
const xsrfHeaderName = own('xsrfHeaderName');
|
|
3569
|
+
const xsrfCookieName = own('xsrfCookieName');
|
|
3570
|
+
let headers = own('headers');
|
|
3571
|
+
const auth = own('auth');
|
|
3572
|
+
const baseURL = own('baseURL');
|
|
3573
|
+
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
3574
|
+
const url = own('url');
|
|
2629
3575
|
|
|
2630
3576
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2631
3577
|
|
|
2632
3578
|
newConfig.url = buildURL(
|
|
2633
|
-
buildFullPath(
|
|
2634
|
-
|
|
2635
|
-
|
|
3579
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig),
|
|
3580
|
+
own('params'),
|
|
3581
|
+
own('paramsSerializer')
|
|
2636
3582
|
);
|
|
2637
3583
|
|
|
2638
3584
|
// HTTP basic authentication
|
|
2639
3585
|
if (auth) {
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
)
|
|
3586
|
+
const username = utils$1.getSafeProp(auth, 'username') || '';
|
|
3587
|
+
const password = utils$1.getSafeProp(auth, 'password') || '';
|
|
3588
|
+
|
|
3589
|
+
try {
|
|
3590
|
+
headers.set(
|
|
3591
|
+
'Authorization',
|
|
3592
|
+
'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : ''))
|
|
3593
|
+
);
|
|
3594
|
+
} catch (e) {
|
|
3595
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_OPTION_VALUE, config);
|
|
3596
|
+
}
|
|
2649
3597
|
}
|
|
2650
3598
|
|
|
2651
3599
|
if (utils$1.isFormData(data)) {
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
3600
|
+
const getHeaders = utils$1.getSafeProp(data, 'getHeaders');
|
|
3601
|
+
|
|
3602
|
+
if (
|
|
3603
|
+
platform.hasStandardBrowserEnv ||
|
|
3604
|
+
platform.hasStandardBrowserWebWorkerEnv ||
|
|
3605
|
+
utils$1.isReactNative(data)
|
|
3606
|
+
) {
|
|
3607
|
+
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
3608
|
+
} else if (utils$1.isFunction(getHeaders)) {
|
|
2655
3609
|
// Node.js FormData (like form-data package)
|
|
2656
|
-
|
|
2657
|
-
// Only set safe headers to avoid overwriting security headers
|
|
2658
|
-
const allowedHeaders = ['content-type', 'content-length'];
|
|
2659
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
2660
|
-
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
2661
|
-
headers.set(key, val);
|
|
2662
|
-
}
|
|
2663
|
-
});
|
|
3610
|
+
setFormDataHeaders(headers, getHeaders.call(data), own('formDataHeaderPolicy'));
|
|
2664
3611
|
}
|
|
2665
3612
|
}
|
|
2666
3613
|
|
|
@@ -2669,10 +3616,17 @@ const resolveConfig = (config) => {
|
|
|
2669
3616
|
// Specifically not if we're in a web worker, or react-native.
|
|
2670
3617
|
|
|
2671
3618
|
if (platform.hasStandardBrowserEnv) {
|
|
2672
|
-
|
|
3619
|
+
if (utils$1.isFunction(withXSRFToken)) {
|
|
3620
|
+
withXSRFToken = withXSRFToken(newConfig);
|
|
3621
|
+
}
|
|
2673
3622
|
|
|
2674
|
-
|
|
2675
|
-
|
|
3623
|
+
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
3624
|
+
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
3625
|
+
// the XSRF token cross-origin.
|
|
3626
|
+
const shouldSendXSRF =
|
|
3627
|
+
withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
3628
|
+
|
|
3629
|
+
if (shouldSendXSRF) {
|
|
2676
3630
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
2677
3631
|
|
|
2678
3632
|
if (xsrfValue) {
|
|
@@ -2682,7 +3636,7 @@ const resolveConfig = (config) => {
|
|
|
2682
3636
|
}
|
|
2683
3637
|
|
|
2684
3638
|
return newConfig;
|
|
2685
|
-
}
|
|
3639
|
+
}
|
|
2686
3640
|
|
|
2687
3641
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2688
3642
|
|
|
@@ -2695,7 +3649,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2695
3649
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
2696
3650
|
let onCanceled;
|
|
2697
3651
|
let uploadThrottled, downloadThrottled;
|
|
2698
|
-
let flushUpload, flushDownload;
|
|
3652
|
+
let flushUpload, flushDownload, flushDownloadWithEvent;
|
|
2699
3653
|
|
|
2700
3654
|
function done() {
|
|
2701
3655
|
flushUpload && flushUpload(); // flush events
|
|
@@ -2710,13 +3664,58 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2710
3664
|
|
|
2711
3665
|
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
2712
3666
|
|
|
2713
|
-
// Set the request timeout in MS
|
|
2714
|
-
request.timeout = _config.timeout;
|
|
3667
|
+
// Set the request timeout in MS
|
|
3668
|
+
request.timeout = _config.timeout;
|
|
3669
|
+
|
|
3670
|
+
function onloadend(event) {
|
|
3671
|
+
if (!request) {
|
|
3672
|
+
return;
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3675
|
+
// Status 0 means no response was received, which onerror and onabort normally
|
|
3676
|
+
// reject before this runs. Firefox 152 fires only readystatechange and loadend for
|
|
3677
|
+
// navigation-canceled requests (https://bugzilla.mozilla.org/show_bug.cgi?id=1505389),
|
|
3678
|
+
// leaving settle() to resolve them as an empty success. ECONNABORTED is the error
|
|
3679
|
+
// onabort raised on Firefox 151. Reads over file:, which some environments report as
|
|
3680
|
+
// status 0 on success, are excluded by the request URL's scheme after browser-style
|
|
3681
|
+
// preprocessing, by the page origin's scheme for relative URLs (which inherit it), or
|
|
3682
|
+
// by responseURL where implemented.
|
|
3683
|
+
if (
|
|
3684
|
+
request.status === 0 &&
|
|
3685
|
+
(parseProtocol(normalizeURLForProtocolCheck(_config.url)) ||
|
|
3686
|
+
parseProtocol(platform.origin)) !== 'file' &&
|
|
3687
|
+
!(request.responseURL && request.responseURL.startsWith('file:'))
|
|
3688
|
+
) {
|
|
3689
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
3690
|
+
done();
|
|
3691
|
+
|
|
3692
|
+
// Clean up request
|
|
3693
|
+
request = null;
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
|
|
3697
|
+
// When loadend is still dispatching, flushing with it gives progress
|
|
3698
|
+
// listeners a final delivery whose event has a live target. The legacy
|
|
3699
|
+
// ready-state fallback has no event, so replay its pending progress.
|
|
3700
|
+
// A throwing listener must not block settlement; rethrow asynchronously,
|
|
3701
|
+
// matching how listener errors surface on the throttle timer path.
|
|
3702
|
+
try {
|
|
3703
|
+
if (event) {
|
|
3704
|
+
flushDownloadWithEvent && flushDownloadWithEvent(event);
|
|
3705
|
+
} else {
|
|
3706
|
+
flushDownload && flushDownload();
|
|
3707
|
+
}
|
|
3708
|
+
} catch (err) {
|
|
3709
|
+
setTimeout(() => {
|
|
3710
|
+
throw err;
|
|
3711
|
+
});
|
|
3712
|
+
}
|
|
2715
3713
|
|
|
2716
|
-
|
|
3714
|
+
// A final progress callback can cancel the request synchronously.
|
|
2717
3715
|
if (!request) {
|
|
2718
3716
|
return;
|
|
2719
3717
|
}
|
|
3718
|
+
|
|
2720
3719
|
// Prepare the response
|
|
2721
3720
|
const responseHeaders = AxiosHeaders$1.from(
|
|
2722
3721
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
@@ -2766,7 +3765,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2766
3765
|
// will return status as 0 even though it's a successful request
|
|
2767
3766
|
if (
|
|
2768
3767
|
request.status === 0 &&
|
|
2769
|
-
!(request.responseURL && request.responseURL.
|
|
3768
|
+
!(request.responseURL && request.responseURL.startsWith('file:'))
|
|
2770
3769
|
) {
|
|
2771
3770
|
return;
|
|
2772
3771
|
}
|
|
@@ -2783,6 +3782,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2783
3782
|
}
|
|
2784
3783
|
|
|
2785
3784
|
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
3785
|
+
done();
|
|
2786
3786
|
|
|
2787
3787
|
// Clean up request
|
|
2788
3788
|
request = null;
|
|
@@ -2798,6 +3798,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2798
3798
|
// attach the underlying event for consumers who want details
|
|
2799
3799
|
err.event = event || null;
|
|
2800
3800
|
reject(err);
|
|
3801
|
+
done();
|
|
2801
3802
|
request = null;
|
|
2802
3803
|
};
|
|
2803
3804
|
|
|
@@ -2818,6 +3819,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2818
3819
|
request
|
|
2819
3820
|
)
|
|
2820
3821
|
);
|
|
3822
|
+
done();
|
|
2821
3823
|
|
|
2822
3824
|
// Clean up request
|
|
2823
3825
|
request = null;
|
|
@@ -2828,7 +3830,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2828
3830
|
|
|
2829
3831
|
// Add headers to the request
|
|
2830
3832
|
if ('setRequestHeader' in request) {
|
|
2831
|
-
utils$1.forEach(requestHeaders
|
|
3833
|
+
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
2832
3834
|
request.setRequestHeader(key, val);
|
|
2833
3835
|
});
|
|
2834
3836
|
}
|
|
@@ -2845,7 +3847,10 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2845
3847
|
|
|
2846
3848
|
// Handle progress if needed
|
|
2847
3849
|
if (onDownloadProgress) {
|
|
2848
|
-
[downloadThrottled, flushDownload] = progressEventReducer(
|
|
3850
|
+
[downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
|
|
3851
|
+
onDownloadProgress,
|
|
3852
|
+
true
|
|
3853
|
+
);
|
|
2849
3854
|
request.addEventListener('progress', downloadThrottled);
|
|
2850
3855
|
}
|
|
2851
3856
|
|
|
@@ -2867,6 +3872,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2867
3872
|
}
|
|
2868
3873
|
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2869
3874
|
request.abort();
|
|
3875
|
+
done();
|
|
2870
3876
|
request = null;
|
|
2871
3877
|
};
|
|
2872
3878
|
|
|
@@ -2880,7 +3886,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2880
3886
|
|
|
2881
3887
|
const protocol = parseProtocol(_config.url);
|
|
2882
3888
|
|
|
2883
|
-
if (protocol && platform.protocols.
|
|
3889
|
+
if (protocol && !platform.protocols.includes(protocol)) {
|
|
2884
3890
|
reject(
|
|
2885
3891
|
new AxiosError$1(
|
|
2886
3892
|
'Unsupported protocol ' + protocol + ':',
|
|
@@ -2888,6 +3894,7 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2888
3894
|
config
|
|
2889
3895
|
)
|
|
2890
3896
|
);
|
|
3897
|
+
done();
|
|
2891
3898
|
return;
|
|
2892
3899
|
}
|
|
2893
3900
|
|
|
@@ -2897,54 +3904,66 @@ const xhrAdapter = isXHRAdapterSupported &&
|
|
|
2897
3904
|
};
|
|
2898
3905
|
|
|
2899
3906
|
const composeSignals = (signals, timeout) => {
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
if (timeout || length) {
|
|
2903
|
-
let controller = new AbortController();
|
|
2904
|
-
|
|
2905
|
-
let aborted;
|
|
2906
|
-
|
|
2907
|
-
const onabort = function (reason) {
|
|
2908
|
-
if (!aborted) {
|
|
2909
|
-
aborted = true;
|
|
2910
|
-
unsubscribe();
|
|
2911
|
-
const err = reason instanceof Error ? reason : this.reason;
|
|
2912
|
-
controller.abort(
|
|
2913
|
-
err instanceof AxiosError$1
|
|
2914
|
-
? err
|
|
2915
|
-
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
2916
|
-
);
|
|
2917
|
-
}
|
|
2918
|
-
};
|
|
3907
|
+
signals = signals ? signals.filter(Boolean) : [];
|
|
2919
3908
|
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
timer = null;
|
|
2924
|
-
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
2925
|
-
}, timeout);
|
|
2926
|
-
|
|
2927
|
-
const unsubscribe = () => {
|
|
2928
|
-
if (signals) {
|
|
2929
|
-
timer && clearTimeout(timer);
|
|
2930
|
-
timer = null;
|
|
2931
|
-
signals.forEach((signal) => {
|
|
2932
|
-
signal.unsubscribe
|
|
2933
|
-
? signal.unsubscribe(onabort)
|
|
2934
|
-
: signal.removeEventListener('abort', onabort);
|
|
2935
|
-
});
|
|
2936
|
-
signals = null;
|
|
2937
|
-
}
|
|
2938
|
-
};
|
|
3909
|
+
if (!timeout && !signals.length) {
|
|
3910
|
+
return;
|
|
3911
|
+
}
|
|
2939
3912
|
|
|
2940
|
-
|
|
3913
|
+
const controller = new AbortController();
|
|
2941
3914
|
|
|
2942
|
-
|
|
3915
|
+
let aborted = false;
|
|
2943
3916
|
|
|
2944
|
-
|
|
3917
|
+
const onabort = function (reason) {
|
|
3918
|
+
if (!aborted) {
|
|
3919
|
+
aborted = true;
|
|
3920
|
+
unsubscribe();
|
|
3921
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
3922
|
+
controller.abort(
|
|
3923
|
+
err instanceof AxiosError$1
|
|
3924
|
+
? err
|
|
3925
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3926
|
+
);
|
|
3927
|
+
}
|
|
3928
|
+
};
|
|
2945
3929
|
|
|
2946
|
-
|
|
2947
|
-
|
|
3930
|
+
let timer =
|
|
3931
|
+
timeout &&
|
|
3932
|
+
setTimeout(() => {
|
|
3933
|
+
timer = null;
|
|
3934
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3935
|
+
}, timeout);
|
|
3936
|
+
|
|
3937
|
+
const unsubscribe = () => {
|
|
3938
|
+
if (!signals) { return; }
|
|
3939
|
+
timer && clearTimeout(timer);
|
|
3940
|
+
timer = null;
|
|
3941
|
+
signals.forEach((signal) => {
|
|
3942
|
+
signal.unsubscribe
|
|
3943
|
+
? signal.unsubscribe(onabort)
|
|
3944
|
+
: signal.removeEventListener('abort', onabort);
|
|
3945
|
+
});
|
|
3946
|
+
signals = null;
|
|
3947
|
+
};
|
|
3948
|
+
|
|
3949
|
+
signals.forEach((signal) => {
|
|
3950
|
+
if (aborted) {
|
|
3951
|
+
return;
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
if (signal.aborted) {
|
|
3955
|
+
onabort.call(signal);
|
|
3956
|
+
return;
|
|
3957
|
+
}
|
|
3958
|
+
|
|
3959
|
+
signal.addEventListener('abort', onabort, { once: true });
|
|
3960
|
+
});
|
|
3961
|
+
|
|
3962
|
+
const { signal } = controller;
|
|
3963
|
+
|
|
3964
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
3965
|
+
|
|
3966
|
+
return signal;
|
|
2948
3967
|
};
|
|
2949
3968
|
|
|
2950
3969
|
const streamChunk = function* (chunk, chunkSize) {
|
|
@@ -3037,16 +4056,209 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3037
4056
|
);
|
|
3038
4057
|
};
|
|
3039
4058
|
|
|
4059
|
+
/**
|
|
4060
|
+
* Estimate data: URL byte lengths *without* allocating large buffers.
|
|
4061
|
+
* - Fetch percent-decodes a base64 body before decoding it.
|
|
4062
|
+
* - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
|
|
4063
|
+
* raw body, including ignored characters and content after padding.
|
|
4064
|
+
* - Non-base64 data is percent-decoded and then encoded as UTF-8.
|
|
4065
|
+
*/
|
|
4066
|
+
const isHexDigit = (charCode) =>
|
|
4067
|
+
(charCode >= 48 && charCode <= 57) ||
|
|
4068
|
+
(charCode >= 65 && charCode <= 70) ||
|
|
4069
|
+
(charCode >= 97 && charCode <= 102);
|
|
4070
|
+
|
|
4071
|
+
const isPercentEncodedByte = (str, i, len) =>
|
|
4072
|
+
i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
4073
|
+
|
|
4074
|
+
const hexValue = (charCode) => (charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55);
|
|
4075
|
+
|
|
4076
|
+
const isBase64Char = (charCode) =>
|
|
4077
|
+
(charCode >= 65 && charCode <= 90) || // A-Z
|
|
4078
|
+
(charCode >= 97 && charCode <= 122) || // a-z
|
|
4079
|
+
(charCode >= 48 && charCode <= 57) || // 0-9
|
|
4080
|
+
charCode === 43 || // +
|
|
4081
|
+
charCode === 47 || // /
|
|
4082
|
+
charCode === 45 || // - (base64url)
|
|
4083
|
+
charCode === 95; // _ (base64url)
|
|
4084
|
+
|
|
4085
|
+
const isBase64Whitespace = (charCode) =>
|
|
4086
|
+
charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
|
|
4087
|
+
|
|
4088
|
+
const base64Bytes = (significant) => {
|
|
4089
|
+
const groups = Math.floor(significant / 4);
|
|
4090
|
+
const remainder = significant % 4;
|
|
4091
|
+
return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
|
|
4092
|
+
};
|
|
4093
|
+
|
|
4094
|
+
// Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
|
|
4095
|
+
// upper bound even when Buffer.from later ignores characters or stops at '='.
|
|
4096
|
+
const estimateBase64BufferAllocation = (body) => {
|
|
4097
|
+
const len = body.length;
|
|
4098
|
+
let padding = 0;
|
|
4099
|
+
|
|
4100
|
+
if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
|
|
4101
|
+
padding++;
|
|
4102
|
+
|
|
4103
|
+
if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
|
|
4104
|
+
padding++;
|
|
4105
|
+
}
|
|
4106
|
+
}
|
|
4107
|
+
|
|
4108
|
+
return Math.floor(((len - padding) * 3) / 4);
|
|
4109
|
+
};
|
|
4110
|
+
|
|
4111
|
+
const estimatePercentDecodedBase64Bytes = (body) => {
|
|
4112
|
+
const len = body.length;
|
|
4113
|
+
let significant = 0;
|
|
4114
|
+
let padding = 0;
|
|
4115
|
+
let invalid = false;
|
|
4116
|
+
|
|
4117
|
+
for (let i = 0; i < len; i++) {
|
|
4118
|
+
let code = body.charCodeAt(i);
|
|
4119
|
+
|
|
4120
|
+
if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
4121
|
+
code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
|
|
4122
|
+
i += 2;
|
|
4123
|
+
}
|
|
4124
|
+
|
|
4125
|
+
if (isBase64Whitespace(code)) {
|
|
4126
|
+
continue;
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
if (code === 61 /* '=' */) {
|
|
4130
|
+
padding++;
|
|
4131
|
+
continue;
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
if (!isBase64Char(code) || padding > 0) {
|
|
4135
|
+
invalid = true;
|
|
4136
|
+
continue;
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
significant++;
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
// Fetch rejects malformed forgiving-base64 input. Returning the raw-size
|
|
4143
|
+
// allocation bound keeps that invalid input from becoming a pre-check bypass.
|
|
4144
|
+
if (
|
|
4145
|
+
invalid ||
|
|
4146
|
+
padding > 2 ||
|
|
4147
|
+
(padding > 0 && (significant + padding) % 4 !== 0) ||
|
|
4148
|
+
significant % 4 === 1
|
|
4149
|
+
) {
|
|
4150
|
+
return estimateBase64BufferAllocation(body);
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4153
|
+
return base64Bytes(significant);
|
|
4154
|
+
};
|
|
4155
|
+
|
|
4156
|
+
const estimateDataURLBytes = (url, estimateBase64) => {
|
|
4157
|
+
if (!url || typeof url !== 'string') return 0;
|
|
4158
|
+
if (!url.startsWith('data:')) return 0;
|
|
4159
|
+
|
|
4160
|
+
const comma = url.indexOf(',');
|
|
4161
|
+
if (comma < 0) return 0;
|
|
4162
|
+
|
|
4163
|
+
const meta = url.slice(5, comma);
|
|
4164
|
+
const body = url.slice(comma + 1);
|
|
4165
|
+
const isBase64 = /;base64/i.test(meta);
|
|
4166
|
+
|
|
4167
|
+
if (isBase64) {
|
|
4168
|
+
return estimateBase64(body);
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
4172
|
+
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
4173
|
+
// Valid %XX triplets count as one decoded byte; this matches the bytes that
|
|
4174
|
+
// decodeURIComponent(body) would produce before Buffer re-encodes the string.
|
|
4175
|
+
let bytes = 0;
|
|
4176
|
+
for (let i = 0, len = body.length; i < len; i++) {
|
|
4177
|
+
const c = body.charCodeAt(i);
|
|
4178
|
+
if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
|
|
4179
|
+
bytes += 1;
|
|
4180
|
+
i += 2;
|
|
4181
|
+
} else if (c < 0x80) {
|
|
4182
|
+
bytes += 1;
|
|
4183
|
+
} else if (c < 0x800) {
|
|
4184
|
+
bytes += 2;
|
|
4185
|
+
} else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
|
4186
|
+
const next = body.charCodeAt(i + 1);
|
|
4187
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
4188
|
+
bytes += 4;
|
|
4189
|
+
i++;
|
|
4190
|
+
} else {
|
|
4191
|
+
bytes += 3;
|
|
4192
|
+
}
|
|
4193
|
+
} else {
|
|
4194
|
+
bytes += 3;
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
return bytes;
|
|
4198
|
+
};
|
|
4199
|
+
|
|
4200
|
+
/**
|
|
4201
|
+
* Estimate the percent-decoded payload size used by Fetch data: URLs.
|
|
4202
|
+
*
|
|
4203
|
+
* @param {string} url
|
|
4204
|
+
* @returns {number}
|
|
4205
|
+
*/
|
|
4206
|
+
function estimateDataURLDecodedBytes(url) {
|
|
4207
|
+
// Fetch removes URL fragments before processing a data: URL.
|
|
4208
|
+
const fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
|
|
4209
|
+
|
|
4210
|
+
return estimateDataURLBytes(
|
|
4211
|
+
fragmentIndex === -1 ? url : url.slice(0, fragmentIndex),
|
|
4212
|
+
estimatePercentDecodedBase64Bytes
|
|
4213
|
+
);
|
|
4214
|
+
}
|
|
4215
|
+
|
|
4216
|
+
const VERSION$1 = "1.20.0";
|
|
4217
|
+
|
|
3040
4218
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3041
4219
|
|
|
4220
|
+
const DEFAULT_REQUEST_OPTIONS = {
|
|
4221
|
+
cache: 'default',
|
|
4222
|
+
redirect: 'follow',
|
|
4223
|
+
referrer: 'about:client',
|
|
4224
|
+
referrerPolicy: '',
|
|
4225
|
+
mode: 'cors',
|
|
4226
|
+
integrity: '',
|
|
4227
|
+
keepalive: false,
|
|
4228
|
+
priority: 'auto',
|
|
4229
|
+
window: null,
|
|
4230
|
+
};
|
|
4231
|
+
|
|
3042
4232
|
const { isFunction } = utils$1;
|
|
3043
4233
|
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
4234
|
+
/**
|
|
4235
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
4236
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
4237
|
+
*
|
|
4238
|
+
* @param {string} str The string to encode
|
|
4239
|
+
*
|
|
4240
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
4241
|
+
*/
|
|
4242
|
+
const encodeUTF8 = (str) =>
|
|
4243
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
4244
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
4245
|
+
);
|
|
4246
|
+
|
|
4247
|
+
// Node's WHATWG URL parser returns `username` and `password` percent-encoded.
|
|
4248
|
+
// Decode before composing the `auth` option so credentials such as
|
|
4249
|
+
// `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
|
|
4250
|
+
// original value for malformed input so a bad encoding never throws.
|
|
4251
|
+
const decodeURIComponentSafe = (value) => {
|
|
4252
|
+
if (!utils$1.isString(value)) {
|
|
4253
|
+
return value;
|
|
4254
|
+
}
|
|
3048
4255
|
|
|
3049
|
-
|
|
4256
|
+
try {
|
|
4257
|
+
return decodeURIComponent(value);
|
|
4258
|
+
} catch (error) {
|
|
4259
|
+
return value;
|
|
4260
|
+
}
|
|
4261
|
+
};
|
|
3050
4262
|
|
|
3051
4263
|
const test = (fn, ...args) => {
|
|
3052
4264
|
try {
|
|
@@ -3056,12 +4268,28 @@ const test = (fn, ...args) => {
|
|
|
3056
4268
|
}
|
|
3057
4269
|
};
|
|
3058
4270
|
|
|
4271
|
+
const maybeWithAuthCredentials = (url) => {
|
|
4272
|
+
const protocolIndex = url.indexOf('://');
|
|
4273
|
+
let urlToCheck = url;
|
|
4274
|
+
if (protocolIndex !== -1) {
|
|
4275
|
+
urlToCheck = urlToCheck.slice(protocolIndex + 3);
|
|
4276
|
+
}
|
|
4277
|
+
return urlToCheck.includes('@') || urlToCheck.includes(':');
|
|
4278
|
+
};
|
|
4279
|
+
|
|
3059
4280
|
const factory = (env) => {
|
|
4281
|
+
const globalObject =
|
|
4282
|
+
utils$1.global !== undefined && utils$1.global !== null ? utils$1.global : globalThis;
|
|
4283
|
+
const { ReadableStream, TextEncoder } = globalObject;
|
|
4284
|
+
|
|
3060
4285
|
env = utils$1.merge.call(
|
|
3061
4286
|
{
|
|
3062
4287
|
skipUndefined: true,
|
|
3063
4288
|
},
|
|
3064
|
-
|
|
4289
|
+
{
|
|
4290
|
+
Request: globalObject.Request,
|
|
4291
|
+
Response: globalObject.Response,
|
|
4292
|
+
},
|
|
3065
4293
|
env
|
|
3066
4294
|
);
|
|
3067
4295
|
|
|
@@ -3074,7 +4302,7 @@ const factory = (env) => {
|
|
|
3074
4302
|
return false;
|
|
3075
4303
|
}
|
|
3076
4304
|
|
|
3077
|
-
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream
|
|
4305
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
|
3078
4306
|
|
|
3079
4307
|
const encodeText =
|
|
3080
4308
|
isFetchSupported &&
|
|
@@ -3091,14 +4319,20 @@ const factory = (env) => {
|
|
|
3091
4319
|
test(() => {
|
|
3092
4320
|
let duplexAccessed = false;
|
|
3093
4321
|
|
|
3094
|
-
const
|
|
3095
|
-
body: new ReadableStream
|
|
4322
|
+
const request = new Request(platform.origin, {
|
|
4323
|
+
body: new ReadableStream(),
|
|
3096
4324
|
method: 'POST',
|
|
3097
4325
|
get duplex() {
|
|
3098
4326
|
duplexAccessed = true;
|
|
3099
4327
|
return 'half';
|
|
3100
4328
|
},
|
|
3101
|
-
})
|
|
4329
|
+
});
|
|
4330
|
+
|
|
4331
|
+
const hasContentType = request.headers.has('Content-Type');
|
|
4332
|
+
|
|
4333
|
+
if (request.body != null) {
|
|
4334
|
+
request.body.cancel();
|
|
4335
|
+
}
|
|
3102
4336
|
|
|
3103
4337
|
return duplexAccessed && !hasContentType;
|
|
3104
4338
|
});
|
|
@@ -3182,8 +4416,15 @@ const factory = (env) => {
|
|
|
3182
4416
|
headers,
|
|
3183
4417
|
withCredentials = 'same-origin',
|
|
3184
4418
|
fetchOptions,
|
|
4419
|
+
maxContentLength,
|
|
4420
|
+
maxBodyLength,
|
|
4421
|
+
maxRedirects,
|
|
3185
4422
|
} = resolveConfig(config);
|
|
3186
4423
|
|
|
4424
|
+
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
4425
|
+
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
4426
|
+
const own = (key) => (utils$1.hasOwnProp(config, key) ? config[key] : undefined);
|
|
4427
|
+
|
|
3187
4428
|
let _fetch = envFetch || fetch;
|
|
3188
4429
|
|
|
3189
4430
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
@@ -3204,34 +4445,171 @@ const factory = (env) => {
|
|
|
3204
4445
|
|
|
3205
4446
|
let requestContentLength;
|
|
3206
4447
|
|
|
4448
|
+
// AxiosError we raise while the request body is being streamed. Captured
|
|
4449
|
+
// by identity so the catch block can surface it directly, regardless of
|
|
4450
|
+
// how the runtime wraps the resulting fetch rejection (undici exposes it
|
|
4451
|
+
// as `err.cause`; some browsers drop the original error entirely).
|
|
4452
|
+
let pendingBodyError = null;
|
|
4453
|
+
|
|
4454
|
+
const maxBodyLengthError = () =>
|
|
4455
|
+
new AxiosError$1(
|
|
4456
|
+
'Request body larger than maxBodyLength limit',
|
|
4457
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
4458
|
+
config,
|
|
4459
|
+
request
|
|
4460
|
+
);
|
|
4461
|
+
|
|
3207
4462
|
try {
|
|
4463
|
+
// HTTP basic authentication
|
|
4464
|
+
let auth = undefined;
|
|
4465
|
+
const configAuth = own('auth');
|
|
4466
|
+
|
|
4467
|
+
if (configAuth) {
|
|
4468
|
+
const username = utils$1.getSafeProp(configAuth, 'username') || '';
|
|
4469
|
+
const password = utils$1.getSafeProp(configAuth, 'password') || '';
|
|
4470
|
+
auth = {
|
|
4471
|
+
username,
|
|
4472
|
+
password,
|
|
4473
|
+
};
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
if (maybeWithAuthCredentials(url)) {
|
|
4477
|
+
const parsedURL = new URL(url, platform.origin);
|
|
4478
|
+
|
|
4479
|
+
if (!auth && (parsedURL.username || parsedURL.password)) {
|
|
4480
|
+
const urlUsername = decodeURIComponentSafe(parsedURL.username);
|
|
4481
|
+
const urlPassword = decodeURIComponentSafe(parsedURL.password);
|
|
4482
|
+
auth = {
|
|
4483
|
+
username: urlUsername,
|
|
4484
|
+
password: urlPassword,
|
|
4485
|
+
};
|
|
4486
|
+
}
|
|
4487
|
+
|
|
4488
|
+
if (parsedURL.username || parsedURL.password) {
|
|
4489
|
+
parsedURL.username = '';
|
|
4490
|
+
parsedURL.password = '';
|
|
4491
|
+
url = parsedURL.href;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
|
|
4495
|
+
if (auth) {
|
|
4496
|
+
headers.delete('authorization');
|
|
4497
|
+
headers.set(
|
|
4498
|
+
'Authorization',
|
|
4499
|
+
'Basic ' + btoa(encodeUTF8((auth.username || '') + ':' + (auth.password || '')))
|
|
4500
|
+
);
|
|
4501
|
+
}
|
|
4502
|
+
|
|
4503
|
+
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
4504
|
+
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
4505
|
+
// "if (protocol === 'data:')" branch).
|
|
4506
|
+
if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
|
|
4507
|
+
const estimated = estimateDataURLDecodedBytes(url);
|
|
4508
|
+
if (estimated > maxContentLength) {
|
|
4509
|
+
throw new AxiosError$1(
|
|
4510
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4511
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4512
|
+
config,
|
|
4513
|
+
request
|
|
4514
|
+
);
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
|
|
4518
|
+
// Enforce maxBodyLength against known-size bodies before dispatch using
|
|
4519
|
+
// the body's *actual* size — never a caller-declared Content-Length,
|
|
4520
|
+
// which could under-report to slip an oversized body past the check.
|
|
4521
|
+
// Unknown-size streams return undefined here and are counted per-chunk
|
|
4522
|
+
// below as fetch consumes them.
|
|
4523
|
+
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
4524
|
+
const outboundLength = await getBodyLength(data);
|
|
4525
|
+
if (typeof outboundLength === 'number' && isFinite(outboundLength)) {
|
|
4526
|
+
requestContentLength = outboundLength;
|
|
4527
|
+
if (outboundLength > maxBodyLength) {
|
|
4528
|
+
throw maxBodyLengthError();
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
}
|
|
4532
|
+
|
|
4533
|
+
// A streamed body under maxBodyLength must be counted as fetch consumes
|
|
4534
|
+
// it; its size is never trusted from a caller-declared Content-Length.
|
|
4535
|
+
const mustEnforceStreamBody =
|
|
4536
|
+
hasMaxBodyLength && (utils$1.isReadableStream(data) || utils$1.isStream(data));
|
|
4537
|
+
|
|
4538
|
+
const trackRequestStream = (stream, onProgress, flush) =>
|
|
4539
|
+
trackStream(
|
|
4540
|
+
stream,
|
|
4541
|
+
DEFAULT_CHUNK_SIZE,
|
|
4542
|
+
(loadedBytes) => {
|
|
4543
|
+
if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
|
|
4544
|
+
throw (pendingBodyError = maxBodyLengthError());
|
|
4545
|
+
}
|
|
4546
|
+
onProgress && onProgress(loadedBytes);
|
|
4547
|
+
},
|
|
4548
|
+
flush
|
|
4549
|
+
);
|
|
4550
|
+
|
|
3208
4551
|
if (
|
|
3209
|
-
onUploadProgress &&
|
|
3210
4552
|
supportsRequestStream &&
|
|
3211
4553
|
method !== 'get' &&
|
|
3212
4554
|
method !== 'head' &&
|
|
3213
|
-
(
|
|
4555
|
+
(onUploadProgress || mustEnforceStreamBody)
|
|
3214
4556
|
) {
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
4557
|
+
requestContentLength =
|
|
4558
|
+
requestContentLength == null
|
|
4559
|
+
? await resolveBodyLength(headers, data)
|
|
4560
|
+
: requestContentLength;
|
|
4561
|
+
|
|
4562
|
+
// A declared length of 0 is only trusted to skip the wrap when we are
|
|
4563
|
+
// not enforcing a stream limit (which must not rely on that header).
|
|
4564
|
+
if (requestContentLength !== 0 || mustEnforceStreamBody) {
|
|
4565
|
+
let _request = new Request(url, {
|
|
4566
|
+
method: 'POST',
|
|
4567
|
+
body: data,
|
|
4568
|
+
duplex: 'half',
|
|
4569
|
+
});
|
|
3220
4570
|
|
|
3221
|
-
|
|
4571
|
+
let contentTypeHeader;
|
|
3222
4572
|
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
4573
|
+
if (
|
|
4574
|
+
utils$1.isFormData(data) &&
|
|
4575
|
+
(contentTypeHeader = _request.headers.get('content-type'))
|
|
4576
|
+
) {
|
|
4577
|
+
headers.setContentType(contentTypeHeader);
|
|
4578
|
+
}
|
|
3226
4579
|
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
4580
|
+
if (_request.body) {
|
|
4581
|
+
const [onProgress, flush] =
|
|
4582
|
+
(onUploadProgress &&
|
|
4583
|
+
progressEventDecorator(
|
|
4584
|
+
requestContentLength,
|
|
4585
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
4586
|
+
)) ||
|
|
4587
|
+
[];
|
|
3232
4588
|
|
|
3233
|
-
|
|
4589
|
+
data = trackRequestStream(_request.body, onProgress, flush);
|
|
4590
|
+
}
|
|
3234
4591
|
}
|
|
4592
|
+
} else if (
|
|
4593
|
+
mustEnforceStreamBody &&
|
|
4594
|
+
!isRequestSupported &&
|
|
4595
|
+
isReadableStreamSupported &&
|
|
4596
|
+
method !== 'get' &&
|
|
4597
|
+
method !== 'head'
|
|
4598
|
+
) {
|
|
4599
|
+
data = trackRequestStream(data);
|
|
4600
|
+
} else if (
|
|
4601
|
+
mustEnforceStreamBody &&
|
|
4602
|
+
isRequestSupported &&
|
|
4603
|
+
!supportsRequestStream &&
|
|
4604
|
+
method !== 'get' &&
|
|
4605
|
+
method !== 'head'
|
|
4606
|
+
) {
|
|
4607
|
+
throw new AxiosError$1(
|
|
4608
|
+
'Stream request bodies are not supported by the current fetch implementation',
|
|
4609
|
+
AxiosError$1.ERR_NOT_SUPPORT,
|
|
4610
|
+
config,
|
|
4611
|
+
request
|
|
4612
|
+
);
|
|
3235
4613
|
}
|
|
3236
4614
|
|
|
3237
4615
|
if (!utils$1.isString(withCredentials)) {
|
|
@@ -3242,33 +4620,106 @@ const factory = (env) => {
|
|
|
3242
4620
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
3243
4621
|
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
3244
4622
|
|
|
3245
|
-
|
|
3246
|
-
|
|
4623
|
+
// If data is FormData and Content-Type is multipart/form-data without boundary,
|
|
4624
|
+
// delete it so fetch can set it correctly with the boundary
|
|
4625
|
+
if (utils$1.isFormData(data)) {
|
|
4626
|
+
const contentType = headers.getContentType();
|
|
4627
|
+
if (
|
|
4628
|
+
contentType &&
|
|
4629
|
+
/^multipart\/form-data/i.test(contentType) &&
|
|
4630
|
+
!/boundary=/i.test(contentType)
|
|
4631
|
+
) {
|
|
4632
|
+
headers.delete('content-type');
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
|
|
4636
|
+
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
4637
|
+
headers.set('User-Agent', 'axios/' + VERSION$1, false);
|
|
4638
|
+
|
|
4639
|
+
const safeFetchOptions =
|
|
4640
|
+
fetchOptions == null ? fetchOptions : Object.assign(Object.create(null), fetchOptions);
|
|
4641
|
+
|
|
4642
|
+
if (safeFetchOptions) {
|
|
4643
|
+
// These options are owned by Axios and are already reflected in the
|
|
4644
|
+
// resolved Request passed to fetch.
|
|
4645
|
+
delete safeFetchOptions.body;
|
|
4646
|
+
delete safeFetchOptions.headers;
|
|
4647
|
+
delete safeFetchOptions.method;
|
|
4648
|
+
delete safeFetchOptions.signal;
|
|
4649
|
+
delete safeFetchOptions.duplex;
|
|
4650
|
+
delete safeFetchOptions.credentials;
|
|
4651
|
+
}
|
|
4652
|
+
|
|
4653
|
+
const resolvedOptions = Object.assign(Object.create(null), safeFetchOptions, {
|
|
3247
4654
|
signal: composedSignal,
|
|
3248
4655
|
method: method.toUpperCase(),
|
|
3249
|
-
headers: headers.normalize()
|
|
4656
|
+
headers: toByteStringHeaderObject(headers.normalize()),
|
|
3250
4657
|
body: data,
|
|
3251
4658
|
duplex: 'half',
|
|
3252
4659
|
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
3253
|
-
};
|
|
4660
|
+
});
|
|
4661
|
+
|
|
4662
|
+
if (isRequestSupported) {
|
|
4663
|
+
utils$1.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
|
|
4664
|
+
if (resolvedOptions[key] === undefined) {
|
|
4665
|
+
resolvedOptions[key] = value;
|
|
4666
|
+
}
|
|
4667
|
+
});
|
|
4668
|
+
|
|
4669
|
+
if (resolvedOptions.signal === undefined) {
|
|
4670
|
+
resolvedOptions.signal = null;
|
|
4671
|
+
}
|
|
4672
|
+
|
|
4673
|
+
if (resolvedOptions.body === undefined) {
|
|
4674
|
+
resolvedOptions.body = null;
|
|
4675
|
+
}
|
|
4676
|
+
}
|
|
4677
|
+
|
|
4678
|
+
if (maxRedirects === 0) {
|
|
4679
|
+
resolvedOptions.redirect = 'manual';
|
|
4680
|
+
|
|
4681
|
+
if (safeFetchOptions) {
|
|
4682
|
+
safeFetchOptions.redirect = 'manual';
|
|
4683
|
+
}
|
|
4684
|
+
}
|
|
3254
4685
|
|
|
3255
4686
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3256
4687
|
|
|
3257
4688
|
let response = await (isRequestSupported
|
|
3258
|
-
? _fetch(request,
|
|
4689
|
+
? _fetch(request, safeFetchOptions)
|
|
3259
4690
|
: _fetch(url, resolvedOptions));
|
|
3260
4691
|
|
|
4692
|
+
const responseHeaders = AxiosHeaders$1.from(response.headers);
|
|
4693
|
+
|
|
4694
|
+
// Cheap pre-check: if the server honestly declares a content-length that
|
|
4695
|
+
// already exceeds the cap, reject before we start streaming.
|
|
4696
|
+
if (hasMaxContentLength) {
|
|
4697
|
+
const declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
4698
|
+
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
4699
|
+
throw new AxiosError$1(
|
|
4700
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4701
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4702
|
+
config,
|
|
4703
|
+
request
|
|
4704
|
+
);
|
|
4705
|
+
}
|
|
4706
|
+
}
|
|
4707
|
+
|
|
3261
4708
|
const isStreamResponse =
|
|
3262
4709
|
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3263
4710
|
|
|
3264
|
-
if (
|
|
4711
|
+
if (
|
|
4712
|
+
supportsResponseStream &&
|
|
4713
|
+
response.body &&
|
|
4714
|
+
(onDownloadProgress || hasMaxContentLength || (isStreamResponse && unsubscribe))
|
|
4715
|
+
) {
|
|
3265
4716
|
const options = {};
|
|
3266
4717
|
|
|
3267
4718
|
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
3268
4719
|
options[prop] = response[prop];
|
|
3269
4720
|
});
|
|
3270
4721
|
|
|
3271
|
-
const responseContentLength = utils$1.toFiniteNumber(
|
|
4722
|
+
const responseContentLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
|
|
3272
4723
|
|
|
3273
4724
|
const [onProgress, flush] =
|
|
3274
4725
|
(onDownloadProgress &&
|
|
@@ -3278,8 +4729,24 @@ const factory = (env) => {
|
|
|
3278
4729
|
)) ||
|
|
3279
4730
|
[];
|
|
3280
4731
|
|
|
4732
|
+
let bytesRead = 0;
|
|
4733
|
+
const onChunkProgress = (loadedBytes) => {
|
|
4734
|
+
if (hasMaxContentLength) {
|
|
4735
|
+
bytesRead = loadedBytes;
|
|
4736
|
+
if (bytesRead > maxContentLength) {
|
|
4737
|
+
throw new AxiosError$1(
|
|
4738
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4739
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4740
|
+
config,
|
|
4741
|
+
request
|
|
4742
|
+
);
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4745
|
+
onProgress && onProgress(loadedBytes);
|
|
4746
|
+
};
|
|
4747
|
+
|
|
3281
4748
|
response = new Response(
|
|
3282
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE,
|
|
4749
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
|
|
3283
4750
|
flush && flush();
|
|
3284
4751
|
unsubscribe && unsubscribe();
|
|
3285
4752
|
}),
|
|
@@ -3294,6 +4761,33 @@ const factory = (env) => {
|
|
|
3294
4761
|
config
|
|
3295
4762
|
);
|
|
3296
4763
|
|
|
4764
|
+
// Fallback enforcement for environments without ReadableStream support
|
|
4765
|
+
// (legacy runtimes). Detect materialized size from typed output; skip
|
|
4766
|
+
// streams/Response passthrough since the user will read those themselves.
|
|
4767
|
+
if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
|
|
4768
|
+
let materializedSize;
|
|
4769
|
+
if (responseData != null) {
|
|
4770
|
+
if (typeof responseData.byteLength === 'number') {
|
|
4771
|
+
materializedSize = responseData.byteLength;
|
|
4772
|
+
} else if (typeof responseData.size === 'number') {
|
|
4773
|
+
materializedSize = responseData.size;
|
|
4774
|
+
} else if (typeof responseData === 'string') {
|
|
4775
|
+
materializedSize =
|
|
4776
|
+
typeof TextEncoder === 'function'
|
|
4777
|
+
? new TextEncoder().encode(responseData).byteLength
|
|
4778
|
+
: responseData.length;
|
|
4779
|
+
}
|
|
4780
|
+
}
|
|
4781
|
+
if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
|
|
4782
|
+
throw new AxiosError$1(
|
|
4783
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
4784
|
+
AxiosError$1.ERR_BAD_RESPONSE,
|
|
4785
|
+
config,
|
|
4786
|
+
request
|
|
4787
|
+
);
|
|
4788
|
+
}
|
|
4789
|
+
}
|
|
4790
|
+
|
|
3297
4791
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3298
4792
|
|
|
3299
4793
|
return await new Promise((resolve, reject) => {
|
|
@@ -3309,19 +4803,62 @@ const factory = (env) => {
|
|
|
3309
4803
|
} catch (err) {
|
|
3310
4804
|
unsubscribe && unsubscribe();
|
|
3311
4805
|
|
|
4806
|
+
// Safari can surface fetch aborts as a DOMException-like object whose
|
|
4807
|
+
// branded getters throw. Prefer our composed signal reason before reading
|
|
4808
|
+
// the caught error, preserving timeout vs cancellation semantics.
|
|
4809
|
+
if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError$1) {
|
|
4810
|
+
const canceledError = composedSignal.reason;
|
|
4811
|
+
canceledError.config = config;
|
|
4812
|
+
request && (canceledError.request = request);
|
|
4813
|
+
if (err !== canceledError) {
|
|
4814
|
+
// Non-enumerable to match native Error `cause` semantics so loggers
|
|
4815
|
+
// don't recurse into circular fetch internals (see #7205).
|
|
4816
|
+
Object.defineProperty(canceledError, 'cause', {
|
|
4817
|
+
__proto__: null,
|
|
4818
|
+
value: err,
|
|
4819
|
+
writable: true,
|
|
4820
|
+
enumerable: false,
|
|
4821
|
+
configurable: true,
|
|
4822
|
+
});
|
|
4823
|
+
}
|
|
4824
|
+
throw canceledError;
|
|
4825
|
+
}
|
|
4826
|
+
|
|
4827
|
+
// Surface a maxBodyLength violation we raised while the request body was
|
|
4828
|
+
// being streamed. Matching by identity (rather than reading
|
|
4829
|
+
// `err.cause.isAxiosError`) keeps the error deterministic across runtimes
|
|
4830
|
+
// and avoids both prototype-pollution reads and mis-attributing a foreign
|
|
4831
|
+
// AxiosError that merely happened to land in `err.cause`.
|
|
4832
|
+
if (pendingBodyError) {
|
|
4833
|
+
request && !pendingBodyError.request && (pendingBodyError.request = request);
|
|
4834
|
+
throw pendingBodyError;
|
|
4835
|
+
}
|
|
4836
|
+
|
|
4837
|
+
// Re-throw AxiosErrors we raised synchronously (data: URL / content-length
|
|
4838
|
+
// pre-checks, response size enforcement) without re-wrapping them.
|
|
4839
|
+
if (err instanceof AxiosError$1) {
|
|
4840
|
+
request && !err.request && (err.request = request);
|
|
4841
|
+
throw err;
|
|
4842
|
+
}
|
|
4843
|
+
|
|
3312
4844
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
err && err.response
|
|
3320
|
-
),
|
|
3321
|
-
{
|
|
3322
|
-
cause: err.cause || err,
|
|
3323
|
-
}
|
|
4845
|
+
const networkError = new AxiosError$1(
|
|
4846
|
+
'Network Error',
|
|
4847
|
+
AxiosError$1.ERR_NETWORK,
|
|
4848
|
+
config,
|
|
4849
|
+
request,
|
|
4850
|
+
err && err.response
|
|
3324
4851
|
);
|
|
4852
|
+
// Non-enumerable to match native Error `cause` semantics so loggers
|
|
4853
|
+
// don't recurse into circular fetch internals (see #7205).
|
|
4854
|
+
Object.defineProperty(networkError, 'cause', {
|
|
4855
|
+
__proto__: null,
|
|
4856
|
+
value: err.cause || err,
|
|
4857
|
+
writable: true,
|
|
4858
|
+
enumerable: false,
|
|
4859
|
+
configurable: true,
|
|
4860
|
+
});
|
|
4861
|
+
throw networkError;
|
|
3325
4862
|
}
|
|
3326
4863
|
|
|
3327
4864
|
throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
|
|
@@ -3377,11 +4914,13 @@ const knownAdapters = {
|
|
|
3377
4914
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3378
4915
|
if (fn) {
|
|
3379
4916
|
try {
|
|
3380
|
-
Object.
|
|
4917
|
+
// Null-proto descriptors so a polluted Object.prototype.get cannot turn
|
|
4918
|
+
// these data descriptors into accessor descriptors on the way in.
|
|
4919
|
+
Object.defineProperty(fn, 'name', { __proto__: null, value });
|
|
3381
4920
|
} catch (e) {
|
|
3382
4921
|
// eslint-disable-next-line no-empty
|
|
3383
4922
|
}
|
|
3384
|
-
Object.defineProperty(fn, 'adapterName', { value });
|
|
4923
|
+
Object.defineProperty(fn, 'adapterName', { __proto__: null, value });
|
|
3385
4924
|
}
|
|
3386
4925
|
});
|
|
3387
4926
|
|
|
@@ -3457,7 +4996,7 @@ function getAdapter$1(adapters, config) {
|
|
|
3457
4996
|
|
|
3458
4997
|
throw new AxiosError$1(
|
|
3459
4998
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
3460
|
-
|
|
4999
|
+
AxiosError$1.ERR_NOT_SUPPORT
|
|
3461
5000
|
);
|
|
3462
5001
|
}
|
|
3463
5002
|
|
|
@@ -3505,10 +5044,15 @@ function throwIfCancellationRequested(config) {
|
|
|
3505
5044
|
*
|
|
3506
5045
|
* @returns {Promise} The Promise to be fulfilled
|
|
3507
5046
|
*/
|
|
3508
|
-
function dispatchRequest(
|
|
5047
|
+
function dispatchRequest(_config) {
|
|
5048
|
+
// Interceptors may replace the merged config with an ordinary object. Flatten
|
|
5049
|
+
// it at the dispatch boundary so shared prototype members cannot become
|
|
5050
|
+
// request behavior, while preserving intentional template/class members.
|
|
5051
|
+
const config = utils$1.toSafeFlatObject(_config);
|
|
5052
|
+
|
|
3509
5053
|
throwIfCancellationRequested(config);
|
|
3510
5054
|
|
|
3511
|
-
config.headers = AxiosHeaders$1.from(config
|
|
5055
|
+
config.headers = AxiosHeaders$1.from(utils$1.getSafeProp(config, 'headers'));
|
|
3512
5056
|
|
|
3513
5057
|
// Transform request data
|
|
3514
5058
|
config.data = transformData.call(config, config.transformRequest);
|
|
@@ -3523,8 +5067,15 @@ function dispatchRequest(config) {
|
|
|
3523
5067
|
function onAdapterResolution(response) {
|
|
3524
5068
|
throwIfCancellationRequested(config);
|
|
3525
5069
|
|
|
3526
|
-
//
|
|
3527
|
-
|
|
5070
|
+
// Expose the current response on config so that transformResponse can
|
|
5071
|
+
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
5072
|
+
// We clean it up afterwards to avoid polluting the config object.
|
|
5073
|
+
config.response = response;
|
|
5074
|
+
try {
|
|
5075
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
5076
|
+
} finally {
|
|
5077
|
+
delete config.response;
|
|
5078
|
+
}
|
|
3528
5079
|
|
|
3529
5080
|
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3530
5081
|
|
|
@@ -3536,11 +5087,16 @@ function dispatchRequest(config) {
|
|
|
3536
5087
|
|
|
3537
5088
|
// Transform response data
|
|
3538
5089
|
if (reason && reason.response) {
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
5090
|
+
config.response = reason.response;
|
|
5091
|
+
try {
|
|
5092
|
+
reason.response.data = transformData.call(
|
|
5093
|
+
config,
|
|
5094
|
+
config.transformResponse,
|
|
5095
|
+
reason.response
|
|
5096
|
+
);
|
|
5097
|
+
} finally {
|
|
5098
|
+
delete config.response;
|
|
5099
|
+
}
|
|
3544
5100
|
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
3545
5101
|
}
|
|
3546
5102
|
}
|
|
@@ -3550,8 +5106,6 @@ function dispatchRequest(config) {
|
|
|
3550
5106
|
);
|
|
3551
5107
|
}
|
|
3552
5108
|
|
|
3553
|
-
const VERSION$1 = "1.13.6";
|
|
3554
|
-
|
|
3555
5109
|
const validators$1 = {};
|
|
3556
5110
|
|
|
3557
5111
|
// eslint-disable-next-line func-names
|
|
@@ -3628,14 +5182,16 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
3628
5182
|
*/
|
|
3629
5183
|
|
|
3630
5184
|
function assertOptions(options, schema, allowUnknown) {
|
|
3631
|
-
if (typeof options !== 'object') {
|
|
5185
|
+
if (typeof options !== 'object' || options === null) {
|
|
3632
5186
|
throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
3633
5187
|
}
|
|
3634
5188
|
const keys = Object.keys(options);
|
|
3635
5189
|
let i = keys.length;
|
|
3636
5190
|
while (i-- > 0) {
|
|
3637
5191
|
const opt = keys[i];
|
|
3638
|
-
|
|
5192
|
+
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
5193
|
+
// a non-function validator and cause a TypeError.
|
|
5194
|
+
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
3639
5195
|
if (validator) {
|
|
3640
5196
|
const value = options[opt];
|
|
3641
5197
|
const result = value === undefined || validator(value, opt, options);
|
|
@@ -3689,21 +5245,37 @@ let Axios$1 = class Axios {
|
|
|
3689
5245
|
return await this._request(configOrUrl, config);
|
|
3690
5246
|
} catch (err) {
|
|
3691
5247
|
if (err instanceof Error) {
|
|
3692
|
-
|
|
5248
|
+
try {
|
|
5249
|
+
let dummy = {};
|
|
3693
5250
|
|
|
3694
|
-
|
|
5251
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
5252
|
+
|
|
5253
|
+
const dummyStack = dummy.stack;
|
|
5254
|
+
let stack = '';
|
|
5255
|
+
|
|
5256
|
+
// slice off the Error: ... line
|
|
5257
|
+
if (typeof dummyStack === 'string') {
|
|
5258
|
+
const firstNewlineIndex = dummyStack.indexOf('\n');
|
|
5259
|
+
|
|
5260
|
+
stack = firstNewlineIndex === -1 ? '' : dummyStack.slice(firstNewlineIndex + 1);
|
|
5261
|
+
}
|
|
3695
5262
|
|
|
3696
|
-
// slice off the Error: ... line
|
|
3697
|
-
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
|
3698
|
-
try {
|
|
3699
5263
|
if (!err.stack) {
|
|
3700
5264
|
err.stack = stack;
|
|
3701
5265
|
// match without the 2 top stack lines
|
|
3702
|
-
} else if (stack
|
|
3703
|
-
|
|
5266
|
+
} else if (stack) {
|
|
5267
|
+
const firstNewlineIndex = stack.indexOf('\n');
|
|
5268
|
+
const secondNewlineIndex =
|
|
5269
|
+
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
5270
|
+
const stackWithoutTwoTopLines =
|
|
5271
|
+
secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|
5272
|
+
|
|
5273
|
+
if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
|
|
5274
|
+
err.stack += '\n' + stack;
|
|
5275
|
+
}
|
|
3704
5276
|
}
|
|
3705
5277
|
} catch (e) {
|
|
3706
|
-
//
|
|
5278
|
+
// Ignore failures from custom stack hooks or un-writable stack properties.
|
|
3707
5279
|
}
|
|
3708
5280
|
}
|
|
3709
5281
|
|
|
@@ -3733,6 +5305,8 @@ let Axios$1 = class Axios {
|
|
|
3733
5305
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
3734
5306
|
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
3735
5307
|
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
5308
|
+
advertiseZstdAcceptEncoding: validators.transitional(validators.boolean),
|
|
5309
|
+
validateStatusUndefinedResolves: validators.transitional(validators.boolean),
|
|
3736
5310
|
},
|
|
3737
5311
|
false
|
|
3738
5312
|
);
|
|
@@ -3772,13 +5346,17 @@ let Axios$1 = class Axios {
|
|
|
3772
5346
|
);
|
|
3773
5347
|
|
|
3774
5348
|
// Set config.method
|
|
3775
|
-
config.method = (
|
|
5349
|
+
config.method = (
|
|
5350
|
+
utils$1.getSafeProp(config, 'method') ||
|
|
5351
|
+
utils$1.getSafeProp(this.defaults, 'method') ||
|
|
5352
|
+
'get'
|
|
5353
|
+
).toLowerCase();
|
|
3776
5354
|
|
|
3777
5355
|
// Flatten headers
|
|
3778
5356
|
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
3779
5357
|
|
|
3780
5358
|
headers &&
|
|
3781
|
-
utils$1.forEach(
|
|
5359
|
+
utils$1.forEach(methodList.concat('common'), (method) => {
|
|
3782
5360
|
delete headers[method];
|
|
3783
5361
|
});
|
|
3784
5362
|
|
|
@@ -3837,17 +5415,35 @@ let Axios$1 = class Axios {
|
|
|
3837
5415
|
const onFulfilled = requestInterceptorChain[i++];
|
|
3838
5416
|
const onRejected = requestInterceptorChain[i++];
|
|
3839
5417
|
try {
|
|
3840
|
-
newConfig = onFulfilled(newConfig);
|
|
5418
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
3841
5419
|
} catch (error) {
|
|
3842
|
-
onRejected
|
|
5420
|
+
if (!onRejected) {
|
|
5421
|
+
promise = Promise.reject(error);
|
|
5422
|
+
break;
|
|
5423
|
+
}
|
|
5424
|
+
|
|
5425
|
+
try {
|
|
5426
|
+
const rejectedResult = onRejected.call(this, error);
|
|
5427
|
+
|
|
5428
|
+
if (utils$1.isThenable(rejectedResult)) {
|
|
5429
|
+
promise = Promise.resolve(rejectedResult).then(() =>
|
|
5430
|
+
dispatchRequest.call(this, newConfig)
|
|
5431
|
+
);
|
|
5432
|
+
}
|
|
5433
|
+
} catch (rejectedError) {
|
|
5434
|
+
promise = Promise.reject(rejectedError);
|
|
5435
|
+
}
|
|
5436
|
+
|
|
3843
5437
|
break;
|
|
3844
5438
|
}
|
|
3845
5439
|
}
|
|
3846
5440
|
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
5441
|
+
if (!promise) {
|
|
5442
|
+
try {
|
|
5443
|
+
promise = dispatchRequest.call(this, newConfig);
|
|
5444
|
+
} catch (error) {
|
|
5445
|
+
promise = Promise.reject(error);
|
|
5446
|
+
}
|
|
3851
5447
|
}
|
|
3852
5448
|
|
|
3853
5449
|
i = 0;
|
|
@@ -3862,7 +5458,7 @@ let Axios$1 = class Axios {
|
|
|
3862
5458
|
|
|
3863
5459
|
getUri(config) {
|
|
3864
5460
|
config = mergeConfig$1(this.defaults, config);
|
|
3865
|
-
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
5461
|
+
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
|
|
3866
5462
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
3867
5463
|
}
|
|
3868
5464
|
};
|
|
@@ -3875,15 +5471,13 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
3875
5471
|
mergeConfig$1(config || {}, {
|
|
3876
5472
|
method,
|
|
3877
5473
|
url,
|
|
3878
|
-
data: (config
|
|
5474
|
+
data: config && utils$1.hasOwnProp(config, 'data') ? config.data : undefined,
|
|
3879
5475
|
})
|
|
3880
5476
|
);
|
|
3881
5477
|
};
|
|
3882
5478
|
});
|
|
3883
5479
|
|
|
3884
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3885
|
-
/*eslint func-names:0*/
|
|
3886
|
-
|
|
5480
|
+
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
3887
5481
|
function generateHTTPMethod(isForm) {
|
|
3888
5482
|
return function httpMethod(url, data, config) {
|
|
3889
5483
|
return this.request(
|
|
@@ -3903,7 +5497,11 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
|
|
|
3903
5497
|
|
|
3904
5498
|
Axios$1.prototype[method] = generateHTTPMethod();
|
|
3905
5499
|
|
|
3906
|
-
|
|
5500
|
+
// QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|
5501
|
+
// its semantics, so no queryForm shorthand is generated.
|
|
5502
|
+
if (method !== 'query') {
|
|
5503
|
+
Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
5504
|
+
}
|
|
3907
5505
|
});
|
|
3908
5506
|
|
|
3909
5507
|
/**
|
|
@@ -4111,14 +5709,22 @@ const HttpStatusCode$1 = {
|
|
|
4111
5709
|
Gone: 410,
|
|
4112
5710
|
LengthRequired: 411,
|
|
4113
5711
|
PreconditionFailed: 412,
|
|
5712
|
+
/**
|
|
5713
|
+
* @deprecated Use `ContentTooLarge` instead.
|
|
5714
|
+
*/
|
|
4114
5715
|
PayloadTooLarge: 413,
|
|
5716
|
+
ContentTooLarge: 413,
|
|
4115
5717
|
UriTooLong: 414,
|
|
4116
5718
|
UnsupportedMediaType: 415,
|
|
4117
5719
|
RangeNotSatisfiable: 416,
|
|
4118
5720
|
ExpectationFailed: 417,
|
|
4119
5721
|
ImATeapot: 418,
|
|
4120
5722
|
MisdirectedRequest: 421,
|
|
5723
|
+
/**
|
|
5724
|
+
* @deprecated Use `UnprocessableContent` instead.
|
|
5725
|
+
*/
|
|
4121
5726
|
UnprocessableEntity: 422,
|
|
5727
|
+
UnprocessableContent: 422,
|
|
4122
5728
|
Locked: 423,
|
|
4123
5729
|
FailedDependency: 424,
|
|
4124
5730
|
TooEarly: 425,
|
|
@@ -4138,6 +5744,7 @@ const HttpStatusCode$1 = {
|
|
|
4138
5744
|
LoopDetected: 508,
|
|
4139
5745
|
NotExtended: 510,
|
|
4140
5746
|
NetworkAuthenticationRequired: 511,
|
|
5747
|
+
WebServerReturnsAnUnknownError: 520,
|
|
4141
5748
|
WebServerIsDown: 521,
|
|
4142
5749
|
ConnectionTimedOut: 522,
|
|
4143
5750
|
OriginIsUnreachable: 523,
|
|
@@ -4147,7 +5754,9 @@ const HttpStatusCode$1 = {
|
|
|
4147
5754
|
};
|
|
4148
5755
|
|
|
4149
5756
|
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
|
4150
|
-
HttpStatusCode$1[value]
|
|
5757
|
+
if (HttpStatusCode$1[value] === undefined) {
|
|
5758
|
+
HttpStatusCode$1[value] = key;
|
|
5759
|
+
}
|
|
4151
5760
|
});
|
|
4152
5761
|
|
|
4153
5762
|
/**
|
|
@@ -4237,6 +5846,7 @@ const {
|
|
|
4237
5846
|
formToJSON,
|
|
4238
5847
|
getAdapter,
|
|
4239
5848
|
mergeConfig,
|
|
5849
|
+
create,
|
|
4240
5850
|
} = axios$1;
|
|
4241
5851
|
|
|
4242
5852
|
let accessToken = null;
|