@xchainjs/xchain-dash 1.0.10 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.esm.js CHANGED
@@ -5,6 +5,7 @@ import * as dashcore from '@dashevo/dashcore-lib';
5
5
  import { Client as Client$1 } from '@xchainjs/xchain-utxo';
6
6
  import * as Dash from 'bitcoinjs-lib';
7
7
  import * as coininfo from 'coininfo';
8
+ import accumulative from 'coinselect/accumulative';
8
9
  import { getSeed } from '@xchainjs/xchain-crypto';
9
10
  import AppBtc from '@ledgerhq/hw-app-btc';
10
11
 
@@ -725,26 +726,6 @@ const toFiniteNumber = (value, defaultValue) => {
725
726
  return value != null && Number.isFinite(value = +value) ? value : defaultValue;
726
727
  };
727
728
 
728
- const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
729
-
730
- const DIGIT = '0123456789';
731
-
732
- const ALPHABET = {
733
- DIGIT,
734
- ALPHA,
735
- ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
736
- };
737
-
738
- const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
739
- let str = '';
740
- const {length} = alphabet;
741
- while (size--) {
742
- str += alphabet[Math.random() * length|0];
743
- }
744
-
745
- return str;
746
- };
747
-
748
729
  /**
749
730
  * If the thing is a FormData object, return true, otherwise return false.
750
731
  *
@@ -822,7 +803,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
822
803
 
823
804
  // *********************
824
805
 
825
- var utils$2 = {
806
+ var utils$1 = {
826
807
  isArray,
827
808
  isArrayBuffer,
828
809
  isBuffer,
@@ -872,8 +853,6 @@ var utils$2 = {
872
853
  findKey,
873
854
  global: _global,
874
855
  isContextDefined,
875
- ALPHABET,
876
- generateString,
877
856
  isSpecCompliantForm,
878
857
  toJSONObject,
879
858
  isAsyncFn,
@@ -907,10 +886,13 @@ function AxiosError(message, code, config, request, response) {
907
886
  code && (this.code = code);
908
887
  config && (this.config = config);
909
888
  request && (this.request = request);
910
- response && (this.response = response);
889
+ if (response) {
890
+ this.response = response;
891
+ this.status = response.status ? response.status : null;
892
+ }
911
893
  }
912
894
 
913
- utils$2.inherits(AxiosError, Error, {
895
+ utils$1.inherits(AxiosError, Error, {
914
896
  toJSON: function toJSON() {
915
897
  return {
916
898
  // Standard
@@ -925,9 +907,9 @@ utils$2.inherits(AxiosError, Error, {
925
907
  columnNumber: this.columnNumber,
926
908
  stack: this.stack,
927
909
  // Axios
928
- config: utils$2.toJSONObject(this.config),
910
+ config: utils$1.toJSONObject(this.config),
929
911
  code: this.code,
930
- status: this.response && this.response.status ? this.response.status : null
912
+ status: this.status
931
913
  };
932
914
  }
933
915
  });
@@ -960,7 +942,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
960
942
  AxiosError.from = (error, code, config, request, response, customProps) => {
961
943
  const axiosError = Object.create(prototype$1);
962
944
 
963
- utils$2.toFlatObject(error, axiosError, function filter(obj) {
945
+ utils$1.toFlatObject(error, axiosError, function filter(obj) {
964
946
  return obj !== Error.prototype;
965
947
  }, prop => {
966
948
  return prop !== 'isAxiosError';
@@ -988,7 +970,7 @@ var httpAdapter = null;
988
970
  * @returns {boolean}
989
971
  */
990
972
  function isVisitable(thing) {
991
- return utils$2.isPlainObject(thing) || utils$2.isArray(thing);
973
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
992
974
  }
993
975
 
994
976
  /**
@@ -999,7 +981,7 @@ function isVisitable(thing) {
999
981
  * @returns {string} the key without the brackets.
1000
982
  */
1001
983
  function removeBrackets(key) {
1002
- return utils$2.endsWith(key, '[]') ? key.slice(0, -2) : key;
984
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1003
985
  }
1004
986
 
1005
987
  /**
@@ -1028,10 +1010,10 @@ function renderKey(path, key, dots) {
1028
1010
  * @returns {boolean}
1029
1011
  */
1030
1012
  function isFlatArray(arr) {
1031
- return utils$2.isArray(arr) && !arr.some(isVisitable);
1013
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
1032
1014
  }
1033
1015
 
1034
- const predicates = utils$2.toFlatObject(utils$2, {}, null, function filter(prop) {
1016
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1035
1017
  return /^is[A-Z]/.test(prop);
1036
1018
  });
1037
1019
 
