@xchainjs/xchain-dash 2.0.8 → 2.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import { ExplorerProvider, Network, TxType, FeeOption, checkFeeBounds } from '@xchainjs/xchain-client';
2
2
  import { AssetType, baseAmount, assetToBase, assetAmount } from '@xchainjs/xchain-util';
3
3
  import { BlockcypherProvider, BlockcypherNetwork, BitgoProvider } from '@xchainjs/xchain-utxo-providers';
4
- import * as dashcore from '@dashevo/dashcore-lib';
5
- import dashcore__default from '@dashevo/dashcore-lib';
4
+ import dashcore from '@dashevo/dashcore-lib';
6
5
  import { toBitcoinJS, Client as Client$1 } from '@xchainjs/xchain-utxo';
7
6
  import * as Dash from 'bitcoinjs-lib';
8
- import accumulative from 'coinselect/accumulative';
7
+ import accumulative from 'coinselect/accumulative.js';
9
8
  import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs';
10
9
  import { getSeed } from '@xchainjs/xchain-crypto';
11
10
  import { HDKey } from '@scure/bip32';
@@ -123,6 +122,13 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
123
122
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
124
123
  };
125
124
 
125
+ /**
126
+ * Create a bound version of a function with a specified `this` context
127
+ *
128
+ * @param {Function} fn - The function to bind
129
+ * @param {*} thisArg - The value to be passed as the `this` parameter
130
+ * @returns {Function} A new function that will call the original function with the specified `this` context
131
+ */
126
132
  function bind(fn, thisArg) {
127
133
  return function wrap() {
128
134
  return fn.apply(thisArg, arguments);
@@ -131,29 +137,30 @@ function bind(fn, thisArg) {
131
137
 
132
138
  // utils is a library of generic helper functions non-specific to axios
133
139
 
134
- const {toString} = Object.prototype;
135
- const {getPrototypeOf} = Object;
140
+ const { toString } = Object.prototype;
141
+ const { getPrototypeOf } = Object;
142
+ const { iterator, toStringTag } = Symbol;
136
143
 
137
- const kindOf = (cache => thing => {
138
- const str = toString.call(thing);
139
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
144
+ const kindOf = ((cache) => (thing) => {
145
+ const str = toString.call(thing);
146
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
140
147
  })(Object.create(null));
141
148
 
142
149
  const kindOfTest = (type) => {
143
150
  type = type.toLowerCase();
144
- return (thing) => kindOf(thing) === type
151
+ return (thing) => kindOf(thing) === type;
145
152
  };
146
153
 
147
- const typeOfTest = type => thing => typeof thing === type;
154
+ const typeOfTest = (type) => (thing) => typeof thing === type;
148
155
 
149
156
  /**
150
- * Determine if a value is an Array
157
+ * Determine if a value is a non-null object
151
158
  *
152
159
  * @param {Object} val The value to test
153
160
  *
154
161
  * @returns {boolean} True if value is an Array, otherwise false
155
162
  */
156
- const {isArray} = Array;
163
+ const { isArray } = Array;
157
164
 
158
165
  /**
159
166
  * Determine if a value is undefined
@@ -162,7 +169,7 @@ const {isArray} = Array;
162
169
  *
163
170
  * @returns {boolean} True if the value is undefined, otherwise false
164
171
  */
165
- const isUndefined = typeOfTest('undefined');
172
+ const isUndefined = typeOfTest("undefined");
166
173
 
167
174
  /**
168
175
  * Determine if a value is a Buffer
@@ -172,8 +179,14 @@ const isUndefined = typeOfTest('undefined');
172
179
  * @returns {boolean} True if value is a Buffer, otherwise false
173
180
  */
174
181
  function isBuffer(val) {
175
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
176
- && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
182
+ return (
183
+ val !== null &&
184
+ !isUndefined(val) &&
185
+ val.constructor !== null &&
186
+ !isUndefined(val.constructor) &&
187
+ isFunction$1(val.constructor.isBuffer) &&
188
+ val.constructor.isBuffer(val)
189
+ );
177
190
  }
178
191
 
179
192
  /**
@@ -183,8 +196,7 @@ function isBuffer(val) {
183
196
  *
184
197
  * @returns {boolean} True if value is an ArrayBuffer, otherwise false
185
198
  */
186
- const isArrayBuffer = kindOfTest('ArrayBuffer');
187
-
199
+ const isArrayBuffer = kindOfTest("ArrayBuffer");
188
200
 
189
201
  /**
190
202
  * Determine if a value is a view on an ArrayBuffer
@@ -195,10 +207,10 @@ const isArrayBuffer = kindOfTest('ArrayBuffer');
195
207
  */
196
208
  function isArrayBufferView(val) {
197
209
  let result;
198
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
210
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
199
211
  result = ArrayBuffer.isView(val);
200
212
  } else {
201
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
213
+ result = val && val.buffer && isArrayBuffer(val.buffer);
202
214
  }
203
215
  return result;
204
216
  }
@@ -210,7 +222,7 @@ function isArrayBufferView(val) {
210
222
  *
211
223
  * @returns {boolean} True if value is a String, otherwise false
212
224
  */
213
- const isString = typeOfTest('string');
225
+ const isString = typeOfTest("string");
214
226
 
215
227
  /**
216
228
  * Determine if a value is a Function
@@ -218,7 +230,7 @@ const isString = typeOfTest('string');
218
230
  * @param {*} val The value to test
219
231
  * @returns {boolean} True if value is a Function, otherwise false
220
232
  */
221
- const isFunction = typeOfTest('function');
233
+ const isFunction$1 = typeOfTest("function");
222
234
 
223
235
  /**
224
236
  * Determine if a value is a Number
@@ -227,7 +239,7 @@ const isFunction = typeOfTest('function');
227
239
  *
228
240
  * @returns {boolean} True if value is a Number, otherwise false
229
241
  */
230
- const isNumber = typeOfTest('number');
242
+ const isNumber = typeOfTest("number");
231
243
 
232
244
  /**
233
245
  * Determine if a value is an Object
@@ -236,7 +248,7 @@ const isNumber = typeOfTest('number');
236
248
  *
237
249
  * @returns {boolean} True if value is an Object, otherwise false
238
250
  */
239
- const isObject = (thing) => thing !== null && typeof thing === 'object';
251
+ const isObject = (thing) => thing !== null && typeof thing === "object";
240
252
 
241
253
  /**
242
254
  * Determine if a value is a Boolean
@@ -244,7 +256,7 @@ const isObject = (thing) => thing !== null && typeof thing === 'object';
244
256
  * @param {*} thing The value to test
245
257
  * @returns {boolean} True if value is a Boolean, otherwise false
246
258
  */
247
- const isBoolean = thing => thing === true || thing === false;
259
+ const isBoolean = (thing) => thing === true || thing === false;
248
260
 
249
261
  /**
250
262
  * Determine if a value is a plain Object
@@ -254,12 +266,42 @@ const isBoolean = thing => thing === true || thing === false;
254
266
  * @returns {boolean} True if value is a plain Object, otherwise false
255
267
  */
256
268
  const isPlainObject = (val) => {
257
- if (kindOf(val) !== 'object') {
269
+ if (kindOf(val) !== "object") {
258
270
  return false;
259
271
  }
260
272
 
261
273
  const prototype = getPrototypeOf(val);
262
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
274
+ return (
275
+ (prototype === null ||
276
+ prototype === Object.prototype ||
277
+ Object.getPrototypeOf(prototype) === null) &&
278
+ !(toStringTag in val) &&
279
+ !(iterator in val)
280
+ );
281
+ };
282
+
283
+ /**
284
+ * Determine if a value is an empty object (safely handles Buffers)
285
+ *
286
+ * @param {*} val The value to test
287
+ *
288
+ * @returns {boolean} True if value is an empty object, otherwise false
289
+ */
290
+ const isEmptyObject = (val) => {
291
+ // Early return for non-objects or Buffers to prevent RangeError
292
+ if (!isObject(val) || isBuffer(val)) {
293
+ return false;
294
+ }
295
+
296
+ try {
297
+ return (
298
+ Object.keys(val).length === 0 &&
299
+ Object.getPrototypeOf(val) === Object.prototype
300
+ );
301
+ } catch (e) {
302
+ // Fallback for any other objects that might cause RangeError with Object.keys()
303
+ return false;
304
+ }
263
305
  };
264
306
 
265
307
  /**
@@ -269,7 +311,7 @@ const isPlainObject = (val) => {
269
311
  *
270
312
  * @returns {boolean} True if value is a Date, otherwise false
271
313
  */
272
- const isDate = kindOfTest('Date');
314
+ const isDate = kindOfTest("Date");
273
315
 
274
316
  /**
275
317
  * Determine if a value is a File
@@ -278,7 +320,7 @@ const isDate = kindOfTest('Date');
278
320
  *
279
321
  * @returns {boolean} True if value is a File, otherwise false
280
322
  */
281
- const isFile = kindOfTest('File');
323
+ const isFile = kindOfTest("File");
282
324
 
283
325
  /**
284
326
  * Determine if a value is a Blob
@@ -287,7 +329,7 @@ const isFile = kindOfTest('File');
287
329
  *
288
330
  * @returns {boolean} True if value is a Blob, otherwise false
289
331
  */
290
- const isBlob = kindOfTest('Blob');
332
+ const isBlob = kindOfTest("Blob");
291
333
 
292
334
  /**
293
335
  * Determine if a value is a FileList
@@ -296,7 +338,7 @@ const isBlob = kindOfTest('Blob');
296
338
  *
297
339
  * @returns {boolean} True if value is a File, otherwise false
298
340
  */
299
- const isFileList = kindOfTest('FileList');
341
+ const isFileList = kindOfTest("FileList");
300
342
 
301
343
  /**
302
344
  * Determine if a value is a Stream
@@ -305,7 +347,7 @@ const isFileList = kindOfTest('FileList');
305
347
  *
306
348
  * @returns {boolean} True if value is a Stream, otherwise false
307
349
  */
308
- const isStream = (val) => isObject(val) && isFunction(val.pipe);
350
+ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
309
351
 
310
352
  /**
311
353
  * Determine if a value is a FormData
@@ -316,15 +358,16 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
316
358
  */
317
359
  const isFormData = (thing) => {
318
360
  let kind;
319
- return thing && (
320
- (typeof FormData === 'function' && thing instanceof FormData) || (
321
- isFunction(thing.append) && (
322
- (kind = kindOf(thing)) === 'formdata' ||
323
- // detect form-data instance
324
- (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
325
- )
326
- )
327
- )
361
+ return (
362
+ thing &&
363
+ ((typeof FormData === "function" && thing instanceof FormData) ||
364
+ (isFunction$1(thing.append) &&
365
+ ((kind = kindOf(thing)) === "formdata" ||
366
+ // detect form-data instance
367
+ (kind === "object" &&
368
+ isFunction$1(thing.toString) &&
369
+ thing.toString() === "[object FormData]"))))
370
+ );
328
371
  };
329
372
 
330
373
  /**
@@ -334,9 +377,14 @@ const isFormData = (thing) => {
334
377
  *
335
378
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
336
379
  */
337
- const isURLSearchParams = kindOfTest('URLSearchParams');
380
+ const isURLSearchParams = kindOfTest("URLSearchParams");
338
381
 
339
- const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
382
+ const [isReadableStream, isRequest, isResponse, isHeaders] = [
383
+ "ReadableStream",
384
+ "Request",
385
+ "Response",
386
+ "Headers",
387
+ ].map(kindOfTest);
340
388
 
341
389
  /**
342
390
  * Trim excess whitespace off the beginning and end of a string
@@ -345,8 +393,8 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream',
345
393
  *
346
394
  * @returns {String} The String freed of excess whitespace
347
395
  */
348
- const trim = (str) => str.trim ?
349
- str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
396
+ const trim = (str) =>
397
+ str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
350
398
 
351
399
  /**
352
400
  * Iterate over an Array or an Object invoking a function for each item.
@@ -357,15 +405,16 @@ const trim = (str) => str.trim ?
357
405
  * If 'obj' is an Object callback will be called passing
358
406
  * the value, key, and complete object for each property.
359
407
  *
360
- * @param {Object|Array} obj The object to iterate
408
+ * @param {Object|Array<unknown>} obj The object to iterate
361
409
  * @param {Function} fn The callback to invoke for each item
362
410
  *
363
- * @param {Boolean} [allOwnKeys = false]
411
+ * @param {Object} [options]
412
+ * @param {Boolean} [options.allOwnKeys = false]
364
413
  * @returns {any}
365
414
  */
366
- function forEach(obj, fn, {allOwnKeys = false} = {}) {
415
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
367
416
  // Don't bother if no value provided
368
- if (obj === null || typeof obj === 'undefined') {
417
+ if (obj === null || typeof obj === "undefined") {
369
418
  return;
370
419
  }
371
420
 
@@ -373,7 +422,7 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
373
422
  let l;
374
423
 
375
424
  // Force an array if not already something iterable
376
- if (typeof obj !== 'object') {
425
+ if (typeof obj !== "object") {
377
426
  /*eslint no-param-reassign:0*/
378
427
  obj = [obj];
379
428
  }
@@ -384,8 +433,15 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
384
433
  fn.call(null, obj[i], i, obj);
385
434
  }
386
435
  } else {
436
+ // Buffer check
437
+ if (isBuffer(obj)) {
438
+ return;
439
+ }
440
+
387
441
  // Iterate over object keys
388
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
442
+ const keys = allOwnKeys
443
+ ? Object.getOwnPropertyNames(obj)
444
+ : Object.keys(obj);
389
445
  const len = keys.length;
390
446
  let key;
391
447
 
@@ -397,6 +453,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
397
453
  }
398
454
 
399
455
  function findKey(obj, key) {
456
+ if (isBuffer(obj)) {
457
+ return null;
458
+ }
459
+
400
460
  key = key.toLowerCase();
401
461
  const keys = Object.keys(obj);
402
462
  let i = keys.length;
@@ -413,10 +473,15 @@ function findKey(obj, key) {
413
473
  const _global = (() => {
414
474
  /*eslint no-undef:0*/
415
475
  if (typeof globalThis !== "undefined") return globalThis;
416
- return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
476
+ return typeof self !== "undefined"
477
+ ? self
478
+ : typeof window !== "undefined"
479
+ ? window
480
+ : global;
417
481
  })();
418
482
 
419
- const isContextDefined = (context) => !isUndefined(context) && context !== _global;
483
+ const isContextDefined = (context) =>
484
+ !isUndefined(context) && context !== _global;
420
485
 
421
486
  /**
422
487
  * Accepts varargs expecting each argument to be an object, then
@@ -428,7 +493,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
428
493
  * Example:
429
494
  *
430
495
  * ```js
431
- * var result = merge({foo: 123}, {foo: 456});
496
+ * const result = merge({foo: 123}, {foo: 456});
432
497
  * console.log(result.foo); // outputs 456
433
498
  * ```
434
499
  *
@@ -437,17 +502,22 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
437
502
  * @returns {Object} Result of all merge properties
438
503
  */
439
504
  function merge(/* obj1, obj2, obj3, ... */) {
440
- const {caseless} = isContextDefined(this) && this || {};
505
+ const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
441
506
  const result = {};
442
507
  const assignValue = (val, key) => {
443
- const targetKey = caseless && findKey(result, key) || key;
508
+ // Skip dangerous property names to prevent prototype pollution
509
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
510
+ return;
511
+ }
512
+
513
+ const targetKey = (caseless && findKey(result, key)) || key;
444
514
  if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
445
515
  result[targetKey] = merge(result[targetKey], val);
446
516
  } else if (isPlainObject(val)) {
447
517
  result[targetKey] = merge({}, val);
448
518
  } else if (isArray(val)) {
449
519
  result[targetKey] = val.slice();
450
- } else {
520
+ } else if (!skipUndefined || !isUndefined(val)) {
451
521
  result[targetKey] = val;
452
522
  }
453
523
  };
@@ -465,17 +535,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
465
535
  * @param {Object} b The object to copy properties from
466
536
  * @param {Object} thisArg The object to bind function to
467
537
  *
468
- * @param {Boolean} [allOwnKeys]
538
+ * @param {Object} [options]
539
+ * @param {Boolean} [options.allOwnKeys]
469
540
  * @returns {Object} The resulting value of object a
470
541
  */
471
- const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
472
- forEach(b, (val, key) => {
473
- if (thisArg && isFunction(val)) {
474
- a[key] = bind(val, thisArg);
475
- } else {
476
- a[key] = val;
477
- }
478
- }, {allOwnKeys});
542
+ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
543
+ forEach(
544
+ b,
545
+ (val, key) => {
546
+ if (thisArg && isFunction$1(val)) {
547
+ Object.defineProperty(a, key, {
548
+ value: bind(val, thisArg),
549
+ writable: true,
550
+ enumerable: true,
551
+ configurable: true,
552
+ });
553
+ } else {
554
+ Object.defineProperty(a, key, {
555
+ value: val,
556
+ writable: true,
557
+ enumerable: true,
558
+ configurable: true,
559
+ });
560
+ }
561
+ },
562
+ { allOwnKeys },
563
+ );
479
564
  return a;
480
565
  };
481
566
 
@@ -487,7 +572,7 @@ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
487
572
  * @returns {string} content value without BOM
488
573
  */
489
574
  const stripBOM = (content) => {
490
- if (content.charCodeAt(0) === 0xFEFF) {
575
+ if (content.charCodeAt(0) === 0xfeff) {
491
576
  content = content.slice(1);
492
577
  }
493
578
  return content;
@@ -503,10 +588,18 @@ const stripBOM = (content) => {
503
588
  * @returns {void}
504
589
  */
505
590
  const inherits = (constructor, superConstructor, props, descriptors) => {
506
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
507
- constructor.prototype.constructor = constructor;
508
- Object.defineProperty(constructor, 'super', {
509
- value: superConstructor.prototype
591
+ constructor.prototype = Object.create(
592
+ superConstructor.prototype,
593
+ descriptors,
594
+ );
595
+ Object.defineProperty(constructor.prototype, "constructor", {
596
+ value: constructor,
597
+ writable: true,
598
+ enumerable: false,
599
+ configurable: true,
600
+ });
601
+ Object.defineProperty(constructor, "super", {
602
+ value: superConstructor.prototype,
510
603
  });
511
604
  props && Object.assign(constructor.prototype, props);
512
605
  };
@@ -535,13 +628,20 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
535
628
  i = props.length;
536
629
  while (i-- > 0) {
537
630
  prop = props[i];
538
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
631
+ if (
632
+ (!propFilter || propFilter(prop, sourceObj, destObj)) &&
633
+ !merged[prop]
634
+ ) {
539
635
  destObj[prop] = sourceObj[prop];
540
636
  merged[prop] = true;
541
637
  }
542
638
  }
543
639
  sourceObj = filter !== false && getPrototypeOf(sourceObj);
544
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
640
+ } while (
641
+ sourceObj &&
642
+ (!filter || filter(sourceObj, destObj)) &&
643
+ sourceObj !== Object.prototype
644
+ );
545
645
 
546
646
  return destObj;
547
647
  };
@@ -565,7 +665,6 @@ const endsWith = (str, searchString, position) => {
565
665
  return lastIndex !== -1 && lastIndex === position;
566
666
  };
567
667
 
568
-
569
668
  /**
570
669
  * Returns new array from array like object or null if failed
571
670
  *
@@ -594,12 +693,12 @@ const toArray = (thing) => {
594
693
  * @returns {Array}
595
694
  */
596
695
  // eslint-disable-next-line func-names
597
- const isTypedArray = (TypedArray => {
696
+ const isTypedArray = ((TypedArray) => {
598
697
  // eslint-disable-next-line func-names
599
- return thing => {
698
+ return (thing) => {
600
699
  return TypedArray && thing instanceof TypedArray;
601
700
  };
602
- })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
701
+ })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
603
702
 
604
703
  /**
605
704
  * For each entry in the object, call the function with the key and value.
@@ -610,13 +709,13 @@ const isTypedArray = (TypedArray => {
610
709
  * @returns {void}
611
710
  */
612
711
  const forEachEntry = (obj, fn) => {
613
- const generator = obj && obj[Symbol.iterator];
712
+ const generator = obj && obj[iterator];
614
713
 
615
- const iterator = generator.call(obj);
714
+ const _iterator = generator.call(obj);
616
715
 
617
716
  let result;
618
717
 
619
- while ((result = iterator.next()) && !result.done) {
718
+ while ((result = _iterator.next()) && !result.done) {
620
719
  const pair = result.value;
621
720
  fn.call(obj, pair[0], pair[1]);
622
721
  }
@@ -642,18 +741,22 @@ const matchAll = (regExp, str) => {
642
741
  };
643
742
 
644
743
  /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
645
- const isHTMLForm = kindOfTest('HTMLFormElement');
744
+ const isHTMLForm = kindOfTest("HTMLFormElement");
646
745
 
647
- const toCamelCase = str => {
648
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
649
- function replacer(m, p1, p2) {
746
+ const toCamelCase = (str) => {
747
+ return str
748
+ .toLowerCase()
749
+ .replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
650
750
  return p1.toUpperCase() + p2;
651
- }
652
- );
751
+ });
653
752
  };
654
753
 
655
754
  /* Creating a function that will check if an object has a property. */
656
- const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
755
+ const hasOwnProperty = (
756
+ ({ hasOwnProperty }) =>
757
+ (obj, prop) =>
758
+ hasOwnProperty.call(obj, prop)
759
+ )(Object.prototype);
657
760
 
658
761
  /**
659
762
  * Determine if a value is a RegExp object
@@ -662,7 +765,7 @@ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call
662
765
  *
663
766
  * @returns {boolean} True if value is a RegExp object, otherwise false
664
767
  */
665
- const isRegExp = kindOfTest('RegExp');
768
+ const isRegExp = kindOfTest("RegExp");
666
769
 
667
770
  const reduceDescriptors = (obj, reducer) => {
668
771
  const descriptors = Object.getOwnPropertyDescriptors(obj);
@@ -686,24 +789,27 @@ const reduceDescriptors = (obj, reducer) => {
686
789
  const freezeMethods = (obj) => {
687
790
  reduceDescriptors(obj, (descriptor, name) => {
688
791
  // skip restricted props in strict mode
689
- if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
792
+ if (
793
+ isFunction$1(obj) &&
794
+ ["arguments", "caller", "callee"].indexOf(name) !== -1
795
+ ) {
690
796
  return false;
691
797
  }
692
798
 
693
799
  const value = obj[name];
694
800
 
695
- if (!isFunction(value)) return;
801
+ if (!isFunction$1(value)) return;
696
802
 
697
803
  descriptor.enumerable = false;
698
804
 
699
- if ('writable' in descriptor) {
805
+ if ("writable" in descriptor) {
700
806
  descriptor.writable = false;
701
807
  return;
702
808
  }
703
809
 
704
810
  if (!descriptor.set) {
705
811
  descriptor.set = () => {
706
- throw Error('Can not rewrite read-only method \'' + name + '\'');
812
+ throw Error("Can not rewrite read-only method '" + name + "'");
707
813
  };
708
814
  }
709
815
  });
@@ -713,12 +819,14 @@ const toObjectSet = (arrayOrString, delimiter) => {
713
819
  const obj = {};
714
820
 
715
821
  const define = (arr) => {
716
- arr.forEach(value => {
822
+ arr.forEach((value) => {
717
823
  obj[value] = true;
718
824
  });
719
825
  };
720
826
 
721
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
827
+ isArray(arrayOrString)
828
+ ? define(arrayOrString)
829
+ : define(String(arrayOrString).split(delimiter));
722
830
 
723
831
  return obj;
724
832
  };
@@ -726,7 +834,9 @@ const toObjectSet = (arrayOrString, delimiter) => {
726
834
  const noop = () => {};
727
835
 
728
836
  const toFiniteNumber = (value, defaultValue) => {
729
- return value != null && Number.isFinite(value = +value) ? value : defaultValue;
837
+ return value != null && Number.isFinite((value = +value))
838
+ ? value
839
+ : defaultValue;
730
840
  };
731
841
 
732
842
  /**
@@ -737,20 +847,29 @@ const toFiniteNumber = (value, defaultValue) => {
737
847
  * @returns {boolean}
738
848
  */
739
849
  function isSpecCompliantForm(thing) {
740
- return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
850
+ return !!(
851
+ thing &&
852
+ isFunction$1(thing.append) &&
853
+ thing[toStringTag] === "FormData" &&
854
+ thing[iterator]
855
+ );
741
856
  }
742
857
 
743
858
  const toJSONObject = (obj) => {
744
859
  const stack = new Array(10);
745
860
 
746
861
  const visit = (source, i) => {
747
-
748
862
  if (isObject(source)) {
749
863
  if (stack.indexOf(source) >= 0) {
750
864
  return;
751
865
  }
752
866
 
753
- if(!('toJSON' in source)) {
867
+ //Buffer check
868
+ if (isBuffer(source)) {
869
+ return source;
870
+ }
871
+
872
+ if (!("toJSON" in source)) {
754
873
  stack[i] = source;
755
874
  const target = isArray(source) ? [] : {};
756
875
 
@@ -771,10 +890,13 @@ const toJSONObject = (obj) => {
771
890
  return visit(obj, 0);
772
891
  };
773
892
 
774
- const isAsyncFn = kindOfTest('AsyncFunction');
893
+ const isAsyncFn = kindOfTest("AsyncFunction");
775
894
 
776
895
  const isThenable = (thing) =>
777
- thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
896
+ thing &&
897
+ (isObject(thing) || isFunction$1(thing)) &&
898
+ isFunction$1(thing.then) &&
899
+ isFunction$1(thing.catch);
778
900
 
779
901
  // original code
780
902
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
@@ -784,28 +906,35 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
784
906
  return setImmediate;
785
907
  }
786
908
 
787
- return postMessageSupported ? ((token, callbacks) => {
788
- _global.addEventListener("message", ({source, data}) => {
789
- if (source === _global && data === token) {
790
- callbacks.length && callbacks.shift()();
791
- }
792
- }, false);
909
+ return postMessageSupported
910
+ ? ((token, callbacks) => {
911
+ _global.addEventListener(
912
+ "message",
913
+ ({ source, data }) => {
914
+ if (source === _global && data === token) {
915
+ callbacks.length && callbacks.shift()();
916
+ }
917
+ },
918
+ false,
919
+ );
793
920
 
794
- return (cb) => {
795
- callbacks.push(cb);
796
- _global.postMessage(token, "*");
797
- }
798
- })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
799
- })(
800
- typeof setImmediate === 'function',
801
- isFunction(_global.postMessage)
802
- );
921
+ return (cb) => {
922
+ callbacks.push(cb);
923
+ _global.postMessage(token, "*");
924
+ };
925
+ })(`axios@${Math.random()}`, [])
926
+ : (cb) => setTimeout(cb);
927
+ })(typeof setImmediate === "function", isFunction$1(_global.postMessage));
803
928
 
804
- const asap = typeof queueMicrotask !== 'undefined' ?
805
- queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
929
+ const asap =
930
+ typeof queueMicrotask !== "undefined"
931
+ ? queueMicrotask.bind(_global)
932
+ : (typeof process !== "undefined" && process.nextTick) || _setImmediate;
806
933
 
807
934
  // *********************
808
935
 
936
+ const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
937
+
809
938
  var utils$1 = {
810
939
  isArray,
811
940
  isArrayBuffer,
@@ -817,6 +946,7 @@ var utils$1 = {
817
946
  isBoolean,
818
947
  isObject,
819
948
  isPlainObject,
949
+ isEmptyObject,
820
950
  isReadableStream,
821
951
  isRequest,
822
952
  isResponse,
@@ -826,7 +956,7 @@ var utils$1 = {
826
956
  isFile,
827
957
  isBlob,
828
958
  isRegExp,
829
- isFunction,
959
+ isFunction: isFunction$1,
830
960
  isStream,
831
961
  isURLSearchParams,
832
962
  isTypedArray,
@@ -861,106 +991,77 @@ var utils$1 = {
861
991
  isAsyncFn,
862
992
  isThenable,
863
993
  setImmediate: _setImmediate,
864
- asap
994
+ asap,
995
+ isIterable,
865
996
  };
866
997
 
867
- /**
868
- * Create an Error with the specified message, config, error code, request and response.
869
- *
870
- * @param {string} message The error message.
871
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
872
- * @param {Object} [config] The config.
873
- * @param {Object} [request] The request.
874
- * @param {Object} [response] The response.
875
- *
876
- * @returns {Error} The created error.
877
- */
878
- function AxiosError(message, code, config, request, response) {
879
- Error.call(this);
998
+ class AxiosError extends Error {
999
+ static from(error, code, config, request, response, customProps) {
1000
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1001
+ axiosError.cause = error;
1002
+ axiosError.name = error.name;
1003
+ customProps && Object.assign(axiosError, customProps);
1004
+ return axiosError;
1005
+ }
880
1006
 
881
- if (Error.captureStackTrace) {
882
- Error.captureStackTrace(this, this.constructor);
883
- } else {
884
- this.stack = (new Error()).stack;
885
- }
1007
+ /**
1008
+ * Create an Error with the specified message, config, error code, request and response.
1009
+ *
1010
+ * @param {string} message The error message.
1011
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
1012
+ * @param {Object} [config] The config.
1013
+ * @param {Object} [request] The request.
1014
+ * @param {Object} [response] The response.
1015
+ *
1016
+ * @returns {Error} The created error.
1017
+ */
1018
+ constructor(message, code, config, request, response) {
1019
+ super(message);
1020
+ this.name = 'AxiosError';
1021
+ this.isAxiosError = true;
1022
+ code && (this.code = code);
1023
+ config && (this.config = config);
1024
+ request && (this.request = request);
1025
+ if (response) {
1026
+ this.response = response;
1027
+ this.status = response.status;
1028
+ }
1029
+ }
886
1030
 
887
- this.message = message;
888
- this.name = 'AxiosError';
889
- code && (this.code = code);
890
- config && (this.config = config);
891
- request && (this.request = request);
892
- if (response) {
893
- this.response = response;
894
- this.status = response.status ? response.status : null;
895
- }
1031
+ toJSON() {
1032
+ return {
1033
+ // Standard
1034
+ message: this.message,
1035
+ name: this.name,
1036
+ // Microsoft
1037
+ description: this.description,
1038
+ number: this.number,
1039
+ // Mozilla
1040
+ fileName: this.fileName,
1041
+ lineNumber: this.lineNumber,
1042
+ columnNumber: this.columnNumber,
1043
+ stack: this.stack,
1044
+ // Axios
1045
+ config: utils$1.toJSONObject(this.config),
1046
+ code: this.code,
1047
+ status: this.status,
1048
+ };
1049
+ }
896
1050
  }
897
1051
 
898
- utils$1.inherits(AxiosError, Error, {
899
- toJSON: function toJSON() {
900
- return {
901
- // Standard
902
- message: this.message,
903
- name: this.name,
904
- // Microsoft
905
- description: this.description,
906
- number: this.number,
907
- // Mozilla
908
- fileName: this.fileName,
909
- lineNumber: this.lineNumber,
910
- columnNumber: this.columnNumber,
911
- stack: this.stack,
912
- // Axios
913
- config: utils$1.toJSONObject(this.config),
914
- code: this.code,
915
- status: this.status
916
- };
917
- }
918
- });
919
-
920
- const prototype$1 = AxiosError.prototype;
921
- const descriptors = {};
922
-
923
- [
924
- 'ERR_BAD_OPTION_VALUE',
925
- 'ERR_BAD_OPTION',
926
- 'ECONNABORTED',
927
- 'ETIMEDOUT',
928
- 'ERR_NETWORK',
929
- 'ERR_FR_TOO_MANY_REDIRECTS',
930
- 'ERR_DEPRECATED',
931
- 'ERR_BAD_RESPONSE',
932
- 'ERR_BAD_REQUEST',
933
- 'ERR_CANCELED',
934
- 'ERR_NOT_SUPPORT',
935
- 'ERR_INVALID_URL'
936
- // eslint-disable-next-line func-names
937
- ].forEach(code => {
938
- descriptors[code] = {value: code};
939
- });
940
-
941
- Object.defineProperties(AxiosError, descriptors);
942
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
943
-
944
- // eslint-disable-next-line func-names
945
- AxiosError.from = (error, code, config, request, response, customProps) => {
946
- const axiosError = Object.create(prototype$1);
947
-
948
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
949
- return obj !== Error.prototype;
950
- }, prop => {
951
- return prop !== 'isAxiosError';
952
- });
953
-
954
- AxiosError.call(axiosError, error.message, code, config, request, response);
955
-
956
- axiosError.cause = error;
957
-
958
- axiosError.name = error.name;
959
-
960
- customProps && Object.assign(axiosError, customProps);
961
-
962
- return axiosError;
963
- };
1052
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1053
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1054
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1055
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
1056
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
1057
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
1058
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1059
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
1060
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1061
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1062
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
1063
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1064
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
964
1065
 
965
1066
  // eslint-disable-next-line strict
966
1067
  var httpAdapter = null;
@@ -1080,6 +1181,10 @@ function toFormData(obj, formData, options) {
1080
1181
  return value.toISOString();
1081
1182
  }
1082
1183
 
1184
+ if (utils$1.isBoolean(value)) {
1185
+ return value.toString();
1186
+ }
1187
+
1083
1188
  if (!useBlob && utils$1.isBlob(value)) {
1084
1189
  throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1085
1190
  }
@@ -1242,9 +1347,7 @@ function encode(val) {
1242
1347
  replace(/%3A/gi, ':').
1243
1348
  replace(/%24/g, '$').
1244
1349
  replace(/%2C/gi, ',').
1245
- replace(/%20/g, '+').
1246
- replace(/%5B/gi, '[').
1247
- replace(/%5D/gi, ']');
1350
+ replace(/%20/g, '+');
1248
1351
  }
1249
1352
 
1250
1353
  /**
@@ -1257,29 +1360,26 @@ function encode(val) {
1257
1360
  * @returns {string} The formatted url
1258
1361
  */
1259
1362
  function buildURL(url, params, options) {
1260
- /*eslint no-param-reassign:0*/
1261
1363
  if (!params) {
1262
1364
  return url;
1263
1365
  }
1264
-
1366
+
1265
1367
  const _encode = options && options.encode || encode;
1266
1368
 
1267
- if (utils$1.isFunction(options)) {
1268
- options = {
1269
- serialize: options
1270
- };
1271
- }
1369
+ const _options = utils$1.isFunction(options) ? {
1370
+ serialize: options
1371
+ } : options;
1272
1372
 
1273
- const serializeFn = options && options.serialize;
1373
+ const serializeFn = _options && _options.serialize;
1274
1374
 
1275
1375
  let serializedParams;
1276
1376
 
1277
1377
  if (serializeFn) {
1278
- serializedParams = serializeFn(params, options);
1378
+ serializedParams = serializeFn(params, _options);
1279
1379
  } else {
1280
1380
  serializedParams = utils$1.isURLSearchParams(params) ?
1281
1381
  params.toString() :
1282
- new AxiosURLSearchParams(params, options).toString(_encode);
1382
+ new AxiosURLSearchParams(params, _options).toString(_encode);
1283
1383
  }
1284
1384
 
1285
1385
  if (serializedParams) {
@@ -1304,6 +1404,7 @@ class InterceptorManager {
1304
1404
  *
1305
1405
  * @param {Function} fulfilled The function to handle `then` for a `Promise`
1306
1406
  * @param {Function} rejected The function to handle `reject` for a `Promise`
1407
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
1307
1408
  *
1308
1409
  * @return {Number} An ID used to remove interceptor later
1309
1410
  */
@@ -1322,7 +1423,7 @@ class InterceptorManager {
1322
1423
  *
1323
1424
  * @param {Number} id The ID that was returned by `use`
1324
1425
  *
1325
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1426
+ * @returns {void}
1326
1427
  */
1327
1428
  eject(id) {
1328
1429
  if (this.handlers[id]) {
@@ -1363,7 +1464,8 @@ class InterceptorManager {
1363
1464
  var transitionalDefaults = {
1364
1465
  silentJSONParsing: true,
1365
1466
  forcedJSONParsing: true,
1366
- clarifyTimeoutError: false
1467
+ clarifyTimeoutError: false,
1468
+ legacyInterceptorReqResOrdering: true
1367
1469
  };
1368
1470
 
1369
1471
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -1441,7 +1543,7 @@ var platform = {
1441
1543
  };
1442
1544
 
1443
1545
  function toURLEncodedForm(data, options) {
1444
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1546
+ return toFormData(data, new platform.classes.URLSearchParams(), {
1445
1547
  visitor: function(value, key, path, helpers) {
1446
1548
  if (platform.isNode && utils$1.isBuffer(value)) {
1447
1549
  this.append(key, value.toString('base64'));
@@ -1449,8 +1551,9 @@ function toURLEncodedForm(data, options) {
1449
1551
  }
1450
1552
 
1451
1553
  return helpers.defaultVisitor.apply(this, arguments);
1452
- }
1453
- }, options));
1554
+ },
1555
+ ...options
1556
+ });
1454
1557
  }
1455
1558
 
1456
1559
  /**
@@ -1646,7 +1749,7 @@ const defaults = {
1646
1749
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
1647
1750
 
1648
1751
  try {
1649
- return JSON.parse(data);
1752
+ return JSON.parse(data, this.parseReviver);
1650
1753
  } catch (e) {
1651
1754
  if (strictJSONParsing) {
1652
1755
  if (e.name === 'SyntaxError') {
@@ -1842,10 +1945,18 @@ class AxiosHeaders {
1842
1945
  setHeaders(header, valueOrRewrite);
1843
1946
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1844
1947
  setHeaders(parseHeaders(header), valueOrRewrite);
1845
- } else if (utils$1.isHeaders(header)) {
1846
- for (const [key, value] of header.entries()) {
1847
- setHeader(value, key, rewrite);
1948
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1949
+ let obj = {}, dest, key;
1950
+ for (const entry of header) {
1951
+ if (!utils$1.isArray(entry)) {
1952
+ throw TypeError('Object iterator must return a key-value pair');
1953
+ }
1954
+
1955
+ obj[key = entry[0]] = (dest = obj[key]) ?
1956
+ (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
1848
1957
  }
1958
+
1959
+ setHeaders(obj, valueOrRewrite);
1849
1960
  } else {
1850
1961
  header != null && setHeader(valueOrRewrite, header, rewrite);
1851
1962
  }
@@ -1987,6 +2098,10 @@ class AxiosHeaders {
1987
2098
  return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1988
2099
  }
1989
2100
 
2101
+ getSetCookie() {
2102
+ return this.get("set-cookie") || [];
2103
+ }
2104
+
1990
2105
  get [Symbol.toStringTag]() {
1991
2106
  return 'AxiosHeaders';
1992
2107
  }
@@ -2068,25 +2183,23 @@ function isCancel(value) {
2068
2183
  return !!(value && value.__CANCEL__);
2069
2184
  }
2070
2185
 
2071
- /**
2072
- * A `CanceledError` is an object that is thrown when an operation is canceled.
2073
- *
2074
- * @param {string=} message The message.
2075
- * @param {Object=} config The config.
2076
- * @param {Object=} request The request.
2077
- *
2078
- * @returns {CanceledError} The created error.
2079
- */
2080
- function CanceledError(message, config, request) {
2081
- // eslint-disable-next-line no-eq-null,eqeqeq
2082
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2083
- this.name = 'CanceledError';
2186
+ class CanceledError extends AxiosError {
2187
+ /**
2188
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2189
+ *
2190
+ * @param {string=} message The message.
2191
+ * @param {Object=} config The config.
2192
+ * @param {Object=} request The request.
2193
+ *
2194
+ * @returns {CanceledError} The created error.
2195
+ */
2196
+ constructor(message, config, request) {
2197
+ super(message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2198
+ this.name = 'CanceledError';
2199
+ this.__CANCEL__ = true;
2200
+ }
2084
2201
  }
2085
2202
 
2086
- utils$1.inherits(CanceledError, AxiosError, {
2087
- __CANCEL__: true
2088
- });
2089
-
2090
2203
  /**
2091
2204
  * Resolve or reject a Promise based on response status.
2092
2205
  *
@@ -2187,7 +2300,7 @@ function throttle(fn, freq) {
2187
2300
  clearTimeout(timer);
2188
2301
  timer = null;
2189
2302
  }
2190
- fn.apply(null, args);
2303
+ fn(...args);
2191
2304
  };
2192
2305
 
2193
2306
  const throttled = (...args) => {
@@ -2269,27 +2382,38 @@ var cookies = platform.hasStandardBrowserEnv ?
2269
2382
 
2270
2383
  // Standard browser envs support document.cookie
2271
2384
  {
2272
- write(name, value, expires, path, domain, secure) {
2273
- const cookie = [name + '=' + encodeURIComponent(value)];
2274
-
2275
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2276
-
2277
- utils$1.isString(path) && cookie.push('path=' + path);
2385
+ write(name, value, expires, path, domain, secure, sameSite) {
2386
+ if (typeof document === 'undefined') return;
2278
2387
 
2279
- utils$1.isString(domain) && cookie.push('domain=' + domain);
2388
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
2280
2389
 
2281
- secure === true && cookie.push('secure');
2390
+ if (utils$1.isNumber(expires)) {
2391
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
2392
+ }
2393
+ if (utils$1.isString(path)) {
2394
+ cookie.push(`path=${path}`);
2395
+ }
2396
+ if (utils$1.isString(domain)) {
2397
+ cookie.push(`domain=${domain}`);
2398
+ }
2399
+ if (secure === true) {
2400
+ cookie.push('secure');
2401
+ }
2402
+ if (utils$1.isString(sameSite)) {
2403
+ cookie.push(`SameSite=${sameSite}`);
2404
+ }
2282
2405
 
2283
2406
  document.cookie = cookie.join('; ');
2284
2407
  },
2285
2408
 
2286
2409
  read(name) {
2287
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2288
- return (match ? decodeURIComponent(match[3]) : null);
2410
+ if (typeof document === 'undefined') return null;
2411
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2412
+ return match ? decodeURIComponent(match[1]) : null;
2289
2413
  },
2290
2414
 
2291
2415
  remove(name) {
2292
- this.write(name, '', Date.now() - 86400000);
2416
+ this.write(name, '', Date.now() - 86400000, '/');
2293
2417
  }
2294
2418
  }
2295
2419
 
@@ -2315,6 +2439,10 @@ function isAbsoluteURL(url) {
2315
2439
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2316
2440
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2317
2441
  // by any combination of letters, digits, plus, period, or hyphen.
2442
+ if (typeof url !== 'string') {
2443
+ return false;
2444
+ }
2445
+
2318
2446
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2319
2447
  }
2320
2448
 
@@ -2350,7 +2478,8 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2350
2478
  return requestedURL;
2351
2479
  }
2352
2480
 
2353
- const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
2481
+ const headersToObject = (thing) =>
2482
+ thing instanceof AxiosHeaders ? { ...thing } : thing;
2354
2483
 
2355
2484
  /**
2356
2485
  * Config-specific merge-function which creates a new config-object
@@ -2368,7 +2497,7 @@ function mergeConfig(config1, config2) {
2368
2497
 
2369
2498
  function getMergedValue(target, source, prop, caseless) {
2370
2499
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2371
- return utils$1.merge.call({caseless}, target, source);
2500
+ return utils$1.merge.call({ caseless }, target, source);
2372
2501
  } else if (utils$1.isPlainObject(source)) {
2373
2502
  return utils$1.merge({}, source);
2374
2503
  } else if (utils$1.isArray(source)) {
@@ -2377,12 +2506,11 @@ function mergeConfig(config1, config2) {
2377
2506
  return source;
2378
2507
  }
2379
2508
 
2380
- // eslint-disable-next-line consistent-return
2381
- function mergeDeepProperties(a, b, prop , caseless) {
2509
+ function mergeDeepProperties(a, b, prop, caseless) {
2382
2510
  if (!utils$1.isUndefined(b)) {
2383
- return getMergedValue(a, b, prop , caseless);
2511
+ return getMergedValue(a, b, prop, caseless);
2384
2512
  } else if (!utils$1.isUndefined(a)) {
2385
- return getMergedValue(undefined, a, prop , caseless);
2513
+ return getMergedValue(undefined, a, prop, caseless);
2386
2514
  }
2387
2515
  }
2388
2516
 
@@ -2440,14 +2568,27 @@ function mergeConfig(config1, config2) {
2440
2568
  socketPath: defaultToConfig2,
2441
2569
  responseEncoding: defaultToConfig2,
2442
2570
  validateStatus: mergeDirectKeys,
2443
- headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2571
+ headers: (a, b, prop) =>
2572
+ mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
2444
2573
  };
2445
2574
 
2446
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2447
- const merge = mergeMap[prop] || mergeDeepProperties;
2448
- const configValue = merge(config1[prop], config2[prop], prop);
2449
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2450
- });
2575
+ utils$1.forEach(
2576
+ Object.keys({ ...config1, ...config2 }),
2577
+ function computeConfigValue(prop) {
2578
+ if (
2579
+ prop === "__proto__" ||
2580
+ prop === "constructor" ||
2581
+ prop === "prototype"
2582
+ )
2583
+ return;
2584
+ const merge = utils$1.hasOwnProp(mergeMap, prop)
2585
+ ? mergeMap[prop]
2586
+ : mergeDeepProperties;
2587
+ const configValue = merge(config1[prop], config2[prop], prop);
2588
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
2589
+ (config[prop] = configValue);
2590
+ },
2591
+ );
2451
2592
 
2452
2593
  return config;
2453
2594
  }
@@ -2455,7 +2596,7 @@ function mergeConfig(config1, config2) {
2455
2596
  var resolveConfig = (config) => {
2456
2597
  const newConfig = mergeConfig({}, config);
2457
2598
 
2458
- let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
2599
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
2459
2600
 
2460
2601
  newConfig.headers = headers = AxiosHeaders.from(headers);
2461
2602
 
@@ -2468,17 +2609,21 @@ var resolveConfig = (config) => {
2468
2609
  );
2469
2610
  }
2470
2611
 
2471
- let contentType;
2472
-
2473
2612
  if (utils$1.isFormData(data)) {
2474
2613
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2475
- headers.setContentType(undefined); // Let the browser set it
2476
- } else if ((contentType = headers.getContentType()) !== false) {
2477
- // fix semicolon duplication issue for ReactNative FormData implementation
2478
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
2479
- headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
2614
+ headers.setContentType(undefined); // browser handles it
2615
+ } else if (utils$1.isFunction(data.getHeaders)) {
2616
+ // Node.js FormData (like form-data package)
2617
+ const formHeaders = data.getHeaders();
2618
+ // Only set safe headers to avoid overwriting security headers
2619
+ const allowedHeaders = ['content-type', 'content-length'];
2620
+ Object.entries(formHeaders).forEach(([key, val]) => {
2621
+ if (allowedHeaders.includes(key.toLowerCase())) {
2622
+ headers.set(key, val);
2623
+ }
2624
+ });
2480
2625
  }
2481
- }
2626
+ }
2482
2627
 
2483
2628
  // Add xsrf header
2484
2629
  // This is only done if running in a standard browser environment.
@@ -2595,15 +2740,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2595
2740
  };
2596
2741
 
2597
2742
  // Handle low level network errors
2598
- request.onerror = function handleError() {
2599
- // Real errors are hidden from us by the browser
2600
- // onerror should only fire if it's a network error
2601
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2602
-
2603
- // Clean up request
2604
- request = null;
2743
+ request.onerror = function handleError(event) {
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(msg, AxiosError.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;
2605
2753
  };
2606
-
2754
+
2607
2755
  // Handle timeout
2608
2756
  request.ontimeout = function handleTimeout() {
2609
2757
  let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
@@ -2706,7 +2854,7 @@ const composeSignals = (signals, timeout) => {
2706
2854
 
2707
2855
  let timer = timeout && setTimeout(() => {
2708
2856
  timer = null;
2709
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
2857
+ onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
2710
2858
  }, timeout);
2711
2859
 
2712
2860
  const unsubscribe = () => {
@@ -2817,14 +2965,18 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2817
2965
  })
2818
2966
  };
2819
2967
 
2820
- const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
2821
- const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
2968
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
2969
+
2970
+ const {isFunction} = utils$1;
2971
+
2972
+ const globalFetchAPI = (({Request, Response}) => ({
2973
+ Request, Response
2974
+ }))(utils$1.global);
2975
+
2976
+ const {
2977
+ ReadableStream: ReadableStream$1, TextEncoder
2978
+ } = utils$1.global;
2822
2979
 
2823
- // used only inside the fetch adapter
2824
- const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
2825
- ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2826
- async (str) => new Uint8Array(await new Response(str).arrayBuffer())
2827
- );
2828
2980
 
2829
2981
  const test = (fn, ...args) => {
2830
2982
  try {
@@ -2834,278 +2986,380 @@ const test = (fn, ...args) => {
2834
2986
  }
2835
2987
  };
2836
2988
 
2837
- const supportsRequestStream = isReadableStreamSupported && test(() => {
2838
- let duplexAccessed = false;
2989
+ const factory = (env) => {
2990
+ env = utils$1.merge.call({
2991
+ skipUndefined: true
2992
+ }, globalFetchAPI, env);
2839
2993
 
2840
- const hasContentType = new Request(platform.origin, {
2841
- body: new ReadableStream(),
2842
- method: 'POST',
2843
- get duplex() {
2844
- duplexAccessed = true;
2845
- return 'half';
2846
- },
2847
- }).headers.has('Content-Type');
2994
+ const {fetch: envFetch, Request, Response} = env;
2995
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
2996
+ const isRequestSupported = isFunction(Request);
2997
+ const isResponseSupported = isFunction(Response);
2848
2998
 
2849
- return duplexAccessed && !hasContentType;
2850
- });
2999
+ if (!isFetchSupported) {
3000
+ return false;
3001
+ }
2851
3002
 
2852
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
3003
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
2853
3004
 
2854
- const supportsResponseStream = isReadableStreamSupported &&
2855
- test(() => utils$1.isReadableStream(new Response('').body));
3005
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
3006
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
3007
+ async (str) => new Uint8Array(await new Request(str).arrayBuffer())
3008
+ );
2856
3009
 
3010
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
3011
+ let duplexAccessed = false;
2857
3012
 
2858
- const resolvers = {
2859
- stream: supportsResponseStream && ((res) => res.body)
2860
- };
3013
+ const hasContentType = new Request(platform.origin, {
3014
+ body: new ReadableStream$1(),
3015
+ method: 'POST',
3016
+ get duplex() {
3017
+ duplexAccessed = true;
3018
+ return 'half';
3019
+ },
3020
+ }).headers.has('Content-Type');
2861
3021
 
2862
- isFetchSupported && (((res) => {
2863
- ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2864
- !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
2865
- (_, config) => {
2866
- throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
2867
- });
3022
+ return duplexAccessed && !hasContentType;
2868
3023
  });
2869
- })(new Response));
2870
3024
 
2871
- const getBodyLength = async (body) => {
2872
- if (body == null) {
2873
- return 0;
2874
- }
3025
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
3026
+ test(() => utils$1.isReadableStream(new Response('').body));
2875
3027
 
2876
- if(utils$1.isBlob(body)) {
2877
- return body.size;
2878
- }
3028
+ const resolvers = {
3029
+ stream: supportsResponseStream && ((res) => res.body)
3030
+ };
2879
3031
 
2880
- if(utils$1.isSpecCompliantForm(body)) {
2881
- const _request = new Request(platform.origin, {
2882
- method: 'POST',
2883
- body,
3032
+ isFetchSupported && ((() => {
3033
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
3034
+ !resolvers[type] && (resolvers[type] = (res, config) => {
3035
+ let method = res && res[type];
3036
+
3037
+ if (method) {
3038
+ return method.call(res);
3039
+ }
3040
+
3041
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
3042
+ });
2884
3043
  });
2885
- return (await _request.arrayBuffer()).byteLength;
2886
- }
3044
+ })());
2887
3045
 
2888
- if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2889
- return body.byteLength;
2890
- }
3046
+ const getBodyLength = async (body) => {
3047
+ if (body == null) {
3048
+ return 0;
3049
+ }
2891
3050
 
2892
- if(utils$1.isURLSearchParams(body)) {
2893
- body = body + '';
2894
- }
3051
+ if (utils$1.isBlob(body)) {
3052
+ return body.size;
3053
+ }
2895
3054
 
2896
- if(utils$1.isString(body)) {
2897
- return (await encodeText(body)).byteLength;
2898
- }
2899
- };
3055
+ if (utils$1.isSpecCompliantForm(body)) {
3056
+ const _request = new Request(platform.origin, {
3057
+ method: 'POST',
3058
+ body,
3059
+ });
3060
+ return (await _request.arrayBuffer()).byteLength;
3061
+ }
2900
3062
 
2901
- const resolveBodyLength = async (headers, body) => {
2902
- const length = utils$1.toFiniteNumber(headers.getContentLength());
3063
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
3064
+ return body.byteLength;
3065
+ }
2903
3066
 
2904
- return length == null ? getBodyLength(body) : length;
2905
- };
3067
+ if (utils$1.isURLSearchParams(body)) {
3068
+ body = body + '';
3069
+ }
3070
+
3071
+ if (utils$1.isString(body)) {
3072
+ return (await encodeText(body)).byteLength;
3073
+ }
3074
+ };
3075
+
3076
+ const resolveBodyLength = async (headers, body) => {
3077
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
3078
+
3079
+ return length == null ? getBodyLength(body) : length;
3080
+ };
3081
+
3082
+ return async (config) => {
3083
+ let {
3084
+ url,
3085
+ method,
3086
+ data,
3087
+ signal,
3088
+ cancelToken,
3089
+ timeout,
3090
+ onDownloadProgress,
3091
+ onUploadProgress,
3092
+ responseType,
3093
+ headers,
3094
+ withCredentials = 'same-origin',
3095
+ fetchOptions
3096
+ } = resolveConfig(config);
3097
+
3098
+ let _fetch = envFetch || fetch;
3099
+
3100
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3101
+
3102
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3103
+
3104
+ let request = null;
2906
3105
 
2907
- var fetchAdapter = isFetchSupported && (async (config) => {
2908
- let {
2909
- url,
2910
- method,
2911
- data,
2912
- signal,
2913
- cancelToken,
2914
- timeout,
2915
- onDownloadProgress,
2916
- onUploadProgress,
2917
- responseType,
2918
- headers,
2919
- withCredentials = 'same-origin',
2920
- fetchOptions
2921
- } = resolveConfig(config);
2922
-
2923
- responseType = responseType ? (responseType + '').toLowerCase() : 'text';
2924
-
2925
- let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2926
-
2927
- let request;
2928
-
2929
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3106
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2930
3107
  composedSignal.unsubscribe();
2931
- });
3108
+ });
2932
3109
 
2933
- let requestContentLength;
3110
+ let requestContentLength;
2934
3111
 
2935
- try {
2936
- if (
2937
- onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
2938
- (requestContentLength = await resolveBodyLength(headers, data)) !== 0
2939
- ) {
2940
- let _request = new Request(url, {
2941
- method: 'POST',
2942
- body: data,
2943
- duplex: "half"
2944
- });
3112
+ try {
3113
+ if (
3114
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3115
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3116
+ ) {
3117
+ let _request = new Request(url, {
3118
+ method: 'POST',
3119
+ body: data,
3120
+ duplex: "half"
3121
+ });
2945
3122
 
2946
- let contentTypeHeader;
3123
+ let contentTypeHeader;
2947
3124
 
2948
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
2949
- headers.setContentType(contentTypeHeader);
2950
- }
3125
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3126
+ headers.setContentType(contentTypeHeader);
3127
+ }
2951
3128
 
2952
- if (_request.body) {
2953
- const [onProgress, flush] = progressEventDecorator(
2954
- requestContentLength,
2955
- progressEventReducer(asyncDecorator(onUploadProgress))
2956
- );
3129
+ if (_request.body) {
3130
+ const [onProgress, flush] = progressEventDecorator(
3131
+ requestContentLength,
3132
+ progressEventReducer(asyncDecorator(onUploadProgress))
3133
+ );
2957
3134
 
2958
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3135
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3136
+ }
2959
3137
  }
2960
- }
2961
3138
 
2962
- if (!utils$1.isString(withCredentials)) {
2963
- withCredentials = withCredentials ? 'include' : 'omit';
2964
- }
3139
+ if (!utils$1.isString(withCredentials)) {
3140
+ withCredentials = withCredentials ? 'include' : 'omit';
3141
+ }
2965
3142
 
2966
- // Cloudflare Workers throws when credentials are defined
2967
- // see https://github.com/cloudflare/workerd/issues/902
2968
- const isCredentialsSupported = "credentials" in Request.prototype;
2969
- request = new Request(url, {
2970
- ...fetchOptions,
2971
- signal: composedSignal,
2972
- method: method.toUpperCase(),
2973
- headers: headers.normalize().toJSON(),
2974
- body: data,
2975
- duplex: "half",
2976
- credentials: isCredentialsSupported ? withCredentials : undefined
2977
- });
3143
+ // Cloudflare Workers throws when credentials are defined
3144
+ // see https://github.com/cloudflare/workerd/issues/902
3145
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
2978
3146
 
2979
- let response = await fetch(request);
3147
+ const resolvedOptions = {
3148
+ ...fetchOptions,
3149
+ signal: composedSignal,
3150
+ method: method.toUpperCase(),
3151
+ headers: headers.normalize().toJSON(),
3152
+ body: data,
3153
+ duplex: "half",
3154
+ credentials: isCredentialsSupported ? withCredentials : undefined
3155
+ };
2980
3156
 
2981
- const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3157
+ request = isRequestSupported && new Request(url, resolvedOptions);
2982
3158
 
2983
- if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
2984
- const options = {};
3159
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
2985
3160
 
2986
- ['status', 'statusText', 'headers'].forEach(prop => {
2987
- options[prop] = response[prop];
2988
- });
3161
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
2989
3162
 
2990
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3163
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3164
+ const options = {};
2991
3165
 
2992
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2993
- responseContentLength,
2994
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
2995
- ) || [];
3166
+ ['status', 'statusText', 'headers'].forEach(prop => {
3167
+ options[prop] = response[prop];
3168
+ });
2996
3169
 
2997
- response = new Response(
2998
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2999
- flush && flush();
3000
- unsubscribe && unsubscribe();
3001
- }),
3002
- options
3003
- );
3004
- }
3170
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3005
3171
 
3006
- responseType = responseType || 'text';
3172
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3173
+ responseContentLength,
3174
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
3175
+ ) || [];
3007
3176
 
3008
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3177
+ response = new Response(
3178
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3179
+ flush && flush();
3180
+ unsubscribe && unsubscribe();
3181
+ }),
3182
+ options
3183
+ );
3184
+ }
3009
3185
 
3010
- !isStreamResponse && unsubscribe && unsubscribe();
3186
+ responseType = responseType || 'text';
3011
3187
 
3012
- return await new Promise((resolve, reject) => {
3013
- settle(resolve, reject, {
3014
- data: responseData,
3015
- headers: AxiosHeaders.from(response.headers),
3016
- status: response.status,
3017
- statusText: response.statusText,
3018
- config,
3019
- request
3020
- });
3021
- })
3022
- } catch (err) {
3023
- unsubscribe && unsubscribe();
3188
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3024
3189
 
3025
- if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3026
- throw Object.assign(
3027
- new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3028
- {
3029
- cause: err.cause || err
3030
- }
3031
- )
3190
+ !isStreamResponse && unsubscribe && unsubscribe();
3191
+
3192
+ return await new Promise((resolve, reject) => {
3193
+ settle(resolve, reject, {
3194
+ data: responseData,
3195
+ headers: AxiosHeaders.from(response.headers),
3196
+ status: response.status,
3197
+ statusText: response.statusText,
3198
+ config,
3199
+ request
3200
+ });
3201
+ })
3202
+ } catch (err) {
3203
+ unsubscribe && unsubscribe();
3204
+
3205
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3206
+ throw Object.assign(
3207
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, err && err.response),
3208
+ {
3209
+ cause: err.cause || err
3210
+ }
3211
+ )
3212
+ }
3213
+
3214
+ throw AxiosError.from(err, err && err.code, config, request, err && err.response);
3032
3215
  }
3216
+ }
3217
+ };
3218
+
3219
+ const seedCache = new Map();
3220
+
3221
+ const getFetch = (config) => {
3222
+ let env = (config && config.env) || {};
3223
+ const {fetch, Request, Response} = env;
3224
+ const seeds = [
3225
+ Request, Response, fetch
3226
+ ];
3227
+
3228
+ let len = seeds.length, i = len,
3229
+ seed, target, map = seedCache;
3230
+
3231
+ while (i--) {
3232
+ seed = seeds[i];
3233
+ target = map.get(seed);
3033
3234
 
3034
- throw AxiosError.from(err, err && err.code, config, request);
3235
+ target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
3236
+
3237
+ map = target;
3035
3238
  }
3036
- });
3037
3239
 
3240
+ return target;
3241
+ };
3242
+
3243
+ getFetch();
3244
+
3245
+ /**
3246
+ * Known adapters mapping.
3247
+ * Provides environment-specific adapters for Axios:
3248
+ * - `http` for Node.js
3249
+ * - `xhr` for browsers
3250
+ * - `fetch` for fetch API-based requests
3251
+ *
3252
+ * @type {Object<string, Function|Object>}
3253
+ */
3038
3254
  const knownAdapters = {
3039
3255
  http: httpAdapter,
3040
3256
  xhr: xhrAdapter,
3041
- fetch: fetchAdapter
3257
+ fetch: {
3258
+ get: getFetch,
3259
+ }
3042
3260
  };
3043
3261
 
3262
+ // Assign adapter names for easier debugging and identification
3044
3263
  utils$1.forEach(knownAdapters, (fn, value) => {
3045
3264
  if (fn) {
3046
3265
  try {
3047
- Object.defineProperty(fn, 'name', {value});
3266
+ Object.defineProperty(fn, 'name', { value });
3048
3267
  } catch (e) {
3049
3268
  // eslint-disable-next-line no-empty
3050
3269
  }
3051
- Object.defineProperty(fn, 'adapterName', {value});
3270
+ Object.defineProperty(fn, 'adapterName', { value });
3052
3271
  }
3053
3272
  });
3054
3273
 
3274
+ /**
3275
+ * Render a rejection reason string for unknown or unsupported adapters
3276
+ *
3277
+ * @param {string} reason
3278
+ * @returns {string}
3279
+ */
3055
3280
  const renderReason = (reason) => `- ${reason}`;
3056
3281
 
3282
+ /**
3283
+ * Check if the adapter is resolved (function, null, or false)
3284
+ *
3285
+ * @param {Function|null|false} adapter
3286
+ * @returns {boolean}
3287
+ */
3057
3288
  const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3058
3289
 
3059
- var adapters = {
3060
- getAdapter: (adapters) => {
3061
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3062
-
3063
- const {length} = adapters;
3064
- let nameOrAdapter;
3065
- let adapter;
3290
+ /**
3291
+ * Get the first suitable adapter from the provided list.
3292
+ * Tries each adapter in order until a supported one is found.
3293
+ * Throws an AxiosError if no adapter is suitable.
3294
+ *
3295
+ * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
3296
+ * @param {Object} config - Axios request configuration
3297
+ * @throws {AxiosError} If no suitable adapter is available
3298
+ * @returns {Function} The resolved adapter function
3299
+ */
3300
+ function getAdapter(adapters, config) {
3301
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3066
3302
 
3067
- const rejectedReasons = {};
3303
+ const { length } = adapters;
3304
+ let nameOrAdapter;
3305
+ let adapter;
3068
3306
 
3069
- for (let i = 0; i < length; i++) {
3070
- nameOrAdapter = adapters[i];
3071
- let id;
3307
+ const rejectedReasons = {};
3072
3308
 
3073
- adapter = nameOrAdapter;
3309
+ for (let i = 0; i < length; i++) {
3310
+ nameOrAdapter = adapters[i];
3311
+ let id;
3074
3312
 
3075
- if (!isResolvedHandle(nameOrAdapter)) {
3076
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3313
+ adapter = nameOrAdapter;
3077
3314
 
3078
- if (adapter === undefined) {
3079
- throw new AxiosError(`Unknown adapter '${id}'`);
3080
- }
3081
- }
3315
+ if (!isResolvedHandle(nameOrAdapter)) {
3316
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3082
3317
 
3083
- if (adapter) {
3084
- break;
3318
+ if (adapter === undefined) {
3319
+ throw new AxiosError(`Unknown adapter '${id}'`);
3085
3320
  }
3321
+ }
3086
3322
 
3087
- rejectedReasons[id || '#' + i] = adapter;
3323
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3324
+ break;
3088
3325
  }
3089
3326
 
3090
- if (!adapter) {
3327
+ rejectedReasons[id || '#' + i] = adapter;
3328
+ }
3091
3329
 
3092
- const reasons = Object.entries(rejectedReasons)
3093
- .map(([id, state]) => `adapter ${id} ` +
3094
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
3095
- );
3330
+ if (!adapter) {
3331
+ const reasons = Object.entries(rejectedReasons)
3332
+ .map(([id, state]) => `adapter ${id} ` +
3333
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
3334
+ );
3096
3335
 
3097
- let s = length ?
3098
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3099
- 'as no adapter specified';
3336
+ let s = length ?
3337
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3338
+ 'as no adapter specified';
3100
3339
 
3101
- throw new AxiosError(
3102
- `There is no suitable adapter to dispatch the request ` + s,
3103
- 'ERR_NOT_SUPPORT'
3104
- );
3105
- }
3340
+ throw new AxiosError(
3341
+ `There is no suitable adapter to dispatch the request ` + s,
3342
+ 'ERR_NOT_SUPPORT'
3343
+ );
3344
+ }
3106
3345
 
3107
- return adapter;
3108
- },
3346
+ return adapter;
3347
+ }
3348
+
3349
+ /**
3350
+ * Exports Axios adapters and utility to resolve an adapter
3351
+ */
3352
+ var adapters = {
3353
+ /**
3354
+ * Resolve an adapter from a list of adapter names or functions.
3355
+ * @type {Function}
3356
+ */
3357
+ getAdapter,
3358
+
3359
+ /**
3360
+ * Exposes all known adapters
3361
+ * @type {Object<string, Function|Object>}
3362
+ */
3109
3363
  adapters: knownAdapters
3110
3364
  };
3111
3365
 
@@ -3148,7 +3402,7 @@ function dispatchRequest(config) {
3148
3402
  config.headers.setContentType('application/x-www-form-urlencoded', false);
3149
3403
  }
3150
3404
 
3151
- const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
3405
+ const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
3152
3406
 
3153
3407
  return adapter(config).then(function onAdapterResolution(response) {
3154
3408
  throwIfCancellationRequested(config);
@@ -3182,7 +3436,7 @@ function dispatchRequest(config) {
3182
3436
  });
3183
3437
  }
3184
3438
 
3185
- const VERSION = "1.8.4";
3439
+ const VERSION = "1.13.5";
3186
3440
 
3187
3441
  const validators$1 = {};
3188
3442
 
@@ -3290,7 +3544,7 @@ const validators = validator.validators;
3290
3544
  */
3291
3545
  class Axios {
3292
3546
  constructor(instanceConfig) {
3293
- this.defaults = instanceConfig;
3547
+ this.defaults = instanceConfig || {};
3294
3548
  this.interceptors = {
3295
3549
  request: new InterceptorManager(),
3296
3550
  response: new InterceptorManager()
@@ -3350,7 +3604,8 @@ class Axios {
3350
3604
  validator.assertOptions(transitional, {
3351
3605
  silentJSONParsing: validators.transitional(validators.boolean),
3352
3606
  forcedJSONParsing: validators.transitional(validators.boolean),
3353
- clarifyTimeoutError: validators.transitional(validators.boolean)
3607
+ clarifyTimeoutError: validators.transitional(validators.boolean),
3608
+ legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
3354
3609
  }, false);
3355
3610
  }
3356
3611
 
@@ -3407,7 +3662,14 @@ class Axios {
3407
3662
 
3408
3663
  synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3409
3664
 
3410
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3665
+ const transitional = config.transitional || transitionalDefaults;
3666
+ const legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
3667
+
3668
+ if (legacyInterceptorReqResOrdering) {
3669
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3670
+ } else {
3671
+ requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3672
+ }
3411
3673
  });
3412
3674
 
3413
3675
  const responseInterceptorChain = [];
@@ -3421,8 +3683,8 @@ class Axios {
3421
3683
 
3422
3684
  if (!synchronousRequestInterceptors) {
3423
3685
  const chain = [dispatchRequest.bind(this), undefined];
3424
- chain.unshift.apply(chain, requestInterceptorChain);
3425
- chain.push.apply(chain, responseInterceptorChain);
3686
+ chain.unshift(...requestInterceptorChain);
3687
+ chain.push(...responseInterceptorChain);
3426
3688
  len = chain.length;
3427
3689
 
3428
3690
  promise = Promise.resolve(config);
@@ -3438,8 +3700,6 @@ class Axios {
3438
3700
 
3439
3701
  let newConfig = config;
3440
3702
 
3441
- i = 0;
3442
-
3443
3703
  while (i < len) {
3444
3704
  const onFulfilled = requestInterceptorChain[i++];
3445
3705
  const onRejected = requestInterceptorChain[i++];
@@ -3644,7 +3904,7 @@ class CancelToken {
3644
3904
  *
3645
3905
  * ```js
3646
3906
  * function f(x, y, z) {}
3647
- * var args = [1, 2, 3];
3907
+ * const args = [1, 2, 3];
3648
3908
  * f.apply(null, args);
3649
3909
  * ```
3650
3910
  *
@@ -3739,6 +3999,12 @@ const HttpStatusCode = {
3739
3999
  LoopDetected: 508,
3740
4000
  NotExtended: 510,
3741
4001
  NetworkAuthenticationRequired: 511,
4002
+ WebServerIsDown: 521,
4003
+ ConnectionTimedOut: 522,
4004
+ OriginIsUnreachable: 523,
4005
+ TimeoutOccurred: 524,
4006
+ SslHandshakeFailed: 525,
4007
+ InvalidSslCertificate: 526,
3742
4008
  };
3743
4009
 
3744
4010
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
@@ -3901,7 +4167,7 @@ const TX_MIN_FEE = 1000;
3901
4167
  /**
3902
4168
  * Threshold value for dust amount in Dash transactions.
3903
4169
  */
3904
- dashcore__default.Transaction.DUST_AMOUNT;
4170
+ dashcore.Transaction.DUST_AMOUNT;
3905
4171
  /**
3906
4172
  * Function to determine the Dash network based on the provided network type.
3907
4173
  * @param {Network} network The network type (Mainnet, Testnet, or Stagenet).
@@ -3927,7 +4193,7 @@ const validateAddress = (address, network) => {
3927
4193
  Dash.address.toOutputScript(address, dashNetwork(network)); // Convert address to output script
3928
4194
  return true; // Address is valid
3929
4195
  }
3930
- catch (error) {
4196
+ catch (_error) {
3931
4197
  return false; // Address is invalid
3932
4198
  }
3933
4199
  };
@@ -3965,7 +4231,7 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ amount, rec
3965
4231
  if (!inputs || !outputs)
3966
4232
  throw new Error('Insufficient balance for transaction');
3967
4233
  // Initialize new Dash transaction
3968
- const tx = new dashcore__default.Transaction().to(recipient, amount.amount().toNumber());
4234
+ const tx = new dashcore.Transaction().to(recipient, amount.amount().toNumber());
3969
4235
  // Add inputs to the transaction
3970
4236
  inputs.forEach((utxo) => {
3971
4237
  const insightUtxo = insightUtxos.find((x) => x.txid === utxo.hash && x.vout == utxo.index);
@@ -3973,12 +4239,12 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ amount, rec
3973
4239
  throw new Error('Unable to match accumulative inputs with insight UTXOs');
3974
4240
  }
3975
4241
  const scriptBuffer = Buffer.from(insightUtxo.scriptPubKey, 'hex');
3976
- const script = new dashcore__default.Script(scriptBuffer);
3977
- const input = new dashcore__default.Transaction.Input.PublicKeyHash({
4242
+ const script = new dashcore.Script(scriptBuffer);
4243
+ const input = new dashcore.Transaction.Input.PublicKeyHash({
3978
4244
  prevTxId: Buffer.from(insightUtxo.txid, 'hex'),
3979
4245
  outputIndex: insightUtxo.vout,
3980
4246
  script: '',
3981
- output: new dashcore__default.Transaction.Output({
4247
+ output: new dashcore.Transaction.Output({
3982
4248
  satoshis: utxo.value,
3983
4249
  script,
3984
4250
  }),
@@ -3986,7 +4252,7 @@ const buildTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ amount, rec
3986
4252
  tx.uncheckedAddInput(input);
3987
4253
  });
3988
4254
  // Define sender address
3989
- const senderAddress = dashcore__default.Address.fromString(sender, network);
4255
+ const senderAddress = dashcore.Address.fromString(sender, network);
3990
4256
  tx.change(senderAddress);
3991
4257
  // Add memo to the transaction if provided
3992
4258
  if (memo) {
@@ -4198,6 +4464,9 @@ class Client extends Client$1 {
4198
4464
  network: this.network,
4199
4465
  });
4200
4466
  // Return the raw unsigned transaction and UTXOs
4467
+ // ESLint disabled: Dash transaction has proper toString() method that returns hex string
4468
+ // Left as-is during ESLint 8 upgrade as this core crypto functionality is tested and working
4469
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
4201
4470
  return { rawUnsignedTx: tx.toString(), utxos, inputs };
4202
4471
  });
4203
4472
  }
@@ -4275,7 +4544,7 @@ const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
4275
4544
  }
4276
4545
  catch (ex) {
4277
4546
  // If an exception occurs during the request, reject the promise with the caught error message.
4278
- return Promise.reject(Error(`failed to broadcast a transaction caught: ${ex}`));
4547
+ return Promise.reject(Error(`failed to broadcast a transaction caught: ${String(ex)}`));
4279
4548
  }
4280
4549
  });
4281
4550