@xchainjs/xchain-dash 2.2.2 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.d.ts +3 -26
- package/lib/index.esm.js +1198 -997
- package/lib/index.js +1195 -994
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -75,7 +75,7 @@ const AssetDASH = { chain: DASHChain, symbol: 'DASH', ticker: 'DASH', type: xcha
|
|
|
75
75
|
/**
|
|
76
76
|
* Explorer provider for Dash mainnet.
|
|
77
77
|
*/
|
|
78
|
-
const DASH_MAINNET_EXPLORER = new xchainClient.ExplorerProvider('https://
|
|
78
|
+
const DASH_MAINNET_EXPLORER = new xchainClient.ExplorerProvider('https://blockchair.com/dash', 'https://blockchair.com/dash/address/%%ADDRESS%%', 'https://blockchair.com/dash/transaction/%%TX_ID%%');
|
|
79
79
|
/**
|
|
80
80
|
* Explorer provider for Dash testnet.
|
|
81
81
|
*/
|
|
@@ -197,7 +197,7 @@ const { isArray } = Array;
|
|
|
197
197
|
*
|
|
198
198
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
199
199
|
*/
|
|
200
|
-
const isUndefined = typeOfTest(
|
|
200
|
+
const isUndefined = typeOfTest('undefined');
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
203
|
* Determine if a value is a Buffer
|
|
@@ -224,7 +224,7 @@ function isBuffer(val) {
|
|
|
224
224
|
*
|
|
225
225
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
226
226
|
*/
|
|
227
|
-
const isArrayBuffer = kindOfTest(
|
|
227
|
+
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
230
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -235,7 +235,7 @@ const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
|
235
235
|
*/
|
|
236
236
|
function isArrayBufferView(val) {
|
|
237
237
|
let result;
|
|
238
|
-
if (typeof ArrayBuffer !==
|
|
238
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
239
239
|
result = ArrayBuffer.isView(val);
|
|
240
240
|
} else {
|
|
241
241
|
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
@@ -250,7 +250,7 @@ function isArrayBufferView(val) {
|
|
|
250
250
|
*
|
|
251
251
|
* @returns {boolean} True if value is a String, otherwise false
|
|
252
252
|
*/
|
|
253
|
-
const isString = typeOfTest(
|
|
253
|
+
const isString = typeOfTest('string');
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
256
|
* Determine if a value is a Function
|
|
@@ -258,7 +258,7 @@ const isString = typeOfTest("string");
|
|
|
258
258
|
* @param {*} val The value to test
|
|
259
259
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
260
260
|
*/
|
|
261
|
-
const isFunction$1 = typeOfTest(
|
|
261
|
+
const isFunction$1 = typeOfTest('function');
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* Determine if a value is a Number
|
|
@@ -267,7 +267,7 @@ const isFunction$1 = typeOfTest("function");
|
|
|
267
267
|
*
|
|
268
268
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
269
269
|
*/
|
|
270
|
-
const isNumber = typeOfTest(
|
|
270
|
+
const isNumber = typeOfTest('number');
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
273
|
* Determine if a value is an Object
|
|
@@ -276,7 +276,7 @@ const isNumber = typeOfTest("number");
|
|
|
276
276
|
*
|
|
277
277
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
278
278
|
*/
|
|
279
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
279
|
+
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
282
|
* Determine if a value is a Boolean
|
|
@@ -294,7 +294,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
294
294
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
295
295
|
*/
|
|
296
296
|
const isPlainObject = (val) => {
|
|
297
|
-
if (kindOf(val) !==
|
|
297
|
+
if (kindOf(val) !== 'object') {
|
|
298
298
|
return false;
|
|
299
299
|
}
|
|
300
300
|
|
|
@@ -322,10 +322,7 @@ const isEmptyObject = (val) => {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
try {
|
|
325
|
-
return (
|
|
326
|
-
Object.keys(val).length === 0 &&
|
|
327
|
-
Object.getPrototypeOf(val) === Object.prototype
|
|
328
|
-
);
|
|
325
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
329
326
|
} catch (e) {
|
|
330
327
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
331
328
|
return false;
|
|
@@ -339,7 +336,7 @@ const isEmptyObject = (val) => {
|
|
|
339
336
|
*
|
|
340
337
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
341
338
|
*/
|
|
342
|
-
const isDate = kindOfTest(
|
|
339
|
+
const isDate = kindOfTest('Date');
|
|
343
340
|
|
|
344
341
|
/**
|
|
345
342
|
* Determine if a value is a File
|
|
@@ -348,7 +345,32 @@ const isDate = kindOfTest("Date");
|
|
|
348
345
|
*
|
|
349
346
|
* @returns {boolean} True if value is a File, otherwise false
|
|
350
347
|
*/
|
|
351
|
-
const isFile = kindOfTest(
|
|
348
|
+
const isFile = kindOfTest('File');
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Determine if a value is a React Native Blob
|
|
352
|
+
* React Native "blob": an object with a `uri` attribute. Optionally, it can
|
|
353
|
+
* also have a `name` and `type` attribute to specify filename and content type
|
|
354
|
+
*
|
|
355
|
+
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
356
|
+
*
|
|
357
|
+
* @param {*} value The value to test
|
|
358
|
+
*
|
|
359
|
+
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
360
|
+
*/
|
|
361
|
+
const isReactNativeBlob = (value) => {
|
|
362
|
+
return !!(value && typeof value.uri !== 'undefined');
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Determine if environment is React Native
|
|
367
|
+
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
368
|
+
*
|
|
369
|
+
* @param {*} formData The formData to test
|
|
370
|
+
*
|
|
371
|
+
* @returns {boolean} True if environment is React Native, otherwise false
|
|
372
|
+
*/
|
|
373
|
+
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
352
374
|
|
|
353
375
|
/**
|
|
354
376
|
* Determine if a value is a Blob
|
|
@@ -357,7 +379,7 @@ const isFile = kindOfTest("File");
|
|
|
357
379
|
*
|
|
358
380
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
359
381
|
*/
|
|
360
|
-
const isBlob = kindOfTest(
|
|
382
|
+
const isBlob = kindOfTest('Blob');
|
|
361
383
|
|
|
362
384
|
/**
|
|
363
385
|
* Determine if a value is a FileList
|
|
@@ -366,7 +388,7 @@ const isBlob = kindOfTest("Blob");
|
|
|
366
388
|
*
|
|
367
389
|
* @returns {boolean} True if value is a File, otherwise false
|
|
368
390
|
*/
|
|
369
|
-
const isFileList = kindOfTest(
|
|
391
|
+
const isFileList = kindOfTest('FileList');
|
|
370
392
|
|
|
371
393
|
/**
|
|
372
394
|
* Determine if a value is a Stream
|
|
@@ -384,18 +406,28 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
|
384
406
|
*
|
|
385
407
|
* @returns {boolean} True if value is an FormData, otherwise false
|
|
386
408
|
*/
|
|
409
|
+
function getGlobal() {
|
|
410
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
411
|
+
if (typeof self !== 'undefined') return self;
|
|
412
|
+
if (typeof window !== 'undefined') return window;
|
|
413
|
+
if (typeof global !== 'undefined') return global;
|
|
414
|
+
return {};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const G = getGlobal();
|
|
418
|
+
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
419
|
+
|
|
387
420
|
const isFormData = (thing) => {
|
|
388
|
-
|
|
389
|
-
return
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
);
|
|
421
|
+
if (!thing) return false;
|
|
422
|
+
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
423
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
|
|
424
|
+
const proto = getPrototypeOf(thing);
|
|
425
|
+
if (!proto || proto === Object.prototype) return false;
|
|
426
|
+
if (!isFunction$1(thing.append)) return false;
|
|
427
|
+
const kind = kindOf(thing);
|
|
428
|
+
return kind === 'formdata' ||
|
|
429
|
+
// detect form-data instance
|
|
430
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]');
|
|
399
431
|
};
|
|
400
432
|
|
|
401
433
|
/**
|
|
@@ -405,13 +437,13 @@ const isFormData = (thing) => {
|
|
|
405
437
|
*
|
|
406
438
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
407
439
|
*/
|
|
408
|
-
const isURLSearchParams = kindOfTest(
|
|
440
|
+
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
409
441
|
|
|
410
442
|
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
443
|
+
'ReadableStream',
|
|
444
|
+
'Request',
|
|
445
|
+
'Response',
|
|
446
|
+
'Headers',
|
|
415
447
|
].map(kindOfTest);
|
|
416
448
|
|
|
417
449
|
/**
|
|
@@ -421,9 +453,9 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
|
421
453
|
*
|
|
422
454
|
* @returns {String} The String freed of excess whitespace
|
|
423
455
|
*/
|
|
424
|
-
const trim = (str) =>
|
|
425
|
-
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
426
|
-
|
|
456
|
+
const trim = (str) => {
|
|
457
|
+
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
458
|
+
};
|
|
427
459
|
/**
|
|
428
460
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
429
461
|
*
|
|
@@ -442,7 +474,7 @@ const trim = (str) =>
|
|
|
442
474
|
*/
|
|
443
475
|
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
444
476
|
// Don't bother if no value provided
|
|
445
|
-
if (obj === null || typeof obj ===
|
|
477
|
+
if (obj === null || typeof obj === 'undefined') {
|
|
446
478
|
return;
|
|
447
479
|
}
|
|
448
480
|
|
|
@@ -450,7 +482,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
450
482
|
let l;
|
|
451
483
|
|
|
452
484
|
// Force an array if not already something iterable
|
|
453
|
-
if (typeof obj !==
|
|
485
|
+
if (typeof obj !== 'object') {
|
|
454
486
|
/*eslint no-param-reassign:0*/
|
|
455
487
|
obj = [obj];
|
|
456
488
|
}
|
|
@@ -467,9 +499,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
467
499
|
}
|
|
468
500
|
|
|
469
501
|
// Iterate over object keys
|
|
470
|
-
const keys = allOwnKeys
|
|
471
|
-
? Object.getOwnPropertyNames(obj)
|
|
472
|
-
: Object.keys(obj);
|
|
502
|
+
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
473
503
|
const len = keys.length;
|
|
474
504
|
let key;
|
|
475
505
|
|
|
@@ -480,6 +510,14 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
480
510
|
}
|
|
481
511
|
}
|
|
482
512
|
|
|
513
|
+
/**
|
|
514
|
+
* Finds a key in an object, case-insensitive, returning the actual key name.
|
|
515
|
+
* Returns null if the object is a Buffer or if no match is found.
|
|
516
|
+
*
|
|
517
|
+
* @param {Object} obj - The object to search.
|
|
518
|
+
* @param {string} key - The key to find (case-insensitive).
|
|
519
|
+
* @returns {?string} The actual key name if found, otherwise null.
|
|
520
|
+
*/
|
|
483
521
|
function findKey(obj, key) {
|
|
484
522
|
if (isBuffer(obj)) {
|
|
485
523
|
return null;
|
|
@@ -500,16 +538,11 @@ function findKey(obj, key) {
|
|
|
500
538
|
|
|
501
539
|
const _global = (() => {
|
|
502
540
|
/*eslint no-undef:0*/
|
|
503
|
-
if (typeof globalThis !==
|
|
504
|
-
return typeof self !==
|
|
505
|
-
? self
|
|
506
|
-
: typeof window !== "undefined"
|
|
507
|
-
? window
|
|
508
|
-
: global;
|
|
541
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
542
|
+
return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
|
|
509
543
|
})();
|
|
510
544
|
|
|
511
|
-
const isContextDefined = (context) =>
|
|
512
|
-
!isUndefined(context) && context !== _global;
|
|
545
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
513
546
|
|
|
514
547
|
/**
|
|
515
548
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -534,7 +567,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
534
567
|
const result = {};
|
|
535
568
|
const assignValue = (val, key) => {
|
|
536
569
|
// Skip dangerous property names to prevent prototype pollution
|
|
537
|
-
if (key ===
|
|
570
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
538
571
|
return;
|
|
539
572
|
}
|
|
540
573
|
|
|
@@ -587,7 +620,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
587
620
|
});
|
|
588
621
|
}
|
|
589
622
|
},
|
|
590
|
-
{ allOwnKeys }
|
|
623
|
+
{ allOwnKeys }
|
|
591
624
|
);
|
|
592
625
|
return a;
|
|
593
626
|
};
|
|
@@ -616,17 +649,14 @@ const stripBOM = (content) => {
|
|
|
616
649
|
* @returns {void}
|
|
617
650
|
*/
|
|
618
651
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
619
|
-
constructor.prototype = Object.create(
|
|
620
|
-
|
|
621
|
-
descriptors,
|
|
622
|
-
);
|
|
623
|
-
Object.defineProperty(constructor.prototype, "constructor", {
|
|
652
|
+
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
653
|
+
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
624
654
|
value: constructor,
|
|
625
655
|
writable: true,
|
|
626
656
|
enumerable: false,
|
|
627
657
|
configurable: true,
|
|
628
658
|
});
|
|
629
|
-
Object.defineProperty(constructor,
|
|
659
|
+
Object.defineProperty(constructor, 'super', {
|
|
630
660
|
value: superConstructor.prototype,
|
|
631
661
|
});
|
|
632
662
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -656,20 +686,13 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
|
656
686
|
i = props.length;
|
|
657
687
|
while (i-- > 0) {
|
|
658
688
|
prop = props[i];
|
|
659
|
-
if (
|
|
660
|
-
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
661
|
-
!merged[prop]
|
|
662
|
-
) {
|
|
689
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
663
690
|
destObj[prop] = sourceObj[prop];
|
|
664
691
|
merged[prop] = true;
|
|
665
692
|
}
|
|
666
693
|
}
|
|
667
694
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
668
|
-
} while (
|
|
669
|
-
sourceObj &&
|
|
670
|
-
(!filter || filter(sourceObj, destObj)) &&
|
|
671
|
-
sourceObj !== Object.prototype
|
|
672
|
-
);
|
|
695
|
+
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
673
696
|
|
|
674
697
|
return destObj;
|
|
675
698
|
};
|
|
@@ -726,7 +749,7 @@ const isTypedArray = ((TypedArray) => {
|
|
|
726
749
|
return (thing) => {
|
|
727
750
|
return TypedArray && thing instanceof TypedArray;
|
|
728
751
|
};
|
|
729
|
-
})(typeof Uint8Array !==
|
|
752
|
+
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
|
730
753
|
|
|
731
754
|
/**
|
|
732
755
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -769,14 +792,12 @@ const matchAll = (regExp, str) => {
|
|
|
769
792
|
};
|
|
770
793
|
|
|
771
794
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
772
|
-
const isHTMLForm = kindOfTest(
|
|
795
|
+
const isHTMLForm = kindOfTest('HTMLFormElement');
|
|
773
796
|
|
|
774
797
|
const toCamelCase = (str) => {
|
|
775
|
-
return str
|
|
776
|
-
.
|
|
777
|
-
|
|
778
|
-
return p1.toUpperCase() + p2;
|
|
779
|
-
});
|
|
798
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
799
|
+
return p1.toUpperCase() + p2;
|
|
800
|
+
});
|
|
780
801
|
};
|
|
781
802
|
|
|
782
803
|
/* Creating a function that will check if an object has a property. */
|
|
@@ -793,7 +814,7 @@ const hasOwnProperty = (
|
|
|
793
814
|
*
|
|
794
815
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
795
816
|
*/
|
|
796
|
-
const isRegExp = kindOfTest(
|
|
817
|
+
const isRegExp = kindOfTest('RegExp');
|
|
797
818
|
|
|
798
819
|
const reduceDescriptors = (obj, reducer) => {
|
|
799
820
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -817,10 +838,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
817
838
|
const freezeMethods = (obj) => {
|
|
818
839
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
819
840
|
// skip restricted props in strict mode
|
|
820
|
-
if (
|
|
821
|
-
isFunction$1(obj) &&
|
|
822
|
-
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
823
|
-
) {
|
|
841
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
824
842
|
return false;
|
|
825
843
|
}
|
|
826
844
|
|
|
@@ -830,7 +848,7 @@ const freezeMethods = (obj) => {
|
|
|
830
848
|
|
|
831
849
|
descriptor.enumerable = false;
|
|
832
850
|
|
|
833
|
-
if (
|
|
851
|
+
if ('writable' in descriptor) {
|
|
834
852
|
descriptor.writable = false;
|
|
835
853
|
return;
|
|
836
854
|
}
|
|
@@ -843,6 +861,14 @@ const freezeMethods = (obj) => {
|
|
|
843
861
|
});
|
|
844
862
|
};
|
|
845
863
|
|
|
864
|
+
/**
|
|
865
|
+
* Converts an array or a delimited string into an object set with values as keys and true as values.
|
|
866
|
+
* Useful for fast membership checks.
|
|
867
|
+
*
|
|
868
|
+
* @param {Array|string} arrayOrString - The array or string to convert.
|
|
869
|
+
* @param {string} delimiter - The delimiter to use if input is a string.
|
|
870
|
+
* @returns {Object} An object with keys from the array or string, values set to true.
|
|
871
|
+
*/
|
|
846
872
|
const toObjectSet = (arrayOrString, delimiter) => {
|
|
847
873
|
const obj = {};
|
|
848
874
|
|
|
@@ -852,9 +878,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
852
878
|
});
|
|
853
879
|
};
|
|
854
880
|
|
|
855
|
-
isArray(arrayOrString)
|
|
856
|
-
? define(arrayOrString)
|
|
857
|
-
: define(String(arrayOrString).split(delimiter));
|
|
881
|
+
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
858
882
|
|
|
859
883
|
return obj;
|
|
860
884
|
};
|
|
@@ -862,9 +886,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
862
886
|
const noop = () => {};
|
|
863
887
|
|
|
864
888
|
const toFiniteNumber = (value, defaultValue) => {
|
|
865
|
-
return value != null && Number.isFinite((value = +value))
|
|
866
|
-
? value
|
|
867
|
-
: defaultValue;
|
|
889
|
+
return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
|
|
868
890
|
};
|
|
869
891
|
|
|
870
892
|
/**
|
|
@@ -878,11 +900,17 @@ function isSpecCompliantForm(thing) {
|
|
|
878
900
|
return !!(
|
|
879
901
|
thing &&
|
|
880
902
|
isFunction$1(thing.append) &&
|
|
881
|
-
thing[toStringTag] ===
|
|
903
|
+
thing[toStringTag] === 'FormData' &&
|
|
882
904
|
thing[iterator]
|
|
883
905
|
);
|
|
884
906
|
}
|
|
885
907
|
|
|
908
|
+
/**
|
|
909
|
+
* Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
|
|
910
|
+
*
|
|
911
|
+
* @param {Object} obj - The object to convert.
|
|
912
|
+
* @returns {Object} The JSON-compatible object.
|
|
913
|
+
*/
|
|
886
914
|
const toJSONObject = (obj) => {
|
|
887
915
|
const stack = new Array(10);
|
|
888
916
|
|
|
@@ -897,7 +925,7 @@ const toJSONObject = (obj) => {
|
|
|
897
925
|
return source;
|
|
898
926
|
}
|
|
899
927
|
|
|
900
|
-
if (!(
|
|
928
|
+
if (!('toJSON' in source)) {
|
|
901
929
|
stack[i] = source;
|
|
902
930
|
const target = isArray(source) ? [] : {};
|
|
903
931
|
|
|
@@ -918,8 +946,20 @@ const toJSONObject = (obj) => {
|
|
|
918
946
|
return visit(obj, 0);
|
|
919
947
|
};
|
|
920
948
|
|
|
921
|
-
|
|
949
|
+
/**
|
|
950
|
+
* Determines if a value is an async function.
|
|
951
|
+
*
|
|
952
|
+
* @param {*} thing - The value to test.
|
|
953
|
+
* @returns {boolean} True if value is an async function, otherwise false.
|
|
954
|
+
*/
|
|
955
|
+
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
922
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Determines if a value is thenable (has then and catch methods).
|
|
959
|
+
*
|
|
960
|
+
* @param {*} thing - The value to test.
|
|
961
|
+
* @returns {boolean} True if value is thenable, otherwise false.
|
|
962
|
+
*/
|
|
923
963
|
const isThenable = (thing) =>
|
|
924
964
|
thing &&
|
|
925
965
|
(isObject(thing) || isFunction$1(thing)) &&
|
|
@@ -929,6 +969,14 @@ const isThenable = (thing) =>
|
|
|
929
969
|
// original code
|
|
930
970
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
931
971
|
|
|
972
|
+
/**
|
|
973
|
+
* Provides a cross-platform setImmediate implementation.
|
|
974
|
+
* Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
|
|
975
|
+
*
|
|
976
|
+
* @param {boolean} setImmediateSupported - Whether setImmediate is supported.
|
|
977
|
+
* @param {boolean} postMessageSupported - Whether postMessage is supported.
|
|
978
|
+
* @returns {Function} A function to schedule a callback asynchronously.
|
|
979
|
+
*/
|
|
932
980
|
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
933
981
|
if (setImmediateSupported) {
|
|
934
982
|
return setImmediate;
|
|
@@ -937,27 +985,33 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
937
985
|
return postMessageSupported
|
|
938
986
|
? ((token, callbacks) => {
|
|
939
987
|
_global.addEventListener(
|
|
940
|
-
|
|
988
|
+
'message',
|
|
941
989
|
({ source, data }) => {
|
|
942
990
|
if (source === _global && data === token) {
|
|
943
991
|
callbacks.length && callbacks.shift()();
|
|
944
992
|
}
|
|
945
993
|
},
|
|
946
|
-
false
|
|
994
|
+
false
|
|
947
995
|
);
|
|
948
996
|
|
|
949
997
|
return (cb) => {
|
|
950
998
|
callbacks.push(cb);
|
|
951
|
-
_global.postMessage(token,
|
|
999
|
+
_global.postMessage(token, '*');
|
|
952
1000
|
};
|
|
953
1001
|
})(`axios@${Math.random()}`, [])
|
|
954
1002
|
: (cb) => setTimeout(cb);
|
|
955
|
-
})(typeof setImmediate ===
|
|
1003
|
+
})(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
|
|
956
1004
|
|
|
1005
|
+
/**
|
|
1006
|
+
* Schedules a microtask or asynchronous callback as soon as possible.
|
|
1007
|
+
* Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
|
|
1008
|
+
*
|
|
1009
|
+
* @type {Function}
|
|
1010
|
+
*/
|
|
957
1011
|
const asap =
|
|
958
|
-
typeof queueMicrotask !==
|
|
1012
|
+
typeof queueMicrotask !== 'undefined'
|
|
959
1013
|
? queueMicrotask.bind(_global)
|
|
960
|
-
: (typeof process !==
|
|
1014
|
+
: (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
|
|
961
1015
|
|
|
962
1016
|
// *********************
|
|
963
1017
|
|
|
@@ -982,6 +1036,8 @@ var utils$1 = {
|
|
|
982
1036
|
isUndefined,
|
|
983
1037
|
isDate,
|
|
984
1038
|
isFile,
|
|
1039
|
+
isReactNativeBlob,
|
|
1040
|
+
isReactNative,
|
|
985
1041
|
isBlob,
|
|
986
1042
|
isRegExp,
|
|
987
1043
|
isFunction: isFunction$1,
|
|
@@ -1024,57 +1080,74 @@ var utils$1 = {
|
|
|
1024
1080
|
};
|
|
1025
1081
|
|
|
1026
1082
|
let AxiosError$1 = class AxiosError extends Error {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
customProps && Object.assign(axiosError, customProps);
|
|
1032
|
-
return axiosError;
|
|
1033
|
-
}
|
|
1083
|
+
static from(error, code, config, request, response, customProps) {
|
|
1084
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1085
|
+
axiosError.cause = error;
|
|
1086
|
+
axiosError.name = error.name;
|
|
1034
1087
|
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
* @param {string} message The error message.
|
|
1039
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1040
|
-
* @param {Object} [config] The config.
|
|
1041
|
-
* @param {Object} [request] The request.
|
|
1042
|
-
* @param {Object} [response] The response.
|
|
1043
|
-
*
|
|
1044
|
-
* @returns {Error} The created error.
|
|
1045
|
-
*/
|
|
1046
|
-
constructor(message, code, config, request, response) {
|
|
1047
|
-
super(message);
|
|
1048
|
-
this.name = 'AxiosError';
|
|
1049
|
-
this.isAxiosError = true;
|
|
1050
|
-
code && (this.code = code);
|
|
1051
|
-
config && (this.config = config);
|
|
1052
|
-
request && (this.request = request);
|
|
1053
|
-
if (response) {
|
|
1054
|
-
this.response = response;
|
|
1055
|
-
this.status = response.status;
|
|
1056
|
-
}
|
|
1088
|
+
// Preserve status from the original error if not already set from response
|
|
1089
|
+
if (error.status != null && axiosError.status == null) {
|
|
1090
|
+
axiosError.status = error.status;
|
|
1057
1091
|
}
|
|
1058
1092
|
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1093
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1094
|
+
return axiosError;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1099
|
+
*
|
|
1100
|
+
* @param {string} message The error message.
|
|
1101
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1102
|
+
* @param {Object} [config] The config.
|
|
1103
|
+
* @param {Object} [request] The request.
|
|
1104
|
+
* @param {Object} [response] The response.
|
|
1105
|
+
*
|
|
1106
|
+
* @returns {Error} The created error.
|
|
1107
|
+
*/
|
|
1108
|
+
constructor(message, code, config, request, response) {
|
|
1109
|
+
super(message);
|
|
1110
|
+
|
|
1111
|
+
// Make message enumerable to maintain backward compatibility
|
|
1112
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1113
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1114
|
+
Object.defineProperty(this, 'message', {
|
|
1115
|
+
value: message,
|
|
1116
|
+
enumerable: true,
|
|
1117
|
+
writable: true,
|
|
1118
|
+
configurable: true,
|
|
1119
|
+
});
|
|
1120
|
+
|
|
1121
|
+
this.name = 'AxiosError';
|
|
1122
|
+
this.isAxiosError = true;
|
|
1123
|
+
code && (this.code = code);
|
|
1124
|
+
config && (this.config = config);
|
|
1125
|
+
request && (this.request = request);
|
|
1126
|
+
if (response) {
|
|
1127
|
+
this.response = response;
|
|
1128
|
+
this.status = response.status;
|
|
1077
1129
|
}
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
toJSON() {
|
|
1133
|
+
return {
|
|
1134
|
+
// Standard
|
|
1135
|
+
message: this.message,
|
|
1136
|
+
name: this.name,
|
|
1137
|
+
// Microsoft
|
|
1138
|
+
description: this.description,
|
|
1139
|
+
number: this.number,
|
|
1140
|
+
// Mozilla
|
|
1141
|
+
fileName: this.fileName,
|
|
1142
|
+
lineNumber: this.lineNumber,
|
|
1143
|
+
columnNumber: this.columnNumber,
|
|
1144
|
+
stack: this.stack,
|
|
1145
|
+
// Axios
|
|
1146
|
+
config: utils$1.toJSONObject(this.config),
|
|
1147
|
+
code: this.code,
|
|
1148
|
+
status: this.status,
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1078
1151
|
};
|
|
1079
1152
|
|
|
1080
1153
|
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
@@ -1090,6 +1163,7 @@ AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
|
1090
1163
|
AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
|
|
1091
1164
|
AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1092
1165
|
AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1166
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1093
1167
|
|
|
1094
1168
|
// eslint-disable-next-line strict
|
|
1095
1169
|
var httpAdapter = null;
|
|
@@ -1127,11 +1201,14 @@ function removeBrackets(key) {
|
|
|
1127
1201
|
*/
|
|
1128
1202
|
function renderKey(path, key, dots) {
|
|
1129
1203
|
if (!path) return key;
|
|
1130
|
-
return path
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1204
|
+
return path
|
|
1205
|
+
.concat(key)
|
|
1206
|
+
.map(function each(token, i) {
|
|
1207
|
+
// eslint-disable-next-line no-param-reassign
|
|
1208
|
+
token = removeBrackets(token);
|
|
1209
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1210
|
+
})
|
|
1211
|
+
.join(dots ? '.' : '');
|
|
1135
1212
|
}
|
|
1136
1213
|
|
|
1137
1214
|
/**
|
|
@@ -1181,21 +1258,27 @@ function toFormData$1(obj, formData, options) {
|
|
|
1181
1258
|
formData = formData || new (FormData)();
|
|
1182
1259
|
|
|
1183
1260
|
// eslint-disable-next-line no-param-reassign
|
|
1184
|
-
options = utils$1.toFlatObject(
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1261
|
+
options = utils$1.toFlatObject(
|
|
1262
|
+
options,
|
|
1263
|
+
{
|
|
1264
|
+
metaTokens: true,
|
|
1265
|
+
dots: false,
|
|
1266
|
+
indexes: false,
|
|
1267
|
+
},
|
|
1268
|
+
false,
|
|
1269
|
+
function defined(option, source) {
|
|
1270
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1271
|
+
return !utils$1.isUndefined(source[option]);
|
|
1272
|
+
}
|
|
1273
|
+
);
|
|
1192
1274
|
|
|
1193
1275
|
const metaTokens = options.metaTokens;
|
|
1194
1276
|
// eslint-disable-next-line no-use-before-define
|
|
1195
1277
|
const visitor = options.visitor || defaultVisitor;
|
|
1196
1278
|
const dots = options.dots;
|
|
1197
1279
|
const indexes = options.indexes;
|
|
1198
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1280
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1281
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1199
1282
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1200
1283
|
|
|
1201
1284
|
if (!utils$1.isFunction(visitor)) {
|
|
@@ -1237,6 +1320,11 @@ function toFormData$1(obj, formData, options) {
|
|
|
1237
1320
|
function defaultVisitor(value, key, path) {
|
|
1238
1321
|
let arr = value;
|
|
1239
1322
|
|
|
1323
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
1324
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1325
|
+
return false;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1240
1328
|
if (value && !path && typeof value === 'object') {
|
|
1241
1329
|
if (utils$1.endsWith(key, '{}')) {
|
|
1242
1330
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -1245,17 +1333,22 @@ function toFormData$1(obj, formData, options) {
|
|
|
1245
1333
|
value = JSON.stringify(value);
|
|
1246
1334
|
} else if (
|
|
1247
1335
|
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1248
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1249
|
-
|
|
1336
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1337
|
+
) {
|
|
1250
1338
|
// eslint-disable-next-line no-param-reassign
|
|
1251
1339
|
key = removeBrackets(key);
|
|
1252
1340
|
|
|
1253
1341
|
arr.forEach(function each(el, index) {
|
|
1254
|
-
!(utils$1.isUndefined(el) || el === null) &&
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1342
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1343
|
+
formData.append(
|
|
1344
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1345
|
+
indexes === true
|
|
1346
|
+
? renderKey([key], index, dots)
|
|
1347
|
+
: indexes === null
|
|
1348
|
+
? key
|
|
1349
|
+
: key + '[]',
|
|
1350
|
+
convertValue(el)
|
|
1351
|
+
);
|
|
1259
1352
|
});
|
|
1260
1353
|
return false;
|
|
1261
1354
|
}
|
|
@@ -1275,12 +1368,19 @@ function toFormData$1(obj, formData, options) {
|
|
|
1275
1368
|
const exposedHelpers = Object.assign(predicates, {
|
|
1276
1369
|
defaultVisitor,
|
|
1277
1370
|
convertValue,
|
|
1278
|
-
isVisitable
|
|
1371
|
+
isVisitable,
|
|
1279
1372
|
});
|
|
1280
1373
|
|
|
1281
|
-
function build(value, path) {
|
|
1374
|
+
function build(value, path, depth = 0) {
|
|
1282
1375
|
if (utils$1.isUndefined(value)) return;
|
|
1283
1376
|
|
|
1377
|
+
if (depth > maxDepth) {
|
|
1378
|
+
throw new AxiosError$1(
|
|
1379
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1380
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1381
|
+
);
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1284
1384
|
if (stack.indexOf(value) !== -1) {
|
|
1285
1385
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1286
1386
|
}
|
|
@@ -1288,12 +1388,12 @@ function toFormData$1(obj, formData, options) {
|
|
|
1288
1388
|
stack.push(value);
|
|
1289
1389
|
|
|
1290
1390
|
utils$1.forEach(value, function each(el, key) {
|
|
1291
|
-
const result =
|
|
1292
|
-
|
|
1293
|
-
|
|
1391
|
+
const result =
|
|
1392
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1393
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1294
1394
|
|
|
1295
1395
|
if (result === true) {
|
|
1296
|
-
build(el, path ? path.concat(key) : [key]);
|
|
1396
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
1297
1397
|
}
|
|
1298
1398
|
});
|
|
1299
1399
|
|
|
@@ -1325,9 +1425,8 @@ function encode$1(str) {
|
|
|
1325
1425
|
')': '%29',
|
|
1326
1426
|
'~': '%7E',
|
|
1327
1427
|
'%20': '+',
|
|
1328
|
-
'%00': '\x00'
|
|
1329
1428
|
};
|
|
1330
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20
|
|
1429
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1331
1430
|
return charMap[match];
|
|
1332
1431
|
});
|
|
1333
1432
|
}
|
|
@@ -1353,29 +1452,33 @@ prototype.append = function append(name, value) {
|
|
|
1353
1452
|
};
|
|
1354
1453
|
|
|
1355
1454
|
prototype.toString = function toString(encoder) {
|
|
1356
|
-
const _encode = encoder
|
|
1357
|
-
|
|
1358
|
-
|
|
1455
|
+
const _encode = encoder
|
|
1456
|
+
? function (value) {
|
|
1457
|
+
return encoder.call(this, value, encode$1);
|
|
1458
|
+
}
|
|
1459
|
+
: encode$1;
|
|
1359
1460
|
|
|
1360
|
-
return this._pairs
|
|
1361
|
-
|
|
1362
|
-
|
|
1461
|
+
return this._pairs
|
|
1462
|
+
.map(function each(pair) {
|
|
1463
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1464
|
+
}, '')
|
|
1465
|
+
.join('&');
|
|
1363
1466
|
};
|
|
1364
1467
|
|
|
1365
1468
|
/**
|
|
1366
|
-
* It replaces
|
|
1367
|
-
*
|
|
1469
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1470
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1368
1471
|
*
|
|
1369
1472
|
* @param {string} val The value to be encoded.
|
|
1370
1473
|
*
|
|
1371
1474
|
* @returns {string} The encoded value.
|
|
1372
1475
|
*/
|
|
1373
1476
|
function encode(val) {
|
|
1374
|
-
return encodeURIComponent(val)
|
|
1375
|
-
replace(/%3A/gi, ':')
|
|
1376
|
-
replace(/%24/g, '$')
|
|
1377
|
-
replace(/%2C/gi, ',')
|
|
1378
|
-
replace(/%20/g, '+');
|
|
1477
|
+
return encodeURIComponent(val)
|
|
1478
|
+
.replace(/%3A/gi, ':')
|
|
1479
|
+
.replace(/%24/g, '$')
|
|
1480
|
+
.replace(/%2C/gi, ',')
|
|
1481
|
+
.replace(/%20/g, '+');
|
|
1379
1482
|
}
|
|
1380
1483
|
|
|
1381
1484
|
/**
|
|
@@ -1392,11 +1495,13 @@ function buildURL(url, params, options) {
|
|
|
1392
1495
|
return url;
|
|
1393
1496
|
}
|
|
1394
1497
|
|
|
1395
|
-
const _encode = options && options.encode || encode;
|
|
1498
|
+
const _encode = (options && options.encode) || encode;
|
|
1396
1499
|
|
|
1397
|
-
const _options = utils$1.isFunction(options)
|
|
1398
|
-
|
|
1399
|
-
|
|
1500
|
+
const _options = utils$1.isFunction(options)
|
|
1501
|
+
? {
|
|
1502
|
+
serialize: options,
|
|
1503
|
+
}
|
|
1504
|
+
: options;
|
|
1400
1505
|
|
|
1401
1506
|
const serializeFn = _options && _options.serialize;
|
|
1402
1507
|
|
|
@@ -1405,13 +1510,13 @@ function buildURL(url, params, options) {
|
|
|
1405
1510
|
if (serializeFn) {
|
|
1406
1511
|
serializedParams = serializeFn(params, _options);
|
|
1407
1512
|
} else {
|
|
1408
|
-
serializedParams = utils$1.isURLSearchParams(params)
|
|
1409
|
-
params.toString()
|
|
1410
|
-
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1513
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
1514
|
+
? params.toString()
|
|
1515
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1411
1516
|
}
|
|
1412
1517
|
|
|
1413
1518
|
if (serializedParams) {
|
|
1414
|
-
const hashmarkIndex = url.indexOf(
|
|
1519
|
+
const hashmarkIndex = url.indexOf('#');
|
|
1415
1520
|
|
|
1416
1521
|
if (hashmarkIndex !== -1) {
|
|
1417
1522
|
url = url.slice(0, hashmarkIndex);
|
|
@@ -1441,7 +1546,7 @@ class InterceptorManager {
|
|
|
1441
1546
|
fulfilled,
|
|
1442
1547
|
rejected,
|
|
1443
1548
|
synchronous: options ? options.synchronous : false,
|
|
1444
|
-
runWhen: options ? options.runWhen : null
|
|
1549
|
+
runWhen: options ? options.runWhen : null,
|
|
1445
1550
|
});
|
|
1446
1551
|
return this.handlers.length - 1;
|
|
1447
1552
|
}
|
|
@@ -1493,7 +1598,7 @@ var transitionalDefaults = {
|
|
|
1493
1598
|
silentJSONParsing: true,
|
|
1494
1599
|
forcedJSONParsing: true,
|
|
1495
1600
|
clarifyTimeoutError: false,
|
|
1496
|
-
legacyInterceptorReqResOrdering: true
|
|
1601
|
+
legacyInterceptorReqResOrdering: true,
|
|
1497
1602
|
};
|
|
1498
1603
|
|
|
1499
1604
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -1507,14 +1612,14 @@ var platform$1 = {
|
|
|
1507
1612
|
classes: {
|
|
1508
1613
|
URLSearchParams: URLSearchParams$1,
|
|
1509
1614
|
FormData: FormData$1,
|
|
1510
|
-
Blob: Blob$1
|
|
1615
|
+
Blob: Blob$1,
|
|
1511
1616
|
},
|
|
1512
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1617
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
1513
1618
|
};
|
|
1514
1619
|
|
|
1515
1620
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1516
1621
|
|
|
1517
|
-
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
1622
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
1518
1623
|
|
|
1519
1624
|
/**
|
|
1520
1625
|
* Determine if we're running in a standard browser environment
|
|
@@ -1533,7 +1638,8 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
|
1533
1638
|
*
|
|
1534
1639
|
* @returns {boolean}
|
|
1535
1640
|
*/
|
|
1536
|
-
const hasStandardBrowserEnv =
|
|
1641
|
+
const hasStandardBrowserEnv =
|
|
1642
|
+
hasBrowserEnv &&
|
|
1537
1643
|
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1538
1644
|
|
|
1539
1645
|
/**
|
|
@@ -1554,7 +1660,7 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
1554
1660
|
);
|
|
1555
1661
|
})();
|
|
1556
1662
|
|
|
1557
|
-
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1663
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
1558
1664
|
|
|
1559
1665
|
var utils = /*#__PURE__*/Object.freeze({
|
|
1560
1666
|
__proto__: null,
|
|
@@ -1567,12 +1673,12 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
1567
1673
|
|
|
1568
1674
|
var platform = {
|
|
1569
1675
|
...utils,
|
|
1570
|
-
...platform$1
|
|
1676
|
+
...platform$1,
|
|
1571
1677
|
};
|
|
1572
1678
|
|
|
1573
1679
|
function toURLEncodedForm(data, options) {
|
|
1574
1680
|
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
1575
|
-
visitor: function(value, key, path, helpers) {
|
|
1681
|
+
visitor: function (value, key, path, helpers) {
|
|
1576
1682
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1577
1683
|
this.append(key, value.toString('base64'));
|
|
1578
1684
|
return false;
|
|
@@ -1580,7 +1686,7 @@ function toURLEncodedForm(data, options) {
|
|
|
1580
1686
|
|
|
1581
1687
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
1582
1688
|
},
|
|
1583
|
-
...options
|
|
1689
|
+
...options,
|
|
1584
1690
|
});
|
|
1585
1691
|
}
|
|
1586
1692
|
|
|
@@ -1596,7 +1702,7 @@ function parsePropPath(name) {
|
|
|
1596
1702
|
// foo.x.y.z
|
|
1597
1703
|
// foo-x-y-z
|
|
1598
1704
|
// foo x y z
|
|
1599
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1705
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
1600
1706
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1601
1707
|
});
|
|
1602
1708
|
}
|
|
@@ -1640,7 +1746,9 @@ function formDataToJSON(formData) {
|
|
|
1640
1746
|
|
|
1641
1747
|
if (isLast) {
|
|
1642
1748
|
if (utils$1.hasOwnProp(target, name)) {
|
|
1643
|
-
target[name] =
|
|
1749
|
+
target[name] = utils$1.isArray(target[name])
|
|
1750
|
+
? target[name].concat(value)
|
|
1751
|
+
: [target[name], value];
|
|
1644
1752
|
} else {
|
|
1645
1753
|
target[name] = value;
|
|
1646
1754
|
}
|
|
@@ -1674,6 +1782,8 @@ function formDataToJSON(formData) {
|
|
|
1674
1782
|
return null;
|
|
1675
1783
|
}
|
|
1676
1784
|
|
|
1785
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
1786
|
+
|
|
1677
1787
|
/**
|
|
1678
1788
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1679
1789
|
* of the input
|
|
@@ -1700,96 +1810,110 @@ function stringifySafely(rawValue, parser, encoder) {
|
|
|
1700
1810
|
}
|
|
1701
1811
|
|
|
1702
1812
|
const defaults = {
|
|
1703
|
-
|
|
1704
1813
|
transitional: transitionalDefaults,
|
|
1705
1814
|
|
|
1706
1815
|
adapter: ['xhr', 'http', 'fetch'],
|
|
1707
1816
|
|
|
1708
|
-
transformRequest: [
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1714
|
-
data = new FormData(data);
|
|
1715
|
-
}
|
|
1817
|
+
transformRequest: [
|
|
1818
|
+
function transformRequest(data, headers) {
|
|
1819
|
+
const contentType = headers.getContentType() || '';
|
|
1820
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1821
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1716
1822
|
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1721
|
-
}
|
|
1823
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1824
|
+
data = new FormData(data);
|
|
1825
|
+
}
|
|
1722
1826
|
|
|
1723
|
-
|
|
1724
|
-
utils$1.isBuffer(data) ||
|
|
1725
|
-
utils$1.isStream(data) ||
|
|
1726
|
-
utils$1.isFile(data) ||
|
|
1727
|
-
utils$1.isBlob(data) ||
|
|
1728
|
-
utils$1.isReadableStream(data)
|
|
1729
|
-
) {
|
|
1730
|
-
return data;
|
|
1731
|
-
}
|
|
1732
|
-
if (utils$1.isArrayBufferView(data)) {
|
|
1733
|
-
return data.buffer;
|
|
1734
|
-
}
|
|
1735
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
1736
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1737
|
-
return data.toString();
|
|
1738
|
-
}
|
|
1827
|
+
const isFormData = utils$1.isFormData(data);
|
|
1739
1828
|
|
|
1740
|
-
|
|
1829
|
+
if (isFormData) {
|
|
1830
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1831
|
+
}
|
|
1741
1832
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1833
|
+
if (
|
|
1834
|
+
utils$1.isArrayBuffer(data) ||
|
|
1835
|
+
utils$1.isBuffer(data) ||
|
|
1836
|
+
utils$1.isStream(data) ||
|
|
1837
|
+
utils$1.isFile(data) ||
|
|
1838
|
+
utils$1.isBlob(data) ||
|
|
1839
|
+
utils$1.isReadableStream(data)
|
|
1840
|
+
) {
|
|
1841
|
+
return data;
|
|
1842
|
+
}
|
|
1843
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
1844
|
+
return data.buffer;
|
|
1845
|
+
}
|
|
1846
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
1847
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1848
|
+
return data.toString();
|
|
1745
1849
|
}
|
|
1746
1850
|
|
|
1747
|
-
|
|
1748
|
-
const _FormData = this.env && this.env.FormData;
|
|
1851
|
+
let isFileList;
|
|
1749
1852
|
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1853
|
+
if (isObjectPayload) {
|
|
1854
|
+
const formSerializer = own(this, 'formSerializer');
|
|
1855
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1856
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
if (
|
|
1860
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
1861
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
1862
|
+
) {
|
|
1863
|
+
const env = own(this, 'env');
|
|
1864
|
+
const _FormData = env && env.FormData;
|
|
1865
|
+
|
|
1866
|
+
return toFormData$1(
|
|
1867
|
+
isFileList ? { 'files[]': data } : data,
|
|
1868
|
+
_FormData && new _FormData(),
|
|
1869
|
+
formSerializer
|
|
1870
|
+
);
|
|
1871
|
+
}
|
|
1755
1872
|
}
|
|
1756
|
-
}
|
|
1757
1873
|
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1874
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
1875
|
+
headers.setContentType('application/json', false);
|
|
1876
|
+
return stringifySafely(data);
|
|
1877
|
+
}
|
|
1762
1878
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1879
|
+
return data;
|
|
1880
|
+
},
|
|
1881
|
+
],
|
|
1765
1882
|
|
|
1766
|
-
transformResponse: [
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1883
|
+
transformResponse: [
|
|
1884
|
+
function transformResponse(data) {
|
|
1885
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
1886
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1887
|
+
const responseType = own(this, 'responseType');
|
|
1888
|
+
const JSONRequested = responseType === 'json';
|
|
1770
1889
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1890
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
1891
|
+
return data;
|
|
1892
|
+
}
|
|
1774
1893
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1894
|
+
if (
|
|
1895
|
+
data &&
|
|
1896
|
+
utils$1.isString(data) &&
|
|
1897
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
1898
|
+
) {
|
|
1899
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1900
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1778
1901
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1902
|
+
try {
|
|
1903
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
1904
|
+
} catch (e) {
|
|
1905
|
+
if (strictJSONParsing) {
|
|
1906
|
+
if (e.name === 'SyntaxError') {
|
|
1907
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
1908
|
+
}
|
|
1909
|
+
throw e;
|
|
1785
1910
|
}
|
|
1786
|
-
throw e;
|
|
1787
1911
|
}
|
|
1788
1912
|
}
|
|
1789
|
-
}
|
|
1790
1913
|
|
|
1791
|
-
|
|
1792
|
-
|
|
1914
|
+
return data;
|
|
1915
|
+
},
|
|
1916
|
+
],
|
|
1793
1917
|
|
|
1794
1918
|
/**
|
|
1795
1919
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
@@ -1805,7 +1929,7 @@ const defaults = {
|
|
|
1805
1929
|
|
|
1806
1930
|
env: {
|
|
1807
1931
|
FormData: platform.classes.FormData,
|
|
1808
|
-
Blob: platform.classes.Blob
|
|
1932
|
+
Blob: platform.classes.Blob,
|
|
1809
1933
|
},
|
|
1810
1934
|
|
|
1811
1935
|
validateStatus: function validateStatus(status) {
|
|
@@ -1814,10 +1938,10 @@ const defaults = {
|
|
|
1814
1938
|
|
|
1815
1939
|
headers: {
|
|
1816
1940
|
common: {
|
|
1817
|
-
|
|
1818
|
-
'Content-Type': undefined
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1941
|
+
Accept: 'application/json, text/plain, */*',
|
|
1942
|
+
'Content-Type': undefined,
|
|
1943
|
+
},
|
|
1944
|
+
},
|
|
1821
1945
|
};
|
|
1822
1946
|
|
|
1823
1947
|
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
@@ -1827,10 +1951,23 @@ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
|
1827
1951
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1828
1952
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1829
1953
|
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1830
|
-
'age',
|
|
1831
|
-
'
|
|
1832
|
-
'
|
|
1833
|
-
'
|
|
1954
|
+
'age',
|
|
1955
|
+
'authorization',
|
|
1956
|
+
'content-length',
|
|
1957
|
+
'content-type',
|
|
1958
|
+
'etag',
|
|
1959
|
+
'expires',
|
|
1960
|
+
'from',
|
|
1961
|
+
'host',
|
|
1962
|
+
'if-modified-since',
|
|
1963
|
+
'if-unmodified-since',
|
|
1964
|
+
'last-modified',
|
|
1965
|
+
'location',
|
|
1966
|
+
'max-forwards',
|
|
1967
|
+
'proxy-authorization',
|
|
1968
|
+
'referer',
|
|
1969
|
+
'retry-after',
|
|
1970
|
+
'user-agent',
|
|
1834
1971
|
]);
|
|
1835
1972
|
|
|
1836
1973
|
/**
|
|
@@ -1847,47 +1984,81 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
|
1847
1984
|
*
|
|
1848
1985
|
* @returns {Object} Headers parsed into an object
|
|
1849
1986
|
*/
|
|
1850
|
-
var parseHeaders = rawHeaders => {
|
|
1987
|
+
var parseHeaders = (rawHeaders) => {
|
|
1851
1988
|
const parsed = {};
|
|
1852
1989
|
let key;
|
|
1853
1990
|
let val;
|
|
1854
1991
|
let i;
|
|
1855
1992
|
|
|
1856
|
-
rawHeaders &&
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1993
|
+
rawHeaders &&
|
|
1994
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
1995
|
+
i = line.indexOf(':');
|
|
1996
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1997
|
+
val = line.substring(i + 1).trim();
|
|
1860
1998
|
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1999
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
1864
2002
|
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
2003
|
+
if (key === 'set-cookie') {
|
|
2004
|
+
if (parsed[key]) {
|
|
2005
|
+
parsed[key].push(val);
|
|
2006
|
+
} else {
|
|
2007
|
+
parsed[key] = [val];
|
|
2008
|
+
}
|
|
1868
2009
|
} else {
|
|
1869
|
-
parsed[key] = [val
|
|
2010
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1870
2011
|
}
|
|
1871
|
-
}
|
|
1872
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1873
|
-
}
|
|
1874
|
-
});
|
|
2012
|
+
});
|
|
1875
2013
|
|
|
1876
2014
|
return parsed;
|
|
1877
2015
|
};
|
|
1878
2016
|
|
|
1879
2017
|
const $internals = Symbol('internals');
|
|
1880
2018
|
|
|
2019
|
+
const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
|
|
2020
|
+
|
|
2021
|
+
function trimSPorHTAB(str) {
|
|
2022
|
+
let start = 0;
|
|
2023
|
+
let end = str.length;
|
|
2024
|
+
|
|
2025
|
+
while (start < end) {
|
|
2026
|
+
const code = str.charCodeAt(start);
|
|
2027
|
+
|
|
2028
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2029
|
+
break;
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
start += 1;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
while (end > start) {
|
|
2036
|
+
const code = str.charCodeAt(end - 1);
|
|
2037
|
+
|
|
2038
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2039
|
+
break;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
end -= 1;
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
2046
|
+
}
|
|
2047
|
+
|
|
1881
2048
|
function normalizeHeader(header) {
|
|
1882
2049
|
return header && String(header).trim().toLowerCase();
|
|
1883
2050
|
}
|
|
1884
2051
|
|
|
2052
|
+
function sanitizeHeaderValue(str) {
|
|
2053
|
+
return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
|
|
2054
|
+
}
|
|
2055
|
+
|
|
1885
2056
|
function normalizeValue(value) {
|
|
1886
2057
|
if (value === false || value == null) {
|
|
1887
2058
|
return value;
|
|
1888
2059
|
}
|
|
1889
2060
|
|
|
1890
|
-
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
2061
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
1891
2062
|
}
|
|
1892
2063
|
|
|
1893
2064
|
function parseTokens(str) {
|
|
@@ -1925,8 +2096,10 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
1925
2096
|
}
|
|
1926
2097
|
|
|
1927
2098
|
function formatHeader(header) {
|
|
1928
|
-
return header
|
|
1929
|
-
.
|
|
2099
|
+
return header
|
|
2100
|
+
.trim()
|
|
2101
|
+
.toLowerCase()
|
|
2102
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1930
2103
|
return char.toUpperCase() + str;
|
|
1931
2104
|
});
|
|
1932
2105
|
}
|
|
@@ -1934,12 +2107,12 @@ function formatHeader(header) {
|
|
|
1934
2107
|
function buildAccessors(obj, header) {
|
|
1935
2108
|
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1936
2109
|
|
|
1937
|
-
['get', 'set', 'has'].forEach(methodName => {
|
|
2110
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
1938
2111
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
1939
|
-
value: function(arg1, arg2, arg3) {
|
|
2112
|
+
value: function (arg1, arg2, arg3) {
|
|
1940
2113
|
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1941
2114
|
},
|
|
1942
|
-
configurable: true
|
|
2115
|
+
configurable: true,
|
|
1943
2116
|
});
|
|
1944
2117
|
});
|
|
1945
2118
|
}
|
|
@@ -1961,7 +2134,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
1961
2134
|
|
|
1962
2135
|
const key = utils$1.findKey(self, lHeader);
|
|
1963
2136
|
|
|
1964
|
-
if
|
|
2137
|
+
if (
|
|
2138
|
+
!key ||
|
|
2139
|
+
self[key] === undefined ||
|
|
2140
|
+
_rewrite === true ||
|
|
2141
|
+
(_rewrite === undefined && self[key] !== false)
|
|
2142
|
+
) {
|
|
1965
2143
|
self[key || _header] = normalizeValue(_value);
|
|
1966
2144
|
}
|
|
1967
2145
|
}
|
|
@@ -1971,17 +2149,22 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
1971
2149
|
|
|
1972
2150
|
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1973
2151
|
setHeaders(header, valueOrRewrite);
|
|
1974
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2152
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1975
2153
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1976
2154
|
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1977
|
-
let obj = {},
|
|
2155
|
+
let obj = {},
|
|
2156
|
+
dest,
|
|
2157
|
+
key;
|
|
1978
2158
|
for (const entry of header) {
|
|
1979
2159
|
if (!utils$1.isArray(entry)) {
|
|
1980
2160
|
throw TypeError('Object iterator must return a key-value pair');
|
|
1981
2161
|
}
|
|
1982
2162
|
|
|
1983
|
-
obj[key = entry[0]] = (dest = obj[key])
|
|
1984
|
-
|
|
2163
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
2164
|
+
? utils$1.isArray(dest)
|
|
2165
|
+
? [...dest, entry[1]]
|
|
2166
|
+
: [dest, entry[1]]
|
|
2167
|
+
: entry[1];
|
|
1985
2168
|
}
|
|
1986
2169
|
|
|
1987
2170
|
setHeaders(obj, valueOrRewrite);
|
|
@@ -2028,7 +2211,11 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2028
2211
|
if (header) {
|
|
2029
2212
|
const key = utils$1.findKey(this, header);
|
|
2030
2213
|
|
|
2031
|
-
return !!(
|
|
2214
|
+
return !!(
|
|
2215
|
+
key &&
|
|
2216
|
+
this[key] !== undefined &&
|
|
2217
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2218
|
+
);
|
|
2032
2219
|
}
|
|
2033
2220
|
|
|
2034
2221
|
return false;
|
|
@@ -2068,7 +2255,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2068
2255
|
|
|
2069
2256
|
while (i--) {
|
|
2070
2257
|
const key = keys[i];
|
|
2071
|
-
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2258
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2072
2259
|
delete this[key];
|
|
2073
2260
|
deleted = true;
|
|
2074
2261
|
}
|
|
@@ -2112,7 +2299,9 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2112
2299
|
const obj = Object.create(null);
|
|
2113
2300
|
|
|
2114
2301
|
utils$1.forEach(this, (value, header) => {
|
|
2115
|
-
value != null &&
|
|
2302
|
+
value != null &&
|
|
2303
|
+
value !== false &&
|
|
2304
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
2116
2305
|
});
|
|
2117
2306
|
|
|
2118
2307
|
return obj;
|
|
@@ -2123,11 +2312,13 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2123
2312
|
}
|
|
2124
2313
|
|
|
2125
2314
|
toString() {
|
|
2126
|
-
return Object.entries(this.toJSON())
|
|
2315
|
+
return Object.entries(this.toJSON())
|
|
2316
|
+
.map(([header, value]) => header + ': ' + value)
|
|
2317
|
+
.join('\n');
|
|
2127
2318
|
}
|
|
2128
2319
|
|
|
2129
2320
|
getSetCookie() {
|
|
2130
|
-
return this.get(
|
|
2321
|
+
return this.get('set-cookie') || [];
|
|
2131
2322
|
}
|
|
2132
2323
|
|
|
2133
2324
|
get [Symbol.toStringTag]() {
|
|
@@ -2147,9 +2338,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2147
2338
|
}
|
|
2148
2339
|
|
|
2149
2340
|
static accessor(header) {
|
|
2150
|
-
const internals =
|
|
2151
|
-
|
|
2152
|
-
|
|
2341
|
+
const internals =
|
|
2342
|
+
(this[$internals] =
|
|
2343
|
+
this[$internals] =
|
|
2344
|
+
{
|
|
2345
|
+
accessors: {},
|
|
2346
|
+
});
|
|
2153
2347
|
|
|
2154
2348
|
const accessors = internals.accessors;
|
|
2155
2349
|
const prototype = this.prototype;
|
|
@@ -2169,17 +2363,24 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2169
2363
|
}
|
|
2170
2364
|
};
|
|
2171
2365
|
|
|
2172
|
-
AxiosHeaders$1.accessor([
|
|
2366
|
+
AxiosHeaders$1.accessor([
|
|
2367
|
+
'Content-Type',
|
|
2368
|
+
'Content-Length',
|
|
2369
|
+
'Accept',
|
|
2370
|
+
'Accept-Encoding',
|
|
2371
|
+
'User-Agent',
|
|
2372
|
+
'Authorization',
|
|
2373
|
+
]);
|
|
2173
2374
|
|
|
2174
2375
|
// reserved names hotfix
|
|
2175
|
-
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
|
|
2376
|
+
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
2176
2377
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2177
2378
|
return {
|
|
2178
2379
|
get: () => value,
|
|
2179
2380
|
set(headerValue) {
|
|
2180
2381
|
this[mapped] = headerValue;
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2382
|
+
},
|
|
2383
|
+
};
|
|
2183
2384
|
});
|
|
2184
2385
|
|
|
2185
2386
|
utils$1.freezeMethods(AxiosHeaders$1);
|
|
@@ -2242,19 +2443,23 @@ function settle(resolve, reject, response) {
|
|
|
2242
2443
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2243
2444
|
resolve(response);
|
|
2244
2445
|
} else {
|
|
2245
|
-
reject(
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2446
|
+
reject(
|
|
2447
|
+
new AxiosError$1(
|
|
2448
|
+
'Request failed with status code ' + response.status,
|
|
2449
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
|
|
2450
|
+
Math.floor(response.status / 100) - 4
|
|
2451
|
+
],
|
|
2452
|
+
response.config,
|
|
2453
|
+
response.request,
|
|
2454
|
+
response
|
|
2455
|
+
)
|
|
2456
|
+
);
|
|
2252
2457
|
}
|
|
2253
2458
|
}
|
|
2254
2459
|
|
|
2255
2460
|
function parseProtocol(url) {
|
|
2256
2461
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
2257
|
-
return match && match[1] || '';
|
|
2462
|
+
return (match && match[1]) || '';
|
|
2258
2463
|
}
|
|
2259
2464
|
|
|
2260
2465
|
/**
|
|
@@ -2305,7 +2510,7 @@ function speedometer(samplesCount, min) {
|
|
|
2305
2510
|
|
|
2306
2511
|
const passed = startedAt && now - startedAt;
|
|
2307
2512
|
|
|
2308
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
2513
|
+
return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
|
|
2309
2514
|
};
|
|
2310
2515
|
}
|
|
2311
2516
|
|
|
@@ -2334,7 +2539,7 @@ function throttle(fn, freq) {
|
|
|
2334
2539
|
const throttled = (...args) => {
|
|
2335
2540
|
const now = Date.now();
|
|
2336
2541
|
const passed = now - timestamp;
|
|
2337
|
-
if (
|
|
2542
|
+
if (passed >= threshold) {
|
|
2338
2543
|
invoke(args, now);
|
|
2339
2544
|
} else {
|
|
2340
2545
|
lastArgs = args;
|
|
@@ -2356,25 +2561,25 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2356
2561
|
let bytesNotified = 0;
|
|
2357
2562
|
const _speedometer = speedometer(50, 250);
|
|
2358
2563
|
|
|
2359
|
-
return throttle(e => {
|
|
2360
|
-
const
|
|
2564
|
+
return throttle((e) => {
|
|
2565
|
+
const rawLoaded = e.loaded;
|
|
2361
2566
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2362
|
-
const
|
|
2567
|
+
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
2568
|
+
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
2363
2569
|
const rate = _speedometer(progressBytes);
|
|
2364
|
-
const inRange = loaded <= total;
|
|
2365
2570
|
|
|
2366
|
-
bytesNotified = loaded;
|
|
2571
|
+
bytesNotified = Math.max(bytesNotified, loaded);
|
|
2367
2572
|
|
|
2368
2573
|
const data = {
|
|
2369
2574
|
loaded,
|
|
2370
2575
|
total,
|
|
2371
|
-
progress: total ?
|
|
2576
|
+
progress: total ? loaded / total : undefined,
|
|
2372
2577
|
bytes: progressBytes,
|
|
2373
2578
|
rate: rate ? rate : undefined,
|
|
2374
|
-
estimated: rate && total
|
|
2579
|
+
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
2375
2580
|
event: e,
|
|
2376
2581
|
lengthComputable: total != null,
|
|
2377
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
|
2582
|
+
[isDownloadStream ? 'download' : 'upload']: true,
|
|
2378
2583
|
};
|
|
2379
2584
|
|
|
2380
2585
|
listener(data);
|
|
@@ -2384,77 +2589,82 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2384
2589
|
const progressEventDecorator = (total, throttled) => {
|
|
2385
2590
|
const lengthComputable = total != null;
|
|
2386
2591
|
|
|
2387
|
-
return [
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2592
|
+
return [
|
|
2593
|
+
(loaded) =>
|
|
2594
|
+
throttled[0]({
|
|
2595
|
+
lengthComputable,
|
|
2596
|
+
total,
|
|
2597
|
+
loaded,
|
|
2598
|
+
}),
|
|
2599
|
+
throttled[1],
|
|
2600
|
+
];
|
|
2392
2601
|
};
|
|
2393
2602
|
|
|
2394
|
-
const asyncDecorator =
|
|
2603
|
+
const asyncDecorator =
|
|
2604
|
+
(fn) =>
|
|
2605
|
+
(...args) =>
|
|
2606
|
+
utils$1.asap(() => fn(...args));
|
|
2395
2607
|
|
|
2396
|
-
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2397
|
-
|
|
2608
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2609
|
+
? ((origin, isMSIE) => (url) => {
|
|
2610
|
+
url = new URL(url, platform.origin);
|
|
2398
2611
|
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
})(
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
)
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
// Standard browser envs support document.cookie
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2612
|
+
return (
|
|
2613
|
+
origin.protocol === url.protocol &&
|
|
2614
|
+
origin.host === url.host &&
|
|
2615
|
+
(isMSIE || origin.port === url.port)
|
|
2616
|
+
);
|
|
2617
|
+
})(
|
|
2618
|
+
new URL(platform.origin),
|
|
2619
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2620
|
+
)
|
|
2621
|
+
: () => true;
|
|
2622
|
+
|
|
2623
|
+
var cookies = platform.hasStandardBrowserEnv
|
|
2624
|
+
? // Standard browser envs support document.cookie
|
|
2625
|
+
{
|
|
2626
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2627
|
+
if (typeof document === 'undefined') return;
|
|
2628
|
+
|
|
2629
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2630
|
+
|
|
2631
|
+
if (utils$1.isNumber(expires)) {
|
|
2632
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2633
|
+
}
|
|
2634
|
+
if (utils$1.isString(path)) {
|
|
2635
|
+
cookie.push(`path=${path}`);
|
|
2636
|
+
}
|
|
2637
|
+
if (utils$1.isString(domain)) {
|
|
2638
|
+
cookie.push(`domain=${domain}`);
|
|
2639
|
+
}
|
|
2640
|
+
if (secure === true) {
|
|
2641
|
+
cookie.push('secure');
|
|
2642
|
+
}
|
|
2643
|
+
if (utils$1.isString(sameSite)) {
|
|
2644
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2645
|
+
}
|
|
2433
2646
|
|
|
2434
|
-
|
|
2435
|
-
|
|
2647
|
+
document.cookie = cookie.join('; ');
|
|
2648
|
+
},
|
|
2436
2649
|
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2650
|
+
read(name) {
|
|
2651
|
+
if (typeof document === 'undefined') return null;
|
|
2652
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
2653
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
2654
|
+
},
|
|
2442
2655
|
|
|
2443
|
-
|
|
2444
|
-
|
|
2656
|
+
remove(name) {
|
|
2657
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2658
|
+
},
|
|
2445
2659
|
}
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
return null;
|
|
2455
|
-
},
|
|
2456
|
-
remove() {}
|
|
2457
|
-
};
|
|
2660
|
+
: // Non-standard browser env (web workers, react-native) lack needed support.
|
|
2661
|
+
{
|
|
2662
|
+
write() {},
|
|
2663
|
+
read() {
|
|
2664
|
+
return null;
|
|
2665
|
+
},
|
|
2666
|
+
remove() {},
|
|
2667
|
+
};
|
|
2458
2668
|
|
|
2459
2669
|
/**
|
|
2460
2670
|
* Determines whether the specified URL is absolute
|
|
@@ -2500,14 +2710,13 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
2500
2710
|
*/
|
|
2501
2711
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
2502
2712
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2503
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls
|
|
2713
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
2504
2714
|
return combineURLs(baseURL, requestedURL);
|
|
2505
2715
|
}
|
|
2506
2716
|
return requestedURL;
|
|
2507
2717
|
}
|
|
2508
2718
|
|
|
2509
|
-
const headersToObject = (thing) =>
|
|
2510
|
-
thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
2719
|
+
const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
|
|
2511
2720
|
|
|
2512
2721
|
/**
|
|
2513
2722
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2521,7 +2730,18 @@ const headersToObject = (thing) =>
|
|
|
2521
2730
|
function mergeConfig$1(config1, config2) {
|
|
2522
2731
|
// eslint-disable-next-line no-param-reassign
|
|
2523
2732
|
config2 = config2 || {};
|
|
2524
|
-
|
|
2733
|
+
|
|
2734
|
+
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
2735
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype
|
|
2736
|
+
// (see GHSA-q8qp-cvcw-x6jj). `hasOwnProperty` is restored as a non-enumerable
|
|
2737
|
+
// own slot to preserve ergonomics for user code that relies on it.
|
|
2738
|
+
const config = Object.create(null);
|
|
2739
|
+
Object.defineProperty(config, 'hasOwnProperty', {
|
|
2740
|
+
value: Object.prototype.hasOwnProperty,
|
|
2741
|
+
enumerable: false,
|
|
2742
|
+
writable: true,
|
|
2743
|
+
configurable: true,
|
|
2744
|
+
});
|
|
2525
2745
|
|
|
2526
2746
|
function getMergedValue(target, source, prop, caseless) {
|
|
2527
2747
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
@@ -2560,9 +2780,9 @@ function mergeConfig$1(config1, config2) {
|
|
|
2560
2780
|
|
|
2561
2781
|
// eslint-disable-next-line consistent-return
|
|
2562
2782
|
function mergeDirectKeys(a, b, prop) {
|
|
2563
|
-
if (prop
|
|
2783
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
2564
2784
|
return getMergedValue(a, b);
|
|
2565
|
-
} else if (prop
|
|
2785
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
2566
2786
|
return getMergedValue(undefined, a);
|
|
2567
2787
|
}
|
|
2568
2788
|
}
|
|
@@ -2594,29 +2814,21 @@ function mergeConfig$1(config1, config2) {
|
|
|
2594
2814
|
httpsAgent: defaultToConfig2,
|
|
2595
2815
|
cancelToken: defaultToConfig2,
|
|
2596
2816
|
socketPath: defaultToConfig2,
|
|
2817
|
+
allowedSocketPaths: defaultToConfig2,
|
|
2597
2818
|
responseEncoding: defaultToConfig2,
|
|
2598
2819
|
validateStatus: mergeDirectKeys,
|
|
2599
2820
|
headers: (a, b, prop) =>
|
|
2600
2821
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2601
2822
|
};
|
|
2602
2823
|
|
|
2603
|
-
utils$1.forEach(
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
return;
|
|
2612
|
-
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2613
|
-
? mergeMap[prop]
|
|
2614
|
-
: mergeDeepProperties;
|
|
2615
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2616
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2617
|
-
(config[prop] = configValue);
|
|
2618
|
-
},
|
|
2619
|
-
);
|
|
2824
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
2825
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
2826
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
2827
|
+
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
2828
|
+
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
2829
|
+
const configValue = merge(a, b, prop);
|
|
2830
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2831
|
+
});
|
|
2620
2832
|
|
|
2621
2833
|
return config;
|
|
2622
2834
|
}
|
|
@@ -2624,16 +2836,38 @@ function mergeConfig$1(config1, config2) {
|
|
|
2624
2836
|
var resolveConfig = (config) => {
|
|
2625
2837
|
const newConfig = mergeConfig$1({}, config);
|
|
2626
2838
|
|
|
2627
|
-
|
|
2839
|
+
// Read only own properties to prevent prototype pollution gadgets
|
|
2840
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com'). See GHSA-q8qp-cvcw-x6jj.
|
|
2841
|
+
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
2842
|
+
|
|
2843
|
+
const data = own('data');
|
|
2844
|
+
let withXSRFToken = own('withXSRFToken');
|
|
2845
|
+
const xsrfHeaderName = own('xsrfHeaderName');
|
|
2846
|
+
const xsrfCookieName = own('xsrfCookieName');
|
|
2847
|
+
let headers = own('headers');
|
|
2848
|
+
const auth = own('auth');
|
|
2849
|
+
const baseURL = own('baseURL');
|
|
2850
|
+
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
2851
|
+
const url = own('url');
|
|
2628
2852
|
|
|
2629
2853
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2630
2854
|
|
|
2631
|
-
newConfig.url = buildURL(
|
|
2855
|
+
newConfig.url = buildURL(
|
|
2856
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls),
|
|
2857
|
+
config.params,
|
|
2858
|
+
config.paramsSerializer
|
|
2859
|
+
);
|
|
2632
2860
|
|
|
2633
2861
|
// HTTP basic authentication
|
|
2634
2862
|
if (auth) {
|
|
2635
|
-
headers.set(
|
|
2636
|
-
|
|
2863
|
+
headers.set(
|
|
2864
|
+
'Authorization',
|
|
2865
|
+
'Basic ' +
|
|
2866
|
+
btoa(
|
|
2867
|
+
(auth.username || '') +
|
|
2868
|
+
':' +
|
|
2869
|
+
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
|
2870
|
+
)
|
|
2637
2871
|
);
|
|
2638
2872
|
}
|
|
2639
2873
|
|
|
@@ -2651,17 +2885,25 @@ var resolveConfig = (config) => {
|
|
|
2651
2885
|
}
|
|
2652
2886
|
});
|
|
2653
2887
|
}
|
|
2654
|
-
}
|
|
2888
|
+
}
|
|
2655
2889
|
|
|
2656
2890
|
// Add xsrf header
|
|
2657
2891
|
// This is only done if running in a standard browser environment.
|
|
2658
2892
|
// Specifically not if we're in a web worker, or react-native.
|
|
2659
2893
|
|
|
2660
2894
|
if (platform.hasStandardBrowserEnv) {
|
|
2661
|
-
|
|
2895
|
+
if (utils$1.isFunction(withXSRFToken)) {
|
|
2896
|
+
withXSRFToken = withXSRFToken(newConfig);
|
|
2897
|
+
}
|
|
2662
2898
|
|
|
2663
|
-
|
|
2664
|
-
|
|
2899
|
+
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
2900
|
+
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
2901
|
+
// the XSRF token cross-origin. See GHSA-xx6v-rp6x-q39c.
|
|
2902
|
+
const shouldSendXSRF =
|
|
2903
|
+
withXSRFToken === true ||
|
|
2904
|
+
(withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
2905
|
+
|
|
2906
|
+
if (shouldSendXSRF) {
|
|
2665
2907
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
2666
2908
|
|
|
2667
2909
|
if (xsrfValue) {
|
|
@@ -2675,196 +2917,218 @@ var resolveConfig = (config) => {
|
|
|
2675
2917
|
|
|
2676
2918
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2677
2919
|
|
|
2678
|
-
var xhrAdapter = isXHRAdapterSupported &&
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2920
|
+
var xhrAdapter = isXHRAdapterSupported &&
|
|
2921
|
+
function (config) {
|
|
2922
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2923
|
+
const _config = resolveConfig(config);
|
|
2924
|
+
let requestData = _config.data;
|
|
2925
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
2926
|
+
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
2927
|
+
let onCanceled;
|
|
2928
|
+
let uploadThrottled, downloadThrottled;
|
|
2929
|
+
let flushUpload, flushDownload;
|
|
2687
2930
|
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2931
|
+
function done() {
|
|
2932
|
+
flushUpload && flushUpload(); // flush events
|
|
2933
|
+
flushDownload && flushDownload(); // flush events
|
|
2691
2934
|
|
|
2692
|
-
|
|
2935
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
2693
2936
|
|
|
2694
|
-
|
|
2695
|
-
|
|
2937
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
2938
|
+
}
|
|
2696
2939
|
|
|
2697
|
-
|
|
2940
|
+
let request = new XMLHttpRequest();
|
|
2698
2941
|
|
|
2699
|
-
|
|
2942
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
2700
2943
|
|
|
2701
|
-
|
|
2702
|
-
|
|
2944
|
+
// Set the request timeout in MS
|
|
2945
|
+
request.timeout = _config.timeout;
|
|
2703
2946
|
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2947
|
+
function onloadend() {
|
|
2948
|
+
if (!request) {
|
|
2949
|
+
return;
|
|
2950
|
+
}
|
|
2951
|
+
// Prepare the response
|
|
2952
|
+
const responseHeaders = AxiosHeaders$1.from(
|
|
2953
|
+
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2954
|
+
);
|
|
2955
|
+
const responseData =
|
|
2956
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
2957
|
+
? request.responseText
|
|
2958
|
+
: request.response;
|
|
2959
|
+
const response = {
|
|
2960
|
+
data: responseData,
|
|
2961
|
+
status: request.status,
|
|
2962
|
+
statusText: request.statusText,
|
|
2963
|
+
headers: responseHeaders,
|
|
2964
|
+
config,
|
|
2965
|
+
request,
|
|
2966
|
+
};
|
|
2967
|
+
|
|
2968
|
+
settle(
|
|
2969
|
+
function _resolve(value) {
|
|
2970
|
+
resolve(value);
|
|
2971
|
+
done();
|
|
2972
|
+
},
|
|
2973
|
+
function _reject(err) {
|
|
2974
|
+
reject(err);
|
|
2975
|
+
done();
|
|
2976
|
+
},
|
|
2977
|
+
response
|
|
2978
|
+
);
|
|
2979
|
+
|
|
2980
|
+
// Clean up request
|
|
2981
|
+
request = null;
|
|
2707
2982
|
}
|
|
2708
|
-
// Prepare the response
|
|
2709
|
-
const responseHeaders = AxiosHeaders$1.from(
|
|
2710
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2711
|
-
);
|
|
2712
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
2713
|
-
request.responseText : request.response;
|
|
2714
|
-
const response = {
|
|
2715
|
-
data: responseData,
|
|
2716
|
-
status: request.status,
|
|
2717
|
-
statusText: request.statusText,
|
|
2718
|
-
headers: responseHeaders,
|
|
2719
|
-
config,
|
|
2720
|
-
request
|
|
2721
|
-
};
|
|
2722
2983
|
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
}
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2984
|
+
if ('onloadend' in request) {
|
|
2985
|
+
// Use onloadend if available
|
|
2986
|
+
request.onloadend = onloadend;
|
|
2987
|
+
} else {
|
|
2988
|
+
// Listen for ready state to emulate onloadend
|
|
2989
|
+
request.onreadystatechange = function handleLoad() {
|
|
2990
|
+
if (!request || request.readyState !== 4) {
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2730
2993
|
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2994
|
+
// The request errored out and we didn't get a response, this will be
|
|
2995
|
+
// handled by onerror instead
|
|
2996
|
+
// With one exception: request that using file: protocol, most browsers
|
|
2997
|
+
// will return status as 0 even though it's a successful request
|
|
2998
|
+
if (
|
|
2999
|
+
request.status === 0 &&
|
|
3000
|
+
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
|
3001
|
+
) {
|
|
3002
|
+
return;
|
|
3003
|
+
}
|
|
3004
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
|
3005
|
+
// so we should call onloadend on the next 'tick'
|
|
3006
|
+
setTimeout(onloadend);
|
|
3007
|
+
};
|
|
3008
|
+
}
|
|
2734
3009
|
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
} else {
|
|
2739
|
-
// Listen for ready state to emulate onloadend
|
|
2740
|
-
request.onreadystatechange = function handleLoad() {
|
|
2741
|
-
if (!request || request.readyState !== 4) {
|
|
3010
|
+
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
3011
|
+
request.onabort = function handleAbort() {
|
|
3012
|
+
if (!request) {
|
|
2742
3013
|
return;
|
|
2743
3014
|
}
|
|
2744
3015
|
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
//
|
|
2748
|
-
|
|
2749
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
2750
|
-
return;
|
|
2751
|
-
}
|
|
2752
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2753
|
-
// so we should call onloadend on the next 'tick'
|
|
2754
|
-
setTimeout(onloadend);
|
|
3016
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
3017
|
+
|
|
3018
|
+
// Clean up request
|
|
3019
|
+
request = null;
|
|
2755
3020
|
};
|
|
2756
|
-
}
|
|
2757
3021
|
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
3022
|
+
// Handle low level network errors
|
|
3023
|
+
request.onerror = function handleError(event) {
|
|
3024
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
3025
|
+
// (message may be empty; when present, surface it)
|
|
3026
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
3027
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
3028
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
3029
|
+
// attach the underlying event for consumers who want details
|
|
3030
|
+
err.event = event || null;
|
|
3031
|
+
reject(err);
|
|
3032
|
+
request = null;
|
|
3033
|
+
};
|
|
2763
3034
|
|
|
2764
|
-
|
|
3035
|
+
// Handle timeout
|
|
3036
|
+
request.ontimeout = function handleTimeout() {
|
|
3037
|
+
let timeoutErrorMessage = _config.timeout
|
|
3038
|
+
? 'timeout of ' + _config.timeout + 'ms exceeded'
|
|
3039
|
+
: 'timeout exceeded';
|
|
3040
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
3041
|
+
if (_config.timeoutErrorMessage) {
|
|
3042
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
3043
|
+
}
|
|
3044
|
+
reject(
|
|
3045
|
+
new AxiosError$1(
|
|
3046
|
+
timeoutErrorMessage,
|
|
3047
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
3048
|
+
config,
|
|
3049
|
+
request
|
|
3050
|
+
)
|
|
3051
|
+
);
|
|
2765
3052
|
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
3053
|
+
// Clean up request
|
|
3054
|
+
request = null;
|
|
3055
|
+
};
|
|
2769
3056
|
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
// Browsers deliver a ProgressEvent in XHR onerror
|
|
2773
|
-
// (message may be empty; when present, surface it)
|
|
2774
|
-
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2775
|
-
const msg = event && event.message ? event.message : 'Network Error';
|
|
2776
|
-
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
2777
|
-
// attach the underlying event for consumers who want details
|
|
2778
|
-
err.event = event || null;
|
|
2779
|
-
reject(err);
|
|
2780
|
-
request = null;
|
|
2781
|
-
};
|
|
2782
|
-
|
|
2783
|
-
// Handle timeout
|
|
2784
|
-
request.ontimeout = function handleTimeout() {
|
|
2785
|
-
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
2786
|
-
const transitional = _config.transitional || transitionalDefaults;
|
|
2787
|
-
if (_config.timeoutErrorMessage) {
|
|
2788
|
-
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2789
|
-
}
|
|
2790
|
-
reject(new AxiosError$1(
|
|
2791
|
-
timeoutErrorMessage,
|
|
2792
|
-
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
2793
|
-
config,
|
|
2794
|
-
request));
|
|
2795
|
-
|
|
2796
|
-
// Clean up request
|
|
2797
|
-
request = null;
|
|
2798
|
-
};
|
|
3057
|
+
// Remove Content-Type if data is undefined
|
|
3058
|
+
requestData === undefined && requestHeaders.setContentType(null);
|
|
2799
3059
|
|
|
2800
|
-
|
|
2801
|
-
|
|
3060
|
+
// Add headers to the request
|
|
3061
|
+
if ('setRequestHeader' in request) {
|
|
3062
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
3063
|
+
request.setRequestHeader(key, val);
|
|
3064
|
+
});
|
|
3065
|
+
}
|
|
2802
3066
|
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
});
|
|
2808
|
-
}
|
|
3067
|
+
// Add withCredentials to request if needed
|
|
3068
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
3069
|
+
request.withCredentials = !!_config.withCredentials;
|
|
3070
|
+
}
|
|
2809
3071
|
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
3072
|
+
// Add responseType to request if needed
|
|
3073
|
+
if (responseType && responseType !== 'json') {
|
|
3074
|
+
request.responseType = _config.responseType;
|
|
3075
|
+
}
|
|
2814
3076
|
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
3077
|
+
// Handle progress if needed
|
|
3078
|
+
if (onDownloadProgress) {
|
|
3079
|
+
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
3080
|
+
request.addEventListener('progress', downloadThrottled);
|
|
3081
|
+
}
|
|
2819
3082
|
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
request.addEventListener('progress', downloadThrottled);
|
|
2824
|
-
}
|
|
3083
|
+
// Not all browsers support upload events
|
|
3084
|
+
if (onUploadProgress && request.upload) {
|
|
3085
|
+
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
|
2825
3086
|
|
|
2826
|
-
|
|
2827
|
-
if (onUploadProgress && request.upload) {
|
|
2828
|
-
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
3087
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
2829
3088
|
|
|
2830
|
-
|
|
3089
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
3090
|
+
}
|
|
2831
3091
|
|
|
2832
|
-
|
|
2833
|
-
|
|
3092
|
+
if (_config.cancelToken || _config.signal) {
|
|
3093
|
+
// Handle cancellation
|
|
3094
|
+
// eslint-disable-next-line func-names
|
|
3095
|
+
onCanceled = (cancel) => {
|
|
3096
|
+
if (!request) {
|
|
3097
|
+
return;
|
|
3098
|
+
}
|
|
3099
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
3100
|
+
request.abort();
|
|
3101
|
+
request = null;
|
|
3102
|
+
};
|
|
2834
3103
|
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
return;
|
|
3104
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
3105
|
+
if (_config.signal) {
|
|
3106
|
+
_config.signal.aborted
|
|
3107
|
+
? onCanceled()
|
|
3108
|
+
: _config.signal.addEventListener('abort', onCanceled);
|
|
2841
3109
|
}
|
|
2842
|
-
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2843
|
-
request.abort();
|
|
2844
|
-
request = null;
|
|
2845
|
-
};
|
|
2846
|
-
|
|
2847
|
-
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
2848
|
-
if (_config.signal) {
|
|
2849
|
-
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
2850
3110
|
}
|
|
2851
|
-
}
|
|
2852
3111
|
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
2856
|
-
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
2857
|
-
return;
|
|
2858
|
-
}
|
|
3112
|
+
const protocol = parseProtocol(_config.url);
|
|
2859
3113
|
|
|
3114
|
+
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
3115
|
+
reject(
|
|
3116
|
+
new AxiosError$1(
|
|
3117
|
+
'Unsupported protocol ' + protocol + ':',
|
|
3118
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
3119
|
+
config
|
|
3120
|
+
)
|
|
3121
|
+
);
|
|
3122
|
+
return;
|
|
3123
|
+
}
|
|
2860
3124
|
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
};
|
|
3125
|
+
// Send the request
|
|
3126
|
+
request.send(requestData || null);
|
|
3127
|
+
});
|
|
3128
|
+
};
|
|
2865
3129
|
|
|
2866
3130
|
const composeSignals = (signals, timeout) => {
|
|
2867
|
-
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
3131
|
+
const { length } = (signals = signals ? signals.filter(Boolean) : []);
|
|
2868
3132
|
|
|
2869
3133
|
if (timeout || length) {
|
|
2870
3134
|
let controller = new AbortController();
|
|
@@ -2876,21 +3140,29 @@ const composeSignals = (signals, timeout) => {
|
|
|
2876
3140
|
aborted = true;
|
|
2877
3141
|
unsubscribe();
|
|
2878
3142
|
const err = reason instanceof Error ? reason : this.reason;
|
|
2879
|
-
controller.abort(
|
|
3143
|
+
controller.abort(
|
|
3144
|
+
err instanceof AxiosError$1
|
|
3145
|
+
? err
|
|
3146
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3147
|
+
);
|
|
2880
3148
|
}
|
|
2881
3149
|
};
|
|
2882
3150
|
|
|
2883
|
-
let timer =
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
3151
|
+
let timer =
|
|
3152
|
+
timeout &&
|
|
3153
|
+
setTimeout(() => {
|
|
3154
|
+
timer = null;
|
|
3155
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3156
|
+
}, timeout);
|
|
2887
3157
|
|
|
2888
3158
|
const unsubscribe = () => {
|
|
2889
3159
|
if (signals) {
|
|
2890
3160
|
timer && clearTimeout(timer);
|
|
2891
3161
|
timer = null;
|
|
2892
|
-
signals.forEach(signal => {
|
|
2893
|
-
signal.unsubscribe
|
|
3162
|
+
signals.forEach((signal) => {
|
|
3163
|
+
signal.unsubscribe
|
|
3164
|
+
? signal.unsubscribe(onabort)
|
|
3165
|
+
: signal.removeEventListener('abort', onabort);
|
|
2894
3166
|
});
|
|
2895
3167
|
signals = null;
|
|
2896
3168
|
}
|
|
@@ -2898,7 +3170,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
2898
3170
|
|
|
2899
3171
|
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
2900
3172
|
|
|
2901
|
-
const {signal} = controller;
|
|
3173
|
+
const { signal } = controller;
|
|
2902
3174
|
|
|
2903
3175
|
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
2904
3176
|
|
|
@@ -2939,7 +3211,7 @@ const readStream = async function* (stream) {
|
|
|
2939
3211
|
const reader = stream.getReader();
|
|
2940
3212
|
try {
|
|
2941
3213
|
for (;;) {
|
|
2942
|
-
const {done, value} = await reader.read();
|
|
3214
|
+
const { done, value } = await reader.read();
|
|
2943
3215
|
if (done) {
|
|
2944
3216
|
break;
|
|
2945
3217
|
}
|
|
@@ -2962,64 +3234,69 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
2962
3234
|
}
|
|
2963
3235
|
};
|
|
2964
3236
|
|
|
2965
|
-
return new ReadableStream(
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
3237
|
+
return new ReadableStream(
|
|
3238
|
+
{
|
|
3239
|
+
async pull(controller) {
|
|
3240
|
+
try {
|
|
3241
|
+
const { done, value } = await iterator.next();
|
|
2969
3242
|
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
3243
|
+
if (done) {
|
|
3244
|
+
_onFinish();
|
|
3245
|
+
controller.close();
|
|
3246
|
+
return;
|
|
3247
|
+
}
|
|
2975
3248
|
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
3249
|
+
let len = value.byteLength;
|
|
3250
|
+
if (onProgress) {
|
|
3251
|
+
let loadedBytes = (bytes += len);
|
|
3252
|
+
onProgress(loadedBytes);
|
|
3253
|
+
}
|
|
3254
|
+
controller.enqueue(new Uint8Array(value));
|
|
3255
|
+
} catch (err) {
|
|
3256
|
+
_onFinish(err);
|
|
3257
|
+
throw err;
|
|
2980
3258
|
}
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
_onFinish(
|
|
2984
|
-
|
|
2985
|
-
}
|
|
3259
|
+
},
|
|
3260
|
+
cancel(reason) {
|
|
3261
|
+
_onFinish(reason);
|
|
3262
|
+
return iterator.return();
|
|
3263
|
+
},
|
|
2986
3264
|
},
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
return iterator.return();
|
|
3265
|
+
{
|
|
3266
|
+
highWaterMark: 2,
|
|
2990
3267
|
}
|
|
2991
|
-
|
|
2992
|
-
highWaterMark: 2
|
|
2993
|
-
})
|
|
3268
|
+
);
|
|
2994
3269
|
};
|
|
2995
3270
|
|
|
2996
3271
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2997
3272
|
|
|
2998
|
-
const {isFunction} = utils$1;
|
|
3273
|
+
const { isFunction } = utils$1;
|
|
2999
3274
|
|
|
3000
|
-
const globalFetchAPI = (({Request, Response}) => ({
|
|
3001
|
-
Request,
|
|
3275
|
+
const globalFetchAPI = (({ Request, Response }) => ({
|
|
3276
|
+
Request,
|
|
3277
|
+
Response,
|
|
3002
3278
|
}))(utils$1.global);
|
|
3003
3279
|
|
|
3004
|
-
const {
|
|
3005
|
-
ReadableStream: ReadableStream$1, TextEncoder
|
|
3006
|
-
} = utils$1.global;
|
|
3007
|
-
|
|
3280
|
+
const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
|
|
3008
3281
|
|
|
3009
3282
|
const test = (fn, ...args) => {
|
|
3010
3283
|
try {
|
|
3011
3284
|
return !!fn(...args);
|
|
3012
3285
|
} catch (e) {
|
|
3013
|
-
return false
|
|
3286
|
+
return false;
|
|
3014
3287
|
}
|
|
3015
3288
|
};
|
|
3016
3289
|
|
|
3017
3290
|
const factory = (env) => {
|
|
3018
|
-
env = utils$1.merge.call(
|
|
3019
|
-
|
|
3020
|
-
|
|
3291
|
+
env = utils$1.merge.call(
|
|
3292
|
+
{
|
|
3293
|
+
skipUndefined: true,
|
|
3294
|
+
},
|
|
3295
|
+
globalFetchAPI,
|
|
3296
|
+
env
|
|
3297
|
+
);
|
|
3021
3298
|
|
|
3022
|
-
const {fetch: envFetch, Request, Response} = env;
|
|
3299
|
+
const { fetch: envFetch, Request, Response } = env;
|
|
3023
3300
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
3024
3301
|
const isRequestSupported = isFunction(Request);
|
|
3025
3302
|
const isResponseSupported = isFunction(Response);
|
|
@@ -3030,46 +3307,67 @@ const factory = (env) => {
|
|
|
3030
3307
|
|
|
3031
3308
|
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
3032
3309
|
|
|
3033
|
-
const encodeText =
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3310
|
+
const encodeText =
|
|
3311
|
+
isFetchSupported &&
|
|
3312
|
+
(typeof TextEncoder === 'function'
|
|
3313
|
+
? (
|
|
3314
|
+
(encoder) => (str) =>
|
|
3315
|
+
encoder.encode(str)
|
|
3316
|
+
)(new TextEncoder())
|
|
3317
|
+
: async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
3318
|
+
|
|
3319
|
+
const supportsRequestStream =
|
|
3320
|
+
isRequestSupported &&
|
|
3321
|
+
isReadableStreamSupported &&
|
|
3322
|
+
test(() => {
|
|
3323
|
+
let duplexAccessed = false;
|
|
3324
|
+
|
|
3325
|
+
const request = new Request(platform.origin, {
|
|
3326
|
+
body: new ReadableStream$1(),
|
|
3327
|
+
method: 'POST',
|
|
3328
|
+
get duplex() {
|
|
3329
|
+
duplexAccessed = true;
|
|
3330
|
+
return 'half';
|
|
3331
|
+
},
|
|
3332
|
+
});
|
|
3037
3333
|
|
|
3038
|
-
|
|
3039
|
-
let duplexAccessed = false;
|
|
3334
|
+
const hasContentType = request.headers.has('Content-Type');
|
|
3040
3335
|
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
get duplex() {
|
|
3045
|
-
duplexAccessed = true;
|
|
3046
|
-
return 'half';
|
|
3047
|
-
},
|
|
3048
|
-
}).headers.has('Content-Type');
|
|
3336
|
+
if (request.body != null) {
|
|
3337
|
+
request.body.cancel();
|
|
3338
|
+
}
|
|
3049
3339
|
|
|
3050
|
-
|
|
3051
|
-
|
|
3340
|
+
return duplexAccessed && !hasContentType;
|
|
3341
|
+
});
|
|
3052
3342
|
|
|
3053
|
-
const supportsResponseStream =
|
|
3343
|
+
const supportsResponseStream =
|
|
3344
|
+
isResponseSupported &&
|
|
3345
|
+
isReadableStreamSupported &&
|
|
3054
3346
|
test(() => utils$1.isReadableStream(new Response('').body));
|
|
3055
3347
|
|
|
3056
3348
|
const resolvers = {
|
|
3057
|
-
stream: supportsResponseStream && ((res) => res.body)
|
|
3349
|
+
stream: supportsResponseStream && ((res) => res.body),
|
|
3058
3350
|
};
|
|
3059
3351
|
|
|
3060
|
-
isFetchSupported &&
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3352
|
+
isFetchSupported &&
|
|
3353
|
+
(() => {
|
|
3354
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
|
|
3355
|
+
!resolvers[type] &&
|
|
3356
|
+
(resolvers[type] = (res, config) => {
|
|
3357
|
+
let method = res && res[type];
|
|
3064
3358
|
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3359
|
+
if (method) {
|
|
3360
|
+
return method.call(res);
|
|
3361
|
+
}
|
|
3068
3362
|
|
|
3069
|
-
|
|
3363
|
+
throw new AxiosError$1(
|
|
3364
|
+
`Response type '${type}' is not supported`,
|
|
3365
|
+
AxiosError$1.ERR_NOT_SUPPORT,
|
|
3366
|
+
config
|
|
3367
|
+
);
|
|
3368
|
+
});
|
|
3070
3369
|
});
|
|
3071
|
-
});
|
|
3072
|
-
})());
|
|
3370
|
+
})();
|
|
3073
3371
|
|
|
3074
3372
|
const getBodyLength = async (body) => {
|
|
3075
3373
|
if (body == null) {
|
|
@@ -3120,32 +3418,41 @@ const factory = (env) => {
|
|
|
3120
3418
|
responseType,
|
|
3121
3419
|
headers,
|
|
3122
3420
|
withCredentials = 'same-origin',
|
|
3123
|
-
fetchOptions
|
|
3421
|
+
fetchOptions,
|
|
3124
3422
|
} = resolveConfig(config);
|
|
3125
3423
|
|
|
3126
3424
|
let _fetch = envFetch || fetch;
|
|
3127
3425
|
|
|
3128
3426
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3129
3427
|
|
|
3130
|
-
let composedSignal = composeSignals(
|
|
3428
|
+
let composedSignal = composeSignals(
|
|
3429
|
+
[signal, cancelToken && cancelToken.toAbortSignal()],
|
|
3430
|
+
timeout
|
|
3431
|
+
);
|
|
3131
3432
|
|
|
3132
3433
|
let request = null;
|
|
3133
3434
|
|
|
3134
|
-
const unsubscribe =
|
|
3135
|
-
composedSignal
|
|
3136
|
-
|
|
3435
|
+
const unsubscribe =
|
|
3436
|
+
composedSignal &&
|
|
3437
|
+
composedSignal.unsubscribe &&
|
|
3438
|
+
(() => {
|
|
3439
|
+
composedSignal.unsubscribe();
|
|
3440
|
+
});
|
|
3137
3441
|
|
|
3138
3442
|
let requestContentLength;
|
|
3139
3443
|
|
|
3140
3444
|
try {
|
|
3141
3445
|
if (
|
|
3142
|
-
onUploadProgress &&
|
|
3446
|
+
onUploadProgress &&
|
|
3447
|
+
supportsRequestStream &&
|
|
3448
|
+
method !== 'get' &&
|
|
3449
|
+
method !== 'head' &&
|
|
3143
3450
|
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
3144
3451
|
) {
|
|
3145
3452
|
let _request = new Request(url, {
|
|
3146
3453
|
method: 'POST',
|
|
3147
3454
|
body: data,
|
|
3148
|
-
duplex:
|
|
3455
|
+
duplex: 'half',
|
|
3149
3456
|
});
|
|
3150
3457
|
|
|
3151
3458
|
let contentTypeHeader;
|
|
@@ -3170,7 +3477,20 @@ const factory = (env) => {
|
|
|
3170
3477
|
|
|
3171
3478
|
// Cloudflare Workers throws when credentials are defined
|
|
3172
3479
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
3173
|
-
const isCredentialsSupported = isRequestSupported &&
|
|
3480
|
+
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
3481
|
+
|
|
3482
|
+
// If data is FormData and Content-Type is multipart/form-data without boundary,
|
|
3483
|
+
// delete it so fetch can set it correctly with the boundary
|
|
3484
|
+
if (utils$1.isFormData(data)) {
|
|
3485
|
+
const contentType = headers.getContentType();
|
|
3486
|
+
if (
|
|
3487
|
+
contentType &&
|
|
3488
|
+
/^multipart\/form-data/i.test(contentType) &&
|
|
3489
|
+
!/boundary=/i.test(contentType)
|
|
3490
|
+
) {
|
|
3491
|
+
headers.delete('content-type');
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3174
3494
|
|
|
3175
3495
|
const resolvedOptions = {
|
|
3176
3496
|
...fetchOptions,
|
|
@@ -3178,29 +3498,35 @@ const factory = (env) => {
|
|
|
3178
3498
|
method: method.toUpperCase(),
|
|
3179
3499
|
headers: headers.normalize().toJSON(),
|
|
3180
3500
|
body: data,
|
|
3181
|
-
duplex:
|
|
3182
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3501
|
+
duplex: 'half',
|
|
3502
|
+
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
3183
3503
|
};
|
|
3184
3504
|
|
|
3185
3505
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3186
3506
|
|
|
3187
|
-
let response = await (isRequestSupported
|
|
3507
|
+
let response = await (isRequestSupported
|
|
3508
|
+
? _fetch(request, fetchOptions)
|
|
3509
|
+
: _fetch(url, resolvedOptions));
|
|
3188
3510
|
|
|
3189
|
-
const isStreamResponse =
|
|
3511
|
+
const isStreamResponse =
|
|
3512
|
+
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3190
3513
|
|
|
3191
3514
|
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
3192
3515
|
const options = {};
|
|
3193
3516
|
|
|
3194
|
-
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3517
|
+
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
3195
3518
|
options[prop] = response[prop];
|
|
3196
3519
|
});
|
|
3197
3520
|
|
|
3198
3521
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3199
3522
|
|
|
3200
|
-
const [onProgress, flush] =
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3523
|
+
const [onProgress, flush] =
|
|
3524
|
+
(onDownloadProgress &&
|
|
3525
|
+
progressEventDecorator(
|
|
3526
|
+
responseContentLength,
|
|
3527
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3528
|
+
)) ||
|
|
3529
|
+
[];
|
|
3204
3530
|
|
|
3205
3531
|
response = new Response(
|
|
3206
3532
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
@@ -3213,7 +3539,10 @@ const factory = (env) => {
|
|
|
3213
3539
|
|
|
3214
3540
|
responseType = responseType || 'text';
|
|
3215
3541
|
|
|
3216
|
-
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3542
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3543
|
+
response,
|
|
3544
|
+
config
|
|
3545
|
+
);
|
|
3217
3546
|
|
|
3218
3547
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3219
3548
|
|
|
@@ -3224,43 +3553,50 @@ const factory = (env) => {
|
|
|
3224
3553
|
status: response.status,
|
|
3225
3554
|
statusText: response.statusText,
|
|
3226
3555
|
config,
|
|
3227
|
-
request
|
|
3556
|
+
request,
|
|
3228
3557
|
});
|
|
3229
|
-
})
|
|
3558
|
+
});
|
|
3230
3559
|
} catch (err) {
|
|
3231
3560
|
unsubscribe && unsubscribe();
|
|
3232
3561
|
|
|
3233
3562
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3234
3563
|
throw Object.assign(
|
|
3235
|
-
new AxiosError$1(
|
|
3564
|
+
new AxiosError$1(
|
|
3565
|
+
'Network Error',
|
|
3566
|
+
AxiosError$1.ERR_NETWORK,
|
|
3567
|
+
config,
|
|
3568
|
+
request,
|
|
3569
|
+
err && err.response
|
|
3570
|
+
),
|
|
3236
3571
|
{
|
|
3237
|
-
cause: err.cause || err
|
|
3572
|
+
cause: err.cause || err,
|
|
3238
3573
|
}
|
|
3239
|
-
)
|
|
3574
|
+
);
|
|
3240
3575
|
}
|
|
3241
3576
|
|
|
3242
3577
|
throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
|
|
3243
3578
|
}
|
|
3244
|
-
}
|
|
3579
|
+
};
|
|
3245
3580
|
};
|
|
3246
3581
|
|
|
3247
3582
|
const seedCache = new Map();
|
|
3248
3583
|
|
|
3249
3584
|
const getFetch = (config) => {
|
|
3250
3585
|
let env = (config && config.env) || {};
|
|
3251
|
-
const {fetch, Request, Response} = env;
|
|
3252
|
-
const seeds = [
|
|
3253
|
-
Request, Response, fetch
|
|
3254
|
-
];
|
|
3586
|
+
const { fetch, Request, Response } = env;
|
|
3587
|
+
const seeds = [Request, Response, fetch];
|
|
3255
3588
|
|
|
3256
|
-
let len = seeds.length,
|
|
3257
|
-
|
|
3589
|
+
let len = seeds.length,
|
|
3590
|
+
i = len,
|
|
3591
|
+
seed,
|
|
3592
|
+
target,
|
|
3593
|
+
map = seedCache;
|
|
3258
3594
|
|
|
3259
3595
|
while (i--) {
|
|
3260
3596
|
seed = seeds[i];
|
|
3261
3597
|
target = map.get(seed);
|
|
3262
3598
|
|
|
3263
|
-
target === undefined && map.set(seed, target =
|
|
3599
|
+
target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
|
|
3264
3600
|
|
|
3265
3601
|
map = target;
|
|
3266
3602
|
}
|
|
@@ -3276,7 +3612,7 @@ getFetch();
|
|
|
3276
3612
|
* - `http` for Node.js
|
|
3277
3613
|
* - `xhr` for browsers
|
|
3278
3614
|
* - `fetch` for fetch API-based requests
|
|
3279
|
-
*
|
|
3615
|
+
*
|
|
3280
3616
|
* @type {Object<string, Function|Object>}
|
|
3281
3617
|
*/
|
|
3282
3618
|
const knownAdapters = {
|
|
@@ -3284,7 +3620,7 @@ const knownAdapters = {
|
|
|
3284
3620
|
xhr: xhrAdapter,
|
|
3285
3621
|
fetch: {
|
|
3286
3622
|
get: getFetch,
|
|
3287
|
-
}
|
|
3623
|
+
},
|
|
3288
3624
|
};
|
|
3289
3625
|
|
|
3290
3626
|
// Assign adapter names for easier debugging and identification
|
|
@@ -3301,7 +3637,7 @@ utils$1.forEach(knownAdapters, (fn, value) => {
|
|
|
3301
3637
|
|
|
3302
3638
|
/**
|
|
3303
3639
|
* Render a rejection reason string for unknown or unsupported adapters
|
|
3304
|
-
*
|
|
3640
|
+
*
|
|
3305
3641
|
* @param {string} reason
|
|
3306
3642
|
* @returns {string}
|
|
3307
3643
|
*/
|
|
@@ -3309,17 +3645,18 @@ const renderReason = (reason) => `- ${reason}`;
|
|
|
3309
3645
|
|
|
3310
3646
|
/**
|
|
3311
3647
|
* Check if the adapter is resolved (function, null, or false)
|
|
3312
|
-
*
|
|
3648
|
+
*
|
|
3313
3649
|
* @param {Function|null|false} adapter
|
|
3314
3650
|
* @returns {boolean}
|
|
3315
3651
|
*/
|
|
3316
|
-
const isResolvedHandle = (adapter) =>
|
|
3652
|
+
const isResolvedHandle = (adapter) =>
|
|
3653
|
+
utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3317
3654
|
|
|
3318
3655
|
/**
|
|
3319
3656
|
* Get the first suitable adapter from the provided list.
|
|
3320
3657
|
* Tries each adapter in order until a supported one is found.
|
|
3321
3658
|
* Throws an AxiosError if no adapter is suitable.
|
|
3322
|
-
*
|
|
3659
|
+
*
|
|
3323
3660
|
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3324
3661
|
* @param {Object} config - Axios request configuration
|
|
3325
3662
|
* @throws {AxiosError} If no suitable adapter is available
|
|
@@ -3356,14 +3693,17 @@ function getAdapter$1(adapters, config) {
|
|
|
3356
3693
|
}
|
|
3357
3694
|
|
|
3358
3695
|
if (!adapter) {
|
|
3359
|
-
const reasons = Object.entries(rejectedReasons)
|
|
3360
|
-
|
|
3696
|
+
const reasons = Object.entries(rejectedReasons).map(
|
|
3697
|
+
([id, state]) =>
|
|
3698
|
+
`adapter ${id} ` +
|
|
3361
3699
|
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3362
|
-
|
|
3700
|
+
);
|
|
3363
3701
|
|
|
3364
|
-
let s = length
|
|
3365
|
-
|
|
3366
|
-
|
|
3702
|
+
let s = length
|
|
3703
|
+
? reasons.length > 1
|
|
3704
|
+
? 'since :\n' + reasons.map(renderReason).join('\n')
|
|
3705
|
+
: ' ' + renderReason(reasons[0])
|
|
3706
|
+
: 'as no adapter specified';
|
|
3367
3707
|
|
|
3368
3708
|
throw new AxiosError$1(
|
|
3369
3709
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
@@ -3388,7 +3728,7 @@ var adapters = {
|
|
|
3388
3728
|
* Exposes all known adapters
|
|
3389
3729
|
* @type {Object<string, Function|Object>}
|
|
3390
3730
|
*/
|
|
3391
|
-
adapters: knownAdapters
|
|
3731
|
+
adapters: knownAdapters,
|
|
3392
3732
|
};
|
|
3393
3733
|
|
|
3394
3734
|
/**
|
|
@@ -3421,10 +3761,7 @@ function dispatchRequest(config) {
|
|
|
3421
3761
|
config.headers = AxiosHeaders$1.from(config.headers);
|
|
3422
3762
|
|
|
3423
3763
|
// Transform request data
|
|
3424
|
-
config.data = transformData.call(
|
|
3425
|
-
config,
|
|
3426
|
-
config.transformRequest
|
|
3427
|
-
);
|
|
3764
|
+
config.data = transformData.call(config, config.transformRequest);
|
|
3428
3765
|
|
|
3429
3766
|
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
3430
3767
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
@@ -3432,39 +3769,38 @@ function dispatchRequest(config) {
|
|
|
3432
3769
|
|
|
3433
3770
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
3434
3771
|
|
|
3435
|
-
return adapter(config).then(
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
// Transform response data
|
|
3439
|
-
response.data = transformData.call(
|
|
3440
|
-
config,
|
|
3441
|
-
config.transformResponse,
|
|
3442
|
-
response
|
|
3443
|
-
);
|
|
3444
|
-
|
|
3445
|
-
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3446
|
-
|
|
3447
|
-
return response;
|
|
3448
|
-
}, function onAdapterRejection(reason) {
|
|
3449
|
-
if (!isCancel$1(reason)) {
|
|
3772
|
+
return adapter(config).then(
|
|
3773
|
+
function onAdapterResolution(response) {
|
|
3450
3774
|
throwIfCancellationRequested(config);
|
|
3451
3775
|
|
|
3452
3776
|
// Transform response data
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3777
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
3778
|
+
|
|
3779
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3780
|
+
|
|
3781
|
+
return response;
|
|
3782
|
+
},
|
|
3783
|
+
function onAdapterRejection(reason) {
|
|
3784
|
+
if (!isCancel$1(reason)) {
|
|
3785
|
+
throwIfCancellationRequested(config);
|
|
3786
|
+
|
|
3787
|
+
// Transform response data
|
|
3788
|
+
if (reason && reason.response) {
|
|
3789
|
+
reason.response.data = transformData.call(
|
|
3790
|
+
config,
|
|
3791
|
+
config.transformResponse,
|
|
3792
|
+
reason.response
|
|
3793
|
+
);
|
|
3794
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
3795
|
+
}
|
|
3460
3796
|
}
|
|
3461
|
-
}
|
|
3462
3797
|
|
|
3463
|
-
|
|
3464
|
-
|
|
3798
|
+
return Promise.reject(reason);
|
|
3799
|
+
}
|
|
3800
|
+
);
|
|
3465
3801
|
}
|
|
3466
3802
|
|
|
3467
|
-
const VERSION$1 = "1.
|
|
3803
|
+
const VERSION$1 = "1.15.2";
|
|
3468
3804
|
|
|
3469
3805
|
const validators$1 = {};
|
|
3470
3806
|
|
|
@@ -3488,7 +3824,15 @@ const deprecatedWarnings = {};
|
|
|
3488
3824
|
*/
|
|
3489
3825
|
validators$1.transitional = function transitional(validator, version, message) {
|
|
3490
3826
|
function formatMessage(opt, desc) {
|
|
3491
|
-
return
|
|
3827
|
+
return (
|
|
3828
|
+
'[Axios v' +
|
|
3829
|
+
VERSION$1 +
|
|
3830
|
+
"] Transitional option '" +
|
|
3831
|
+
opt +
|
|
3832
|
+
"'" +
|
|
3833
|
+
desc +
|
|
3834
|
+
(message ? '. ' + message : '')
|
|
3835
|
+
);
|
|
3492
3836
|
}
|
|
3493
3837
|
|
|
3494
3838
|
// eslint-disable-next-line func-names
|
|
@@ -3520,7 +3864,7 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
3520
3864
|
// eslint-disable-next-line no-console
|
|
3521
3865
|
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
3522
3866
|
return true;
|
|
3523
|
-
}
|
|
3867
|
+
};
|
|
3524
3868
|
};
|
|
3525
3869
|
|
|
3526
3870
|
/**
|
|
@@ -3541,12 +3885,17 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3541
3885
|
let i = keys.length;
|
|
3542
3886
|
while (i-- > 0) {
|
|
3543
3887
|
const opt = keys[i];
|
|
3544
|
-
|
|
3888
|
+
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
3889
|
+
// a non-function validator and cause a TypeError. See GHSA-q8qp-cvcw-x6jj.
|
|
3890
|
+
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
3545
3891
|
if (validator) {
|
|
3546
3892
|
const value = options[opt];
|
|
3547
3893
|
const result = value === undefined || validator(value, opt, options);
|
|
3548
3894
|
if (result !== true) {
|
|
3549
|
-
throw new AxiosError$1(
|
|
3895
|
+
throw new AxiosError$1(
|
|
3896
|
+
'option ' + opt + ' must be ' + result,
|
|
3897
|
+
AxiosError$1.ERR_BAD_OPTION_VALUE
|
|
3898
|
+
);
|
|
3550
3899
|
}
|
|
3551
3900
|
continue;
|
|
3552
3901
|
}
|
|
@@ -3558,7 +3907,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3558
3907
|
|
|
3559
3908
|
var validator = {
|
|
3560
3909
|
assertOptions,
|
|
3561
|
-
validators: validators$1
|
|
3910
|
+
validators: validators$1,
|
|
3562
3911
|
};
|
|
3563
3912
|
|
|
3564
3913
|
const validators = validator.validators;
|
|
@@ -3575,7 +3924,7 @@ let Axios$1 = class Axios {
|
|
|
3575
3924
|
this.defaults = instanceConfig || {};
|
|
3576
3925
|
this.interceptors = {
|
|
3577
3926
|
request: new InterceptorManager(),
|
|
3578
|
-
response: new InterceptorManager()
|
|
3927
|
+
response: new InterceptorManager(),
|
|
3579
3928
|
};
|
|
3580
3929
|
}
|
|
3581
3930
|
|
|
@@ -3597,13 +3946,29 @@ let Axios$1 = class Axios {
|
|
|
3597
3946
|
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
3598
3947
|
|
|
3599
3948
|
// slice off the Error: ... line
|
|
3600
|
-
const stack =
|
|
3949
|
+
const stack = (() => {
|
|
3950
|
+
if (!dummy.stack) {
|
|
3951
|
+
return '';
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
const firstNewlineIndex = dummy.stack.indexOf('\n');
|
|
3955
|
+
|
|
3956
|
+
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
3957
|
+
})();
|
|
3601
3958
|
try {
|
|
3602
3959
|
if (!err.stack) {
|
|
3603
3960
|
err.stack = stack;
|
|
3604
3961
|
// match without the 2 top stack lines
|
|
3605
|
-
} else if (stack
|
|
3606
|
-
|
|
3962
|
+
} else if (stack) {
|
|
3963
|
+
const firstNewlineIndex = stack.indexOf('\n');
|
|
3964
|
+
const secondNewlineIndex =
|
|
3965
|
+
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
3966
|
+
const stackWithoutTwoTopLines =
|
|
3967
|
+
secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|
3968
|
+
|
|
3969
|
+
if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
|
|
3970
|
+
err.stack += '\n' + stack;
|
|
3971
|
+
}
|
|
3607
3972
|
}
|
|
3608
3973
|
} catch (e) {
|
|
3609
3974
|
// ignore the case where "stack" is an un-writable property
|
|
@@ -3626,27 +3991,35 @@ let Axios$1 = class Axios {
|
|
|
3626
3991
|
|
|
3627
3992
|
config = mergeConfig$1(this.defaults, config);
|
|
3628
3993
|
|
|
3629
|
-
const {transitional, paramsSerializer, headers} = config;
|
|
3994
|
+
const { transitional, paramsSerializer, headers } = config;
|
|
3630
3995
|
|
|
3631
3996
|
if (transitional !== undefined) {
|
|
3632
|
-
validator.assertOptions(
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3997
|
+
validator.assertOptions(
|
|
3998
|
+
transitional,
|
|
3999
|
+
{
|
|
4000
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
4001
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
4002
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
4003
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
4004
|
+
},
|
|
4005
|
+
false
|
|
4006
|
+
);
|
|
3638
4007
|
}
|
|
3639
4008
|
|
|
3640
4009
|
if (paramsSerializer != null) {
|
|
3641
4010
|
if (utils$1.isFunction(paramsSerializer)) {
|
|
3642
4011
|
config.paramsSerializer = {
|
|
3643
|
-
serialize: paramsSerializer
|
|
4012
|
+
serialize: paramsSerializer,
|
|
3644
4013
|
};
|
|
3645
4014
|
} else {
|
|
3646
|
-
validator.assertOptions(
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
4015
|
+
validator.assertOptions(
|
|
4016
|
+
paramsSerializer,
|
|
4017
|
+
{
|
|
4018
|
+
encode: validators.function,
|
|
4019
|
+
serialize: validators.function,
|
|
4020
|
+
},
|
|
4021
|
+
true
|
|
4022
|
+
);
|
|
3650
4023
|
}
|
|
3651
4024
|
}
|
|
3652
4025
|
|
|
@@ -3657,26 +4030,25 @@ let Axios$1 = class Axios {
|
|
|
3657
4030
|
config.allowAbsoluteUrls = true;
|
|
3658
4031
|
}
|
|
3659
4032
|
|
|
3660
|
-
validator.assertOptions(
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
4033
|
+
validator.assertOptions(
|
|
4034
|
+
config,
|
|
4035
|
+
{
|
|
4036
|
+
baseUrl: validators.spelling('baseURL'),
|
|
4037
|
+
withXsrfToken: validators.spelling('withXSRFToken'),
|
|
4038
|
+
},
|
|
4039
|
+
true
|
|
4040
|
+
);
|
|
3664
4041
|
|
|
3665
4042
|
// Set config.method
|
|
3666
4043
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3667
4044
|
|
|
3668
4045
|
// Flatten headers
|
|
3669
|
-
let contextHeaders = headers && utils$1.merge(
|
|
3670
|
-
headers.common,
|
|
3671
|
-
headers[config.method]
|
|
3672
|
-
);
|
|
4046
|
+
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
3673
4047
|
|
|
3674
|
-
headers &&
|
|
3675
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3676
|
-
(method) => {
|
|
4048
|
+
headers &&
|
|
4049
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
3677
4050
|
delete headers[method];
|
|
3678
|
-
}
|
|
3679
|
-
);
|
|
4051
|
+
});
|
|
3680
4052
|
|
|
3681
4053
|
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
3682
4054
|
|
|
@@ -3691,7 +4063,8 @@ let Axios$1 = class Axios {
|
|
|
3691
4063
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3692
4064
|
|
|
3693
4065
|
const transitional = config.transitional || transitionalDefaults;
|
|
3694
|
-
const legacyInterceptorReqResOrdering =
|
|
4066
|
+
const legacyInterceptorReqResOrdering =
|
|
4067
|
+
transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3695
4068
|
|
|
3696
4069
|
if (legacyInterceptorReqResOrdering) {
|
|
3697
4070
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
@@ -3765,28 +4138,32 @@ let Axios$1 = class Axios {
|
|
|
3765
4138
|
// Provide aliases for supported request methods
|
|
3766
4139
|
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3767
4140
|
/*eslint func-names:0*/
|
|
3768
|
-
Axios$1.prototype[method] = function(url, config) {
|
|
3769
|
-
return this.request(
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
4141
|
+
Axios$1.prototype[method] = function (url, config) {
|
|
4142
|
+
return this.request(
|
|
4143
|
+
mergeConfig$1(config || {}, {
|
|
4144
|
+
method,
|
|
4145
|
+
url,
|
|
4146
|
+
data: (config || {}).data,
|
|
4147
|
+
})
|
|
4148
|
+
);
|
|
3774
4149
|
};
|
|
3775
4150
|
});
|
|
3776
4151
|
|
|
3777
4152
|
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3778
|
-
/*eslint func-names:0*/
|
|
3779
|
-
|
|
3780
4153
|
function generateHTTPMethod(isForm) {
|
|
3781
4154
|
return function httpMethod(url, data, config) {
|
|
3782
|
-
return this.request(
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
4155
|
+
return this.request(
|
|
4156
|
+
mergeConfig$1(config || {}, {
|
|
4157
|
+
method,
|
|
4158
|
+
headers: isForm
|
|
4159
|
+
? {
|
|
4160
|
+
'Content-Type': 'multipart/form-data',
|
|
4161
|
+
}
|
|
4162
|
+
: {},
|
|
4163
|
+
url,
|
|
4164
|
+
data,
|
|
4165
|
+
})
|
|
4166
|
+
);
|
|
3790
4167
|
};
|
|
3791
4168
|
}
|
|
3792
4169
|
|
|
@@ -3817,7 +4194,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
3817
4194
|
const token = this;
|
|
3818
4195
|
|
|
3819
4196
|
// eslint-disable-next-line func-names
|
|
3820
|
-
this.promise.then(cancel => {
|
|
4197
|
+
this.promise.then((cancel) => {
|
|
3821
4198
|
if (!token._listeners) return;
|
|
3822
4199
|
|
|
3823
4200
|
let i = token._listeners.length;
|
|
@@ -3829,10 +4206,10 @@ let CancelToken$1 = class CancelToken {
|
|
|
3829
4206
|
});
|
|
3830
4207
|
|
|
3831
4208
|
// eslint-disable-next-line func-names
|
|
3832
|
-
this.promise.then = onfulfilled => {
|
|
4209
|
+
this.promise.then = (onfulfilled) => {
|
|
3833
4210
|
let _resolve;
|
|
3834
4211
|
// eslint-disable-next-line func-names
|
|
3835
|
-
const promise = new Promise(resolve => {
|
|
4212
|
+
const promise = new Promise((resolve) => {
|
|
3836
4213
|
token.subscribe(resolve);
|
|
3837
4214
|
_resolve = resolve;
|
|
3838
4215
|
}).then(onfulfilled);
|
|
@@ -3920,7 +4297,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
3920
4297
|
});
|
|
3921
4298
|
return {
|
|
3922
4299
|
token,
|
|
3923
|
-
cancel
|
|
4300
|
+
cancel,
|
|
3924
4301
|
};
|
|
3925
4302
|
}
|
|
3926
4303
|
};
|
|
@@ -3960,7 +4337,7 @@ function spread$1(callback) {
|
|
|
3960
4337
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3961
4338
|
*/
|
|
3962
4339
|
function isAxiosError$1(payload) {
|
|
3963
|
-
return utils$1.isObject(payload) &&
|
|
4340
|
+
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
3964
4341
|
}
|
|
3965
4342
|
|
|
3966
4343
|
const HttpStatusCode$1 = {
|
|
@@ -4051,10 +4428,10 @@ function createInstance(defaultConfig) {
|
|
|
4051
4428
|
const instance = bind(Axios$1.prototype.request, context);
|
|
4052
4429
|
|
|
4053
4430
|
// Copy axios.prototype to instance
|
|
4054
|
-
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
4431
|
+
utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
|
|
4055
4432
|
|
|
4056
4433
|
// Copy context to instance
|
|
4057
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
4434
|
+
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
4058
4435
|
|
|
4059
4436
|
// Factory for creating new instances
|
|
4060
4437
|
instance.create = function create(instanceConfig) {
|
|
@@ -4098,7 +4475,7 @@ axios.mergeConfig = mergeConfig$1;
|
|
|
4098
4475
|
|
|
4099
4476
|
axios.AxiosHeaders = AxiosHeaders$1;
|
|
4100
4477
|
|
|
4101
|
-
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4478
|
+
axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4102
4479
|
|
|
4103
4480
|
axios.getAdapter = adapters.getAdapter;
|
|
4104
4481
|
|
|
@@ -4125,7 +4502,7 @@ const {
|
|
|
4125
4502
|
HttpStatusCode,
|
|
4126
4503
|
formToJSON,
|
|
4127
4504
|
getAdapter,
|
|
4128
|
-
mergeConfig
|
|
4505
|
+
mergeConfig,
|
|
4129
4506
|
} = axios;
|
|
4130
4507
|
|
|
4131
4508
|
/**
|
|
@@ -4143,26 +4520,6 @@ const urlForNetwork = (network) => {
|
|
|
4143
4520
|
return 'http://insight.testnet.networks.dash.org:3001/insight-api';
|
|
4144
4521
|
}
|
|
4145
4522
|
};
|
|
4146
|
-
/**
|
|
4147
|
-
* Fetch address details from the Insight API.
|
|
4148
|
-
*
|
|
4149
|
-
* @param {InsightAddressParams} p Parameters for fetching address details.
|
|
4150
|
-
* @returns {Promise<InsightAddressResponse>} Address details fetched from the Insight API.
|
|
4151
|
-
*/
|
|
4152
|
-
const getAddress = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4153
|
-
const data = (yield axios.get(`${urlForNetwork(p.network)}/addr/${p.address}`)).data;
|
|
4154
|
-
return data;
|
|
4155
|
-
});
|
|
4156
|
-
/**
|
|
4157
|
-
* Fetch transactions associated with an address from the Insight API.
|
|
4158
|
-
*
|
|
4159
|
-
* @param {InsightAddressParams} p Parameters for fetching address transactions.
|
|
4160
|
-
* @returns {Promise<{ txs: InsightTxResponse[]; pagesTotal: number }>} Transactions associated with the address.
|
|
4161
|
-
*/
|
|
4162
|
-
const getAddressTxs = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4163
|
-
const pageNum = (p === null || p === void 0 ? void 0 : p.pageNum) || 0;
|
|
4164
|
-
return (yield axios.get(`${urlForNetwork(p.network)}/txs?address=${p.address}&pageNum=${pageNum}`)).data;
|
|
4165
|
-
});
|
|
4166
4523
|
/**
|
|
4167
4524
|
* Fetch UTXOs associated with an address from the Insight API.
|
|
4168
4525
|
*
|
|
@@ -4172,15 +4529,6 @@ const getAddressTxs = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
4172
4529
|
const getAddressUtxos = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4173
4530
|
return (yield axios.get(`${urlForNetwork(p.network)}/addr/${p.address}/utxo`)).data;
|
|
4174
4531
|
});
|
|
4175
|
-
/**
|
|
4176
|
-
* Fetch transaction details from the Insight API.
|
|
4177
|
-
*
|
|
4178
|
-
* @param {InsightTransactionParams} p Parameters for fetching transaction details.
|
|
4179
|
-
* @returns {Promise<InsightTxResponse>} Transaction details fetched from the Insight API.
|
|
4180
|
-
*/
|
|
4181
|
-
const getTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4182
|
-
return (yield axios.get(`${urlForNetwork(p.network)}/tx/${p.txid}`)).data;
|
|
4183
|
-
});
|
|
4184
4532
|
/**
|
|
4185
4533
|
* Fetch raw transaction data from the Insight API.
|
|
4186
4534
|
*
|
|
@@ -4332,7 +4680,7 @@ const defaultDashParams = {
|
|
|
4332
4680
|
network: xchainClient.Network.Mainnet,
|
|
4333
4681
|
phrase: '',
|
|
4334
4682
|
explorerProviders: explorerProviders,
|
|
4335
|
-
dataProviders: [
|
|
4683
|
+
dataProviders: [BlockcypherDataProviders, BitgoProviders],
|
|
4336
4684
|
rootDerivationPaths: {
|
|
4337
4685
|
[xchainClient.Network.Mainnet]: `m/44'/5'/0'/0/`,
|
|
4338
4686
|
[xchainClient.Network.Stagenet]: `m/44'/5'/0'/0/`,
|
|
@@ -4383,120 +4731,6 @@ class Client extends xchainUtxo.Client {
|
|
|
4383
4731
|
validateAddress(address) {
|
|
4384
4732
|
return validateAddress(address, this.network);
|
|
4385
4733
|
}
|
|
4386
|
-
/**
|
|
4387
|
-
* Asynchronously get the balance for a DASH address.
|
|
4388
|
-
* @param {string} address The DASH address.
|
|
4389
|
-
* @returns {Promise<Balance[]>} A promise resolving to an array of balances.
|
|
4390
|
-
*/
|
|
4391
|
-
getBalance(address) {
|
|
4392
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4393
|
-
const addressResponse = yield getAddress({ network: this.network, address });
|
|
4394
|
-
const confirmed = xchainUtil.baseAmount(addressResponse.balanceSat);
|
|
4395
|
-
const unconfirmed = xchainUtil.baseAmount(addressResponse.unconfirmedBalanceSat);
|
|
4396
|
-
return [
|
|
4397
|
-
{
|
|
4398
|
-
asset: AssetDASH,
|
|
4399
|
-
amount: confirmed.plus(unconfirmed),
|
|
4400
|
-
},
|
|
4401
|
-
];
|
|
4402
|
-
});
|
|
4403
|
-
}
|
|
4404
|
-
/**
|
|
4405
|
-
* Asynchronously retrieves transactions for a given address.
|
|
4406
|
-
* @param {TxHistoryParams} params - Parameters for transaction retrieval.
|
|
4407
|
-
* @returns {Promise<TxsPage>} A promise resolving to a page of transactions.
|
|
4408
|
-
*/
|
|
4409
|
-
getTransactions(params) {
|
|
4410
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4411
|
-
var _a;
|
|
4412
|
-
// Extract offset and limit from parameters or set default values
|
|
4413
|
-
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
4414
|
-
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
4415
|
-
// Insight uses pages rather than offset/limit indexes, so we have to
|
|
4416
|
-
// iterate through each page within the offset/limit range.
|
|
4417
|
-
const perPage = 10;
|
|
4418
|
-
const startPage = Math.floor(offset / perPage);
|
|
4419
|
-
const endPage = Math.floor((offset + limit - 1) / perPage);
|
|
4420
|
-
const firstPageOffset = offset % perPage;
|
|
4421
|
-
const lastPageLimit = (firstPageOffset + (limit - 1)) % perPage;
|
|
4422
|
-
let totalPages = -1;
|
|
4423
|
-
let lastPageTotal = -1;
|
|
4424
|
-
let insightTxs = [];
|
|
4425
|
-
// Iterate through each page within the offset/limit range
|
|
4426
|
-
for (let pageNum = startPage; pageNum <= endPage; pageNum++) {
|
|
4427
|
-
const response = yield getAddressTxs({
|
|
4428
|
-
network: this.network,
|
|
4429
|
-
address: `${params === null || params === void 0 ? void 0 : params.address}`,
|
|
4430
|
-
pageNum,
|
|
4431
|
-
});
|
|
4432
|
-
let startIndex = 0;
|
|
4433
|
-
let endIndex = perPage - 1;
|
|
4434
|
-
if (pageNum == startPage) {
|
|
4435
|
-
startIndex = firstPageOffset;
|
|
4436
|
-
}
|
|
4437
|
-
if (pageNum === endPage) {
|
|
4438
|
-
endIndex = lastPageLimit;
|
|
4439
|
-
}
|
|
4440
|
-
insightTxs = [...insightTxs, ...response.txs.slice(startIndex, endIndex + 1)];
|
|
4441
|
-
// Insight only returns the number of pages not the total number of
|
|
4442
|
-
// transactions. If the last page is within the offset/limit range then we
|
|
4443
|
-
// can set the lastPageTotal here and avoid having to send another request,
|
|
4444
|
-
// otherwise we can fetch the last page later to determine the total
|
|
4445
|
-
// transaction count
|
|
4446
|
-
totalPages = response.pagesTotal;
|
|
4447
|
-
if (pageNum === totalPages - 1) {
|
|
4448
|
-
lastPageTotal = response.txs.length;
|
|
4449
|
-
}
|
|
4450
|
-
}
|
|
4451
|
-
// Map insight transactions to XChain transactions
|
|
4452
|
-
const txs = insightTxs.map(this.insightTxToXChainTx);
|
|
4453
|
-
// Fetch transactions count for last page if not obtained
|
|
4454
|
-
if (lastPageTotal < 0) {
|
|
4455
|
-
const lastPageResponse = yield getAddressTxs({
|
|
4456
|
-
network: this.network,
|
|
4457
|
-
address: `${params === null || params === void 0 ? void 0 : params.address}`,
|
|
4458
|
-
pageNum: totalPages - 1,
|
|
4459
|
-
});
|
|
4460
|
-
lastPageTotal = lastPageResponse.txs.length;
|
|
4461
|
-
}
|
|
4462
|
-
// Calculate total transactions count and return the page of transactions
|
|
4463
|
-
return {
|
|
4464
|
-
total: (totalPages - 1) * perPage + lastPageTotal,
|
|
4465
|
-
txs,
|
|
4466
|
-
};
|
|
4467
|
-
});
|
|
4468
|
-
}
|
|
4469
|
-
/**
|
|
4470
|
-
* Asynchronously retrieves transaction data for a given transaction ID.
|
|
4471
|
-
* @param {string} txid - The transaction ID.
|
|
4472
|
-
* @returns {Promise<Tx>} A promise resolving to the transaction data.
|
|
4473
|
-
*/
|
|
4474
|
-
getTransactionData(txid) {
|
|
4475
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4476
|
-
const tx = yield getTx({ network: this.network, txid });
|
|
4477
|
-
return this.insightTxToXChainTx(tx);
|
|
4478
|
-
});
|
|
4479
|
-
}
|
|
4480
|
-
/**
|
|
4481
|
-
* Converts an Insight transaction response to XChain transaction.
|
|
4482
|
-
* @param {InsightTxResponse} tx - The Insight transaction response.
|
|
4483
|
-
* @returns {Tx} The XChain transaction.
|
|
4484
|
-
*/
|
|
4485
|
-
insightTxToXChainTx(tx) {
|
|
4486
|
-
return {
|
|
4487
|
-
asset: AssetDASH,
|
|
4488
|
-
from: tx.vin.map((i) => ({
|
|
4489
|
-
from: i.addr,
|
|
4490
|
-
amount: xchainUtil.assetToBase(xchainUtil.assetAmount(i.value)),
|
|
4491
|
-
})),
|
|
4492
|
-
to: tx.vout
|
|
4493
|
-
.filter((i) => i.scriptPubKey.type !== 'nulldata')
|
|
4494
|
-
.map((i) => { var _a; return ({ to: (_a = i.scriptPubKey.addresses) === null || _a === void 0 ? void 0 : _a[0], amount: xchainUtil.assetToBase(xchainUtil.assetAmount(i.value)) }); }),
|
|
4495
|
-
date: new Date(tx.time * 1000),
|
|
4496
|
-
type: xchainClient.TxType.Transfer,
|
|
4497
|
-
hash: tx.txid,
|
|
4498
|
-
};
|
|
4499
|
-
}
|
|
4500
4734
|
/**
|
|
4501
4735
|
* Asynchronously prepares a transaction for sending assets.
|
|
4502
4736
|
* @deprecated Use `prepareTxEnhanced` instead for better UTXO selection and error handling.
|
|
@@ -4566,6 +4800,15 @@ class Client extends xchainUtxo.Client {
|
|
|
4566
4800
|
// Ensure fee meets minimum requirement
|
|
4567
4801
|
return fee > TX_MIN_FEE ? fee : TX_MIN_FEE;
|
|
4568
4802
|
}
|
|
4803
|
+
getUtxoScriptHex(utxo) {
|
|
4804
|
+
var _a;
|
|
4805
|
+
// Providers may populate either scriptPubKey (Insight) or witnessUtxo.script (Blockcypher)
|
|
4806
|
+
const scriptHex = utxo.scriptPubKey || ((_a = utxo.witnessUtxo) === null || _a === void 0 ? void 0 : _a.script.toString('hex'));
|
|
4807
|
+
if (!scriptHex) {
|
|
4808
|
+
throw xchainUtxo.UtxoError.validationError(`UTXO ${utxo.hash}:${utxo.index} is missing scriptPubKey and witnessUtxo.script`);
|
|
4809
|
+
}
|
|
4810
|
+
return scriptHex;
|
|
4811
|
+
}
|
|
4569
4812
|
// ==================== Enhanced Transaction Methods ====================
|
|
4570
4813
|
/**
|
|
4571
4814
|
* Prepare transaction with enhanced UTXO selection.
|
|
@@ -4601,7 +4844,7 @@ class Client extends xchainUtxo.Client {
|
|
|
4601
4844
|
const tx = new dashcore__default.default.Transaction().to(recipient, targetValue);
|
|
4602
4845
|
// Add selected inputs
|
|
4603
4846
|
for (const utxo of selectionResult.inputs) {
|
|
4604
|
-
const scriptBuffer = Buffer.from(utxo
|
|
4847
|
+
const scriptBuffer = Buffer.from(this.getUtxoScriptHex(utxo), 'hex');
|
|
4605
4848
|
const script = new dashcore__default.default.Script(scriptBuffer);
|
|
4606
4849
|
const input = new dashcore__default.default.Transaction.Input.PublicKeyHash({
|
|
4607
4850
|
prevTxId: Buffer.from(utxo.hash, 'hex'),
|
|
@@ -4662,7 +4905,7 @@ class Client extends xchainUtxo.Client {
|
|
|
4662
4905
|
const tx = new dashcore__default.default.Transaction().to(recipient, maxCalc.amount);
|
|
4663
4906
|
// Add inputs
|
|
4664
4907
|
for (const utxo of maxCalc.inputs) {
|
|
4665
|
-
const scriptBuffer = Buffer.from(utxo
|
|
4908
|
+
const scriptBuffer = Buffer.from(this.getUtxoScriptHex(utxo), 'hex');
|
|
4666
4909
|
const script = new dashcore__default.default.Script(scriptBuffer);
|
|
4667
4910
|
const input = new dashcore__default.default.Transaction.Input.PublicKeyHash({
|
|
4668
4911
|
prevTxId: Buffer.from(utxo.hash, 'hex'),
|
|
@@ -4699,37 +4942,6 @@ class Client extends xchainUtxo.Client {
|
|
|
4699
4942
|
}
|
|
4700
4943
|
}
|
|
4701
4944
|
|
|
4702
|
-
/**
|
|
4703
|
-
* Function to broadcast a transaction to the Dash network.
|
|
4704
|
-
*
|
|
4705
|
-
* @param {BroadcastTxParams} params Parameters for broadcasting the transaction.
|
|
4706
|
-
* @returns {Promise<TxHash>} Promise that resolves with the transaction hash if successful, or rejects with an error message if unsuccessful.
|
|
4707
|
-
*/
|
|
4708
|
-
const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4709
|
-
const uniqueId = new Date().getTime().toString(); // Generate a unique identifier for the transaction request.
|
|
4710
|
-
try {
|
|
4711
|
-
const response = (yield axios.post(`${params.nodeUrl}/tx/send`, // URL endpoint for broadcasting the transaction.
|
|
4712
|
-
{
|
|
4713
|
-
jsonrpc: '2.0',
|
|
4714
|
-
rawtx: [params.txHex], // Include the hexadecimal transaction in the request body.
|
|
4715
|
-
id: uniqueId,
|
|
4716
|
-
}, {
|
|
4717
|
-
auth: params.auth, // Include authentication credentials if provided.
|
|
4718
|
-
timeout: 30 * 1000, // Set a timeout for the request.
|
|
4719
|
-
})).data;
|
|
4720
|
-
if (response.error) {
|
|
4721
|
-
// If there is an error in the response, reject the promise with the error message.
|
|
4722
|
-
return Promise.reject(Error(`failed to broadcast a transaction: ${response.error}`));
|
|
4723
|
-
}
|
|
4724
|
-
// If no error, return the transaction ID indicating successful broadcast.
|
|
4725
|
-
return response.txid;
|
|
4726
|
-
}
|
|
4727
|
-
catch (ex) {
|
|
4728
|
-
// If an exception occurs during the request, reject the promise with the caught error message.
|
|
4729
|
-
return Promise.reject(Error(`failed to broadcast a transaction caught: ${String(ex)}`));
|
|
4730
|
-
}
|
|
4731
|
-
});
|
|
4732
|
-
|
|
4733
4945
|
const ECPair = ecpair.ECPairFactory(ecc__namespace);
|
|
4734
4946
|
class ClientKeystore extends Client {
|
|
4735
4947
|
/**
|
|
@@ -4802,13 +5014,16 @@ class ClientKeystore extends Client {
|
|
|
4802
5014
|
const tx = new dashcore__default.default.Transaction(rawUnsignedTx);
|
|
4803
5015
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4804
5016
|
tx.inputs.forEach((input, index) => {
|
|
5017
|
+
var _a;
|
|
4805
5018
|
const insightUtxo = utxos.find((utxo) => {
|
|
4806
5019
|
return utxo.hash === input.prevTxId.toString('hex') && utxo.index == input.outputIndex;
|
|
4807
5020
|
});
|
|
4808
5021
|
if (!insightUtxo) {
|
|
4809
5022
|
throw new Error('Unable to match accumulative inputs with insight utxos');
|
|
4810
5023
|
}
|
|
4811
|
-
|
|
5024
|
+
// Providers may populate either scriptPubKey (Insight) or witnessUtxo.script (Blockcypher)
|
|
5025
|
+
const scriptHex = insightUtxo.scriptPubKey || ((_a = insightUtxo.witnessUtxo) === null || _a === void 0 ? void 0 : _a.script.toString('hex')) || '';
|
|
5026
|
+
const scriptBuffer = Buffer.from(scriptHex, 'hex');
|
|
4812
5027
|
const script = new dashcore__default.default.Script(scriptBuffer);
|
|
4813
5028
|
tx.inputs[index] = new dashcore__default.default.Transaction.Input.PublicKeyHash({
|
|
4814
5029
|
prevTxId: Buffer.from(insightUtxo.hash, 'hex'),
|
|
@@ -4823,11 +5038,7 @@ class ClientKeystore extends Client {
|
|
|
4823
5038
|
const dashKeys = this.getDashKeys(this.phrase, fromAddressIndex);
|
|
4824
5039
|
tx.sign(`${(_a = dashKeys.privateKey) === null || _a === void 0 ? void 0 : _a.toString('hex')}`);
|
|
4825
5040
|
const txHex = tx.checkedSerialize({});
|
|
4826
|
-
return yield broadcastTx(
|
|
4827
|
-
txHex,
|
|
4828
|
-
nodeUrl: this.nodeUrls[this.network],
|
|
4829
|
-
auth: this.nodeAuth,
|
|
4830
|
-
});
|
|
5041
|
+
return yield this.broadcastTx(txHex);
|
|
4831
5042
|
});
|
|
4832
5043
|
}
|
|
4833
5044
|
/**
|
|
@@ -4860,13 +5071,16 @@ class ClientKeystore extends Client {
|
|
|
4860
5071
|
const tx = new dashcore__default.default.Transaction(rawUnsignedTx);
|
|
4861
5072
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4862
5073
|
tx.inputs.forEach((input, index) => {
|
|
5074
|
+
var _a;
|
|
4863
5075
|
const insightUtxo = utxos.find((utxo) => {
|
|
4864
5076
|
return utxo.hash === input.prevTxId.toString('hex') && utxo.index == input.outputIndex;
|
|
4865
5077
|
});
|
|
4866
5078
|
if (!insightUtxo) {
|
|
4867
5079
|
throw new Error('Unable to match accumulative inputs with insight utxos');
|
|
4868
5080
|
}
|
|
4869
|
-
|
|
5081
|
+
// Providers may populate either scriptPubKey (Insight) or witnessUtxo.script (Blockcypher)
|
|
5082
|
+
const scriptHex = insightUtxo.scriptPubKey || ((_a = insightUtxo.witnessUtxo) === null || _a === void 0 ? void 0 : _a.script.toString('hex')) || '';
|
|
5083
|
+
const scriptBuffer = Buffer.from(scriptHex, 'hex');
|
|
4870
5084
|
const script = new dashcore__default.default.Script(scriptBuffer);
|
|
4871
5085
|
tx.inputs[index] = new dashcore__default.default.Transaction.Input.PublicKeyHash({
|
|
4872
5086
|
prevTxId: Buffer.from(insightUtxo.hash, 'hex'),
|
|
@@ -4881,11 +5095,7 @@ class ClientKeystore extends Client {
|
|
|
4881
5095
|
const dashKeys = this.getDashKeys(this.phrase, fromAddressIndex);
|
|
4882
5096
|
tx.sign(`${(_a = dashKeys.privateKey) === null || _a === void 0 ? void 0 : _a.toString('hex')}`);
|
|
4883
5097
|
const txHex = tx.checkedSerialize({});
|
|
4884
|
-
const hash = yield broadcastTx(
|
|
4885
|
-
txHex,
|
|
4886
|
-
nodeUrl: this.nodeUrls[this.network],
|
|
4887
|
-
auth: this.nodeAuth,
|
|
4888
|
-
});
|
|
5098
|
+
const hash = yield this.broadcastTx(txHex);
|
|
4889
5099
|
return { hash, maxAmount, fee };
|
|
4890
5100
|
});
|
|
4891
5101
|
}
|
|
@@ -4968,13 +5178,8 @@ class ClientLedger extends Client {
|
|
|
4968
5178
|
useTrustedInputForSegwit: false,
|
|
4969
5179
|
additionals: [],
|
|
4970
5180
|
});
|
|
4971
|
-
// Broadcast transaction
|
|
4972
|
-
const txHash = yield broadcastTx(
|
|
4973
|
-
txHex,
|
|
4974
|
-
nodeUrl: this.nodeUrls[this.network],
|
|
4975
|
-
auth: this.nodeAuth,
|
|
4976
|
-
});
|
|
4977
|
-
// Throw error if no transaction hash is received
|
|
5181
|
+
// Broadcast transaction via the configured data providers
|
|
5182
|
+
const txHash = yield this.broadcastTx(txHex);
|
|
4978
5183
|
if (!txHash) {
|
|
4979
5184
|
throw Error('No Tx hash');
|
|
4980
5185
|
}
|
|
@@ -5022,11 +5227,7 @@ class ClientLedger extends Client {
|
|
|
5022
5227
|
useTrustedInputForSegwit: false,
|
|
5023
5228
|
additionals: [],
|
|
5024
5229
|
});
|
|
5025
|
-
const hash = yield broadcastTx(
|
|
5026
|
-
txHex,
|
|
5027
|
-
nodeUrl: this.nodeUrls[this.network],
|
|
5028
|
-
auth: this.nodeAuth,
|
|
5029
|
-
});
|
|
5230
|
+
const hash = yield this.broadcastTx(txHex);
|
|
5030
5231
|
if (!hash) {
|
|
5031
5232
|
throw Error('No Tx hash');
|
|
5032
5233
|
}
|