@@ -1059,7 +1041,7 @@ const predicates = utils$2.toFlatObject(utils$2, {}, null, function filter(prop)
1059
1041
  * @returns
1060
1042
  */
1061
1043
  function toFormData(obj, formData, options) {
1062
- if (!utils$2.isObject(obj)) {
1044
+ if (!utils$1.isObject(obj)) {
1063
1045
  throw new TypeError('target must be an object');
1064
1046
  }
1065
1047
 
@@ -1067,13 +1049,13 @@ function toFormData(obj, formData, options) {
1067
1049
  formData = formData || new (FormData)();
1068
1050
 
1069
1051
  // eslint-disable-next-line no-param-reassign
1070
- options = utils$2.toFlatObject(options, {
1052
+ options = utils$1.toFlatObject(options, {
1071
1053
  metaTokens: true,
1072
1054
  dots: false,
1073
1055
  indexes: false
1074
1056
  }, false, function defined(option, source) {
1075
1057
  // eslint-disable-next-line no-eq-null,eqeqeq
1076
- return !utils$2.isUndefined(source[option]);
1058
+ return !utils$1.isUndefined(source[option]);
1077
1059
  });
1078
1060
 
1079
1061
  const metaTokens = options.metaTokens;
@@ -1082,24 +1064,24 @@ function toFormData(obj, formData, options) {
1082
1064
  const dots = options.dots;
1083
1065
  const indexes = options.indexes;
1084
1066
  const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1085
- const useBlob = _Blob && utils$2.isSpecCompliantForm(formData);
1067
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1086
1068
 
1087
- if (!utils$2.isFunction(visitor)) {
1069
+ if (!utils$1.isFunction(visitor)) {
1088
1070
  throw new TypeError('visitor must be a function');
1089
1071
  }
1090
1072
 
1091
1073
  function convertValue(value) {
1092
1074
  if (value === null) return '';
1093
1075
 
1094
- if (utils$2.isDate(value)) {
1076
+ if (utils$1.isDate(value)) {
1095
1077
  return value.toISOString();
1096
1078
  }
1097
1079
 
1098
- if (!useBlob && utils$2.isBlob(value)) {
1080
+ if (!useBlob && utils$1.isBlob(value)) {
1099
1081
  throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1100
1082
  }
1101
1083
 
1102
- if (utils$2.isArrayBuffer(value) || utils$2.isTypedArray(value)) {
1084
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1103
1085
  return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1104
1086
  }
1105
1087
 
@@ -1120,20 +1102,20 @@ function toFormData(obj, formData, options) {
1120
1102
  let arr = value;
1121
1103
 
1122
1104
  if (value && !path && typeof value === 'object') {
1123
- if (utils$2.endsWith(key, '{}')) {
1105
+ if (utils$1.endsWith(key, '{}')) {
1124
1106
  // eslint-disable-next-line no-param-reassign
1125
1107
  key = metaTokens ? key : key.slice(0, -2);
1126
1108
  // eslint-disable-next-line no-param-reassign
1127
1109
  value = JSON.stringify(value);
1128
1110
  } else if (
1129
- (utils$2.isArray(value) && isFlatArray(value)) ||
1130
- ((utils$2.isFileList(value) || utils$2.endsWith(key, '[]')) && (arr = utils$2.toArray(value))
1111
+ (utils$1.isArray(value) && isFlatArray(value)) ||
1112
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1131
1113
  )) {
1132
1114
  // eslint-disable-next-line no-param-reassign
1133
1115
  key = removeBrackets(key);
1134
1116
 
1135
1117
  arr.forEach(function each(el, index) {
1136
- !(utils$2.isUndefined(el) || el === null) && formData.append(
1118
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
1137
1119
  // eslint-disable-next-line no-nested-ternary
1138
1120
  indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1139
1121
  convertValue(el)
@@ -1161,7 +1143,7 @@ function toFormData(obj, formData, options) {
1161
1143
  });
1162
1144
 
1163
1145
  function build(value, path) {
1164
- if (utils$2.isUndefined(value)) return;
1146
+ if (utils$1.isUndefined(value)) return;
1165
1147
 
1166
1148
  if (stack.indexOf(value) !== -1) {
1167
1149
  throw Error('Circular reference detected in ' + path.join('.'));
@@ -1169,9 +1151,9 @@ function toFormData(obj, formData, options) {
1169
1151
 
1170
1152
  stack.push(value);
1171
1153
 
1172
- utils$2.forEach(value, function each(el, key) {
1173
- const result = !(utils$2.isUndefined(el) || el === null) && visitor.call(
1174
- formData, el, utils$2.isString(key) ? key.trim() : key, path, exposedHelpers
1154
+ utils$1.forEach(value, function each(el, key) {
1155
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1156
+ formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1175
1157
  );
1176
1158
 
1177
1159
  if (result === true) {
@@ -1182,7 +1164,7 @@ function toFormData(obj, formData, options) {
1182
1164
  stack.pop();
1183
1165
  }
1184
1166
 
1185
- if (!utils$2.isObject(obj)) {
1167
+ if (!utils$1.isObject(obj)) {
1186
1168
  throw new TypeError('data must be an object');
1187
1169
  }
1188
1170
 
@@ -1267,7 +1249,7 @@ function encode(val) {
1267
1249
  *
1268
1250
  * @param {string} url The base of the url (e.g., http://www.google.com)
1269
1251
  * @param {object} [params] The params to be appended
1270
- * @param {?object} options
1252
+ * @param {?(object|Function)} options
1271
1253
  *
1272
1254
  * @returns {string} The formatted url
1273
1255
  */
@@ -1279,6 +1261,12 @@ function buildURL(url, params, options) {
1279
1261
 
1280
1262
  const _encode = options && options.encode || encode;
1281
1263
 
1264
+ if (utils$1.isFunction(options)) {
1265
+ options = {
1266
+ serialize: options
1267
+ };
1268
+ }
1269
+
1282
1270
  const serializeFn = options && options.serialize;
1283
1271
 
1284
1272
  let serializedParams;
@@ -1286,7 +1274,7 @@ function buildURL(url, params, options) {
1286
1274
  if (serializeFn) {
1287
1275
  serializedParams = serializeFn(params, options);
1288
1276
  } else {
1289
- serializedParams = utils$2.isURLSearchParams(params) ?
1277
+ serializedParams = utils$1.isURLSearchParams(params) ?
1290
1278
  params.toString() :
1291
1279
  new AxiosURLSearchParams(params, options).toString(_encode);
1292
1280
  }
@@ -1361,7 +1349,7 @@ class InterceptorManager {
1361
1349
  * @returns {void}
1362
1350
  */
1363
1351
  forEach(fn) {
1364
- utils$2.forEach(this.handlers, function forEachHandler(h) {
1352
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1365
1353
  if (h !== null) {
1366
1354
  fn(h);
1367
1355
  }
@@ -1393,6 +1381,8 @@ var platform$1 = {
1393
1381
 
1394
1382
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1395
1383
 
1384
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1385
+
1396
1386
  /**
1397
1387
  * Determine if we're running in a standard browser environment
1398
1388
  *
@@ -1410,10 +1400,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
1410
1400
  *
1411
1401
  * @returns {boolean}
1412
1402
  */
1413
- const hasStandardBrowserEnv = (
1414
- (product) => {
1415
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
1416
- })(typeof navigator !== 'undefined' && navigator.product);
1403
+ const hasStandardBrowserEnv = hasBrowserEnv &&
1404
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1417
1405
 
1418
1406
  /**
1419
1407
  * Determine if we're running in a standard browser webWorker environment
@@ -1435,23 +1423,24 @@ const hasStandardBrowserWebWorkerEnv = (() => {
1435
1423
 
1436
1424
  const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1437
1425
 
1438
- var utils$1 = /*#__PURE__*/Object.freeze({
1426
+ var utils = /*#__PURE__*/Object.freeze({
1439
1427
  __proto__: null,
1440
1428
  hasBrowserEnv: hasBrowserEnv,
1441
1429
  hasStandardBrowserEnv: hasStandardBrowserEnv,
1442
1430
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1431
+ navigator: _navigator,
1443
1432
  origin: origin
1444
1433
  });
1445
1434
 
1446
1435
  var platform = {
1447
- ...utils$1,
1436
+ ...utils,
1448
1437
  ...platform$1
1449
1438
  };
1450
1439
 
1451
1440
  function toURLEncodedForm(data, options) {
1452
1441
  return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1453
1442
  visitor: function(value, key, path, helpers) {
1454
- if (platform.isNode && utils$2.isBuffer(value)) {
1443
+ if (platform.isNode && utils$1.isBuffer(value)) {
1455
1444
  this.append(key, value.toString('base64'));
1456
1445
  return false;
1457
1446
  }
@@ -1473,7 +1462,7 @@ function parsePropPath(name) {
1473
1462
  // foo.x.y.z
1474
1463
  // foo-x-y-z
1475
1464
  // foo x y z
1476
- return utils$2.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1465
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1477
1466
  return match[0] === '[]' ? '' : match[1] || match[0];
1478
1467
  });
1479
1468
  }
@@ -1513,10 +1502,10 @@ function formDataToJSON(formData) {
1513
1502
 
1514
1503
  const isNumericKey = Number.isFinite(+name);
1515
1504
  const isLast = index >= path.length;
1516
- name = !name && utils$2.isArray(target) ? target.length : name;
1505
+ name = !name && utils$1.isArray(target) ? target.length : name;
1517
1506
 
1518
1507
  if (isLast) {
1519
- if (utils$2.hasOwnProp(target, name)) {
1508
+ if (utils$1.hasOwnProp(target, name)) {
1520
1509
  target[name] = [target[name], value];
1521
1510
  } else {
1522
1511
  target[name] = value;
@@ -1525,23 +1514,23 @@ function formDataToJSON(formData) {
1525
1514
  return !isNumericKey;
1526
1515
  }
1527
1516
 
1528
- if (!target[name] || !utils$2.isObject(target[name])) {
1517
+ if (!target[name] || !utils$1.isObject(target[name])) {
1529
1518
  target[name] = [];
1530
1519
  }
1531
1520
 
1532
1521
  const result = buildPath(path, value, target[name], index);
1533
1522
 
1534
- if (result && utils$2.isArray(target[name])) {
1523
+ if (result && utils$1.isArray(target[name])) {
1535
1524
  target[name] = arrayToObject(target[name]);
1536
1525
  }
1537
1526
 
1538
1527
  return !isNumericKey;
1539
1528
  }
1540
1529
 
1541
- if (utils$2.isFormData(formData) && utils$2.isFunction(formData.entries)) {
1530
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1542
1531
  const obj = {};
1543
1532
 
1544
- utils$2.forEachEntry(formData, (name, value) => {
1533
+ utils$1.forEachEntry(formData, (name, value) => {
1545
1534
  buildPath(parsePropPath(name), value, obj, 0);
1546
1535
  });
1547
1536
 
@@ -1562,10 +1551,10 @@ function formDataToJSON(formData) {
1562
1551
  * @returns {string} A stringified version of the rawValue.
1563
1552
  */
1564
1553
  function stringifySafely(rawValue, parser, encoder) {
1565
- if (utils$2.isString(rawValue)) {
1554
+ if (utils$1.isString(rawValue)) {
1566
1555
  try {
1567
1556
  (parser || JSON.parse)(rawValue);
1568
- return utils$2.trim(rawValue);
1557
+ return utils$1.trim(rawValue);
1569
1558
  } catch (e) {
1570
1559
  if (e.name !== 'SyntaxError') {
1571
1560
  throw e;
@@ -1585,31 +1574,31 @@ const defaults = {
1585
1574
  transformRequest: [function transformRequest(data, headers) {
1586
1575
  const contentType = headers.getContentType() || '';
1587
1576
  const hasJSONContentType = contentType.indexOf('application/json') > -1;
1588
- const isObjectPayload = utils$2.isObject(data);
1577
+ const isObjectPayload = utils$1.isObject(data);
1589
1578
 
1590
- if (isObjectPayload && utils$2.isHTMLForm(data)) {
1579
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1591
1580
  data = new FormData(data);
1592
1581
  }
1593
1582
 
1594
- const isFormData = utils$2.isFormData(data);
1583
+ const isFormData = utils$1.isFormData(data);
1595
1584
 
1596
1585
  if (isFormData) {
1597
1586
  return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1598
1587
  }
1599
1588
 
1600
- if (utils$2.isArrayBuffer(data) ||
1601
- utils$2.isBuffer(data) ||
1602
- utils$2.isStream(data) ||
1603
- utils$2.isFile(data) ||
1604
- utils$2.isBlob(data) ||
1605
- utils$2.isReadableStream(data)
1589
+ if (utils$1.isArrayBuffer(data) ||
1590
+ utils$1.isBuffer(data) ||
1591
+ utils$1.isStream(data) ||
1592
+ utils$1.isFile(data) ||
1593
+ utils$1.isBlob(data) ||
1594
+ utils$1.isReadableStream(data)
1606
1595
  ) {
1607
1596
  return data;
1608
1597
  }
1609
- if (utils$2.isArrayBufferView(data)) {
1598
+ if (utils$1.isArrayBufferView(data)) {
1610
1599
  return data.buffer;
1611
1600
  }
1612
- if (utils$2.isURLSearchParams(data)) {
1601
+ if (utils$1.isURLSearchParams(data)) {
1613
1602
  headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1614
1603
  return data.toString();
1615
1604
  }
@@ -1621,7 +1610,7 @@ const defaults = {
1621
1610
  return toURLEncodedForm(data, this.formSerializer).toString();
1622
1611
  }
1623
1612
 
1624
- if ((isFileList = utils$2.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1613
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1625
1614
  const _FormData = this.env && this.env.FormData;
1626
1615
 
1627
1616
  return toFormData(
@@ -1645,11 +1634,11 @@ const defaults = {
1645
1634
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1646
1635
  const JSONRequested = this.responseType === 'json';
1647
1636
 
1648
- if (utils$2.isResponse(data) || utils$2.isReadableStream(data)) {
1637
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1649
1638
  return data;
1650
1639
  }
1651
1640
 
1652
- if (data && utils$2.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1641
+ if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1653
1642
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
1654
1643
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
1655
1644
 
@@ -1697,13 +1686,13 @@ const defaults = {
1697
1686
  }
1698
1687
  };
1699
1688
 
1700
- utils$2.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1689
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1701
1690
  defaults.headers[method] = {};
1702
1691
  });
1703
1692
 
1704
1693
  // RawAxiosHeaders whose duplicates are ignored by node
1705
1694
  // c.f. https://nodejs.org/api/http.html#http_message_headers
1706
- const ignoreDuplicateOf = utils$2.toObjectSet([
1695
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1707
1696
  'age', 'authorization', 'content-length', 'content-type', 'etag',
1708
1697
  'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1709
1698
  'last-modified', 'location', 'max-forwards', 'proxy-authorization',
@@ -1764,7 +1753,7 @@ function normalizeValue(value) {
1764
1753
  return value;
1765
1754
  }
1766
1755
 
1767
- return utils$2.isArray(value) ? value.map(normalizeValue) : String(value);
1756
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1768
1757
  }
1769
1758
 
1770
1759
  function parseTokens(str) {
@@ -1782,7 +1771,7 @@ function parseTokens(str) {
1782
1771
  const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1783
1772
 
1784
1773
  function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1785
- if (utils$2.isFunction(filter)) {
1774
+ if (utils$1.isFunction(filter)) {
1786
1775
  return filter.call(this, value, header);
1787
1776
  }
1788
1777
 
@@ -1790,13 +1779,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1790
1779
  value = header;
1791
1780
  }
1792
1781
 
1793
- if (!utils$2.isString(value)) return;
1782
+ if (!utils$1.isString(value)) return;
1794
1783
 
1795
- if (utils$2.isString(filter)) {
1784
+ if (utils$1.isString(filter)) {
1796
1785
  return value.indexOf(filter) !== -1;
1797
1786
  }
1798
1787
 
1799
- if (utils$2.isRegExp(filter)) {
1788
+ if (utils$1.isRegExp(filter)) {
1800
1789
  return filter.test(value);
1801
1790
  }
1802
1791
  }
@@ -1809,7 +1798,7 @@ function formatHeader(header) {
1809
1798
  }
1810
1799
 
1811
1800
  function buildAccessors(obj, header) {
1812
- const accessorName = utils$2.toCamelCase(' ' + header);
1801
+ const accessorName = utils$1.toCamelCase(' ' + header);
1813
1802
 
1814
1803
  ['get', 'set', 'has'].forEach(methodName => {
1815
1804
  Object.defineProperty(obj, methodName + accessorName, {
@@ -1836,7 +1825,7 @@ class AxiosHeaders {
1836
1825
  throw new Error('header name must be a non-empty string');
1837
1826
  }
1838
1827
 
1839
- const key = utils$2.findKey(self, lHeader);
1828
+ const key = utils$1.findKey(self, lHeader);
1840
1829
 
1841
1830
  if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1842
1831
  self[key || _header] = normalizeValue(_value);
@@ -1844,13 +1833,13 @@ class AxiosHeaders {
1844
1833
  }
1845
1834
 
1846
1835
  const setHeaders = (headers, _rewrite) =>
1847
- utils$2.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1836
+ utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1848
1837
 
1849
- if (utils$2.isPlainObject(header) || header instanceof this.constructor) {
1838
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1850
1839
  setHeaders(header, valueOrRewrite);
1851
- } else if(utils$2.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1840
+ } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1852
1841
  setHeaders(parseHeaders(header), valueOrRewrite);
1853
- } else if (utils$2.isHeaders(header)) {
1842
+ } else if (utils$1.isHeaders(header)) {
1854
1843
  for (const [key, value] of header.entries()) {
1855
1844
  setHeader(value, key, rewrite);
1856
1845
  }
@@ -1865,7 +1854,7 @@ class AxiosHeaders {
1865
1854
  header = normalizeHeader(header);
1866
1855
 
1867
1856
  if (header) {
1868
- const key = utils$2.findKey(this, header);
1857
+ const key = utils$1.findKey(this, header);
1869
1858
 
1870
1859
  if (key) {
1871
1860
  const value = this[key];
@@ -1878,11 +1867,11 @@ class AxiosHeaders {
1878
1867
  return parseTokens(value);
1879
1868
  }
1880
1869
 
1881
- if (utils$2.isFunction(parser)) {
1870
+ if (utils$1.isFunction(parser)) {
1882
1871
  return parser.call(this, value, key);
1883
1872
  }
1884
1873
 
1885
- if (utils$2.isRegExp(parser)) {
1874
+ if (utils$1.isRegExp(parser)) {
1886
1875
  return parser.exec(value);
1887
1876
  }
1888
1877
 
@@ -1895,7 +1884,7 @@ class AxiosHeaders {
1895
1884
  header = normalizeHeader(header);
1896
1885
 
1897
1886
  if (header) {
1898
- const key = utils$2.findKey(this, header);
1887
+ const key = utils$1.findKey(this, header);
1899
1888
 
1900
1889
  return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1901
1890
  }
@@ -1911,7 +1900,7 @@ class AxiosHeaders {
1911
1900
  _header = normalizeHeader(_header);
1912
1901
 
1913
1902
  if (_header) {
1914
- const key = utils$2.findKey(self, _header);
1903
+ const key = utils$1.findKey(self, _header);
1915
1904
 
1916
1905
  if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1917
1906
  delete self[key];
@@ -1921,7 +1910,7 @@ class AxiosHeaders {
1921
1910
  }
1922
1911
  }
1923
1912
 
1924
- if (utils$2.isArray(header)) {
1913
+ if (utils$1.isArray(header)) {
1925
1914
  header.forEach(deleteHeader);
1926
1915
  } else {
1927
1916
  deleteHeader(header);
@@ -1950,8 +1939,8 @@ class AxiosHeaders {
1950
1939
  const self = this;
1951
1940
  const headers = {};
1952
1941
 
1953
- utils$2.forEach(this, (value, header) => {
1954
- const key = utils$2.findKey(headers, header);
1942
+ utils$1.forEach(this, (value, header) => {
1943
+ const key = utils$1.findKey(headers, header);
1955
1944
 
1956
1945
  if (key) {
1957
1946
  self[key] = normalizeValue(value);
@@ -1980,8 +1969,8 @@ class AxiosHeaders {
1980
1969
  toJSON(asStrings) {
1981
1970
  const obj = Object.create(null);
1982
1971
 
1983
- utils$2.forEach(this, (value, header) => {
1984
- value != null && value !== false && (obj[header] = asStrings && utils$2.isArray(value) ? value.join(', ') : value);
1972
+ utils$1.forEach(this, (value, header) => {
1973
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1985
1974
  });
1986
1975
 
1987
1976
  return obj;
@@ -2028,7 +2017,7 @@ class AxiosHeaders {
2028
2017
  }
2029
2018
  }
2030
2019
 
2031
- utils$2.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2020
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2032
2021
 
2033
2022
  return this;
2034
2023
  }
@@ -2037,7 +2026,7 @@ class AxiosHeaders {
2037
2026
  AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
2038
2027
 
2039
2028
  // reserved names hotfix
2040
- utils$2.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
2029
+ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
2041
2030
  let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2042
2031
  return {
2043
2032
  get: () => value,
@@ -2047,7 +2036,7 @@ utils$2.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
2047
2036
  }
2048
2037
  });
2049
2038
 
2050
- utils$2.freezeMethods(AxiosHeaders);
2039
+ utils$1.freezeMethods(AxiosHeaders);
2051
2040
 
2052
2041
  /**
2053
2042
  * Transform the data for a request or a response
@@ -2063,7 +2052,7 @@ function transformData(fns, response) {
2063
2052
  const headers = AxiosHeaders.from(context.headers);
2064
2053
  let data = context.data;
2065
2054
 
2066
- utils$2.forEach(fns, function transform(fn) {
2055
+ utils$1.forEach(fns, function transform(fn) {
2067
2056
  data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
2068
2057
  });
2069
2058
 
@@ -2091,7 +2080,7 @@ function CanceledError(message, config, request) {
2091
2080
  this.name = 'CanceledError';
2092
2081
  }
2093
2082
 
2094
- utils$2.inherits(CanceledError, AxiosError, {
2083
+ utils$1.inherits(CanceledError, AxiosError, {
2095
2084
  __CANCEL__: true
2096
2085
  });
2097
2086
 
@@ -2258,70 +2247,20 @@ const progressEventDecorator = (total, throttled) => {
2258
2247
  }), throttled[1]];
2259
2248
  };
2260
2249
 
2261
- const asyncDecorator = (fn) => (...args) => utils$2.asap(() => fn(...args));
2262
-
2263
- var isURLSameOrigin = platform.hasStandardBrowserEnv ?
2264
-
2265
- // Standard browser envs have full support of the APIs needed to test
2266
- // whether the request URL is of the same origin as current location.
2267
- (function standardBrowserEnv() {
2268
- const msie = /(msie|trident)/i.test(navigator.userAgent);
2269
- const urlParsingNode = document.createElement('a');
2270
- let originURL;
2250
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2271
2251
 
2272
- /**
2273
- * Parse a URL to discover its components
2274
- *
2275
- * @param {String} url The URL to be parsed
2276
- * @returns {Object}
2277
- */
2278
- function resolveURL(url) {
2279
- let href = url;
2280
-
2281
- if (msie) {
2282
- // IE needs attribute set twice to normalize properties
2283
- urlParsingNode.setAttribute('href', href);
2284
- href = urlParsingNode.href;
2285
- }
2252
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2253
+ url = new URL(url, platform.origin);
2286
2254
 
2287
- urlParsingNode.setAttribute('href', href);
2288
-
2289
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2290
- return {
2291
- href: urlParsingNode.href,
2292
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2293
- host: urlParsingNode.host,
2294
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2295
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2296
- hostname: urlParsingNode.hostname,
2297
- port: urlParsingNode.port,
2298
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2299
- urlParsingNode.pathname :
2300
- '/' + urlParsingNode.pathname
2301
- };
2302
- }
2303
-
2304
- originURL = resolveURL(window.location.href);
2305
-
2306
- /**
2307
- * Determine if a URL shares the same origin as the current location
2308
- *
2309
- * @param {String} requestURL The URL to test
2310
- * @returns {boolean} True if URL shares the same origin, otherwise false
2311
- */
2312
- return function isURLSameOrigin(requestURL) {
2313
- const parsed = (utils$2.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2314
- return (parsed.protocol === originURL.protocol &&
2315
- parsed.host === originURL.host);
2316
- };
2317
- })() :
2318
-
2319
- // Non standard browser envs (web workers, react-native) lack needed support.
2320
- (function nonStandardBrowserEnv() {
2321
- return function isURLSameOrigin() {
2322
- return true;
2323
- };
2324
- })();
2255
+ return (
2256
+ origin.protocol === url.protocol &&
2257
+ origin.host === url.host &&
2258
+ (isMSIE || origin.port === url.port)
2259
+ );
2260
+ })(
2261
+ new URL(platform.origin),
2262
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2263
+ ) : () => true;
2325
2264
 
2326
2265
  var cookies = platform.hasStandardBrowserEnv ?
2327
2266
 
@@ -2330,11 +2269,11 @@ var cookies = platform.hasStandardBrowserEnv ?
2330
2269
  write(name, value, expires, path, domain, secure) {
2331
2270
  const cookie = [name + '=' + encodeURIComponent(value)];
2332
2271
 
2333
- utils$2.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2272
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2334
2273
 
2335
- utils$2.isString(path) && cookie.push('path=' + path);
2274
+ utils$1.isString(path) && cookie.push('path=' + path);
2336
2275
 
2337
- utils$2.isString(domain) && cookie.push('domain=' + domain);
2276
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
2338
2277
 
2339
2278
  secure === true && cookie.push('secure');
2340
2279
 
@@ -2400,8 +2339,9 @@ function combineURLs(baseURL, relativeURL) {
2400
2339
  *
2401
2340
  * @returns {string} The combined full path
2402
2341
  */
2403
- function buildFullPath(baseURL, requestedURL) {
2404
- if (baseURL && !isAbsoluteURL(requestedURL)) {
2342
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2343
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
2344
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2405
2345
  return combineURLs(baseURL, requestedURL);
2406
2346
  }
2407
2347
  return requestedURL;
@@ -2423,38 +2363,38 @@ function mergeConfig(config1, config2) {
2423
2363
  config2 = config2 || {};
2424
2364
  const config = {};
2425
2365
 
2426
- function getMergedValue(target, source, caseless) {
2427
- if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source)) {
2428
- return utils$2.merge.call({caseless}, target, source);
2429
- } else if (utils$2.isPlainObject(source)) {
2430
- return utils$2.merge({}, source);
2431
- } else if (utils$2.isArray(source)) {
2366
+ function getMergedValue(target, source, prop, caseless) {
2367
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2368
+ return utils$1.merge.call({caseless}, target, source);
2369
+ } else if (utils$1.isPlainObject(source)) {
2370
+ return utils$1.merge({}, source);
2371
+ } else if (utils$1.isArray(source)) {
2432
2372
  return source.slice();
2433
2373
  }
2434
2374
  return source;
2435
2375
  }
2436
2376
 
2437
2377
  // eslint-disable-next-line consistent-return
2438
- function mergeDeepProperties(a, b, caseless) {
2439
- if (!utils$2.isUndefined(b)) {
2440
- return getMergedValue(a, b, caseless);
2441
- } else if (!utils$2.isUndefined(a)) {
2442
- return getMergedValue(undefined, a, caseless);
2378
+ function mergeDeepProperties(a, b, prop , caseless) {
2379
+ if (!utils$1.isUndefined(b)) {
2380
+ return getMergedValue(a, b, prop , caseless);
2381
+ } else if (!utils$1.isUndefined(a)) {
2382
+ return getMergedValue(undefined, a, prop , caseless);
2443
2383
  }
2444
2384
  }
2445
2385
 
2446
2386
  // eslint-disable-next-line consistent-return
2447
2387
  function valueFromConfig2(a, b) {
2448
- if (!utils$2.isUndefined(b)) {
2388
+ if (!utils$1.isUndefined(b)) {
2449
2389
  return getMergedValue(undefined, b);
2450
2390
  }
2451
2391
  }
2452
2392
 
2453
2393
  // eslint-disable-next-line consistent-return
2454
2394
  function defaultToConfig2(a, b) {
2455
- if (!utils$2.isUndefined(b)) {
2395
+ if (!utils$1.isUndefined(b)) {
2456
2396
  return getMergedValue(undefined, b);
2457
- } else if (!utils$2.isUndefined(a)) {
2397
+ } else if (!utils$1.isUndefined(a)) {
2458
2398
  return getMergedValue(undefined, a);
2459
2399
  }
2460
2400
  }
@@ -2497,13 +2437,13 @@ function mergeConfig(config1, config2) {
2497
2437
  socketPath: defaultToConfig2,
2498
2438
  responseEncoding: defaultToConfig2,
2499
2439
  validateStatus: mergeDirectKeys,
2500
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2440
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2501
2441
  };
2502
2442
 
2503
- utils$2.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2443
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2504
2444
  const merge = mergeMap[prop] || mergeDeepProperties;
2505
2445
  const configValue = merge(config1[prop], config2[prop], prop);
2506
- (utils$2.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2446
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2507
2447
  });
2508
2448
 
2509
2449
  return config;
@@ -2516,7 +2456,7 @@ var resolveConfig = (config) => {
2516
2456
 
2517
2457
  newConfig.headers = headers = AxiosHeaders.from(headers);
2518
2458
 
2519
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
2459
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
2520
2460
 
2521
2461
  // HTTP basic authentication
2522
2462
  if (auth) {
@@ -2527,7 +2467,7 @@ var resolveConfig = (config) => {
2527
2467
 
2528
2468
  let contentType;
2529
2469
 
2530
- if (utils$2.isFormData(data)) {
2470
+ if (utils$1.isFormData(data)) {
2531
2471
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2532
2472
  headers.setContentType(undefined); // Let the browser set it
2533
2473
  } else if ((contentType = headers.getContentType()) !== false) {
@@ -2542,7 +2482,7 @@ var resolveConfig = (config) => {
2542
2482
  // Specifically not if we're in a web worker, or react-native.
2543
2483
 
2544
2484
  if (platform.hasStandardBrowserEnv) {
2545
- withXSRFToken && utils$2.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2485
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2546
2486
 
2547
2487
  if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
2548
2488
  // Add xsrf header
@@ -2683,13 +2623,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2683
2623
 
2684
2624
  // Add headers to the request
2685
2625
  if ('setRequestHeader' in request) {
2686
- utils$2.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2626
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2687
2627
  request.setRequestHeader(key, val);
2688
2628
  });
2689
2629
  }
2690
2630
 
2691
2631
  // Add withCredentials to request if needed
2692
- if (!utils$2.isUndefined(_config.withCredentials)) {
2632
+ if (!utils$1.isUndefined(_config.withCredentials)) {
2693
2633
  request.withCredentials = !!_config.withCredentials;
2694
2634
  }
2695
2635
 
@@ -2745,45 +2685,46 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2745
2685
  };
2746
2686
 
2747
2687
  const composeSignals = (signals, timeout) => {
2748
- let controller = new AbortController();
2688
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
2749
2689
 
2750
- let aborted;
2690
+ if (timeout || length) {
2691
+ let controller = new AbortController();
2751
2692
 
2752
- const onabort = function (cancel) {
2753
- if (!aborted) {
2754
- aborted = true;
2755
- unsubscribe();
2756
- const err = cancel instanceof Error ? cancel : this.reason;
2757
- controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
2758
- }
2759
- };
2693
+ let aborted;
2760
2694
 
2761
- let timer = timeout && setTimeout(() => {
2762
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
2763
- }, timeout);
2695
+ const onabort = function (reason) {
2696
+ if (!aborted) {
2697
+ aborted = true;
2698
+ unsubscribe();
2699
+ const err = reason instanceof Error ? reason : this.reason;
2700
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
2701
+ }
2702
+ };
2764
2703
 
2765
- const unsubscribe = () => {
2766
- if (signals) {
2767
- timer && clearTimeout(timer);
2704
+ let timer = timeout && setTimeout(() => {
2768
2705
  timer = null;
2769
- signals.forEach(signal => {
2770
- signal &&
2771
- (signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
2772
- });
2773
- signals = null;
2774
- }
2775
- };
2706
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
2707
+ }, timeout);
2708
+
2709
+ const unsubscribe = () => {
2710
+ if (signals) {
2711
+ timer && clearTimeout(timer);
2712
+ timer = null;
2713
+ signals.forEach(signal => {
2714
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
2715
+ });
2716
+ signals = null;
2717
+ }
2718
+ };
2776
2719
 
2777
- signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
2720
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
2778
2721
 
2779
- const {signal} = controller;
2722
+ const {signal} = controller;
2780
2723
 
2781
- signal.unsubscribe = unsubscribe;
2724
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
2782
2725
 
2783
- return [signal, () => {
2784
- timer && clearTimeout(timer);
2785
- timer = null;
2786
- }];
2726
+ return signal;
2727
+ }
2787
2728
  };
2788
2729
 
2789
2730
  const streamChunk = function* (chunk, chunkSize) {
@@ -2804,14 +2745,34 @@ const streamChunk = function* (chunk, chunkSize) {
2804
2745
  }
2805
2746
  };
2806
2747
 
2807
- const readBytes = async function* (iterable, chunkSize, encode) {
2808
- for await (const chunk of iterable) {
2809
- yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
2748
+ const readBytes = async function* (iterable, chunkSize) {
2749
+ for await (const chunk of readStream(iterable)) {
2750
+ yield* streamChunk(chunk, chunkSize);
2751
+ }
2752
+ };
2753
+
2754
+ const readStream = async function* (stream) {
2755
+ if (stream[Symbol.asyncIterator]) {
2756
+ yield* stream;
2757
+ return;
2758
+ }
2759
+
2760
+ const reader = stream.getReader();
2761
+ try {
2762
+ for (;;) {
2763
+ const {done, value} = await reader.read();
2764
+ if (done) {
2765
+ break;
2766
+ }
2767
+ yield value;
2768
+ }
2769
+ } finally {
2770
+ await reader.cancel();
2810
2771
  }
2811
2772
  };
2812
2773
 
2813
- const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
2814
- const iterator = readBytes(stream, chunkSize, encode);
2774
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2775
+ const iterator = readBytes(stream, chunkSize);
2815
2776
 
2816
2777
  let bytes = 0;
2817
2778
  let done;
@@ -2888,7 +2849,7 @@ const supportsRequestStream = isReadableStreamSupported && test(() => {
2888
2849
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
2889
2850
 
2890
2851
  const supportsResponseStream = isReadableStreamSupported &&
2891
- test(() => utils$2.isReadableStream(new Response('').body));
2852
+ test(() => utils$1.isReadableStream(new Response('').body));
2892
2853
 
2893
2854
 
2894
2855
  const resolvers = {
@@ -2897,7 +2858,7 @@ const resolvers = {
2897
2858
 
2898
2859
  isFetchSupported && (((res) => {
2899
2860
  ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2900
- !resolvers[type] && (resolvers[type] = utils$2.isFunction(res[type]) ? (res) => res[type]() :
2861
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
2901
2862
  (_, config) => {
2902
2863
  throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
2903
2864
  });
@@ -2909,29 +2870,33 @@ const getBodyLength = async (body) => {
2909
2870
  return 0;
2910
2871
  }
2911
2872
 
2912
- if(utils$2.isBlob(body)) {
2873
+ if(utils$1.isBlob(body)) {
2913
2874
  return body.size;
2914
2875
  }
2915
2876
 
2916
- if(utils$2.isSpecCompliantForm(body)) {
2917
- return (await new Request(body).arrayBuffer()).byteLength;
2877
+ if(utils$1.isSpecCompliantForm(body)) {
2878
+ const _request = new Request(platform.origin, {
2879
+ method: 'POST',
2880
+ body,
2881
+ });
2882
+ return (await _request.arrayBuffer()).byteLength;
2918
2883
  }
2919
2884
 
2920
- if(utils$2.isArrayBufferView(body) || utils$2.isArrayBuffer(body)) {
2885
+ if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2921
2886
  return body.byteLength;
2922
2887
  }
2923
2888
 
2924
- if(utils$2.isURLSearchParams(body)) {
2889
+ if(utils$1.isURLSearchParams(body)) {
2925
2890
  body = body + '';
2926
2891
  }
2927
2892
 
2928
- if(utils$2.isString(body)) {
2893
+ if(utils$1.isString(body)) {
2929
2894
  return (await encodeText(body)).byteLength;
2930
2895
  }
2931
2896
  };
2932
2897
 
2933
2898
  const resolveBodyLength = async (headers, body) => {
2934
- const length = utils$2.toFiniteNumber(headers.getContentLength());
2899
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
2935
2900
 
2936
2901
  return length == null ? getBodyLength(body) : length;
2937
2902
  };
@@ -2954,18 +2919,13 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2954
2919
 
2955
2920
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
2956
2921
 
2957
- let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
2958
- composeSignals([signal, cancelToken], timeout) : [];
2959
-
2960
- let finished, request;
2922
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2961
2923
 
2962
- const onFinish = () => {
2963
- !finished && setTimeout(() => {
2964
- composedSignal && composedSignal.unsubscribe();
2965
- });
2924
+ let request;
2966
2925
 
2967
- finished = true;
2968
- };
2926
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2927
+ composedSignal.unsubscribe();
2928
+ });
2969
2929
 
2970
2930
  let requestContentLength;
2971
2931
 
@@ -2982,7 +2942,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2982
2942
 
2983
2943
  let contentTypeHeader;
2984
2944
 
2985
- if (utils$2.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
2945
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
2986
2946
  headers.setContentType(contentTypeHeader);
2987
2947
  }
2988
2948
 
@@ -2992,14 +2952,17 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2992
2952
  progressEventReducer(asyncDecorator(onUploadProgress))
2993
2953
  );
2994
2954
 
2995
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush, encodeText);
2955
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
2996
2956
  }
2997
2957
  }
2998
2958
 
2999
- if (!utils$2.isString(withCredentials)) {
2959
+ if (!utils$1.isString(withCredentials)) {
3000
2960
  withCredentials = withCredentials ? 'include' : 'omit';
3001
2961
  }
3002
2962
 
2963
+ // Cloudflare Workers throws when credentials are defined
2964
+ // see https://github.com/cloudflare/workerd/issues/902
2965
+ const isCredentialsSupported = "credentials" in Request.prototype;
3003
2966
  request = new Request(url, {
3004
2967
  ...fetchOptions,
3005
2968
  signal: composedSignal,
@@ -3007,21 +2970,21 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3007
2970
  headers: headers.normalize().toJSON(),
3008
2971
  body: data,
3009
2972
  duplex: "half",
3010
- credentials: withCredentials
2973
+ credentials: isCredentialsSupported ? withCredentials : undefined
3011
2974
  });
3012
2975
 
3013
2976
  let response = await fetch(request);
3014
2977
 
3015
2978
  const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3016
2979
 
3017
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
2980
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3018
2981
  const options = {};
3019
2982
 
3020
2983
  ['status', 'statusText', 'headers'].forEach(prop => {
3021
2984
  options[prop] = response[prop];
3022
2985
  });
3023
2986
 
3024
- const responseContentLength = utils$2.toFiniteNumber(response.headers.get('content-length'));
2987
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3025
2988
 
3026
2989
  const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3027
2990
  responseContentLength,
@@ -3031,19 +2994,17 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3031
2994
  response = new Response(
3032
2995
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3033
2996
  flush && flush();
3034
- isStreamResponse && onFinish();
3035
- }, encodeText),
2997
+ unsubscribe && unsubscribe();
2998
+ }),
3036
2999
  options
3037
3000
  );
3038
3001
  }
3039
3002
 
3040
3003
  responseType = responseType || 'text';
3041
3004
 
3042
- let responseData = await resolvers[utils$2.findKey(resolvers, responseType) || 'text'](response, config);
3005
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3043
3006
 
3044
- !isStreamResponse && onFinish();
3045
-
3046
- stopTimeout && stopTimeout();
3007
+ !isStreamResponse && unsubscribe && unsubscribe();
3047
3008
 
3048
3009
  return await new Promise((resolve, reject) => {
3049
3010
  settle(resolve, reject, {
@@ -3056,7 +3017,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
3056
3017
  });
3057
3018
  })
3058
3019
  } catch (err) {
3059
- onFinish();
3020
+ unsubscribe && unsubscribe();
3060
3021
 
3061
3022
  if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3062
3023
  throw Object.assign(
@@ -3077,7 +3038,7 @@ const knownAdapters = {
3077
3038
  fetch: fetchAdapter
3078
3039
  };
3079
3040
 
3080
- utils$2.forEach(knownAdapters, (fn, value) => {
3041
+ utils$1.forEach(knownAdapters, (fn, value) => {
3081
3042
  if (fn) {
3082
3043
  try {
3083
3044
  Object.defineProperty(fn, 'name', {value});
@@ -3090,11 +3051,11 @@ utils$2.forEach(knownAdapters, (fn, value) => {
3090
3051
 
3091
3052
  const renderReason = (reason) => `- ${reason}`;
3092
3053
 
3093
- const isResolvedHandle = (adapter) => utils$2.isFunction(adapter) || adapter === null || adapter === false;
3054
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3094
3055
 
3095
3056
  var adapters = {
3096
3057
  getAdapter: (adapters) => {
3097
- adapters = utils$2.isArray(adapters) ? adapters : [adapters];
3058
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3098
3059
 
3099
3060
  const {length} = adapters;
3100
3061
  let nameOrAdapter;
@@ -3218,7 +3179,7 @@ function dispatchRequest(config) {
3218
3179
  });
3219
3180
  }
3220
3181
 
3221
- const VERSION = "1.7.4";
3182
+ const VERSION = "1.8.4";
3222
3183
 
3223
3184
  const validators$1 = {};
3224
3185
 
@@ -3269,6 +3230,14 @@ validators$1.transitional = function transitional(validator, version, message) {
3269
3230
  };
3270
3231
  };
3271
3232
 
3233
+ validators$1.spelling = function spelling(correctSpelling) {
3234
+ return (value, opt) => {
3235
+ // eslint-disable-next-line no-console
3236
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3237
+ return true;
3238
+ }
3239
+ };
3240
+
3272
3241
  /**
3273
3242
  * Assert object's properties type
3274
3243
  *
@@ -3338,9 +3307,9 @@ class Axios {
3338
3307
  return await this._request(configOrUrl, config);
3339
3308
  } catch (err) {
3340
3309
  if (err instanceof Error) {
3341
- let dummy;
3310
+ let dummy = {};
3342
3311
 
3343
- Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
3312
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3344
3313
 
3345
3314
  // slice off the Error: ... line
3346
3315
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
@@ -3383,7 +3352,7 @@ class Axios {
3383
3352
  }
3384
3353
 
3385
3354
  if (paramsSerializer != null) {
3386
- if (utils$2.isFunction(paramsSerializer)) {
3355
+ if (utils$1.isFunction(paramsSerializer)) {
3387
3356
  config.paramsSerializer = {
3388
3357
  serialize: paramsSerializer
3389
3358
  };
@@ -3395,16 +3364,28 @@ class Axios {
3395
3364
  }
3396
3365
  }
3397
3366
 
3367
+ // Set config.allowAbsoluteUrls
3368
+ if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
3369
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
3370
+ } else {
3371
+ config.allowAbsoluteUrls = true;
3372
+ }
3373
+
3374
+ validator.assertOptions(config, {
3375
+ baseUrl: validators.spelling('baseURL'),
3376
+ withXsrfToken: validators.spelling('withXSRFToken')
3377
+ }, true);
3378
+
3398
3379
  // Set config.method
3399
3380
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3400
3381
 
3401
3382
  // Flatten headers
3402
- let contextHeaders = headers && utils$2.merge(
3383
+ let contextHeaders = headers && utils$1.merge(
3403
3384
  headers.common,
3404
3385
  headers[config.method]
3405
3386
  );
3406
3387
 
3407
- headers && utils$2.forEach(
3388
+ headers && utils$1.forEach(
3408
3389
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3409
3390
  (method) => {
3410
3391
  delete headers[method];
@@ -3485,13 +3466,13 @@ class Axios {
3485
3466
 
3486
3467
  getUri(config) {
3487
3468
  config = mergeConfig(this.defaults, config);
3488
- const fullPath = buildFullPath(config.baseURL, config.url);
3469
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
3489
3470
  return buildURL(fullPath, config.params, config.paramsSerializer);
3490
3471
  }
3491
3472
  }
3492
3473
 
3493
3474
  // Provide aliases for supported request methods
3494
- utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3475
+ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3495
3476
  /*eslint func-names:0*/
3496
3477
  Axios.prototype[method] = function(url, config) {
3497
3478
  return this.request(mergeConfig(config || {}, {
@@ -3502,7 +3483,7 @@ utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
3502
3483
  };
3503
3484
  });
3504
3485
 
3505
- utils$2.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3486
+ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3506
3487
  /*eslint func-names:0*/
3507
3488
 
3508
3489
  function generateHTTPMethod(isForm) {
@@ -3623,6 +3604,20 @@ class CancelToken {
3623
3604
  }
3624
3605
  }
3625
3606
 
3607
+ toAbortSignal() {
3608
+ const controller = new AbortController();
3609
+
3610
+ const abort = (err) => {
3611
+ controller.abort(err);
3612
+ };
3613
+
3614
+ this.subscribe(abort);
3615
+
3616
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
3617
+
3618
+ return controller.signal;
3619
+ }
3620
+
3626
3621
  /**
3627
3622
  * Returns an object that contains a new `CancelToken` and a function that, when called,
3628
3623
  * cancels the `CancelToken`.
@@ -3674,7 +3669,7 @@ function spread(callback) {
3674
3669
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3675
3670
  */
3676
3671
  function isAxiosError(payload) {
3677
- return utils$2.isObject(payload) && (payload.isAxiosError === true);
3672
+ return utils$1.isObject(payload) && (payload.isAxiosError === true);
3678
3673
  }
3679
3674
 
3680
3675
  const HttpStatusCode = {
@@ -3759,10 +3754,10 @@ function createInstance(defaultConfig) {
3759
3754
  const instance = bind(Axios.prototype.request, context);
3760
3755
 
3761
3756
  // Copy axios.prototype to instance
3762
- utils$2.extend(instance, Axios.prototype, context, {allOwnKeys: true});
3757
+ utils$1.extend(instance, Axios.prototype, context, {allOwnKeys: true});
3763
3758
 
3764
3759
  // Copy context to instance
3765
- utils$2.extend(instance, context, null, {allOwnKeys: true});
3760
+ utils$1.extend(instance, context, null, {allOwnKeys: true});
3766
3761
 
3767
3762
  // Factory for creating new instances
3768
3763
  instance.create = function create(instanceConfig) {
@@ -3806,7 +3801,7 @@ axios.mergeConfig = mergeConfig;
3806
3801
 
3807
3802
  axios.AxiosHeaders = AxiosHeaders;
3808
3803
 
3809
- axios.formToJSON = thing => formDataToJSON(utils$2.isHTMLForm(thing) ? new FormData(thing) : thing);
3804
+ axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3810
3805
 
3811
3806
  axios.getAdapter = adapters.getAdapter;
3812
3807
 
@@ -3877,143 +3872,6 @@ const getRawTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
3877
3872
  return (yield axios.get(`${urlForNetwork(p.network)}/rawtx/${p.txid}`)).data.rawtx;
3878
3873
  });
3879
3874
 
3880
- function getDefaultExportFromCjs (x) {
3881
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
3882
- }
3883
-
3884
- var utils;
3885
- var hasRequiredUtils;
3886
-
3887
- function requireUtils () {
3888
- if (hasRequiredUtils) return utils;
3889
- hasRequiredUtils = 1;
3890
- // baseline estimates, used to improve performance
3891
- var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
3892
- var TX_INPUT_BASE = 32 + 4 + 1 + 4;
3893
- var TX_INPUT_PUBKEYHASH = 107;
3894
- var TX_OUTPUT_BASE = 8 + 1;
3895
- var TX_OUTPUT_PUBKEYHASH = 25;
3896
-
3897
- function inputBytes (input) {
3898
- return TX_INPUT_BASE + (input.script ? input.script.length : TX_INPUT_PUBKEYHASH)
3899
- }
3900
-
3901
- function outputBytes (output) {
3902
- return TX_OUTPUT_BASE + (output.script ? output.script.length : TX_OUTPUT_PUBKEYHASH)
3903
- }
3904
-
3905
- function dustThreshold (output, feeRate) {
3906
- /* ... classify the output for input estimate */
3907
- return inputBytes({}) * feeRate
3908
- }
3909
-
3910
- function transactionBytes (inputs, outputs) {
3911
- return TX_EMPTY_SIZE +
3912
- inputs.reduce(function (a, x) { return a + inputBytes(x) }, 0) +
3913
- outputs.reduce(function (a, x) { return a + outputBytes(x) }, 0)
3914
- }
3915
-
3916
- function uintOrNaN (v) {
3917
- if (typeof v !== 'number') return NaN
3918
- if (!isFinite(v)) return NaN
3919
- if (Math.floor(v) !== v) return NaN
3920
- if (v < 0) return NaN
3921
- return v
3922
- }
3923
-
3924
- function sumForgiving (range) {
3925
- return range.reduce(function (a, x) { return a + (isFinite(x.value) ? x.value : 0) }, 0)
3926
- }
3927
-
3928
- function sumOrNaN (range) {
3929
- return range.reduce(function (a, x) { return a + uintOrNaN(x.value) }, 0)
3930
- }
3931
-
3932
- var BLANK_OUTPUT = outputBytes({});
3933
-
3934
- function finalize (inputs, outputs, feeRate) {
3935
- var bytesAccum = transactionBytes(inputs, outputs);
3936
- var feeAfterExtraOutput = feeRate * (bytesAccum + BLANK_OUTPUT);
3937
- var remainderAfterExtraOutput = sumOrNaN(inputs) - (sumOrNaN(outputs) + feeAfterExtraOutput);
3938
-
3939
- // is it worth a change output?
3940
- if (remainderAfterExtraOutput > dustThreshold({}, feeRate)) {
3941
- outputs = outputs.concat({ value: remainderAfterExtraOutput });
3942
- }
3943
-
3944
- var fee = sumOrNaN(inputs) - sumOrNaN(outputs);
3945
- if (!isFinite(fee)) return { fee: feeRate * bytesAccum }
3946
-
3947
- return {
3948
- inputs: inputs,
3949
- outputs: outputs,
3950
- fee: fee
3951
- }
3952
- }
3953
-
3954
- utils = {
3955
- dustThreshold: dustThreshold,
3956
- finalize: finalize,
3957
- inputBytes: inputBytes,
3958
- outputBytes: outputBytes,
3959
- sumOrNaN: sumOrNaN,
3960
- sumForgiving: sumForgiving,
3961
- transactionBytes: transactionBytes,
3962
- uintOrNaN: uintOrNaN
3963
- };
3964
- return utils;
3965
- }
3966
-
3967
- var accumulative$1;
3968
- var hasRequiredAccumulative;
3969
-
3970
- function requireAccumulative () {
3971
- if (hasRequiredAccumulative) return accumulative$1;
3972
- hasRequiredAccumulative = 1;
3973
- var utils = requireUtils();
3974
-
3975
- // add inputs until we reach or surpass the target value (or deplete)
3976
- // worst-case: O(n)
3977
- accumulative$1 = function accumulative (utxos, outputs, feeRate) {
3978
- if (!isFinite(utils.uintOrNaN(feeRate))) return {}
3979
- var bytesAccum = utils.transactionBytes([], outputs);
3980
-
3981
- var inAccum = 0;
3982
- var inputs = [];
3983
- var outAccum = utils.sumOrNaN(outputs);
3984
-
3985
- for (var i = 0; i < utxos.length; ++i) {
3986
- var utxo = utxos[i];
3987
- var utxoBytes = utils.inputBytes(utxo);
3988
- var utxoFee = feeRate * utxoBytes;
3989
- var utxoValue = utils.uintOrNaN(utxo.value);
3990
-
3991
- // skip detrimental input
3992
- if (utxoFee > utxo.value) {
3993
- if (i === utxos.length - 1) return { fee: feeRate * (bytesAccum + utxoBytes) }
3994
- continue
3995
- }
3996
-
3997
- bytesAccum += utxoBytes;
3998
- inAccum += utxoValue;
3999
- inputs.push(utxo);
4000
-
4001
- var fee = feeRate * bytesAccum;
4002
-
4003
- // go again?
4004
- if (inAccum < outAccum + fee) continue
4005
-
4006
- return utils.finalize(inputs, outputs, feeRate)
4007
- }
4008
-
4009
- return { fee: feeRate * bytesAccum }
4010
- };
4011
- return accumulative$1;
4012
- }
4013
-
4014
- var accumulativeExports = requireAccumulative();
4015
- var accumulative = /*@__PURE__*/getDefaultExportFromCjs(accumulativeExports);
4016
-
4017
3875
  /**
4018
3876
  * Object containing the sizes (in bytes) of various components in a Dash transaction.
4019
3877
  */
@@ -4610,4 +4468,3 @@ class ClientLedger extends Client {
4610
4468
  }
4611
4469
 
4612
4470
  export { AssetDASH, BitgoProviders, BlockcypherDataProviders, ClientKeystore as Client, ClientKeystore, ClientLedger, DASHChain, DASH_DECIMAL, DASH_SYMBOL, DEFAULT_FEE_RATE, LOWER_FEE_BOUND, MIN_TX_FEE, UPPER_FEE_BOUND, buildTx, defaultDashParams, explorerProviders, getPrefix, validateAddress };
4613
- //# sourceMappingURL=index.esm.js.map