@xchainjs/xchain-aggregator 2.0.33 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.esm.js +808 -374
- package/lib/index.js +808 -374
- package/package.json +16 -16
package/lib/index.js
CHANGED
|
@@ -317,6 +317,13 @@ class ChainflipProtocol {
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
/**
|
|
321
|
+
* Create a bound version of a function with a specified `this` context
|
|
322
|
+
*
|
|
323
|
+
* @param {Function} fn - The function to bind
|
|
324
|
+
* @param {*} thisArg - The value to be passed as the `this` parameter
|
|
325
|
+
* @returns {Function} A new function that will call the original function with the specified `this` context
|
|
326
|
+
*/
|
|
320
327
|
function bind(fn, thisArg) {
|
|
321
328
|
return function wrap() {
|
|
322
329
|
return fn.apply(thisArg, arguments);
|
|
@@ -325,30 +332,30 @@ function bind(fn, thisArg) {
|
|
|
325
332
|
|
|
326
333
|
// utils is a library of generic helper functions non-specific to axios
|
|
327
334
|
|
|
328
|
-
const {toString} = Object.prototype;
|
|
329
|
-
const {getPrototypeOf} = Object;
|
|
330
|
-
const {iterator, toStringTag} = Symbol;
|
|
335
|
+
const { toString } = Object.prototype;
|
|
336
|
+
const { getPrototypeOf } = Object;
|
|
337
|
+
const { iterator, toStringTag } = Symbol;
|
|
331
338
|
|
|
332
|
-
const kindOf = (cache => thing => {
|
|
333
|
-
|
|
334
|
-
|
|
339
|
+
const kindOf = ((cache) => (thing) => {
|
|
340
|
+
const str = toString.call(thing);
|
|
341
|
+
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
335
342
|
})(Object.create(null));
|
|
336
343
|
|
|
337
344
|
const kindOfTest = (type) => {
|
|
338
345
|
type = type.toLowerCase();
|
|
339
|
-
return (thing) => kindOf(thing) === type
|
|
346
|
+
return (thing) => kindOf(thing) === type;
|
|
340
347
|
};
|
|
341
348
|
|
|
342
|
-
const typeOfTest = type => thing => typeof thing === type;
|
|
349
|
+
const typeOfTest = (type) => (thing) => typeof thing === type;
|
|
343
350
|
|
|
344
351
|
/**
|
|
345
|
-
* Determine if a value is
|
|
352
|
+
* Determine if a value is a non-null object
|
|
346
353
|
*
|
|
347
354
|
* @param {Object} val The value to test
|
|
348
355
|
*
|
|
349
356
|
* @returns {boolean} True if value is an Array, otherwise false
|
|
350
357
|
*/
|
|
351
|
-
const {isArray} = Array;
|
|
358
|
+
const { isArray } = Array;
|
|
352
359
|
|
|
353
360
|
/**
|
|
354
361
|
* Determine if a value is undefined
|
|
@@ -357,7 +364,7 @@ const {isArray} = Array;
|
|
|
357
364
|
*
|
|
358
365
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
359
366
|
*/
|
|
360
|
-
const isUndefined = typeOfTest(
|
|
367
|
+
const isUndefined = typeOfTest("undefined");
|
|
361
368
|
|
|
362
369
|
/**
|
|
363
370
|
* Determine if a value is a Buffer
|
|
@@ -367,8 +374,14 @@ const isUndefined = typeOfTest('undefined');
|
|
|
367
374
|
* @returns {boolean} True if value is a Buffer, otherwise false
|
|
368
375
|
*/
|
|
369
376
|
function isBuffer(val) {
|
|
370
|
-
return
|
|
371
|
-
|
|
377
|
+
return (
|
|
378
|
+
val !== null &&
|
|
379
|
+
!isUndefined(val) &&
|
|
380
|
+
val.constructor !== null &&
|
|
381
|
+
!isUndefined(val.constructor) &&
|
|
382
|
+
isFunction$1(val.constructor.isBuffer) &&
|
|
383
|
+
val.constructor.isBuffer(val)
|
|
384
|
+
);
|
|
372
385
|
}
|
|
373
386
|
|
|
374
387
|
/**
|
|
@@ -378,8 +391,7 @@ function isBuffer(val) {
|
|
|
378
391
|
*
|
|
379
392
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
380
393
|
*/
|
|
381
|
-
const isArrayBuffer = kindOfTest(
|
|
382
|
-
|
|
394
|
+
const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
383
395
|
|
|
384
396
|
/**
|
|
385
397
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -390,10 +402,10 @@ const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
|
390
402
|
*/
|
|
391
403
|
function isArrayBufferView(val) {
|
|
392
404
|
let result;
|
|
393
|
-
if (
|
|
405
|
+
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
394
406
|
result = ArrayBuffer.isView(val);
|
|
395
407
|
} else {
|
|
396
|
-
result =
|
|
408
|
+
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
397
409
|
}
|
|
398
410
|
return result;
|
|
399
411
|
}
|
|
@@ -405,7 +417,7 @@ function isArrayBufferView(val) {
|
|
|
405
417
|
*
|
|
406
418
|
* @returns {boolean} True if value is a String, otherwise false
|
|
407
419
|
*/
|
|
408
|
-
const isString = typeOfTest(
|
|
420
|
+
const isString = typeOfTest("string");
|
|
409
421
|
|
|
410
422
|
/**
|
|
411
423
|
* Determine if a value is a Function
|
|
@@ -413,7 +425,7 @@ const isString = typeOfTest('string');
|
|
|
413
425
|
* @param {*} val The value to test
|
|
414
426
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
415
427
|
*/
|
|
416
|
-
const isFunction$1 = typeOfTest(
|
|
428
|
+
const isFunction$1 = typeOfTest("function");
|
|
417
429
|
|
|
418
430
|
/**
|
|
419
431
|
* Determine if a value is a Number
|
|
@@ -422,7 +434,7 @@ const isFunction$1 = typeOfTest('function');
|
|
|
422
434
|
*
|
|
423
435
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
424
436
|
*/
|
|
425
|
-
const isNumber = typeOfTest(
|
|
437
|
+
const isNumber = typeOfTest("number");
|
|
426
438
|
|
|
427
439
|
/**
|
|
428
440
|
* Determine if a value is an Object
|
|
@@ -431,7 +443,7 @@ const isNumber = typeOfTest('number');
|
|
|
431
443
|
*
|
|
432
444
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
433
445
|
*/
|
|
434
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
446
|
+
const isObject = (thing) => thing !== null && typeof thing === "object";
|
|
435
447
|
|
|
436
448
|
/**
|
|
437
449
|
* Determine if a value is a Boolean
|
|
@@ -439,7 +451,7 @@ const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
|
439
451
|
* @param {*} thing The value to test
|
|
440
452
|
* @returns {boolean} True if value is a Boolean, otherwise false
|
|
441
453
|
*/
|
|
442
|
-
const isBoolean = thing => thing === true || thing === false;
|
|
454
|
+
const isBoolean = (thing) => thing === true || thing === false;
|
|
443
455
|
|
|
444
456
|
/**
|
|
445
457
|
* Determine if a value is a plain Object
|
|
@@ -449,12 +461,18 @@ const isBoolean = thing => thing === true || thing === false;
|
|
|
449
461
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
450
462
|
*/
|
|
451
463
|
const isPlainObject = (val) => {
|
|
452
|
-
if (kindOf(val) !==
|
|
464
|
+
if (kindOf(val) !== "object") {
|
|
453
465
|
return false;
|
|
454
466
|
}
|
|
455
467
|
|
|
456
468
|
const prototype = getPrototypeOf(val);
|
|
457
|
-
return (
|
|
469
|
+
return (
|
|
470
|
+
(prototype === null ||
|
|
471
|
+
prototype === Object.prototype ||
|
|
472
|
+
Object.getPrototypeOf(prototype) === null) &&
|
|
473
|
+
!(toStringTag in val) &&
|
|
474
|
+
!(iterator in val)
|
|
475
|
+
);
|
|
458
476
|
};
|
|
459
477
|
|
|
460
478
|
/**
|
|
@@ -471,7 +489,10 @@ const isEmptyObject = (val) => {
|
|
|
471
489
|
}
|
|
472
490
|
|
|
473
491
|
try {
|
|
474
|
-
return
|
|
492
|
+
return (
|
|
493
|
+
Object.keys(val).length === 0 &&
|
|
494
|
+
Object.getPrototypeOf(val) === Object.prototype
|
|
495
|
+
);
|
|
475
496
|
} catch (e) {
|
|
476
497
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
477
498
|
return false;
|
|
@@ -485,7 +506,7 @@ const isEmptyObject = (val) => {
|
|
|
485
506
|
*
|
|
486
507
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
487
508
|
*/
|
|
488
|
-
const isDate = kindOfTest(
|
|
509
|
+
const isDate = kindOfTest("Date");
|
|
489
510
|
|
|
490
511
|
/**
|
|
491
512
|
* Determine if a value is a File
|
|
@@ -494,7 +515,7 @@ const isDate = kindOfTest('Date');
|
|
|
494
515
|
*
|
|
495
516
|
* @returns {boolean} True if value is a File, otherwise false
|
|
496
517
|
*/
|
|
497
|
-
const isFile = kindOfTest(
|
|
518
|
+
const isFile = kindOfTest("File");
|
|
498
519
|
|
|
499
520
|
/**
|
|
500
521
|
* Determine if a value is a Blob
|
|
@@ -503,7 +524,7 @@ const isFile = kindOfTest('File');
|
|
|
503
524
|
*
|
|
504
525
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
505
526
|
*/
|
|
506
|
-
const isBlob = kindOfTest(
|
|
527
|
+
const isBlob = kindOfTest("Blob");
|
|
507
528
|
|
|
508
529
|
/**
|
|
509
530
|
* Determine if a value is a FileList
|
|
@@ -512,7 +533,7 @@ const isBlob = kindOfTest('Blob');
|
|
|
512
533
|
*
|
|
513
534
|
* @returns {boolean} True if value is a File, otherwise false
|
|
514
535
|
*/
|
|
515
|
-
const isFileList = kindOfTest(
|
|
536
|
+
const isFileList = kindOfTest("FileList");
|
|
516
537
|
|
|
517
538
|
/**
|
|
518
539
|
* Determine if a value is a Stream
|
|
@@ -532,15 +553,16 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
|
532
553
|
*/
|
|
533
554
|
const isFormData = (thing) => {
|
|
534
555
|
let kind;
|
|
535
|
-
return
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
556
|
+
return (
|
|
557
|
+
thing &&
|
|
558
|
+
((typeof FormData === "function" && thing instanceof FormData) ||
|
|
559
|
+
(isFunction$1(thing.append) &&
|
|
560
|
+
((kind = kindOf(thing)) === "formdata" ||
|
|
561
|
+
// detect form-data instance
|
|
562
|
+
(kind === "object" &&
|
|
563
|
+
isFunction$1(thing.toString) &&
|
|
564
|
+
thing.toString() === "[object FormData]"))))
|
|
565
|
+
);
|
|
544
566
|
};
|
|
545
567
|
|
|
546
568
|
/**
|
|
@@ -550,9 +572,14 @@ const isFormData = (thing) => {
|
|
|
550
572
|
*
|
|
551
573
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
552
574
|
*/
|
|
553
|
-
const isURLSearchParams = kindOfTest(
|
|
575
|
+
const isURLSearchParams = kindOfTest("URLSearchParams");
|
|
554
576
|
|
|
555
|
-
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
577
|
+
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
578
|
+
"ReadableStream",
|
|
579
|
+
"Request",
|
|
580
|
+
"Response",
|
|
581
|
+
"Headers",
|
|
582
|
+
].map(kindOfTest);
|
|
556
583
|
|
|
557
584
|
/**
|
|
558
585
|
* Trim excess whitespace off the beginning and end of a string
|
|
@@ -561,8 +588,8 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream',
|
|
|
561
588
|
*
|
|
562
589
|
* @returns {String} The String freed of excess whitespace
|
|
563
590
|
*/
|
|
564
|
-
const trim = (str) =>
|
|
565
|
-
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
591
|
+
const trim = (str) =>
|
|
592
|
+
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
566
593
|
|
|
567
594
|
/**
|
|
568
595
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
@@ -573,15 +600,16 @@ const trim = (str) => str.trim ?
|
|
|
573
600
|
* If 'obj' is an Object callback will be called passing
|
|
574
601
|
* the value, key, and complete object for each property.
|
|
575
602
|
*
|
|
576
|
-
* @param {Object|Array} obj The object to iterate
|
|
603
|
+
* @param {Object|Array<unknown>} obj The object to iterate
|
|
577
604
|
* @param {Function} fn The callback to invoke for each item
|
|
578
605
|
*
|
|
579
|
-
* @param {
|
|
606
|
+
* @param {Object} [options]
|
|
607
|
+
* @param {Boolean} [options.allOwnKeys = false]
|
|
580
608
|
* @returns {any}
|
|
581
609
|
*/
|
|
582
|
-
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
610
|
+
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
583
611
|
// Don't bother if no value provided
|
|
584
|
-
if (obj === null || typeof obj ===
|
|
612
|
+
if (obj === null || typeof obj === "undefined") {
|
|
585
613
|
return;
|
|
586
614
|
}
|
|
587
615
|
|
|
@@ -589,7 +617,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
589
617
|
let l;
|
|
590
618
|
|
|
591
619
|
// Force an array if not already something iterable
|
|
592
|
-
if (typeof obj !==
|
|
620
|
+
if (typeof obj !== "object") {
|
|
593
621
|
/*eslint no-param-reassign:0*/
|
|
594
622
|
obj = [obj];
|
|
595
623
|
}
|
|
@@ -606,7 +634,9 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
606
634
|
}
|
|
607
635
|
|
|
608
636
|
// Iterate over object keys
|
|
609
|
-
const keys = allOwnKeys
|
|
637
|
+
const keys = allOwnKeys
|
|
638
|
+
? Object.getOwnPropertyNames(obj)
|
|
639
|
+
: Object.keys(obj);
|
|
610
640
|
const len = keys.length;
|
|
611
641
|
let key;
|
|
612
642
|
|
|
@@ -618,7 +648,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
618
648
|
}
|
|
619
649
|
|
|
620
650
|
function findKey(obj, key) {
|
|
621
|
-
if (isBuffer(obj)){
|
|
651
|
+
if (isBuffer(obj)) {
|
|
622
652
|
return null;
|
|
623
653
|
}
|
|
624
654
|
|
|
@@ -638,10 +668,15 @@ function findKey(obj, key) {
|
|
|
638
668
|
const _global = (() => {
|
|
639
669
|
/*eslint no-undef:0*/
|
|
640
670
|
if (typeof globalThis !== "undefined") return globalThis;
|
|
641
|
-
return typeof self !== "undefined"
|
|
671
|
+
return typeof self !== "undefined"
|
|
672
|
+
? self
|
|
673
|
+
: typeof window !== "undefined"
|
|
674
|
+
? window
|
|
675
|
+
: global;
|
|
642
676
|
})();
|
|
643
677
|
|
|
644
|
-
const isContextDefined = (context) =>
|
|
678
|
+
const isContextDefined = (context) =>
|
|
679
|
+
!isUndefined(context) && context !== _global;
|
|
645
680
|
|
|
646
681
|
/**
|
|
647
682
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -653,7 +688,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
653
688
|
* Example:
|
|
654
689
|
*
|
|
655
690
|
* ```js
|
|
656
|
-
*
|
|
691
|
+
* const result = merge({foo: 123}, {foo: 456});
|
|
657
692
|
* console.log(result.foo); // outputs 456
|
|
658
693
|
* ```
|
|
659
694
|
*
|
|
@@ -662,20 +697,23 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|
|
662
697
|
* @returns {Object} Result of all merge properties
|
|
663
698
|
*/
|
|
664
699
|
function merge(/* obj1, obj2, obj3, ... */) {
|
|
665
|
-
const {caseless, skipUndefined} = isContextDefined(this) && this || {};
|
|
700
|
+
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
666
701
|
const result = {};
|
|
667
702
|
const assignValue = (val, key) => {
|
|
668
|
-
|
|
703
|
+
// Skip dangerous property names to prevent prototype pollution
|
|
704
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
const targetKey = (caseless && findKey(result, key)) || key;
|
|
669
709
|
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
|
670
710
|
result[targetKey] = merge(result[targetKey], val);
|
|
671
711
|
} else if (isPlainObject(val)) {
|
|
672
712
|
result[targetKey] = merge({}, val);
|
|
673
713
|
} else if (isArray(val)) {
|
|
674
714
|
result[targetKey] = val.slice();
|
|
675
|
-
} else {
|
|
676
|
-
|
|
677
|
-
result[targetKey] = val;
|
|
678
|
-
}
|
|
715
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
716
|
+
result[targetKey] = val;
|
|
679
717
|
}
|
|
680
718
|
};
|
|
681
719
|
|
|
@@ -692,17 +730,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
692
730
|
* @param {Object} b The object to copy properties from
|
|
693
731
|
* @param {Object} thisArg The object to bind function to
|
|
694
732
|
*
|
|
695
|
-
* @param {
|
|
733
|
+
* @param {Object} [options]
|
|
734
|
+
* @param {Boolean} [options.allOwnKeys]
|
|
696
735
|
* @returns {Object} The resulting value of object a
|
|
697
736
|
*/
|
|
698
|
-
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
699
|
-
forEach(
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
737
|
+
const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
738
|
+
forEach(
|
|
739
|
+
b,
|
|
740
|
+
(val, key) => {
|
|
741
|
+
if (thisArg && isFunction$1(val)) {
|
|
742
|
+
Object.defineProperty(a, key, {
|
|
743
|
+
value: bind(val, thisArg),
|
|
744
|
+
writable: true,
|
|
745
|
+
enumerable: true,
|
|
746
|
+
configurable: true,
|
|
747
|
+
});
|
|
748
|
+
} else {
|
|
749
|
+
Object.defineProperty(a, key, {
|
|
750
|
+
value: val,
|
|
751
|
+
writable: true,
|
|
752
|
+
enumerable: true,
|
|
753
|
+
configurable: true,
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
{ allOwnKeys },
|
|
758
|
+
);
|
|
706
759
|
return a;
|
|
707
760
|
};
|
|
708
761
|
|
|
@@ -714,7 +767,7 @@ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
|
|
714
767
|
* @returns {string} content value without BOM
|
|
715
768
|
*/
|
|
716
769
|
const stripBOM = (content) => {
|
|
717
|
-
if (content.charCodeAt(0) ===
|
|
770
|
+
if (content.charCodeAt(0) === 0xfeff) {
|
|
718
771
|
content = content.slice(1);
|
|
719
772
|
}
|
|
720
773
|
return content;
|
|
@@ -730,10 +783,18 @@ const stripBOM = (content) => {
|
|
|
730
783
|
* @returns {void}
|
|
731
784
|
*/
|
|
732
785
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
733
|
-
constructor.prototype = Object.create(
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
786
|
+
constructor.prototype = Object.create(
|
|
787
|
+
superConstructor.prototype,
|
|
788
|
+
descriptors,
|
|
789
|
+
);
|
|
790
|
+
Object.defineProperty(constructor.prototype, "constructor", {
|
|
791
|
+
value: constructor,
|
|
792
|
+
writable: true,
|
|
793
|
+
enumerable: false,
|
|
794
|
+
configurable: true,
|
|
795
|
+
});
|
|
796
|
+
Object.defineProperty(constructor, "super", {
|
|
797
|
+
value: superConstructor.prototype,
|
|
737
798
|
});
|
|
738
799
|
props && Object.assign(constructor.prototype, props);
|
|
739
800
|
};
|
|
@@ -762,13 +823,20 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
|
762
823
|
i = props.length;
|
|
763
824
|
while (i-- > 0) {
|
|
764
825
|
prop = props[i];
|
|
765
|
-
if (
|
|
826
|
+
if (
|
|
827
|
+
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
828
|
+
!merged[prop]
|
|
829
|
+
) {
|
|
766
830
|
destObj[prop] = sourceObj[prop];
|
|
767
831
|
merged[prop] = true;
|
|
768
832
|
}
|
|
769
833
|
}
|
|
770
834
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
771
|
-
} while (
|
|
835
|
+
} while (
|
|
836
|
+
sourceObj &&
|
|
837
|
+
(!filter || filter(sourceObj, destObj)) &&
|
|
838
|
+
sourceObj !== Object.prototype
|
|
839
|
+
);
|
|
772
840
|
|
|
773
841
|
return destObj;
|
|
774
842
|
};
|
|
@@ -792,7 +860,6 @@ const endsWith = (str, searchString, position) => {
|
|
|
792
860
|
return lastIndex !== -1 && lastIndex === position;
|
|
793
861
|
};
|
|
794
862
|
|
|
795
|
-
|
|
796
863
|
/**
|
|
797
864
|
* Returns new array from array like object or null if failed
|
|
798
865
|
*
|
|
@@ -821,12 +888,12 @@ const toArray = (thing) => {
|
|
|
821
888
|
* @returns {Array}
|
|
822
889
|
*/
|
|
823
890
|
// eslint-disable-next-line func-names
|
|
824
|
-
const isTypedArray = (TypedArray => {
|
|
891
|
+
const isTypedArray = ((TypedArray) => {
|
|
825
892
|
// eslint-disable-next-line func-names
|
|
826
|
-
return thing => {
|
|
893
|
+
return (thing) => {
|
|
827
894
|
return TypedArray && thing instanceof TypedArray;
|
|
828
895
|
};
|
|
829
|
-
})(typeof Uint8Array !==
|
|
896
|
+
})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
|
|
830
897
|
|
|
831
898
|
/**
|
|
832
899
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -869,18 +936,22 @@ const matchAll = (regExp, str) => {
|
|
|
869
936
|
};
|
|
870
937
|
|
|
871
938
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
872
|
-
const isHTMLForm = kindOfTest(
|
|
939
|
+
const isHTMLForm = kindOfTest("HTMLFormElement");
|
|
873
940
|
|
|
874
|
-
const toCamelCase = str => {
|
|
875
|
-
return str
|
|
876
|
-
|
|
941
|
+
const toCamelCase = (str) => {
|
|
942
|
+
return str
|
|
943
|
+
.toLowerCase()
|
|
944
|
+
.replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
877
945
|
return p1.toUpperCase() + p2;
|
|
878
|
-
}
|
|
879
|
-
);
|
|
946
|
+
});
|
|
880
947
|
};
|
|
881
948
|
|
|
882
949
|
/* Creating a function that will check if an object has a property. */
|
|
883
|
-
const hasOwnProperty = (
|
|
950
|
+
const hasOwnProperty = (
|
|
951
|
+
({ hasOwnProperty }) =>
|
|
952
|
+
(obj, prop) =>
|
|
953
|
+
hasOwnProperty.call(obj, prop)
|
|
954
|
+
)(Object.prototype);
|
|
884
955
|
|
|
885
956
|
/**
|
|
886
957
|
* Determine if a value is a RegExp object
|
|
@@ -889,7 +960,7 @@ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call
|
|
|
889
960
|
*
|
|
890
961
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
891
962
|
*/
|
|
892
|
-
const isRegExp = kindOfTest(
|
|
963
|
+
const isRegExp = kindOfTest("RegExp");
|
|
893
964
|
|
|
894
965
|
const reduceDescriptors = (obj, reducer) => {
|
|
895
966
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -913,7 +984,10 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
913
984
|
const freezeMethods = (obj) => {
|
|
914
985
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
915
986
|
// skip restricted props in strict mode
|
|
916
|
-
if (
|
|
987
|
+
if (
|
|
988
|
+
isFunction$1(obj) &&
|
|
989
|
+
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
990
|
+
) {
|
|
917
991
|
return false;
|
|
918
992
|
}
|
|
919
993
|
|
|
@@ -923,14 +997,14 @@ const freezeMethods = (obj) => {
|
|
|
923
997
|
|
|
924
998
|
descriptor.enumerable = false;
|
|
925
999
|
|
|
926
|
-
if (
|
|
1000
|
+
if ("writable" in descriptor) {
|
|
927
1001
|
descriptor.writable = false;
|
|
928
1002
|
return;
|
|
929
1003
|
}
|
|
930
1004
|
|
|
931
1005
|
if (!descriptor.set) {
|
|
932
1006
|
descriptor.set = () => {
|
|
933
|
-
throw Error(
|
|
1007
|
+
throw Error("Can not rewrite read-only method '" + name + "'");
|
|
934
1008
|
};
|
|
935
1009
|
}
|
|
936
1010
|
});
|
|
@@ -940,12 +1014,14 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
940
1014
|
const obj = {};
|
|
941
1015
|
|
|
942
1016
|
const define = (arr) => {
|
|
943
|
-
arr.forEach(value => {
|
|
1017
|
+
arr.forEach((value) => {
|
|
944
1018
|
obj[value] = true;
|
|
945
1019
|
});
|
|
946
1020
|
};
|
|
947
1021
|
|
|
948
|
-
isArray(arrayOrString)
|
|
1022
|
+
isArray(arrayOrString)
|
|
1023
|
+
? define(arrayOrString)
|
|
1024
|
+
: define(String(arrayOrString).split(delimiter));
|
|
949
1025
|
|
|
950
1026
|
return obj;
|
|
951
1027
|
};
|
|
@@ -953,11 +1029,11 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
953
1029
|
const noop = () => {};
|
|
954
1030
|
|
|
955
1031
|
const toFiniteNumber = (value, defaultValue) => {
|
|
956
|
-
return value != null && Number.isFinite(value = +value)
|
|
1032
|
+
return value != null && Number.isFinite((value = +value))
|
|
1033
|
+
? value
|
|
1034
|
+
: defaultValue;
|
|
957
1035
|
};
|
|
958
1036
|
|
|
959
|
-
|
|
960
|
-
|
|
961
1037
|
/**
|
|
962
1038
|
* If the thing is a FormData object, return true, otherwise return false.
|
|
963
1039
|
*
|
|
@@ -966,14 +1042,18 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
966
1042
|
* @returns {boolean}
|
|
967
1043
|
*/
|
|
968
1044
|
function isSpecCompliantForm(thing) {
|
|
969
|
-
return !!(
|
|
1045
|
+
return !!(
|
|
1046
|
+
thing &&
|
|
1047
|
+
isFunction$1(thing.append) &&
|
|
1048
|
+
thing[toStringTag] === "FormData" &&
|
|
1049
|
+
thing[iterator]
|
|
1050
|
+
);
|
|
970
1051
|
}
|
|
971
1052
|
|
|
972
1053
|
const toJSONObject = (obj) => {
|
|
973
1054
|
const stack = new Array(10);
|
|
974
1055
|
|
|
975
1056
|
const visit = (source, i) => {
|
|
976
|
-
|
|
977
1057
|
if (isObject(source)) {
|
|
978
1058
|
if (stack.indexOf(source) >= 0) {
|
|
979
1059
|
return;
|
|
@@ -984,7 +1064,7 @@ const toJSONObject = (obj) => {
|
|
|
984
1064
|
return source;
|
|
985
1065
|
}
|
|
986
1066
|
|
|
987
|
-
if(!(
|
|
1067
|
+
if (!("toJSON" in source)) {
|
|
988
1068
|
stack[i] = source;
|
|
989
1069
|
const target = isArray(source) ? [] : {};
|
|
990
1070
|
|
|
@@ -1005,10 +1085,13 @@ const toJSONObject = (obj) => {
|
|
|
1005
1085
|
return visit(obj, 0);
|
|
1006
1086
|
};
|
|
1007
1087
|
|
|
1008
|
-
const isAsyncFn = kindOfTest(
|
|
1088
|
+
const isAsyncFn = kindOfTest("AsyncFunction");
|
|
1009
1089
|
|
|
1010
1090
|
const isThenable = (thing) =>
|
|
1011
|
-
thing &&
|
|
1091
|
+
thing &&
|
|
1092
|
+
(isObject(thing) || isFunction$1(thing)) &&
|
|
1093
|
+
isFunction$1(thing.then) &&
|
|
1094
|
+
isFunction$1(thing.catch);
|
|
1012
1095
|
|
|
1013
1096
|
// original code
|
|
1014
1097
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
@@ -1018,32 +1101,35 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
1018
1101
|
return setImmediate;
|
|
1019
1102
|
}
|
|
1020
1103
|
|
|
1021
|
-
return postMessageSupported
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1104
|
+
return postMessageSupported
|
|
1105
|
+
? ((token, callbacks) => {
|
|
1106
|
+
_global.addEventListener(
|
|
1107
|
+
"message",
|
|
1108
|
+
({ source, data }) => {
|
|
1109
|
+
if (source === _global && data === token) {
|
|
1110
|
+
callbacks.length && callbacks.shift()();
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
false,
|
|
1114
|
+
);
|
|
1027
1115
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
isFunction$1(_global.postMessage)
|
|
1036
|
-
);
|
|
1116
|
+
return (cb) => {
|
|
1117
|
+
callbacks.push(cb);
|
|
1118
|
+
_global.postMessage(token, "*");
|
|
1119
|
+
};
|
|
1120
|
+
})(`axios@${Math.random()}`, [])
|
|
1121
|
+
: (cb) => setTimeout(cb);
|
|
1122
|
+
})(typeof setImmediate === "function", isFunction$1(_global.postMessage));
|
|
1037
1123
|
|
|
1038
|
-
const asap =
|
|
1039
|
-
|
|
1124
|
+
const asap =
|
|
1125
|
+
typeof queueMicrotask !== "undefined"
|
|
1126
|
+
? queueMicrotask.bind(_global)
|
|
1127
|
+
: (typeof process !== "undefined" && process.nextTick) || _setImmediate;
|
|
1040
1128
|
|
|
1041
1129
|
// *********************
|
|
1042
1130
|
|
|
1043
|
-
|
|
1044
1131
|
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
1045
1132
|
|
|
1046
|
-
|
|
1047
1133
|
var utils$1 = {
|
|
1048
1134
|
isArray,
|
|
1049
1135
|
isArrayBuffer,
|
|
@@ -1101,113 +1187,76 @@ var utils$1 = {
|
|
|
1101
1187
|
isThenable,
|
|
1102
1188
|
setImmediate: _setImmediate,
|
|
1103
1189
|
asap,
|
|
1104
|
-
isIterable
|
|
1190
|
+
isIterable,
|
|
1105
1191
|
};
|
|
1106
1192
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
*
|
|
1116
|
-
* @returns {Error} The created error.
|
|
1117
|
-
*/
|
|
1118
|
-
function AxiosError(message, code, config, request, response) {
|
|
1119
|
-
Error.call(this);
|
|
1193
|
+
class AxiosError extends Error {
|
|
1194
|
+
static from(error, code, config, request, response, customProps) {
|
|
1195
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1196
|
+
axiosError.cause = error;
|
|
1197
|
+
axiosError.name = error.name;
|
|
1198
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1199
|
+
return axiosError;
|
|
1200
|
+
}
|
|
1120
1201
|
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1202
|
+
/**
|
|
1203
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1204
|
+
*
|
|
1205
|
+
* @param {string} message The error message.
|
|
1206
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1207
|
+
* @param {Object} [config] The config.
|
|
1208
|
+
* @param {Object} [request] The request.
|
|
1209
|
+
* @param {Object} [response] The response.
|
|
1210
|
+
*
|
|
1211
|
+
* @returns {Error} The created error.
|
|
1212
|
+
*/
|
|
1213
|
+
constructor(message, code, config, request, response) {
|
|
1214
|
+
super(message);
|
|
1215
|
+
this.name = 'AxiosError';
|
|
1216
|
+
this.isAxiosError = true;
|
|
1217
|
+
code && (this.code = code);
|
|
1218
|
+
config && (this.config = config);
|
|
1219
|
+
request && (this.request = request);
|
|
1220
|
+
if (response) {
|
|
1221
|
+
this.response = response;
|
|
1222
|
+
this.status = response.status;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1126
1225
|
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1226
|
+
toJSON() {
|
|
1227
|
+
return {
|
|
1228
|
+
// Standard
|
|
1229
|
+
message: this.message,
|
|
1230
|
+
name: this.name,
|
|
1231
|
+
// Microsoft
|
|
1232
|
+
description: this.description,
|
|
1233
|
+
number: this.number,
|
|
1234
|
+
// Mozilla
|
|
1235
|
+
fileName: this.fileName,
|
|
1236
|
+
lineNumber: this.lineNumber,
|
|
1237
|
+
columnNumber: this.columnNumber,
|
|
1238
|
+
stack: this.stack,
|
|
1239
|
+
// Axios
|
|
1240
|
+
config: utils$1.toJSONObject(this.config),
|
|
1241
|
+
code: this.code,
|
|
1242
|
+
status: this.status,
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1136
1245
|
}
|
|
1137
1246
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
stack: this.stack,
|
|
1152
|
-
// Axios
|
|
1153
|
-
config: utils$1.toJSONObject(this.config),
|
|
1154
|
-
code: this.code,
|
|
1155
|
-
status: this.status
|
|
1156
|
-
};
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
|
|
1160
|
-
const prototype$1 = AxiosError.prototype;
|
|
1161
|
-
const descriptors = {};
|
|
1162
|
-
|
|
1163
|
-
[
|
|
1164
|
-
'ERR_BAD_OPTION_VALUE',
|
|
1165
|
-
'ERR_BAD_OPTION',
|
|
1166
|
-
'ECONNABORTED',
|
|
1167
|
-
'ETIMEDOUT',
|
|
1168
|
-
'ERR_NETWORK',
|
|
1169
|
-
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
1170
|
-
'ERR_DEPRECATED',
|
|
1171
|
-
'ERR_BAD_RESPONSE',
|
|
1172
|
-
'ERR_BAD_REQUEST',
|
|
1173
|
-
'ERR_CANCELED',
|
|
1174
|
-
'ERR_NOT_SUPPORT',
|
|
1175
|
-
'ERR_INVALID_URL'
|
|
1176
|
-
// eslint-disable-next-line func-names
|
|
1177
|
-
].forEach(code => {
|
|
1178
|
-
descriptors[code] = {value: code};
|
|
1179
|
-
});
|
|
1180
|
-
|
|
1181
|
-
Object.defineProperties(AxiosError, descriptors);
|
|
1182
|
-
Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
1183
|
-
|
|
1184
|
-
// eslint-disable-next-line func-names
|
|
1185
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
1186
|
-
const axiosError = Object.create(prototype$1);
|
|
1187
|
-
|
|
1188
|
-
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
1189
|
-
return obj !== Error.prototype;
|
|
1190
|
-
}, prop => {
|
|
1191
|
-
return prop !== 'isAxiosError';
|
|
1192
|
-
});
|
|
1193
|
-
|
|
1194
|
-
const msg = error && error.message ? error.message : 'Error';
|
|
1195
|
-
|
|
1196
|
-
// Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
|
|
1197
|
-
const errCode = code == null && error ? error.code : code;
|
|
1198
|
-
AxiosError.call(axiosError, msg, errCode, config, request, response);
|
|
1199
|
-
|
|
1200
|
-
// Chain the original error on the standard field; non-enumerable to avoid JSON noise
|
|
1201
|
-
if (error && axiosError.cause == null) {
|
|
1202
|
-
Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
axiosError.name = (error && error.name) || 'Error';
|
|
1206
|
-
|
|
1207
|
-
customProps && Object.assign(axiosError, customProps);
|
|
1208
|
-
|
|
1209
|
-
return axiosError;
|
|
1210
|
-
};
|
|
1247
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
1248
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
1249
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1250
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
1251
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
1252
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
1253
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1254
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1255
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1256
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1257
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
1258
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1259
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1211
1260
|
|
|
1212
1261
|
// eslint-disable-next-line strict
|
|
1213
1262
|
var httpAdapter = null;
|
|
@@ -1506,29 +1555,26 @@ function encode(val) {
|
|
|
1506
1555
|
* @returns {string} The formatted url
|
|
1507
1556
|
*/
|
|
1508
1557
|
function buildURL(url, params, options) {
|
|
1509
|
-
/*eslint no-param-reassign:0*/
|
|
1510
1558
|
if (!params) {
|
|
1511
1559
|
return url;
|
|
1512
1560
|
}
|
|
1513
|
-
|
|
1561
|
+
|
|
1514
1562
|
const _encode = options && options.encode || encode;
|
|
1515
1563
|
|
|
1516
|
-
|
|
1517
|
-
options
|
|
1518
|
-
|
|
1519
|
-
};
|
|
1520
|
-
}
|
|
1564
|
+
const _options = utils$1.isFunction(options) ? {
|
|
1565
|
+
serialize: options
|
|
1566
|
+
} : options;
|
|
1521
1567
|
|
|
1522
|
-
const serializeFn =
|
|
1568
|
+
const serializeFn = _options && _options.serialize;
|
|
1523
1569
|
|
|
1524
1570
|
let serializedParams;
|
|
1525
1571
|
|
|
1526
1572
|
if (serializeFn) {
|
|
1527
|
-
serializedParams = serializeFn(params,
|
|
1573
|
+
serializedParams = serializeFn(params, _options);
|
|
1528
1574
|
} else {
|
|
1529
1575
|
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
1530
1576
|
params.toString() :
|
|
1531
|
-
new AxiosURLSearchParams(params,
|
|
1577
|
+
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1532
1578
|
}
|
|
1533
1579
|
|
|
1534
1580
|
if (serializedParams) {
|
|
@@ -1553,6 +1599,7 @@ class InterceptorManager {
|
|
|
1553
1599
|
*
|
|
1554
1600
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1555
1601
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1602
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
1556
1603
|
*
|
|
1557
1604
|
* @return {Number} An ID used to remove interceptor later
|
|
1558
1605
|
*/
|
|
@@ -1571,7 +1618,7 @@ class InterceptorManager {
|
|
|
1571
1618
|
*
|
|
1572
1619
|
* @param {Number} id The ID that was returned by `use`
|
|
1573
1620
|
*
|
|
1574
|
-
* @returns {
|
|
1621
|
+
* @returns {void}
|
|
1575
1622
|
*/
|
|
1576
1623
|
eject(id) {
|
|
1577
1624
|
if (this.handlers[id]) {
|
|
@@ -1612,7 +1659,8 @@ class InterceptorManager {
|
|
|
1612
1659
|
var transitionalDefaults = {
|
|
1613
1660
|
silentJSONParsing: true,
|
|
1614
1661
|
forcedJSONParsing: true,
|
|
1615
|
-
clarifyTimeoutError: false
|
|
1662
|
+
clarifyTimeoutError: false,
|
|
1663
|
+
legacyInterceptorReqResOrdering: true
|
|
1616
1664
|
};
|
|
1617
1665
|
|
|
1618
1666
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -2330,25 +2378,23 @@ function isCancel(value) {
|
|
|
2330
2378
|
return !!(value && value.__CANCEL__);
|
|
2331
2379
|
}
|
|
2332
2380
|
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2381
|
+
class CanceledError extends AxiosError {
|
|
2382
|
+
/**
|
|
2383
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
2384
|
+
*
|
|
2385
|
+
* @param {string=} message The message.
|
|
2386
|
+
* @param {Object=} config The config.
|
|
2387
|
+
* @param {Object=} request The request.
|
|
2388
|
+
*
|
|
2389
|
+
* @returns {CanceledError} The created error.
|
|
2390
|
+
*/
|
|
2391
|
+
constructor(message, config, request) {
|
|
2392
|
+
super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
|
2393
|
+
this.name = 'CanceledError';
|
|
2394
|
+
this.__CANCEL__ = true;
|
|
2395
|
+
}
|
|
2346
2396
|
}
|
|
2347
2397
|
|
|
2348
|
-
utils$1.inherits(CanceledError, AxiosError, {
|
|
2349
|
-
__CANCEL__: true
|
|
2350
|
-
});
|
|
2351
|
-
|
|
2352
2398
|
/**
|
|
2353
2399
|
* Resolve or reject a Promise based on response status.
|
|
2354
2400
|
*
|
|
@@ -2531,27 +2577,38 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
2531
2577
|
|
|
2532
2578
|
// Standard browser envs support document.cookie
|
|
2533
2579
|
{
|
|
2534
|
-
write(name, value, expires, path, domain, secure) {
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2538
|
-
|
|
2539
|
-
utils$1.isString(path) && cookie.push('path=' + path);
|
|
2580
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2581
|
+
if (typeof document === 'undefined') return;
|
|
2540
2582
|
|
|
2541
|
-
|
|
2583
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2542
2584
|
|
|
2543
|
-
|
|
2585
|
+
if (utils$1.isNumber(expires)) {
|
|
2586
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2587
|
+
}
|
|
2588
|
+
if (utils$1.isString(path)) {
|
|
2589
|
+
cookie.push(`path=${path}`);
|
|
2590
|
+
}
|
|
2591
|
+
if (utils$1.isString(domain)) {
|
|
2592
|
+
cookie.push(`domain=${domain}`);
|
|
2593
|
+
}
|
|
2594
|
+
if (secure === true) {
|
|
2595
|
+
cookie.push('secure');
|
|
2596
|
+
}
|
|
2597
|
+
if (utils$1.isString(sameSite)) {
|
|
2598
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2599
|
+
}
|
|
2544
2600
|
|
|
2545
2601
|
document.cookie = cookie.join('; ');
|
|
2546
2602
|
},
|
|
2547
2603
|
|
|
2548
2604
|
read(name) {
|
|
2549
|
-
|
|
2550
|
-
|
|
2605
|
+
if (typeof document === 'undefined') return null;
|
|
2606
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
2607
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
2551
2608
|
},
|
|
2552
2609
|
|
|
2553
2610
|
remove(name) {
|
|
2554
|
-
this.write(name, '', Date.now() - 86400000);
|
|
2611
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2555
2612
|
}
|
|
2556
2613
|
}
|
|
2557
2614
|
|
|
@@ -2577,6 +2634,10 @@ function isAbsoluteURL(url) {
|
|
|
2577
2634
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
2578
2635
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
2579
2636
|
// by any combination of letters, digits, plus, period, or hyphen.
|
|
2637
|
+
if (typeof url !== 'string') {
|
|
2638
|
+
return false;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2580
2641
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
2581
2642
|
}
|
|
2582
2643
|
|
|
@@ -2612,7 +2673,8 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
|
2612
2673
|
return requestedURL;
|
|
2613
2674
|
}
|
|
2614
2675
|
|
|
2615
|
-
const headersToObject = (thing) =>
|
|
2676
|
+
const headersToObject = (thing) =>
|
|
2677
|
+
thing instanceof AxiosHeaders ? { ...thing } : thing;
|
|
2616
2678
|
|
|
2617
2679
|
/**
|
|
2618
2680
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2630,7 +2692,7 @@ function mergeConfig(config1, config2) {
|
|
|
2630
2692
|
|
|
2631
2693
|
function getMergedValue(target, source, prop, caseless) {
|
|
2632
2694
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
2633
|
-
return utils$1.merge.call({caseless}, target, source);
|
|
2695
|
+
return utils$1.merge.call({ caseless }, target, source);
|
|
2634
2696
|
} else if (utils$1.isPlainObject(source)) {
|
|
2635
2697
|
return utils$1.merge({}, source);
|
|
2636
2698
|
} else if (utils$1.isArray(source)) {
|
|
@@ -2639,12 +2701,11 @@ function mergeConfig(config1, config2) {
|
|
|
2639
2701
|
return source;
|
|
2640
2702
|
}
|
|
2641
2703
|
|
|
2642
|
-
|
|
2643
|
-
function mergeDeepProperties(a, b, prop , caseless) {
|
|
2704
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
2644
2705
|
if (!utils$1.isUndefined(b)) {
|
|
2645
|
-
return getMergedValue(a, b, prop
|
|
2706
|
+
return getMergedValue(a, b, prop, caseless);
|
|
2646
2707
|
} else if (!utils$1.isUndefined(a)) {
|
|
2647
|
-
return getMergedValue(undefined, a, prop
|
|
2708
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
2648
2709
|
}
|
|
2649
2710
|
}
|
|
2650
2711
|
|
|
@@ -2702,14 +2763,27 @@ function mergeConfig(config1, config2) {
|
|
|
2702
2763
|
socketPath: defaultToConfig2,
|
|
2703
2764
|
responseEncoding: defaultToConfig2,
|
|
2704
2765
|
validateStatus: mergeDirectKeys,
|
|
2705
|
-
headers: (a, b
|
|
2766
|
+
headers: (a, b, prop) =>
|
|
2767
|
+
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2706
2768
|
};
|
|
2707
2769
|
|
|
2708
|
-
utils$1.forEach(
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2770
|
+
utils$1.forEach(
|
|
2771
|
+
Object.keys({ ...config1, ...config2 }),
|
|
2772
|
+
function computeConfigValue(prop) {
|
|
2773
|
+
if (
|
|
2774
|
+
prop === "__proto__" ||
|
|
2775
|
+
prop === "constructor" ||
|
|
2776
|
+
prop === "prototype"
|
|
2777
|
+
)
|
|
2778
|
+
return;
|
|
2779
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2780
|
+
? mergeMap[prop]
|
|
2781
|
+
: mergeDeepProperties;
|
|
2782
|
+
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2783
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2784
|
+
(config[prop] = configValue);
|
|
2785
|
+
},
|
|
2786
|
+
);
|
|
2713
2787
|
|
|
2714
2788
|
return config;
|
|
2715
2789
|
}
|
|
@@ -2975,7 +3049,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
2975
3049
|
|
|
2976
3050
|
let timer = timeout && setTimeout(() => {
|
|
2977
3051
|
timer = null;
|
|
2978
|
-
onabort(new AxiosError(`timeout ${timeout}
|
|
3052
|
+
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
|
|
2979
3053
|
}, timeout);
|
|
2980
3054
|
|
|
2981
3055
|
const unsubscribe = () => {
|
|
@@ -3090,9 +3164,9 @@ const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
|
3090
3164
|
|
|
3091
3165
|
const {isFunction} = utils$1;
|
|
3092
3166
|
|
|
3093
|
-
const globalFetchAPI = (({
|
|
3094
|
-
|
|
3095
|
-
|
|
3167
|
+
const globalFetchAPI = (({Request, Response}) => ({
|
|
3168
|
+
Request, Response
|
|
3169
|
+
}))(utils$1.global);
|
|
3096
3170
|
|
|
3097
3171
|
const {
|
|
3098
3172
|
ReadableStream: ReadableStream$1, TextEncoder
|
|
@@ -3108,8 +3182,12 @@ const test = (fn, ...args) => {
|
|
|
3108
3182
|
};
|
|
3109
3183
|
|
|
3110
3184
|
const factory = (env) => {
|
|
3111
|
-
|
|
3112
|
-
|
|
3185
|
+
env = utils$1.merge.call({
|
|
3186
|
+
skipUndefined: true
|
|
3187
|
+
}, globalFetchAPI, env);
|
|
3188
|
+
|
|
3189
|
+
const {fetch: envFetch, Request, Response} = env;
|
|
3190
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
3113
3191
|
const isRequestSupported = isFunction(Request);
|
|
3114
3192
|
const isResponseSupported = isFunction(Response);
|
|
3115
3193
|
|
|
@@ -3212,6 +3290,8 @@ const factory = (env) => {
|
|
|
3212
3290
|
fetchOptions
|
|
3213
3291
|
} = resolveConfig(config);
|
|
3214
3292
|
|
|
3293
|
+
let _fetch = envFetch || fetch;
|
|
3294
|
+
|
|
3215
3295
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3216
3296
|
|
|
3217
3297
|
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
@@ -3271,7 +3351,7 @@ const factory = (env) => {
|
|
|
3271
3351
|
|
|
3272
3352
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3273
3353
|
|
|
3274
|
-
let response = await (isRequestSupported ?
|
|
3354
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
3275
3355
|
|
|
3276
3356
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3277
3357
|
|
|
@@ -3319,14 +3399,14 @@ const factory = (env) => {
|
|
|
3319
3399
|
|
|
3320
3400
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3321
3401
|
throw Object.assign(
|
|
3322
|
-
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
|
|
3402
|
+
new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response),
|
|
3323
3403
|
{
|
|
3324
3404
|
cause: err.cause || err
|
|
3325
3405
|
}
|
|
3326
3406
|
)
|
|
3327
3407
|
}
|
|
3328
3408
|
|
|
3329
|
-
throw AxiosError.from(err, err && err.code, config, request);
|
|
3409
|
+
throw AxiosError.from(err, err && err.code, config, request, err && err.response);
|
|
3330
3410
|
}
|
|
3331
3411
|
}
|
|
3332
3412
|
};
|
|
@@ -3334,12 +3414,8 @@ const factory = (env) => {
|
|
|
3334
3414
|
const seedCache = new Map();
|
|
3335
3415
|
|
|
3336
3416
|
const getFetch = (config) => {
|
|
3337
|
-
let env =
|
|
3338
|
-
skipUndefined: true
|
|
3339
|
-
}, globalFetchAPI, config ? config.env : null);
|
|
3340
|
-
|
|
3417
|
+
let env = (config && config.env) || {};
|
|
3341
3418
|
const {fetch, Request, Response} = env;
|
|
3342
|
-
|
|
3343
3419
|
const seeds = [
|
|
3344
3420
|
Request, Response, fetch
|
|
3345
3421
|
];
|
|
@@ -3361,6 +3437,15 @@ const getFetch = (config) => {
|
|
|
3361
3437
|
|
|
3362
3438
|
getFetch();
|
|
3363
3439
|
|
|
3440
|
+
/**
|
|
3441
|
+
* Known adapters mapping.
|
|
3442
|
+
* Provides environment-specific adapters for Axios:
|
|
3443
|
+
* - `http` for Node.js
|
|
3444
|
+
* - `xhr` for browsers
|
|
3445
|
+
* - `fetch` for fetch API-based requests
|
|
3446
|
+
*
|
|
3447
|
+
* @type {Object<string, Function|Object>}
|
|
3448
|
+
*/
|
|
3364
3449
|
const knownAdapters = {
|
|
3365
3450
|
http: httpAdapter,
|
|
3366
3451
|
xhr: xhrAdapter,
|
|
@@ -3369,71 +3454,107 @@ const knownAdapters = {
|
|
|
3369
3454
|
}
|
|
3370
3455
|
};
|
|
3371
3456
|
|
|
3457
|
+
// Assign adapter names for easier debugging and identification
|
|
3372
3458
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3373
3459
|
if (fn) {
|
|
3374
3460
|
try {
|
|
3375
|
-
Object.defineProperty(fn, 'name', {value});
|
|
3461
|
+
Object.defineProperty(fn, 'name', { value });
|
|
3376
3462
|
} catch (e) {
|
|
3377
3463
|
// eslint-disable-next-line no-empty
|
|
3378
3464
|
}
|
|
3379
|
-
Object.defineProperty(fn, 'adapterName', {value});
|
|
3465
|
+
Object.defineProperty(fn, 'adapterName', { value });
|
|
3380
3466
|
}
|
|
3381
3467
|
});
|
|
3382
3468
|
|
|
3469
|
+
/**
|
|
3470
|
+
* Render a rejection reason string for unknown or unsupported adapters
|
|
3471
|
+
*
|
|
3472
|
+
* @param {string} reason
|
|
3473
|
+
* @returns {string}
|
|
3474
|
+
*/
|
|
3383
3475
|
const renderReason = (reason) => `- ${reason}`;
|
|
3384
3476
|
|
|
3477
|
+
/**
|
|
3478
|
+
* Check if the adapter is resolved (function, null, or false)
|
|
3479
|
+
*
|
|
3480
|
+
* @param {Function|null|false} adapter
|
|
3481
|
+
* @returns {boolean}
|
|
3482
|
+
*/
|
|
3385
3483
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3386
3484
|
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3485
|
+
/**
|
|
3486
|
+
* Get the first suitable adapter from the provided list.
|
|
3487
|
+
* Tries each adapter in order until a supported one is found.
|
|
3488
|
+
* Throws an AxiosError if no adapter is suitable.
|
|
3489
|
+
*
|
|
3490
|
+
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3491
|
+
* @param {Object} config - Axios request configuration
|
|
3492
|
+
* @throws {AxiosError} If no suitable adapter is available
|
|
3493
|
+
* @returns {Function} The resolved adapter function
|
|
3494
|
+
*/
|
|
3495
|
+
function getAdapter(adapters, config) {
|
|
3496
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
3394
3497
|
|
|
3395
|
-
|
|
3498
|
+
const { length } = adapters;
|
|
3499
|
+
let nameOrAdapter;
|
|
3500
|
+
let adapter;
|
|
3396
3501
|
|
|
3397
|
-
|
|
3398
|
-
nameOrAdapter = adapters[i];
|
|
3399
|
-
let id;
|
|
3502
|
+
const rejectedReasons = {};
|
|
3400
3503
|
|
|
3401
|
-
|
|
3504
|
+
for (let i = 0; i < length; i++) {
|
|
3505
|
+
nameOrAdapter = adapters[i];
|
|
3506
|
+
let id;
|
|
3402
3507
|
|
|
3403
|
-
|
|
3404
|
-
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3508
|
+
adapter = nameOrAdapter;
|
|
3405
3509
|
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
}
|
|
3409
|
-
}
|
|
3510
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
3511
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
3410
3512
|
|
|
3411
|
-
if (adapter
|
|
3412
|
-
|
|
3513
|
+
if (adapter === undefined) {
|
|
3514
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
3413
3515
|
}
|
|
3516
|
+
}
|
|
3414
3517
|
|
|
3415
|
-
|
|
3518
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|
3519
|
+
break;
|
|
3416
3520
|
}
|
|
3417
3521
|
|
|
3418
|
-
|
|
3522
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
3523
|
+
}
|
|
3419
3524
|
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
)
|
|
3525
|
+
if (!adapter) {
|
|
3526
|
+
const reasons = Object.entries(rejectedReasons)
|
|
3527
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
3528
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3529
|
+
);
|
|
3424
3530
|
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3531
|
+
let s = length ?
|
|
3532
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
3533
|
+
'as no adapter specified';
|
|
3428
3534
|
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3535
|
+
throw new AxiosError(
|
|
3536
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
3537
|
+
'ERR_NOT_SUPPORT'
|
|
3538
|
+
);
|
|
3539
|
+
}
|
|
3434
3540
|
|
|
3435
|
-
|
|
3436
|
-
|
|
3541
|
+
return adapter;
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
/**
|
|
3545
|
+
* Exports Axios adapters and utility to resolve an adapter
|
|
3546
|
+
*/
|
|
3547
|
+
var adapters = {
|
|
3548
|
+
/**
|
|
3549
|
+
* Resolve an adapter from a list of adapter names or functions.
|
|
3550
|
+
* @type {Function}
|
|
3551
|
+
*/
|
|
3552
|
+
getAdapter,
|
|
3553
|
+
|
|
3554
|
+
/**
|
|
3555
|
+
* Exposes all known adapters
|
|
3556
|
+
* @type {Object<string, Function|Object>}
|
|
3557
|
+
*/
|
|
3437
3558
|
adapters: knownAdapters
|
|
3438
3559
|
};
|
|
3439
3560
|
|
|
@@ -3510,7 +3631,7 @@ function dispatchRequest(config) {
|
|
|
3510
3631
|
});
|
|
3511
3632
|
}
|
|
3512
3633
|
|
|
3513
|
-
const VERSION = "1.
|
|
3634
|
+
const VERSION = "1.13.5";
|
|
3514
3635
|
|
|
3515
3636
|
const validators$1 = {};
|
|
3516
3637
|
|
|
@@ -3678,7 +3799,8 @@ class Axios {
|
|
|
3678
3799
|
validator.assertOptions(transitional, {
|
|
3679
3800
|
silentJSONParsing: validators.transitional(validators.boolean),
|
|
3680
3801
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
3681
|
-
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
3802
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
3803
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
|
|
3682
3804
|
}, false);
|
|
3683
3805
|
}
|
|
3684
3806
|
|
|
@@ -3735,7 +3857,14 @@ class Axios {
|
|
|
3735
3857
|
|
|
3736
3858
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3737
3859
|
|
|
3738
|
-
|
|
3860
|
+
const transitional = config.transitional || transitionalDefaults;
|
|
3861
|
+
const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3862
|
+
|
|
3863
|
+
if (legacyInterceptorReqResOrdering) {
|
|
3864
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
3865
|
+
} else {
|
|
3866
|
+
requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
3867
|
+
}
|
|
3739
3868
|
});
|
|
3740
3869
|
|
|
3741
3870
|
const responseInterceptorChain = [];
|
|
@@ -3766,8 +3895,6 @@ class Axios {
|
|
|
3766
3895
|
|
|
3767
3896
|
let newConfig = config;
|
|
3768
3897
|
|
|
3769
|
-
i = 0;
|
|
3770
|
-
|
|
3771
3898
|
while (i < len) {
|
|
3772
3899
|
const onFulfilled = requestInterceptorChain[i++];
|
|
3773
3900
|
const onRejected = requestInterceptorChain[i++];
|
|
@@ -3972,7 +4099,7 @@ class CancelToken {
|
|
|
3972
4099
|
*
|
|
3973
4100
|
* ```js
|
|
3974
4101
|
* function f(x, y, z) {}
|
|
3975
|
-
*
|
|
4102
|
+
* const args = [1, 2, 3];
|
|
3976
4103
|
* f.apply(null, args);
|
|
3977
4104
|
* ```
|
|
3978
4105
|
*
|
|
@@ -4067,6 +4194,12 @@ const HttpStatusCode = {
|
|
|
4067
4194
|
LoopDetected: 508,
|
|
4068
4195
|
NotExtended: 510,
|
|
4069
4196
|
NetworkAuthenticationRequired: 511,
|
|
4197
|
+
WebServerIsDown: 521,
|
|
4198
|
+
ConnectionTimedOut: 522,
|
|
4199
|
+
OriginIsUnreachable: 523,
|
|
4200
|
+
TimeoutOccurred: 524,
|
|
4201
|
+
SslHandshakeFailed: 525,
|
|
4202
|
+
InvalidSslCertificate: 526,
|
|
4070
4203
|
};
|
|
4071
4204
|
|
|
4072
4205
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
@@ -5950,36 +6083,36 @@ function requireIsRetryAllowed () {
|
|
|
5950
6083
|
var isRetryAllowedExports = requireIsRetryAllowed();
|
|
5951
6084
|
var isRetryAllowed = /*@__PURE__*/getDefaultExportFromCjs(isRetryAllowedExports);
|
|
5952
6085
|
|
|
5953
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6086
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5954
6087
|
|
|
5955
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6088
|
+
function _asyncToGenerator$1(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5956
6089
|
|
|
5957
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6090
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
5958
6091
|
|
|
5959
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6092
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
5960
6093
|
|
|
5961
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5962
|
-
var namespace = 'axios-retry';
|
|
6094
|
+
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6095
|
+
var namespace$1 = 'axios-retry';
|
|
5963
6096
|
/**
|
|
5964
6097
|
* @param {Error} error
|
|
5965
6098
|
* @return {boolean}
|
|
5966
6099
|
*/
|
|
5967
6100
|
|
|
5968
|
-
function isNetworkError(error) {
|
|
6101
|
+
function isNetworkError$1(error) {
|
|
5969
6102
|
var CODE_EXCLUDE_LIST = ['ERR_CANCELED', 'ECONNABORTED'];
|
|
5970
6103
|
return !error.response && Boolean(error.code) && // Prevents retrying cancelled requests
|
|
5971
6104
|
!CODE_EXCLUDE_LIST.includes(error.code) && // Prevents retrying timed out & cancelled requests
|
|
5972
6105
|
isRetryAllowed(error) // Prevents retrying unsafe errors
|
|
5973
6106
|
;
|
|
5974
6107
|
}
|
|
5975
|
-
var SAFE_HTTP_METHODS = ['get', 'head', 'options'];
|
|
5976
|
-
var IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(['put', 'delete']);
|
|
6108
|
+
var SAFE_HTTP_METHODS$1 = ['get', 'head', 'options'];
|
|
6109
|
+
var IDEMPOTENT_HTTP_METHODS$1 = SAFE_HTTP_METHODS$1.concat(['put', 'delete']);
|
|
5977
6110
|
/**
|
|
5978
6111
|
* @param {Error} error
|
|
5979
6112
|
* @return {boolean}
|
|
5980
6113
|
*/
|
|
5981
6114
|
|
|
5982
|
-
function isRetryableError(error) {
|
|
6115
|
+
function isRetryableError$1(error) {
|
|
5983
6116
|
return error.code !== 'ECONNABORTED' && (!error.response || error.response.status >= 500 && error.response.status <= 599);
|
|
5984
6117
|
}
|
|
5985
6118
|
/**
|
|
@@ -5987,40 +6120,40 @@ function isRetryableError(error) {
|
|
|
5987
6120
|
* @return {boolean}
|
|
5988
6121
|
*/
|
|
5989
6122
|
|
|
5990
|
-
function isSafeRequestError(error) {
|
|
6123
|
+
function isSafeRequestError$1(error) {
|
|
5991
6124
|
if (!error.config) {
|
|
5992
6125
|
// Cannot determine if the request can be retried
|
|
5993
6126
|
return false;
|
|
5994
6127
|
}
|
|
5995
6128
|
|
|
5996
|
-
return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
6129
|
+
return isRetryableError$1(error) && SAFE_HTTP_METHODS$1.indexOf(error.config.method) !== -1;
|
|
5997
6130
|
}
|
|
5998
6131
|
/**
|
|
5999
6132
|
* @param {Error} error
|
|
6000
6133
|
* @return {boolean}
|
|
6001
6134
|
*/
|
|
6002
6135
|
|
|
6003
|
-
function isIdempotentRequestError(error) {
|
|
6136
|
+
function isIdempotentRequestError$1(error) {
|
|
6004
6137
|
if (!error.config) {
|
|
6005
6138
|
// Cannot determine if the request can be retried
|
|
6006
6139
|
return false;
|
|
6007
6140
|
}
|
|
6008
6141
|
|
|
6009
|
-
return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
6142
|
+
return isRetryableError$1(error) && IDEMPOTENT_HTTP_METHODS$1.indexOf(error.config.method) !== -1;
|
|
6010
6143
|
}
|
|
6011
6144
|
/**
|
|
6012
6145
|
* @param {Error} error
|
|
6013
6146
|
* @return {boolean}
|
|
6014
6147
|
*/
|
|
6015
6148
|
|
|
6016
|
-
function isNetworkOrIdempotentRequestError(error) {
|
|
6017
|
-
return isNetworkError(error) || isIdempotentRequestError(error);
|
|
6149
|
+
function isNetworkOrIdempotentRequestError$1(error) {
|
|
6150
|
+
return isNetworkError$1(error) || isIdempotentRequestError$1(error);
|
|
6018
6151
|
}
|
|
6019
6152
|
/**
|
|
6020
6153
|
* @return {number} - delay in milliseconds, always 0
|
|
6021
6154
|
*/
|
|
6022
6155
|
|
|
6023
|
-
function noDelay() {
|
|
6156
|
+
function noDelay$1() {
|
|
6024
6157
|
return 0;
|
|
6025
6158
|
}
|
|
6026
6159
|
/**
|
|
@@ -6033,7 +6166,7 @@ function noDelay() {
|
|
|
6033
6166
|
*/
|
|
6034
6167
|
|
|
6035
6168
|
|
|
6036
|
-
function exponentialDelay() {
|
|
6169
|
+
function exponentialDelay$1() {
|
|
6037
6170
|
var retryNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
6038
6171
|
var delayFactor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
|
|
6039
6172
|
var delay = Math.pow(2, retryNumber) * delayFactor;
|
|
@@ -6043,10 +6176,10 @@ function exponentialDelay() {
|
|
|
6043
6176
|
}
|
|
6044
6177
|
/** @type {IAxiosRetryConfig} */
|
|
6045
6178
|
|
|
6046
|
-
var DEFAULT_OPTIONS = {
|
|
6179
|
+
var DEFAULT_OPTIONS$1 = {
|
|
6047
6180
|
retries: 3,
|
|
6048
|
-
retryCondition: isNetworkOrIdempotentRequestError,
|
|
6049
|
-
retryDelay: noDelay,
|
|
6181
|
+
retryCondition: isNetworkOrIdempotentRequestError$1,
|
|
6182
|
+
retryDelay: noDelay$1,
|
|
6050
6183
|
shouldResetTimeout: false,
|
|
6051
6184
|
onRetry: () => {}
|
|
6052
6185
|
};
|
|
@@ -6057,8 +6190,8 @@ var DEFAULT_OPTIONS = {
|
|
|
6057
6190
|
* @return {IAxiosRetryConfigExtended}
|
|
6058
6191
|
*/
|
|
6059
6192
|
|
|
6060
|
-
function getRequestOptions(config, defaultOptions) {
|
|
6061
|
-
return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), defaultOptions), config[namespace]);
|
|
6193
|
+
function getRequestOptions$1(config, defaultOptions) {
|
|
6194
|
+
return _objectSpread$1(_objectSpread$1(_objectSpread$1({}, DEFAULT_OPTIONS$1), defaultOptions), config[namespace$1]);
|
|
6062
6195
|
}
|
|
6063
6196
|
/**
|
|
6064
6197
|
* Initializes and returns the retry state for the given request/config
|
|
@@ -6068,10 +6201,10 @@ function getRequestOptions(config, defaultOptions) {
|
|
|
6068
6201
|
*/
|
|
6069
6202
|
|
|
6070
6203
|
|
|
6071
|
-
function getCurrentState(config, defaultOptions) {
|
|
6072
|
-
var currentState = getRequestOptions(config, defaultOptions);
|
|
6204
|
+
function getCurrentState$1(config, defaultOptions) {
|
|
6205
|
+
var currentState = getRequestOptions$1(config, defaultOptions);
|
|
6073
6206
|
currentState.retryCount = currentState.retryCount || 0;
|
|
6074
|
-
config[namespace] = currentState;
|
|
6207
|
+
config[namespace$1] = currentState;
|
|
6075
6208
|
return currentState;
|
|
6076
6209
|
}
|
|
6077
6210
|
/**
|
|
@@ -6080,7 +6213,7 @@ function getCurrentState(config, defaultOptions) {
|
|
|
6080
6213
|
*/
|
|
6081
6214
|
|
|
6082
6215
|
|
|
6083
|
-
function fixConfig(axios, config) {
|
|
6216
|
+
function fixConfig$1(axios, config) {
|
|
6084
6217
|
if (axios.defaults.agent === config.agent) {
|
|
6085
6218
|
delete config.agent;
|
|
6086
6219
|
}
|
|
@@ -6101,8 +6234,8 @@ function fixConfig(axios, config) {
|
|
|
6101
6234
|
*/
|
|
6102
6235
|
|
|
6103
6236
|
|
|
6104
|
-
function shouldRetry(_x, _x2) {
|
|
6105
|
-
return _shouldRetry.apply(this, arguments);
|
|
6237
|
+
function shouldRetry$1(_x, _x2) {
|
|
6238
|
+
return _shouldRetry$1.apply(this, arguments);
|
|
6106
6239
|
}
|
|
6107
6240
|
/**
|
|
6108
6241
|
* Adds response interceptors to an axios instance to retry requests failed due to network issues
|
|
@@ -6162,8 +6295,8 @@ function shouldRetry(_x, _x2) {
|
|
|
6162
6295
|
*/
|
|
6163
6296
|
|
|
6164
6297
|
|
|
6165
|
-
function _shouldRetry() {
|
|
6166
|
-
_shouldRetry = _asyncToGenerator(function* (currentState, error) {
|
|
6298
|
+
function _shouldRetry$1() {
|
|
6299
|
+
_shouldRetry$1 = _asyncToGenerator$1(function* (currentState, error) {
|
|
6167
6300
|
var {
|
|
6168
6301
|
retries,
|
|
6169
6302
|
retryCondition
|
|
@@ -6182,17 +6315,17 @@ function _shouldRetry() {
|
|
|
6182
6315
|
|
|
6183
6316
|
return shouldRetryOrPromise;
|
|
6184
6317
|
});
|
|
6185
|
-
return _shouldRetry.apply(this, arguments);
|
|
6318
|
+
return _shouldRetry$1.apply(this, arguments);
|
|
6186
6319
|
}
|
|
6187
6320
|
|
|
6188
|
-
function axiosRetry(axios, defaultOptions) {
|
|
6321
|
+
function axiosRetry$1(axios, defaultOptions) {
|
|
6189
6322
|
var requestInterceptorId = axios.interceptors.request.use(config => {
|
|
6190
|
-
var currentState = getCurrentState(config, defaultOptions);
|
|
6323
|
+
var currentState = getCurrentState$1(config, defaultOptions);
|
|
6191
6324
|
currentState.lastRequestTime = Date.now();
|
|
6192
6325
|
return config;
|
|
6193
6326
|
});
|
|
6194
6327
|
var responseInterceptorId = axios.interceptors.response.use(null, /*#__PURE__*/function () {
|
|
6195
|
-
var _ref = _asyncToGenerator(function* (error) {
|
|
6328
|
+
var _ref = _asyncToGenerator$1(function* (error) {
|
|
6196
6329
|
var {
|
|
6197
6330
|
config
|
|
6198
6331
|
} = error; // If we have no information to retry the request
|
|
@@ -6201,9 +6334,9 @@ function axiosRetry(axios, defaultOptions) {
|
|
|
6201
6334
|
return Promise.reject(error);
|
|
6202
6335
|
}
|
|
6203
6336
|
|
|
6204
|
-
var currentState = getCurrentState(config, defaultOptions);
|
|
6337
|
+
var currentState = getCurrentState$1(config, defaultOptions);
|
|
6205
6338
|
|
|
6206
|
-
if (yield shouldRetry(currentState, error)) {
|
|
6339
|
+
if (yield shouldRetry$1(currentState, error)) {
|
|
6207
6340
|
currentState.retryCount += 1;
|
|
6208
6341
|
var {
|
|
6209
6342
|
retryDelay,
|
|
@@ -6213,7 +6346,7 @@ function axiosRetry(axios, defaultOptions) {
|
|
|
6213
6346
|
var delay = retryDelay(currentState.retryCount, error); // Axios fails merging this configuration to the default configuration because it has an issue
|
|
6214
6347
|
// with circular structures: https://github.com/mzabriskie/axios/issues/370
|
|
6215
6348
|
|
|
6216
|
-
fixConfig(axios, config);
|
|
6349
|
+
fixConfig$1(axios, config);
|
|
6217
6350
|
|
|
6218
6351
|
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
|
|
6219
6352
|
var lastRequestDuration = Date.now() - currentState.lastRequestTime;
|
|
@@ -6244,12 +6377,12 @@ function axiosRetry(axios, defaultOptions) {
|
|
|
6244
6377
|
};
|
|
6245
6378
|
} // Compatibility with CommonJS
|
|
6246
6379
|
|
|
6247
|
-
axiosRetry.isNetworkError = isNetworkError;
|
|
6248
|
-
axiosRetry.isSafeRequestError = isSafeRequestError;
|
|
6249
|
-
axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
|
|
6250
|
-
axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
|
|
6251
|
-
axiosRetry.exponentialDelay = exponentialDelay;
|
|
6252
|
-
axiosRetry.isRetryableError = isRetryableError;
|
|
6380
|
+
axiosRetry$1.isNetworkError = isNetworkError$1;
|
|
6381
|
+
axiosRetry$1.isSafeRequestError = isSafeRequestError$1;
|
|
6382
|
+
axiosRetry$1.isIdempotentRequestError = isIdempotentRequestError$1;
|
|
6383
|
+
axiosRetry$1.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError$1;
|
|
6384
|
+
axiosRetry$1.exponentialDelay = exponentialDelay$1;
|
|
6385
|
+
axiosRetry$1.isRetryableError = isRetryableError$1;
|
|
6253
6386
|
|
|
6254
6387
|
/******************************************************************************
|
|
6255
6388
|
Copyright (c) Microsoft Corporation.
|
|
@@ -6313,7 +6446,7 @@ let MidgardApi$1 = class MidgardApi {
|
|
|
6313
6446
|
constructor(network = xchainClient.Network.Mainnet, config) {
|
|
6314
6447
|
this.network = network;
|
|
6315
6448
|
this.config = config !== null && config !== void 0 ? config : defaultMidgardConfig$1[this.network];
|
|
6316
|
-
axiosRetry(axios, { retries: this.config.apiRetries, retryDelay: axiosRetry.exponentialDelay });
|
|
6449
|
+
axiosRetry$1(axios, { retries: this.config.apiRetries, retryDelay: axiosRetry$1.exponentialDelay });
|
|
6317
6450
|
this.midgardClients = this.config.midgardBaseUrls.map((url) => new MidgardApi$2(new Configuration$1({ basePath: url })));
|
|
6318
6451
|
}
|
|
6319
6452
|
/**
|
|
@@ -8740,6 +8873,307 @@ class MidgardApi extends DefaultApi {
|
|
|
8740
8873
|
}
|
|
8741
8874
|
}
|
|
8742
8875
|
|
|
8876
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8877
|
+
|
|
8878
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
8879
|
+
|
|
8880
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8881
|
+
|
|
8882
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8883
|
+
|
|
8884
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8885
|
+
var namespace = 'axios-retry';
|
|
8886
|
+
/**
|
|
8887
|
+
* @param {Error} error
|
|
8888
|
+
* @return {boolean}
|
|
8889
|
+
*/
|
|
8890
|
+
|
|
8891
|
+
function isNetworkError(error) {
|
|
8892
|
+
var CODE_EXCLUDE_LIST = ['ERR_CANCELED', 'ECONNABORTED'];
|
|
8893
|
+
return !error.response && Boolean(error.code) && // Prevents retrying cancelled requests
|
|
8894
|
+
!CODE_EXCLUDE_LIST.includes(error.code) && // Prevents retrying timed out & cancelled requests
|
|
8895
|
+
isRetryAllowed(error) // Prevents retrying unsafe errors
|
|
8896
|
+
;
|
|
8897
|
+
}
|
|
8898
|
+
var SAFE_HTTP_METHODS = ['get', 'head', 'options'];
|
|
8899
|
+
var IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(['put', 'delete']);
|
|
8900
|
+
/**
|
|
8901
|
+
* @param {Error} error
|
|
8902
|
+
* @return {boolean}
|
|
8903
|
+
*/
|
|
8904
|
+
|
|
8905
|
+
function isRetryableError(error) {
|
|
8906
|
+
return error.code !== 'ECONNABORTED' && (!error.response || error.response.status >= 500 && error.response.status <= 599);
|
|
8907
|
+
}
|
|
8908
|
+
/**
|
|
8909
|
+
* @param {Error} error
|
|
8910
|
+
* @return {boolean}
|
|
8911
|
+
*/
|
|
8912
|
+
|
|
8913
|
+
function isSafeRequestError(error) {
|
|
8914
|
+
if (!error.config) {
|
|
8915
|
+
// Cannot determine if the request can be retried
|
|
8916
|
+
return false;
|
|
8917
|
+
}
|
|
8918
|
+
|
|
8919
|
+
return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
8920
|
+
}
|
|
8921
|
+
/**
|
|
8922
|
+
* @param {Error} error
|
|
8923
|
+
* @return {boolean}
|
|
8924
|
+
*/
|
|
8925
|
+
|
|
8926
|
+
function isIdempotentRequestError(error) {
|
|
8927
|
+
if (!error.config) {
|
|
8928
|
+
// Cannot determine if the request can be retried
|
|
8929
|
+
return false;
|
|
8930
|
+
}
|
|
8931
|
+
|
|
8932
|
+
return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
|
|
8933
|
+
}
|
|
8934
|
+
/**
|
|
8935
|
+
* @param {Error} error
|
|
8936
|
+
* @return {boolean}
|
|
8937
|
+
*/
|
|
8938
|
+
|
|
8939
|
+
function isNetworkOrIdempotentRequestError(error) {
|
|
8940
|
+
return isNetworkError(error) || isIdempotentRequestError(error);
|
|
8941
|
+
}
|
|
8942
|
+
/**
|
|
8943
|
+
* @return {number} - delay in milliseconds, always 0
|
|
8944
|
+
*/
|
|
8945
|
+
|
|
8946
|
+
function noDelay() {
|
|
8947
|
+
return 0;
|
|
8948
|
+
}
|
|
8949
|
+
/**
|
|
8950
|
+
* Set delayFactor 1000 for an exponential delay to occur on the order
|
|
8951
|
+
* of seconds
|
|
8952
|
+
* @param {number} [retryNumber=0]
|
|
8953
|
+
* @param {Error} error - unused; for existing API of retryDelay callback
|
|
8954
|
+
* @param {number} [delayFactor=100] milliseconds
|
|
8955
|
+
* @return {number} - delay in milliseconds
|
|
8956
|
+
*/
|
|
8957
|
+
|
|
8958
|
+
|
|
8959
|
+
function exponentialDelay() {
|
|
8960
|
+
var retryNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
8961
|
+
var delayFactor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
|
|
8962
|
+
var delay = Math.pow(2, retryNumber) * delayFactor;
|
|
8963
|
+
var randomSum = delay * 0.2 * Math.random(); // 0-20% of the delay
|
|
8964
|
+
|
|
8965
|
+
return delay + randomSum;
|
|
8966
|
+
}
|
|
8967
|
+
/** @type {IAxiosRetryConfig} */
|
|
8968
|
+
|
|
8969
|
+
var DEFAULT_OPTIONS = {
|
|
8970
|
+
retries: 3,
|
|
8971
|
+
retryCondition: isNetworkOrIdempotentRequestError,
|
|
8972
|
+
retryDelay: noDelay,
|
|
8973
|
+
shouldResetTimeout: false,
|
|
8974
|
+
onRetry: () => {}
|
|
8975
|
+
};
|
|
8976
|
+
/**
|
|
8977
|
+
* Returns the axios-retry options for the current request
|
|
8978
|
+
* @param {AxiosRequestConfig} config
|
|
8979
|
+
* @param {IAxiosRetryConfig} defaultOptions
|
|
8980
|
+
* @return {IAxiosRetryConfigExtended}
|
|
8981
|
+
*/
|
|
8982
|
+
|
|
8983
|
+
function getRequestOptions(config, defaultOptions) {
|
|
8984
|
+
return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), defaultOptions), config[namespace]);
|
|
8985
|
+
}
|
|
8986
|
+
/**
|
|
8987
|
+
* Initializes and returns the retry state for the given request/config
|
|
8988
|
+
* @param {AxiosRequestConfig} config
|
|
8989
|
+
* @param {IAxiosRetryConfig} defaultOptions
|
|
8990
|
+
* @return {IAxiosRetryConfigExtended}
|
|
8991
|
+
*/
|
|
8992
|
+
|
|
8993
|
+
|
|
8994
|
+
function getCurrentState(config, defaultOptions) {
|
|
8995
|
+
var currentState = getRequestOptions(config, defaultOptions);
|
|
8996
|
+
currentState.retryCount = currentState.retryCount || 0;
|
|
8997
|
+
config[namespace] = currentState;
|
|
8998
|
+
return currentState;
|
|
8999
|
+
}
|
|
9000
|
+
/**
|
|
9001
|
+
* @param {Axios} axios
|
|
9002
|
+
* @param {AxiosRequestConfig} config
|
|
9003
|
+
*/
|
|
9004
|
+
|
|
9005
|
+
|
|
9006
|
+
function fixConfig(axios, config) {
|
|
9007
|
+
if (axios.defaults.agent === config.agent) {
|
|
9008
|
+
delete config.agent;
|
|
9009
|
+
}
|
|
9010
|
+
|
|
9011
|
+
if (axios.defaults.httpAgent === config.httpAgent) {
|
|
9012
|
+
delete config.httpAgent;
|
|
9013
|
+
}
|
|
9014
|
+
|
|
9015
|
+
if (axios.defaults.httpsAgent === config.httpsAgent) {
|
|
9016
|
+
delete config.httpsAgent;
|
|
9017
|
+
}
|
|
9018
|
+
}
|
|
9019
|
+
/**
|
|
9020
|
+
* Checks retryCondition if request can be retried. Handles it's returning value or Promise.
|
|
9021
|
+
* @param {IAxiosRetryConfigExtended} currentState
|
|
9022
|
+
* @param {Error} error
|
|
9023
|
+
* @return {Promise<boolean>}
|
|
9024
|
+
*/
|
|
9025
|
+
|
|
9026
|
+
|
|
9027
|
+
function shouldRetry(_x, _x2) {
|
|
9028
|
+
return _shouldRetry.apply(this, arguments);
|
|
9029
|
+
}
|
|
9030
|
+
/**
|
|
9031
|
+
* Adds response interceptors to an axios instance to retry requests failed due to network issues
|
|
9032
|
+
*
|
|
9033
|
+
* @example
|
|
9034
|
+
*
|
|
9035
|
+
* import axios from 'axios';
|
|
9036
|
+
*
|
|
9037
|
+
* axiosRetry(axios, { retries: 3 });
|
|
9038
|
+
*
|
|
9039
|
+
* axios.get('http://example.com/test') // The first request fails and the second returns 'ok'
|
|
9040
|
+
* .then(result => {
|
|
9041
|
+
* result.data; // 'ok'
|
|
9042
|
+
* });
|
|
9043
|
+
*
|
|
9044
|
+
* // Exponential back-off retry delay between requests
|
|
9045
|
+
* axiosRetry(axios, { retryDelay : axiosRetry.exponentialDelay});
|
|
9046
|
+
*
|
|
9047
|
+
* // Custom retry delay
|
|
9048
|
+
* axiosRetry(axios, { retryDelay : (retryCount) => {
|
|
9049
|
+
* return retryCount * 1000;
|
|
9050
|
+
* }});
|
|
9051
|
+
*
|
|
9052
|
+
* // Also works with custom axios instances
|
|
9053
|
+
* const client = axios.create({ baseURL: 'http://example.com' });
|
|
9054
|
+
* axiosRetry(client, { retries: 3 });
|
|
9055
|
+
*
|
|
9056
|
+
* client.get('/test') // The first request fails and the second returns 'ok'
|
|
9057
|
+
* .then(result => {
|
|
9058
|
+
* result.data; // 'ok'
|
|
9059
|
+
* });
|
|
9060
|
+
*
|
|
9061
|
+
* // Allows request-specific configuration
|
|
9062
|
+
* client
|
|
9063
|
+
* .get('/test', {
|
|
9064
|
+
* 'axios-retry': {
|
|
9065
|
+
* retries: 0
|
|
9066
|
+
* }
|
|
9067
|
+
* })
|
|
9068
|
+
* .catch(error => { // The first request fails
|
|
9069
|
+
* error !== undefined
|
|
9070
|
+
* });
|
|
9071
|
+
*
|
|
9072
|
+
* @param {Axios} axios An axios instance (the axios object or one created from axios.create)
|
|
9073
|
+
* @param {Object} [defaultOptions]
|
|
9074
|
+
* @param {number} [defaultOptions.retries=3] Number of retries
|
|
9075
|
+
* @param {boolean} [defaultOptions.shouldResetTimeout=false]
|
|
9076
|
+
* Defines if the timeout should be reset between retries
|
|
9077
|
+
* @param {Function} [defaultOptions.retryCondition=isNetworkOrIdempotentRequestError]
|
|
9078
|
+
* A function to determine if the error can be retried
|
|
9079
|
+
* @param {Function} [defaultOptions.retryDelay=noDelay]
|
|
9080
|
+
* A function to determine the delay between retry requests
|
|
9081
|
+
* @param {Function} [defaultOptions.onRetry=()=>{}]
|
|
9082
|
+
* A function to get notified when a retry occurs
|
|
9083
|
+
* @return {{ requestInterceptorId: number, responseInterceptorId: number }}
|
|
9084
|
+
* The ids of the interceptors added to the request and to the response (so they can be ejected at a later time)
|
|
9085
|
+
*/
|
|
9086
|
+
|
|
9087
|
+
|
|
9088
|
+
function _shouldRetry() {
|
|
9089
|
+
_shouldRetry = _asyncToGenerator(function* (currentState, error) {
|
|
9090
|
+
var {
|
|
9091
|
+
retries,
|
|
9092
|
+
retryCondition
|
|
9093
|
+
} = currentState;
|
|
9094
|
+
var shouldRetryOrPromise = currentState.retryCount < retries && retryCondition(error); // This could be a promise
|
|
9095
|
+
|
|
9096
|
+
if (typeof shouldRetryOrPromise === 'object') {
|
|
9097
|
+
try {
|
|
9098
|
+
var shouldRetryPromiseResult = yield shouldRetryOrPromise; // keep return true unless shouldRetryPromiseResult return false for compatibility
|
|
9099
|
+
|
|
9100
|
+
return shouldRetryPromiseResult !== false;
|
|
9101
|
+
} catch (_err) {
|
|
9102
|
+
return false;
|
|
9103
|
+
}
|
|
9104
|
+
}
|
|
9105
|
+
|
|
9106
|
+
return shouldRetryOrPromise;
|
|
9107
|
+
});
|
|
9108
|
+
return _shouldRetry.apply(this, arguments);
|
|
9109
|
+
}
|
|
9110
|
+
|
|
9111
|
+
function axiosRetry(axios, defaultOptions) {
|
|
9112
|
+
var requestInterceptorId = axios.interceptors.request.use(config => {
|
|
9113
|
+
var currentState = getCurrentState(config, defaultOptions);
|
|
9114
|
+
currentState.lastRequestTime = Date.now();
|
|
9115
|
+
return config;
|
|
9116
|
+
});
|
|
9117
|
+
var responseInterceptorId = axios.interceptors.response.use(null, /*#__PURE__*/function () {
|
|
9118
|
+
var _ref = _asyncToGenerator(function* (error) {
|
|
9119
|
+
var {
|
|
9120
|
+
config
|
|
9121
|
+
} = error; // If we have no information to retry the request
|
|
9122
|
+
|
|
9123
|
+
if (!config) {
|
|
9124
|
+
return Promise.reject(error);
|
|
9125
|
+
}
|
|
9126
|
+
|
|
9127
|
+
var currentState = getCurrentState(config, defaultOptions);
|
|
9128
|
+
|
|
9129
|
+
if (yield shouldRetry(currentState, error)) {
|
|
9130
|
+
currentState.retryCount += 1;
|
|
9131
|
+
var {
|
|
9132
|
+
retryDelay,
|
|
9133
|
+
shouldResetTimeout,
|
|
9134
|
+
onRetry
|
|
9135
|
+
} = currentState;
|
|
9136
|
+
var delay = retryDelay(currentState.retryCount, error); // Axios fails merging this configuration to the default configuration because it has an issue
|
|
9137
|
+
// with circular structures: https://github.com/mzabriskie/axios/issues/370
|
|
9138
|
+
|
|
9139
|
+
fixConfig(axios, config);
|
|
9140
|
+
|
|
9141
|
+
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
|
|
9142
|
+
var lastRequestDuration = Date.now() - currentState.lastRequestTime;
|
|
9143
|
+
var timeout = config.timeout - lastRequestDuration - delay;
|
|
9144
|
+
|
|
9145
|
+
if (timeout <= 0) {
|
|
9146
|
+
return Promise.reject(error);
|
|
9147
|
+
}
|
|
9148
|
+
|
|
9149
|
+
config.timeout = timeout;
|
|
9150
|
+
}
|
|
9151
|
+
|
|
9152
|
+
config.transformRequest = [data => data];
|
|
9153
|
+
yield onRetry(currentState.retryCount, error, config);
|
|
9154
|
+
return new Promise(resolve => setTimeout(() => resolve(axios(config)), delay));
|
|
9155
|
+
}
|
|
9156
|
+
|
|
9157
|
+
return Promise.reject(error);
|
|
9158
|
+
});
|
|
9159
|
+
|
|
9160
|
+
return function (_x3) {
|
|
9161
|
+
return _ref.apply(this, arguments);
|
|
9162
|
+
};
|
|
9163
|
+
}());
|
|
9164
|
+
return {
|
|
9165
|
+
requestInterceptorId,
|
|
9166
|
+
responseInterceptorId
|
|
9167
|
+
};
|
|
9168
|
+
} // Compatibility with CommonJS
|
|
9169
|
+
|
|
9170
|
+
axiosRetry.isNetworkError = isNetworkError;
|
|
9171
|
+
axiosRetry.isSafeRequestError = isSafeRequestError;
|
|
9172
|
+
axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
|
|
9173
|
+
axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
|
|
9174
|
+
axiosRetry.exponentialDelay = exponentialDelay;
|
|
9175
|
+
axiosRetry.isRetryableError = isRetryableError;
|
|
9176
|
+
|
|
8743
9177
|
/******************************************************************************
|
|
8744
9178
|
Copyright (c) Microsoft Corporation.
|
|
8745
9179
|
|