@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.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExplorerProvider, Network,
|
|
2
|
-
import { AssetType
|
|
1
|
+
import { ExplorerProvider, Network, FeeOption, checkFeeBounds } from '@xchainjs/xchain-client';
|
|
2
|
+
import { AssetType } from '@xchainjs/xchain-util';
|
|
3
3
|
import { BlockcypherProvider, BlockcypherNetwork, BitgoProvider } from '@xchainjs/xchain-utxo-providers';
|
|
4
4
|
import dashcore from '@dashevo/dashcore-lib';
|
|
5
|
-
import { toBitcoinJS, Client as Client$1,
|
|
5
|
+
import { toBitcoinJS, Client as Client$1, UtxoError, UtxoTransactionValidator } from '@xchainjs/xchain-utxo';
|
|
6
6
|
import * as Dash from 'bitcoinjs-lib';
|
|
7
7
|
import accumulative from 'coinselect/accumulative.js';
|
|
8
8
|
import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs';
|
|
@@ -47,7 +47,7 @@ const AssetDASH = { chain: DASHChain, symbol: 'DASH', ticker: 'DASH', type: Asse
|
|
|
47
47
|
/**
|
|
48
48
|
* Explorer provider for Dash mainnet.
|
|
49
49
|
*/
|
|
50
|
-
const DASH_MAINNET_EXPLORER = new ExplorerProvider('https://
|
|
50
|
+
const DASH_MAINNET_EXPLORER = new ExplorerProvider('https://blockchair.com/dash', 'https://blockchair.com/dash/address/%%ADDRESS%%', 'https://blockchair.com/dash/transaction/%%TX_ID%%');
|
|
51
51
|
/**
|
|
52
52
|
* Explorer provider for Dash testnet.
|
|
53
53
|
*/
|
|
@@ -169,7 +169,7 @@ const { isArray } = Array;
|
|
|
169
169
|
*
|
|
170
170
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
171
171
|
*/
|
|
172
|
-
const isUndefined = typeOfTest(
|
|
172
|
+
const isUndefined = typeOfTest('undefined');
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Determine if a value is a Buffer
|
|
@@ -196,7 +196,7 @@ function isBuffer(val) {
|
|
|
196
196
|
*
|
|
197
197
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
198
198
|
*/
|
|
199
|
-
const isArrayBuffer = kindOfTest(
|
|
199
|
+
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -207,7 +207,7 @@ const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
|
207
207
|
*/
|
|
208
208
|
function isArrayBufferView(val) {
|
|
209
209
|
let result;
|
|
210
|
-
if (typeof ArrayBuffer !==
|
|
210
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
211
211
|
result = ArrayBuffer.isView(val);
|
|
212
212
|
} else {
|
|
213
213
|
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
@@ -222,7 +222,7 @@ function isArrayBufferView(val) {
|
|
|
222
222
|
*
|
|
223
223
|
* @returns {boolean} True if value is a String, otherwise false
|
|
224
224
|
*/
|
|
225
|
-
const isString = typeOfTest(
|
|
225
|
+
const isString = typeOfTest('string');
|
|
226
226
|
|
|
227
227
|
/**
|
|
228
228
|
* Determine if a value is a Function
|
|
@@ -230,7 +230,7 @@ const isString = typeOfTest("string");
|
|
|
230
230
|
* @param {*} val The value to test
|
|
231
231
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
232
232
|
*/
|
|
233
|
-
const isFunction$1 = typeOfTest(
|
|
233
|
+
const isFunction$1 = typeOfTest('function');
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* Determine if a value is a Number
|
|
@@ -239,7 +239,7 @@ const isFunction$1 = typeOfTest("function");
|
|
|
239
239
|
*
|
|
240
240
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
241
241
|
*/
|
|
242
|
-
const isNumber = typeOfTest(
|
|
242
|
+
const isNumber = typeOfTest('number');
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
245
|
* Determine if a value is an Object
|
|
@@ -248,7 +248,7 @@ const isNumber = typeOfTest("number");
|
|
|
248
248
|
*
|
|
249
249
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
250
250
|
*/
|
|
251
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
251
|
+
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
254
|
* Determine if a value is a Boolean
|
|
@@ -266,7 +266,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
266
266
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
267
267
|
*/
|
|
268
268
|
const isPlainObject = (val) => {
|
|
269
|
-
if (kindOf(val) !==
|
|
269
|
+
if (kindOf(val) !== 'object') {
|
|
270
270
|
return false;
|
|
271
271
|
}
|
|
272
272
|
|
|
@@ -294,10 +294,7 @@ const isEmptyObject = (val) => {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
try {
|
|
297
|
-
return (
|
|
298
|
-
Object.keys(val).length === 0 &&
|
|
299
|
-
Object.getPrototypeOf(val) === Object.prototype
|
|
300
|
-
);
|
|
297
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
301
298
|
} catch (e) {
|
|
302
299
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
303
300
|
return false;
|
|
@@ -311,7 +308,7 @@ const isEmptyObject = (val) => {
|
|
|
311
308
|
*
|
|
312
309
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
313
310
|
*/
|
|
314
|
-
const isDate = kindOfTest(
|
|
311
|
+
const isDate = kindOfTest('Date');
|
|
315
312
|
|
|
316
313
|
/**
|
|
317
314
|
* Determine if a value is a File
|
|
@@ -320,7 +317,32 @@ const isDate = kindOfTest("Date");
|
|
|
320
317
|
*
|
|
321
318
|
* @returns {boolean} True if value is a File, otherwise false
|
|
322
319
|
*/
|
|
323
|
-
const isFile = kindOfTest(
|
|
320
|
+
const isFile = kindOfTest('File');
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Determine if a value is a React Native Blob
|
|
324
|
+
* React Native "blob": an object with a `uri` attribute. Optionally, it can
|
|
325
|
+
* also have a `name` and `type` attribute to specify filename and content type
|
|
326
|
+
*
|
|
327
|
+
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
328
|
+
*
|
|
329
|
+
* @param {*} value The value to test
|
|
330
|
+
*
|
|
331
|
+
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
332
|
+
*/
|
|
333
|
+
const isReactNativeBlob = (value) => {
|
|
334
|
+
return !!(value && typeof value.uri !== 'undefined');
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Determine if environment is React Native
|
|
339
|
+
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
340
|
+
*
|
|
341
|
+
* @param {*} formData The formData to test
|
|
342
|
+
*
|
|
343
|
+
* @returns {boolean} True if environment is React Native, otherwise false
|
|
344
|
+
*/
|
|
345
|
+
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
324
346
|
|
|
325
347
|
/**
|
|
326
348
|
* Determine if a value is a Blob
|
|
@@ -329,7 +351,7 @@ const isFile = kindOfTest("File");
|
|
|
329
351
|
*
|
|
330
352
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
331
353
|
*/
|
|
332
|
-
const isBlob = kindOfTest(
|
|
354
|
+
const isBlob = kindOfTest('Blob');
|
|
333
355
|
|
|
334
356
|
/**
|
|
335
357
|
* Determine if a value is a FileList
|
|
@@ -338,7 +360,7 @@ const isBlob = kindOfTest("Blob");
|
|
|
338
360
|
*
|
|
339
361
|
* @returns {boolean} True if value is a File, otherwise false
|
|
340
362
|
*/
|
|
341
|
-
const isFileList = kindOfTest(
|
|
363
|
+
const isFileList = kindOfTest('FileList');
|
|
342
364
|
|
|
343
365
|
/**
|
|
344
366
|
* Determine if a value is a Stream
|
|
@@ -356,18 +378,28 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
|
356
378
|
*
|
|
357
379
|
* @returns {boolean} True if value is an FormData, otherwise false
|
|
358
380
|
*/
|
|
381
|
+
function getGlobal() {
|
|
382
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
383
|
+
if (typeof self !== 'undefined') return self;
|
|
384
|
+
if (typeof window !== 'undefined') return window;
|
|
385
|
+
if (typeof global !== 'undefined') return global;
|
|
386
|
+
return {};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const G = getGlobal();
|
|
390
|
+
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
391
|
+
|
|
359
392
|
const isFormData = (thing) => {
|
|
360
|
-
|
|
361
|
-
return
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
);
|
|
393
|
+
if (!thing) return false;
|
|
394
|
+
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
395
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
|
|
396
|
+
const proto = getPrototypeOf(thing);
|
|
397
|
+
if (!proto || proto === Object.prototype) return false;
|
|
398
|
+
if (!isFunction$1(thing.append)) return false;
|
|
399
|
+
const kind = kindOf(thing);
|
|
400
|
+
return kind === 'formdata' ||
|
|
401
|
+
// detect form-data instance
|
|
402
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]');
|
|
371
403
|
};
|
|
372
404
|
|
|
373
405
|
/**
|
|
@@ -377,13 +409,13 @@ const isFormData = (thing) => {
|
|
|
377
409
|
*
|
|
378
410
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
379
411
|
*/
|
|
380
|
-
const isURLSearchParams = kindOfTest(
|
|
412
|
+
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
381
413
|
|
|
382
414
|
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
415
|
+
'ReadableStream',
|
|
416
|
+
'Request',
|
|
417
|
+
'Response',
|
|
418
|
+
'Headers',
|
|
387
419
|
].map(kindOfTest);
|
|
388
420
|
|
|
389
421
|
/**
|
|
@@ -393,9 +425,9 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
|
393
425
|
*
|
|
394
426
|
* @returns {String} The String freed of excess whitespace
|
|
395
427
|
*/
|
|
396
|
-
const trim = (str) =>
|
|
397
|
-
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
398
|
-
|
|
428
|
+
const trim = (str) => {
|
|
429
|
+
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
430
|
+
};
|
|
399
431
|
/**
|
|
400
432
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
401
433
|
*
|
|
@@ -414,7 +446,7 @@ const trim = (str) =>
|
|
|
414
446
|
*/
|
|
415
447
|
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
416
448
|
// Don't bother if no value provided
|
|
417
|
-
if (obj === null || typeof obj ===
|
|
449
|
+
if (obj === null || typeof obj === 'undefined') {
|
|
418
450
|
return;
|
|
419
451
|
}
|
|
420
452
|
|
|
@@ -422,7 +454,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
422
454
|
let l;
|
|
423
455
|
|
|
424
456
|
// Force an array if not already something iterable
|
|
425
|
-
if (typeof obj !==
|
|
457
|
+
if (typeof obj !== 'object') {
|
|
426
458
|
/*eslint no-param-reassign:0*/
|
|
427
459
|
obj = [obj];
|
|
428
460
|
}
|
|
@@ -439,9 +471,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
439
471
|
}
|
|
440
472
|
|
|
441
473
|
// Iterate over object keys
|
|
442
|
-
const keys = allOwnKeys
|
|
443
|
-
? Object.getOwnPropertyNames(obj)
|
|
444
|
-
: Object.keys(obj);
|
|
474
|
+
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
445
475
|
const len = keys.length;
|
|
446
476
|
let key;
|
|
447
477
|
|
|
@@ -452,6 +482,14 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
452
482
|
}
|
|
453
483
|
}
|
|
454
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Finds a key in an object, case-insensitive, returning the actual key name.
|
|
487
|
+
* Returns null if the object is a Buffer or if no match is found.
|
|
488
|
+
*
|
|
489
|
+
* @param {Object} obj - The object to search.
|
|
490
|
+
* @param {string} key - The key to find (case-insensitive).
|
|
491
|
+
* @returns {?string} The actual key name if found, otherwise null.
|
|
492
|
+
*/
|
|
455
493
|
function findKey(obj, key) {
|
|
456
494
|
if (isBuffer(obj)) {
|
|
457
495
|
return null;
|
|
@@ -472,16 +510,11 @@ function findKey(obj, key) {
|
|
|
472
510
|
|
|
473
511
|
const _global = (() => {
|
|
474
512
|
/*eslint no-undef:0*/
|
|
475
|
-
if (typeof globalThis !==
|
|
476
|
-
return typeof self !==
|
|
477
|
-
? self
|
|
478
|
-
: typeof window !== "undefined"
|
|
479
|
-
? window
|
|
480
|
-
: global;
|
|
513
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
514
|
+
return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
|
|
481
515
|
})();
|
|
482
516
|
|
|
483
|
-
const isContextDefined = (context) =>
|
|
484
|
-
!isUndefined(context) && context !== _global;
|
|
517
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
485
518
|
|
|
486
519
|
/**
|
|
487
520
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -506,7 +539,7 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
506
539
|
const result = {};
|
|
507
540
|
const assignValue = (val, key) => {
|
|
508
541
|
// Skip dangerous property names to prevent prototype pollution
|
|
509
|
-
if (key ===
|
|
542
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
510
543
|
return;
|
|
511
544
|
}
|
|
512
545
|
|
|
@@ -559,7 +592,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
559
592
|
});
|
|
560
593
|
}
|
|
561
594
|
},
|
|
562
|
-
{ allOwnKeys }
|
|
595
|
+
{ allOwnKeys }
|
|
563
596
|
);
|
|
564
597
|
return a;
|
|
565
598
|
};
|
|
@@ -588,17 +621,14 @@ const stripBOM = (content) => {
|
|
|
588
621
|
* @returns {void}
|
|
589
622
|
*/
|
|
590
623
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
591
|
-
constructor.prototype = Object.create(
|
|
592
|
-
|
|
593
|
-
descriptors,
|
|
594
|
-
);
|
|
595
|
-
Object.defineProperty(constructor.prototype, "constructor", {
|
|
624
|
+
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
625
|
+
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
596
626
|
value: constructor,
|
|
597
627
|
writable: true,
|
|
598
628
|
enumerable: false,
|
|
599
629
|
configurable: true,
|
|
600
630
|
});
|
|
601
|
-
Object.defineProperty(constructor,
|
|
631
|
+
Object.defineProperty(constructor, 'super', {
|
|
602
632
|
value: superConstructor.prototype,
|
|
603
633
|
});
|
|
604
634
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -628,20 +658,13 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
|
628
658
|
i = props.length;
|
|
629
659
|
while (i-- > 0) {
|
|
630
660
|
prop = props[i];
|
|
631
|
-
if (
|
|
632
|
-
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
633
|
-
!merged[prop]
|
|
634
|
-
) {
|
|
661
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
635
662
|
destObj[prop] = sourceObj[prop];
|
|
636
663
|
merged[prop] = true;
|
|
637
664
|
}
|
|
638
665
|
}
|
|
639
666
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
640
|
-
} while (
|
|
641
|
-
sourceObj &&
|
|
642
|
-
(!filter || filter(sourceObj, destObj)) &&
|
|
643
|
-
sourceObj !== Object.prototype
|
|
644
|
-
);
|
|
667
|
+
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
645
668
|
|
|
646
669
|
return destObj;
|
|
647
670
|
};
|
|
@@ -698,7 +721,7 @@ const isTypedArray = ((TypedArray) => {
|
|
|
698
721
|
return (thing) => {
|
|
699
722
|
return TypedArray && thing instanceof TypedArray;
|
|
700
723
|
};
|
|
701
|
-
})(typeof Uint8Array !==
|
|
724
|
+
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
|
702
725
|
|
|
703
726
|
/**
|
|
704
727
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -741,14 +764,12 @@ const matchAll = (regExp, str) => {
|
|
|
741
764
|
};
|
|
742
765
|
|
|
743
766
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
744
|
-
const isHTMLForm = kindOfTest(
|
|
767
|
+
const isHTMLForm = kindOfTest('HTMLFormElement');
|
|
745
768
|
|
|
746
769
|
const toCamelCase = (str) => {
|
|
747
|
-
return str
|
|
748
|
-
.
|
|
749
|
-
|
|
750
|
-
return p1.toUpperCase() + p2;
|
|
751
|
-
});
|
|
770
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
771
|
+
return p1.toUpperCase() + p2;
|
|
772
|
+
});
|
|
752
773
|
};
|
|
753
774
|
|
|
754
775
|
/* Creating a function that will check if an object has a property. */
|
|
@@ -765,7 +786,7 @@ const hasOwnProperty = (
|
|
|
765
786
|
*
|
|
766
787
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
767
788
|
*/
|
|
768
|
-
const isRegExp = kindOfTest(
|
|
789
|
+
const isRegExp = kindOfTest('RegExp');
|
|
769
790
|
|
|
770
791
|
const reduceDescriptors = (obj, reducer) => {
|
|
771
792
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -789,10 +810,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
789
810
|
const freezeMethods = (obj) => {
|
|
790
811
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
791
812
|
// skip restricted props in strict mode
|
|
792
|
-
if (
|
|
793
|
-
isFunction$1(obj) &&
|
|
794
|
-
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
795
|
-
) {
|
|
813
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
|
796
814
|
return false;
|
|
797
815
|
}
|
|
798
816
|
|
|
@@ -802,7 +820,7 @@ const freezeMethods = (obj) => {
|
|
|
802
820
|
|
|
803
821
|
descriptor.enumerable = false;
|
|
804
822
|
|
|
805
|
-
if (
|
|
823
|
+
if ('writable' in descriptor) {
|
|
806
824
|
descriptor.writable = false;
|
|
807
825
|
return;
|
|
808
826
|
}
|
|
@@ -815,6 +833,14 @@ const freezeMethods = (obj) => {
|
|
|
815
833
|
});
|
|
816
834
|
};
|
|
817
835
|
|
|
836
|
+
/**
|
|
837
|
+
* Converts an array or a delimited string into an object set with values as keys and true as values.
|
|
838
|
+
* Useful for fast membership checks.
|
|
839
|
+
*
|
|
840
|
+
* @param {Array|string} arrayOrString - The array or string to convert.
|
|
841
|
+
* @param {string} delimiter - The delimiter to use if input is a string.
|
|
842
|
+
* @returns {Object} An object with keys from the array or string, values set to true.
|
|
843
|
+
*/
|
|
818
844
|
const toObjectSet = (arrayOrString, delimiter) => {
|
|
819
845
|
const obj = {};
|
|
820
846
|
|
|
@@ -824,9 +850,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
824
850
|
});
|
|
825
851
|
};
|
|
826
852
|
|
|
827
|
-
isArray(arrayOrString)
|
|
828
|
-
? define(arrayOrString)
|
|
829
|
-
: define(String(arrayOrString).split(delimiter));
|
|
853
|
+
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
830
854
|
|
|
831
855
|
return obj;
|
|
832
856
|
};
|
|
@@ -834,9 +858,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
834
858
|
const noop = () => {};
|
|
835
859
|
|
|
836
860
|
const toFiniteNumber = (value, defaultValue) => {
|
|
837
|
-
return value != null && Number.isFinite((value = +value))
|
|
838
|
-
? value
|
|
839
|
-
: defaultValue;
|
|
861
|
+
return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
|
|
840
862
|
};
|
|
841
863
|
|
|
842
864
|
/**
|
|
@@ -850,11 +872,17 @@ function isSpecCompliantForm(thing) {
|
|
|
850
872
|
return !!(
|
|
851
873
|
thing &&
|
|
852
874
|
isFunction$1(thing.append) &&
|
|
853
|
-
thing[toStringTag] ===
|
|
875
|
+
thing[toStringTag] === 'FormData' &&
|
|
854
876
|
thing[iterator]
|
|
855
877
|
);
|
|
856
878
|
}
|
|
857
879
|
|
|
880
|
+
/**
|
|
881
|
+
* Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
|
|
882
|
+
*
|
|
883
|
+
* @param {Object} obj - The object to convert.
|
|
884
|
+
* @returns {Object} The JSON-compatible object.
|
|
885
|
+
*/
|
|
858
886
|
const toJSONObject = (obj) => {
|
|
859
887
|
const stack = new Array(10);
|
|
860
888
|
|
|
@@ -869,7 +897,7 @@ const toJSONObject = (obj) => {
|
|
|
869
897
|
return source;
|
|
870
898
|
}
|
|
871
899
|
|
|
872
|
-
if (!(
|
|
900
|
+
if (!('toJSON' in source)) {
|
|
873
901
|
stack[i] = source;
|
|
874
902
|
const target = isArray(source) ? [] : {};
|
|
875
903
|
|
|
@@ -890,8 +918,20 @@ const toJSONObject = (obj) => {
|
|
|
890
918
|
return visit(obj, 0);
|
|
891
919
|
};
|
|
892
920
|
|
|
893
|
-
|
|
921
|
+
/**
|
|
922
|
+
* Determines if a value is an async function.
|
|
923
|
+
*
|
|
924
|
+
* @param {*} thing - The value to test.
|
|
925
|
+
* @returns {boolean} True if value is an async function, otherwise false.
|
|
926
|
+
*/
|
|
927
|
+
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
894
928
|
|
|
929
|
+
/**
|
|
930
|
+
* Determines if a value is thenable (has then and catch methods).
|
|
931
|
+
*
|
|
932
|
+
* @param {*} thing - The value to test.
|
|
933
|
+
* @returns {boolean} True if value is thenable, otherwise false.
|
|
934
|
+
*/
|
|
895
935
|
const isThenable = (thing) =>
|
|
896
936
|
thing &&
|
|
897
937
|
(isObject(thing) || isFunction$1(thing)) &&
|
|
@@ -901,6 +941,14 @@ const isThenable = (thing) =>
|
|
|
901
941
|
// original code
|
|
902
942
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
903
943
|
|
|
944
|
+
/**
|
|
945
|
+
* Provides a cross-platform setImmediate implementation.
|
|
946
|
+
* Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
|
|
947
|
+
*
|
|
948
|
+
* @param {boolean} setImmediateSupported - Whether setImmediate is supported.
|
|
949
|
+
* @param {boolean} postMessageSupported - Whether postMessage is supported.
|
|
950
|
+
* @returns {Function} A function to schedule a callback asynchronously.
|
|
951
|
+
*/
|
|
904
952
|
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
905
953
|
if (setImmediateSupported) {
|
|
906
954
|
return setImmediate;
|
|
@@ -909,27 +957,33 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
909
957
|
return postMessageSupported
|
|
910
958
|
? ((token, callbacks) => {
|
|
911
959
|
_global.addEventListener(
|
|
912
|
-
|
|
960
|
+
'message',
|
|
913
961
|
({ source, data }) => {
|
|
914
962
|
if (source === _global && data === token) {
|
|
915
963
|
callbacks.length && callbacks.shift()();
|
|
916
964
|
}
|
|
917
965
|
},
|
|
918
|
-
false
|
|
966
|
+
false
|
|
919
967
|
);
|
|
920
968
|
|
|
921
969
|
return (cb) => {
|
|
922
970
|
callbacks.push(cb);
|
|
923
|
-
_global.postMessage(token,
|
|
971
|
+
_global.postMessage(token, '*');
|
|
924
972
|
};
|
|
925
973
|
})(`axios@${Math.random()}`, [])
|
|
926
974
|
: (cb) => setTimeout(cb);
|
|
927
|
-
})(typeof setImmediate ===
|
|
975
|
+
})(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
|
|
928
976
|
|
|
977
|
+
/**
|
|
978
|
+
* Schedules a microtask or asynchronous callback as soon as possible.
|
|
979
|
+
* Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
|
|
980
|
+
*
|
|
981
|
+
* @type {Function}
|
|
982
|
+
*/
|
|
929
983
|
const asap =
|
|
930
|
-
typeof queueMicrotask !==
|
|
984
|
+
typeof queueMicrotask !== 'undefined'
|
|
931
985
|
? queueMicrotask.bind(_global)
|
|
932
|
-
: (typeof process !==
|
|
986
|
+
: (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
|
|
933
987
|
|
|
934
988
|
// *********************
|
|
935
989
|
|
|
@@ -954,6 +1008,8 @@ var utils$1 = {
|
|
|
954
1008
|
isUndefined,
|
|
955
1009
|
isDate,
|
|
956
1010
|
isFile,
|
|
1011
|
+
isReactNativeBlob,
|
|
1012
|
+
isReactNative,
|
|
957
1013
|
isBlob,
|
|
958
1014
|
isRegExp,
|
|
959
1015
|
isFunction: isFunction$1,
|
|
@@ -996,57 +1052,74 @@ var utils$1 = {
|
|
|
996
1052
|
};
|
|
997
1053
|
|
|
998
1054
|
let AxiosError$1 = class AxiosError extends Error {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
customProps && Object.assign(axiosError, customProps);
|
|
1004
|
-
return axiosError;
|
|
1005
|
-
}
|
|
1055
|
+
static from(error, code, config, request, response, customProps) {
|
|
1056
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1057
|
+
axiosError.cause = error;
|
|
1058
|
+
axiosError.name = error.name;
|
|
1006
1059
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
* @param {string} message The error message.
|
|
1011
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1012
|
-
* @param {Object} [config] The config.
|
|
1013
|
-
* @param {Object} [request] The request.
|
|
1014
|
-
* @param {Object} [response] The response.
|
|
1015
|
-
*
|
|
1016
|
-
* @returns {Error} The created error.
|
|
1017
|
-
*/
|
|
1018
|
-
constructor(message, code, config, request, response) {
|
|
1019
|
-
super(message);
|
|
1020
|
-
this.name = 'AxiosError';
|
|
1021
|
-
this.isAxiosError = true;
|
|
1022
|
-
code && (this.code = code);
|
|
1023
|
-
config && (this.config = config);
|
|
1024
|
-
request && (this.request = request);
|
|
1025
|
-
if (response) {
|
|
1026
|
-
this.response = response;
|
|
1027
|
-
this.status = response.status;
|
|
1028
|
-
}
|
|
1060
|
+
// Preserve status from the original error if not already set from response
|
|
1061
|
+
if (error.status != null && axiosError.status == null) {
|
|
1062
|
+
axiosError.status = error.status;
|
|
1029
1063
|
}
|
|
1030
1064
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1065
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1066
|
+
return axiosError;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1071
|
+
*
|
|
1072
|
+
* @param {string} message The error message.
|
|
1073
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1074
|
+
* @param {Object} [config] The config.
|
|
1075
|
+
* @param {Object} [request] The request.
|
|
1076
|
+
* @param {Object} [response] The response.
|
|
1077
|
+
*
|
|
1078
|
+
* @returns {Error} The created error.
|
|
1079
|
+
*/
|
|
1080
|
+
constructor(message, code, config, request, response) {
|
|
1081
|
+
super(message);
|
|
1082
|
+
|
|
1083
|
+
// Make message enumerable to maintain backward compatibility
|
|
1084
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1085
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1086
|
+
Object.defineProperty(this, 'message', {
|
|
1087
|
+
value: message,
|
|
1088
|
+
enumerable: true,
|
|
1089
|
+
writable: true,
|
|
1090
|
+
configurable: true,
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
this.name = 'AxiosError';
|
|
1094
|
+
this.isAxiosError = true;
|
|
1095
|
+
code && (this.code = code);
|
|
1096
|
+
config && (this.config = config);
|
|
1097
|
+
request && (this.request = request);
|
|
1098
|
+
if (response) {
|
|
1099
|
+
this.response = response;
|
|
1100
|
+
this.status = response.status;
|
|
1049
1101
|
}
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
toJSON() {
|
|
1105
|
+
return {
|
|
1106
|
+
// Standard
|
|
1107
|
+
message: this.message,
|
|
1108
|
+
name: this.name,
|
|
1109
|
+
// Microsoft
|
|
1110
|
+
description: this.description,
|
|
1111
|
+
number: this.number,
|
|
1112
|
+
// Mozilla
|
|
1113
|
+
fileName: this.fileName,
|
|
1114
|
+
lineNumber: this.lineNumber,
|
|
1115
|
+
columnNumber: this.columnNumber,
|
|
1116
|
+
stack: this.stack,
|
|
1117
|
+
// Axios
|
|
1118
|
+
config: utils$1.toJSONObject(this.config),
|
|
1119
|
+
code: this.code,
|
|
1120
|
+
status: this.status,
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1050
1123
|
};
|
|
1051
1124
|
|
|
1052
1125
|
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
@@ -1062,6 +1135,7 @@ AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
|
1062
1135
|
AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
|
|
1063
1136
|
AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1064
1137
|
AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1138
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1065
1139
|
|
|
1066
1140
|
// eslint-disable-next-line strict
|
|
1067
1141
|
var httpAdapter = null;
|
|
@@ -1099,11 +1173,14 @@ function removeBrackets(key) {
|
|
|
1099
1173
|
*/
|
|
1100
1174
|
function renderKey(path, key, dots) {
|
|
1101
1175
|
if (!path) return key;
|
|
1102
|
-
return path
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1176
|
+
return path
|
|
1177
|
+
.concat(key)
|
|
1178
|
+
.map(function each(token, i) {
|
|
1179
|
+
// eslint-disable-next-line no-param-reassign
|
|
1180
|
+
token = removeBrackets(token);
|
|
1181
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1182
|
+
})
|
|
1183
|
+
.join(dots ? '.' : '');
|
|
1107
1184
|
}
|
|
1108
1185
|
|
|
1109
1186
|
/**
|
|
@@ -1153,21 +1230,27 @@ function toFormData$1(obj, formData, options) {
|
|
|
1153
1230
|
formData = formData || new (FormData)();
|
|
1154
1231
|
|
|
1155
1232
|
// eslint-disable-next-line no-param-reassign
|
|
1156
|
-
options = utils$1.toFlatObject(
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1233
|
+
options = utils$1.toFlatObject(
|
|
1234
|
+
options,
|
|
1235
|
+
{
|
|
1236
|
+
metaTokens: true,
|
|
1237
|
+
dots: false,
|
|
1238
|
+
indexes: false,
|
|
1239
|
+
},
|
|
1240
|
+
false,
|
|
1241
|
+
function defined(option, source) {
|
|
1242
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1243
|
+
return !utils$1.isUndefined(source[option]);
|
|
1244
|
+
}
|
|
1245
|
+
);
|
|
1164
1246
|
|
|
1165
1247
|
const metaTokens = options.metaTokens;
|
|
1166
1248
|
// eslint-disable-next-line no-use-before-define
|
|
1167
1249
|
const visitor = options.visitor || defaultVisitor;
|
|
1168
1250
|
const dots = options.dots;
|
|
1169
1251
|
const indexes = options.indexes;
|
|
1170
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1252
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1253
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1171
1254
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1172
1255
|
|
|
1173
1256
|
if (!utils$1.isFunction(visitor)) {
|
|
@@ -1209,6 +1292,11 @@ function toFormData$1(obj, formData, options) {
|
|
|
1209
1292
|
function defaultVisitor(value, key, path) {
|
|
1210
1293
|
let arr = value;
|
|
1211
1294
|
|
|
1295
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
1296
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1297
|
+
return false;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1212
1300
|
if (value && !path && typeof value === 'object') {
|
|
1213
1301
|
if (utils$1.endsWith(key, '{}')) {
|
|
1214
1302
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -1217,17 +1305,22 @@ function toFormData$1(obj, formData, options) {
|
|
|
1217
1305
|
value = JSON.stringify(value);
|
|
1218
1306
|
} else if (
|
|
1219
1307
|
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1220
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1221
|
-
|
|
1308
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1309
|
+
) {
|
|
1222
1310
|
// eslint-disable-next-line no-param-reassign
|
|
1223
1311
|
key = removeBrackets(key);
|
|
1224
1312
|
|
|
1225
1313
|
arr.forEach(function each(el, index) {
|
|
1226
|
-
!(utils$1.isUndefined(el) || el === null) &&
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1314
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1315
|
+
formData.append(
|
|
1316
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1317
|
+
indexes === true
|
|
1318
|
+
? renderKey([key], index, dots)
|
|
1319
|
+
: indexes === null
|
|
1320
|
+
? key
|
|
1321
|
+
: key + '[]',
|
|
1322
|
+
convertValue(el)
|
|
1323
|
+
);
|
|
1231
1324
|
});
|
|
1232
1325
|
return false;
|
|
1233
1326
|
}
|
|
@@ -1247,12 +1340,19 @@ function toFormData$1(obj, formData, options) {
|
|
|
1247
1340
|
const exposedHelpers = Object.assign(predicates, {
|
|
1248
1341
|
defaultVisitor,
|
|
1249
1342
|
convertValue,
|
|
1250
|
-
isVisitable
|
|
1343
|
+
isVisitable,
|
|
1251
1344
|
});
|
|
1252
1345
|
|
|
1253
|
-
function build(value, path) {
|
|
1346
|
+
function build(value, path, depth = 0) {
|
|
1254
1347
|
if (utils$1.isUndefined(value)) return;
|
|
1255
1348
|
|
|
1349
|
+
if (depth > maxDepth) {
|
|
1350
|
+
throw new AxiosError$1(
|
|
1351
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1352
|
+
AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1256
1356
|
if (stack.indexOf(value) !== -1) {
|
|
1257
1357
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1258
1358
|
}
|
|
@@ -1260,12 +1360,12 @@ function toFormData$1(obj, formData, options) {
|
|
|
1260
1360
|
stack.push(value);
|
|
1261
1361
|
|
|
1262
1362
|
utils$1.forEach(value, function each(el, key) {
|
|
1263
|
-
const result =
|
|
1264
|
-
|
|
1265
|
-
|
|
1363
|
+
const result =
|
|
1364
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1365
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1266
1366
|
|
|
1267
1367
|
if (result === true) {
|
|
1268
|
-
build(el, path ? path.concat(key) : [key]);
|
|
1368
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
1269
1369
|
}
|
|
1270
1370
|
});
|
|
1271
1371
|
|
|
@@ -1297,9 +1397,8 @@ function encode$1(str) {
|
|
|
1297
1397
|
')': '%29',
|
|
1298
1398
|
'~': '%7E',
|
|
1299
1399
|
'%20': '+',
|
|
1300
|
-
'%00': '\x00'
|
|
1301
1400
|
};
|
|
1302
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20
|
|
1401
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1303
1402
|
return charMap[match];
|
|
1304
1403
|
});
|
|
1305
1404
|
}
|
|
@@ -1325,29 +1424,33 @@ prototype.append = function append(name, value) {
|
|
|
1325
1424
|
};
|
|
1326
1425
|
|
|
1327
1426
|
prototype.toString = function toString(encoder) {
|
|
1328
|
-
const _encode = encoder
|
|
1329
|
-
|
|
1330
|
-
|
|
1427
|
+
const _encode = encoder
|
|
1428
|
+
? function (value) {
|
|
1429
|
+
return encoder.call(this, value, encode$1);
|
|
1430
|
+
}
|
|
1431
|
+
: encode$1;
|
|
1331
1432
|
|
|
1332
|
-
return this._pairs
|
|
1333
|
-
|
|
1334
|
-
|
|
1433
|
+
return this._pairs
|
|
1434
|
+
.map(function each(pair) {
|
|
1435
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1436
|
+
}, '')
|
|
1437
|
+
.join('&');
|
|
1335
1438
|
};
|
|
1336
1439
|
|
|
1337
1440
|
/**
|
|
1338
|
-
* It replaces
|
|
1339
|
-
*
|
|
1441
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1442
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1340
1443
|
*
|
|
1341
1444
|
* @param {string} val The value to be encoded.
|
|
1342
1445
|
*
|
|
1343
1446
|
* @returns {string} The encoded value.
|
|
1344
1447
|
*/
|
|
1345
1448
|
function encode(val) {
|
|
1346
|
-
return encodeURIComponent(val)
|
|
1347
|
-
replace(/%3A/gi, ':')
|
|
1348
|
-
replace(/%24/g, '$')
|
|
1349
|
-
replace(/%2C/gi, ',')
|
|
1350
|
-
replace(/%20/g, '+');
|
|
1449
|
+
return encodeURIComponent(val)
|
|
1450
|
+
.replace(/%3A/gi, ':')
|
|
1451
|
+
.replace(/%24/g, '$')
|
|
1452
|
+
.replace(/%2C/gi, ',')
|
|
1453
|
+
.replace(/%20/g, '+');
|
|
1351
1454
|
}
|
|
1352
1455
|
|
|
1353
1456
|
/**
|
|
@@ -1364,11 +1467,13 @@ function buildURL(url, params, options) {
|
|
|
1364
1467
|
return url;
|
|
1365
1468
|
}
|
|
1366
1469
|
|
|
1367
|
-
const _encode = options && options.encode || encode;
|
|
1470
|
+
const _encode = (options && options.encode) || encode;
|
|
1368
1471
|
|
|
1369
|
-
const _options = utils$1.isFunction(options)
|
|
1370
|
-
|
|
1371
|
-
|
|
1472
|
+
const _options = utils$1.isFunction(options)
|
|
1473
|
+
? {
|
|
1474
|
+
serialize: options,
|
|
1475
|
+
}
|
|
1476
|
+
: options;
|
|
1372
1477
|
|
|
1373
1478
|
const serializeFn = _options && _options.serialize;
|
|
1374
1479
|
|
|
@@ -1377,13 +1482,13 @@ function buildURL(url, params, options) {
|
|
|
1377
1482
|
if (serializeFn) {
|
|
1378
1483
|
serializedParams = serializeFn(params, _options);
|
|
1379
1484
|
} else {
|
|
1380
|
-
serializedParams = utils$1.isURLSearchParams(params)
|
|
1381
|
-
params.toString()
|
|
1382
|
-
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1485
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
1486
|
+
? params.toString()
|
|
1487
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1383
1488
|
}
|
|
1384
1489
|
|
|
1385
1490
|
if (serializedParams) {
|
|
1386
|
-
const hashmarkIndex = url.indexOf(
|
|
1491
|
+
const hashmarkIndex = url.indexOf('#');
|
|
1387
1492
|
|
|
1388
1493
|
if (hashmarkIndex !== -1) {
|
|
1389
1494
|
url = url.slice(0, hashmarkIndex);
|
|
@@ -1413,7 +1518,7 @@ class InterceptorManager {
|
|
|
1413
1518
|
fulfilled,
|
|
1414
1519
|
rejected,
|
|
1415
1520
|
synchronous: options ? options.synchronous : false,
|
|
1416
|
-
runWhen: options ? options.runWhen : null
|
|
1521
|
+
runWhen: options ? options.runWhen : null,
|
|
1417
1522
|
});
|
|
1418
1523
|
return this.handlers.length - 1;
|
|
1419
1524
|
}
|
|
@@ -1465,7 +1570,7 @@ var transitionalDefaults = {
|
|
|
1465
1570
|
silentJSONParsing: true,
|
|
1466
1571
|
forcedJSONParsing: true,
|
|
1467
1572
|
clarifyTimeoutError: false,
|
|
1468
|
-
legacyInterceptorReqResOrdering: true
|
|
1573
|
+
legacyInterceptorReqResOrdering: true,
|
|
1469
1574
|
};
|
|
1470
1575
|
|
|
1471
1576
|
var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
@@ -1479,14 +1584,14 @@ var platform$1 = {
|
|
|
1479
1584
|
classes: {
|
|
1480
1585
|
URLSearchParams: URLSearchParams$1,
|
|
1481
1586
|
FormData: FormData$1,
|
|
1482
|
-
Blob: Blob$1
|
|
1587
|
+
Blob: Blob$1,
|
|
1483
1588
|
},
|
|
1484
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1589
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
1485
1590
|
};
|
|
1486
1591
|
|
|
1487
1592
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1488
1593
|
|
|
1489
|
-
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
1594
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
1490
1595
|
|
|
1491
1596
|
/**
|
|
1492
1597
|
* Determine if we're running in a standard browser environment
|
|
@@ -1505,7 +1610,8 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
|
1505
1610
|
*
|
|
1506
1611
|
* @returns {boolean}
|
|
1507
1612
|
*/
|
|
1508
|
-
const hasStandardBrowserEnv =
|
|
1613
|
+
const hasStandardBrowserEnv =
|
|
1614
|
+
hasBrowserEnv &&
|
|
1509
1615
|
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1510
1616
|
|
|
1511
1617
|
/**
|
|
@@ -1526,7 +1632,7 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
1526
1632
|
);
|
|
1527
1633
|
})();
|
|
1528
1634
|
|
|
1529
|
-
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1635
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
1530
1636
|
|
|
1531
1637
|
var utils = /*#__PURE__*/Object.freeze({
|
|
1532
1638
|
__proto__: null,
|
|
@@ -1539,12 +1645,12 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
1539
1645
|
|
|
1540
1646
|
var platform = {
|
|
1541
1647
|
...utils,
|
|
1542
|
-
...platform$1
|
|
1648
|
+
...platform$1,
|
|
1543
1649
|
};
|
|
1544
1650
|
|
|
1545
1651
|
function toURLEncodedForm(data, options) {
|
|
1546
1652
|
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
1547
|
-
visitor: function(value, key, path, helpers) {
|
|
1653
|
+
visitor: function (value, key, path, helpers) {
|
|
1548
1654
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1549
1655
|
this.append(key, value.toString('base64'));
|
|
1550
1656
|
return false;
|
|
@@ -1552,7 +1658,7 @@ function toURLEncodedForm(data, options) {
|
|
|
1552
1658
|
|
|
1553
1659
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
1554
1660
|
},
|
|
1555
|
-
...options
|
|
1661
|
+
...options,
|
|
1556
1662
|
});
|
|
1557
1663
|
}
|
|
1558
1664
|
|
|
@@ -1568,7 +1674,7 @@ function parsePropPath(name) {
|
|
|
1568
1674
|
// foo.x.y.z
|
|
1569
1675
|
// foo-x-y-z
|
|
1570
1676
|
// foo x y z
|
|
1571
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1677
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
1572
1678
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1573
1679
|
});
|
|
1574
1680
|
}
|
|
@@ -1612,7 +1718,9 @@ function formDataToJSON(formData) {
|
|
|
1612
1718
|
|
|
1613
1719
|
if (isLast) {
|
|
1614
1720
|
if (utils$1.hasOwnProp(target, name)) {
|
|
1615
|
-
target[name] =
|
|
1721
|
+
target[name] = utils$1.isArray(target[name])
|
|
1722
|
+
? target[name].concat(value)
|
|
1723
|
+
: [target[name], value];
|
|
1616
1724
|
} else {
|
|
1617
1725
|
target[name] = value;
|
|
1618
1726
|
}
|
|
@@ -1646,6 +1754,8 @@ function formDataToJSON(formData) {
|
|
|
1646
1754
|
return null;
|
|
1647
1755
|
}
|
|
1648
1756
|
|
|
1757
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
1758
|
+
|
|
1649
1759
|
/**
|
|
1650
1760
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1651
1761
|
* of the input
|
|
@@ -1672,96 +1782,110 @@ function stringifySafely(rawValue, parser, encoder) {
|
|
|
1672
1782
|
}
|
|
1673
1783
|
|
|
1674
1784
|
const defaults = {
|
|
1675
|
-
|
|
1676
1785
|
transitional: transitionalDefaults,
|
|
1677
1786
|
|
|
1678
1787
|
adapter: ['xhr', 'http', 'fetch'],
|
|
1679
1788
|
|
|
1680
|
-
transformRequest: [
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1686
|
-
data = new FormData(data);
|
|
1687
|
-
}
|
|
1789
|
+
transformRequest: [
|
|
1790
|
+
function transformRequest(data, headers) {
|
|
1791
|
+
const contentType = headers.getContentType() || '';
|
|
1792
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1793
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1688
1794
|
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1693
|
-
}
|
|
1795
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1796
|
+
data = new FormData(data);
|
|
1797
|
+
}
|
|
1694
1798
|
|
|
1695
|
-
|
|
1696
|
-
utils$1.isBuffer(data) ||
|
|
1697
|
-
utils$1.isStream(data) ||
|
|
1698
|
-
utils$1.isFile(data) ||
|
|
1699
|
-
utils$1.isBlob(data) ||
|
|
1700
|
-
utils$1.isReadableStream(data)
|
|
1701
|
-
) {
|
|
1702
|
-
return data;
|
|
1703
|
-
}
|
|
1704
|
-
if (utils$1.isArrayBufferView(data)) {
|
|
1705
|
-
return data.buffer;
|
|
1706
|
-
}
|
|
1707
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
1708
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1709
|
-
return data.toString();
|
|
1710
|
-
}
|
|
1799
|
+
const isFormData = utils$1.isFormData(data);
|
|
1711
1800
|
|
|
1712
|
-
|
|
1801
|
+
if (isFormData) {
|
|
1802
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1803
|
+
}
|
|
1713
1804
|
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1805
|
+
if (
|
|
1806
|
+
utils$1.isArrayBuffer(data) ||
|
|
1807
|
+
utils$1.isBuffer(data) ||
|
|
1808
|
+
utils$1.isStream(data) ||
|
|
1809
|
+
utils$1.isFile(data) ||
|
|
1810
|
+
utils$1.isBlob(data) ||
|
|
1811
|
+
utils$1.isReadableStream(data)
|
|
1812
|
+
) {
|
|
1813
|
+
return data;
|
|
1814
|
+
}
|
|
1815
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
1816
|
+
return data.buffer;
|
|
1817
|
+
}
|
|
1818
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
1819
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1820
|
+
return data.toString();
|
|
1717
1821
|
}
|
|
1718
1822
|
|
|
1719
|
-
|
|
1720
|
-
const _FormData = this.env && this.env.FormData;
|
|
1823
|
+
let isFileList;
|
|
1721
1824
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1825
|
+
if (isObjectPayload) {
|
|
1826
|
+
const formSerializer = own(this, 'formSerializer');
|
|
1827
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1828
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
if (
|
|
1832
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
1833
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
1834
|
+
) {
|
|
1835
|
+
const env = own(this, 'env');
|
|
1836
|
+
const _FormData = env && env.FormData;
|
|
1837
|
+
|
|
1838
|
+
return toFormData$1(
|
|
1839
|
+
isFileList ? { 'files[]': data } : data,
|
|
1840
|
+
_FormData && new _FormData(),
|
|
1841
|
+
formSerializer
|
|
1842
|
+
);
|
|
1843
|
+
}
|
|
1727
1844
|
}
|
|
1728
|
-
}
|
|
1729
1845
|
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1846
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
1847
|
+
headers.setContentType('application/json', false);
|
|
1848
|
+
return stringifySafely(data);
|
|
1849
|
+
}
|
|
1734
1850
|
|
|
1735
|
-
|
|
1736
|
-
|
|
1851
|
+
return data;
|
|
1852
|
+
},
|
|
1853
|
+
],
|
|
1737
1854
|
|
|
1738
|
-
transformResponse: [
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1855
|
+
transformResponse: [
|
|
1856
|
+
function transformResponse(data) {
|
|
1857
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
1858
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1859
|
+
const responseType = own(this, 'responseType');
|
|
1860
|
+
const JSONRequested = responseType === 'json';
|
|
1742
1861
|
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1862
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
1863
|
+
return data;
|
|
1864
|
+
}
|
|
1746
1865
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1866
|
+
if (
|
|
1867
|
+
data &&
|
|
1868
|
+
utils$1.isString(data) &&
|
|
1869
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
1870
|
+
) {
|
|
1871
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1872
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1750
1873
|
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1874
|
+
try {
|
|
1875
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
1876
|
+
} catch (e) {
|
|
1877
|
+
if (strictJSONParsing) {
|
|
1878
|
+
if (e.name === 'SyntaxError') {
|
|
1879
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
1880
|
+
}
|
|
1881
|
+
throw e;
|
|
1757
1882
|
}
|
|
1758
|
-
throw e;
|
|
1759
1883
|
}
|
|
1760
1884
|
}
|
|
1761
|
-
}
|
|
1762
1885
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1886
|
+
return data;
|
|
1887
|
+
},
|
|
1888
|
+
],
|
|
1765
1889
|
|
|
1766
1890
|
/**
|
|
1767
1891
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
@@ -1777,7 +1901,7 @@ const defaults = {
|
|
|
1777
1901
|
|
|
1778
1902
|
env: {
|
|
1779
1903
|
FormData: platform.classes.FormData,
|
|
1780
|
-
Blob: platform.classes.Blob
|
|
1904
|
+
Blob: platform.classes.Blob,
|
|
1781
1905
|
},
|
|
1782
1906
|
|
|
1783
1907
|
validateStatus: function validateStatus(status) {
|
|
@@ -1786,10 +1910,10 @@ const defaults = {
|
|
|
1786
1910
|
|
|
1787
1911
|
headers: {
|
|
1788
1912
|
common: {
|
|
1789
|
-
|
|
1790
|
-
'Content-Type': undefined
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1913
|
+
Accept: 'application/json, text/plain, */*',
|
|
1914
|
+
'Content-Type': undefined,
|
|
1915
|
+
},
|
|
1916
|
+
},
|
|
1793
1917
|
};
|
|
1794
1918
|
|
|
1795
1919
|
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
@@ -1799,10 +1923,23 @@ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
|
1799
1923
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1800
1924
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1801
1925
|
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1802
|
-
'age',
|
|
1803
|
-
'
|
|
1804
|
-
'
|
|
1805
|
-
'
|
|
1926
|
+
'age',
|
|
1927
|
+
'authorization',
|
|
1928
|
+
'content-length',
|
|
1929
|
+
'content-type',
|
|
1930
|
+
'etag',
|
|
1931
|
+
'expires',
|
|
1932
|
+
'from',
|
|
1933
|
+
'host',
|
|
1934
|
+
'if-modified-since',
|
|
1935
|
+
'if-unmodified-since',
|
|
1936
|
+
'last-modified',
|
|
1937
|
+
'location',
|
|
1938
|
+
'max-forwards',
|
|
1939
|
+
'proxy-authorization',
|
|
1940
|
+
'referer',
|
|
1941
|
+
'retry-after',
|
|
1942
|
+
'user-agent',
|
|
1806
1943
|
]);
|
|
1807
1944
|
|
|
1808
1945
|
/**
|
|
@@ -1819,47 +1956,81 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
|
1819
1956
|
*
|
|
1820
1957
|
* @returns {Object} Headers parsed into an object
|
|
1821
1958
|
*/
|
|
1822
|
-
var parseHeaders = rawHeaders => {
|
|
1959
|
+
var parseHeaders = (rawHeaders) => {
|
|
1823
1960
|
const parsed = {};
|
|
1824
1961
|
let key;
|
|
1825
1962
|
let val;
|
|
1826
1963
|
let i;
|
|
1827
1964
|
|
|
1828
|
-
rawHeaders &&
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1965
|
+
rawHeaders &&
|
|
1966
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
1967
|
+
i = line.indexOf(':');
|
|
1968
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1969
|
+
val = line.substring(i + 1).trim();
|
|
1832
1970
|
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1971
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1836
1974
|
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1975
|
+
if (key === 'set-cookie') {
|
|
1976
|
+
if (parsed[key]) {
|
|
1977
|
+
parsed[key].push(val);
|
|
1978
|
+
} else {
|
|
1979
|
+
parsed[key] = [val];
|
|
1980
|
+
}
|
|
1840
1981
|
} else {
|
|
1841
|
-
parsed[key] = [val
|
|
1982
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1842
1983
|
}
|
|
1843
|
-
}
|
|
1844
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1845
|
-
}
|
|
1846
|
-
});
|
|
1984
|
+
});
|
|
1847
1985
|
|
|
1848
1986
|
return parsed;
|
|
1849
1987
|
};
|
|
1850
1988
|
|
|
1851
1989
|
const $internals = Symbol('internals');
|
|
1852
1990
|
|
|
1991
|
+
const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
|
|
1992
|
+
|
|
1993
|
+
function trimSPorHTAB(str) {
|
|
1994
|
+
let start = 0;
|
|
1995
|
+
let end = str.length;
|
|
1996
|
+
|
|
1997
|
+
while (start < end) {
|
|
1998
|
+
const code = str.charCodeAt(start);
|
|
1999
|
+
|
|
2000
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2001
|
+
break;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
start += 1;
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
while (end > start) {
|
|
2008
|
+
const code = str.charCodeAt(end - 1);
|
|
2009
|
+
|
|
2010
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
2011
|
+
break;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
end -= 1;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
2018
|
+
}
|
|
2019
|
+
|
|
1853
2020
|
function normalizeHeader(header) {
|
|
1854
2021
|
return header && String(header).trim().toLowerCase();
|
|
1855
2022
|
}
|
|
1856
2023
|
|
|
2024
|
+
function sanitizeHeaderValue(str) {
|
|
2025
|
+
return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
|
|
2026
|
+
}
|
|
2027
|
+
|
|
1857
2028
|
function normalizeValue(value) {
|
|
1858
2029
|
if (value === false || value == null) {
|
|
1859
2030
|
return value;
|
|
1860
2031
|
}
|
|
1861
2032
|
|
|
1862
|
-
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
2033
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
1863
2034
|
}
|
|
1864
2035
|
|
|
1865
2036
|
function parseTokens(str) {
|
|
@@ -1897,8 +2068,10 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
1897
2068
|
}
|
|
1898
2069
|
|
|
1899
2070
|
function formatHeader(header) {
|
|
1900
|
-
return header
|
|
1901
|
-
.
|
|
2071
|
+
return header
|
|
2072
|
+
.trim()
|
|
2073
|
+
.toLowerCase()
|
|
2074
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1902
2075
|
return char.toUpperCase() + str;
|
|
1903
2076
|
});
|
|
1904
2077
|
}
|
|
@@ -1906,12 +2079,12 @@ function formatHeader(header) {
|
|
|
1906
2079
|
function buildAccessors(obj, header) {
|
|
1907
2080
|
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1908
2081
|
|
|
1909
|
-
['get', 'set', 'has'].forEach(methodName => {
|
|
2082
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
1910
2083
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
1911
|
-
value: function(arg1, arg2, arg3) {
|
|
2084
|
+
value: function (arg1, arg2, arg3) {
|
|
1912
2085
|
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1913
2086
|
},
|
|
1914
|
-
configurable: true
|
|
2087
|
+
configurable: true,
|
|
1915
2088
|
});
|
|
1916
2089
|
});
|
|
1917
2090
|
}
|
|
@@ -1933,7 +2106,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
1933
2106
|
|
|
1934
2107
|
const key = utils$1.findKey(self, lHeader);
|
|
1935
2108
|
|
|
1936
|
-
if
|
|
2109
|
+
if (
|
|
2110
|
+
!key ||
|
|
2111
|
+
self[key] === undefined ||
|
|
2112
|
+
_rewrite === true ||
|
|
2113
|
+
(_rewrite === undefined && self[key] !== false)
|
|
2114
|
+
) {
|
|
1937
2115
|
self[key || _header] = normalizeValue(_value);
|
|
1938
2116
|
}
|
|
1939
2117
|
}
|
|
@@ -1943,17 +2121,22 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
1943
2121
|
|
|
1944
2122
|
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1945
2123
|
setHeaders(header, valueOrRewrite);
|
|
1946
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
2124
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1947
2125
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1948
2126
|
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1949
|
-
let obj = {},
|
|
2127
|
+
let obj = {},
|
|
2128
|
+
dest,
|
|
2129
|
+
key;
|
|
1950
2130
|
for (const entry of header) {
|
|
1951
2131
|
if (!utils$1.isArray(entry)) {
|
|
1952
2132
|
throw TypeError('Object iterator must return a key-value pair');
|
|
1953
2133
|
}
|
|
1954
2134
|
|
|
1955
|
-
obj[key = entry[0]] = (dest = obj[key])
|
|
1956
|
-
|
|
2135
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
2136
|
+
? utils$1.isArray(dest)
|
|
2137
|
+
? [...dest, entry[1]]
|
|
2138
|
+
: [dest, entry[1]]
|
|
2139
|
+
: entry[1];
|
|
1957
2140
|
}
|
|
1958
2141
|
|
|
1959
2142
|
setHeaders(obj, valueOrRewrite);
|
|
@@ -2000,7 +2183,11 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2000
2183
|
if (header) {
|
|
2001
2184
|
const key = utils$1.findKey(this, header);
|
|
2002
2185
|
|
|
2003
|
-
return !!(
|
|
2186
|
+
return !!(
|
|
2187
|
+
key &&
|
|
2188
|
+
this[key] !== undefined &&
|
|
2189
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
2190
|
+
);
|
|
2004
2191
|
}
|
|
2005
2192
|
|
|
2006
2193
|
return false;
|
|
@@ -2040,7 +2227,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2040
2227
|
|
|
2041
2228
|
while (i--) {
|
|
2042
2229
|
const key = keys[i];
|
|
2043
|
-
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2230
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
2044
2231
|
delete this[key];
|
|
2045
2232
|
deleted = true;
|
|
2046
2233
|
}
|
|
@@ -2084,7 +2271,9 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2084
2271
|
const obj = Object.create(null);
|
|
2085
2272
|
|
|
2086
2273
|
utils$1.forEach(this, (value, header) => {
|
|
2087
|
-
value != null &&
|
|
2274
|
+
value != null &&
|
|
2275
|
+
value !== false &&
|
|
2276
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
2088
2277
|
});
|
|
2089
2278
|
|
|
2090
2279
|
return obj;
|
|
@@ -2095,11 +2284,13 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2095
2284
|
}
|
|
2096
2285
|
|
|
2097
2286
|
toString() {
|
|
2098
|
-
return Object.entries(this.toJSON())
|
|
2287
|
+
return Object.entries(this.toJSON())
|
|
2288
|
+
.map(([header, value]) => header + ': ' + value)
|
|
2289
|
+
.join('\n');
|
|
2099
2290
|
}
|
|
2100
2291
|
|
|
2101
2292
|
getSetCookie() {
|
|
2102
|
-
return this.get(
|
|
2293
|
+
return this.get('set-cookie') || [];
|
|
2103
2294
|
}
|
|
2104
2295
|
|
|
2105
2296
|
get [Symbol.toStringTag]() {
|
|
@@ -2119,9 +2310,12 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2119
2310
|
}
|
|
2120
2311
|
|
|
2121
2312
|
static accessor(header) {
|
|
2122
|
-
const internals =
|
|
2123
|
-
|
|
2124
|
-
|
|
2313
|
+
const internals =
|
|
2314
|
+
(this[$internals] =
|
|
2315
|
+
this[$internals] =
|
|
2316
|
+
{
|
|
2317
|
+
accessors: {},
|
|
2318
|
+
});
|
|
2125
2319
|
|
|
2126
2320
|
const accessors = internals.accessors;
|
|
2127
2321
|
const prototype = this.prototype;
|
|
@@ -2141,17 +2335,24 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
2141
2335
|
}
|
|
2142
2336
|
};
|
|
2143
2337
|
|
|
2144
|
-
AxiosHeaders$1.accessor([
|
|
2338
|
+
AxiosHeaders$1.accessor([
|
|
2339
|
+
'Content-Type',
|
|
2340
|
+
'Content-Length',
|
|
2341
|
+
'Accept',
|
|
2342
|
+
'Accept-Encoding',
|
|
2343
|
+
'User-Agent',
|
|
2344
|
+
'Authorization',
|
|
2345
|
+
]);
|
|
2145
2346
|
|
|
2146
2347
|
// reserved names hotfix
|
|
2147
|
-
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
|
|
2348
|
+
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
2148
2349
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2149
2350
|
return {
|
|
2150
2351
|
get: () => value,
|
|
2151
2352
|
set(headerValue) {
|
|
2152
2353
|
this[mapped] = headerValue;
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2354
|
+
},
|
|
2355
|
+
};
|
|
2155
2356
|
});
|
|
2156
2357
|
|
|
2157
2358
|
utils$1.freezeMethods(AxiosHeaders$1);
|
|
@@ -2214,19 +2415,23 @@ function settle(resolve, reject, response) {
|
|
|
2214
2415
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
2215
2416
|
resolve(response);
|
|
2216
2417
|
} else {
|
|
2217
|
-
reject(
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2418
|
+
reject(
|
|
2419
|
+
new AxiosError$1(
|
|
2420
|
+
'Request failed with status code ' + response.status,
|
|
2421
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
|
|
2422
|
+
Math.floor(response.status / 100) - 4
|
|
2423
|
+
],
|
|
2424
|
+
response.config,
|
|
2425
|
+
response.request,
|
|
2426
|
+
response
|
|
2427
|
+
)
|
|
2428
|
+
);
|
|
2224
2429
|
}
|
|
2225
2430
|
}
|
|
2226
2431
|
|
|
2227
2432
|
function parseProtocol(url) {
|
|
2228
2433
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
2229
|
-
return match && match[1] || '';
|
|
2434
|
+
return (match && match[1]) || '';
|
|
2230
2435
|
}
|
|
2231
2436
|
|
|
2232
2437
|
/**
|
|
@@ -2277,7 +2482,7 @@ function speedometer(samplesCount, min) {
|
|
|
2277
2482
|
|
|
2278
2483
|
const passed = startedAt && now - startedAt;
|
|
2279
2484
|
|
|
2280
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
2485
|
+
return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
|
|
2281
2486
|
};
|
|
2282
2487
|
}
|
|
2283
2488
|
|
|
@@ -2306,7 +2511,7 @@ function throttle(fn, freq) {
|
|
|
2306
2511
|
const throttled = (...args) => {
|
|
2307
2512
|
const now = Date.now();
|
|
2308
2513
|
const passed = now - timestamp;
|
|
2309
|
-
if (
|
|
2514
|
+
if (passed >= threshold) {
|
|
2310
2515
|
invoke(args, now);
|
|
2311
2516
|
} else {
|
|
2312
2517
|
lastArgs = args;
|
|
@@ -2328,25 +2533,25 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2328
2533
|
let bytesNotified = 0;
|
|
2329
2534
|
const _speedometer = speedometer(50, 250);
|
|
2330
2535
|
|
|
2331
|
-
return throttle(e => {
|
|
2332
|
-
const
|
|
2536
|
+
return throttle((e) => {
|
|
2537
|
+
const rawLoaded = e.loaded;
|
|
2333
2538
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2334
|
-
const
|
|
2539
|
+
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
2540
|
+
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
2335
2541
|
const rate = _speedometer(progressBytes);
|
|
2336
|
-
const inRange = loaded <= total;
|
|
2337
2542
|
|
|
2338
|
-
bytesNotified = loaded;
|
|
2543
|
+
bytesNotified = Math.max(bytesNotified, loaded);
|
|
2339
2544
|
|
|
2340
2545
|
const data = {
|
|
2341
2546
|
loaded,
|
|
2342
2547
|
total,
|
|
2343
|
-
progress: total ?
|
|
2548
|
+
progress: total ? loaded / total : undefined,
|
|
2344
2549
|
bytes: progressBytes,
|
|
2345
2550
|
rate: rate ? rate : undefined,
|
|
2346
|
-
estimated: rate && total
|
|
2551
|
+
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
2347
2552
|
event: e,
|
|
2348
2553
|
lengthComputable: total != null,
|
|
2349
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
|
2554
|
+
[isDownloadStream ? 'download' : 'upload']: true,
|
|
2350
2555
|
};
|
|
2351
2556
|
|
|
2352
2557
|
listener(data);
|
|
@@ -2356,77 +2561,82 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2356
2561
|
const progressEventDecorator = (total, throttled) => {
|
|
2357
2562
|
const lengthComputable = total != null;
|
|
2358
2563
|
|
|
2359
|
-
return [
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2564
|
+
return [
|
|
2565
|
+
(loaded) =>
|
|
2566
|
+
throttled[0]({
|
|
2567
|
+
lengthComputable,
|
|
2568
|
+
total,
|
|
2569
|
+
loaded,
|
|
2570
|
+
}),
|
|
2571
|
+
throttled[1],
|
|
2572
|
+
];
|
|
2364
2573
|
};
|
|
2365
2574
|
|
|
2366
|
-
const asyncDecorator =
|
|
2575
|
+
const asyncDecorator =
|
|
2576
|
+
(fn) =>
|
|
2577
|
+
(...args) =>
|
|
2578
|
+
utils$1.asap(() => fn(...args));
|
|
2367
2579
|
|
|
2368
|
-
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2369
|
-
|
|
2580
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2581
|
+
? ((origin, isMSIE) => (url) => {
|
|
2582
|
+
url = new URL(url, platform.origin);
|
|
2370
2583
|
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
})(
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
)
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
// Standard browser envs support document.cookie
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2584
|
+
return (
|
|
2585
|
+
origin.protocol === url.protocol &&
|
|
2586
|
+
origin.host === url.host &&
|
|
2587
|
+
(isMSIE || origin.port === url.port)
|
|
2588
|
+
);
|
|
2589
|
+
})(
|
|
2590
|
+
new URL(platform.origin),
|
|
2591
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2592
|
+
)
|
|
2593
|
+
: () => true;
|
|
2594
|
+
|
|
2595
|
+
var cookies = platform.hasStandardBrowserEnv
|
|
2596
|
+
? // Standard browser envs support document.cookie
|
|
2597
|
+
{
|
|
2598
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2599
|
+
if (typeof document === 'undefined') return;
|
|
2600
|
+
|
|
2601
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2602
|
+
|
|
2603
|
+
if (utils$1.isNumber(expires)) {
|
|
2604
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2605
|
+
}
|
|
2606
|
+
if (utils$1.isString(path)) {
|
|
2607
|
+
cookie.push(`path=${path}`);
|
|
2608
|
+
}
|
|
2609
|
+
if (utils$1.isString(domain)) {
|
|
2610
|
+
cookie.push(`domain=${domain}`);
|
|
2611
|
+
}
|
|
2612
|
+
if (secure === true) {
|
|
2613
|
+
cookie.push('secure');
|
|
2614
|
+
}
|
|
2615
|
+
if (utils$1.isString(sameSite)) {
|
|
2616
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2617
|
+
}
|
|
2405
2618
|
|
|
2406
|
-
|
|
2407
|
-
|
|
2619
|
+
document.cookie = cookie.join('; ');
|
|
2620
|
+
},
|
|
2408
2621
|
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2622
|
+
read(name) {
|
|
2623
|
+
if (typeof document === 'undefined') return null;
|
|
2624
|
+
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
|
2625
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
2626
|
+
},
|
|
2414
2627
|
|
|
2415
|
-
|
|
2416
|
-
|
|
2628
|
+
remove(name) {
|
|
2629
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2630
|
+
},
|
|
2417
2631
|
}
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
return null;
|
|
2427
|
-
},
|
|
2428
|
-
remove() {}
|
|
2429
|
-
};
|
|
2632
|
+
: // Non-standard browser env (web workers, react-native) lack needed support.
|
|
2633
|
+
{
|
|
2634
|
+
write() {},
|
|
2635
|
+
read() {
|
|
2636
|
+
return null;
|
|
2637
|
+
},
|
|
2638
|
+
remove() {},
|
|
2639
|
+
};
|
|
2430
2640
|
|
|
2431
2641
|
/**
|
|
2432
2642
|
* Determines whether the specified URL is absolute
|
|
@@ -2472,14 +2682,13 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
2472
2682
|
*/
|
|
2473
2683
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
2474
2684
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2475
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls
|
|
2685
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
2476
2686
|
return combineURLs(baseURL, requestedURL);
|
|
2477
2687
|
}
|
|
2478
2688
|
return requestedURL;
|
|
2479
2689
|
}
|
|
2480
2690
|
|
|
2481
|
-
const headersToObject = (thing) =>
|
|
2482
|
-
thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
2691
|
+
const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
|
|
2483
2692
|
|
|
2484
2693
|
/**
|
|
2485
2694
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2493,7 +2702,18 @@ const headersToObject = (thing) =>
|
|
|
2493
2702
|
function mergeConfig$1(config1, config2) {
|
|
2494
2703
|
// eslint-disable-next-line no-param-reassign
|
|
2495
2704
|
config2 = config2 || {};
|
|
2496
|
-
|
|
2705
|
+
|
|
2706
|
+
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
2707
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype
|
|
2708
|
+
// (see GHSA-q8qp-cvcw-x6jj). `hasOwnProperty` is restored as a non-enumerable
|
|
2709
|
+
// own slot to preserve ergonomics for user code that relies on it.
|
|
2710
|
+
const config = Object.create(null);
|
|
2711
|
+
Object.defineProperty(config, 'hasOwnProperty', {
|
|
2712
|
+
value: Object.prototype.hasOwnProperty,
|
|
2713
|
+
enumerable: false,
|
|
2714
|
+
writable: true,
|
|
2715
|
+
configurable: true,
|
|
2716
|
+
});
|
|
2497
2717
|
|
|
2498
2718
|
function getMergedValue(target, source, prop, caseless) {
|
|
2499
2719
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
@@ -2532,9 +2752,9 @@ function mergeConfig$1(config1, config2) {
|
|
|
2532
2752
|
|
|
2533
2753
|
// eslint-disable-next-line consistent-return
|
|
2534
2754
|
function mergeDirectKeys(a, b, prop) {
|
|
2535
|
-
if (prop
|
|
2755
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
2536
2756
|
return getMergedValue(a, b);
|
|
2537
|
-
} else if (prop
|
|
2757
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
2538
2758
|
return getMergedValue(undefined, a);
|
|
2539
2759
|
}
|
|
2540
2760
|
}
|
|
@@ -2566,29 +2786,21 @@ function mergeConfig$1(config1, config2) {
|
|
|
2566
2786
|
httpsAgent: defaultToConfig2,
|
|
2567
2787
|
cancelToken: defaultToConfig2,
|
|
2568
2788
|
socketPath: defaultToConfig2,
|
|
2789
|
+
allowedSocketPaths: defaultToConfig2,
|
|
2569
2790
|
responseEncoding: defaultToConfig2,
|
|
2570
2791
|
validateStatus: mergeDirectKeys,
|
|
2571
2792
|
headers: (a, b, prop) =>
|
|
2572
2793
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2573
2794
|
};
|
|
2574
2795
|
|
|
2575
|
-
utils$1.forEach(
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
return;
|
|
2584
|
-
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2585
|
-
? mergeMap[prop]
|
|
2586
|
-
: mergeDeepProperties;
|
|
2587
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2588
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2589
|
-
(config[prop] = configValue);
|
|
2590
|
-
},
|
|
2591
|
-
);
|
|
2796
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
2797
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
2798
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
2799
|
+
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
2800
|
+
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
2801
|
+
const configValue = merge(a, b, prop);
|
|
2802
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2803
|
+
});
|
|
2592
2804
|
|
|
2593
2805
|
return config;
|
|
2594
2806
|
}
|
|
@@ -2596,16 +2808,38 @@ function mergeConfig$1(config1, config2) {
|
|
|
2596
2808
|
var resolveConfig = (config) => {
|
|
2597
2809
|
const newConfig = mergeConfig$1({}, config);
|
|
2598
2810
|
|
|
2599
|
-
|
|
2811
|
+
// Read only own properties to prevent prototype pollution gadgets
|
|
2812
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com'). See GHSA-q8qp-cvcw-x6jj.
|
|
2813
|
+
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
2814
|
+
|
|
2815
|
+
const data = own('data');
|
|
2816
|
+
let withXSRFToken = own('withXSRFToken');
|
|
2817
|
+
const xsrfHeaderName = own('xsrfHeaderName');
|
|
2818
|
+
const xsrfCookieName = own('xsrfCookieName');
|
|
2819
|
+
let headers = own('headers');
|
|
2820
|
+
const auth = own('auth');
|
|
2821
|
+
const baseURL = own('baseURL');
|
|
2822
|
+
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
2823
|
+
const url = own('url');
|
|
2600
2824
|
|
|
2601
2825
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
2602
2826
|
|
|
2603
|
-
newConfig.url = buildURL(
|
|
2827
|
+
newConfig.url = buildURL(
|
|
2828
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls),
|
|
2829
|
+
config.params,
|
|
2830
|
+
config.paramsSerializer
|
|
2831
|
+
);
|
|
2604
2832
|
|
|
2605
2833
|
// HTTP basic authentication
|
|
2606
2834
|
if (auth) {
|
|
2607
|
-
headers.set(
|
|
2608
|
-
|
|
2835
|
+
headers.set(
|
|
2836
|
+
'Authorization',
|
|
2837
|
+
'Basic ' +
|
|
2838
|
+
btoa(
|
|
2839
|
+
(auth.username || '') +
|
|
2840
|
+
':' +
|
|
2841
|
+
(auth.password ? unescape(encodeURIComponent(auth.password)) : '')
|
|
2842
|
+
)
|
|
2609
2843
|
);
|
|
2610
2844
|
}
|
|
2611
2845
|
|
|
@@ -2623,17 +2857,25 @@ var resolveConfig = (config) => {
|
|
|
2623
2857
|
}
|
|
2624
2858
|
});
|
|
2625
2859
|
}
|
|
2626
|
-
}
|
|
2860
|
+
}
|
|
2627
2861
|
|
|
2628
2862
|
// Add xsrf header
|
|
2629
2863
|
// This is only done if running in a standard browser environment.
|
|
2630
2864
|
// Specifically not if we're in a web worker, or react-native.
|
|
2631
2865
|
|
|
2632
2866
|
if (platform.hasStandardBrowserEnv) {
|
|
2633
|
-
|
|
2867
|
+
if (utils$1.isFunction(withXSRFToken)) {
|
|
2868
|
+
withXSRFToken = withXSRFToken(newConfig);
|
|
2869
|
+
}
|
|
2634
2870
|
|
|
2635
|
-
|
|
2636
|
-
|
|
2871
|
+
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
2872
|
+
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
2873
|
+
// the XSRF token cross-origin. See GHSA-xx6v-rp6x-q39c.
|
|
2874
|
+
const shouldSendXSRF =
|
|
2875
|
+
withXSRFToken === true ||
|
|
2876
|
+
(withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
2877
|
+
|
|
2878
|
+
if (shouldSendXSRF) {
|
|
2637
2879
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
2638
2880
|
|
|
2639
2881
|
if (xsrfValue) {
|
|
@@ -2647,196 +2889,218 @@ var resolveConfig = (config) => {
|
|
|
2647
2889
|
|
|
2648
2890
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2649
2891
|
|
|
2650
|
-
var xhrAdapter = isXHRAdapterSupported &&
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2892
|
+
var xhrAdapter = isXHRAdapterSupported &&
|
|
2893
|
+
function (config) {
|
|
2894
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2895
|
+
const _config = resolveConfig(config);
|
|
2896
|
+
let requestData = _config.data;
|
|
2897
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
2898
|
+
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
2899
|
+
let onCanceled;
|
|
2900
|
+
let uploadThrottled, downloadThrottled;
|
|
2901
|
+
let flushUpload, flushDownload;
|
|
2659
2902
|
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2903
|
+
function done() {
|
|
2904
|
+
flushUpload && flushUpload(); // flush events
|
|
2905
|
+
flushDownload && flushDownload(); // flush events
|
|
2663
2906
|
|
|
2664
|
-
|
|
2907
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
2665
2908
|
|
|
2666
|
-
|
|
2667
|
-
|
|
2909
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
2910
|
+
}
|
|
2668
2911
|
|
|
2669
|
-
|
|
2912
|
+
let request = new XMLHttpRequest();
|
|
2670
2913
|
|
|
2671
|
-
|
|
2914
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
2672
2915
|
|
|
2673
|
-
|
|
2674
|
-
|
|
2916
|
+
// Set the request timeout in MS
|
|
2917
|
+
request.timeout = _config.timeout;
|
|
2675
2918
|
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2919
|
+
function onloadend() {
|
|
2920
|
+
if (!request) {
|
|
2921
|
+
return;
|
|
2922
|
+
}
|
|
2923
|
+
// Prepare the response
|
|
2924
|
+
const responseHeaders = AxiosHeaders$1.from(
|
|
2925
|
+
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2926
|
+
);
|
|
2927
|
+
const responseData =
|
|
2928
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
2929
|
+
? request.responseText
|
|
2930
|
+
: request.response;
|
|
2931
|
+
const response = {
|
|
2932
|
+
data: responseData,
|
|
2933
|
+
status: request.status,
|
|
2934
|
+
statusText: request.statusText,
|
|
2935
|
+
headers: responseHeaders,
|
|
2936
|
+
config,
|
|
2937
|
+
request,
|
|
2938
|
+
};
|
|
2939
|
+
|
|
2940
|
+
settle(
|
|
2941
|
+
function _resolve(value) {
|
|
2942
|
+
resolve(value);
|
|
2943
|
+
done();
|
|
2944
|
+
},
|
|
2945
|
+
function _reject(err) {
|
|
2946
|
+
reject(err);
|
|
2947
|
+
done();
|
|
2948
|
+
},
|
|
2949
|
+
response
|
|
2950
|
+
);
|
|
2951
|
+
|
|
2952
|
+
// Clean up request
|
|
2953
|
+
request = null;
|
|
2679
2954
|
}
|
|
2680
|
-
// Prepare the response
|
|
2681
|
-
const responseHeaders = AxiosHeaders$1.from(
|
|
2682
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2683
|
-
);
|
|
2684
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
2685
|
-
request.responseText : request.response;
|
|
2686
|
-
const response = {
|
|
2687
|
-
data: responseData,
|
|
2688
|
-
status: request.status,
|
|
2689
|
-
statusText: request.statusText,
|
|
2690
|
-
headers: responseHeaders,
|
|
2691
|
-
config,
|
|
2692
|
-
request
|
|
2693
|
-
};
|
|
2694
2955
|
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2956
|
+
if ('onloadend' in request) {
|
|
2957
|
+
// Use onloadend if available
|
|
2958
|
+
request.onloadend = onloadend;
|
|
2959
|
+
} else {
|
|
2960
|
+
// Listen for ready state to emulate onloadend
|
|
2961
|
+
request.onreadystatechange = function handleLoad() {
|
|
2962
|
+
if (!request || request.readyState !== 4) {
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2702
2965
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2966
|
+
// The request errored out and we didn't get a response, this will be
|
|
2967
|
+
// handled by onerror instead
|
|
2968
|
+
// With one exception: request that using file: protocol, most browsers
|
|
2969
|
+
// will return status as 0 even though it's a successful request
|
|
2970
|
+
if (
|
|
2971
|
+
request.status === 0 &&
|
|
2972
|
+
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
|
2973
|
+
) {
|
|
2974
|
+
return;
|
|
2975
|
+
}
|
|
2976
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2977
|
+
// so we should call onloadend on the next 'tick'
|
|
2978
|
+
setTimeout(onloadend);
|
|
2979
|
+
};
|
|
2980
|
+
}
|
|
2706
2981
|
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
} else {
|
|
2711
|
-
// Listen for ready state to emulate onloadend
|
|
2712
|
-
request.onreadystatechange = function handleLoad() {
|
|
2713
|
-
if (!request || request.readyState !== 4) {
|
|
2982
|
+
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
2983
|
+
request.onabort = function handleAbort() {
|
|
2984
|
+
if (!request) {
|
|
2714
2985
|
return;
|
|
2715
2986
|
}
|
|
2716
2987
|
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
//
|
|
2720
|
-
|
|
2721
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
2722
|
-
return;
|
|
2723
|
-
}
|
|
2724
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2725
|
-
// so we should call onloadend on the next 'tick'
|
|
2726
|
-
setTimeout(onloadend);
|
|
2988
|
+
reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
|
|
2989
|
+
|
|
2990
|
+
// Clean up request
|
|
2991
|
+
request = null;
|
|
2727
2992
|
};
|
|
2728
|
-
}
|
|
2729
2993
|
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2994
|
+
// Handle low level network errors
|
|
2995
|
+
request.onerror = function handleError(event) {
|
|
2996
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
2997
|
+
// (message may be empty; when present, surface it)
|
|
2998
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2999
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
3000
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
3001
|
+
// attach the underlying event for consumers who want details
|
|
3002
|
+
err.event = event || null;
|
|
3003
|
+
reject(err);
|
|
3004
|
+
request = null;
|
|
3005
|
+
};
|
|
2735
3006
|
|
|
2736
|
-
|
|
3007
|
+
// Handle timeout
|
|
3008
|
+
request.ontimeout = function handleTimeout() {
|
|
3009
|
+
let timeoutErrorMessage = _config.timeout
|
|
3010
|
+
? 'timeout of ' + _config.timeout + 'ms exceeded'
|
|
3011
|
+
: 'timeout exceeded';
|
|
3012
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
3013
|
+
if (_config.timeoutErrorMessage) {
|
|
3014
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
3015
|
+
}
|
|
3016
|
+
reject(
|
|
3017
|
+
new AxiosError$1(
|
|
3018
|
+
timeoutErrorMessage,
|
|
3019
|
+
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
3020
|
+
config,
|
|
3021
|
+
request
|
|
3022
|
+
)
|
|
3023
|
+
);
|
|
2737
3024
|
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
3025
|
+
// Clean up request
|
|
3026
|
+
request = null;
|
|
3027
|
+
};
|
|
2741
3028
|
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
// Browsers deliver a ProgressEvent in XHR onerror
|
|
2745
|
-
// (message may be empty; when present, surface it)
|
|
2746
|
-
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
2747
|
-
const msg = event && event.message ? event.message : 'Network Error';
|
|
2748
|
-
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
|
|
2749
|
-
// attach the underlying event for consumers who want details
|
|
2750
|
-
err.event = event || null;
|
|
2751
|
-
reject(err);
|
|
2752
|
-
request = null;
|
|
2753
|
-
};
|
|
2754
|
-
|
|
2755
|
-
// Handle timeout
|
|
2756
|
-
request.ontimeout = function handleTimeout() {
|
|
2757
|
-
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
2758
|
-
const transitional = _config.transitional || transitionalDefaults;
|
|
2759
|
-
if (_config.timeoutErrorMessage) {
|
|
2760
|
-
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2761
|
-
}
|
|
2762
|
-
reject(new AxiosError$1(
|
|
2763
|
-
timeoutErrorMessage,
|
|
2764
|
-
transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
2765
|
-
config,
|
|
2766
|
-
request));
|
|
2767
|
-
|
|
2768
|
-
// Clean up request
|
|
2769
|
-
request = null;
|
|
2770
|
-
};
|
|
3029
|
+
// Remove Content-Type if data is undefined
|
|
3030
|
+
requestData === undefined && requestHeaders.setContentType(null);
|
|
2771
3031
|
|
|
2772
|
-
|
|
2773
|
-
|
|
3032
|
+
// Add headers to the request
|
|
3033
|
+
if ('setRequestHeader' in request) {
|
|
3034
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
3035
|
+
request.setRequestHeader(key, val);
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
2774
3038
|
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
});
|
|
2780
|
-
}
|
|
3039
|
+
// Add withCredentials to request if needed
|
|
3040
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
3041
|
+
request.withCredentials = !!_config.withCredentials;
|
|
3042
|
+
}
|
|
2781
3043
|
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
3044
|
+
// Add responseType to request if needed
|
|
3045
|
+
if (responseType && responseType !== 'json') {
|
|
3046
|
+
request.responseType = _config.responseType;
|
|
3047
|
+
}
|
|
2786
3048
|
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
3049
|
+
// Handle progress if needed
|
|
3050
|
+
if (onDownloadProgress) {
|
|
3051
|
+
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
3052
|
+
request.addEventListener('progress', downloadThrottled);
|
|
3053
|
+
}
|
|
2791
3054
|
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
request.addEventListener('progress', downloadThrottled);
|
|
2796
|
-
}
|
|
3055
|
+
// Not all browsers support upload events
|
|
3056
|
+
if (onUploadProgress && request.upload) {
|
|
3057
|
+
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
|
2797
3058
|
|
|
2798
|
-
|
|
2799
|
-
if (onUploadProgress && request.upload) {
|
|
2800
|
-
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
3059
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
2801
3060
|
|
|
2802
|
-
|
|
3061
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
3062
|
+
}
|
|
2803
3063
|
|
|
2804
|
-
|
|
2805
|
-
|
|
3064
|
+
if (_config.cancelToken || _config.signal) {
|
|
3065
|
+
// Handle cancellation
|
|
3066
|
+
// eslint-disable-next-line func-names
|
|
3067
|
+
onCanceled = (cancel) => {
|
|
3068
|
+
if (!request) {
|
|
3069
|
+
return;
|
|
3070
|
+
}
|
|
3071
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
3072
|
+
request.abort();
|
|
3073
|
+
request = null;
|
|
3074
|
+
};
|
|
2806
3075
|
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
return;
|
|
3076
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
3077
|
+
if (_config.signal) {
|
|
3078
|
+
_config.signal.aborted
|
|
3079
|
+
? onCanceled()
|
|
3080
|
+
: _config.signal.addEventListener('abort', onCanceled);
|
|
2813
3081
|
}
|
|
2814
|
-
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
2815
|
-
request.abort();
|
|
2816
|
-
request = null;
|
|
2817
|
-
};
|
|
2818
|
-
|
|
2819
|
-
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
2820
|
-
if (_config.signal) {
|
|
2821
|
-
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
2822
3082
|
}
|
|
2823
|
-
}
|
|
2824
3083
|
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
2828
|
-
reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
|
|
2829
|
-
return;
|
|
2830
|
-
}
|
|
3084
|
+
const protocol = parseProtocol(_config.url);
|
|
2831
3085
|
|
|
3086
|
+
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
3087
|
+
reject(
|
|
3088
|
+
new AxiosError$1(
|
|
3089
|
+
'Unsupported protocol ' + protocol + ':',
|
|
3090
|
+
AxiosError$1.ERR_BAD_REQUEST,
|
|
3091
|
+
config
|
|
3092
|
+
)
|
|
3093
|
+
);
|
|
3094
|
+
return;
|
|
3095
|
+
}
|
|
2832
3096
|
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
};
|
|
3097
|
+
// Send the request
|
|
3098
|
+
request.send(requestData || null);
|
|
3099
|
+
});
|
|
3100
|
+
};
|
|
2837
3101
|
|
|
2838
3102
|
const composeSignals = (signals, timeout) => {
|
|
2839
|
-
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
3103
|
+
const { length } = (signals = signals ? signals.filter(Boolean) : []);
|
|
2840
3104
|
|
|
2841
3105
|
if (timeout || length) {
|
|
2842
3106
|
let controller = new AbortController();
|
|
@@ -2848,21 +3112,29 @@ const composeSignals = (signals, timeout) => {
|
|
|
2848
3112
|
aborted = true;
|
|
2849
3113
|
unsubscribe();
|
|
2850
3114
|
const err = reason instanceof Error ? reason : this.reason;
|
|
2851
|
-
controller.abort(
|
|
3115
|
+
controller.abort(
|
|
3116
|
+
err instanceof AxiosError$1
|
|
3117
|
+
? err
|
|
3118
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3119
|
+
);
|
|
2852
3120
|
}
|
|
2853
3121
|
};
|
|
2854
3122
|
|
|
2855
|
-
let timer =
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
3123
|
+
let timer =
|
|
3124
|
+
timeout &&
|
|
3125
|
+
setTimeout(() => {
|
|
3126
|
+
timer = null;
|
|
3127
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3128
|
+
}, timeout);
|
|
2859
3129
|
|
|
2860
3130
|
const unsubscribe = () => {
|
|
2861
3131
|
if (signals) {
|
|
2862
3132
|
timer && clearTimeout(timer);
|
|
2863
3133
|
timer = null;
|
|
2864
|
-
signals.forEach(signal => {
|
|
2865
|
-
signal.unsubscribe
|
|
3134
|
+
signals.forEach((signal) => {
|
|
3135
|
+
signal.unsubscribe
|
|
3136
|
+
? signal.unsubscribe(onabort)
|
|
3137
|
+
: signal.removeEventListener('abort', onabort);
|
|
2866
3138
|
});
|
|
2867
3139
|
signals = null;
|
|
2868
3140
|
}
|
|
@@ -2870,7 +3142,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
2870
3142
|
|
|
2871
3143
|
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
2872
3144
|
|
|
2873
|
-
const {signal} = controller;
|
|
3145
|
+
const { signal } = controller;
|
|
2874
3146
|
|
|
2875
3147
|
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
2876
3148
|
|
|
@@ -2911,7 +3183,7 @@ const readStream = async function* (stream) {
|
|
|
2911
3183
|
const reader = stream.getReader();
|
|
2912
3184
|
try {
|
|
2913
3185
|
for (;;) {
|
|
2914
|
-
const {done, value} = await reader.read();
|
|
3186
|
+
const { done, value } = await reader.read();
|
|
2915
3187
|
if (done) {
|
|
2916
3188
|
break;
|
|
2917
3189
|
}
|
|
@@ -2934,64 +3206,69 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
2934
3206
|
}
|
|
2935
3207
|
};
|
|
2936
3208
|
|
|
2937
|
-
return new ReadableStream(
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
3209
|
+
return new ReadableStream(
|
|
3210
|
+
{
|
|
3211
|
+
async pull(controller) {
|
|
3212
|
+
try {
|
|
3213
|
+
const { done, value } = await iterator.next();
|
|
2941
3214
|
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
3215
|
+
if (done) {
|
|
3216
|
+
_onFinish();
|
|
3217
|
+
controller.close();
|
|
3218
|
+
return;
|
|
3219
|
+
}
|
|
2947
3220
|
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
3221
|
+
let len = value.byteLength;
|
|
3222
|
+
if (onProgress) {
|
|
3223
|
+
let loadedBytes = (bytes += len);
|
|
3224
|
+
onProgress(loadedBytes);
|
|
3225
|
+
}
|
|
3226
|
+
controller.enqueue(new Uint8Array(value));
|
|
3227
|
+
} catch (err) {
|
|
3228
|
+
_onFinish(err);
|
|
3229
|
+
throw err;
|
|
2952
3230
|
}
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
_onFinish(
|
|
2956
|
-
|
|
2957
|
-
}
|
|
3231
|
+
},
|
|
3232
|
+
cancel(reason) {
|
|
3233
|
+
_onFinish(reason);
|
|
3234
|
+
return iterator.return();
|
|
3235
|
+
},
|
|
2958
3236
|
},
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
return iterator.return();
|
|
3237
|
+
{
|
|
3238
|
+
highWaterMark: 2,
|
|
2962
3239
|
}
|
|
2963
|
-
|
|
2964
|
-
highWaterMark: 2
|
|
2965
|
-
})
|
|
3240
|
+
);
|
|
2966
3241
|
};
|
|
2967
3242
|
|
|
2968
3243
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2969
3244
|
|
|
2970
|
-
const {isFunction} = utils$1;
|
|
3245
|
+
const { isFunction } = utils$1;
|
|
2971
3246
|
|
|
2972
|
-
const globalFetchAPI = (({Request, Response}) => ({
|
|
2973
|
-
Request,
|
|
3247
|
+
const globalFetchAPI = (({ Request, Response }) => ({
|
|
3248
|
+
Request,
|
|
3249
|
+
Response,
|
|
2974
3250
|
}))(utils$1.global);
|
|
2975
3251
|
|
|
2976
|
-
const {
|
|
2977
|
-
ReadableStream: ReadableStream$1, TextEncoder
|
|
2978
|
-
} = utils$1.global;
|
|
2979
|
-
|
|
3252
|
+
const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
|
|
2980
3253
|
|
|
2981
3254
|
const test = (fn, ...args) => {
|
|
2982
3255
|
try {
|
|
2983
3256
|
return !!fn(...args);
|
|
2984
3257
|
} catch (e) {
|
|
2985
|
-
return false
|
|
3258
|
+
return false;
|
|
2986
3259
|
}
|
|
2987
3260
|
};
|
|
2988
3261
|
|
|
2989
3262
|
const factory = (env) => {
|
|
2990
|
-
env = utils$1.merge.call(
|
|
2991
|
-
|
|
2992
|
-
|
|
3263
|
+
env = utils$1.merge.call(
|
|
3264
|
+
{
|
|
3265
|
+
skipUndefined: true,
|
|
3266
|
+
},
|
|
3267
|
+
globalFetchAPI,
|
|
3268
|
+
env
|
|
3269
|
+
);
|
|
2993
3270
|
|
|
2994
|
-
const {fetch: envFetch, Request, Response} = env;
|
|
3271
|
+
const { fetch: envFetch, Request, Response } = env;
|
|
2995
3272
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
2996
3273
|
const isRequestSupported = isFunction(Request);
|
|
2997
3274
|
const isResponseSupported = isFunction(Response);
|
|
@@ -3002,46 +3279,67 @@ const factory = (env) => {
|
|
|
3002
3279
|
|
|
3003
3280
|
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
3004
3281
|
|
|
3005
|
-
const encodeText =
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3282
|
+
const encodeText =
|
|
3283
|
+
isFetchSupported &&
|
|
3284
|
+
(typeof TextEncoder === 'function'
|
|
3285
|
+
? (
|
|
3286
|
+
(encoder) => (str) =>
|
|
3287
|
+
encoder.encode(str)
|
|
3288
|
+
)(new TextEncoder())
|
|
3289
|
+
: async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
3290
|
+
|
|
3291
|
+
const supportsRequestStream =
|
|
3292
|
+
isRequestSupported &&
|
|
3293
|
+
isReadableStreamSupported &&
|
|
3294
|
+
test(() => {
|
|
3295
|
+
let duplexAccessed = false;
|
|
3296
|
+
|
|
3297
|
+
const request = new Request(platform.origin, {
|
|
3298
|
+
body: new ReadableStream$1(),
|
|
3299
|
+
method: 'POST',
|
|
3300
|
+
get duplex() {
|
|
3301
|
+
duplexAccessed = true;
|
|
3302
|
+
return 'half';
|
|
3303
|
+
},
|
|
3304
|
+
});
|
|
3009
3305
|
|
|
3010
|
-
|
|
3011
|
-
let duplexAccessed = false;
|
|
3306
|
+
const hasContentType = request.headers.has('Content-Type');
|
|
3012
3307
|
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
get duplex() {
|
|
3017
|
-
duplexAccessed = true;
|
|
3018
|
-
return 'half';
|
|
3019
|
-
},
|
|
3020
|
-
}).headers.has('Content-Type');
|
|
3308
|
+
if (request.body != null) {
|
|
3309
|
+
request.body.cancel();
|
|
3310
|
+
}
|
|
3021
3311
|
|
|
3022
|
-
|
|
3023
|
-
|
|
3312
|
+
return duplexAccessed && !hasContentType;
|
|
3313
|
+
});
|
|
3024
3314
|
|
|
3025
|
-
const supportsResponseStream =
|
|
3315
|
+
const supportsResponseStream =
|
|
3316
|
+
isResponseSupported &&
|
|
3317
|
+
isReadableStreamSupported &&
|
|
3026
3318
|
test(() => utils$1.isReadableStream(new Response('').body));
|
|
3027
3319
|
|
|
3028
3320
|
const resolvers = {
|
|
3029
|
-
stream: supportsResponseStream && ((res) => res.body)
|
|
3321
|
+
stream: supportsResponseStream && ((res) => res.body),
|
|
3030
3322
|
};
|
|
3031
3323
|
|
|
3032
|
-
isFetchSupported &&
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3324
|
+
isFetchSupported &&
|
|
3325
|
+
(() => {
|
|
3326
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
|
|
3327
|
+
!resolvers[type] &&
|
|
3328
|
+
(resolvers[type] = (res, config) => {
|
|
3329
|
+
let method = res && res[type];
|
|
3036
3330
|
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3331
|
+
if (method) {
|
|
3332
|
+
return method.call(res);
|
|
3333
|
+
}
|
|
3040
3334
|
|
|
3041
|
-
|
|
3335
|
+
throw new AxiosError$1(
|
|
3336
|
+
`Response type '${type}' is not supported`,
|
|
3337
|
+
AxiosError$1.ERR_NOT_SUPPORT,
|
|
3338
|
+
config
|
|
3339
|
+
);
|
|
3340
|
+
});
|
|
3042
3341
|
});
|
|
3043
|
-
});
|
|
3044
|
-
})());
|
|
3342
|
+
})();
|
|
3045
3343
|
|
|
3046
3344
|
const getBodyLength = async (body) => {
|
|
3047
3345
|
if (body == null) {
|
|
@@ -3092,32 +3390,41 @@ const factory = (env) => {
|
|
|
3092
3390
|
responseType,
|
|
3093
3391
|
headers,
|
|
3094
3392
|
withCredentials = 'same-origin',
|
|
3095
|
-
fetchOptions
|
|
3393
|
+
fetchOptions,
|
|
3096
3394
|
} = resolveConfig(config);
|
|
3097
3395
|
|
|
3098
3396
|
let _fetch = envFetch || fetch;
|
|
3099
3397
|
|
|
3100
3398
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
3101
3399
|
|
|
3102
|
-
let composedSignal = composeSignals(
|
|
3400
|
+
let composedSignal = composeSignals(
|
|
3401
|
+
[signal, cancelToken && cancelToken.toAbortSignal()],
|
|
3402
|
+
timeout
|
|
3403
|
+
);
|
|
3103
3404
|
|
|
3104
3405
|
let request = null;
|
|
3105
3406
|
|
|
3106
|
-
const unsubscribe =
|
|
3107
|
-
composedSignal
|
|
3108
|
-
|
|
3407
|
+
const unsubscribe =
|
|
3408
|
+
composedSignal &&
|
|
3409
|
+
composedSignal.unsubscribe &&
|
|
3410
|
+
(() => {
|
|
3411
|
+
composedSignal.unsubscribe();
|
|
3412
|
+
});
|
|
3109
3413
|
|
|
3110
3414
|
let requestContentLength;
|
|
3111
3415
|
|
|
3112
3416
|
try {
|
|
3113
3417
|
if (
|
|
3114
|
-
onUploadProgress &&
|
|
3418
|
+
onUploadProgress &&
|
|
3419
|
+
supportsRequestStream &&
|
|
3420
|
+
method !== 'get' &&
|
|
3421
|
+
method !== 'head' &&
|
|
3115
3422
|
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
3116
3423
|
) {
|
|
3117
3424
|
let _request = new Request(url, {
|
|
3118
3425
|
method: 'POST',
|
|
3119
3426
|
body: data,
|
|
3120
|
-
duplex:
|
|
3427
|
+
duplex: 'half',
|
|
3121
3428
|
});
|
|
3122
3429
|
|
|
3123
3430
|
let contentTypeHeader;
|
|
@@ -3142,7 +3449,20 @@ const factory = (env) => {
|
|
|
3142
3449
|
|
|
3143
3450
|
// Cloudflare Workers throws when credentials are defined
|
|
3144
3451
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
3145
|
-
const isCredentialsSupported = isRequestSupported &&
|
|
3452
|
+
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
3453
|
+
|
|
3454
|
+
// If data is FormData and Content-Type is multipart/form-data without boundary,
|
|
3455
|
+
// delete it so fetch can set it correctly with the boundary
|
|
3456
|
+
if (utils$1.isFormData(data)) {
|
|
3457
|
+
const contentType = headers.getContentType();
|
|
3458
|
+
if (
|
|
3459
|
+
contentType &&
|
|
3460
|
+
/^multipart\/form-data/i.test(contentType) &&
|
|
3461
|
+
!/boundary=/i.test(contentType)
|
|
3462
|
+
) {
|
|
3463
|
+
headers.delete('content-type');
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3146
3466
|
|
|
3147
3467
|
const resolvedOptions = {
|
|
3148
3468
|
...fetchOptions,
|
|
@@ -3150,29 +3470,35 @@ const factory = (env) => {
|
|
|
3150
3470
|
method: method.toUpperCase(),
|
|
3151
3471
|
headers: headers.normalize().toJSON(),
|
|
3152
3472
|
body: data,
|
|
3153
|
-
duplex:
|
|
3154
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3473
|
+
duplex: 'half',
|
|
3474
|
+
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
3155
3475
|
};
|
|
3156
3476
|
|
|
3157
3477
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3158
3478
|
|
|
3159
|
-
let response = await (isRequestSupported
|
|
3479
|
+
let response = await (isRequestSupported
|
|
3480
|
+
? _fetch(request, fetchOptions)
|
|
3481
|
+
: _fetch(url, resolvedOptions));
|
|
3160
3482
|
|
|
3161
|
-
const isStreamResponse =
|
|
3483
|
+
const isStreamResponse =
|
|
3484
|
+
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3162
3485
|
|
|
3163
3486
|
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
3164
3487
|
const options = {};
|
|
3165
3488
|
|
|
3166
|
-
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3489
|
+
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
3167
3490
|
options[prop] = response[prop];
|
|
3168
3491
|
});
|
|
3169
3492
|
|
|
3170
3493
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3171
3494
|
|
|
3172
|
-
const [onProgress, flush] =
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3495
|
+
const [onProgress, flush] =
|
|
3496
|
+
(onDownloadProgress &&
|
|
3497
|
+
progressEventDecorator(
|
|
3498
|
+
responseContentLength,
|
|
3499
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3500
|
+
)) ||
|
|
3501
|
+
[];
|
|
3176
3502
|
|
|
3177
3503
|
response = new Response(
|
|
3178
3504
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
@@ -3185,7 +3511,10 @@ const factory = (env) => {
|
|
|
3185
3511
|
|
|
3186
3512
|
responseType = responseType || 'text';
|
|
3187
3513
|
|
|
3188
|
-
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3514
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3515
|
+
response,
|
|
3516
|
+
config
|
|
3517
|
+
);
|
|
3189
3518
|
|
|
3190
3519
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3191
3520
|
|
|
@@ -3196,43 +3525,50 @@ const factory = (env) => {
|
|
|
3196
3525
|
status: response.status,
|
|
3197
3526
|
statusText: response.statusText,
|
|
3198
3527
|
config,
|
|
3199
|
-
request
|
|
3528
|
+
request,
|
|
3200
3529
|
});
|
|
3201
|
-
})
|
|
3530
|
+
});
|
|
3202
3531
|
} catch (err) {
|
|
3203
3532
|
unsubscribe && unsubscribe();
|
|
3204
3533
|
|
|
3205
3534
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3206
3535
|
throw Object.assign(
|
|
3207
|
-
new AxiosError$1(
|
|
3536
|
+
new AxiosError$1(
|
|
3537
|
+
'Network Error',
|
|
3538
|
+
AxiosError$1.ERR_NETWORK,
|
|
3539
|
+
config,
|
|
3540
|
+
request,
|
|
3541
|
+
err && err.response
|
|
3542
|
+
),
|
|
3208
3543
|
{
|
|
3209
|
-
cause: err.cause || err
|
|
3544
|
+
cause: err.cause || err,
|
|
3210
3545
|
}
|
|
3211
|
-
)
|
|
3546
|
+
);
|
|
3212
3547
|
}
|
|
3213
3548
|
|
|
3214
3549
|
throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
|
|
3215
3550
|
}
|
|
3216
|
-
}
|
|
3551
|
+
};
|
|
3217
3552
|
};
|
|
3218
3553
|
|
|
3219
3554
|
const seedCache = new Map();
|
|
3220
3555
|
|
|
3221
3556
|
const getFetch = (config) => {
|
|
3222
3557
|
let env = (config && config.env) || {};
|
|
3223
|
-
const {fetch, Request, Response} = env;
|
|
3224
|
-
const seeds = [
|
|
3225
|
-
Request, Response, fetch
|
|
3226
|
-
];
|
|
3558
|
+
const { fetch, Request, Response } = env;
|
|
3559
|
+
const seeds = [Request, Response, fetch];
|
|
3227
3560
|
|
|
3228
|
-
let len = seeds.length,
|
|
3229
|
-
|
|
3561
|
+
let len = seeds.length,
|
|
3562
|
+
i = len,
|
|
3563
|
+
seed,
|
|
3564
|
+
target,
|
|
3565
|
+
map = seedCache;
|
|
3230
3566
|
|
|
3231
3567
|
while (i--) {
|
|
3232
3568
|
seed = seeds[i];
|
|
3233
3569
|
target = map.get(seed);
|
|
3234
3570
|
|
|
3235
|
-
target === undefined && map.set(seed, target =
|
|
3571
|
+
target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
|
|
3236
3572
|
|
|
3237
3573
|
map = target;
|
|
3238
3574
|
}
|
|
@@ -3248,7 +3584,7 @@ getFetch();
|
|
|
3248
3584
|
* - `http` for Node.js
|
|
3249
3585
|
* - `xhr` for browsers
|
|
3250
3586
|
* - `fetch` for fetch API-based requests
|
|
3251
|
-
*
|
|
3587
|
+
*
|
|
3252
3588
|
* @type {Object<string, Function|Object>}
|
|
3253
3589
|
*/
|
|
3254
3590
|
const knownAdapters = {
|
|
@@ -3256,7 +3592,7 @@ const knownAdapters = {
|
|
|
3256
3592
|
xhr: xhrAdapter,
|
|
3257
3593
|
fetch: {
|
|
3258
3594
|
get: getFetch,
|
|
3259
|
-
}
|
|
3595
|
+
},
|
|
3260
3596
|
};
|
|
3261
3597
|
|
|
3262
3598
|
// Assign adapter names for easier debugging and identification
|
|
@@ -3273,7 +3609,7 @@ utils$1.forEach(knownAdapters, (fn, value) => {
|
|
|
3273
3609
|
|
|
3274
3610
|
/**
|
|
3275
3611
|
* Render a rejection reason string for unknown or unsupported adapters
|
|
3276
|
-
*
|
|
3612
|
+
*
|
|
3277
3613
|
* @param {string} reason
|
|
3278
3614
|
* @returns {string}
|
|
3279
3615
|
*/
|
|
@@ -3281,17 +3617,18 @@ const renderReason = (reason) => `- ${reason}`;
|
|
|
3281
3617
|
|
|
3282
3618
|
/**
|
|
3283
3619
|
* Check if the adapter is resolved (function, null, or false)
|
|
3284
|
-
*
|
|
3620
|
+
*
|
|
3285
3621
|
* @param {Function|null|false} adapter
|
|
3286
3622
|
* @returns {boolean}
|
|
3287
3623
|
*/
|
|
3288
|
-
const isResolvedHandle = (adapter) =>
|
|
3624
|
+
const isResolvedHandle = (adapter) =>
|
|
3625
|
+
utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3289
3626
|
|
|
3290
3627
|
/**
|
|
3291
3628
|
* Get the first suitable adapter from the provided list.
|
|
3292
3629
|
* Tries each adapter in order until a supported one is found.
|
|
3293
3630
|
* Throws an AxiosError if no adapter is suitable.
|
|
3294
|
-
*
|
|
3631
|
+
*
|
|
3295
3632
|
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3296
3633
|
* @param {Object} config - Axios request configuration
|
|
3297
3634
|
* @throws {AxiosError} If no suitable adapter is available
|
|
@@ -3328,14 +3665,17 @@ function getAdapter$1(adapters, config) {
|
|
|
3328
3665
|
}
|
|
3329
3666
|
|
|
3330
3667
|
if (!adapter) {
|
|
3331
|
-
const reasons = Object.entries(rejectedReasons)
|
|
3332
|
-
|
|
3668
|
+
const reasons = Object.entries(rejectedReasons).map(
|
|
3669
|
+
([id, state]) =>
|
|
3670
|
+
`adapter ${id} ` +
|
|
3333
3671
|
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3334
|
-
|
|
3672
|
+
);
|
|
3335
3673
|
|
|
3336
|
-
let s = length
|
|
3337
|
-
|
|
3338
|
-
|
|
3674
|
+
let s = length
|
|
3675
|
+
? reasons.length > 1
|
|
3676
|
+
? 'since :\n' + reasons.map(renderReason).join('\n')
|
|
3677
|
+
: ' ' + renderReason(reasons[0])
|
|
3678
|
+
: 'as no adapter specified';
|
|
3339
3679
|
|
|
3340
3680
|
throw new AxiosError$1(
|
|
3341
3681
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
@@ -3360,7 +3700,7 @@ var adapters = {
|
|
|
3360
3700
|
* Exposes all known adapters
|
|
3361
3701
|
* @type {Object<string, Function|Object>}
|
|
3362
3702
|
*/
|
|
3363
|
-
adapters: knownAdapters
|
|
3703
|
+
adapters: knownAdapters,
|
|
3364
3704
|
};
|
|
3365
3705
|
|
|
3366
3706
|
/**
|
|
@@ -3393,10 +3733,7 @@ function dispatchRequest(config) {
|
|
|
3393
3733
|
config.headers = AxiosHeaders$1.from(config.headers);
|
|
3394
3734
|
|
|
3395
3735
|
// Transform request data
|
|
3396
|
-
config.data = transformData.call(
|
|
3397
|
-
config,
|
|
3398
|
-
config.transformRequest
|
|
3399
|
-
);
|
|
3736
|
+
config.data = transformData.call(config, config.transformRequest);
|
|
3400
3737
|
|
|
3401
3738
|
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
3402
3739
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
@@ -3404,39 +3741,38 @@ function dispatchRequest(config) {
|
|
|
3404
3741
|
|
|
3405
3742
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
3406
3743
|
|
|
3407
|
-
return adapter(config).then(
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
// Transform response data
|
|
3411
|
-
response.data = transformData.call(
|
|
3412
|
-
config,
|
|
3413
|
-
config.transformResponse,
|
|
3414
|
-
response
|
|
3415
|
-
);
|
|
3416
|
-
|
|
3417
|
-
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3418
|
-
|
|
3419
|
-
return response;
|
|
3420
|
-
}, function onAdapterRejection(reason) {
|
|
3421
|
-
if (!isCancel$1(reason)) {
|
|
3744
|
+
return adapter(config).then(
|
|
3745
|
+
function onAdapterResolution(response) {
|
|
3422
3746
|
throwIfCancellationRequested(config);
|
|
3423
3747
|
|
|
3424
3748
|
// Transform response data
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3749
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
3750
|
+
|
|
3751
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
|
3752
|
+
|
|
3753
|
+
return response;
|
|
3754
|
+
},
|
|
3755
|
+
function onAdapterRejection(reason) {
|
|
3756
|
+
if (!isCancel$1(reason)) {
|
|
3757
|
+
throwIfCancellationRequested(config);
|
|
3758
|
+
|
|
3759
|
+
// Transform response data
|
|
3760
|
+
if (reason && reason.response) {
|
|
3761
|
+
reason.response.data = transformData.call(
|
|
3762
|
+
config,
|
|
3763
|
+
config.transformResponse,
|
|
3764
|
+
reason.response
|
|
3765
|
+
);
|
|
3766
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
3767
|
+
}
|
|
3432
3768
|
}
|
|
3433
|
-
}
|
|
3434
3769
|
|
|
3435
|
-
|
|
3436
|
-
|
|
3770
|
+
return Promise.reject(reason);
|
|
3771
|
+
}
|
|
3772
|
+
);
|
|
3437
3773
|
}
|
|
3438
3774
|
|
|
3439
|
-
const VERSION$1 = "1.
|
|
3775
|
+
const VERSION$1 = "1.15.2";
|
|
3440
3776
|
|
|
3441
3777
|
const validators$1 = {};
|
|
3442
3778
|
|
|
@@ -3460,7 +3796,15 @@ const deprecatedWarnings = {};
|
|
|
3460
3796
|
*/
|
|
3461
3797
|
validators$1.transitional = function transitional(validator, version, message) {
|
|
3462
3798
|
function formatMessage(opt, desc) {
|
|
3463
|
-
return
|
|
3799
|
+
return (
|
|
3800
|
+
'[Axios v' +
|
|
3801
|
+
VERSION$1 +
|
|
3802
|
+
"] Transitional option '" +
|
|
3803
|
+
opt +
|
|
3804
|
+
"'" +
|
|
3805
|
+
desc +
|
|
3806
|
+
(message ? '. ' + message : '')
|
|
3807
|
+
);
|
|
3464
3808
|
}
|
|
3465
3809
|
|
|
3466
3810
|
// eslint-disable-next-line func-names
|
|
@@ -3492,7 +3836,7 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
3492
3836
|
// eslint-disable-next-line no-console
|
|
3493
3837
|
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
3494
3838
|
return true;
|
|
3495
|
-
}
|
|
3839
|
+
};
|
|
3496
3840
|
};
|
|
3497
3841
|
|
|
3498
3842
|
/**
|
|
@@ -3513,12 +3857,17 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3513
3857
|
let i = keys.length;
|
|
3514
3858
|
while (i-- > 0) {
|
|
3515
3859
|
const opt = keys[i];
|
|
3516
|
-
|
|
3860
|
+
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
3861
|
+
// a non-function validator and cause a TypeError. See GHSA-q8qp-cvcw-x6jj.
|
|
3862
|
+
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
3517
3863
|
if (validator) {
|
|
3518
3864
|
const value = options[opt];
|
|
3519
3865
|
const result = value === undefined || validator(value, opt, options);
|
|
3520
3866
|
if (result !== true) {
|
|
3521
|
-
throw new AxiosError$1(
|
|
3867
|
+
throw new AxiosError$1(
|
|
3868
|
+
'option ' + opt + ' must be ' + result,
|
|
3869
|
+
AxiosError$1.ERR_BAD_OPTION_VALUE
|
|
3870
|
+
);
|
|
3522
3871
|
}
|
|
3523
3872
|
continue;
|
|
3524
3873
|
}
|
|
@@ -3530,7 +3879,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3530
3879
|
|
|
3531
3880
|
var validator = {
|
|
3532
3881
|
assertOptions,
|
|
3533
|
-
validators: validators$1
|
|
3882
|
+
validators: validators$1,
|
|
3534
3883
|
};
|
|
3535
3884
|
|
|
3536
3885
|
const validators = validator.validators;
|
|
@@ -3547,7 +3896,7 @@ let Axios$1 = class Axios {
|
|
|
3547
3896
|
this.defaults = instanceConfig || {};
|
|
3548
3897
|
this.interceptors = {
|
|
3549
3898
|
request: new InterceptorManager(),
|
|
3550
|
-
response: new InterceptorManager()
|
|
3899
|
+
response: new InterceptorManager(),
|
|
3551
3900
|
};
|
|
3552
3901
|
}
|
|
3553
3902
|
|
|
@@ -3569,13 +3918,29 @@ let Axios$1 = class Axios {
|
|
|
3569
3918
|
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
3570
3919
|
|
|
3571
3920
|
// slice off the Error: ... line
|
|
3572
|
-
const stack =
|
|
3921
|
+
const stack = (() => {
|
|
3922
|
+
if (!dummy.stack) {
|
|
3923
|
+
return '';
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3926
|
+
const firstNewlineIndex = dummy.stack.indexOf('\n');
|
|
3927
|
+
|
|
3928
|
+
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
3929
|
+
})();
|
|
3573
3930
|
try {
|
|
3574
3931
|
if (!err.stack) {
|
|
3575
3932
|
err.stack = stack;
|
|
3576
3933
|
// match without the 2 top stack lines
|
|
3577
|
-
} else if (stack
|
|
3578
|
-
|
|
3934
|
+
} else if (stack) {
|
|
3935
|
+
const firstNewlineIndex = stack.indexOf('\n');
|
|
3936
|
+
const secondNewlineIndex =
|
|
3937
|
+
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
3938
|
+
const stackWithoutTwoTopLines =
|
|
3939
|
+
secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|
3940
|
+
|
|
3941
|
+
if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
|
|
3942
|
+
err.stack += '\n' + stack;
|
|
3943
|
+
}
|
|
3579
3944
|
}
|
|
3580
3945
|
} catch (e) {
|
|
3581
3946
|
// ignore the case where "stack" is an un-writable property
|
|
@@ -3598,27 +3963,35 @@ let Axios$1 = class Axios {
|
|
|
3598
3963
|
|
|
3599
3964
|
config = mergeConfig$1(this.defaults, config);
|
|
3600
3965
|
|
|
3601
|
-
const {transitional, paramsSerializer, headers} = config;
|
|
3966
|
+
const { transitional, paramsSerializer, headers } = config;
|
|
3602
3967
|
|
|
3603
3968
|
if (transitional !== undefined) {
|
|
3604
|
-
validator.assertOptions(
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3969
|
+
validator.assertOptions(
|
|
3970
|
+
transitional,
|
|
3971
|
+
{
|
|
3972
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
3973
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
3974
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
3975
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
3976
|
+
},
|
|
3977
|
+
false
|
|
3978
|
+
);
|
|
3610
3979
|
}
|
|
3611
3980
|
|
|
3612
3981
|
if (paramsSerializer != null) {
|
|
3613
3982
|
if (utils$1.isFunction(paramsSerializer)) {
|
|
3614
3983
|
config.paramsSerializer = {
|
|
3615
|
-
serialize: paramsSerializer
|
|
3984
|
+
serialize: paramsSerializer,
|
|
3616
3985
|
};
|
|
3617
3986
|
} else {
|
|
3618
|
-
validator.assertOptions(
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3987
|
+
validator.assertOptions(
|
|
3988
|
+
paramsSerializer,
|
|
3989
|
+
{
|
|
3990
|
+
encode: validators.function,
|
|
3991
|
+
serialize: validators.function,
|
|
3992
|
+
},
|
|
3993
|
+
true
|
|
3994
|
+
);
|
|
3622
3995
|
}
|
|
3623
3996
|
}
|
|
3624
3997
|
|
|
@@ -3629,26 +4002,25 @@ let Axios$1 = class Axios {
|
|
|
3629
4002
|
config.allowAbsoluteUrls = true;
|
|
3630
4003
|
}
|
|
3631
4004
|
|
|
3632
|
-
validator.assertOptions(
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
4005
|
+
validator.assertOptions(
|
|
4006
|
+
config,
|
|
4007
|
+
{
|
|
4008
|
+
baseUrl: validators.spelling('baseURL'),
|
|
4009
|
+
withXsrfToken: validators.spelling('withXSRFToken'),
|
|
4010
|
+
},
|
|
4011
|
+
true
|
|
4012
|
+
);
|
|
3636
4013
|
|
|
3637
4014
|
// Set config.method
|
|
3638
4015
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3639
4016
|
|
|
3640
4017
|
// Flatten headers
|
|
3641
|
-
let contextHeaders = headers && utils$1.merge(
|
|
3642
|
-
headers.common,
|
|
3643
|
-
headers[config.method]
|
|
3644
|
-
);
|
|
4018
|
+
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
3645
4019
|
|
|
3646
|
-
headers &&
|
|
3647
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3648
|
-
(method) => {
|
|
4020
|
+
headers &&
|
|
4021
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
|
|
3649
4022
|
delete headers[method];
|
|
3650
|
-
}
|
|
3651
|
-
);
|
|
4023
|
+
});
|
|
3652
4024
|
|
|
3653
4025
|
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
3654
4026
|
|
|
@@ -3663,7 +4035,8 @@ let Axios$1 = class Axios {
|
|
|
3663
4035
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3664
4036
|
|
|
3665
4037
|
const transitional = config.transitional || transitionalDefaults;
|
|
3666
|
-
const legacyInterceptorReqResOrdering =
|
|
4038
|
+
const legacyInterceptorReqResOrdering =
|
|
4039
|
+
transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3667
4040
|
|
|
3668
4041
|
if (legacyInterceptorReqResOrdering) {
|
|
3669
4042
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
@@ -3737,28 +4110,32 @@ let Axios$1 = class Axios {
|
|
|
3737
4110
|
// Provide aliases for supported request methods
|
|
3738
4111
|
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3739
4112
|
/*eslint func-names:0*/
|
|
3740
|
-
Axios$1.prototype[method] = function(url, config) {
|
|
3741
|
-
return this.request(
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
4113
|
+
Axios$1.prototype[method] = function (url, config) {
|
|
4114
|
+
return this.request(
|
|
4115
|
+
mergeConfig$1(config || {}, {
|
|
4116
|
+
method,
|
|
4117
|
+
url,
|
|
4118
|
+
data: (config || {}).data,
|
|
4119
|
+
})
|
|
4120
|
+
);
|
|
3746
4121
|
};
|
|
3747
4122
|
});
|
|
3748
4123
|
|
|
3749
4124
|
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3750
|
-
/*eslint func-names:0*/
|
|
3751
|
-
|
|
3752
4125
|
function generateHTTPMethod(isForm) {
|
|
3753
4126
|
return function httpMethod(url, data, config) {
|
|
3754
|
-
return this.request(
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
4127
|
+
return this.request(
|
|
4128
|
+
mergeConfig$1(config || {}, {
|
|
4129
|
+
method,
|
|
4130
|
+
headers: isForm
|
|
4131
|
+
? {
|
|
4132
|
+
'Content-Type': 'multipart/form-data',
|
|
4133
|
+
}
|
|
4134
|
+
: {},
|
|
4135
|
+
url,
|
|
4136
|
+
data,
|
|
4137
|
+
})
|
|
4138
|
+
);
|
|
3762
4139
|
};
|
|
3763
4140
|
}
|
|
3764
4141
|
|
|
@@ -3789,7 +4166,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
3789
4166
|
const token = this;
|
|
3790
4167
|
|
|
3791
4168
|
// eslint-disable-next-line func-names
|
|
3792
|
-
this.promise.then(cancel => {
|
|
4169
|
+
this.promise.then((cancel) => {
|
|
3793
4170
|
if (!token._listeners) return;
|
|
3794
4171
|
|
|
3795
4172
|
let i = token._listeners.length;
|
|
@@ -3801,10 +4178,10 @@ let CancelToken$1 = class CancelToken {
|
|
|
3801
4178
|
});
|
|
3802
4179
|
|
|
3803
4180
|
// eslint-disable-next-line func-names
|
|
3804
|
-
this.promise.then = onfulfilled => {
|
|
4181
|
+
this.promise.then = (onfulfilled) => {
|
|
3805
4182
|
let _resolve;
|
|
3806
4183
|
// eslint-disable-next-line func-names
|
|
3807
|
-
const promise = new Promise(resolve => {
|
|
4184
|
+
const promise = new Promise((resolve) => {
|
|
3808
4185
|
token.subscribe(resolve);
|
|
3809
4186
|
_resolve = resolve;
|
|
3810
4187
|
}).then(onfulfilled);
|
|
@@ -3892,7 +4269,7 @@ let CancelToken$1 = class CancelToken {
|
|
|
3892
4269
|
});
|
|
3893
4270
|
return {
|
|
3894
4271
|
token,
|
|
3895
|
-
cancel
|
|
4272
|
+
cancel,
|
|
3896
4273
|
};
|
|
3897
4274
|
}
|
|
3898
4275
|
};
|
|
@@ -3932,7 +4309,7 @@ function spread$1(callback) {
|
|
|
3932
4309
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3933
4310
|
*/
|
|
3934
4311
|
function isAxiosError$1(payload) {
|
|
3935
|
-
return utils$1.isObject(payload) &&
|
|
4312
|
+
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
3936
4313
|
}
|
|
3937
4314
|
|
|
3938
4315
|
const HttpStatusCode$1 = {
|
|
@@ -4023,10 +4400,10 @@ function createInstance(defaultConfig) {
|
|
|
4023
4400
|
const instance = bind(Axios$1.prototype.request, context);
|
|
4024
4401
|
|
|
4025
4402
|
// Copy axios.prototype to instance
|
|
4026
|
-
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
4403
|
+
utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
|
|
4027
4404
|
|
|
4028
4405
|
// Copy context to instance
|
|
4029
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
4406
|
+
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
4030
4407
|
|
|
4031
4408
|
// Factory for creating new instances
|
|
4032
4409
|
instance.create = function create(instanceConfig) {
|
|
@@ -4070,7 +4447,7 @@ axios.mergeConfig = mergeConfig$1;
|
|
|
4070
4447
|
|
|
4071
4448
|
axios.AxiosHeaders = AxiosHeaders$1;
|
|
4072
4449
|
|
|
4073
|
-
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4450
|
+
axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4074
4451
|
|
|
4075
4452
|
axios.getAdapter = adapters.getAdapter;
|
|
4076
4453
|
|
|
@@ -4097,7 +4474,7 @@ const {
|
|
|
4097
4474
|
HttpStatusCode,
|
|
4098
4475
|
formToJSON,
|
|
4099
4476
|
getAdapter,
|
|
4100
|
-
mergeConfig
|
|
4477
|
+
mergeConfig,
|
|
4101
4478
|
} = axios;
|
|
4102
4479
|
|
|
4103
4480
|
/**
|
|
@@ -4115,26 +4492,6 @@ const urlForNetwork = (network) => {
|
|
|
4115
4492
|
return 'http://insight.testnet.networks.dash.org:3001/insight-api';
|
|
4116
4493
|
}
|
|
4117
4494
|
};
|
|
4118
|
-
/**
|
|
4119
|
-
* Fetch address details from the Insight API.
|
|
4120
|
-
*
|
|
4121
|
-
* @param {InsightAddressParams} p Parameters for fetching address details.
|
|
4122
|
-
* @returns {Promise<InsightAddressResponse>} Address details fetched from the Insight API.
|
|
4123
|
-
*/
|
|
4124
|
-
const getAddress = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4125
|
-
const data = (yield axios.get(`${urlForNetwork(p.network)}/addr/${p.address}`)).data;
|
|
4126
|
-
return data;
|
|
4127
|
-
});
|
|
4128
|
-
/**
|
|
4129
|
-
* Fetch transactions associated with an address from the Insight API.
|
|
4130
|
-
*
|
|
4131
|
-
* @param {InsightAddressParams} p Parameters for fetching address transactions.
|
|
4132
|
-
* @returns {Promise<{ txs: InsightTxResponse[]; pagesTotal: number }>} Transactions associated with the address.
|
|
4133
|
-
*/
|
|
4134
|
-
const getAddressTxs = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4135
|
-
const pageNum = (p === null || p === void 0 ? void 0 : p.pageNum) || 0;
|
|
4136
|
-
return (yield axios.get(`${urlForNetwork(p.network)}/txs?address=${p.address}&pageNum=${pageNum}`)).data;
|
|
4137
|
-
});
|
|
4138
4495
|
/**
|
|
4139
4496
|
* Fetch UTXOs associated with an address from the Insight API.
|
|
4140
4497
|
*
|
|
@@ -4144,15 +4501,6 @@ const getAddressTxs = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
4144
4501
|
const getAddressUtxos = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4145
4502
|
return (yield axios.get(`${urlForNetwork(p.network)}/addr/${p.address}/utxo`)).data;
|
|
4146
4503
|
});
|
|
4147
|
-
/**
|
|
4148
|
-
* Fetch transaction details from the Insight API.
|
|
4149
|
-
*
|
|
4150
|
-
* @param {InsightTransactionParams} p Parameters for fetching transaction details.
|
|
4151
|
-
* @returns {Promise<InsightTxResponse>} Transaction details fetched from the Insight API.
|
|
4152
|
-
*/
|
|
4153
|
-
const getTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4154
|
-
return (yield axios.get(`${urlForNetwork(p.network)}/tx/${p.txid}`)).data;
|
|
4155
|
-
});
|
|
4156
4504
|
/**
|
|
4157
4505
|
* Fetch raw transaction data from the Insight API.
|
|
4158
4506
|
*
|
|
@@ -4304,7 +4652,7 @@ const defaultDashParams = {
|
|
|
4304
4652
|
network: Network.Mainnet,
|
|
4305
4653
|
phrase: '',
|
|
4306
4654
|
explorerProviders: explorerProviders,
|
|
4307
|
-
dataProviders: [
|
|
4655
|
+
dataProviders: [BlockcypherDataProviders, BitgoProviders],
|
|
4308
4656
|
rootDerivationPaths: {
|
|
4309
4657
|
[Network.Mainnet]: `m/44'/5'/0'/0/`,
|
|
4310
4658
|
[Network.Stagenet]: `m/44'/5'/0'/0/`,
|
|
@@ -4355,120 +4703,6 @@ class Client extends Client$1 {
|
|
|
4355
4703
|
validateAddress(address) {
|
|
4356
4704
|
return validateAddress(address, this.network);
|
|
4357
4705
|
}
|
|
4358
|
-
/**
|
|
4359
|
-
* Asynchronously get the balance for a DASH address.
|
|
4360
|
-
* @param {string} address The DASH address.
|
|
4361
|
-
* @returns {Promise<Balance[]>} A promise resolving to an array of balances.
|
|
4362
|
-
*/
|
|
4363
|
-
getBalance(address) {
|
|
4364
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4365
|
-
const addressResponse = yield getAddress({ network: this.network, address });
|
|
4366
|
-
const confirmed = baseAmount(addressResponse.balanceSat);
|
|
4367
|
-
const unconfirmed = baseAmount(addressResponse.unconfirmedBalanceSat);
|
|
4368
|
-
return [
|
|
4369
|
-
{
|
|
4370
|
-
asset: AssetDASH,
|
|
4371
|
-
amount: confirmed.plus(unconfirmed),
|
|
4372
|
-
},
|
|
4373
|
-
];
|
|
4374
|
-
});
|
|
4375
|
-
}
|
|
4376
|
-
/**
|
|
4377
|
-
* Asynchronously retrieves transactions for a given address.
|
|
4378
|
-
* @param {TxHistoryParams} params - Parameters for transaction retrieval.
|
|
4379
|
-
* @returns {Promise<TxsPage>} A promise resolving to a page of transactions.
|
|
4380
|
-
*/
|
|
4381
|
-
getTransactions(params) {
|
|
4382
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4383
|
-
var _a;
|
|
4384
|
-
// Extract offset and limit from parameters or set default values
|
|
4385
|
-
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
4386
|
-
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
4387
|
-
// Insight uses pages rather than offset/limit indexes, so we have to
|
|
4388
|
-
// iterate through each page within the offset/limit range.
|
|
4389
|
-
const perPage = 10;
|
|
4390
|
-
const startPage = Math.floor(offset / perPage);
|
|
4391
|
-
const endPage = Math.floor((offset + limit - 1) / perPage);
|
|
4392
|
-
const firstPageOffset = offset % perPage;
|
|
4393
|
-
const lastPageLimit = (firstPageOffset + (limit - 1)) % perPage;
|
|
4394
|
-
let totalPages = -1;
|
|
4395
|
-
let lastPageTotal = -1;
|
|
4396
|
-
let insightTxs = [];
|
|
4397
|
-
// Iterate through each page within the offset/limit range
|
|
4398
|
-
for (let pageNum = startPage; pageNum <= endPage; pageNum++) {
|
|
4399
|
-
const response = yield getAddressTxs({
|
|
4400
|
-
network: this.network,
|
|
4401
|
-
address: `${params === null || params === void 0 ? void 0 : params.address}`,
|
|
4402
|
-
pageNum,
|
|
4403
|
-
});
|
|
4404
|
-
let startIndex = 0;
|
|
4405
|
-
let endIndex = perPage - 1;
|
|
4406
|
-
if (pageNum == startPage) {
|
|
4407
|
-
startIndex = firstPageOffset;
|
|
4408
|
-
}
|
|
4409
|
-
if (pageNum === endPage) {
|
|
4410
|
-
endIndex = lastPageLimit;
|
|
4411
|
-
}
|
|
4412
|
-
insightTxs = [...insightTxs, ...response.txs.slice(startIndex, endIndex + 1)];
|
|
4413
|
-
// Insight only returns the number of pages not the total number of
|
|
4414
|
-
// transactions. If the last page is within the offset/limit range then we
|
|
4415
|
-
// can set the lastPageTotal here and avoid having to send another request,
|
|
4416
|
-
// otherwise we can fetch the last page later to determine the total
|
|
4417
|
-
// transaction count
|
|
4418
|
-
totalPages = response.pagesTotal;
|
|
4419
|
-
if (pageNum === totalPages - 1) {
|
|
4420
|
-
lastPageTotal = response.txs.length;
|
|
4421
|
-
}
|
|
4422
|
-
}
|
|
4423
|
-
// Map insight transactions to XChain transactions
|
|
4424
|
-
const txs = insightTxs.map(this.insightTxToXChainTx);
|
|
4425
|
-
// Fetch transactions count for last page if not obtained
|
|
4426
|
-
if (lastPageTotal < 0) {
|
|
4427
|
-
const lastPageResponse = yield getAddressTxs({
|
|
4428
|
-
network: this.network,
|
|
4429
|
-
address: `${params === null || params === void 0 ? void 0 : params.address}`,
|
|
4430
|
-
pageNum: totalPages - 1,
|
|
4431
|
-
});
|
|
4432
|
-
lastPageTotal = lastPageResponse.txs.length;
|
|
4433
|
-
}
|
|
4434
|
-
// Calculate total transactions count and return the page of transactions
|
|
4435
|
-
return {
|
|
4436
|
-
total: (totalPages - 1) * perPage + lastPageTotal,
|
|
4437
|
-
txs,
|
|
4438
|
-
};
|
|
4439
|
-
});
|
|
4440
|
-
}
|
|
4441
|
-
/**
|
|
4442
|
-
* Asynchronously retrieves transaction data for a given transaction ID.
|
|
4443
|
-
* @param {string} txid - The transaction ID.
|
|
4444
|
-
* @returns {Promise<Tx>} A promise resolving to the transaction data.
|
|
4445
|
-
*/
|
|
4446
|
-
getTransactionData(txid) {
|
|
4447
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4448
|
-
const tx = yield getTx({ network: this.network, txid });
|
|
4449
|
-
return this.insightTxToXChainTx(tx);
|
|
4450
|
-
});
|
|
4451
|
-
}
|
|
4452
|
-
/**
|
|
4453
|
-
* Converts an Insight transaction response to XChain transaction.
|
|
4454
|
-
* @param {InsightTxResponse} tx - The Insight transaction response.
|
|
4455
|
-
* @returns {Tx} The XChain transaction.
|
|
4456
|
-
*/
|
|
4457
|
-
insightTxToXChainTx(tx) {
|
|
4458
|
-
return {
|
|
4459
|
-
asset: AssetDASH,
|
|
4460
|
-
from: tx.vin.map((i) => ({
|
|
4461
|
-
from: i.addr,
|
|
4462
|
-
amount: assetToBase(assetAmount(i.value)),
|
|
4463
|
-
})),
|
|
4464
|
-
to: tx.vout
|
|
4465
|
-
.filter((i) => i.scriptPubKey.type !== 'nulldata')
|
|
4466
|
-
.map((i) => { var _a; return ({ to: (_a = i.scriptPubKey.addresses) === null || _a === void 0 ? void 0 : _a[0], amount: assetToBase(assetAmount(i.value)) }); }),
|
|
4467
|
-
date: new Date(tx.time * 1000),
|
|
4468
|
-
type: TxType.Transfer,
|
|
4469
|
-
hash: tx.txid,
|
|
4470
|
-
};
|
|
4471
|
-
}
|
|
4472
4706
|
/**
|
|
4473
4707
|
* Asynchronously prepares a transaction for sending assets.
|
|
4474
4708
|
* @deprecated Use `prepareTxEnhanced` instead for better UTXO selection and error handling.
|
|
@@ -4538,6 +4772,15 @@ class Client extends Client$1 {
|
|
|
4538
4772
|
// Ensure fee meets minimum requirement
|
|
4539
4773
|
return fee > TX_MIN_FEE ? fee : TX_MIN_FEE;
|
|
4540
4774
|
}
|
|
4775
|
+
getUtxoScriptHex(utxo) {
|
|
4776
|
+
var _a;
|
|
4777
|
+
// Providers may populate either scriptPubKey (Insight) or witnessUtxo.script (Blockcypher)
|
|
4778
|
+
const scriptHex = utxo.scriptPubKey || ((_a = utxo.witnessUtxo) === null || _a === void 0 ? void 0 : _a.script.toString('hex'));
|
|
4779
|
+
if (!scriptHex) {
|
|
4780
|
+
throw UtxoError.validationError(`UTXO ${utxo.hash}:${utxo.index} is missing scriptPubKey and witnessUtxo.script`);
|
|
4781
|
+
}
|
|
4782
|
+
return scriptHex;
|
|
4783
|
+
}
|
|
4541
4784
|
// ==================== Enhanced Transaction Methods ====================
|
|
4542
4785
|
/**
|
|
4543
4786
|
* Prepare transaction with enhanced UTXO selection.
|
|
@@ -4573,7 +4816,7 @@ class Client extends Client$1 {
|
|
|
4573
4816
|
const tx = new dashcore.Transaction().to(recipient, targetValue);
|
|
4574
4817
|
// Add selected inputs
|
|
4575
4818
|
for (const utxo of selectionResult.inputs) {
|
|
4576
|
-
const scriptBuffer = Buffer.from(utxo
|
|
4819
|
+
const scriptBuffer = Buffer.from(this.getUtxoScriptHex(utxo), 'hex');
|
|
4577
4820
|
const script = new dashcore.Script(scriptBuffer);
|
|
4578
4821
|
const input = new dashcore.Transaction.Input.PublicKeyHash({
|
|
4579
4822
|
prevTxId: Buffer.from(utxo.hash, 'hex'),
|
|
@@ -4634,7 +4877,7 @@ class Client extends Client$1 {
|
|
|
4634
4877
|
const tx = new dashcore.Transaction().to(recipient, maxCalc.amount);
|
|
4635
4878
|
// Add inputs
|
|
4636
4879
|
for (const utxo of maxCalc.inputs) {
|
|
4637
|
-
const scriptBuffer = Buffer.from(utxo
|
|
4880
|
+
const scriptBuffer = Buffer.from(this.getUtxoScriptHex(utxo), 'hex');
|
|
4638
4881
|
const script = new dashcore.Script(scriptBuffer);
|
|
4639
4882
|
const input = new dashcore.Transaction.Input.PublicKeyHash({
|
|
4640
4883
|
prevTxId: Buffer.from(utxo.hash, 'hex'),
|
|
@@ -4671,37 +4914,6 @@ class Client extends Client$1 {
|
|
|
4671
4914
|
}
|
|
4672
4915
|
}
|
|
4673
4916
|
|
|
4674
|
-
/**
|
|
4675
|
-
* Function to broadcast a transaction to the Dash network.
|
|
4676
|
-
*
|
|
4677
|
-
* @param {BroadcastTxParams} params Parameters for broadcasting the transaction.
|
|
4678
|
-
* @returns {Promise<TxHash>} Promise that resolves with the transaction hash if successful, or rejects with an error message if unsuccessful.
|
|
4679
|
-
*/
|
|
4680
|
-
const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4681
|
-
const uniqueId = new Date().getTime().toString(); // Generate a unique identifier for the transaction request.
|
|
4682
|
-
try {
|
|
4683
|
-
const response = (yield axios.post(`${params.nodeUrl}/tx/send`, // URL endpoint for broadcasting the transaction.
|
|
4684
|
-
{
|
|
4685
|
-
jsonrpc: '2.0',
|
|
4686
|
-
rawtx: [params.txHex], // Include the hexadecimal transaction in the request body.
|
|
4687
|
-
id: uniqueId,
|
|
4688
|
-
}, {
|
|
4689
|
-
auth: params.auth, // Include authentication credentials if provided.
|
|
4690
|
-
timeout: 30 * 1000, // Set a timeout for the request.
|
|
4691
|
-
})).data;
|
|
4692
|
-
if (response.error) {
|
|
4693
|
-
// If there is an error in the response, reject the promise with the error message.
|
|
4694
|
-
return Promise.reject(Error(`failed to broadcast a transaction: ${response.error}`));
|
|
4695
|
-
}
|
|
4696
|
-
// If no error, return the transaction ID indicating successful broadcast.
|
|
4697
|
-
return response.txid;
|
|
4698
|
-
}
|
|
4699
|
-
catch (ex) {
|
|
4700
|
-
// If an exception occurs during the request, reject the promise with the caught error message.
|
|
4701
|
-
return Promise.reject(Error(`failed to broadcast a transaction caught: ${String(ex)}`));
|
|
4702
|
-
}
|
|
4703
|
-
});
|
|
4704
|
-
|
|
4705
4917
|
const ECPair = ECPairFactory(ecc);
|
|
4706
4918
|
class ClientKeystore extends Client {
|
|
4707
4919
|
/**
|
|
@@ -4774,13 +4986,16 @@ class ClientKeystore extends Client {
|
|
|
4774
4986
|
const tx = new dashcore.Transaction(rawUnsignedTx);
|
|
4775
4987
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4776
4988
|
tx.inputs.forEach((input, index) => {
|
|
4989
|
+
var _a;
|
|
4777
4990
|
const insightUtxo = utxos.find((utxo) => {
|
|
4778
4991
|
return utxo.hash === input.prevTxId.toString('hex') && utxo.index == input.outputIndex;
|
|
4779
4992
|
});
|
|
4780
4993
|
if (!insightUtxo) {
|
|
4781
4994
|
throw new Error('Unable to match accumulative inputs with insight utxos');
|
|
4782
4995
|
}
|
|
4783
|
-
|
|
4996
|
+
// Providers may populate either scriptPubKey (Insight) or witnessUtxo.script (Blockcypher)
|
|
4997
|
+
const scriptHex = insightUtxo.scriptPubKey || ((_a = insightUtxo.witnessUtxo) === null || _a === void 0 ? void 0 : _a.script.toString('hex')) || '';
|
|
4998
|
+
const scriptBuffer = Buffer.from(scriptHex, 'hex');
|
|
4784
4999
|
const script = new dashcore.Script(scriptBuffer);
|
|
4785
5000
|
tx.inputs[index] = new dashcore.Transaction.Input.PublicKeyHash({
|
|
4786
5001
|
prevTxId: Buffer.from(insightUtxo.hash, 'hex'),
|
|
@@ -4795,11 +5010,7 @@ class ClientKeystore extends Client {
|
|
|
4795
5010
|
const dashKeys = this.getDashKeys(this.phrase, fromAddressIndex);
|
|
4796
5011
|
tx.sign(`${(_a = dashKeys.privateKey) === null || _a === void 0 ? void 0 : _a.toString('hex')}`);
|
|
4797
5012
|
const txHex = tx.checkedSerialize({});
|
|
4798
|
-
return yield broadcastTx(
|
|
4799
|
-
txHex,
|
|
4800
|
-
nodeUrl: this.nodeUrls[this.network],
|
|
4801
|
-
auth: this.nodeAuth,
|
|
4802
|
-
});
|
|
5013
|
+
return yield this.broadcastTx(txHex);
|
|
4803
5014
|
});
|
|
4804
5015
|
}
|
|
4805
5016
|
/**
|
|
@@ -4832,13 +5043,16 @@ class ClientKeystore extends Client {
|
|
|
4832
5043
|
const tx = new dashcore.Transaction(rawUnsignedTx);
|
|
4833
5044
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4834
5045
|
tx.inputs.forEach((input, index) => {
|
|
5046
|
+
var _a;
|
|
4835
5047
|
const insightUtxo = utxos.find((utxo) => {
|
|
4836
5048
|
return utxo.hash === input.prevTxId.toString('hex') && utxo.index == input.outputIndex;
|
|
4837
5049
|
});
|
|
4838
5050
|
if (!insightUtxo) {
|
|
4839
5051
|
throw new Error('Unable to match accumulative inputs with insight utxos');
|
|
4840
5052
|
}
|
|
4841
|
-
|
|
5053
|
+
// Providers may populate either scriptPubKey (Insight) or witnessUtxo.script (Blockcypher)
|
|
5054
|
+
const scriptHex = insightUtxo.scriptPubKey || ((_a = insightUtxo.witnessUtxo) === null || _a === void 0 ? void 0 : _a.script.toString('hex')) || '';
|
|
5055
|
+
const scriptBuffer = Buffer.from(scriptHex, 'hex');
|
|
4842
5056
|
const script = new dashcore.Script(scriptBuffer);
|
|
4843
5057
|
tx.inputs[index] = new dashcore.Transaction.Input.PublicKeyHash({
|
|
4844
5058
|
prevTxId: Buffer.from(insightUtxo.hash, 'hex'),
|
|
@@ -4853,11 +5067,7 @@ class ClientKeystore extends Client {
|
|
|
4853
5067
|
const dashKeys = this.getDashKeys(this.phrase, fromAddressIndex);
|
|
4854
5068
|
tx.sign(`${(_a = dashKeys.privateKey) === null || _a === void 0 ? void 0 : _a.toString('hex')}`);
|
|
4855
5069
|
const txHex = tx.checkedSerialize({});
|
|
4856
|
-
const hash = yield broadcastTx(
|
|
4857
|
-
txHex,
|
|
4858
|
-
nodeUrl: this.nodeUrls[this.network],
|
|
4859
|
-
auth: this.nodeAuth,
|
|
4860
|
-
});
|
|
5070
|
+
const hash = yield this.broadcastTx(txHex);
|
|
4861
5071
|
return { hash, maxAmount, fee };
|
|
4862
5072
|
});
|
|
4863
5073
|
}
|
|
@@ -4940,13 +5150,8 @@ class ClientLedger extends Client {
|
|
|
4940
5150
|
useTrustedInputForSegwit: false,
|
|
4941
5151
|
additionals: [],
|
|
4942
5152
|
});
|
|
4943
|
-
// Broadcast transaction
|
|
4944
|
-
const txHash = yield broadcastTx(
|
|
4945
|
-
txHex,
|
|
4946
|
-
nodeUrl: this.nodeUrls[this.network],
|
|
4947
|
-
auth: this.nodeAuth,
|
|
4948
|
-
});
|
|
4949
|
-
// Throw error if no transaction hash is received
|
|
5153
|
+
// Broadcast transaction via the configured data providers
|
|
5154
|
+
const txHash = yield this.broadcastTx(txHex);
|
|
4950
5155
|
if (!txHash) {
|
|
4951
5156
|
throw Error('No Tx hash');
|
|
4952
5157
|
}
|
|
@@ -4994,11 +5199,7 @@ class ClientLedger extends Client {
|
|
|
4994
5199
|
useTrustedInputForSegwit: false,
|
|
4995
5200
|
additionals: [],
|
|
4996
5201
|
});
|
|
4997
|
-
const hash = yield broadcastTx(
|
|
4998
|
-
txHex,
|
|
4999
|
-
nodeUrl: this.nodeUrls[this.network],
|
|
5000
|
-
auth: this.nodeAuth,
|
|
5001
|
-
});
|
|
5202
|
+
const hash = yield this.broadcastTx(txHex);
|
|
5002
5203
|
if (!hash) {
|
|
5003
5204
|
throw Error('No Tx hash');
|
|
5004
5205
|
}
|