@xchainjs/xchain-dash 2.0.9 → 2.0.10
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/lib/index.esm.js +462 -329
- package/lib/index.js +462 -329
- package/package.json +5 -5
package/lib/index.esm.js
CHANGED
|
@@ -122,6 +122,13 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
122
122
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Create a bound version of a function with a specified `this` context
|
|
127
|
+
*
|
|
128
|
+
* @param {Function} fn - The function to bind
|
|
129
|
+
* @param {*} thisArg - The value to be passed as the `this` parameter
|
|
130
|
+
* @returns {Function} A new function that will call the original function with the specified `this` context
|
|
131
|
+
*/
|
|
125
132
|
function bind(fn, thisArg) {
|
|
126
133
|
return function wrap() {
|
|
127
134
|
return fn.apply(thisArg, arguments);
|
|
@@ -130,30 +137,30 @@ function bind(fn, thisArg) {
|
|
|
130
137
|
|
|
131
138
|
// utils is a library of generic helper functions non-specific to axios
|
|
132
139
|
|
|
133
|
-
const {toString} = Object.prototype;
|
|
134
|
-
const {getPrototypeOf} = Object;
|
|
135
|
-
const {iterator, toStringTag} = Symbol;
|
|
140
|
+
const { toString } = Object.prototype;
|
|
141
|
+
const { getPrototypeOf } = Object;
|
|
142
|
+
const { iterator, toStringTag } = Symbol;
|
|
136
143
|
|
|
137
|
-
const kindOf = (cache => thing => {
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
const kindOf = ((cache) => (thing) => {
|
|
145
|
+
const str = toString.call(thing);
|
|
146
|
+
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
140
147
|
})(Object.create(null));
|
|
141
148
|
|
|
142
149
|
const kindOfTest = (type) => {
|
|
143
150
|
type = type.toLowerCase();
|
|
144
|
-
return (thing) => kindOf(thing) === type
|
|
151
|
+
return (thing) => kindOf(thing) === type;
|
|
145
152
|
};
|
|
146
153
|
|
|
147
|
-
const typeOfTest = type => thing => typeof thing === type;
|
|
154
|
+
const typeOfTest = (type) => (thing) => typeof thing === type;
|
|
148
155
|
|
|
149
156
|
/**
|
|
150
|
-
* Determine if a value is
|
|
157
|
+
* Determine if a value is a non-null object
|
|
151
158
|
*
|
|
152
159
|
* @param {Object} val The value to test
|
|
153
160
|
*
|
|
154
161
|
* @returns {boolean} True if value is an Array, otherwise false
|
|
155
162
|
*/
|
|
156
|
-
const {isArray} = Array;
|
|
163
|
+
const { isArray } = Array;
|
|
157
164
|
|
|
158
165
|
/**
|
|
159
166
|
* Determine if a value is undefined
|
|
@@ -162,7 +169,7 @@ const {isArray} = Array;
|
|
|
162
169
|
*
|
|
163
170
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
164
171
|
*/
|
|
165
|
-
const isUndefined = typeOfTest(
|
|
172
|
+
const isUndefined = typeOfTest("undefined");
|
|
166
173
|
|
|
167
174
|
/**
|
|
168
175
|
* Determine if a value is a Buffer
|
|
@@ -172,8 +179,14 @@ const isUndefined = typeOfTest('undefined');
|
|
|
172
179
|
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
173
180
|
*/
|
|
174
181
|
function isBuffer(val) {
|
|
175
|
-
return
|
|
176
|
-
|
|
182
|
+
return (
|
|
183
|
+
val !== null &&
|
|
184
|
+
!isUndefined(val) &&
|
|
185
|
+
val.constructor !== null &&
|
|
186
|
+
!isUndefined(val.constructor) &&
|
|
187
|
+
isFunction$1(val.constructor.isBuffer) &&
|
|
188
|
+
val.constructor.isBuffer(val)
|
|
189
|
+
);
|
|
177
190
|
}
|
|
178
191
|
|
|
179
192
|
/**
|
|
@@ -183,8 +196,7 @@ function isBuffer(val) {
|
|
|
183
196
|
*
|
|
184
197
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
185
198
|
*/
|
|
186
|
-
const isArrayBuffer = kindOfTest(
|
|
187
|
-
|
|
199
|
+
const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
188
200
|
|
|
189
201
|
/**
|
|
190
202
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -195,10 +207,10 @@ const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
|
195
207
|
*/
|
|
196
208
|
function isArrayBufferView(val) {
|
|
197
209
|
let result;
|
|
198
|
-
if (
|
|
210
|
+
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
199
211
|
result = ArrayBuffer.isView(val);
|
|
200
212
|
} else {
|
|
201
|
-
result =
|
|
213
|
+
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
202
214
|
}
|
|
203
215
|
return result;
|
|
204
216
|
}
|
|
@@ -210,7 +222,7 @@ function isArrayBufferView(val) {
|
|
|
210
222
|
*
|
|
211
223
|
* @returns {boolean} True if value is a String, otherwise false
|
|
212
224
|
*/
|
|
213
|
-
const isString = typeOfTest(
|
|
225
|
+
const isString = typeOfTest("string");
|
|
214
226
|
|
|
215
227
|
/**
|
|
216
228
|
* Determine if a value is a Function
|
|
@@ -218,7 +230,7 @@ const isString = typeOfTest('string');
|
|
|
218
230
|
* @param {*} val The value to test
|
|
219
231
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
220
232
|
*/
|
|
221
|
-
const isFunction$1 = typeOfTest(
|
|
233
|
+
const isFunction$1 = typeOfTest("function");
|
|
222
234
|
|
|
223
235
|
/**
|
|
224
236
|
* Determine if a value is a Number
|
|
@@ -227,7 +239,7 @@ const isFunction$1 = typeOfTest('function');
|
|
|
227
239
|
*
|
|
228
240
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
229
241
|
*/
|
|
230
|
-
const isNumber = typeOfTest(
|
|
242
|
+
const isNumber = typeOfTest("number");
|
|
231
243
|
|
|
232
244
|
/**
|
|
233
245
|
* Determine if a value is an Object
|
|
@@ -236,7 +248,7 @@ const isNumber = typeOfTest('number');
|
|
|
236
248
|
*
|
|
237
249
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
238
250
|
*/
|
|
239
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
251
|
+
const isObject = (thing) => thing !== null && typeof thing === "object";
|
|
240
252
|
|
|
241
253
|
/**
|
|
242
254
|
* Determine if a value is a Boolean
|
|
@@ -244,7 +256,7 @@ const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
|
244
256
|
* @param {*} thing The value to test
|
|
245
257
|
* @returns {boolean} True if value is a Boolean, otherwise false
|
|
246
258
|
*/
|
|
247
|
-
const isBoolean = thing => thing === true || thing === false;
|
|
259
|
+
const isBoolean = (thing) => thing === true || thing === false;
|
|
248
260
|
|
|
249
261
|
/**
|
|
250
262
|
* Determine if a value is a plain Object
|
|
@@ -254,12 +266,18 @@ const isBoolean = thing => thing === true || thing === false;
|
|
|
254
266
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
255
267
|
*/
|
|
256
268
|
const isPlainObject = (val) => {
|
|
257
|
-
if (kindOf(val) !==
|
|
269
|
+
if (kindOf(val) !== "object") {
|
|
258
270
|
return false;
|
|
259
271
|
}
|
|
260
272
|
|
|
261
273
|
const prototype = getPrototypeOf(val);
|
|
262
|
-
return (
|
|
274
|
+
return (
|
|
275
|
+
(prototype === null ||
|
|
276
|
+
prototype === Object.prototype ||
|
|
277
|
+
Object.getPrototypeOf(prototype) === null) &&
|
|
278
|
+
!(toStringTag in val) &&
|
|
279
|
+
!(iterator in val)
|
|
280
|
+
);
|
|
263
281
|
};
|
|
264
282
|
|
|
265
283
|
/**
|
|
@@ -276,7 +294,10 @@ const isEmptyObject = (val) => {
|
|
|
276
294
|
}
|
|
277
295
|
|
|
278
296
|
try {
|
|
279
|
-
return
|
|
297
|
+
return (
|
|
298
|
+
Object.keys(val).length === 0 &&
|
|
299
|
+
Object.getPrototypeOf(val) === Object.prototype
|
|
300
|
+
);
|
|
280
301
|
} catch (e) {
|
|
281
302
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
282
303
|
return false;
|
|
@@ -290,7 +311,7 @@ const isEmptyObject = (val) => {
|
|
|
290
311
|
*
|
|
291
312
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
292
313
|
*/
|
|
293
|
-
const isDate = kindOfTest(
|
|
314
|
+
const isDate = kindOfTest("Date");
|
|
294
315
|
|
|
295
316
|
/**
|
|
296
317
|
* Determine if a value is a File
|
|
@@ -299,7 +320,7 @@ const isDate = kindOfTest('Date');
|
|
|
299
320
|
*
|
|
300
321
|
* @returns {boolean} True if value is a File, otherwise false
|
|
301
322
|
*/
|
|
302
|
-
const isFile = kindOfTest(
|
|
323
|
+
const isFile = kindOfTest("File");
|
|
303
324
|
|
|
304
325
|
/**
|
|
305
326
|
* Determine if a value is a Blob
|
|
@@ -308,7 +329,7 @@ const isFile = kindOfTest('File');
|
|
|
308
329
|
*
|
|
309
330
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
310
331
|
*/
|
|
311
|
-
const isBlob = kindOfTest(
|
|
332
|
+
const isBlob = kindOfTest("Blob");
|
|
312
333
|
|
|
313
334
|
/**
|
|
314
335
|
* Determine if a value is a FileList
|
|
@@ -317,7 +338,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
317
338
|
*
|
|
318
339
|
* @returns {boolean} True if value is a File, otherwise false
|
|
319
340
|
*/
|
|
320
|
-
const isFileList = kindOfTest(
|
|
341
|
+
const isFileList = kindOfTest("FileList");
|
|
321
342
|
|
|
322
343
|
/**
|
|
323
344
|
* Determine if a value is a Stream
|
|
@@ -337,15 +358,16 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
|
337
358
|
*/
|
|
338
359
|
const isFormData = (thing) => {
|
|
339
360
|
let kind;
|
|
340
|
-
return
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
361
|
+
return (
|
|
362
|
+
thing &&
|
|
363
|
+
((typeof FormData === "function" && thing instanceof FormData) ||
|
|
364
|
+
(isFunction$1(thing.append) &&
|
|
365
|
+
((kind = kindOf(thing)) === "formdata" ||
|
|
366
|
+
// detect form-data instance
|
|
367
|
+
(kind === "object" &&
|
|
368
|
+
isFunction$1(thing.toString) &&
|
|
369
|
+
thing.toString() === "[object FormData]"))))
|
|
370
|
+
);
|
|
349
371
|
};
|
|
350
372
|
|
|
351
373
|
/**
|
|
@@ -355,9 +377,14 @@ const isFormData = (thing) => {
|
|
|
355
377
|
*
|
|
356
378
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
357
379
|
*/
|
|
358
|
-
const isURLSearchParams = kindOfTest(
|
|
380
|
+
const isURLSearchParams = kindOfTest("URLSearchParams");
|
|
359
381
|
|
|
360
|
-
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
382
|
+
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
383
|
+
"ReadableStream",
|
|
384
|
+
"Request",
|
|
385
|
+
"Response",
|
|
386
|
+
"Headers",
|
|
387
|
+
].map(kindOfTest);
|
|
361
388
|
|
|
362
389
|
/**
|
|
363
390
|
* Trim excess whitespace off the beginning and end of a string
|
|
@@ -366,8 +393,8 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream',
|
|
|
366
393
|
*
|
|
367
394
|
* @returns {String} The String freed of excess whitespace
|
|
368
395
|
*/
|
|
369
|
-
const trim = (str) =>
|
|
370
|
-
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
396
|
+
const trim = (str) =>
|
|
397
|
+
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
371
398
|
|
|
372
399
|
/**
|
|
373
400
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
@@ -378,15 +405,16 @@ const trim = (str) => str.trim ?
|
|
|
378
405
|
* If 'obj' is an Object callback will be called passing
|
|
379
406
|
* the value, key, and complete object for each property.
|
|
380
407
|
*
|
|
381
|
-
* @param {Object|Array} obj The object to iterate
|
|
408
|
+
* @param {Object|Array<unknown>} obj The object to iterate
|
|
382
409
|
* @param {Function} fn The callback to invoke for each item
|
|
383
410
|
*
|
|
384
|
-
* @param {
|
|
411
|
+
* @param {Object} [options]
|
|
412
|
+
* @param {Boolean} [options.allOwnKeys = false]
|
|
385
413
|
* @returns {any}
|
|
386
414
|
*/
|
|
387
|
-
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
415
|
+
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
388
416
|
// Don't bother if no value provided
|
|
389
|
-
if (obj === null || typeof obj ===
|
|
417
|
+
if (obj === null || typeof obj === "undefined") {
|
|
390
418
|
return;
|
|
391
419
|
}
|
|
392
420
|
|
|
@@ -394,7 +422,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
394
422
|
let l;
|
|
395
423
|
|
|
396
424
|
// Force an array if not already something iterable
|
|
397
|
-
if (typeof obj !==
|
|
425
|
+
if (typeof obj !== "object") {
|
|
398
426
|
/*eslint no-param-reassign:0*/
|
|
399
427
|
obj = [obj];
|
|
400
428
|
}
|
|
@@ -411,7 +439,9 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
411
439
|
}
|
|
412
440
|
|
|
413
441
|
// Iterate over object keys
|
|
414
|
-
const keys = allOwnKeys
|
|
442
|
+
const keys = allOwnKeys
|
|
443
|
+
? Object.getOwnPropertyNames(obj)
|
|
444
|
+
: Object.keys(obj);
|
|
415
445
|
const len = keys.length;
|
|
416
446
|
let key;
|
|
417
447
|
|
|
@@ -423,7 +453,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
423
453
|
}
|
|
424
454
|
|
|
425
455
|
function findKey(obj, key) {
|
|
426
|
-
if (isBuffer(obj)){
|
|
456
|
+
if (isBuffer(obj)) {
|
|
427
457
|
return null;
|
|
428
458
|
}
|
|
429
459
|
|
|
@@ -443,10 +473,15 @@ function findKey(obj, key) {
|
|
|
443
473
|
const _global = (() => {
|
|
444
474
|
/*eslint no-undef:0*/
|
|
445
475
|
if (typeof globalThis !== "undefined") return globalThis;
|
|
446
|
-
return typeof self !== "undefined"
|
|
476
|
+
return typeof self !== "undefined"
|
|
477
|
+
? self
|
|
478
|
+
: typeof window !== "undefined"
|
|
479
|
+
? window
|
|
480
|
+
: global;
|
|
447
481
|
})();
|
|
448
482
|
|
|
449
|
-
const isContextDefined = (context) =>
|
|
483
|
+
const isContextDefined = (context) =>
|
|
484
|
+
!isUndefined(context) && context !== _global;
|
|
450
485
|
|
|
451
486
|
/**
|
|
452
487
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -458,7 +493,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
458
493
|
* Example:
|
|
459
494
|
*
|
|
460
495
|
* ```js
|
|
461
|
-
*
|
|
496
|
+
* const result = merge({foo: 123}, {foo: 456});
|
|
462
497
|
* console.log(result.foo); // outputs 456
|
|
463
498
|
* ```
|
|
464
499
|
*
|
|
@@ -467,20 +502,23 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
467
502
|
* @returns {Object} Result of all merge properties
|
|
468
503
|
*/
|
|
469
504
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
470
|
-
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
505
|
+
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
471
506
|
const result = {};
|
|
472
507
|
const assignValue = (val, key) => {
|
|
473
|
-
|
|
508
|
+
// Skip dangerous property names to prevent prototype pollution
|
|
509
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const targetKey = (caseless && findKey(result, key)) || key;
|
|
474
514
|
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
|
475
515
|
result[targetKey] = merge(result[targetKey], val);
|
|
476
516
|
} else if (isPlainObject(val)) {
|
|
477
517
|
result[targetKey] = merge({}, val);
|
|
478
518
|
} else if (isArray(val)) {
|
|
479
519
|
result[targetKey] = val.slice();
|
|
480
|
-
} else {
|
|
481
|
-
|
|
482
|
-
result[targetKey] = val;
|
|
483
|
-
}
|
|
520
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
521
|
+
result[targetKey] = val;
|
|
484
522
|
}
|
|
485
523
|
};
|
|
486
524
|
|
|
@@ -497,17 +535,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
497
535
|
* @param {Object} b The object to copy properties from
|
|
498
536
|
* @param {Object} thisArg The object to bind function to
|
|
499
537
|
*
|
|
500
|
-
* @param {
|
|
538
|
+
* @param {Object} [options]
|
|
539
|
+
* @param {Boolean} [options.allOwnKeys]
|
|
501
540
|
* @returns {Object} The resulting value of object a
|
|
502
541
|
*/
|
|
503
|
-
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
504
|
-
forEach(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
542
|
+
const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
543
|
+
forEach(
|
|
544
|
+
b,
|
|
545
|
+
(val, key) => {
|
|
546
|
+
if (thisArg && isFunction$1(val)) {
|
|
547
|
+
Object.defineProperty(a, key, {
|
|
548
|
+
value: bind(val, thisArg),
|
|
549
|
+
writable: true,
|
|
550
|
+
enumerable: true,
|
|
551
|
+
configurable: true,
|
|
552
|
+
});
|
|
553
|
+
} else {
|
|
554
|
+
Object.defineProperty(a, key, {
|
|
555
|
+
value: val,
|
|
556
|
+
writable: true,
|
|
557
|
+
enumerable: true,
|
|
558
|
+
configurable: true,
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
{ allOwnKeys },
|
|
563
|
+
);
|
|
511
564
|
return a;
|
|
512
565
|
};
|
|
513
566
|
|
|
@@ -519,7 +572,7 @@ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
|
519
572
|
* @returns {string} content value without BOM
|
|
520
573
|
*/
|
|
521
574
|
const stripBOM = (content) => {
|
|
522
|
-
if (content.charCodeAt(0) ===
|
|
575
|
+
if (content.charCodeAt(0) === 0xfeff) {
|
|
523
576
|
content = content.slice(1);
|
|
524
577
|
}
|
|
525
578
|
return content;
|
|
@@ -535,10 +588,18 @@ const stripBOM = (content) => {
|
|
|
535
588
|
* @returns {void}
|
|
536
589
|
*/
|
|
537
590
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
538
|
-
constructor.prototype = Object.create(
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
591
|
+
constructor.prototype = Object.create(
|
|
592
|
+
superConstructor.prototype,
|
|
593
|
+
descriptors,
|
|
594
|
+
);
|
|
595
|
+
Object.defineProperty(constructor.prototype, "constructor", {
|
|
596
|
+
value: constructor,
|
|
597
|
+
writable: true,
|
|
598
|
+
enumerable: false,
|
|
599
|
+
configurable: true,
|
|
600
|
+
});
|
|
601
|
+
Object.defineProperty(constructor, "super", {
|
|
602
|
+
value: superConstructor.prototype,
|
|
542
603
|
});
|
|
543
604
|
props && Object.assign(constructor.prototype, props);
|
|
544
605
|
};
|
|
@@ -567,13 +628,20 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
|
567
628
|
i = props.length;
|
|
568
629
|
while (i-- > 0) {
|
|
569
630
|
prop = props[i];
|
|
570
|
-
if (
|
|
631
|
+
if (
|
|
632
|
+
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
633
|
+
!merged[prop]
|
|
634
|
+
) {
|
|
571
635
|
destObj[prop] = sourceObj[prop];
|
|
572
636
|
merged[prop] = true;
|
|
573
637
|
}
|
|
574
638
|
}
|
|
575
639
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
576
|
-
} while (
|
|
640
|
+
} while (
|
|
641
|
+
sourceObj &&
|
|
642
|
+
(!filter || filter(sourceObj, destObj)) &&
|
|
643
|
+
sourceObj !== Object.prototype
|
|
644
|
+
);
|
|
577
645
|
|
|
578
646
|
return destObj;
|
|
579
647
|
};
|
|
@@ -597,7 +665,6 @@ const endsWith = (str, searchString, position) => {
|
|
|
597
665
|
return lastIndex !== -1 && lastIndex === position;
|
|
598
666
|
};
|
|
599
667
|
|
|
600
|
-
|
|
601
668
|
/**
|
|
602
669
|
* Returns new array from array like object or null if failed
|
|
603
670
|
*
|
|
@@ -626,12 +693,12 @@ const toArray = (thing) => {
|
|
|
626
693
|
* @returns {Array}
|
|
627
694
|
*/
|
|
628
695
|
// eslint-disable-next-line func-names
|
|
629
|
-
const isTypedArray = (TypedArray => {
|
|
696
|
+
const isTypedArray = ((TypedArray) => {
|
|
630
697
|
// eslint-disable-next-line func-names
|
|
631
|
-
return thing => {
|
|
698
|
+
return (thing) => {
|
|
632
699
|
return TypedArray && thing instanceof TypedArray;
|
|
633
700
|
};
|
|
634
|
-
})(typeof Uint8Array !==
|
|
701
|
+
})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
|
|
635
702
|
|
|
636
703
|
/**
|
|
637
704
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -674,18 +741,22 @@ const matchAll = (regExp, str) => {
|
|
|
674
741
|
};
|
|
675
742
|
|
|
676
743
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
677
|
-
const isHTMLForm = kindOfTest(
|
|
744
|
+
const isHTMLForm = kindOfTest("HTMLFormElement");
|
|
678
745
|
|
|
679
|
-
const toCamelCase = str => {
|
|
680
|
-
return str
|
|
681
|
-
|
|
746
|
+
const toCamelCase = (str) => {
|
|
747
|
+
return str
|
|
748
|
+
.toLowerCase()
|
|
749
|
+
.replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
682
750
|
return p1.toUpperCase() + p2;
|
|
683
|
-
}
|
|
684
|
-
);
|
|
751
|
+
});
|
|
685
752
|
};
|
|
686
753
|
|
|
687
754
|
/* Creating a function that will check if an object has a property. */
|
|
688
|
-
const hasOwnProperty = (
|
|
755
|
+
const hasOwnProperty = (
|
|
756
|
+
({ hasOwnProperty }) =>
|
|
757
|
+
(obj, prop) =>
|
|
758
|
+
hasOwnProperty.call(obj, prop)
|
|
759
|
+
)(Object.prototype);
|
|
689
760
|
|
|
690
761
|
/**
|
|
691
762
|
* Determine if a value is a RegExp object
|
|
@@ -694,7 +765,7 @@ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call
|
|
|
694
765
|
*
|
|
695
766
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
696
767
|
*/
|
|
697
|
-
const isRegExp = kindOfTest(
|
|
768
|
+
const isRegExp = kindOfTest("RegExp");
|
|
698
769
|
|
|
699
770
|
const reduceDescriptors = (obj, reducer) => {
|
|
700
771
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -718,7 +789,10 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
718
789
|
const freezeMethods = (obj) => {
|
|
719
790
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
720
791
|
// skip restricted props in strict mode
|
|
721
|
-
if (
|
|
792
|
+
if (
|
|
793
|
+
isFunction$1(obj) &&
|
|
794
|
+
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
795
|
+
) {
|
|
722
796
|
return false;
|
|
723
797
|
}
|
|
724
798
|
|
|
@@ -728,14 +802,14 @@ const freezeMethods = (obj) => {
|
|
|
728
802
|
|
|
729
803
|
descriptor.enumerable = false;
|
|
730
804
|
|
|
731
|
-
if (
|
|
805
|
+
if ("writable" in descriptor) {
|
|
732
806
|
descriptor.writable = false;
|
|
733
807
|
return;
|
|
734
808
|
}
|
|
735
809
|
|
|
736
810
|
if (!descriptor.set) {
|
|
737
811
|
descriptor.set = () => {
|
|
738
|
-
throw Error(
|
|
812
|
+
throw Error("Can not rewrite read-only method '" + name + "'");
|
|
739
813
|
};
|
|
740
814
|
}
|
|
741
815
|
});
|
|
@@ -745,12 +819,14 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
745
819
|
const obj = {};
|
|
746
820
|
|
|
747
821
|
const define = (arr) => {
|
|
748
|
-
arr.forEach(value => {
|
|
822
|
+
arr.forEach((value) => {
|
|
749
823
|
obj[value] = true;
|
|
750
824
|
});
|
|
751
825
|
};
|
|
752
826
|
|
|
753
|
-
isArray(arrayOrString)
|
|
827
|
+
isArray(arrayOrString)
|
|
828
|
+
? define(arrayOrString)
|
|
829
|
+
: define(String(arrayOrString).split(delimiter));
|
|
754
830
|
|
|
755
831
|
return obj;
|
|
756
832
|
};
|
|
@@ -758,11 +834,11 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
758
834
|
const noop = () => {};
|
|
759
835
|
|
|
760
836
|
const toFiniteNumber = (value, defaultValue) => {
|
|
761
|
-
return value != null && Number.isFinite(value = +value)
|
|
837
|
+
return value != null && Number.isFinite((value = +value))
|
|
838
|
+
? value
|
|
839
|
+
: defaultValue;
|
|
762
840
|
};
|
|
763
841
|
|
|
764
|
-
|
|
765
|
-
|
|
766
842
|
/**
|
|
767
843
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
768
844
|
*
|
|
@@ -771,14 +847,18 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
771
847
|
* @returns {boolean}
|
|
772
848
|
*/
|
|
773
849
|
function isSpecCompliantForm(thing) {
|
|
774
|
-
return !!(
|
|
850
|
+
return !!(
|
|
851
|
+
thing &&
|
|
852
|
+
isFunction$1(thing.append) &&
|
|
853
|
+
thing[toStringTag] === "FormData" &&
|
|
854
|
+
thing[iterator]
|
|
855
|
+
);
|
|
775
856
|
}
|
|
776
857
|
|
|
777
858
|
const toJSONObject = (obj) => {
|
|
778
859
|
const stack = new Array(10);
|
|
779
860
|
|
|
780
861
|
const visit = (source, i) => {
|
|
781
|
-
|
|
782
862
|
if (isObject(source)) {
|
|
783
863
|
if (stack.indexOf(source) >= 0) {
|
|
784
864
|
return;
|
|
@@ -789,7 +869,7 @@ const toJSONObject = (obj) => {
|
|
|
789
869
|
return source;
|
|
790
870
|
}
|
|
791
871
|
|
|
792
|
-
if(!(
|
|
872
|
+
if (!("toJSON" in source)) {
|
|
793
873
|
stack[i] = source;
|
|
794
874
|
const target = isArray(source) ? [] : {};
|
|
795
875
|
|
|
@@ -810,10 +890,13 @@ const toJSONObject = (obj) => {
|
|
|
810
890
|
return visit(obj, 0);
|
|
811
891
|
};
|
|
812
892
|
|
|
813
|
-
const isAsyncFn = kindOfTest(
|
|
893
|
+
const isAsyncFn = kindOfTest("AsyncFunction");
|
|
814
894
|
|
|
815
895
|
const isThenable = (thing) =>
|
|
816
|
-
thing &&
|
|
896
|
+
thing &&
|
|
897
|
+
(isObject(thing) || isFunction$1(thing)) &&
|
|
898
|
+
isFunction$1(thing.then) &&
|
|
899
|
+
isFunction$1(thing.catch);
|
|
817
900
|
|
|
818
901
|
// original code
|
|
819
902
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -823,32 +906,35 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
823
906
|
return setImmediate;
|
|
824
907
|
}
|
|
825
908
|
|
|
826
|
-
return postMessageSupported
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
909
|
+
return postMessageSupported
|
|
910
|
+
? ((token, callbacks) => {
|
|
911
|
+
_global.addEventListener(
|
|
912
|
+
"message",
|
|
913
|
+
({ source, data }) => {
|
|
914
|
+
if (source === _global && data === token) {
|
|
915
|
+
callbacks.length && callbacks.shift()();
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
false,
|
|
919
|
+
);
|
|
832
920
|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
isFunction$1(_global.postMessage)
|
|
841
|
-
);
|
|
921
|
+
return (cb) => {
|
|
922
|
+
callbacks.push(cb);
|
|
923
|
+
_global.postMessage(token, "*");
|
|
924
|
+
};
|
|
925
|
+
})(`axios@${Math.random()}`, [])
|
|
926
|
+
: (cb) => setTimeout(cb);
|
|
927
|
+
})(typeof setImmediate === "function", isFunction$1(_global.postMessage));
|
|
842
928
|
|
|
843
|
-
const asap =
|
|
844
|
-
|
|
929
|
+
const asap =
|
|
930
|
+
typeof queueMicrotask !== "undefined"
|
|
931
|
+
? queueMicrotask.bind(_global)
|
|
932
|
+
: (typeof process !== "undefined" && process.nextTick) || _setImmediate;
|
|
845
933
|
|
|
846
934
|
// *********************
|
|
847
935
|
|
|
848
|
-
|
|
849
936
|
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
850
937
|
|
|
851
|
-
|
|
852
938
|
var utils$1 = {
|
|
853
939
|
isArray,
|
|
854
940
|
isArrayBuffer,
|
|
@@ -906,113 +992,76 @@ var utils$1 = {
|
|
|
906
992
|
isThenable,
|
|
907
993
|
setImmediate: _setImmediate,
|
|
908
994
|
asap,
|
|
909
|
-
isIterable
|
|
995
|
+
isIterable,
|
|
910
996
|
};
|
|
911
997
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
*
|
|
921
|
-
* @returns {Error} The created error.
|
|
922
|
-
*/
|
|
923
|
-
function AxiosError(message, code, config, request, response) {
|
|
924
|
-
Error.call(this);
|
|
998
|
+
class AxiosError extends Error {
|
|
999
|
+
static from(error, code, config, request, response, customProps) {
|
|
1000
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1001
|
+
axiosError.cause = error;
|
|
1002
|
+
axiosError.name = error.name;
|
|
1003
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1004
|
+
return axiosError;
|
|
1005
|
+
}
|
|
925
1006
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1007
|
+
/**
|
|
1008
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1009
|
+
*
|
|
1010
|
+
* @param {string} message The error message.
|
|
1011
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1012
|
+
* @param {Object} [config] The config.
|
|
1013
|
+
* @param {Object} [request] The request.
|
|
1014
|
+
* @param {Object} [response] The response.
|
|
1015
|
+
*
|
|
1016
|
+
* @returns {Error} The created error.
|
|
1017
|
+
*/
|
|
1018
|
+
constructor(message, code, config, request, response) {
|
|
1019
|
+
super(message);
|
|
1020
|
+
this.name = 'AxiosError';
|
|
1021
|
+
this.isAxiosError = true;
|
|
1022
|
+
code && (this.code = code);
|
|
1023
|
+
config && (this.config = config);
|
|
1024
|
+
request && (this.request = request);
|
|
1025
|
+
if (response) {
|
|
1026
|
+
this.response = response;
|
|
1027
|
+
this.status = response.status;
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
931
1030
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1031
|
+
toJSON() {
|
|
1032
|
+
return {
|
|
1033
|
+
// Standard
|
|
1034
|
+
message: this.message,
|
|
1035
|
+
name: this.name,
|
|
1036
|
+
// Microsoft
|
|
1037
|
+
description: this.description,
|
|
1038
|
+
number: this.number,
|
|
1039
|
+
// Mozilla
|
|
1040
|
+
fileName: this.fileName,
|
|
1041
|
+
lineNumber: this.lineNumber,
|
|
1042
|
+
columnNumber: this.columnNumber,
|
|
1043
|
+
stack: this.stack,
|
|
1044
|
+
// Axios
|
|
1045
|
+
config: utils$1.toJSONObject(this.config),
|
|
1046
|
+
code: this.code,
|
|
1047
|
+
status: this.status,
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
941
1050
|
}
|
|
942
1051
|
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
stack: this.stack,
|
|
957
|
-
// Axios
|
|
958
|
-
config: utils$1.toJSONObject(this.config),
|
|
959
|
-
code: this.code,
|
|
960
|
-
status: this.status
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
});
|
|
964
|
-
|
|
965
|
-
const prototype$1 = AxiosError.prototype;
|
|
966
|
-
const descriptors = {};
|
|
967
|
-
|
|
968
|
-
[
|
|
969
|
-
'ERR_BAD_OPTION_VALUE',
|
|
970
|
-
'ERR_BAD_OPTION',
|
|
971
|
-
'ECONNABORTED',
|
|
972
|
-
'ETIMEDOUT',
|
|
973
|
-
'ERR_NETWORK',
|
|
974
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
975
|
-
'ERR_DEPRECATED',
|
|
976
|
-
'ERR_BAD_RESPONSE',
|
|
977
|
-
'ERR_BAD_REQUEST',
|
|
978
|
-
'ERR_CANCELED',
|
|
979
|
-
'ERR_NOT_SUPPORT',
|
|
980
|
-
'ERR_INVALID_URL'
|
|
981
|
-
// eslint-disable-next-line func-names
|
|
982
|
-
].forEach(code => {
|
|
983
|
-
descriptors[code] = {value: code};
|
|
984
|
-
});
|
|
985
|
-
|
|
986
|
-
Object.defineProperties(AxiosError, descriptors);
|
|
987
|
-
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
988
|
-
|
|
989
|
-
// eslint-disable-next-line func-names
|
|
990
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
991
|
-
const axiosError = Object.create(prototype$1);
|
|
992
|
-
|
|
993
|
-
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
994
|
-
return obj !== Error.prototype;
|
|
995
|
-
}, prop => {
|
|
996
|
-
return prop !== 'isAxiosError';
|
|
997
|
-
});
|
|
998
|
-
|
|
999
|
-
const msg = error && error.message ? error.message : 'Error';
|
|
1000
|
-
|
|
1001
|
-
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
1002
|
-
const errCode = code == null && error ? error.code : code;
|
|
1003
|
-
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
1004
|
-
|
|
1005
|
-
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
1006
|
-
if (error && axiosError.cause == null) {
|
|
1007
|
-
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
axiosError.name = (error && error.name) || 'Error';
|
|
1011
|
-
|
|
1012
|
-
customProps && Object.assign(axiosError, customProps);
|
|
1013
|
-
|
|
1014
|
-
return axiosError;
|
|
1015
|
-
};
|
|
1052
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
1053
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
1054
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1055
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
1056
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
1057
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
1058
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1059
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1060
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1061
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1062
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
1063
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1064
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1016
1065
|
|
|
1017
1066
|
// eslint-disable-next-line strict
|
|
1018
1067
|
var httpAdapter = null;
|
|
@@ -1311,29 +1360,26 @@ function encode(val) {
|
|
|
1311
1360
|
* @returns {string} The formatted url
|
|
1312
1361
|
*/
|
|
1313
1362
|
function buildURL(url, params, options) {
|
|
1314
|
-
/*eslint no-param-reassign:0*/
|
|
1315
1363
|
if (!params) {
|
|
1316
1364
|
return url;
|
|
1317
1365
|
}
|
|
1318
|
-
|
|
1366
|
+
|
|
1319
1367
|
const _encode = options && options.encode || encode;
|
|
1320
1368
|
|
|
1321
|
-
|
|
1322
|
-
options
|
|
1323
|
-
|
|
1324
|
-
};
|
|
1325
|
-
}
|
|
1369
|
+
const _options = utils$1.isFunction(options) ? {
|
|
1370
|
+
serialize: options
|
|
1371
|
+
} : options;
|
|
1326
1372
|
|
|
1327
|
-
const serializeFn =
|
|
1373
|
+
const serializeFn = _options && _options.serialize;
|
|
1328
1374
|
|
|
1329
1375
|
let serializedParams;
|
|
1330
1376
|
|
|
1331
1377
|
if (serializeFn) {
|
|
1332
|
-
serializedParams = serializeFn(params,
|
|
1378
|
+
serializedParams = serializeFn(params, _options);
|
|
1333
1379
|
} else {
|
|
1334
1380
|
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
1335
1381
|
params.toString() :
|
|
1336
|
-
new AxiosURLSearchParams(params,
|
|
1382
|
+
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1337
1383
|
}
|
|
1338
1384
|
|
|
1339
1385
|
if (serializedParams) {
|
|
@@ -1358,6 +1404,7 @@ class InterceptorManager {
|
|
|
1358
1404
|
*
|
|
1359
1405
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1360
1406
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1407
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
1361
1408
|
*
|
|
1362
1409
|
* @return {Number} An ID used to remove interceptor later
|
|
1363
1410
|
*/
|
|
@@ -1376,7 +1423,7 @@ class InterceptorManager {
|
|
|
1376
1423
|
*
|
|
1377
1424
|
* @param {Number} id The ID that was returned by `use`
|
|
1378
1425
|
*
|
|
1379
|
-
* @returns {
|
|
1426
|
+
* @returns {void}
|
|
1380
1427
|
*/
|
|
1381
1428
|
eject(id) {
|
|
1382
1429
|
if (this.handlers[id]) {
|
|
@@ -1417,7 +1464,8 @@ class InterceptorManager {
|
|
|
1417
1464
|
var transitionalDefaults = {
|
|
1418
1465
|
silentJSONParsing: true,
|
|
1419
1466
|
forcedJSONParsing: true,
|
|
1420
|
-
clarifyTimeoutError: false
|
|
1467
|
+
clarifyTimeoutError: false,
|
|
1468
|
+
legacyInterceptorReqResOrdering: true
|
|
1421
1469
|
};
|
|
1422
1470
|
|
|
1423
1471
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -2135,25 +2183,23 @@ function isCancel(value) {
|
|
|
2135
2183
|
return !!(value && value.__CANCEL__);
|
|
2136
2184
|
}
|
|
2137
2185
|
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2186
|
+
class CanceledError extends AxiosError {
|
|
2187
|
+
/**
|
|
2188
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
2189
|
+
*
|
|
2190
|
+
* @param {string=} message The message.
|
|
2191
|
+
* @param {Object=} config The config.
|
|
2192
|
+
* @param {Object=} request The request.
|
|
2193
|
+
*
|
|
2194
|
+
* @returns {CanceledError} The created error.
|
|
2195
|
+
*/
|
|
2196
|
+
constructor(message, config, request) {
|
|
2197
|
+
super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
|
2198
|
+
this.name = 'CanceledError';
|
|
2199
|
+
this.__CANCEL__ = true;
|
|
2200
|
+
}
|
|
2151
2201
|
}
|
|
2152
2202
|
|
|
2153
|
-
utils$1.inherits(CanceledError, AxiosError, {
|
|
2154
|
-
__CANCEL__: true
|
|
2155
|
-
});
|
|
2156
|
-
|
|
2157
2203
|
/**
|
|
2158
2204
|
* Resolve or reject a Promise based on response status.
|
|
2159
2205
|
*
|
|
@@ -2336,27 +2382,38 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
2336
2382
|
|
|
2337
2383
|
// Standard browser envs support document.cookie
|
|
2338
2384
|
{
|
|
2339
|
-
write(name, value, expires, path, domain, secure) {
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2385
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2386
|
+
if (typeof document === 'undefined') return;
|
|
2343
2387
|
|
|
2344
|
-
|
|
2388
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2345
2389
|
|
|
2346
|
-
utils$1.
|
|
2347
|
-
|
|
2348
|
-
|
|
2390
|
+
if (utils$1.isNumber(expires)) {
|
|
2391
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2392
|
+
}
|
|
2393
|
+
if (utils$1.isString(path)) {
|
|
2394
|
+
cookie.push(`path=${path}`);
|
|
2395
|
+
}
|
|
2396
|
+
if (utils$1.isString(domain)) {
|
|
2397
|
+
cookie.push(`domain=${domain}`);
|
|
2398
|
+
}
|
|
2399
|
+
if (secure === true) {
|
|
2400
|
+
cookie.push('secure');
|
|
2401
|
+
}
|
|
2402
|
+
if (utils$1.isString(sameSite)) {
|
|
2403
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2404
|
+
}
|
|
2349
2405
|
|
|
2350
2406
|
document.cookie = cookie.join('; ');
|
|
2351
2407
|
},
|
|
2352
2408
|
|
|
2353
2409
|
read(name) {
|
|
2354
|
-
|
|
2355
|
-
|
|
2410
|
+
if (typeof document === 'undefined') return null;
|
|
2411
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
2412
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
2356
2413
|
},
|
|
2357
2414
|
|
|
2358
2415
|
remove(name) {
|
|
2359
|
-
this.write(name, '', Date.now() - 86400000);
|
|
2416
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2360
2417
|
}
|
|
2361
2418
|
}
|
|
2362
2419
|
|
|
@@ -2382,6 +2439,10 @@ function isAbsoluteURL(url) {
|
|
|
2382
2439
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
2383
2440
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
2384
2441
|
// by any combination of letters, digits, plus, period, or hyphen.
|
|
2442
|
+
if (typeof url !== 'string') {
|
|
2443
|
+
return false;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2385
2446
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
2386
2447
|
}
|
|
2387
2448
|
|
|
@@ -2417,7 +2478,8 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
|
2417
2478
|
return requestedURL;
|
|
2418
2479
|
}
|
|
2419
2480
|
|
|
2420
|
-
const headersToObject = (thing) =>
|
|
2481
|
+
const headersToObject = (thing) =>
|
|
2482
|
+
thing instanceof AxiosHeaders ? { ...thing } : thing;
|
|
2421
2483
|
|
|
2422
2484
|
/**
|
|
2423
2485
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2435,7 +2497,7 @@ function mergeConfig(config1, config2) {
|
|
|
2435
2497
|
|
|
2436
2498
|
function getMergedValue(target, source, prop, caseless) {
|
|
2437
2499
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
2438
|
-
return utils$1.merge.call({caseless}, target, source);
|
|
2500
|
+
return utils$1.merge.call({ caseless }, target, source);
|
|
2439
2501
|
} else if (utils$1.isPlainObject(source)) {
|
|
2440
2502
|
return utils$1.merge({}, source);
|
|
2441
2503
|
} else if (utils$1.isArray(source)) {
|
|
@@ -2444,12 +2506,11 @@ function mergeConfig(config1, config2) {
|
|
|
2444
2506
|
return source;
|
|
2445
2507
|
}
|
|
2446
2508
|
|
|
2447
|
-
|
|
2448
|
-
function mergeDeepProperties(a, b, prop , caseless) {
|
|
2509
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
2449
2510
|
if (!utils$1.isUndefined(b)) {
|
|
2450
|
-
return getMergedValue(a, b, prop
|
|
2511
|
+
return getMergedValue(a, b, prop, caseless);
|
|
2451
2512
|
} else if (!utils$1.isUndefined(a)) {
|
|
2452
|
-
return getMergedValue(undefined, a, prop
|
|
2513
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
2453
2514
|
}
|
|
2454
2515
|
}
|
|
2455
2516
|
|
|
@@ -2507,14 +2568,27 @@ function mergeConfig(config1, config2) {
|
|
|
2507
2568
|
socketPath: defaultToConfig2,
|
|
2508
2569
|
responseEncoding: defaultToConfig2,
|
|
2509
2570
|
validateStatus: mergeDirectKeys,
|
|
2510
|
-
headers: (a, b
|
|
2571
|
+
headers: (a, b, prop) =>
|
|
2572
|
+
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2511
2573
|
};
|
|
2512
2574
|
|
|
2513
|
-
utils$1.forEach(
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2575
|
+
utils$1.forEach(
|
|
2576
|
+
Object.keys({ ...config1, ...config2 }),
|
|
2577
|
+
function computeConfigValue(prop) {
|
|
2578
|
+
if (
|
|
2579
|
+
prop === "__proto__" ||
|
|
2580
|
+
prop === "constructor" ||
|
|
2581
|
+
prop === "prototype"
|
|
2582
|
+
)
|
|
2583
|
+
return;
|
|
2584
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2585
|
+
? mergeMap[prop]
|
|
2586
|
+
: mergeDeepProperties;
|
|
2587
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2588
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2589
|
+
(config[prop] = configValue);
|
|
2590
|
+
},
|
|
2591
|
+
);
|
|
2518
2592
|
|
|
2519
2593
|
return config;
|
|
2520
2594
|
}
|
|
@@ -2780,7 +2854,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
2780
2854
|
|
|
2781
2855
|
let timer = timeout && setTimeout(() => {
|
|
2782
2856
|
timer = null;
|
|
2783
|
-
onabort(new AxiosError(`timeout ${timeout}
|
|
2857
|
+
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
|
|
2784
2858
|
}, timeout);
|
|
2785
2859
|
|
|
2786
2860
|
const unsubscribe = () => {
|
|
@@ -2895,9 +2969,9 @@ const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
|
2895
2969
|
|
|
2896
2970
|
const {isFunction} = utils$1;
|
|
2897
2971
|
|
|
2898
|
-
const globalFetchAPI = (({
|
|
2899
|
-
|
|
2900
|
-
|
|
2972
|
+
const globalFetchAPI = (({Request, Response}) => ({
|
|
2973
|
+
Request, Response
|
|
2974
|
+
}))(utils$1.global);
|
|
2901
2975
|
|
|
2902
2976
|
const {
|
|
2903
2977
|
ReadableStream: ReadableStream$1, TextEncoder
|
|
@@ -2913,8 +2987,12 @@ const test = (fn, ...args) => {
|
|
|
2913
2987
|
};
|
|
2914
2988
|
|
|
2915
2989
|
const factory = (env) => {
|
|
2916
|
-
|
|
2917
|
-
|
|
2990
|
+
env = utils$1.merge.call({
|
|
2991
|
+
skipUndefined: true
|
|
2992
|
+
}, globalFetchAPI, env);
|
|
2993
|
+
|
|
2994
|
+
const {fetch: envFetch, Request, Response} = env;
|
|
2995
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
2918
2996
|
const isRequestSupported = isFunction(Request);
|
|
2919
2997
|
const isResponseSupported = isFunction(Response);
|
|
2920
2998
|
|
|
@@ -3017,6 +3095,8 @@ const factory = (env) => {
|
|
|
3017
3095
|
fetchOptions
|
|
3018
3096
|
} = resolveConfig(config);
|
|
3019
3097
|
|
|
3098
|
+
let _fetch = envFetch || fetch;
|
|
3099
|
+
|
|
3020
3100
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3021
3101
|
|
|
3022
3102
|
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
@@ -3076,7 +3156,7 @@ const factory = (env) => {
|
|
|
3076
3156
|
|
|
3077
3157
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3078
3158
|
|
|
3079
|
-
let response = await (isRequestSupported ?
|
|
3159
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
3080
3160
|
|
|
3081
3161
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3082
3162
|
|
|
@@ -3124,14 +3204,14 @@ const factory = (env) => {
|
|
|
3124
3204
|
|
|
3125
3205
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3126
3206
|
throw Object.assign(
|
|
3127
|
-
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
3207
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response),
|
|
3128
3208
|
{
|
|
3129
3209
|
cause: err.cause || err
|
|
3130
3210
|
}
|
|
3131
3211
|
)
|
|
3132
3212
|
}
|
|
3133
3213
|
|
|
3134
|
-
throw AxiosError.from(err, err && err.code, config, request);
|
|
3214
|
+
throw AxiosError.from(err, err && err.code, config, request, err && err.response);
|
|
3135
3215
|
}
|
|
3136
3216
|
}
|
|
3137
3217
|
};
|
|
@@ -3139,12 +3219,8 @@ const factory = (env) => {
|
|
|
3139
3219
|
const seedCache = new Map();
|
|
3140
3220
|
|
|
3141
3221
|
const getFetch = (config) => {
|
|
3142
|
-
let env =
|
|
3143
|
-
skipUndefined: true
|
|
3144
|
-
}, globalFetchAPI, config ? config.env : null);
|
|
3145
|
-
|
|
3222
|
+
let env = (config && config.env) || {};
|
|
3146
3223
|
const {fetch, Request, Response} = env;
|
|
3147
|
-
|
|
3148
3224
|
const seeds = [
|
|
3149
3225
|
Request, Response, fetch
|
|
3150
3226
|
];
|
|
@@ -3166,6 +3242,15 @@ const getFetch = (config) => {
|
|
|
3166
3242
|
|
|
3167
3243
|
getFetch();
|
|
3168
3244
|
|
|
3245
|
+
/**
|
|
3246
|
+
* Known adapters mapping.
|
|
3247
|
+
* Provides environment-specific adapters for Axios:
|
|
3248
|
+
* - `http` for Node.js
|
|
3249
|
+
* - `xhr` for browsers
|
|
3250
|
+
* - `fetch` for fetch API-based requests
|
|
3251
|
+
*
|
|
3252
|
+
* @type {Object<string, Function|Object>}
|
|
3253
|
+
*/
|
|
3169
3254
|
const knownAdapters = {
|
|
3170
3255
|
http: httpAdapter,
|
|
3171
3256
|
xhr: xhrAdapter,
|
|
@@ -3174,71 +3259,107 @@ const knownAdapters = {
|
|
|
3174
3259
|
}
|
|
3175
3260
|
};
|
|
3176
3261
|
|
|
3262
|
+
// Assign adapter names for easier debugging and identification
|
|
3177
3263
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3178
3264
|
if (fn) {
|
|
3179
3265
|
try {
|
|
3180
|
-
Object.defineProperty(fn, 'name', {value});
|
|
3266
|
+
Object.defineProperty(fn, 'name', { value });
|
|
3181
3267
|
} catch (e) {
|
|
3182
3268
|
// eslint-disable-next-line no-empty
|
|
3183
3269
|
}
|
|
3184
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
3270
|
+
Object.defineProperty(fn, 'adapterName', { value });
|
|
3185
3271
|
}
|
|
3186
3272
|
});
|
|
3187
3273
|
|
|
3274
|
+
/**
|
|
3275
|
+
* Render a rejection reason string for unknown or unsupported adapters
|
|
3276
|
+
*
|
|
3277
|
+
* @param {string} reason
|
|
3278
|
+
* @returns {string}
|
|
3279
|
+
*/
|
|
3188
3280
|
const renderReason = (reason) => `- ${reason}`;
|
|
3189
3281
|
|
|
3282
|
+
/**
|
|
3283
|
+
* Check if the adapter is resolved (function, null, or false)
|
|
3284
|
+
*
|
|
3285
|
+
* @param {Function|null|false} adapter
|
|
3286
|
+
* @returns {boolean}
|
|
3287
|
+
*/
|
|
3190
3288
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3191
3289
|
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3290
|
+
/**
|
|
3291
|
+
* Get the first suitable adapter from the provided list.
|
|
3292
|
+
* Tries each adapter in order until a supported one is found.
|
|
3293
|
+
* Throws an AxiosError if no adapter is suitable.
|
|
3294
|
+
*
|
|
3295
|
+
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3296
|
+
* @param {Object} config - Axios request configuration
|
|
3297
|
+
* @throws {AxiosError} If no suitable adapter is available
|
|
3298
|
+
* @returns {Function} The resolved adapter function
|
|
3299
|
+
*/
|
|
3300
|
+
function getAdapter(adapters, config) {
|
|
3301
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
3199
3302
|
|
|
3200
|
-
|
|
3303
|
+
const { length } = adapters;
|
|
3304
|
+
let nameOrAdapter;
|
|
3305
|
+
let adapter;
|
|
3201
3306
|
|
|
3202
|
-
|
|
3203
|
-
nameOrAdapter = adapters[i];
|
|
3204
|
-
let id;
|
|
3307
|
+
const rejectedReasons = {};
|
|
3205
3308
|
|
|
3206
|
-
|
|
3309
|
+
for (let i = 0; i < length; i++) {
|
|
3310
|
+
nameOrAdapter = adapters[i];
|
|
3311
|
+
let id;
|
|
3207
3312
|
|
|
3208
|
-
|
|
3209
|
-
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3313
|
+
adapter = nameOrAdapter;
|
|
3210
3314
|
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
}
|
|
3214
|
-
}
|
|
3315
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
3316
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3215
3317
|
|
|
3216
|
-
if (adapter
|
|
3217
|
-
|
|
3318
|
+
if (adapter === undefined) {
|
|
3319
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
3218
3320
|
}
|
|
3321
|
+
}
|
|
3219
3322
|
|
|
3220
|
-
|
|
3323
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
3324
|
+
break;
|
|
3221
3325
|
}
|
|
3222
3326
|
|
|
3223
|
-
|
|
3327
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
3328
|
+
}
|
|
3224
3329
|
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
)
|
|
3330
|
+
if (!adapter) {
|
|
3331
|
+
const reasons = Object.entries(rejectedReasons)
|
|
3332
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
3333
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3334
|
+
);
|
|
3229
3335
|
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3336
|
+
let s = length ?
|
|
3337
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
3338
|
+
'as no adapter specified';
|
|
3233
3339
|
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3340
|
+
throw new AxiosError(
|
|
3341
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
3342
|
+
'ERR_NOT_SUPPORT'
|
|
3343
|
+
);
|
|
3344
|
+
}
|
|
3239
3345
|
|
|
3240
|
-
|
|
3241
|
-
|
|
3346
|
+
return adapter;
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
/**
|
|
3350
|
+
* Exports Axios adapters and utility to resolve an adapter
|
|
3351
|
+
*/
|
|
3352
|
+
var adapters = {
|
|
3353
|
+
/**
|
|
3354
|
+
* Resolve an adapter from a list of adapter names or functions.
|
|
3355
|
+
* @type {Function}
|
|
3356
|
+
*/
|
|
3357
|
+
getAdapter,
|
|
3358
|
+
|
|
3359
|
+
/**
|
|
3360
|
+
* Exposes all known adapters
|
|
3361
|
+
* @type {Object<string, Function|Object>}
|
|
3362
|
+
*/
|
|
3242
3363
|
adapters: knownAdapters
|
|
3243
3364
|
};
|
|
3244
3365
|
|
|
@@ -3315,7 +3436,7 @@ function dispatchRequest(config) {
|
|
|
3315
3436
|
});
|
|
3316
3437
|
}
|
|
3317
3438
|
|
|
3318
|
-
const VERSION = "1.
|
|
3439
|
+
const VERSION = "1.13.5";
|
|
3319
3440
|
|
|
3320
3441
|
const validators$1 = {};
|
|
3321
3442
|
|
|
@@ -3483,7 +3604,8 @@ class Axios {
|
|
|
3483
3604
|
validator.assertOptions(transitional, {
|
|
3484
3605
|
silentJSONParsing: validators.transitional(validators.boolean),
|
|
3485
3606
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
3486
|
-
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
3607
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
3608
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
|
|
3487
3609
|
}, false);
|
|
3488
3610
|
}
|
|
3489
3611
|
|
|
@@ -3540,7 +3662,14 @@ class Axios {
|
|
|
3540
3662
|
|
|
3541
3663
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3542
3664
|
|
|
3543
|
-
|
|
3665
|
+
const transitional = config.transitional || transitionalDefaults;
|
|
3666
|
+
const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3667
|
+
|
|
3668
|
+
if (legacyInterceptorReqResOrdering) {
|
|
3669
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
3670
|
+
} else {
|
|
3671
|
+
requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
3672
|
+
}
|
|
3544
3673
|
});
|
|
3545
3674
|
|
|
3546
3675
|
const responseInterceptorChain = [];
|
|
@@ -3571,8 +3700,6 @@ class Axios {
|
|
|
3571
3700
|
|
|
3572
3701
|
let newConfig = config;
|
|
3573
3702
|
|
|
3574
|
-
i = 0;
|
|
3575
|
-
|
|
3576
3703
|
while (i < len) {
|
|
3577
3704
|
const onFulfilled = requestInterceptorChain[i++];
|
|
3578
3705
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -3777,7 +3904,7 @@ class CancelToken {
|
|
|
3777
3904
|
*
|
|
3778
3905
|
* ```js
|
|
3779
3906
|
* function f(x, y, z) {}
|
|
3780
|
-
*
|
|
3907
|
+
* const args = [1, 2, 3];
|
|
3781
3908
|
* f.apply(null, args);
|
|
3782
3909
|
* ```
|
|
3783
3910
|
*
|
|
@@ -3872,6 +3999,12 @@ const HttpStatusCode = {
|
|
|
3872
3999
|
LoopDetected: 508,
|
|
3873
4000
|
NotExtended: 510,
|
|
3874
4001
|
NetworkAuthenticationRequired: 511,
|
|
4002
|
+
WebServerIsDown: 521,
|
|
4003
|
+
ConnectionTimedOut: 522,
|
|
4004
|
+
OriginIsUnreachable: 523,
|
|
4005
|
+
TimeoutOccurred: 524,
|
|
4006
|
+
SslHandshakeFailed: 525,
|
|
4007
|
+
InvalidSslCertificate: 526,
|
|
3875
4008
|
};
|
|
3876
4009
|
|
|
3877
4010
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|