@xchainjs/xchain-aggregator 2.3.1 → 2.3.3
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/const.d.ts +1 -1
- package/lib/index.esm.js +1426 -801
- package/lib/index.js +1425 -800
- package/lib/protocols/oneclick/api.d.ts +8 -0
- package/lib/protocols/oneclick/index.d.ts +1 -0
- package/lib/protocols/oneclick/oneclickProtocol.d.ts +19 -0
- package/lib/protocols/oneclick/types.d.ts +41 -0
- package/lib/protocols/oneclick/utils.d.ts +11 -0
- package/lib/types.d.ts +6 -1
- package/package.json +17 -17
package/lib/index.js
CHANGED
|
@@ -42,7 +42,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
42
42
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const SupportedProtocols = ['Thorchain', 'Mayachain', 'Chainflip'];
|
|
45
|
+
const SupportedProtocols = ['Thorchain', 'Mayachain', 'Chainflip', 'OneClick'];
|
|
46
46
|
const DEFAULT_CONFIG = {
|
|
47
47
|
protocols: SupportedProtocols,
|
|
48
48
|
network: xchainClient.Network.Mainnet,
|
|
@@ -352,7 +352,7 @@ const { isArray } = Array;
|
|
|
352
352
|
*
|
|
353
353
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
354
354
|
*/
|
|
355
|
-
const isUndefined = typeOfTest(
|
|
355
|
+
const isUndefined = typeOfTest('undefined');
|
|
356
356
|
|
|
357
357
|
/**
|
|
358
358
|
* Determine if a value is a Buffer
|
|
@@ -379,7 +379,7 @@ function isBuffer(val) {
|
|
|
379
379
|
*
|
|
380
380
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
381
381
|
*/
|
|
382
|
-
const isArrayBuffer = kindOfTest(
|
|
382
|
+
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
383
383
|
|
|
384
384
|
/**
|
|
385
385
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -390,7 +390,7 @@ const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
|
390
390
|
*/
|
|
391
391
|
function isArrayBufferView(val) {
|
|
392
392
|
let result;
|
|
393
|
-
if (typeof ArrayBuffer !==
|
|
393
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
394
394
|
result = ArrayBuffer.isView(val);
|
|
395
395
|
} else {
|
|
396
396
|
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
@@ -405,7 +405,7 @@ function isArrayBufferView(val) {
|
|
|
405
405
|
*
|
|
406
406
|
* @returns {boolean} True if value is a String, otherwise false
|
|
407
407
|
*/
|
|
408
|
-
const isString = typeOfTest(
|
|
408
|
+
const isString = typeOfTest('string');
|
|
409
409
|
|
|
410
410
|
/**
|
|
411
411
|
* Determine if a value is a Function
|
|
@@ -413,7 +413,7 @@ const isString = typeOfTest("string");
|
|
|
413
413
|
* @param {*} val The value to test
|
|
414
414
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
415
415
|
*/
|
|
416
|
-
const isFunction$1 = typeOfTest(
|
|
416
|
+
const isFunction$1 = typeOfTest('function');
|
|
417
417
|
|
|
418
418
|
/**
|
|
419
419
|
* Determine if a value is a Number
|
|
@@ -422,7 +422,7 @@ const isFunction$1 = typeOfTest("function");
|
|
|
422
422
|
*
|
|
423
423
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
424
424
|
*/
|
|
425
|
-
const isNumber = typeOfTest(
|
|
425
|
+
const isNumber = typeOfTest('number');
|
|
426
426
|
|
|
427
427
|
/**
|
|
428
428
|
* Determine if a value is an Object
|
|
@@ -431,7 +431,7 @@ const isNumber = typeOfTest("number");
|
|
|
431
431
|
*
|
|
432
432
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
433
433
|
*/
|
|
434
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
434
|
+
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
437
|
* Determine if a value is a Boolean
|
|
@@ -449,7 +449,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
449
449
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
450
450
|
*/
|
|
451
451
|
const isPlainObject = (val) => {
|
|
452
|
-
if (kindOf(val) !==
|
|
452
|
+
if (kindOf(val) !== 'object') {
|
|
453
453
|
return false;
|
|
454
454
|
}
|
|
455
455
|
|
|
@@ -477,10 +477,7 @@ const isEmptyObject = (val) => {
|
|
|
477
477
|
}
|
|
478
478
|
|
|
479
479
|
try {
|
|
480
|
-
return (
|
|
481
|
-
Object.keys(val).length === 0 &&
|
|
482
|
-
Object.getPrototypeOf(val) === Object.prototype
|
|
483
|
-
);
|
|
480
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
484
481
|
} catch (e) {
|
|
485
482
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
486
483
|
return false;
|
|
@@ -494,7 +491,7 @@ const isEmptyObject = (val) => {
|
|
|
494
491
|
*
|
|
495
492
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
496
493
|
*/
|
|
497
|
-
const isDate = kindOfTest(
|
|
494
|
+
const isDate = kindOfTest('Date');
|
|
498
495
|
|
|
499
496
|
/**
|
|
500
497
|
* Determine if a value is a File
|
|
@@ -503,7 +500,32 @@ const isDate = kindOfTest("Date");
|
|
|
503
500
|
*
|
|
504
501
|
* @returns {boolean} True if value is a File, otherwise false
|
|
505
502
|
*/
|
|
506
|
-
const isFile = kindOfTest(
|
|
503
|
+
const isFile = kindOfTest('File');
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Determine if a value is a React Native Blob
|
|
507
|
+
* React Native "blob": an object with a `uri` attribute. Optionally, it can
|
|
508
|
+
* also have a `name` and `type` attribute to specify filename and content type
|
|
509
|
+
*
|
|
510
|
+
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
511
|
+
*
|
|
512
|
+
* @param {*} value The value to test
|
|
513
|
+
*
|
|
514
|
+
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
515
|
+
*/
|
|
516
|
+
const isReactNativeBlob = (value) => {
|
|
517
|
+
return !!(value && typeof value.uri !== 'undefined');
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Determine if environment is React Native
|
|
522
|
+
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
523
|
+
*
|
|
524
|
+
* @param {*} formData The formData to test
|
|
525
|
+
*
|
|
526
|
+
* @returns {boolean} True if environment is React Native, otherwise false
|
|
527
|
+
*/
|
|
528
|
+
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
507
529
|
|
|
508
530
|
/**
|
|
509
531
|
* Determine if a value is a Blob
|
|
@@ -512,7 +534,7 @@ const isFile = kindOfTest("File");
|
|
|
512
534
|
*
|
|
513
535
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
514
536
|
*/
|
|
515
|
-
const isBlob = kindOfTest(
|
|
537
|
+
const isBlob = kindOfTest('Blob');
|
|
516
538
|
|
|
517
539
|
/**
|
|
518
540
|
* Determine if a value is a FileList
|
|
@@ -521,7 +543,7 @@ const isBlob = kindOfTest("Blob");
|
|
|
521
543
|
*
|
|
522
544
|
* @returns {boolean} True if value is a File, otherwise false
|
|
523
545
|
*/
|
|
524
|
-
const isFileList = kindOfTest(
|
|
546
|
+
const isFileList = kindOfTest('FileList');
|
|
525
547
|
|
|
526
548
|
/**
|
|
527
549
|
* Determine if a value is a Stream
|
|
@@ -539,18 +561,28 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
|
539
561
|
*
|
|
540
562
|
* @returns {boolean} True if value is an FormData, otherwise false
|
|
541
563
|
*/
|
|
564
|
+
function getGlobal() {
|
|
565
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
566
|
+
if (typeof self !== 'undefined') return self;
|
|
567
|
+
if (typeof window !== 'undefined') return window;
|
|
568
|
+
if (typeof global !== 'undefined') return global;
|
|
569
|
+
return {};
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const G = getGlobal();
|
|
573
|
+
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
574
|
+
|
|
542
575
|
const isFormData = (thing) => {
|
|
543
|
-
|
|
544
|
-
return
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
);
|
|
576
|
+
if (!thing) return false;
|
|
577
|
+
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
578
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
|
|
579
|
+
const proto = getPrototypeOf(thing);
|
|
580
|
+
if (!proto || proto === Object.prototype) return false;
|
|
581
|
+
if (!isFunction$1(thing.append)) return false;
|
|
582
|
+
const kind = kindOf(thing);
|
|
583
|
+
return kind === 'formdata' ||
|
|
584
|
+
// detect form-data instance
|
|
585
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]');
|
|
554
586
|
};
|
|
555
587
|
|
|
556
588
|
/**
|
|
@@ -560,13 +592,13 @@ const isFormData = (thing) => {
|
|
|
560
592
|
*
|
|
561
593
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
562
594
|
*/
|
|
563
|
-
const isURLSearchParams = kindOfTest(
|
|
595
|
+
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
564
596
|
|
|
565
597
|
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
598
|
+
'ReadableStream',
|
|
599
|
+
'Request',
|
|
600
|
+
'Response',
|
|
601
|
+
'Headers',
|
|
570
602
|
].map(kindOfTest);
|
|
571
603
|
|
|
572
604
|
/**
|
|
@@ -576,9 +608,9 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
|
576
608
|
*
|
|
577
609
|
* @returns {String} The String freed of excess whitespace
|
|
578
610
|
*/
|
|
579
|
-
const trim = (str) =>
|
|
580
|
-
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
581
|
-
|
|
611
|
+
const trim = (str) => {
|
|
612
|
+
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
613
|
+
};
|
|
582
614
|
/**
|
|
583
615
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
584
616
|
*
|
|
@@ -597,7 +629,7 @@ const trim = (str) =>
|
|
|
597
629
|
*/
|
|
598
630
|
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
599
631
|
// Don't bother if no value provided
|
|
600
|
-
if (obj === null || typeof obj ===
|
|
632
|
+
if (obj === null || typeof obj === 'undefined') {
|
|
601
633
|
return;
|
|
602
634
|
}
|
|
603
635
|
|
|
@@ -605,7 +637,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
605
637
|
let l;
|
|
606
638
|
|
|
607
639
|
// Force an array if not already something iterable
|
|
608
|
-
if (typeof obj !==
|
|
640
|
+
if (typeof obj !== 'object') {
|
|
609
641
|
/*eslint no-param-reassign:0*/
|
|
610
642
|
obj = [obj];
|
|
611
643
|
}
|
|
@@ -622,9 +654,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
622
654
|
}
|
|
623
655
|
|
|
624
656
|
// Iterate over object keys
|
|
625
|
-
const keys = allOwnKeys
|
|
626
|
-
? Object.getOwnPropertyNames(obj)
|
|
627
|
-
: Object.keys(obj);
|
|
657
|
+
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
628
658
|
const len = keys.length;
|
|
629
659
|
let key;
|
|
630
660
|
|
|
@@ -635,6 +665,14 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
635
665
|
}
|
|
636
666
|
}
|
|
637
667
|
|
|
668
|
+
/**
|
|
669
|
+
* Finds a key in an object, case-insensitive, returning the actual key name.
|
|
670
|
+
* Returns null if the object is a Buffer or if no match is found.
|
|
671
|
+
*
|
|
672
|
+
* @param {Object} obj - The object to search.
|
|
673
|
+
* @param {string} key - The key to find (case-insensitive).
|
|
674
|
+
* @returns {?string} The actual key name if found, otherwise null.
|
|
675
|
+
*/
|
|
638
676
|
function findKey(obj, key) {
|
|
639
677
|
if (isBuffer(obj)) {
|
|
640
678
|
return null;
|
|
@@ -655,16 +693,11 @@ function findKey(obj, key) {
|
|
|
655
693
|
|
|
656
694
|
const _global = (() => {
|
|
657
695
|
/*eslint no-undef:0*/
|
|
658
|
-
if (typeof globalThis !==
|
|
659
|
-
return typeof self !==
|
|
660
|
-
? self
|
|
661
|
-
: typeof window !== "undefined"
|
|
662
|
-
? window
|
|
663
|
-
: global;
|
|
696
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
697
|
+
return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
|
|
664
698
|
})();
|
|
665
699
|
|
|
666
|
-
const isContextDefined = (context) =>
|
|
667
|
-
!isUndefined(context) && context !== _global;
|
|
700
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
668
701
|
|
|
669
702
|
/**
|
|
670
703
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -689,7 +722,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
689
722
|
const result = {};
|
|
690
723
|
const assignValue = (val, key) => {
|
|
691
724
|
// Skip dangerous property names to prevent prototype pollution
|
|
692
|
-
if (key ===
|
|
725
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
693
726
|
return;
|
|
694
727
|
}
|
|
695
728
|
|
|
@@ -742,7 +775,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
742
775
|
});
|
|
743
776
|
}
|
|
744
777
|
},
|
|
745
|
-
{ allOwnKeys }
|
|
778
|
+
{ allOwnKeys }
|
|
746
779
|
);
|
|
747
780
|
return a;
|
|
748
781
|
};
|
|
@@ -771,17 +804,14 @@ const stripBOM = (content) => {
|
|
|
771
804
|
* @returns {void}
|
|
772
805
|
*/
|
|
773
806
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
774
|
-
constructor.prototype = Object.create(
|
|
775
|
-
|
|
776
|
-
descriptors,
|
|
777
|
-
);
|
|
778
|
-
Object.defineProperty(constructor.prototype, "constructor", {
|
|
807
|
+
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
808
|
+
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
779
809
|
value: constructor,
|
|
780
810
|
writable: true,
|
|
781
811
|
enumerable: false,
|
|
782
812
|
configurable: true,
|
|
783
813
|
});
|
|
784
|
-
Object.defineProperty(constructor,
|
|
814
|
+
Object.defineProperty(constructor, 'super', {
|
|
785
815
|
value: superConstructor.prototype,
|
|
786
816
|
});
|
|
787
817
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -811,20 +841,13 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
|
811
841
|
i = props.length;
|
|
812
842
|
while (i-- > 0) {
|
|
813
843
|
prop = props[i];
|
|
814
|
-
if (
|
|
815
|
-
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
816
|
-
!merged[prop]
|
|
817
|
-
) {
|
|
844
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
818
845
|
destObj[prop] = sourceObj[prop];
|
|
819
846
|
merged[prop] = true;
|
|
820
847
|
}
|
|
821
848
|
}
|
|
822
849
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
823
|
-
} while (
|
|
824
|
-
sourceObj &&
|
|
825
|
-
(!filter || filter(sourceObj, destObj)) &&
|
|
826
|
-
sourceObj !== Object.prototype
|
|
827
|
-
);
|
|
850
|
+
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
828
851
|
|
|
829
852
|
return destObj;
|
|
830
853
|
};
|
|
@@ -881,7 +904,7 @@ const isTypedArray = ((TypedArray) => {
|
|
|
881
904
|
return (thing) => {
|
|
882
905
|
return TypedArray && thing instanceof TypedArray;
|
|
883
906
|
};
|
|
884
|
-
})(typeof Uint8Array !==
|
|
907
|
+
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
|
885
908
|
|
|
886
909
|
/**
|
|
887
910
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -924,14 +947,12 @@ const matchAll = (regExp, str) => {
|
|
|
924
947
|
};
|
|
925
948
|
|
|
926
949
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
927
|
-
const isHTMLForm = kindOfTest(
|
|
950
|
+
const isHTMLForm = kindOfTest('HTMLFormElement');
|
|
928
951
|
|
|
929
952
|
const toCamelCase = (str) => {
|
|
930
|
-
return str
|
|
931
|
-
.
|
|
932
|
-
|
|
933
|
-
return p1.toUpperCase() + p2;
|
|
934
|
-
});
|
|
953
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
954
|
+
return p1.toUpperCase() + p2;
|
|
955
|
+
});
|
|
935
956
|
};
|
|
936
957
|
|
|
937
958
|
/* Creating a function that will check if an object has a property. */
|
|
@@ -948,7 +969,7 @@ const hasOwnProperty = (
|
|
|
948
969
|
*
|
|
949
970
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
950
971
|
*/
|
|
951
|
-
const isRegExp = kindOfTest(
|
|
972
|
+
const isRegExp = kindOfTest('RegExp');
|
|
952
973
|
|
|
953
974
|
const reduceDescriptors = (obj, reducer) => {
|
|
954
975
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -972,10 +993,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
972
993
|
const freezeMethods = (obj) => {
|
|
973
994
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
974
995
|
// skip restricted props in strict mode
|
|
975
|
-
if (
|
|
976
|
-
isFunction$1(obj) &&
|
|
977
|
-
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
978
|
-
) {
|
|
996
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
979
997
|
return false;
|
|
980
998
|
}
|
|
981
999
|
|
|
@@ -985,7 +1003,7 @@ const freezeMethods = (obj) => {
|
|
|
985
1003
|
|
|
986
1004
|
descriptor.enumerable = false;
|
|
987
1005
|
|
|
988
|
-
if (
|
|
1006
|
+
if ('writable' in descriptor) {
|
|
989
1007
|
descriptor.writable = false;
|
|
990
1008
|
return;
|
|
991
1009
|
}
|
|
@@ -998,6 +1016,14 @@ const freezeMethods = (obj) => {
|
|
|
998
1016
|
});
|
|
999
1017
|
};
|
|
1000
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* Converts an array or a delimited string into an object set with values as keys and true as values.
|
|
1021
|
+
* Useful for fast membership checks.
|
|
1022
|
+
*
|
|
1023
|
+
* @param {Array|string} arrayOrString - The array or string to convert.
|
|
1024
|
+
* @param {string} delimiter - The delimiter to use if input is a string.
|
|
1025
|
+
* @returns {Object} An object with keys from the array or string, values set to true.
|
|
1026
|
+
*/
|
|
1001
1027
|
const toObjectSet = (arrayOrString, delimiter) => {
|
|
1002
1028
|
const obj = {};
|
|
1003
1029
|
|
|
@@ -1007,9 +1033,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
1007
1033
|
});
|
|
1008
1034
|
};
|
|
1009
1035
|
|
|
1010
|
-
isArray(arrayOrString)
|
|
1011
|
-
? define(arrayOrString)
|
|
1012
|
-
: define(String(arrayOrString).split(delimiter));
|
|
1036
|
+
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
1013
1037
|
|
|
1014
1038
|
return obj;
|
|
1015
1039
|
};
|
|
@@ -1017,9 +1041,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
1017
1041
|
const noop = () => {};
|
|
1018
1042
|
|
|
1019
1043
|
const toFiniteNumber = (value, defaultValue) => {
|
|
1020
|
-
return value != null && Number.isFinite((value = +value))
|
|
1021
|
-
? value
|
|
1022
|
-
: defaultValue;
|
|
1044
|
+
return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
|
|
1023
1045
|
};
|
|
1024
1046
|
|
|
1025
1047
|
/**
|
|
@@ -1033,11 +1055,17 @@ function isSpecCompliantForm(thing) {
|
|
|
1033
1055
|
return !!(
|
|
1034
1056
|
thing &&
|
|
1035
1057
|
isFunction$1(thing.append) &&
|
|
1036
|
-
thing[toStringTag] ===
|
|
1058
|
+
thing[toStringTag] === 'FormData' &&
|
|
1037
1059
|
thing[iterator]
|
|
1038
1060
|
);
|
|
1039
1061
|
}
|
|
1040
1062
|
|
|
1063
|
+
/**
|
|
1064
|
+
* Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
|
|
1065
|
+
*
|
|
1066
|
+
* @param {Object} obj - The object to convert.
|
|
1067
|
+
* @returns {Object} The JSON-compatible object.
|
|
1068
|
+
*/
|
|
1041
1069
|
const toJSONObject = (obj) => {
|
|
1042
1070
|
const stack = new Array(10);
|
|
1043
1071
|
|
|
@@ -1052,7 +1080,7 @@ const toJSONObject = (obj) => {
|
|
|
1052
1080
|
return source;
|
|
1053
1081
|
}
|
|
1054
1082
|
|
|
1055
|
-
if (!(
|
|
1083
|
+
if (!('toJSON' in source)) {
|
|
1056
1084
|
stack[i] = source;
|
|
1057
1085
|
const target = isArray(source) ? [] : {};
|
|
1058
1086
|
|
|
@@ -1073,8 +1101,20 @@ const toJSONObject = (obj) => {
|
|
|
1073
1101
|
return visit(obj, 0);
|
|
1074
1102
|
};
|
|
1075
1103
|
|
|
1076
|
-
|
|
1104
|
+
/**
|
|
1105
|
+
* Determines if a value is an async function.
|
|
1106
|
+
*
|
|
1107
|
+
* @param {*} thing - The value to test.
|
|
1108
|
+
* @returns {boolean} True if value is an async function, otherwise false.
|
|
1109
|
+
*/
|
|
1110
|
+
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
1077
1111
|
|
|
1112
|
+
/**
|
|
1113
|
+
* Determines if a value is thenable (has then and catch methods).
|
|
1114
|
+
*
|
|
1115
|
+
* @param {*} thing - The value to test.
|
|
1116
|
+
* @returns {boolean} True if value is thenable, otherwise false.
|
|
1117
|
+
*/
|
|
1078
1118
|
const isThenable = (thing) =>
|
|
1079
1119
|
thing &&
|
|
1080
1120
|
(isObject(thing) || isFunction$1(thing)) &&
|
|
@@ -1084,6 +1124,14 @@ const isThenable = (thing) =>
|
|
|
1084
1124
|
// original code
|
|
1085
1125
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
1086
1126
|
|
|
1127
|
+
/**
|
|
1128
|
+
* Provides a cross-platform setImmediate implementation.
|
|
1129
|
+
* Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
|
|
1130
|
+
*
|
|
1131
|
+
* @param {boolean} setImmediateSupported - Whether setImmediate is supported.
|
|
1132
|
+
* @param {boolean} postMessageSupported - Whether postMessage is supported.
|
|
1133
|
+
* @returns {Function} A function to schedule a callback asynchronously.
|
|
1134
|
+
*/
|
|
1087
1135
|
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
1088
1136
|
if (setImmediateSupported) {
|
|
1089
1137
|
return setImmediate;
|
|
@@ -1092,27 +1140,33 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
1092
1140
|
return postMessageSupported
|
|
1093
1141
|
? ((token, callbacks) => {
|
|
1094
1142
|
_global.addEventListener(
|
|
1095
|
-
|
|
1143
|
+
'message',
|
|
1096
1144
|
({ source, data }) => {
|
|
1097
1145
|
if (source === _global && data === token) {
|
|
1098
1146
|
callbacks.length && callbacks.shift()();
|
|
1099
1147
|
}
|
|
1100
1148
|
},
|
|
1101
|
-
false
|
|
1149
|
+
false
|
|
1102
1150
|
);
|
|
1103
1151
|
|
|
1104
1152
|
return (cb) => {
|
|
1105
1153
|
callbacks.push(cb);
|
|
1106
|
-
_global.postMessage(token,
|
|
1154
|
+
_global.postMessage(token, '*');
|
|
1107
1155
|
};
|
|
1108
1156
|
})(`axios@${Math.random()}`, [])
|
|
1109
1157
|
: (cb) => setTimeout(cb);
|
|
1110
|
-
})(typeof setImmediate ===
|
|
1158
|
+
})(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
|
|
1111
1159
|
|
|
1160
|
+
/**
|
|
1161
|
+
* Schedules a microtask or asynchronous callback as soon as possible.
|
|
1162
|
+
* Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
|
|
1163
|
+
*
|
|
1164
|
+
* @type {Function}
|
|
1165
|
+
*/
|
|
1112
1166
|
const asap =
|
|
1113
|
-
typeof queueMicrotask !==
|
|
1167
|
+
typeof queueMicrotask !== 'undefined'
|
|
1114
1168
|
? queueMicrotask.bind(_global)
|
|
1115
|
-
: (typeof process !==
|
|
1169
|
+
: (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
|
|
1116
1170
|
|
|
1117
1171
|
// *********************
|
|
1118
1172
|
|
|
@@ -1137,6 +1191,8 @@ var utils$1 = {
|
|
|
1137
1191
|
isUndefined,
|
|
1138
1192
|
isDate,
|
|
1139
1193
|
isFile,
|
|
1194
|
+
isReactNativeBlob,
|
|
1195
|
+
isReactNative,
|
|
1140
1196
|
isBlob,
|
|
1141
1197
|
isRegExp,
|
|
1142
1198
|
isFunction: isFunction$1,
|
|
@@ -1179,57 +1235,74 @@ var utils$1 = {
|
|
|
1179
1235
|
};
|
|
1180
1236
|
|
|
1181
1237
|
let AxiosError$1 = class AxiosError extends Error {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
customProps && Object.assign(axiosError, customProps);
|
|
1187
|
-
return axiosError;
|
|
1188
|
-
}
|
|
1238
|
+
static from(error, code, config, request, response, customProps) {
|
|
1239
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1240
|
+
axiosError.cause = error;
|
|
1241
|
+
axiosError.name = error.name;
|
|
1189
1242
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
* @param {string} message The error message.
|
|
1194
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1195
|
-
* @param {Object} [config] The config.
|
|
1196
|
-
* @param {Object} [request] The request.
|
|
1197
|
-
* @param {Object} [response] The response.
|
|
1198
|
-
*
|
|
1199
|
-
* @returns {Error} The created error.
|
|
1200
|
-
*/
|
|
1201
|
-
constructor(message, code, config, request, response) {
|
|
1202
|
-
super(message);
|
|
1203
|
-
this.name = 'AxiosError';
|
|
1204
|
-
this.isAxiosError = true;
|
|
1205
|
-
code && (this.code = code);
|
|
1206
|
-
config && (this.config = config);
|
|
1207
|
-
request && (this.request = request);
|
|
1208
|
-
if (response) {
|
|
1209
|
-
this.response = response;
|
|
1210
|
-
this.status = response.status;
|
|
1211
|
-
}
|
|
1243
|
+
// Preserve status from the original error if not already set from response
|
|
1244
|
+
if (error.status != null && axiosError.status == null) {
|
|
1245
|
+
axiosError.status = error.status;
|
|
1212
1246
|
}
|
|
1213
1247
|
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1248
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1249
|
+
return axiosError;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1254
|
+
*
|
|
1255
|
+
* @param {string} message The error message.
|
|
1256
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1257
|
+
* @param {Object} [config] The config.
|
|
1258
|
+
* @param {Object} [request] The request.
|
|
1259
|
+
* @param {Object} [response] The response.
|
|
1260
|
+
*
|
|
1261
|
+
* @returns {Error} The created error.
|
|
1262
|
+
*/
|
|
1263
|
+
constructor(message, code, config, request, response) {
|
|
1264
|
+
super(message);
|
|
1265
|
+
|
|
1266
|
+
// Make message enumerable to maintain backward compatibility
|
|
1267
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1268
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1269
|
+
Object.defineProperty(this, 'message', {
|
|
1270
|
+
value: message,
|
|
1271
|
+
enumerable: true,
|
|
1272
|
+
writable: true,
|
|
1273
|
+
configurable: true,
|
|
1274
|
+
});
|
|
1275
|
+
|
|
1276
|
+
this.name = 'AxiosError';
|
|
1277
|
+
this.isAxiosError = true;
|
|
1278
|
+
code && (this.code = code);
|
|
1279
|
+
config && (this.config = config);
|
|
1280
|
+
request && (this.request = request);
|
|
1281
|
+
if (response) {
|
|
1282
|
+
this.response = response;
|
|
1283
|
+
this.status = response.status;
|
|
1232
1284
|
}
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
toJSON() {
|
|
1288
|
+
return {
|
|
1289
|
+
// Standard
|
|
1290
|
+
message: this.message,
|
|
1291
|
+
name: this.name,
|
|
1292
|
+
// Microsoft
|
|
1293
|
+
description: this.description,
|
|
1294
|
+
number: this.number,
|
|
1295
|
+
// Mozilla
|
|
1296
|
+
fileName: this.fileName,
|
|
1297
|
+
lineNumber: this.lineNumber,
|
|
1298
|
+
columnNumber: this.columnNumber,
|
|
1299
|
+
stack: this.stack,
|
|
1300
|
+
// Axios
|
|
1301
|
+
config: utils$1.toJSONObject(this.config),
|
|
1302
|
+
code: this.code,
|
|
1303
|
+
status: this.status,
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1233
1306
|
};
|
|
1234
1307
|
|
|
1235
1308
|
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
@@ -1245,6 +1318,7 @@ AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
|
1245
1318
|
AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
|
|
1246
1319
|
AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1247
1320
|
AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1321
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1248
1322
|
|
|
1249
1323
|
// eslint-disable-next-line strict
|
|
1250
1324
|
var httpAdapter = null;
|
|
@@ -1282,11 +1356,14 @@ function removeBrackets(key) {
|
|
|
1282
1356
|
*/
|
|
1283
1357
|
function renderKey(path, key, dots) {
|
|
1284
1358
|
if (!path) return key;
|
|
1285
|
-
return path
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1359
|
+
return path
|
|
1360
|
+
.concat(key)
|
|
1361
|
+
.map(function each(token, i) {
|
|
1362
|
+
// eslint-disable-next-line no-param-reassign
|
|
1363
|
+
token = removeBrackets(token);
|
|
1364
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1365
|
+
})
|
|
1366
|
+
.join(dots ? '.' : '');
|
|
1290
1367
|
}
|
|
1291
1368
|
|
|
1292
1369
|
/**
|
|
@@ -1336,21 +1413,27 @@ function toFormData$1(obj, formData, options) {
|
|
|
1336
1413
|
formData = formData || new (FormData)();
|
|
1337
1414
|
|
|
1338
1415
|
// eslint-disable-next-line no-param-reassign
|
|
1339
|
-
options = utils$1.toFlatObject(
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1416
|
+
options = utils$1.toFlatObject(
|
|
1417
|
+
options,
|
|
1418
|
+
{
|
|
1419
|
+
metaTokens: true,
|
|
1420
|
+
dots: false,
|
|
1421
|
+
indexes: false,
|
|
1422
|
+
},
|
|
1423
|
+
false,
|
|
1424
|
+
function defined(option, source) {
|
|
1425
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1426
|
+
return !utils$1.isUndefined(source[option]);
|
|
1427
|
+
}
|
|
1428
|
+
);
|
|
1347
1429
|
|
|
1348
1430
|
const metaTokens = options.metaTokens;
|
|
1349
1431
|
// eslint-disable-next-line no-use-before-define
|
|
1350
1432
|
const visitor = options.visitor || defaultVisitor;
|
|
1351
1433
|
const dots = options.dots;
|
|
1352
1434
|
const indexes = options.indexes;
|
|
1353
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1435
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1436
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1354
1437
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1355
1438
|
|
|
1356
1439
|
if (!utils$1.isFunction(visitor)) {
|
|
@@ -1392,6 +1475,11 @@ function toFormData$1(obj, formData, options) {
|
|
|
1392
1475
|
function defaultVisitor(value, key, path) {
|
|
1393
1476
|
let arr = value;
|
|
1394
1477
|
|
|
1478
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
1479
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1480
|
+
return false;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1395
1483
|
if (value && !path && typeof value === 'object') {
|
|
1396
1484
|
if (utils$1.endsWith(key, '{}')) {
|
|
1397
1485
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -1400,17 +1488,22 @@ function toFormData$1(obj, formData, options) {
|
|
|
1400
1488
|
value = JSON.stringify(value);
|
|
1401
1489
|
} else if (
|
|
1402
1490
|
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1403
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1404
|
-
|
|
1491
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1492
|
+
) {
|
|
1405
1493
|
// eslint-disable-next-line no-param-reassign
|
|
1406
1494
|
key = removeBrackets(key);
|
|
1407
1495
|
|
|
1408
1496
|
arr.forEach(function each(el, index) {
|
|
1409
|
-
!(utils$1.isUndefined(el) || el === null) &&
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1497
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1498
|
+
formData.append(
|
|
1499
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1500
|
+
indexes === true
|
|
1501
|
+
? renderKey([key], index, dots)
|
|
1502
|
+
: indexes === null
|
|
1503
|
+
? key
|
|
1504
|
+
: key + '[]',
|
|
1505
|
+
convertValue(el)
|
|
1506
|
+
);
|
|
1414
1507
|
});
|
|
1415
1508
|
return false;
|
|
1416
1509
|
}
|
|
@@ -1430,12 +1523,19 @@ function toFormData$1(obj, formData, options) {
|
|
|
1430
1523
|
const exposedHelpers = Object.assign(predicates, {
|
|
1431
1524
|
defaultVisitor,
|
|
1432
1525
|
convertValue,
|
|
1433
|
-
isVisitable
|
|
1526
|
+
isVisitable,
|
|
1434
1527
|
});
|
|
1435
1528
|
|
|
1436
|
-
function build(value, path) {
|
|
1529
|
+
function build(value, path, depth = 0) {
|
|
1437
1530
|
if (utils$1.isUndefined(value)) return;
|
|
1438
1531
|
|
|
1532
|
+
if (depth > maxDepth) {
|
|
1533
|
+
throw new AxiosError$1(
|
|
1534
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1535
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1439
1539
|
if (stack.indexOf(value) !== -1) {
|
|
1440
1540
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1441
1541
|
}
|
|
@@ -1443,12 +1543,12 @@ function toFormData$1(obj, formData, options) {
|
|
|
1443
1543
|
stack.push(value);
|
|
1444
1544
|
|
|
1445
1545
|
utils$1.forEach(value, function each(el, key) {
|
|
1446
|
-
const result =
|
|
1447
|
-
|
|
1448
|
-
|
|
1546
|
+
const result =
|
|
1547
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1548
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1449
1549
|
|
|
1450
1550
|
if (result === true) {
|
|
1451
|
-
build(el, path ? path.concat(key) : [key]);
|
|
1551
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
1452
1552
|
}
|
|
1453
1553
|
});
|
|
1454
1554
|
|
|
@@ -1480,9 +1580,8 @@ function encode$1(str) {
|
|
|
1480
1580
|
')': '%29',
|
|
1481
1581
|
'~': '%7E',
|
|
1482
1582
|
'%20': '+',
|
|
1483
|
-
'%00': '\x00'
|
|
1484
1583
|
};
|
|
1485
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20
|
|
1584
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1486
1585
|
return charMap[match];
|
|
1487
1586
|
});
|
|
1488
1587
|
}
|
|
@@ -1508,29 +1607,33 @@ prototype.append = function append(name, value) {
|
|
|
1508
1607
|
};
|
|
1509
1608
|
|
|
1510
1609
|
prototype.toString = function toString(encoder) {
|
|
1511
|
-
const _encode = encoder
|
|
1512
|
-
|
|
1513
|
-
|
|
1610
|
+
const _encode = encoder
|
|
1611
|
+
? function (value) {
|
|
1612
|
+
return encoder.call(this, value, encode$1);
|
|
1613
|
+
}
|
|
1614
|
+
: encode$1;
|
|
1514
1615
|
|
|
1515
|
-
return this._pairs
|
|
1516
|
-
|
|
1517
|
-
|
|
1616
|
+
return this._pairs
|
|
1617
|
+
.map(function each(pair) {
|
|
1618
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1619
|
+
}, '')
|
|
1620
|
+
.join('&');
|
|
1518
1621
|
};
|
|
1519
1622
|
|
|
1520
1623
|
/**
|
|
1521
|
-
* It replaces
|
|
1522
|
-
*
|
|
1624
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1625
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1523
1626
|
*
|
|
1524
1627
|
* @param {string} val The value to be encoded.
|
|
1525
1628
|
*
|
|
1526
1629
|
* @returns {string} The encoded value.
|
|
1527
1630
|
*/
|
|
1528
1631
|
function encode(val) {
|
|
1529
|
-
return encodeURIComponent(val)
|
|
1530
|
-
replace(/%3A/gi, ':')
|
|
1531
|
-
replace(/%24/g, '$')
|
|
1532
|
-
replace(/%2C/gi, ',')
|
|
1533
|
-
replace(/%20/g, '+');
|
|
1632
|
+
return encodeURIComponent(val)
|
|
1633
|
+
.replace(/%3A/gi, ':')
|
|
1634
|
+
.replace(/%24/g, '$')
|
|
1635
|
+
.replace(/%2C/gi, ',')
|
|
1636
|
+
.replace(/%20/g, '+');
|
|
1534
1637
|
}
|
|
1535
1638
|
|
|
1536
1639
|
/**
|
|
@@ -1547,11 +1650,13 @@ function buildURL(url, params, options) {
|
|
|
1547
1650
|
return url;
|
|
1548
1651
|
}
|
|
1549
1652
|
|
|
1550
|
-
const _encode = options && options.encode || encode;
|
|
1653
|
+
const _encode = (options && options.encode) || encode;
|
|
1551
1654
|
|
|
1552
|
-
const _options = utils$1.isFunction(options)
|
|
1553
|
-
|
|
1554
|
-
|
|
1655
|
+
const _options = utils$1.isFunction(options)
|
|
1656
|
+
? {
|
|
1657
|
+
serialize: options,
|
|
1658
|
+
}
|
|
1659
|
+
: options;
|
|
1555
1660
|
|
|
1556
1661
|
const serializeFn = _options && _options.serialize;
|
|
1557
1662
|
|
|
@@ -1560,13 +1665,13 @@ function buildURL(url, params, options) {
|
|
|
1560
1665
|
if (serializeFn) {
|
|
1561
1666
|
serializedParams = serializeFn(params, _options);
|
|
1562
1667
|
} else {
|
|
1563
|
-
serializedParams = utils$1.isURLSearchParams(params)
|
|
1564
|
-
params.toString()
|
|
1565
|
-
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1668
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
1669
|
+
? params.toString()
|
|
1670
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1566
1671
|
}
|
|
1567
1672
|
|
|
1568
1673
|
if (serializedParams) {
|
|
1569
|
-
const hashmarkIndex = url.indexOf(
|
|
1674
|
+
const hashmarkIndex = url.indexOf('#');
|
|
1570
1675
|
|
|
1571
1676
|
if (hashmarkIndex !== -1) {
|
|
1572
1677
|
url = url.slice(0, hashmarkIndex);
|
|
@@ -1596,7 +1701,7 @@ class InterceptorManager {
|
|
|
1596
1701
|
fulfilled,
|
|
1597
1702
|
rejected,
|
|
1598
1703
|
synchronous: options ? options.synchronous : false,
|
|
1599
|
-
runWhen: options ? options.runWhen : null
|
|
1704
|
+
runWhen: options ? options.runWhen : null,
|
|
1600
1705
|
});
|
|
1601
1706
|
return this.handlers.length - 1;
|
|
1602
1707
|
}
|
|
@@ -1648,7 +1753,7 @@ var transitionalDefaults = {
|
|
|
1648
1753
|
silentJSONParsing: true,
|
|
1649
1754
|
forcedJSONParsing: true,
|
|
1650
1755
|
clarifyTimeoutError: false,
|
|
1651
|
-
legacyInterceptorReqResOrdering: true
|
|
1756
|
+
legacyInterceptorReqResOrdering: true,
|
|
1652
1757
|
};
|
|
1653
1758
|
|
|
1654
1759
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -1662,14 +1767,14 @@ var platform$1 = {
|
|
|
1662
1767
|
classes: {
|
|
1663
1768
|
URLSearchParams: URLSearchParams$1,
|
|
1664
1769
|
FormData: FormData$1,
|
|
1665
|
-
Blob: Blob$1
|
|
1770
|
+
Blob: Blob$1,
|
|
1666
1771
|
},
|
|
1667
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1772
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
1668
1773
|
};
|
|
1669
1774
|
|
|
1670
1775
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1671
1776
|
|
|
1672
|
-
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
1777
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
1673
1778
|
|
|
1674
1779
|
/**
|
|
1675
1780
|
* Determine if we're running in a standard browser environment
|
|
@@ -1688,7 +1793,8 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
|
1688
1793
|
*
|
|
1689
1794
|
* @returns {boolean}
|
|
1690
1795
|
*/
|
|
1691
|
-
const hasStandardBrowserEnv =
|
|
1796
|
+
const hasStandardBrowserEnv =
|
|
1797
|
+
hasBrowserEnv &&
|
|
1692
1798
|
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1693
1799
|
|
|
1694
1800
|
/**
|
|
@@ -1709,7 +1815,7 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
1709
1815
|
);
|
|
1710
1816
|
})();
|
|
1711
1817
|
|
|
1712
|
-
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1818
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
1713
1819
|
|
|
1714
1820
|
var utils = /*#__PURE__*/Object.freeze({
|
|
1715
1821
|
__proto__: null,
|
|
@@ -1722,12 +1828,12 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
1722
1828
|
|
|
1723
1829
|
var platform = {
|
|
1724
1830
|
...utils,
|
|
1725
|
-
...platform$1
|
|
1831
|
+
...platform$1,
|
|
1726
1832
|
};
|
|
1727
1833
|
|
|
1728
1834
|
function toURLEncodedForm(data, options) {
|
|
1729
1835
|
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
1730
|
-
visitor: function(value, key, path, helpers) {
|
|
1836
|
+
visitor: function (value, key, path, helpers) {
|
|
1731
1837
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1732
1838
|
this.append(key, value.toString('base64'));
|
|
1733
1839
|
return false;
|
|
@@ -1735,7 +1841,7 @@ function toURLEncodedForm(data, options) {
|
|
|
1735
1841
|
|
|
1736
1842
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
1737
1843
|
},
|
|
1738
|
-
...options
|
|
1844
|
+
...options,
|
|
1739
1845
|
});
|
|
1740
1846
|
}
|
|
1741
1847
|
|
|
@@ -1751,7 +1857,7 @@ function parsePropPath(name) {
|
|
|
1751
1857
|
// foo.x.y.z
|
|
1752
1858
|
// foo-x-y-z
|
|
1753
1859
|
// foo x y z
|
|
1754
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1860
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
1755
1861
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1756
1862
|
});
|
|
1757
1863
|
}
|
|
@@ -1795,7 +1901,9 @@ function formDataToJSON(formData) {
|
|
|
1795
1901
|
|
|
1796
1902
|
if (isLast) {
|
|
1797
1903
|
if (utils$1.hasOwnProp(target, name)) {
|
|
1798
|
-
target[name] =
|
|
1904
|
+
target[name] = utils$1.isArray(target[name])
|
|
1905
|
+
? target[name].concat(value)
|
|
1906
|
+
: [target[name], value];
|
|
1799
1907
|
} else {
|
|
1800
1908
|
target[name] = value;
|
|
1801
1909
|
}
|
|
@@ -1829,6 +1937,8 @@ function formDataToJSON(formData) {
|
|
|
1829
1937
|
return null;
|
|
1830
1938
|
}
|
|
1831
1939
|
|
|
1940
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
1941
|
+
|
|
1832
1942
|
/**
|
|
1833
1943
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1834
1944
|
* of the input
|
|
@@ -1855,96 +1965,110 @@ function stringifySafely(rawValue, parser, encoder) {
|
|
|
1855
1965
|
}
|
|
1856
1966
|
|
|
1857
1967
|
const defaults = {
|
|
1858
|
-
|
|
1859
1968
|
transitional: transitionalDefaults,
|
|
1860
1969
|
|
|
1861
1970
|
adapter: ['xhr', 'http', 'fetch'],
|
|
1862
1971
|
|
|
1863
|
-
transformRequest: [
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1869
|
-
data = new FormData(data);
|
|
1870
|
-
}
|
|
1972
|
+
transformRequest: [
|
|
1973
|
+
function transformRequest(data, headers) {
|
|
1974
|
+
const contentType = headers.getContentType() || '';
|
|
1975
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1976
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1871
1977
|
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1876
|
-
}
|
|
1978
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1979
|
+
data = new FormData(data);
|
|
1980
|
+
}
|
|
1877
1981
|
|
|
1878
|
-
|
|
1879
|
-
utils$1.isBuffer(data) ||
|
|
1880
|
-
utils$1.isStream(data) ||
|
|
1881
|
-
utils$1.isFile(data) ||
|
|
1882
|
-
utils$1.isBlob(data) ||
|
|
1883
|
-
utils$1.isReadableStream(data)
|
|
1884
|
-
) {
|
|
1885
|
-
return data;
|
|
1886
|
-
}
|
|
1887
|
-
if (utils$1.isArrayBufferView(data)) {
|
|
1888
|
-
return data.buffer;
|
|
1889
|
-
}
|
|
1890
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
1891
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1892
|
-
return data.toString();
|
|
1893
|
-
}
|
|
1982
|
+
const isFormData = utils$1.isFormData(data);
|
|
1894
1983
|
|
|
1895
|
-
|
|
1984
|
+
if (isFormData) {
|
|
1985
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1986
|
+
}
|
|
1896
1987
|
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1988
|
+
if (
|
|
1989
|
+
utils$1.isArrayBuffer(data) ||
|
|
1990
|
+
utils$1.isBuffer(data) ||
|
|
1991
|
+
utils$1.isStream(data) ||
|
|
1992
|
+
utils$1.isFile(data) ||
|
|
1993
|
+
utils$1.isBlob(data) ||
|
|
1994
|
+
utils$1.isReadableStream(data)
|
|
1995
|
+
) {
|
|
1996
|
+
return data;
|
|
1997
|
+
}
|
|
1998
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
1999
|
+
return data.buffer;
|
|
2000
|
+
}
|
|
2001
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
2002
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
2003
|
+
return data.toString();
|
|
1900
2004
|
}
|
|
1901
2005
|
|
|
1902
|
-
|
|
1903
|
-
const _FormData = this.env && this.env.FormData;
|
|
2006
|
+
let isFileList;
|
|
1904
2007
|
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
2008
|
+
if (isObjectPayload) {
|
|
2009
|
+
const formSerializer = own(this, 'formSerializer');
|
|
2010
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
2011
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
if (
|
|
2015
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
2016
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
2017
|
+
) {
|
|
2018
|
+
const env = own(this, 'env');
|
|
2019
|
+
const _FormData = env && env.FormData;
|
|
2020
|
+
|
|
2021
|
+
return toFormData$1(
|
|
2022
|
+
isFileList ? { 'files[]': data } : data,
|
|
2023
|
+
_FormData && new _FormData(),
|
|
2024
|
+
formSerializer
|
|
2025
|
+
);
|
|
2026
|
+
}
|
|
1910
2027
|
}
|
|
1911
|
-
}
|
|
1912
2028
|
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
2029
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
2030
|
+
headers.setContentType('application/json', false);
|
|
2031
|
+
return stringifySafely(data);
|
|
2032
|
+
}
|
|
1917
2033
|
|
|
1918
|
-
|
|
1919
|
-
|
|
2034
|
+
return data;
|
|
2035
|
+
},
|
|
2036
|
+
],
|
|
1920
2037
|
|
|
1921
|
-
transformResponse: [
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
2038
|
+
transformResponse: [
|
|
2039
|
+
function transformResponse(data) {
|
|
2040
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
2041
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
2042
|
+
const responseType = own(this, 'responseType');
|
|
2043
|
+
const JSONRequested = responseType === 'json';
|
|
1925
2044
|
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
2045
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
2046
|
+
return data;
|
|
2047
|
+
}
|
|
1929
2048
|
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
2049
|
+
if (
|
|
2050
|
+
data &&
|
|
2051
|
+
utils$1.isString(data) &&
|
|
2052
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
2053
|
+
) {
|
|
2054
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2055
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1933
2056
|
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2057
|
+
try {
|
|
2058
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
2059
|
+
} catch (e) {
|
|
2060
|
+
if (strictJSONParsing) {
|
|
2061
|
+
if (e.name === 'SyntaxError') {
|
|
2062
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
2063
|
+
}
|
|
2064
|
+
throw e;
|
|
1940
2065
|
}
|
|
1941
|
-
throw e;
|
|
1942
2066
|
}
|
|
1943
2067
|
}
|
|
1944
|
-
}
|
|
1945
2068
|
|
|
1946
|
-
|
|
1947
|
-
|
|
2069
|
+
return data;
|
|
2070
|
+
},
|
|
2071
|
+
],
|
|
1948
2072
|
|
|
1949
2073
|
/**
|
|
1950
2074
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
@@ -1960,7 +2084,7 @@ const defaults = {
|
|
|
1960
2084
|
|
|
1961
2085
|
env: {
|
|
1962
2086
|
FormData: platform.classes.FormData,
|
|
1963
|
-
Blob: platform.classes.Blob
|
|
2087
|
+
Blob: platform.classes.Blob,
|
|
1964
2088
|
},
|
|
1965
2089
|
|
|
1966
2090
|
validateStatus: function validateStatus(status) {
|
|
@@ -1969,10 +2093,10 @@ const defaults = {
|
|
|
1969
2093
|
|
|
1970
2094
|
headers: {
|
|
1971
2095
|
common: {
|
|
1972
|
-
|
|
1973
|
-
'Content-Type': undefined
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
2096
|
+
Accept: 'application/json, text/plain, */*',
|
|
2097
|
+
'Content-Type': undefined,
|
|
2098
|
+
},
|
|
2099
|
+
},
|
|
1976
2100
|
};
|
|
1977
2101
|
|
|
1978
2102
|
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
@@ -1982,10 +2106,23 @@ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
|
1982
2106
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1983
2107
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1984
2108
|
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1985
|
-
'age',
|
|
1986
|
-
'
|
|
1987
|
-
'
|
|
1988
|
-
'
|
|
2109
|
+
'age',
|
|
2110
|
+
'authorization',
|
|
2111
|
+
'content-length',
|
|
2112
|
+
'content-type',
|
|
2113
|
+
'etag',
|
|
2114
|
+
'expires',
|
|
2115
|
+
'from',
|
|
2116
|
+
'host',
|
|
2117
|
+
'if-modified-since',
|
|
2118
|
+
'if-unmodified-since',
|
|
2119
|
+
'last-modified',
|
|
2120
|
+
'location',
|
|
2121
|
+
'max-forwards',
|
|
2122
|
+
'proxy-authorization',
|
|
2123
|
+
'referer',
|
|
2124
|
+
'retry-after',
|
|
2125
|
+
'user-agent',
|
|
1989
2126
|
]);
|
|
1990
2127
|
|
|
1991
2128
|
/**
|
|
@@ -2002,47 +2139,81 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
|
2002
2139
|
*
|
|
2003
2140
|
* @returns {Object} Headers parsed into an object
|
|
2004
2141
|
*/
|
|
2005
|
-
var parseHeaders = rawHeaders => {
|
|
2142
|
+
var parseHeaders = (rawHeaders) => {
|
|
2006
2143
|
const parsed = {};
|
|
2007
2144
|
let key;
|
|
2008
2145
|
let val;
|
|
2009
2146
|
let i;
|
|
2010
2147
|
|
|
2011
|
-
rawHeaders &&
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2148
|
+
rawHeaders &&
|
|
2149
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
2150
|
+
i = line.indexOf(':');
|
|
2151
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
2152
|
+
val = line.substring(i + 1).trim();
|
|
2015
2153
|
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2154
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
2155
|
+
return;
|
|
2156
|
+
}
|
|
2019
2157
|
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2158
|
+
if (key === 'set-cookie') {
|
|
2159
|
+
if (parsed[key]) {
|
|
2160
|
+
parsed[key].push(val);
|
|
2161
|
+
} else {
|
|
2162
|
+
parsed[key] = [val];
|
|
2163
|
+
}
|
|
2023
2164
|
} else {
|
|
2024
|
-
parsed[key] = [val
|
|
2165
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
2025
2166
|
}
|
|
2026
|
-
}
|
|
2027
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
2028
|
-
}
|
|
2029
|
-
});
|
|
2167
|
+
});
|
|
2030
2168
|
|
|
2031
2169
|
return parsed;
|
|
2032
2170
|
};
|
|
2033
2171
|
|
|
2034
2172
|
const $internals = Symbol('internals');
|
|
2035
2173
|
|
|
2174
|
+
const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
|
|
2175
|
+
|
|
2176
|
+
function trimSPorHTAB(str) {
|
|
2177
|
+
let start = 0;
|
|
2178
|
+
let end = str.length;
|
|
2179
|
+
|
|
2180
|
+
while (start < end) {
|
|
2181
|
+
const code = str.charCodeAt(start);
|
|
2182
|
+
|
|
2183
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2184
|
+
break;
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
start += 1;
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
while (end > start) {
|
|
2191
|
+
const code = str.charCodeAt(end - 1);
|
|
2192
|
+
|
|
2193
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2194
|
+
break;
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
end -= 1;
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2036
2203
|
function normalizeHeader(header) {
|
|
2037
2204
|
return header && String(header).trim().toLowerCase();
|
|
2038
2205
|
}
|
|
2039
2206
|
|
|
2207
|
+
function sanitizeHeaderValue(str) {
|
|
2208
|
+
return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2040
2211
|
function normalizeValue(value) {
|
|
2041
2212
|
if (value === false || value == null) {
|
|
2042
2213
|
return value;
|
|
2043
2214
|
}
|
|
2044
2215
|
|
|
2045
|
-
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
2216
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
2046
2217
|
}
|
|
2047
2218
|
|
|
2048
2219
|
function parseTokens(str) {
|
|
@@ -2080,8 +2251,10 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
2080
2251
|
}
|
|
2081
2252
|
|
|
2082
2253
|
function formatHeader(header) {
|
|
2083
|
-
return header
|
|
2084
|
-
.
|
|
2254
|
+
return header
|
|
2255
|
+
.trim()
|
|
2256
|
+
.toLowerCase()
|
|
2257
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
2085
2258
|
return char.toUpperCase() + str;
|
|
2086
2259
|
});
|
|
2087
2260
|
}
|
|
@@ -2089,12 +2262,12 @@ function formatHeader(header) {
|
|
|
2089
2262
|
function buildAccessors(obj, header) {
|
|
2090
2263
|
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
2091
2264
|
|
|
2092
|
-
['get', 'set', 'has'].forEach(methodName => {
|
|
2265
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
2093
2266
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
2094
|
-
value: function(arg1, arg2, arg3) {
|
|
2267
|
+
value: function (arg1, arg2, arg3) {
|
|
2095
2268
|
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
2096
2269
|
},
|
|
2097
|
-
configurable: true
|
|
2270
|
+
configurable: true,
|
|
2098
2271
|
});
|
|
2099
2272
|
});
|
|
2100
2273
|
}
|
|
@@ -2116,7 +2289,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2116
2289
|
|
|
2117
2290
|
const key = utils$1.findKey(self, lHeader);
|
|
2118
2291
|
|
|
2119
|
-
if
|
|
2292
|
+
if (
|
|
2293
|
+
!key ||
|
|
2294
|
+
self[key] === undefined ||
|
|
2295
|
+
_rewrite === true ||
|
|
2296
|
+
(_rewrite === undefined && self[key] !== false)
|
|
2297
|
+
) {
|
|
2120
2298
|
self[key || _header] = normalizeValue(_value);
|
|
2121
2299
|
}
|
|
2122
2300
|
}
|
|
@@ -2126,17 +2304,22 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2126
2304
|
|
|
2127
2305
|
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
2128
2306
|
setHeaders(header, valueOrRewrite);
|
|
2129
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2307
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2130
2308
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
2131
2309
|
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
2132
|
-
let obj = {},
|
|
2310
|
+
let obj = {},
|
|
2311
|
+
dest,
|
|
2312
|
+
key;
|
|
2133
2313
|
for (const entry of header) {
|
|
2134
2314
|
if (!utils$1.isArray(entry)) {
|
|
2135
2315
|
throw TypeError('Object iterator must return a key-value pair');
|
|
2136
2316
|
}
|
|
2137
2317
|
|
|
2138
|
-
obj[key = entry[0]] = (dest = obj[key])
|
|
2139
|
-
|
|
2318
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
2319
|
+
? utils$1.isArray(dest)
|
|
2320
|
+
? [...dest, entry[1]]
|
|
2321
|
+
: [dest, entry[1]]
|
|
2322
|
+
: entry[1];
|
|
2140
2323
|
}
|
|
2141
2324
|
|
|
2142
2325
|
setHeaders(obj, valueOrRewrite);
|
|
@@ -2183,7 +2366,11 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2183
2366
|
if (header) {
|
|
2184
2367
|
const key = utils$1.findKey(this, header);
|
|
2185
2368
|
|
|
2186
|
-
return !!(
|
|
2369
|
+
return !!(
|
|
2370
|
+
key &&
|
|
2371
|
+
this[key] !== undefined &&
|
|
2372
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2373
|
+
);
|
|
2187
2374
|
}
|
|
2188
2375
|
|
|
2189
2376
|
return false;
|
|
@@ -2223,7 +2410,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2223
2410
|
|
|
2224
2411
|
while (i--) {
|
|
2225
2412
|
const key = keys[i];
|
|
2226
|
-
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2413
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2227
2414
|
delete this[key];
|
|
2228
2415
|
deleted = true;
|
|
2229
2416
|
}
|
|
@@ -2267,7 +2454,9 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2267
2454
|
const obj = Object.create(null);
|
|
2268
2455
|
|
|
2269
2456
|
utils$1.forEach(this, (value, header) => {
|
|
2270
|
-
value != null &&
|
|
2457
|
+
value != null &&
|
|
2458
|
+
value !== false &&
|
|
2459
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
2271
2460
|
});
|
|
2272
2461
|
|
|
2273
2462
|
return obj;
|
|
@@ -2278,11 +2467,13 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2278
2467
|
}
|
|
2279
2468
|
|
|
2280
2469
|
toString() {
|
|
2281
|
-
return Object.entries(this.toJSON())
|
|
2470
|
+
return Object.entries(this.toJSON())
|
|
2471
|
+
.map(([header, value]) => header + ': ' + value)
|
|
2472
|
+
.join('\n');
|
|
2282
2473
|
}
|
|
2283
2474
|
|
|
2284
2475
|
getSetCookie() {
|
|
2285
|
-
return this.get(
|
|
2476
|
+
return this.get('set-cookie') || [];
|
|
2286
2477
|
}
|
|
2287
2478
|
|
|
2288
2479
|
get [Symbol.toStringTag]() {
|
|
@@ -2302,9 +2493,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2302
2493
|
}
|
|
2303
2494
|
|
|
2304
2495
|
static accessor(header) {
|
|
2305
|
-
const internals =
|
|
2306
|
-
|
|
2307
|
-
|
|
2496
|
+
const internals =
|
|
2497
|
+
(this[$internals] =
|
|
2498
|
+
this[$internals] =
|
|
2499
|
+
{
|
|
2500
|
+
accessors: {},
|
|
2501
|
+
});
|
|
2308
2502
|
|
|
2309
2503
|
const accessors = internals.accessors;
|
|
2310
2504
|
const prototype = this.prototype;
|
|
@@ -2324,17 +2518,24 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2324
2518
|
}
|
|
2325
2519
|
};
|
|
2326
2520
|
|
|
2327
|
-
AxiosHeaders$1.accessor([
|
|
2521
|
+
AxiosHeaders$1.accessor([
|
|
2522
|
+
'Content-Type',
|
|
2523
|
+
'Content-Length',
|
|
2524
|
+
'Accept',
|
|
2525
|
+
'Accept-Encoding',
|
|
2526
|
+
'User-Agent',
|
|
2527
|
+
'Authorization',
|
|
2528
|
+
]);
|
|
2328
2529
|
|
|
2329
2530
|
// reserved names hotfix
|
|
2330
|
-
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
|
|
2531
|
+
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
2331
2532
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2332
2533
|
return {
|
|
2333
2534
|
get: () => value,
|
|
2334
2535
|
set(headerValue) {
|
|
2335
2536
|
this[mapped] = headerValue;
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2537
|
+
},
|
|
2538
|
+
};
|
|
2338
2539
|
});
|
|
2339
2540
|
|
|
2340
2541
|
utils$1.freezeMethods(AxiosHeaders$1);
|
|
@@ -2397,19 +2598,23 @@ function settle(resolve, reject, response) {
|
|
|
2397
2598
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2398
2599
|
resolve(response);
|
|
2399
2600
|
} else {
|
|
2400
|
-
reject(
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2601
|
+
reject(
|
|
2602
|
+
new AxiosError$1(
|
|
2603
|
+
'Request failed with status code ' + response.status,
|
|
2604
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
|
|
2605
|
+
Math.floor(response.status / 100) - 4
|
|
2606
|
+
],
|
|
2607
|
+
response.config,
|
|
2608
|
+
response.request,
|
|
2609
|
+
response
|
|
2610
|
+
)
|
|
2611
|
+
);
|
|
2407
2612
|
}
|
|
2408
2613
|
}
|
|
2409
2614
|
|
|
2410
2615
|
function parseProtocol(url) {
|
|
2411
2616
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
2412
|
-
return match && match[1] || '';
|
|
2617
|
+
return (match && match[1]) || '';
|
|
2413
2618
|
}
|
|
2414
2619
|
|
|
2415
2620
|
/**
|
|
@@ -2460,7 +2665,7 @@ function speedometer(samplesCount, min) {
|
|
|
2460
2665
|
|
|
2461
2666
|
const passed = startedAt && now - startedAt;
|
|
2462
2667
|
|
|
2463
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
2668
|
+
return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
|
|
2464
2669
|
};
|
|
2465
2670
|
}
|
|
2466
2671
|
|
|
@@ -2489,7 +2694,7 @@ function throttle(fn, freq) {
|
|
|
2489
2694
|
const throttled = (...args) => {
|
|
2490
2695
|
const now = Date.now();
|
|
2491
2696
|
const passed = now - timestamp;
|
|
2492
|
-
if (
|
|
2697
|
+
if (passed >= threshold) {
|
|
2493
2698
|
invoke(args, now);
|
|
2494
2699
|
} else {
|
|
2495
2700
|
lastArgs = args;
|
|
@@ -2511,25 +2716,25 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2511
2716
|
let bytesNotified = 0;
|
|
2512
2717
|
const _speedometer = speedometer(50, 250);
|
|
2513
2718
|
|
|
2514
|
-
return throttle(e => {
|
|
2515
|
-
const
|
|
2719
|
+
return throttle((e) => {
|
|
2720
|
+
const rawLoaded = e.loaded;
|
|
2516
2721
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2517
|
-
const
|
|
2722
|
+
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
2723
|
+
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
2518
2724
|
const rate = _speedometer(progressBytes);
|
|
2519
|
-
const inRange = loaded <= total;
|
|
2520
2725
|
|
|
2521
|
-
bytesNotified = loaded;
|
|
2726
|
+
bytesNotified = Math.max(bytesNotified, loaded);
|
|
2522
2727
|
|
|
2523
2728
|
const data = {
|
|
2524
2729
|
loaded,
|
|
2525
2730
|
total,
|
|
2526
|
-
progress: total ?
|
|
2731
|
+
progress: total ? loaded / total : undefined,
|
|
2527
2732
|
bytes: progressBytes,
|
|
2528
2733
|
rate: rate ? rate : undefined,
|
|
2529
|
-
estimated: rate && total
|
|
2734
|
+
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
2530
2735
|
event: e,
|
|
2531
2736
|
lengthComputable: total != null,
|
|
2532
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
|
2737
|
+
[isDownloadStream ? 'download' : 'upload']: true,
|
|
2533
2738
|
};
|
|
2534
2739
|
|
|
2535
2740
|
listener(data);
|
|
@@ -2539,77 +2744,82 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2539
2744
|
const progressEventDecorator = (total, throttled) => {
|
|
2540
2745
|
const lengthComputable = total != null;
|
|
2541
2746
|
|
|
2542
|
-
return [
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2747
|
+
return [
|
|
2748
|
+
(loaded) =>
|
|
2749
|
+
throttled[0]({
|
|
2750
|
+
lengthComputable,
|
|
2751
|
+
total,
|
|
2752
|
+
loaded,
|
|
2753
|
+
}),
|
|
2754
|
+
throttled[1],
|
|
2755
|
+
];
|
|
2547
2756
|
};
|
|
2548
2757
|
|
|
2549
|
-
const asyncDecorator =
|
|
2758
|
+
const asyncDecorator =
|
|
2759
|
+
(fn) =>
|
|
2760
|
+
(...args) =>
|
|
2761
|
+
utils$1.asap(() => fn(...args));
|
|
2550
2762
|
|
|
2551
|
-
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2552
|
-
|
|
2763
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2764
|
+
? ((origin, isMSIE) => (url) => {
|
|
2765
|
+
url = new URL(url, platform.origin);
|
|
2553
2766
|
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
})(
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
)
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
// Standard browser envs support document.cookie
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2767
|
+
return (
|
|
2768
|
+
origin.protocol === url.protocol &&
|
|
2769
|
+
origin.host === url.host &&
|
|
2770
|
+
(isMSIE || origin.port === url.port)
|
|
2771
|
+
);
|
|
2772
|
+
})(
|
|
2773
|
+
new URL(platform.origin),
|
|
2774
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2775
|
+
)
|
|
2776
|
+
: () => true;
|
|
2777
|
+
|
|
2778
|
+
var cookies = platform.hasStandardBrowserEnv
|
|
2779
|
+
? // Standard browser envs support document.cookie
|
|
2780
|
+
{
|
|
2781
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2782
|
+
if (typeof document === 'undefined') return;
|
|
2783
|
+
|
|
2784
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2785
|
+
|
|
2786
|
+
if (utils$1.isNumber(expires)) {
|
|
2787
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2788
|
+
}
|
|
2789
|
+
if (utils$1.isString(path)) {
|
|
2790
|
+
cookie.push(`path=${path}`);
|
|
2791
|
+
}
|
|
2792
|
+
if (utils$1.isString(domain)) {
|
|
2793
|
+
cookie.push(`domain=${domain}`);
|
|
2794
|
+
}
|
|
2795
|
+
if (secure === true) {
|
|
2796
|
+
cookie.push('secure');
|
|
2797
|
+
}
|
|
2798
|
+
if (utils$1.isString(sameSite)) {
|
|
2799
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2800
|
+
}
|
|
2588
2801
|
|
|
2589
|
-
|
|
2590
|
-
|
|
2802
|
+
document.cookie = cookie.join('; ');
|
|
2803
|
+
},
|
|
2591
2804
|
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2805
|
+
read(name) {
|
|
2806
|
+
if (typeof document === 'undefined') return null;
|
|
2807
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
2808
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
2809
|
+
},
|
|
2597
2810
|
|
|
2598
|
-
|
|
2599
|
-
|
|
2811
|
+
remove(name) {
|
|
2812
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2813
|
+
},
|
|
2600
2814
|
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
return null;
|
|
2610
|
-
},
|
|
2611
|
-
remove() {}
|
|
2612
|
-
};
|
|
2815
|
+
: // Non-standard browser env (web workers, react-native) lack needed support.
|
|
2816
|
+
{
|
|
2817
|
+
write() {},
|
|
2818
|
+
read() {
|
|
2819
|
+
return null;
|
|
2820
|
+
},
|
|
2821
|
+
remove() {},
|
|
2822
|
+
};
|
|
2613
2823
|
|
|
2614
2824
|
/**
|
|
2615
2825
|
* Determines whether the specified URL is absolute
|
|
@@ -2655,14 +2865,13 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
2655
2865
|
*/
|
|
2656
2866
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
2657
2867
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2658
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls
|
|
2868
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
2659
2869
|
return combineURLs(baseURL, requestedURL);
|
|
2660
2870
|
}
|
|
2661
2871
|
return requestedURL;
|
|
2662
2872
|
}
|
|
2663
2873
|
|
|
2664
|
-
const headersToObject = (thing) =>
|
|
2665
|
-
thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
2874
|
+
const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
|
|
2666
2875
|
|
|
2667
2876
|
/**
|
|
2668
2877
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2676,7 +2885,18 @@ const headersToObject = (thing) =>
|
|
|
2676
2885
|
function mergeConfig$1(config1, config2) {
|
|
2677
2886
|
// eslint-disable-next-line no-param-reassign
|
|
2678
2887
|
config2 = config2 || {};
|
|
2679
|
-
|
|
2888
|
+
|
|
2889
|
+
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
2890
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype
|
|
2891
|
+
// (see GHSA-q8qp-cvcw-x6jj). `hasOwnProperty` is restored as a non-enumerable
|
|
2892
|
+
// own slot to preserve ergonomics for user code that relies on it.
|
|
2893
|
+
const config = Object.create(null);
|
|
2894
|
+
Object.defineProperty(config, 'hasOwnProperty', {
|
|
2895
|
+
value: Object.prototype.hasOwnProperty,
|
|
2896
|
+
enumerable: false,
|
|
2897
|
+
writable: true,
|
|
2898
|
+
configurable: true,
|
|
2899
|
+
});
|
|
2680
2900
|
|
|
2681
2901
|
function getMergedValue(target, source, prop, caseless) {
|
|
2682
2902
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
@@ -2715,9 +2935,9 @@ function mergeConfig$1(config1, config2) {
|
|
|
2715
2935
|
|
|
2716
2936
|
// eslint-disable-next-line consistent-return
|
|
2717
2937
|
function mergeDirectKeys(a, b, prop) {
|
|
2718
|
-
if (prop
|
|
2938
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
2719
2939
|
return getMergedValue(a, b);
|
|
2720
|
-
} else if (prop
|
|
2940
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
2721
2941
|
return getMergedValue(undefined, a);
|
|
2722
2942
|
}
|
|
2723
2943
|
}
|
|
@@ -2749,29 +2969,21 @@ function mergeConfig$1(config1, config2) {
|
|
|
2749
2969
|
httpsAgent: defaultToConfig2,
|
|
2750
2970
|
cancelToken: defaultToConfig2,
|
|
2751
2971
|
socketPath: defaultToConfig2,
|
|
2972
|
+
allowedSocketPaths: defaultToConfig2,
|
|
2752
2973
|
responseEncoding: defaultToConfig2,
|
|
2753
2974
|
validateStatus: mergeDirectKeys,
|
|
2754
2975
|
headers: (a, b, prop) =>
|
|
2755
2976
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2756
2977
|
};
|
|
2757
2978
|
|
|
2758
|
-
utils$1.forEach(
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
return;
|
|
2767
|
-
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2768
|
-
? mergeMap[prop]
|
|
2769
|
-
: mergeDeepProperties;
|
|
2770
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2771
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2772
|
-
(config[prop] = configValue);
|
|
2773
|
-
},
|
|
2774
|
-
);
|
|
2979
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
2980
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
2981
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
2982
|
+
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
2983
|
+
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
2984
|
+
const configValue = merge(a, b, prop);
|
|
2985
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2986
|
+
});
|
|
2775
2987
|
|
|
2776
2988
|
return config;
|
|
2777
2989
|
}
|
|
@@ -2779,16 +2991,38 @@ function mergeConfig$1(config1, config2) {
|
|
|
2779
2991
|
var resolveConfig = (config) => {
|
|
2780
2992
|
const newConfig = mergeConfig$1({}, config);
|
|
2781
2993
|
|
|
2782
|
-
|
|
2994
|
+
// Read only own properties to prevent prototype pollution gadgets
|
|
2995
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com'). See GHSA-q8qp-cvcw-x6jj.
|
|
2996
|
+
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
2997
|
+
|
|
2998
|
+
const data = own('data');
|
|
2999
|
+
let withXSRFToken = own('withXSRFToken');
|
|
3000
|
+
const xsrfHeaderName = own('xsrfHeaderName');
|
|
3001
|
+
const xsrfCookieName = own('xsrfCookieName');
|
|
3002
|
+
let headers = own('headers');
|
|
3003
|
+
const auth = own('auth');
|
|
3004
|
+
const baseURL = own('baseURL');
|
|
3005
|
+
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
3006
|
+
const url = own('url');
|
|
2783
3007
|
|
|
2784
3008
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2785
3009
|
|
|
2786
|
-
newConfig.url = buildURL(
|
|
3010
|
+
newConfig.url = buildURL(
|
|
3011
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls),
|
|
3012
|
+
config.params,
|
|
3013
|
+
config.paramsSerializer
|
|
3014
|
+
);
|
|
2787
3015
|
|
|
2788
3016
|
// HTTP basic authentication
|
|
2789
3017
|
if (auth) {
|
|
2790
|
-
headers.set(
|
|
2791
|
-
|
|
3018
|
+
headers.set(
|
|
3019
|
+
'Authorization',
|
|
3020
|
+
'Basic ' +
|
|
3021
|
+
btoa(
|
|
3022
|
+
(auth.username || '') +
|
|
3023
|
+
':' +
|
|
3024
|
+
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
|
3025
|
+
)
|
|
2792
3026
|
);
|
|
2793
3027
|
}
|
|
2794
3028
|
|
|
@@ -2806,17 +3040,25 @@ var resolveConfig = (config) => {
|
|
|
2806
3040
|
}
|
|
2807
3041
|
});
|
|
2808
3042
|
}
|
|
2809
|
-
}
|
|
3043
|
+
}
|
|
2810
3044
|
|
|
2811
3045
|
// Add xsrf header
|
|
2812
3046
|
// This is only done if running in a standard browser environment.
|
|
2813
3047
|
// Specifically not if we're in a web worker, or react-native.
|
|
2814
3048
|
|
|
2815
3049
|
if (platform.hasStandardBrowserEnv) {
|
|
2816
|
-
|
|
3050
|
+
if (utils$1.isFunction(withXSRFToken)) {
|
|
3051
|
+
withXSRFToken = withXSRFToken(newConfig);
|
|
3052
|
+
}
|
|
2817
3053
|
|
|
2818
|
-
|
|
2819
|
-
|
|
3054
|
+
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
3055
|
+
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
3056
|
+
// the XSRF token cross-origin. See GHSA-xx6v-rp6x-q39c.
|
|
3057
|
+
const shouldSendXSRF =
|
|
3058
|
+
withXSRFToken === true ||
|
|
3059
|
+
(withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
3060
|
+
|
|
3061
|
+
if (shouldSendXSRF) {
|
|
2820
3062
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
2821
3063
|
|
|
2822
3064
|
if (xsrfValue) {
|
|
@@ -2830,196 +3072,218 @@ var resolveConfig = (config) => {
|
|
|
2830
3072
|
|
|
2831
3073
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2832
3074
|
|
|
2833
|
-
var xhrAdapter = isXHRAdapterSupported &&
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
3075
|
+
var xhrAdapter = isXHRAdapterSupported &&
|
|
3076
|
+
function (config) {
|
|
3077
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
3078
|
+
const _config = resolveConfig(config);
|
|
3079
|
+
let requestData = _config.data;
|
|
3080
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
3081
|
+
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
3082
|
+
let onCanceled;
|
|
3083
|
+
let uploadThrottled, downloadThrottled;
|
|
3084
|
+
let flushUpload, flushDownload;
|
|
2842
3085
|
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
3086
|
+
function done() {
|
|
3087
|
+
flushUpload && flushUpload(); // flush events
|
|
3088
|
+
flushDownload && flushDownload(); // flush events
|
|
2846
3089
|
|
|
2847
|
-
|
|
3090
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
2848
3091
|
|
|
2849
|
-
|
|
2850
|
-
|
|
3092
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
3093
|
+
}
|
|
2851
3094
|
|
|
2852
|
-
|
|
3095
|
+
let request = new XMLHttpRequest();
|
|
2853
3096
|
|
|
2854
|
-
|
|
3097
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
2855
3098
|
|
|
2856
|
-
|
|
2857
|
-
|
|
3099
|
+
// Set the request timeout in MS
|
|
3100
|
+
request.timeout = _config.timeout;
|
|
2858
3101
|
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
3102
|
+
function onloadend() {
|
|
3103
|
+
if (!request) {
|
|
3104
|
+
return;
|
|
3105
|
+
}
|
|
3106
|
+
// Prepare the response
|
|
3107
|
+
const responseHeaders = AxiosHeaders$1.from(
|
|
3108
|
+
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
3109
|
+
);
|
|
3110
|
+
const responseData =
|
|
3111
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
3112
|
+
? request.responseText
|
|
3113
|
+
: request.response;
|
|
3114
|
+
const response = {
|
|
3115
|
+
data: responseData,
|
|
3116
|
+
status: request.status,
|
|
3117
|
+
statusText: request.statusText,
|
|
3118
|
+
headers: responseHeaders,
|
|
3119
|
+
config,
|
|
3120
|
+
request,
|
|
3121
|
+
};
|
|
3122
|
+
|
|
3123
|
+
settle(
|
|
3124
|
+
function _resolve(value) {
|
|
3125
|
+
resolve(value);
|
|
3126
|
+
done();
|
|
3127
|
+
},
|
|
3128
|
+
function _reject(err) {
|
|
3129
|
+
reject(err);
|
|
3130
|
+
done();
|
|
3131
|
+
},
|
|
3132
|
+
response
|
|
3133
|
+
);
|
|
3134
|
+
|
|
3135
|
+
// Clean up request
|
|
3136
|
+
request = null;
|
|
2862
3137
|
}
|
|
2863
|
-
// Prepare the response
|
|
2864
|
-
const responseHeaders = AxiosHeaders$1.from(
|
|
2865
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2866
|
-
);
|
|
2867
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
2868
|
-
request.responseText : request.response;
|
|
2869
|
-
const response = {
|
|
2870
|
-
data: responseData,
|
|
2871
|
-
status: request.status,
|
|
2872
|
-
statusText: request.statusText,
|
|
2873
|
-
headers: responseHeaders,
|
|
2874
|
-
config,
|
|
2875
|
-
request
|
|
2876
|
-
};
|
|
2877
3138
|
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
3139
|
+
if ('onloadend' in request) {
|
|
3140
|
+
// Use onloadend if available
|
|
3141
|
+
request.onloadend = onloadend;
|
|
3142
|
+
} else {
|
|
3143
|
+
// Listen for ready state to emulate onloadend
|
|
3144
|
+
request.onreadystatechange = function handleLoad() {
|
|
3145
|
+
if (!request || request.readyState !== 4) {
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
2885
3148
|
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
3149
|
+
// The request errored out and we didn't get a response, this will be
|
|
3150
|
+
// handled by onerror instead
|
|
3151
|
+
// With one exception: request that using file: protocol, most browsers
|
|
3152
|
+
// will return status as 0 even though it's a successful request
|
|
3153
|
+
if (
|
|
3154
|
+
request.status === 0 &&
|
|
3155
|
+
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
|
3156
|
+
) {
|
|
3157
|
+
return;
|
|
3158
|
+
}
|
|
3159
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
|
3160
|
+
// so we should call onloadend on the next 'tick'
|
|
3161
|
+
setTimeout(onloadend);
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
2889
3164
|
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
} else {
|
|
2894
|
-
// Listen for ready state to emulate onloadend
|
|
2895
|
-
request.onreadystatechange = function handleLoad() {
|
|
2896
|
-
if (!request || request.readyState !== 4) {
|
|
3165
|
+
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
3166
|
+
request.onabort = function handleAbort() {
|
|
3167
|
+
if (!request) {
|
|
2897
3168
|
return;
|
|
2898
3169
|
}
|
|
2899
3170
|
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
//
|
|
2903
|
-
|
|
2904
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
2905
|
-
return;
|
|
2906
|
-
}
|
|
2907
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2908
|
-
// so we should call onloadend on the next 'tick'
|
|
2909
|
-
setTimeout(onloadend);
|
|
3171
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
3172
|
+
|
|
3173
|
+
// Clean up request
|
|
3174
|
+
request = null;
|
|
2910
3175
|
};
|
|
2911
|
-
}
|
|
2912
3176
|
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
3177
|
+
// Handle low level network errors
|
|
3178
|
+
request.onerror = function handleError(event) {
|
|
3179
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
3180
|
+
// (message may be empty; when present, surface it)
|
|
3181
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
3182
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
3183
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
3184
|
+
// attach the underlying event for consumers who want details
|
|
3185
|
+
err.event = event || null;
|
|
3186
|
+
reject(err);
|
|
3187
|
+
request = null;
|
|
3188
|
+
};
|
|
2918
3189
|
|
|
2919
|
-
|
|
3190
|
+
// Handle timeout
|
|
3191
|
+
request.ontimeout = function handleTimeout() {
|
|
3192
|
+
let timeoutErrorMessage = _config.timeout
|
|
3193
|
+
? 'timeout of ' + _config.timeout + 'ms exceeded'
|
|
3194
|
+
: 'timeout exceeded';
|
|
3195
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
3196
|
+
if (_config.timeoutErrorMessage) {
|
|
3197
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
3198
|
+
}
|
|
3199
|
+
reject(
|
|
3200
|
+
new AxiosError$1(
|
|
3201
|
+
timeoutErrorMessage,
|
|
3202
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
3203
|
+
config,
|
|
3204
|
+
request
|
|
3205
|
+
)
|
|
3206
|
+
);
|
|
2920
3207
|
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
3208
|
+
// Clean up request
|
|
3209
|
+
request = null;
|
|
3210
|
+
};
|
|
2924
3211
|
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
// Browsers deliver a ProgressEvent in XHR onerror
|
|
2928
|
-
// (message may be empty; when present, surface it)
|
|
2929
|
-
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2930
|
-
const msg = event && event.message ? event.message : 'Network Error';
|
|
2931
|
-
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
2932
|
-
// attach the underlying event for consumers who want details
|
|
2933
|
-
err.event = event || null;
|
|
2934
|
-
reject(err);
|
|
2935
|
-
request = null;
|
|
2936
|
-
};
|
|
2937
|
-
|
|
2938
|
-
// Handle timeout
|
|
2939
|
-
request.ontimeout = function handleTimeout() {
|
|
2940
|
-
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
2941
|
-
const transitional = _config.transitional || transitionalDefaults;
|
|
2942
|
-
if (_config.timeoutErrorMessage) {
|
|
2943
|
-
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2944
|
-
}
|
|
2945
|
-
reject(new AxiosError$1(
|
|
2946
|
-
timeoutErrorMessage,
|
|
2947
|
-
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
2948
|
-
config,
|
|
2949
|
-
request));
|
|
2950
|
-
|
|
2951
|
-
// Clean up request
|
|
2952
|
-
request = null;
|
|
2953
|
-
};
|
|
3212
|
+
// Remove Content-Type if data is undefined
|
|
3213
|
+
requestData === undefined && requestHeaders.setContentType(null);
|
|
2954
3214
|
|
|
2955
|
-
|
|
2956
|
-
|
|
3215
|
+
// Add headers to the request
|
|
3216
|
+
if ('setRequestHeader' in request) {
|
|
3217
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
3218
|
+
request.setRequestHeader(key, val);
|
|
3219
|
+
});
|
|
3220
|
+
}
|
|
2957
3221
|
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
});
|
|
2963
|
-
}
|
|
3222
|
+
// Add withCredentials to request if needed
|
|
3223
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
3224
|
+
request.withCredentials = !!_config.withCredentials;
|
|
3225
|
+
}
|
|
2964
3226
|
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
3227
|
+
// Add responseType to request if needed
|
|
3228
|
+
if (responseType && responseType !== 'json') {
|
|
3229
|
+
request.responseType = _config.responseType;
|
|
3230
|
+
}
|
|
2969
3231
|
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
3232
|
+
// Handle progress if needed
|
|
3233
|
+
if (onDownloadProgress) {
|
|
3234
|
+
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
3235
|
+
request.addEventListener('progress', downloadThrottled);
|
|
3236
|
+
}
|
|
2974
3237
|
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
request.addEventListener('progress', downloadThrottled);
|
|
2979
|
-
}
|
|
3238
|
+
// Not all browsers support upload events
|
|
3239
|
+
if (onUploadProgress && request.upload) {
|
|
3240
|
+
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
|
2980
3241
|
|
|
2981
|
-
|
|
2982
|
-
if (onUploadProgress && request.upload) {
|
|
2983
|
-
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
3242
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
2984
3243
|
|
|
2985
|
-
|
|
3244
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
3245
|
+
}
|
|
2986
3246
|
|
|
2987
|
-
|
|
2988
|
-
|
|
3247
|
+
if (_config.cancelToken || _config.signal) {
|
|
3248
|
+
// Handle cancellation
|
|
3249
|
+
// eslint-disable-next-line func-names
|
|
3250
|
+
onCanceled = (cancel) => {
|
|
3251
|
+
if (!request) {
|
|
3252
|
+
return;
|
|
3253
|
+
}
|
|
3254
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
3255
|
+
request.abort();
|
|
3256
|
+
request = null;
|
|
3257
|
+
};
|
|
2989
3258
|
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
return;
|
|
3259
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
3260
|
+
if (_config.signal) {
|
|
3261
|
+
_config.signal.aborted
|
|
3262
|
+
? onCanceled()
|
|
3263
|
+
: _config.signal.addEventListener('abort', onCanceled);
|
|
2996
3264
|
}
|
|
2997
|
-
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2998
|
-
request.abort();
|
|
2999
|
-
request = null;
|
|
3000
|
-
};
|
|
3001
|
-
|
|
3002
|
-
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
3003
|
-
if (_config.signal) {
|
|
3004
|
-
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
3005
3265
|
}
|
|
3006
|
-
}
|
|
3007
|
-
|
|
3008
|
-
const protocol = parseProtocol(_config.url);
|
|
3009
3266
|
|
|
3010
|
-
|
|
3011
|
-
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
3012
|
-
return;
|
|
3013
|
-
}
|
|
3267
|
+
const protocol = parseProtocol(_config.url);
|
|
3014
3268
|
|
|
3269
|
+
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
3270
|
+
reject(
|
|
3271
|
+
new AxiosError$1(
|
|
3272
|
+
'Unsupported protocol ' + protocol + ':',
|
|
3273
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
3274
|
+
config
|
|
3275
|
+
)
|
|
3276
|
+
);
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3015
3279
|
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
};
|
|
3280
|
+
// Send the request
|
|
3281
|
+
request.send(requestData || null);
|
|
3282
|
+
});
|
|
3283
|
+
};
|
|
3020
3284
|
|
|
3021
3285
|
const composeSignals = (signals, timeout) => {
|
|
3022
|
-
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
3286
|
+
const { length } = (signals = signals ? signals.filter(Boolean) : []);
|
|
3023
3287
|
|
|
3024
3288
|
if (timeout || length) {
|
|
3025
3289
|
let controller = new AbortController();
|
|
@@ -3031,21 +3295,29 @@ const composeSignals = (signals, timeout) => {
|
|
|
3031
3295
|
aborted = true;
|
|
3032
3296
|
unsubscribe();
|
|
3033
3297
|
const err = reason instanceof Error ? reason : this.reason;
|
|
3034
|
-
controller.abort(
|
|
3298
|
+
controller.abort(
|
|
3299
|
+
err instanceof AxiosError$1
|
|
3300
|
+
? err
|
|
3301
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3302
|
+
);
|
|
3035
3303
|
}
|
|
3036
3304
|
};
|
|
3037
3305
|
|
|
3038
|
-
let timer =
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3306
|
+
let timer =
|
|
3307
|
+
timeout &&
|
|
3308
|
+
setTimeout(() => {
|
|
3309
|
+
timer = null;
|
|
3310
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3311
|
+
}, timeout);
|
|
3042
3312
|
|
|
3043
3313
|
const unsubscribe = () => {
|
|
3044
3314
|
if (signals) {
|
|
3045
3315
|
timer && clearTimeout(timer);
|
|
3046
3316
|
timer = null;
|
|
3047
|
-
signals.forEach(signal => {
|
|
3048
|
-
signal.unsubscribe
|
|
3317
|
+
signals.forEach((signal) => {
|
|
3318
|
+
signal.unsubscribe
|
|
3319
|
+
? signal.unsubscribe(onabort)
|
|
3320
|
+
: signal.removeEventListener('abort', onabort);
|
|
3049
3321
|
});
|
|
3050
3322
|
signals = null;
|
|
3051
3323
|
}
|
|
@@ -3053,7 +3325,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
3053
3325
|
|
|
3054
3326
|
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
3055
3327
|
|
|
3056
|
-
const {signal} = controller;
|
|
3328
|
+
const { signal } = controller;
|
|
3057
3329
|
|
|
3058
3330
|
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
3059
3331
|
|
|
@@ -3094,7 +3366,7 @@ const readStream = async function* (stream) {
|
|
|
3094
3366
|
const reader = stream.getReader();
|
|
3095
3367
|
try {
|
|
3096
3368
|
for (;;) {
|
|
3097
|
-
const {done, value} = await reader.read();
|
|
3369
|
+
const { done, value } = await reader.read();
|
|
3098
3370
|
if (done) {
|
|
3099
3371
|
break;
|
|
3100
3372
|
}
|
|
@@ -3117,64 +3389,69 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
3117
3389
|
}
|
|
3118
3390
|
};
|
|
3119
3391
|
|
|
3120
|
-
return new ReadableStream(
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3392
|
+
return new ReadableStream(
|
|
3393
|
+
{
|
|
3394
|
+
async pull(controller) {
|
|
3395
|
+
try {
|
|
3396
|
+
const { done, value } = await iterator.next();
|
|
3124
3397
|
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3398
|
+
if (done) {
|
|
3399
|
+
_onFinish();
|
|
3400
|
+
controller.close();
|
|
3401
|
+
return;
|
|
3402
|
+
}
|
|
3130
3403
|
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3404
|
+
let len = value.byteLength;
|
|
3405
|
+
if (onProgress) {
|
|
3406
|
+
let loadedBytes = (bytes += len);
|
|
3407
|
+
onProgress(loadedBytes);
|
|
3408
|
+
}
|
|
3409
|
+
controller.enqueue(new Uint8Array(value));
|
|
3410
|
+
} catch (err) {
|
|
3411
|
+
_onFinish(err);
|
|
3412
|
+
throw err;
|
|
3135
3413
|
}
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
_onFinish(
|
|
3139
|
-
|
|
3140
|
-
}
|
|
3414
|
+
},
|
|
3415
|
+
cancel(reason) {
|
|
3416
|
+
_onFinish(reason);
|
|
3417
|
+
return iterator.return();
|
|
3418
|
+
},
|
|
3141
3419
|
},
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
return iterator.return();
|
|
3420
|
+
{
|
|
3421
|
+
highWaterMark: 2,
|
|
3145
3422
|
}
|
|
3146
|
-
|
|
3147
|
-
highWaterMark: 2
|
|
3148
|
-
})
|
|
3423
|
+
);
|
|
3149
3424
|
};
|
|
3150
3425
|
|
|
3151
3426
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3152
3427
|
|
|
3153
|
-
const {isFunction} = utils$1;
|
|
3428
|
+
const { isFunction } = utils$1;
|
|
3154
3429
|
|
|
3155
|
-
const globalFetchAPI = (({Request, Response}) => ({
|
|
3156
|
-
Request,
|
|
3430
|
+
const globalFetchAPI = (({ Request, Response }) => ({
|
|
3431
|
+
Request,
|
|
3432
|
+
Response,
|
|
3157
3433
|
}))(utils$1.global);
|
|
3158
3434
|
|
|
3159
|
-
const {
|
|
3160
|
-
ReadableStream: ReadableStream$1, TextEncoder
|
|
3161
|
-
} = utils$1.global;
|
|
3162
|
-
|
|
3435
|
+
const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
|
|
3163
3436
|
|
|
3164
3437
|
const test = (fn, ...args) => {
|
|
3165
3438
|
try {
|
|
3166
3439
|
return !!fn(...args);
|
|
3167
3440
|
} catch (e) {
|
|
3168
|
-
return false
|
|
3441
|
+
return false;
|
|
3169
3442
|
}
|
|
3170
3443
|
};
|
|
3171
3444
|
|
|
3172
3445
|
const factory = (env) => {
|
|
3173
|
-
env = utils$1.merge.call(
|
|
3174
|
-
|
|
3175
|
-
|
|
3446
|
+
env = utils$1.merge.call(
|
|
3447
|
+
{
|
|
3448
|
+
skipUndefined: true,
|
|
3449
|
+
},
|
|
3450
|
+
globalFetchAPI,
|
|
3451
|
+
env
|
|
3452
|
+
);
|
|
3176
3453
|
|
|
3177
|
-
const {fetch: envFetch, Request, Response} = env;
|
|
3454
|
+
const { fetch: envFetch, Request, Response } = env;
|
|
3178
3455
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
3179
3456
|
const isRequestSupported = isFunction(Request);
|
|
3180
3457
|
const isResponseSupported = isFunction(Response);
|
|
@@ -3185,46 +3462,67 @@ const factory = (env) => {
|
|
|
3185
3462
|
|
|
3186
3463
|
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
3187
3464
|
|
|
3188
|
-
const encodeText =
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3465
|
+
const encodeText =
|
|
3466
|
+
isFetchSupported &&
|
|
3467
|
+
(typeof TextEncoder === 'function'
|
|
3468
|
+
? (
|
|
3469
|
+
(encoder) => (str) =>
|
|
3470
|
+
encoder.encode(str)
|
|
3471
|
+
)(new TextEncoder())
|
|
3472
|
+
: async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
3473
|
+
|
|
3474
|
+
const supportsRequestStream =
|
|
3475
|
+
isRequestSupported &&
|
|
3476
|
+
isReadableStreamSupported &&
|
|
3477
|
+
test(() => {
|
|
3478
|
+
let duplexAccessed = false;
|
|
3479
|
+
|
|
3480
|
+
const request = new Request(platform.origin, {
|
|
3481
|
+
body: new ReadableStream$1(),
|
|
3482
|
+
method: 'POST',
|
|
3483
|
+
get duplex() {
|
|
3484
|
+
duplexAccessed = true;
|
|
3485
|
+
return 'half';
|
|
3486
|
+
},
|
|
3487
|
+
});
|
|
3192
3488
|
|
|
3193
|
-
|
|
3194
|
-
let duplexAccessed = false;
|
|
3489
|
+
const hasContentType = request.headers.has('Content-Type');
|
|
3195
3490
|
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
get duplex() {
|
|
3200
|
-
duplexAccessed = true;
|
|
3201
|
-
return 'half';
|
|
3202
|
-
},
|
|
3203
|
-
}).headers.has('Content-Type');
|
|
3491
|
+
if (request.body != null) {
|
|
3492
|
+
request.body.cancel();
|
|
3493
|
+
}
|
|
3204
3494
|
|
|
3205
|
-
|
|
3206
|
-
|
|
3495
|
+
return duplexAccessed && !hasContentType;
|
|
3496
|
+
});
|
|
3207
3497
|
|
|
3208
|
-
const supportsResponseStream =
|
|
3498
|
+
const supportsResponseStream =
|
|
3499
|
+
isResponseSupported &&
|
|
3500
|
+
isReadableStreamSupported &&
|
|
3209
3501
|
test(() => utils$1.isReadableStream(new Response('').body));
|
|
3210
3502
|
|
|
3211
3503
|
const resolvers = {
|
|
3212
|
-
stream: supportsResponseStream && ((res) => res.body)
|
|
3504
|
+
stream: supportsResponseStream && ((res) => res.body),
|
|
3213
3505
|
};
|
|
3214
3506
|
|
|
3215
|
-
isFetchSupported &&
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3507
|
+
isFetchSupported &&
|
|
3508
|
+
(() => {
|
|
3509
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
|
|
3510
|
+
!resolvers[type] &&
|
|
3511
|
+
(resolvers[type] = (res, config) => {
|
|
3512
|
+
let method = res && res[type];
|
|
3219
3513
|
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3514
|
+
if (method) {
|
|
3515
|
+
return method.call(res);
|
|
3516
|
+
}
|
|
3223
3517
|
|
|
3224
|
-
|
|
3518
|
+
throw new AxiosError$1(
|
|
3519
|
+
`Response type '${type}' is not supported`,
|
|
3520
|
+
AxiosError$1.ERR_NOT_SUPPORT,
|
|
3521
|
+
config
|
|
3522
|
+
);
|
|
3523
|
+
});
|
|
3225
3524
|
});
|
|
3226
|
-
});
|
|
3227
|
-
})());
|
|
3525
|
+
})();
|
|
3228
3526
|
|
|
3229
3527
|
const getBodyLength = async (body) => {
|
|
3230
3528
|
if (body == null) {
|
|
@@ -3275,32 +3573,41 @@ const factory = (env) => {
|
|
|
3275
3573
|
responseType,
|
|
3276
3574
|
headers,
|
|
3277
3575
|
withCredentials = 'same-origin',
|
|
3278
|
-
fetchOptions
|
|
3576
|
+
fetchOptions,
|
|
3279
3577
|
} = resolveConfig(config);
|
|
3280
3578
|
|
|
3281
3579
|
let _fetch = envFetch || fetch;
|
|
3282
3580
|
|
|
3283
3581
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3284
3582
|
|
|
3285
|
-
let composedSignal = composeSignals(
|
|
3583
|
+
let composedSignal = composeSignals(
|
|
3584
|
+
[signal, cancelToken && cancelToken.toAbortSignal()],
|
|
3585
|
+
timeout
|
|
3586
|
+
);
|
|
3286
3587
|
|
|
3287
3588
|
let request = null;
|
|
3288
3589
|
|
|
3289
|
-
const unsubscribe =
|
|
3290
|
-
composedSignal
|
|
3291
|
-
|
|
3590
|
+
const unsubscribe =
|
|
3591
|
+
composedSignal &&
|
|
3592
|
+
composedSignal.unsubscribe &&
|
|
3593
|
+
(() => {
|
|
3594
|
+
composedSignal.unsubscribe();
|
|
3595
|
+
});
|
|
3292
3596
|
|
|
3293
3597
|
let requestContentLength;
|
|
3294
3598
|
|
|
3295
3599
|
try {
|
|
3296
3600
|
if (
|
|
3297
|
-
onUploadProgress &&
|
|
3601
|
+
onUploadProgress &&
|
|
3602
|
+
supportsRequestStream &&
|
|
3603
|
+
method !== 'get' &&
|
|
3604
|
+
method !== 'head' &&
|
|
3298
3605
|
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
3299
3606
|
) {
|
|
3300
3607
|
let _request = new Request(url, {
|
|
3301
3608
|
method: 'POST',
|
|
3302
3609
|
body: data,
|
|
3303
|
-
duplex:
|
|
3610
|
+
duplex: 'half',
|
|
3304
3611
|
});
|
|
3305
3612
|
|
|
3306
3613
|
let contentTypeHeader;
|
|
@@ -3325,7 +3632,20 @@ const factory = (env) => {
|
|
|
3325
3632
|
|
|
3326
3633
|
// Cloudflare Workers throws when credentials are defined
|
|
3327
3634
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
3328
|
-
const isCredentialsSupported = isRequestSupported &&
|
|
3635
|
+
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
3636
|
+
|
|
3637
|
+
// If data is FormData and Content-Type is multipart/form-data without boundary,
|
|
3638
|
+
// delete it so fetch can set it correctly with the boundary
|
|
3639
|
+
if (utils$1.isFormData(data)) {
|
|
3640
|
+
const contentType = headers.getContentType();
|
|
3641
|
+
if (
|
|
3642
|
+
contentType &&
|
|
3643
|
+
/^multipart\/form-data/i.test(contentType) &&
|
|
3644
|
+
!/boundary=/i.test(contentType)
|
|
3645
|
+
) {
|
|
3646
|
+
headers.delete('content-type');
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3329
3649
|
|
|
3330
3650
|
const resolvedOptions = {
|
|
3331
3651
|
...fetchOptions,
|
|
@@ -3333,29 +3653,35 @@ const factory = (env) => {
|
|
|
3333
3653
|
method: method.toUpperCase(),
|
|
3334
3654
|
headers: headers.normalize().toJSON(),
|
|
3335
3655
|
body: data,
|
|
3336
|
-
duplex:
|
|
3337
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3656
|
+
duplex: 'half',
|
|
3657
|
+
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
3338
3658
|
};
|
|
3339
3659
|
|
|
3340
3660
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3341
3661
|
|
|
3342
|
-
let response = await (isRequestSupported
|
|
3662
|
+
let response = await (isRequestSupported
|
|
3663
|
+
? _fetch(request, fetchOptions)
|
|
3664
|
+
: _fetch(url, resolvedOptions));
|
|
3343
3665
|
|
|
3344
|
-
const isStreamResponse =
|
|
3666
|
+
const isStreamResponse =
|
|
3667
|
+
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3345
3668
|
|
|
3346
3669
|
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
3347
3670
|
const options = {};
|
|
3348
3671
|
|
|
3349
|
-
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3672
|
+
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
3350
3673
|
options[prop] = response[prop];
|
|
3351
3674
|
});
|
|
3352
3675
|
|
|
3353
3676
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3354
3677
|
|
|
3355
|
-
const [onProgress, flush] =
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3678
|
+
const [onProgress, flush] =
|
|
3679
|
+
(onDownloadProgress &&
|
|
3680
|
+
progressEventDecorator(
|
|
3681
|
+
responseContentLength,
|
|
3682
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3683
|
+
)) ||
|
|
3684
|
+
[];
|
|
3359
3685
|
|
|
3360
3686
|
response = new Response(
|
|
3361
3687
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
@@ -3368,7 +3694,10 @@ const factory = (env) => {
|
|
|
3368
3694
|
|
|
3369
3695
|
responseType = responseType || 'text';
|
|
3370
3696
|
|
|
3371
|
-
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3697
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3698
|
+
response,
|
|
3699
|
+
config
|
|
3700
|
+
);
|
|
3372
3701
|
|
|
3373
3702
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3374
3703
|
|
|
@@ -3379,43 +3708,50 @@ const factory = (env) => {
|
|
|
3379
3708
|
status: response.status,
|
|
3380
3709
|
statusText: response.statusText,
|
|
3381
3710
|
config,
|
|
3382
|
-
request
|
|
3711
|
+
request,
|
|
3383
3712
|
});
|
|
3384
|
-
})
|
|
3713
|
+
});
|
|
3385
3714
|
} catch (err) {
|
|
3386
3715
|
unsubscribe && unsubscribe();
|
|
3387
3716
|
|
|
3388
3717
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3389
3718
|
throw Object.assign(
|
|
3390
|
-
new AxiosError$1(
|
|
3719
|
+
new AxiosError$1(
|
|
3720
|
+
'Network Error',
|
|
3721
|
+
AxiosError$1.ERR_NETWORK,
|
|
3722
|
+
config,
|
|
3723
|
+
request,
|
|
3724
|
+
err && err.response
|
|
3725
|
+
),
|
|
3391
3726
|
{
|
|
3392
|
-
cause: err.cause || err
|
|
3727
|
+
cause: err.cause || err,
|
|
3393
3728
|
}
|
|
3394
|
-
)
|
|
3729
|
+
);
|
|
3395
3730
|
}
|
|
3396
3731
|
|
|
3397
3732
|
throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
|
|
3398
3733
|
}
|
|
3399
|
-
}
|
|
3734
|
+
};
|
|
3400
3735
|
};
|
|
3401
3736
|
|
|
3402
3737
|
const seedCache = new Map();
|
|
3403
3738
|
|
|
3404
3739
|
const getFetch = (config) => {
|
|
3405
3740
|
let env = (config && config.env) || {};
|
|
3406
|
-
const {fetch, Request, Response} = env;
|
|
3407
|
-
const seeds = [
|
|
3408
|
-
Request, Response, fetch
|
|
3409
|
-
];
|
|
3741
|
+
const { fetch, Request, Response } = env;
|
|
3742
|
+
const seeds = [Request, Response, fetch];
|
|
3410
3743
|
|
|
3411
|
-
let len = seeds.length,
|
|
3412
|
-
|
|
3744
|
+
let len = seeds.length,
|
|
3745
|
+
i = len,
|
|
3746
|
+
seed,
|
|
3747
|
+
target,
|
|
3748
|
+
map = seedCache;
|
|
3413
3749
|
|
|
3414
3750
|
while (i--) {
|
|
3415
3751
|
seed = seeds[i];
|
|
3416
3752
|
target = map.get(seed);
|
|
3417
3753
|
|
|
3418
|
-
target === undefined && map.set(seed, target =
|
|
3754
|
+
target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
|
|
3419
3755
|
|
|
3420
3756
|
map = target;
|
|
3421
3757
|
}
|
|
@@ -3431,7 +3767,7 @@ getFetch();
|
|
|
3431
3767
|
* - `http` for Node.js
|
|
3432
3768
|
* - `xhr` for browsers
|
|
3433
3769
|
* - `fetch` for fetch API-based requests
|
|
3434
|
-
*
|
|
3770
|
+
*
|
|
3435
3771
|
* @type {Object<string, Function|Object>}
|
|
3436
3772
|
*/
|
|
3437
3773
|
const knownAdapters = {
|
|
@@ -3439,7 +3775,7 @@ const knownAdapters = {
|
|
|
3439
3775
|
xhr: xhrAdapter,
|
|
3440
3776
|
fetch: {
|
|
3441
3777
|
get: getFetch,
|
|
3442
|
-
}
|
|
3778
|
+
},
|
|
3443
3779
|
};
|
|
3444
3780
|
|
|
3445
3781
|
// Assign adapter names for easier debugging and identification
|
|
@@ -3456,7 +3792,7 @@ utils$1.forEach(knownAdapters, (fn, value) => {
|
|
|
3456
3792
|
|
|
3457
3793
|
/**
|
|
3458
3794
|
* Render a rejection reason string for unknown or unsupported adapters
|
|
3459
|
-
*
|
|
3795
|
+
*
|
|
3460
3796
|
* @param {string} reason
|
|
3461
3797
|
* @returns {string}
|
|
3462
3798
|
*/
|
|
@@ -3464,17 +3800,18 @@ const renderReason = (reason) => `- ${reason}`;
|
|
|
3464
3800
|
|
|
3465
3801
|
/**
|
|
3466
3802
|
* Check if the adapter is resolved (function, null, or false)
|
|
3467
|
-
*
|
|
3803
|
+
*
|
|
3468
3804
|
* @param {Function|null|false} adapter
|
|
3469
3805
|
* @returns {boolean}
|
|
3470
3806
|
*/
|
|
3471
|
-
const isResolvedHandle = (adapter) =>
|
|
3807
|
+
const isResolvedHandle = (adapter) =>
|
|
3808
|
+
utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3472
3809
|
|
|
3473
3810
|
/**
|
|
3474
3811
|
* Get the first suitable adapter from the provided list.
|
|
3475
3812
|
* Tries each adapter in order until a supported one is found.
|
|
3476
3813
|
* Throws an AxiosError if no adapter is suitable.
|
|
3477
|
-
*
|
|
3814
|
+
*
|
|
3478
3815
|
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3479
3816
|
* @param {Object} config - Axios request configuration
|
|
3480
3817
|
* @throws {AxiosError} If no suitable adapter is available
|
|
@@ -3511,14 +3848,17 @@ function getAdapter$1(adapters, config) {
|
|
|
3511
3848
|
}
|
|
3512
3849
|
|
|
3513
3850
|
if (!adapter) {
|
|
3514
|
-
const reasons = Object.entries(rejectedReasons)
|
|
3515
|
-
|
|
3851
|
+
const reasons = Object.entries(rejectedReasons).map(
|
|
3852
|
+
([id, state]) =>
|
|
3853
|
+
`adapter ${id} ` +
|
|
3516
3854
|
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3517
|
-
|
|
3855
|
+
);
|
|
3518
3856
|
|
|
3519
|
-
let s = length
|
|
3520
|
-
|
|
3521
|
-
|
|
3857
|
+
let s = length
|
|
3858
|
+
? reasons.length > 1
|
|
3859
|
+
? 'since :\n' + reasons.map(renderReason).join('\n')
|
|
3860
|
+
: ' ' + renderReason(reasons[0])
|
|
3861
|
+
: 'as no adapter specified';
|
|
3522
3862
|
|
|
3523
3863
|
throw new AxiosError$1(
|
|
3524
3864
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
@@ -3543,7 +3883,7 @@ var adapters = {
|
|
|
3543
3883
|
* Exposes all known adapters
|
|
3544
3884
|
* @type {Object<string, Function|Object>}
|
|
3545
3885
|
*/
|
|
3546
|
-
adapters: knownAdapters
|
|
3886
|
+
adapters: knownAdapters,
|
|
3547
3887
|
};
|
|
3548
3888
|
|
|
3549
3889
|
/**
|
|
@@ -3576,10 +3916,7 @@ function dispatchRequest(config) {
|
|
|
3576
3916
|
config.headers = AxiosHeaders$1.from(config.headers);
|
|
3577
3917
|
|
|
3578
3918
|
// Transform request data
|
|
3579
|
-
config.data = transformData.call(
|
|
3580
|
-
config,
|
|
3581
|
-
config.transformRequest
|
|
3582
|
-
);
|
|
3919
|
+
config.data = transformData.call(config, config.transformRequest);
|
|
3583
3920
|
|
|
3584
3921
|
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
3585
3922
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
@@ -3587,39 +3924,38 @@ function dispatchRequest(config) {
|
|
|
3587
3924
|
|
|
3588
3925
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
3589
3926
|
|
|
3590
|
-
return adapter(config).then(
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
// Transform response data
|
|
3594
|
-
response.data = transformData.call(
|
|
3595
|
-
config,
|
|
3596
|
-
config.transformResponse,
|
|
3597
|
-
response
|
|
3598
|
-
);
|
|
3599
|
-
|
|
3600
|
-
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3601
|
-
|
|
3602
|
-
return response;
|
|
3603
|
-
}, function onAdapterRejection(reason) {
|
|
3604
|
-
if (!isCancel$1(reason)) {
|
|
3927
|
+
return adapter(config).then(
|
|
3928
|
+
function onAdapterResolution(response) {
|
|
3605
3929
|
throwIfCancellationRequested(config);
|
|
3606
3930
|
|
|
3607
3931
|
// Transform response data
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3932
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
3933
|
+
|
|
3934
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3935
|
+
|
|
3936
|
+
return response;
|
|
3937
|
+
},
|
|
3938
|
+
function onAdapterRejection(reason) {
|
|
3939
|
+
if (!isCancel$1(reason)) {
|
|
3940
|
+
throwIfCancellationRequested(config);
|
|
3941
|
+
|
|
3942
|
+
// Transform response data
|
|
3943
|
+
if (reason && reason.response) {
|
|
3944
|
+
reason.response.data = transformData.call(
|
|
3945
|
+
config,
|
|
3946
|
+
config.transformResponse,
|
|
3947
|
+
reason.response
|
|
3948
|
+
);
|
|
3949
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
3950
|
+
}
|
|
3615
3951
|
}
|
|
3616
|
-
}
|
|
3617
3952
|
|
|
3618
|
-
|
|
3619
|
-
|
|
3953
|
+
return Promise.reject(reason);
|
|
3954
|
+
}
|
|
3955
|
+
);
|
|
3620
3956
|
}
|
|
3621
3957
|
|
|
3622
|
-
const VERSION$1 = "1.
|
|
3958
|
+
const VERSION$1 = "1.15.2";
|
|
3623
3959
|
|
|
3624
3960
|
const validators$1 = {};
|
|
3625
3961
|
|
|
@@ -3643,7 +3979,15 @@ const deprecatedWarnings = {};
|
|
|
3643
3979
|
*/
|
|
3644
3980
|
validators$1.transitional = function transitional(validator, version, message) {
|
|
3645
3981
|
function formatMessage(opt, desc) {
|
|
3646
|
-
return
|
|
3982
|
+
return (
|
|
3983
|
+
'[Axios v' +
|
|
3984
|
+
VERSION$1 +
|
|
3985
|
+
"] Transitional option '" +
|
|
3986
|
+
opt +
|
|
3987
|
+
"'" +
|
|
3988
|
+
desc +
|
|
3989
|
+
(message ? '. ' + message : '')
|
|
3990
|
+
);
|
|
3647
3991
|
}
|
|
3648
3992
|
|
|
3649
3993
|
// eslint-disable-next-line func-names
|
|
@@ -3675,7 +4019,7 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
3675
4019
|
// eslint-disable-next-line no-console
|
|
3676
4020
|
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
3677
4021
|
return true;
|
|
3678
|
-
}
|
|
4022
|
+
};
|
|
3679
4023
|
};
|
|
3680
4024
|
|
|
3681
4025
|
/**
|
|
@@ -3696,12 +4040,17 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3696
4040
|
let i = keys.length;
|
|
3697
4041
|
while (i-- > 0) {
|
|
3698
4042
|
const opt = keys[i];
|
|
3699
|
-
|
|
4043
|
+
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
4044
|
+
// a non-function validator and cause a TypeError. See GHSA-q8qp-cvcw-x6jj.
|
|
4045
|
+
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
3700
4046
|
if (validator) {
|
|
3701
4047
|
const value = options[opt];
|
|
3702
4048
|
const result = value === undefined || validator(value, opt, options);
|
|
3703
4049
|
if (result !== true) {
|
|
3704
|
-
throw new AxiosError$1(
|
|
4050
|
+
throw new AxiosError$1(
|
|
4051
|
+
'option ' + opt + ' must be ' + result,
|
|
4052
|
+
AxiosError$1.ERR_BAD_OPTION_VALUE
|
|
4053
|
+
);
|
|
3705
4054
|
}
|
|
3706
4055
|
continue;
|
|
3707
4056
|
}
|
|
@@ -3713,7 +4062,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3713
4062
|
|
|
3714
4063
|
var validator = {
|
|
3715
4064
|
assertOptions,
|
|
3716
|
-
validators: validators$1
|
|
4065
|
+
validators: validators$1,
|
|
3717
4066
|
};
|
|
3718
4067
|
|
|
3719
4068
|
const validators = validator.validators;
|
|
@@ -3730,7 +4079,7 @@ let Axios$1 = class Axios {
|
|
|
3730
4079
|
this.defaults = instanceConfig || {};
|
|
3731
4080
|
this.interceptors = {
|
|
3732
4081
|
request: new InterceptorManager(),
|
|
3733
|
-
response: new InterceptorManager()
|
|
4082
|
+
response: new InterceptorManager(),
|
|
3734
4083
|
};
|
|
3735
4084
|
}
|
|
3736
4085
|
|
|
@@ -3752,13 +4101,29 @@ let Axios$1 = class Axios {
|
|
|
3752
4101
|
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
3753
4102
|
|
|
3754
4103
|
// slice off the Error: ... line
|
|
3755
|
-
const stack =
|
|
4104
|
+
const stack = (() => {
|
|
4105
|
+
if (!dummy.stack) {
|
|
4106
|
+
return '';
|
|
4107
|
+
}
|
|
4108
|
+
|
|
4109
|
+
const firstNewlineIndex = dummy.stack.indexOf('\n');
|
|
4110
|
+
|
|
4111
|
+
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
4112
|
+
})();
|
|
3756
4113
|
try {
|
|
3757
4114
|
if (!err.stack) {
|
|
3758
4115
|
err.stack = stack;
|
|
3759
4116
|
// match without the 2 top stack lines
|
|
3760
|
-
} else if (stack
|
|
3761
|
-
|
|
4117
|
+
} else if (stack) {
|
|
4118
|
+
const firstNewlineIndex = stack.indexOf('\n');
|
|
4119
|
+
const secondNewlineIndex =
|
|
4120
|
+
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
4121
|
+
const stackWithoutTwoTopLines =
|
|
4122
|
+
secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|
4123
|
+
|
|
4124
|
+
if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
|
|
4125
|
+
err.stack += '\n' + stack;
|
|
4126
|
+
}
|
|
3762
4127
|
}
|
|
3763
4128
|
} catch (e) {
|
|
3764
4129
|
// ignore the case where "stack" is an un-writable property
|
|
@@ -3781,27 +4146,35 @@ let Axios$1 = class Axios {
|
|
|
3781
4146
|
|
|
3782
4147
|
config = mergeConfig$1(this.defaults, config);
|
|
3783
4148
|
|
|
3784
|
-
const {transitional, paramsSerializer, headers} = config;
|
|
4149
|
+
const { transitional, paramsSerializer, headers } = config;
|
|
3785
4150
|
|
|
3786
4151
|
if (transitional !== undefined) {
|
|
3787
|
-
validator.assertOptions(
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
4152
|
+
validator.assertOptions(
|
|
4153
|
+
transitional,
|
|
4154
|
+
{
|
|
4155
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
4156
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
4157
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
4158
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
4159
|
+
},
|
|
4160
|
+
false
|
|
4161
|
+
);
|
|
3793
4162
|
}
|
|
3794
4163
|
|
|
3795
4164
|
if (paramsSerializer != null) {
|
|
3796
4165
|
if (utils$1.isFunction(paramsSerializer)) {
|
|
3797
4166
|
config.paramsSerializer = {
|
|
3798
|
-
serialize: paramsSerializer
|
|
4167
|
+
serialize: paramsSerializer,
|
|
3799
4168
|
};
|
|
3800
4169
|
} else {
|
|
3801
|
-
validator.assertOptions(
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
4170
|
+
validator.assertOptions(
|
|
4171
|
+
paramsSerializer,
|
|
4172
|
+
{
|
|
4173
|
+
encode: validators.function,
|
|
4174
|
+
serialize: validators.function,
|
|
4175
|
+
},
|
|
4176
|
+
true
|
|
4177
|
+
);
|
|
3805
4178
|
}
|
|
3806
4179
|
}
|
|
3807
4180
|
|
|
@@ -3812,26 +4185,25 @@ let Axios$1 = class Axios {
|
|
|
3812
4185
|
config.allowAbsoluteUrls = true;
|
|
3813
4186
|
}
|
|
3814
4187
|
|
|
3815
|
-
validator.assertOptions(
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
4188
|
+
validator.assertOptions(
|
|
4189
|
+
config,
|
|
4190
|
+
{
|
|
4191
|
+
baseUrl: validators.spelling('baseURL'),
|
|
4192
|
+
withXsrfToken: validators.spelling('withXSRFToken'),
|
|
4193
|
+
},
|
|
4194
|
+
true
|
|
4195
|
+
);
|
|
3819
4196
|
|
|
3820
4197
|
// Set config.method
|
|
3821
4198
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3822
4199
|
|
|
3823
4200
|
// Flatten headers
|
|
3824
|
-
let contextHeaders = headers && utils$1.merge(
|
|
3825
|
-
headers.common,
|
|
3826
|
-
headers[config.method]
|
|
3827
|
-
);
|
|
4201
|
+
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
3828
4202
|
|
|
3829
|
-
headers &&
|
|
3830
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3831
|
-
(method) => {
|
|
4203
|
+
headers &&
|
|
4204
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
3832
4205
|
delete headers[method];
|
|
3833
|
-
}
|
|
3834
|
-
);
|
|
4206
|
+
});
|
|
3835
4207
|
|
|
3836
4208
|
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
3837
4209
|
|
|
@@ -3846,7 +4218,8 @@ let Axios$1 = class Axios {
|
|
|
3846
4218
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3847
4219
|
|
|
3848
4220
|
const transitional = config.transitional || transitionalDefaults;
|
|
3849
|
-
const legacyInterceptorReqResOrdering =
|
|
4221
|
+
const legacyInterceptorReqResOrdering =
|
|
4222
|
+
transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3850
4223
|
|
|
3851
4224
|
if (legacyInterceptorReqResOrdering) {
|
|
3852
4225
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
@@ -3920,28 +4293,32 @@ let Axios$1 = class Axios {
|
|
|
3920
4293
|
// Provide aliases for supported request methods
|
|
3921
4294
|
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3922
4295
|
/*eslint func-names:0*/
|
|
3923
|
-
Axios$1.prototype[method] = function(url, config) {
|
|
3924
|
-
return this.request(
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
4296
|
+
Axios$1.prototype[method] = function (url, config) {
|
|
4297
|
+
return this.request(
|
|
4298
|
+
mergeConfig$1(config || {}, {
|
|
4299
|
+
method,
|
|
4300
|
+
url,
|
|
4301
|
+
data: (config || {}).data,
|
|
4302
|
+
})
|
|
4303
|
+
);
|
|
3929
4304
|
};
|
|
3930
4305
|
});
|
|
3931
4306
|
|
|
3932
4307
|
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3933
|
-
/*eslint func-names:0*/
|
|
3934
|
-
|
|
3935
4308
|
function generateHTTPMethod(isForm) {
|
|
3936
4309
|
return function httpMethod(url, data, config) {
|
|
3937
|
-
return this.request(
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
4310
|
+
return this.request(
|
|
4311
|
+
mergeConfig$1(config || {}, {
|
|
4312
|
+
method,
|
|
4313
|
+
headers: isForm
|
|
4314
|
+
? {
|
|
4315
|
+
'Content-Type': 'multipart/form-data',
|
|
4316
|
+
}
|
|
4317
|
+
: {},
|
|
4318
|
+
url,
|
|
4319
|
+
data,
|
|
4320
|
+
})
|
|
4321
|
+
);
|
|
3945
4322
|
};
|
|
3946
4323
|
}
|
|
3947
4324
|
|
|
@@ -3972,7 +4349,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
3972
4349
|
const token = this;
|
|
3973
4350
|
|
|
3974
4351
|
// eslint-disable-next-line func-names
|
|
3975
|
-
this.promise.then(cancel => {
|
|
4352
|
+
this.promise.then((cancel) => {
|
|
3976
4353
|
if (!token._listeners) return;
|
|
3977
4354
|
|
|
3978
4355
|
let i = token._listeners.length;
|
|
@@ -3984,10 +4361,10 @@ let CancelToken$1 = class CancelToken {
|
|
|
3984
4361
|
});
|
|
3985
4362
|
|
|
3986
4363
|
// eslint-disable-next-line func-names
|
|
3987
|
-
this.promise.then = onfulfilled => {
|
|
4364
|
+
this.promise.then = (onfulfilled) => {
|
|
3988
4365
|
let _resolve;
|
|
3989
4366
|
// eslint-disable-next-line func-names
|
|
3990
|
-
const promise = new Promise(resolve => {
|
|
4367
|
+
const promise = new Promise((resolve) => {
|
|
3991
4368
|
token.subscribe(resolve);
|
|
3992
4369
|
_resolve = resolve;
|
|
3993
4370
|
}).then(onfulfilled);
|
|
@@ -4075,7 +4452,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
4075
4452
|
});
|
|
4076
4453
|
return {
|
|
4077
4454
|
token,
|
|
4078
|
-
cancel
|
|
4455
|
+
cancel,
|
|
4079
4456
|
};
|
|
4080
4457
|
}
|
|
4081
4458
|
};
|
|
@@ -4115,7 +4492,7 @@ function spread$1(callback) {
|
|
|
4115
4492
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
4116
4493
|
*/
|
|
4117
4494
|
function isAxiosError$1(payload) {
|
|
4118
|
-
return utils$1.isObject(payload) &&
|
|
4495
|
+
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
4119
4496
|
}
|
|
4120
4497
|
|
|
4121
4498
|
const HttpStatusCode$1 = {
|
|
@@ -4206,10 +4583,10 @@ function createInstance(defaultConfig) {
|
|
|
4206
4583
|
const instance = bind(Axios$1.prototype.request, context);
|
|
4207
4584
|
|
|
4208
4585
|
// Copy axios.prototype to instance
|
|
4209
|
-
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
4586
|
+
utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
|
|
4210
4587
|
|
|
4211
4588
|
// Copy context to instance
|
|
4212
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
4589
|
+
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
4213
4590
|
|
|
4214
4591
|
// Factory for creating new instances
|
|
4215
4592
|
instance.create = function create(instanceConfig) {
|
|
@@ -4253,7 +4630,7 @@ axios.mergeConfig = mergeConfig$1;
|
|
|
4253
4630
|
|
|
4254
4631
|
axios.AxiosHeaders = AxiosHeaders$1;
|
|
4255
4632
|
|
|
4256
|
-
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4633
|
+
axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4257
4634
|
|
|
4258
4635
|
axios.getAdapter = adapters.getAdapter;
|
|
4259
4636
|
|
|
@@ -4280,7 +4657,7 @@ const {
|
|
|
4280
4657
|
HttpStatusCode,
|
|
4281
4658
|
formToJSON,
|
|
4282
4659
|
getAdapter,
|
|
4283
|
-
mergeConfig
|
|
4660
|
+
mergeConfig,
|
|
4284
4661
|
} = axios;
|
|
4285
4662
|
|
|
4286
4663
|
/******************************************************************************
|
|
@@ -7368,10 +7745,255 @@ class MayachainProtocol {
|
|
|
7368
7745
|
}
|
|
7369
7746
|
}
|
|
7370
7747
|
|
|
7748
|
+
const BASE_URL = 'https://1click.chaindefuser.com';
|
|
7749
|
+
class OneClickApi {
|
|
7750
|
+
constructor(apiKey) {
|
|
7751
|
+
this.headers = { 'Content-Type': 'application/json' };
|
|
7752
|
+
if (apiKey) {
|
|
7753
|
+
this.headers['Authorization'] = `Bearer ${apiKey}`;
|
|
7754
|
+
}
|
|
7755
|
+
}
|
|
7756
|
+
getTokens() {
|
|
7757
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7758
|
+
const resp = yield fetch(`${BASE_URL}/v0/tokens`, { headers: this.headers });
|
|
7759
|
+
if (!resp.ok)
|
|
7760
|
+
throw new Error(`1Click getTokens failed: ${resp.status}`);
|
|
7761
|
+
return resp.json();
|
|
7762
|
+
});
|
|
7763
|
+
}
|
|
7764
|
+
getQuote(params) {
|
|
7765
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7766
|
+
const resp = yield fetch(`${BASE_URL}/v0/quote`, {
|
|
7767
|
+
method: 'POST',
|
|
7768
|
+
headers: this.headers,
|
|
7769
|
+
body: JSON.stringify(params),
|
|
7770
|
+
});
|
|
7771
|
+
if (!resp.ok)
|
|
7772
|
+
throw new Error(`1Click getQuote failed: ${resp.status}`);
|
|
7773
|
+
return resp.json();
|
|
7774
|
+
});
|
|
7775
|
+
}
|
|
7776
|
+
submitDeposit(txHash, depositAddress) {
|
|
7777
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7778
|
+
yield fetch(`${BASE_URL}/v0/deposit/submit`, {
|
|
7779
|
+
method: 'POST',
|
|
7780
|
+
headers: this.headers,
|
|
7781
|
+
body: JSON.stringify({ txHash, depositAddress }),
|
|
7782
|
+
}).catch(() => {
|
|
7783
|
+
// Fire-and-forget
|
|
7784
|
+
});
|
|
7785
|
+
});
|
|
7786
|
+
}
|
|
7787
|
+
}
|
|
7788
|
+
|
|
7789
|
+
const X_TO_ONECLICK = {
|
|
7790
|
+
BTC: 'btc',
|
|
7791
|
+
ETH: 'eth',
|
|
7792
|
+
ARB: 'arb',
|
|
7793
|
+
AVAX: 'avax',
|
|
7794
|
+
BSC: 'bsc',
|
|
7795
|
+
SOL: 'sol',
|
|
7796
|
+
DOGE: 'doge',
|
|
7797
|
+
DASH: 'dash',
|
|
7798
|
+
LTC: 'ltc',
|
|
7799
|
+
BCH: 'bch',
|
|
7800
|
+
XRP: 'xrp',
|
|
7801
|
+
ADA: 'cardano',
|
|
7802
|
+
SUI: 'sui',
|
|
7803
|
+
};
|
|
7804
|
+
const ONECLICK_TO_X = Object.fromEntries(Object.entries(X_TO_ONECLICK).map(([k, v]) => [v, k]));
|
|
7805
|
+
const xChainToOneClickBlockchain = (chain) => {
|
|
7806
|
+
var _a;
|
|
7807
|
+
return (_a = X_TO_ONECLICK[chain]) !== null && _a !== void 0 ? _a : null;
|
|
7808
|
+
};
|
|
7809
|
+
const oneClickBlockchainToXChain = (blockchain) => {
|
|
7810
|
+
var _a;
|
|
7811
|
+
return (_a = ONECLICK_TO_X[blockchain]) !== null && _a !== void 0 ? _a : null;
|
|
7812
|
+
};
|
|
7813
|
+
const findOneClickToken = (asset, tokens) => {
|
|
7814
|
+
if (xchainUtil.isSynthAsset(asset) || xchainUtil.isTradeAsset(asset) || xchainUtil.isSecuredAsset(asset))
|
|
7815
|
+
return undefined;
|
|
7816
|
+
const blockchain = xChainToOneClickBlockchain(asset.chain);
|
|
7817
|
+
if (!blockchain)
|
|
7818
|
+
return undefined;
|
|
7819
|
+
return tokens.find((token) => {
|
|
7820
|
+
if (token.blockchain !== blockchain)
|
|
7821
|
+
return false;
|
|
7822
|
+
if (xchainUtil.isTokenAsset(asset)) {
|
|
7823
|
+
// Match by contract address (case-insensitive)
|
|
7824
|
+
const assetContract = asset.symbol.includes('-') ? asset.symbol.split('-')[1] : undefined;
|
|
7825
|
+
return assetContract && token.contractAddress
|
|
7826
|
+
? token.contractAddress.toLowerCase() === assetContract.toLowerCase()
|
|
7827
|
+
: false;
|
|
7828
|
+
}
|
|
7829
|
+
// Native asset: match by symbol, ensure no contract address on token
|
|
7830
|
+
return token.symbol.toUpperCase() === asset.symbol.toUpperCase() && !token.contractAddress;
|
|
7831
|
+
});
|
|
7832
|
+
};
|
|
7833
|
+
|
|
7834
|
+
class OneClickProtocol {
|
|
7835
|
+
constructor(configuration) {
|
|
7836
|
+
this.name = 'OneClick';
|
|
7837
|
+
this.api = new OneClickApi(configuration === null || configuration === void 0 ? void 0 : configuration.oneClickApiKey);
|
|
7838
|
+
this.wallet = configuration === null || configuration === void 0 ? void 0 : configuration.wallet;
|
|
7839
|
+
this.affiliateAddress = configuration === null || configuration === void 0 ? void 0 : configuration.affiliateAddress;
|
|
7840
|
+
this.affiliateBps = configuration === null || configuration === void 0 ? void 0 : configuration.affiliateBps;
|
|
7841
|
+
this.tokensCache = new xchainUtil.CachedValue(() => this.api.getTokens(), 24 * 60 * 60 * 1000);
|
|
7842
|
+
}
|
|
7843
|
+
approveRouterToSpend(_params) {
|
|
7844
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7845
|
+
throw new Error('Not implemented');
|
|
7846
|
+
});
|
|
7847
|
+
}
|
|
7848
|
+
shouldBeApproved(_params) {
|
|
7849
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7850
|
+
return false;
|
|
7851
|
+
});
|
|
7852
|
+
}
|
|
7853
|
+
isAssetSupported(asset) {
|
|
7854
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7855
|
+
if (xchainUtil.isSynthAsset(asset) || xchainUtil.isTradeAsset(asset) || xchainUtil.isSecuredAsset(asset))
|
|
7856
|
+
return false;
|
|
7857
|
+
const tokens = yield this.tokensCache.getValue();
|
|
7858
|
+
return findOneClickToken(asset, tokens) !== undefined;
|
|
7859
|
+
});
|
|
7860
|
+
}
|
|
7861
|
+
getSupportedChains() {
|
|
7862
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7863
|
+
const tokens = yield this.tokensCache.getValue();
|
|
7864
|
+
const chains = new Set();
|
|
7865
|
+
for (const token of tokens) {
|
|
7866
|
+
const chain = oneClickBlockchainToXChain(token.blockchain);
|
|
7867
|
+
if (chain)
|
|
7868
|
+
chains.add(chain);
|
|
7869
|
+
}
|
|
7870
|
+
return Array.from(chains);
|
|
7871
|
+
});
|
|
7872
|
+
}
|
|
7873
|
+
estimateSwap(params) {
|
|
7874
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7875
|
+
var _a, _b, _c;
|
|
7876
|
+
const tokens = yield this.tokensCache.getValue();
|
|
7877
|
+
const srcToken = findOneClickToken(params.fromAsset, tokens);
|
|
7878
|
+
const destToken = findOneClickToken(params.destinationAsset, tokens);
|
|
7879
|
+
if (!srcToken || !destToken) {
|
|
7880
|
+
return this.errorQuote(params, srcToken ? 'Destination asset not supported' : 'Source asset not supported');
|
|
7881
|
+
}
|
|
7882
|
+
try {
|
|
7883
|
+
const isDry = !(params.fromAddress && params.destinationAddress);
|
|
7884
|
+
const deadline = new Date(Date.now() + 10 * 60 * 1000).toISOString();
|
|
7885
|
+
const appFees = this.affiliateAddress && this.affiliateBps
|
|
7886
|
+
? [{ recipient: this.affiliateAddress, fee: this.affiliateBps }]
|
|
7887
|
+
: undefined;
|
|
7888
|
+
const resp = yield this.api.getQuote({
|
|
7889
|
+
dry: isDry,
|
|
7890
|
+
swapType: 'EXACT_INPUT',
|
|
7891
|
+
depositType: 'ORIGIN_CHAIN',
|
|
7892
|
+
recipientType: 'DESTINATION_CHAIN',
|
|
7893
|
+
refundType: 'ORIGIN_CHAIN',
|
|
7894
|
+
originAsset: srcToken.assetId,
|
|
7895
|
+
destinationAsset: destToken.assetId,
|
|
7896
|
+
amount: params.amount.baseAmount.amount().toString(),
|
|
7897
|
+
refundTo: params.fromAddress || '',
|
|
7898
|
+
recipient: params.destinationAddress || '',
|
|
7899
|
+
slippageTolerance: (_a = params.toleranceBps) !== null && _a !== void 0 ? _a : 100,
|
|
7900
|
+
deadline,
|
|
7901
|
+
appFees,
|
|
7902
|
+
});
|
|
7903
|
+
if (resp.error || resp.message) {
|
|
7904
|
+
return this.errorQuote(params, resp.error || resp.message || 'Unknown error');
|
|
7905
|
+
}
|
|
7906
|
+
const quote = resp.quote;
|
|
7907
|
+
const toAddress = (_b = quote.depositAddress) !== null && _b !== void 0 ? _b : '';
|
|
7908
|
+
return {
|
|
7909
|
+
protocol: this.name,
|
|
7910
|
+
toAddress,
|
|
7911
|
+
memo: '',
|
|
7912
|
+
expectedAmount: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(quote.amountOut, destToken.decimals), params.destinationAsset),
|
|
7913
|
+
dustThreshold: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.fromAsset),
|
|
7914
|
+
totalSwapSeconds: (_c = quote.timeEstimate) !== null && _c !== void 0 ? _c : 0,
|
|
7915
|
+
maxStreamingQuantity: undefined,
|
|
7916
|
+
canSwap: toAddress !== '',
|
|
7917
|
+
warning: '',
|
|
7918
|
+
errors: [],
|
|
7919
|
+
slipBasisPoints: 0,
|
|
7920
|
+
fees: {
|
|
7921
|
+
asset: params.fromAsset,
|
|
7922
|
+
affiliateFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.fromAsset),
|
|
7923
|
+
outboundFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.destinationAsset),
|
|
7924
|
+
},
|
|
7925
|
+
};
|
|
7926
|
+
}
|
|
7927
|
+
catch (e) {
|
|
7928
|
+
return this.errorQuote(params, e instanceof Error ? e.message : 'Unknown error');
|
|
7929
|
+
}
|
|
7930
|
+
});
|
|
7931
|
+
}
|
|
7932
|
+
doSwap(params) {
|
|
7933
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7934
|
+
const quoteSwap = yield this.estimateSwap(params);
|
|
7935
|
+
if (!quoteSwap.canSwap) {
|
|
7936
|
+
throw new Error(`Can not make swap. ${quoteSwap.errors.join('\n')}`);
|
|
7937
|
+
}
|
|
7938
|
+
if (!this.wallet)
|
|
7939
|
+
throw new Error('Wallet not configured. Can not do swap');
|
|
7940
|
+
const hash = yield this.wallet.transfer({
|
|
7941
|
+
recipient: quoteSwap.toAddress,
|
|
7942
|
+
amount: params.amount.baseAmount,
|
|
7943
|
+
asset: params.fromAsset,
|
|
7944
|
+
memo: quoteSwap.memo,
|
|
7945
|
+
});
|
|
7946
|
+
// Funds are already on the wire. Awaiting submitDeposit lets callers distinguish
|
|
7947
|
+
// "deposit registered, swap will settle" from "registration silently failed, swap will
|
|
7948
|
+
// never settle" — surface the failure with the broadcast hash so it can be retried.
|
|
7949
|
+
try {
|
|
7950
|
+
yield this.api.submitDeposit(hash, quoteSwap.toAddress);
|
|
7951
|
+
}
|
|
7952
|
+
catch (e) {
|
|
7953
|
+
throw new Error(`1Click deposit tx ${hash} was broadcast, but submitDeposit failed: ${e instanceof Error ? e.message : 'unknown error'}`);
|
|
7954
|
+
}
|
|
7955
|
+
// Explorer URL is best-effort; the hash is what callers actually need for tracking.
|
|
7956
|
+
let url = '';
|
|
7957
|
+
try {
|
|
7958
|
+
url = yield this.wallet.getExplorerTxUrl(params.fromAsset.chain, hash);
|
|
7959
|
+
}
|
|
7960
|
+
catch (_a) {
|
|
7961
|
+
// swallow: explorer URL lookup must not reject a successful swap
|
|
7962
|
+
}
|
|
7963
|
+
return { hash, url };
|
|
7964
|
+
});
|
|
7965
|
+
}
|
|
7966
|
+
getSwapHistory(_params) {
|
|
7967
|
+
return __awaiter$4(this, void 0, void 0, function* () {
|
|
7968
|
+
return { count: 0, swaps: [] };
|
|
7969
|
+
});
|
|
7970
|
+
}
|
|
7971
|
+
errorQuote(params, error) {
|
|
7972
|
+
return {
|
|
7973
|
+
protocol: this.name,
|
|
7974
|
+
toAddress: '',
|
|
7975
|
+
memo: '',
|
|
7976
|
+
expectedAmount: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.destinationAsset),
|
|
7977
|
+
dustThreshold: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.fromAsset),
|
|
7978
|
+
totalSwapSeconds: 0,
|
|
7979
|
+
maxStreamingQuantity: undefined,
|
|
7980
|
+
canSwap: false,
|
|
7981
|
+
warning: '',
|
|
7982
|
+
errors: [error],
|
|
7983
|
+
slipBasisPoints: 0,
|
|
7984
|
+
fees: {
|
|
7985
|
+
asset: params.fromAsset,
|
|
7986
|
+
affiliateFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.fromAsset),
|
|
7987
|
+
outboundFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.destinationAsset),
|
|
7988
|
+
},
|
|
7989
|
+
};
|
|
7990
|
+
}
|
|
7991
|
+
}
|
|
7992
|
+
|
|
7371
7993
|
/**
|
|
7372
|
-
* The base URL for the Midgard API
|
|
7994
|
+
* The base URL for the Midgard API endpoint.
|
|
7373
7995
|
*/
|
|
7374
|
-
const
|
|
7996
|
+
const MIDGARD_API_URL = 'https://midgard.thorchain.network/';
|
|
7375
7997
|
|
|
7376
7998
|
/******************************************************************************
|
|
7377
7999
|
Copyright (c) Microsoft Corporation.
|
|
@@ -9846,7 +10468,7 @@ class Configuration {
|
|
|
9846
10468
|
/**
|
|
9847
10469
|
* The base URL for the Midgard API.
|
|
9848
10470
|
*/
|
|
9849
|
-
const baseUrl =
|
|
10471
|
+
const baseUrl = MIDGARD_API_URL;
|
|
9850
10472
|
/**
|
|
9851
10473
|
* Default configuration for the Midgard API client.
|
|
9852
10474
|
*/
|
|
@@ -10200,15 +10822,15 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
10200
10822
|
const defaultMidgardConfig = {
|
|
10201
10823
|
mainnet: {
|
|
10202
10824
|
apiRetries: 3,
|
|
10203
|
-
midgardBaseUrls: ['https://midgard.
|
|
10825
|
+
midgardBaseUrls: ['https://midgard.thorchain.network', 'https://gateway.liquify.com/chain/thorchain_midgard'],
|
|
10204
10826
|
},
|
|
10205
10827
|
stagenet: {
|
|
10206
10828
|
apiRetries: 3,
|
|
10207
|
-
midgardBaseUrls: [
|
|
10829
|
+
midgardBaseUrls: [],
|
|
10208
10830
|
},
|
|
10209
10831
|
testnet: {
|
|
10210
10832
|
apiRetries: 3,
|
|
10211
|
-
midgardBaseUrls: ['
|
|
10833
|
+
midgardBaseUrls: ['deprecated'],
|
|
10212
10834
|
},
|
|
10213
10835
|
};
|
|
10214
10836
|
class Midgard {
|
|
@@ -10434,7 +11056,7 @@ class MidgardQuery {
|
|
|
10434
11056
|
getFallbackDecimals(asset) {
|
|
10435
11057
|
const assetString = xchainUtil.assetToString(asset);
|
|
10436
11058
|
// Map of assets to their actual decimal places from THORChain pools
|
|
10437
|
-
// Data sourced from https://
|
|
11059
|
+
// Data sourced from https://gateway.liquify.com/chain/thorchain_api/thorchain/pools
|
|
10438
11060
|
const fallbackDecimalMap = {
|
|
10439
11061
|
// Bitcoin and forks
|
|
10440
11062
|
'BTC.BTC': 8,
|
|
@@ -10753,6 +11375,7 @@ const getProtocolConfig = (name, configuration) => {
|
|
|
10753
11375
|
network: configuration.network,
|
|
10754
11376
|
affiliateBrokers: configuration.affiliateBrokers,
|
|
10755
11377
|
brokerUrl: configuration.brokerUrl,
|
|
11378
|
+
oneClickApiKey: configuration.oneClickApiKey,
|
|
10756
11379
|
};
|
|
10757
11380
|
};
|
|
10758
11381
|
class ProtocolFactory {
|
|
@@ -10765,6 +11388,8 @@ class ProtocolFactory {
|
|
|
10765
11388
|
return new MayachainProtocol(protocolConfig);
|
|
10766
11389
|
case 'Chainflip':
|
|
10767
11390
|
return new ChainflipProtocol(protocolConfig);
|
|
11391
|
+
case 'OneClick':
|
|
11392
|
+
return new OneClickProtocol(protocolConfig);
|
|
10768
11393
|
}
|
|
10769
11394
|
}
|
|
10770
11395
|
}
|