@xchainjs/xchain-aggregator 2.3.2 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -42,7 +42,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
42
42
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
43
43
  };
44
44
 
45
- const SupportedProtocols = ['Thorchain', 'Mayachain', 'Chainflip'];
45
+ const SupportedProtocols = ['Thorchain', 'Mayachain', 'Chainflip', 'OneClick'];
46
46
  const DEFAULT_CONFIG = {
47
47
  protocols: SupportedProtocols,
48
48
  network: xchainClient.Network.Mainnet,
@@ -508,9 +508,9 @@ const isFile = kindOfTest('File');
508
508
  * also have a `name` and `type` attribute to specify filename and content type
509
509
  *
510
510
  * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
511
- *
511
+ *
512
512
  * @param {*} value The value to test
513
- *
513
+ *
514
514
  * @returns {boolean} True if value is a React Native Blob, otherwise false
515
515
  */
516
516
  const isReactNativeBlob = (value) => {
@@ -520,9 +520,9 @@ const isReactNativeBlob = (value) => {
520
520
  /**
521
521
  * Determine if environment is React Native
522
522
  * ReactNative `FormData` has a non-standard `getParts()` method
523
- *
523
+ *
524
524
  * @param {*} formData The formData to test
525
- *
525
+ *
526
526
  * @returns {boolean} True if environment is React Native, otherwise false
527
527
  */
528
528
  const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
@@ -541,7 +541,7 @@ const isBlob = kindOfTest('Blob');
541
541
  *
542
542
  * @param {*} val The value to test
543
543
  *
544
- * @returns {boolean} True if value is a File, otherwise false
544
+ * @returns {boolean} True if value is a FileList, otherwise false
545
545
  */
546
546
  const isFileList = kindOfTest('FileList');
547
547
 
@@ -573,15 +573,17 @@ const G = getGlobal();
573
573
  const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
574
574
 
575
575
  const isFormData = (thing) => {
576
- let kind;
577
- return thing && (
578
- (FormDataCtor && thing instanceof FormDataCtor) || (
579
- isFunction$1(thing.append) && (
580
- (kind = kindOf(thing)) === 'formdata' ||
581
- // detect form-data instance
582
- (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
583
- )
584
- )
576
+ if (!thing) return false;
577
+ if (FormDataCtor && thing instanceof FormDataCtor) return true;
578
+ // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
579
+ const proto = getPrototypeOf(thing);
580
+ if (!proto || proto === Object.prototype) return false;
581
+ if (!isFunction$1(thing.append)) return false;
582
+ const kind = kindOf(thing);
583
+ return (
584
+ kind === 'formdata' ||
585
+ // detect form-data instance
586
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
585
587
  );
586
588
  };
587
589
 
@@ -717,7 +719,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
717
719
  *
718
720
  * @returns {Object} Result of all merge properties
719
721
  */
720
- function merge(/* obj1, obj2, obj3, ... */) {
722
+ function merge(...objs) {
721
723
  const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
722
724
  const result = {};
723
725
  const assignValue = (val, key) => {
@@ -727,8 +729,12 @@ function merge(/* obj1, obj2, obj3, ... */) {
727
729
  }
728
730
 
729
731
  const targetKey = (caseless && findKey(result, key)) || key;
730
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
731
- result[targetKey] = merge(result[targetKey], val);
732
+ // Read via own-prop only — a bare `result[targetKey]` walks the prototype
733
+ // chain, so a polluted Object.prototype value could surface here and get
734
+ // copied into the merged result.
735
+ const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
736
+ if (isPlainObject(existing) && isPlainObject(val)) {
737
+ result[targetKey] = merge(existing, val);
732
738
  } else if (isPlainObject(val)) {
733
739
  result[targetKey] = merge({}, val);
734
740
  } else if (isArray(val)) {
@@ -738,8 +744,8 @@ function merge(/* obj1, obj2, obj3, ... */) {
738
744
  }
739
745
  };
740
746
 
741
- for (let i = 0, l = arguments.length; i < l; i++) {
742
- arguments[i] && forEach(arguments[i], assignValue);
747
+ for (let i = 0, l = objs.length; i < l; i++) {
748
+ objs[i] && forEach(objs[i], assignValue);
743
749
  }
744
750
  return result;
745
751
  }
@@ -761,6 +767,9 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
761
767
  (val, key) => {
762
768
  if (thisArg && isFunction$1(val)) {
763
769
  Object.defineProperty(a, key, {
770
+ // Null-proto descriptor so a polluted Object.prototype.get cannot
771
+ // hijack defineProperty's accessor-vs-data resolution.
772
+ __proto__: null,
764
773
  value: bind(val, thisArg),
765
774
  writable: true,
766
775
  enumerable: true,
@@ -768,6 +777,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
768
777
  });
769
778
  } else {
770
779
  Object.defineProperty(a, key, {
780
+ __proto__: null,
771
781
  value: val,
772
782
  writable: true,
773
783
  enumerable: true,
@@ -806,12 +816,14 @@ const stripBOM = (content) => {
806
816
  const inherits = (constructor, superConstructor, props, descriptors) => {
807
817
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
808
818
  Object.defineProperty(constructor.prototype, 'constructor', {
819
+ __proto__: null,
809
820
  value: constructor,
810
821
  writable: true,
811
822
  enumerable: false,
812
823
  configurable: true,
813
824
  });
814
825
  Object.defineProperty(constructor, 'super', {
826
+ __proto__: null,
815
827
  value: superConstructor.prototype,
816
828
  });
817
829
  props && Object.assign(constructor.prototype, props);
@@ -993,7 +1005,7 @@ const reduceDescriptors = (obj, reducer) => {
993
1005
  const freezeMethods = (obj) => {
994
1006
  reduceDescriptors(obj, (descriptor, name) => {
995
1007
  // skip restricted props in strict mode
996
- if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
1008
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
997
1009
  return false;
998
1010
  }
999
1011
 
@@ -1067,11 +1079,11 @@ function isSpecCompliantForm(thing) {
1067
1079
  * @returns {Object} The JSON-compatible object.
1068
1080
  */
1069
1081
  const toJSONObject = (obj) => {
1070
- const stack = new Array(10);
1082
+ const visited = new WeakSet();
1071
1083
 
1072
- const visit = (source, i) => {
1084
+ const visit = (source) => {
1073
1085
  if (isObject(source)) {
1074
- if (stack.indexOf(source) >= 0) {
1086
+ if (visited.has(source)) {
1075
1087
  return;
1076
1088
  }
1077
1089
 
@@ -1081,15 +1093,16 @@ const toJSONObject = (obj) => {
1081
1093
  }
1082
1094
 
1083
1095
  if (!('toJSON' in source)) {
1084
- stack[i] = source;
1096
+ // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
1097
+ visited.add(source);
1085
1098
  const target = isArray(source) ? [] : {};
1086
1099
 
1087
1100
  forEach(source, (value, key) => {
1088
- const reducedValue = visit(value, i + 1);
1101
+ const reducedValue = visit(value);
1089
1102
  !isUndefined(reducedValue) && (target[key] = reducedValue);
1090
1103
  });
1091
1104
 
1092
- stack[i] = undefined;
1105
+ visited.delete(source);
1093
1106
 
1094
1107
  return target;
1095
1108
  }
@@ -1098,7 +1111,7 @@ const toJSONObject = (obj) => {
1098
1111
  return source;
1099
1112
  };
1100
1113
 
1101
- return visit(obj, 0);
1114
+ return visit(obj);
1102
1115
  };
1103
1116
 
1104
1117
  /**
@@ -1234,1297 +1247,1422 @@ var utils$1 = {
1234
1247
  isIterable,
1235
1248
  };
1236
1249
 
1237
- let AxiosError$1 = class AxiosError extends Error {
1238
- static from(error, code, config, request, response, customProps) {
1239
- const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1240
- axiosError.cause = error;
1241
- axiosError.name = error.name;
1250
+ // RawAxiosHeaders whose duplicates are ignored by node
1251
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1252
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1253
+ 'age',
1254
+ 'authorization',
1255
+ 'content-length',
1256
+ 'content-type',
1257
+ 'etag',
1258
+ 'expires',
1259
+ 'from',
1260
+ 'host',
1261
+ 'if-modified-since',
1262
+ 'if-unmodified-since',
1263
+ 'last-modified',
1264
+ 'location',
1265
+ 'max-forwards',
1266
+ 'proxy-authorization',
1267
+ 'referer',
1268
+ 'retry-after',
1269
+ 'user-agent',
1270
+ ]);
1242
1271
 
1243
- // Preserve status from the original error if not already set from response
1244
- if (error.status != null && axiosError.status == null) {
1245
- axiosError.status = error.status;
1246
- }
1272
+ /**
1273
+ * Parse headers into an object
1274
+ *
1275
+ * ```
1276
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1277
+ * Content-Type: application/json
1278
+ * Connection: keep-alive
1279
+ * Transfer-Encoding: chunked
1280
+ * ```
1281
+ *
1282
+ * @param {String} rawHeaders Headers needing to be parsed
1283
+ *
1284
+ * @returns {Object} Headers parsed into an object
1285
+ */
1286
+ var parseHeaders = (rawHeaders) => {
1287
+ const parsed = {};
1288
+ let key;
1289
+ let val;
1290
+ let i;
1247
1291
 
1248
- customProps && Object.assign(axiosError, customProps);
1249
- return axiosError;
1250
- }
1292
+ rawHeaders &&
1293
+ rawHeaders.split('\n').forEach(function parser(line) {
1294
+ i = line.indexOf(':');
1295
+ key = line.substring(0, i).trim().toLowerCase();
1296
+ val = line.substring(i + 1).trim();
1251
1297
 
1252
- /**
1253
- * Create an Error with the specified message, config, error code, request and response.
1254
- *
1255
- * @param {string} message The error message.
1256
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
1257
- * @param {Object} [config] The config.
1258
- * @param {Object} [request] The request.
1259
- * @param {Object} [response] The response.
1260
- *
1261
- * @returns {Error} The created error.
1262
- */
1263
- constructor(message, code, config, request, response) {
1264
- super(message);
1265
-
1266
- // Make message enumerable to maintain backward compatibility
1267
- // The native Error constructor sets message as non-enumerable,
1268
- // but axios < v1.13.3 had it as enumerable
1269
- Object.defineProperty(this, 'message', {
1270
- value: message,
1271
- enumerable: true,
1272
- writable: true,
1273
- configurable: true
1274
- });
1275
-
1276
- this.name = 'AxiosError';
1277
- this.isAxiosError = true;
1278
- code && (this.code = code);
1279
- config && (this.config = config);
1280
- request && (this.request = request);
1281
- if (response) {
1282
- this.response = response;
1283
- this.status = response.status;
1298
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1299
+ return;
1300
+ }
1301
+
1302
+ if (key === 'set-cookie') {
1303
+ if (parsed[key]) {
1304
+ parsed[key].push(val);
1305
+ } else {
1306
+ parsed[key] = [val];
1307
+ }
1308
+ } else {
1309
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1284
1310
  }
1311
+ });
1312
+
1313
+ return parsed;
1314
+ };
1315
+
1316
+ function trimSPorHTAB(str) {
1317
+ let start = 0;
1318
+ let end = str.length;
1319
+
1320
+ while (start < end) {
1321
+ const code = str.charCodeAt(start);
1322
+
1323
+ if (code !== 0x09 && code !== 0x20) {
1324
+ break;
1285
1325
  }
1286
1326
 
1287
- toJSON() {
1288
- return {
1289
- // Standard
1290
- message: this.message,
1291
- name: this.name,
1292
- // Microsoft
1293
- description: this.description,
1294
- number: this.number,
1295
- // Mozilla
1296
- fileName: this.fileName,
1297
- lineNumber: this.lineNumber,
1298
- columnNumber: this.columnNumber,
1299
- stack: this.stack,
1300
- // Axios
1301
- config: utils$1.toJSONObject(this.config),
1302
- code: this.code,
1303
- status: this.status,
1304
- };
1327
+ start += 1;
1305
1328
  }
1306
- };
1307
1329
 
1308
- // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1309
- AxiosError$1.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1310
- AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1311
- AxiosError$1.ECONNABORTED = 'ECONNABORTED';
1312
- AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';
1313
- AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';
1314
- AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1315
- AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';
1316
- AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1317
- AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1318
- AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
1319
- AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1320
- AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
1330
+ while (end > start) {
1331
+ const code = str.charCodeAt(end - 1);
1321
1332
 
1322
- // eslint-disable-next-line strict
1323
- var httpAdapter = null;
1333
+ if (code !== 0x09 && code !== 0x20) {
1334
+ break;
1335
+ }
1324
1336
 
1325
- /**
1326
- * Determines if the given thing is a array or js object.
1327
- *
1328
- * @param {string} thing - The object or array to be visited.
1329
- *
1330
- * @returns {boolean}
1331
- */
1332
- function isVisitable(thing) {
1333
- return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
1334
- }
1337
+ end -= 1;
1338
+ }
1335
1339
 
1336
- /**
1337
- * It removes the brackets from the end of a string
1338
- *
1339
- * @param {string} key - The key of the parameter.
1340
- *
1341
- * @returns {string} the key without the brackets.
1342
- */
1343
- function removeBrackets(key) {
1344
- return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1340
+ return start === 0 && end === str.length ? str : str.slice(start, end);
1345
1341
  }
1346
1342
 
1347
- /**
1348
- * It takes a path, a key, and a boolean, and returns a string
1349
- *
1350
- * @param {string} path - The path to the current key.
1351
- * @param {string} key - The key of the current object being iterated over.
1352
- * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
1353
- *
1354
- * @returns {string} The path to the current key.
1355
- */
1356
- function renderKey(path, key, dots) {
1357
- if (!path) return key;
1358
- return path
1359
- .concat(key)
1360
- .map(function each(token, i) {
1361
- // eslint-disable-next-line no-param-reassign
1362
- token = removeBrackets(token);
1363
- return !dots && i ? '[' + token + ']' : token;
1364
- })
1365
- .join(dots ? '.' : '');
1366
- }
1343
+ // The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
1344
+ // eslint-disable-next-line no-control-regex
1345
+ const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
1346
+ // eslint-disable-next-line no-control-regex
1347
+ const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
1367
1348
 
1368
- /**
1369
- * If the array is an array and none of its elements are visitable, then it's a flat array.
1370
- *
1371
- * @param {Array<any>} arr - The array to check
1372
- *
1373
- * @returns {boolean}
1374
- */
1375
- function isFlatArray(arr) {
1376
- return utils$1.isArray(arr) && !arr.some(isVisitable);
1349
+ function sanitizeValue(value, invalidChars) {
1350
+ if (utils$1.isArray(value)) {
1351
+ return value.map((item) => sanitizeValue(item, invalidChars));
1352
+ }
1353
+
1354
+ return trimSPorHTAB(String(value).replace(invalidChars, ''));
1377
1355
  }
1378
1356
 
1379
- const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1380
- return /^is[A-Z]/.test(prop);
1381
- });
1357
+ const sanitizeHeaderValue = (value) =>
1358
+ sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
1382
1359
 
1383
- /**
1384
- * Convert a data object to FormData
1385
- *
1386
- * @param {Object} obj
1387
- * @param {?Object} [formData]
1388
- * @param {?Object} [options]
1389
- * @param {Function} [options.visitor]
1390
- * @param {Boolean} [options.metaTokens = true]
1391
- * @param {Boolean} [options.dots = false]
1392
- * @param {?Boolean} [options.indexes = false]
1393
- *
1394
- * @returns {Object}
1395
- **/
1360
+ const sanitizeByteStringHeaderValue = (value) =>
1361
+ sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
1396
1362
 
1397
- /**
1398
- * It converts an object into a FormData object
1399
- *
1400
- * @param {Object<any, any>} obj - The object to convert to form data.
1401
- * @param {string} formData - The FormData object to append to.
1402
- * @param {Object<string, any>} options
1403
- *
1404
- * @returns
1405
- */
1406
- function toFormData$1(obj, formData, options) {
1407
- if (!utils$1.isObject(obj)) {
1408
- throw new TypeError('target must be an object');
1409
- }
1363
+ function toByteStringHeaderObject(headers) {
1364
+ const byteStringHeaders = Object.create(null);
1410
1365
 
1411
- // eslint-disable-next-line no-param-reassign
1412
- formData = formData || new (FormData)();
1366
+ utils$1.forEach(headers.toJSON(), (value, header) => {
1367
+ byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
1368
+ });
1413
1369
 
1414
- // eslint-disable-next-line no-param-reassign
1415
- options = utils$1.toFlatObject(
1416
- options,
1417
- {
1418
- metaTokens: true,
1419
- dots: false,
1420
- indexes: false,
1421
- },
1422
- false,
1423
- function defined(option, source) {
1424
- // eslint-disable-next-line no-eq-null,eqeqeq
1425
- return !utils$1.isUndefined(source[option]);
1426
- }
1427
- );
1370
+ return byteStringHeaders;
1371
+ }
1428
1372
 
1429
- const metaTokens = options.metaTokens;
1430
- // eslint-disable-next-line no-use-before-define
1431
- const visitor = options.visitor || defaultVisitor;
1432
- const dots = options.dots;
1433
- const indexes = options.indexes;
1434
- const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
1435
- const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1373
+ const $internals = Symbol('internals');
1436
1374
 
1437
- if (!utils$1.isFunction(visitor)) {
1438
- throw new TypeError('visitor must be a function');
1375
+ function normalizeHeader(header) {
1376
+ return header && String(header).trim().toLowerCase();
1377
+ }
1378
+
1379
+ function normalizeValue(value) {
1380
+ if (value === false || value == null) {
1381
+ return value;
1439
1382
  }
1440
1383
 
1441
- function convertValue(value) {
1442
- if (value === null) return '';
1384
+ return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
1385
+ }
1443
1386
 
1444
- if (utils$1.isDate(value)) {
1445
- return value.toISOString();
1446
- }
1387
+ function parseTokens(str) {
1388
+ const tokens = Object.create(null);
1389
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1390
+ let match;
1447
1391
 
1448
- if (utils$1.isBoolean(value)) {
1449
- return value.toString();
1450
- }
1392
+ while ((match = tokensRE.exec(str))) {
1393
+ tokens[match[1]] = match[2];
1394
+ }
1451
1395
 
1452
- if (!useBlob && utils$1.isBlob(value)) {
1453
- throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
1454
- }
1396
+ return tokens;
1397
+ }
1455
1398
 
1456
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1457
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1458
- }
1399
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1459
1400
 
1460
- return value;
1401
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1402
+ if (utils$1.isFunction(filter)) {
1403
+ return filter.call(this, value, header);
1461
1404
  }
1462
1405
 
1463
- /**
1464
- * Default visitor.
1465
- *
1466
- * @param {*} value
1467
- * @param {String|Number} key
1468
- * @param {Array<String|Number>} path
1469
- * @this {FormData}
1470
- *
1471
- * @returns {boolean} return true to visit the each prop of the value recursively
1472
- */
1473
- function defaultVisitor(value, key, path) {
1474
- let arr = value;
1406
+ if (isHeaderNameFilter) {
1407
+ value = header;
1408
+ }
1475
1409
 
1476
- if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
1477
- formData.append(renderKey(path, key, dots), convertValue(value));
1478
- return false;
1479
- }
1410
+ if (!utils$1.isString(value)) return;
1480
1411
 
1481
- if (value && !path && typeof value === 'object') {
1482
- if (utils$1.endsWith(key, '{}')) {
1483
- // eslint-disable-next-line no-param-reassign
1484
- key = metaTokens ? key : key.slice(0, -2);
1485
- // eslint-disable-next-line no-param-reassign
1486
- value = JSON.stringify(value);
1487
- } else if (
1488
- (utils$1.isArray(value) && isFlatArray(value)) ||
1489
- ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
1490
- ) {
1491
- // eslint-disable-next-line no-param-reassign
1492
- key = removeBrackets(key);
1412
+ if (utils$1.isString(filter)) {
1413
+ return value.indexOf(filter) !== -1;
1414
+ }
1493
1415
 
1494
- arr.forEach(function each(el, index) {
1495
- !(utils$1.isUndefined(el) || el === null) &&
1496
- formData.append(
1497
- // eslint-disable-next-line no-nested-ternary
1498
- indexes === true
1499
- ? renderKey([key], index, dots)
1500
- : indexes === null
1501
- ? key
1502
- : key + '[]',
1503
- convertValue(el)
1504
- );
1505
- });
1506
- return false;
1507
- }
1508
- }
1416
+ if (utils$1.isRegExp(filter)) {
1417
+ return filter.test(value);
1418
+ }
1419
+ }
1509
1420
 
1510
- if (isVisitable(value)) {
1511
- return true;
1512
- }
1421
+ function formatHeader(header) {
1422
+ return header
1423
+ .trim()
1424
+ .toLowerCase()
1425
+ .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1426
+ return char.toUpperCase() + str;
1427
+ });
1428
+ }
1513
1429
 
1514
- formData.append(renderKey(path, key, dots), convertValue(value));
1430
+ function buildAccessors(obj, header) {
1431
+ const accessorName = utils$1.toCamelCase(' ' + header);
1515
1432
 
1516
- return false;
1433
+ ['get', 'set', 'has'].forEach((methodName) => {
1434
+ Object.defineProperty(obj, methodName + accessorName, {
1435
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
1436
+ // this data descriptor into an accessor descriptor on the way in.
1437
+ __proto__: null,
1438
+ value: function (arg1, arg2, arg3) {
1439
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1440
+ },
1441
+ configurable: true,
1442
+ });
1443
+ });
1444
+ }
1445
+
1446
+ let AxiosHeaders$1 = class AxiosHeaders {
1447
+ constructor(headers) {
1448
+ headers && this.set(headers);
1517
1449
  }
1518
1450
 
1519
- const stack = [];
1451
+ set(header, valueOrRewrite, rewrite) {
1452
+ const self = this;
1520
1453
 
1521
- const exposedHelpers = Object.assign(predicates, {
1522
- defaultVisitor,
1523
- convertValue,
1524
- isVisitable,
1525
- });
1454
+ function setHeader(_value, _header, _rewrite) {
1455
+ const lHeader = normalizeHeader(_header);
1526
1456
 
1527
- function build(value, path) {
1528
- if (utils$1.isUndefined(value)) return;
1457
+ if (!lHeader) {
1458
+ throw new Error('header name must be a non-empty string');
1459
+ }
1529
1460
 
1530
- if (stack.indexOf(value) !== -1) {
1531
- throw Error('Circular reference detected in ' + path.join('.'));
1461
+ const key = utils$1.findKey(self, lHeader);
1462
+
1463
+ if (
1464
+ !key ||
1465
+ self[key] === undefined ||
1466
+ _rewrite === true ||
1467
+ (_rewrite === undefined && self[key] !== false)
1468
+ ) {
1469
+ self[key || _header] = normalizeValue(_value);
1470
+ }
1532
1471
  }
1533
1472
 
1534
- stack.push(value);
1473
+ const setHeaders = (headers, _rewrite) =>
1474
+ utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1535
1475
 
1536
- utils$1.forEach(value, function each(el, key) {
1537
- const result =
1538
- !(utils$1.isUndefined(el) || el === null) &&
1539
- visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
1476
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1477
+ setHeaders(header, valueOrRewrite);
1478
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1479
+ setHeaders(parseHeaders(header), valueOrRewrite);
1480
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1481
+ let obj = {},
1482
+ dest,
1483
+ key;
1484
+ for (const entry of header) {
1485
+ if (!utils$1.isArray(entry)) {
1486
+ throw TypeError('Object iterator must return a key-value pair');
1487
+ }
1540
1488
 
1541
- if (result === true) {
1542
- build(el, path ? path.concat(key) : [key]);
1489
+ obj[(key = entry[0])] = (dest = obj[key])
1490
+ ? utils$1.isArray(dest)
1491
+ ? [...dest, entry[1]]
1492
+ : [dest, entry[1]]
1493
+ : entry[1];
1543
1494
  }
1544
- });
1545
1495
 
1546
- stack.pop();
1547
- }
1496
+ setHeaders(obj, valueOrRewrite);
1497
+ } else {
1498
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1499
+ }
1548
1500
 
1549
- if (!utils$1.isObject(obj)) {
1550
- throw new TypeError('data must be an object');
1501
+ return this;
1551
1502
  }
1552
1503
 
1553
- build(obj);
1504
+ get(header, parser) {
1505
+ header = normalizeHeader(header);
1554
1506
 
1555
- return formData;
1556
- }
1507
+ if (header) {
1508
+ const key = utils$1.findKey(this, header);
1557
1509
 
1558
- /**
1559
- * It encodes a string by replacing all characters that are not in the unreserved set with
1560
- * their percent-encoded equivalents
1561
- *
1562
- * @param {string} str - The string to encode.
1563
- *
1564
- * @returns {string} The encoded string.
1565
- */
1566
- function encode$1(str) {
1567
- const charMap = {
1568
- '!': '%21',
1569
- "'": '%27',
1570
- '(': '%28',
1571
- ')': '%29',
1572
- '~': '%7E',
1573
- '%20': '+',
1574
- '%00': '\x00',
1575
- };
1576
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1577
- return charMap[match];
1578
- });
1579
- }
1510
+ if (key) {
1511
+ const value = this[key];
1580
1512
 
1581
- /**
1582
- * It takes a params object and converts it to a FormData object
1583
- *
1584
- * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1585
- * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1586
- *
1587
- * @returns {void}
1588
- */
1589
- function AxiosURLSearchParams(params, options) {
1590
- this._pairs = [];
1513
+ if (!parser) {
1514
+ return value;
1515
+ }
1591
1516
 
1592
- params && toFormData$1(params, this, options);
1593
- }
1517
+ if (parser === true) {
1518
+ return parseTokens(value);
1519
+ }
1594
1520
 
1595
- const prototype = AxiosURLSearchParams.prototype;
1521
+ if (utils$1.isFunction(parser)) {
1522
+ return parser.call(this, value, key);
1523
+ }
1596
1524
 
1597
- prototype.append = function append(name, value) {
1598
- this._pairs.push([name, value]);
1599
- };
1525
+ if (utils$1.isRegExp(parser)) {
1526
+ return parser.exec(value);
1527
+ }
1600
1528
 
1601
- prototype.toString = function toString(encoder) {
1602
- const _encode = encoder
1603
- ? function (value) {
1604
- return encoder.call(this, value, encode$1);
1529
+ throw new TypeError('parser must be boolean|regexp|function');
1605
1530
  }
1606
- : encode$1;
1531
+ }
1532
+ }
1607
1533
 
1608
- return this._pairs
1609
- .map(function each(pair) {
1610
- return _encode(pair[0]) + '=' + _encode(pair[1]);
1611
- }, '')
1612
- .join('&');
1613
- };
1534
+ has(header, matcher) {
1535
+ header = normalizeHeader(header);
1614
1536
 
1615
- /**
1616
- * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
1617
- * their plain counterparts (`:`, `$`, `,`, `+`).
1618
- *
1619
- * @param {string} val The value to be encoded.
1620
- *
1621
- * @returns {string} The encoded value.
1622
- */
1623
- function encode(val) {
1624
- return encodeURIComponent(val)
1625
- .replace(/%3A/gi, ':')
1626
- .replace(/%24/g, '$')
1627
- .replace(/%2C/gi, ',')
1628
- .replace(/%20/g, '+');
1629
- }
1537
+ if (header) {
1538
+ const key = utils$1.findKey(this, header);
1630
1539
 
1631
- /**
1632
- * Build a URL by appending params to the end
1633
- *
1634
- * @param {string} url The base of the url (e.g., http://www.google.com)
1635
- * @param {object} [params] The params to be appended
1636
- * @param {?(object|Function)} options
1637
- *
1638
- * @returns {string} The formatted url
1639
- */
1640
- function buildURL(url, params, options) {
1641
- if (!params) {
1642
- return url;
1540
+ return !!(
1541
+ key &&
1542
+ this[key] !== undefined &&
1543
+ (!matcher || matchHeaderValue(this, this[key], key, matcher))
1544
+ );
1545
+ }
1546
+
1547
+ return false;
1643
1548
  }
1644
1549
 
1645
- const _encode = (options && options.encode) || encode;
1550
+ delete(header, matcher) {
1551
+ const self = this;
1552
+ let deleted = false;
1646
1553
 
1647
- const _options = utils$1.isFunction(options)
1648
- ? {
1649
- serialize: options,
1650
- }
1651
- : options;
1554
+ function deleteHeader(_header) {
1555
+ _header = normalizeHeader(_header);
1652
1556
 
1653
- const serializeFn = _options && _options.serialize;
1557
+ if (_header) {
1558
+ const key = utils$1.findKey(self, _header);
1654
1559
 
1655
- let serializedParams;
1560
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1561
+ delete self[key];
1656
1562
 
1657
- if (serializeFn) {
1658
- serializedParams = serializeFn(params, _options);
1659
- } else {
1660
- serializedParams = utils$1.isURLSearchParams(params)
1661
- ? params.toString()
1662
- : new AxiosURLSearchParams(params, _options).toString(_encode);
1563
+ deleted = true;
1564
+ }
1565
+ }
1566
+ }
1567
+
1568
+ if (utils$1.isArray(header)) {
1569
+ header.forEach(deleteHeader);
1570
+ } else {
1571
+ deleteHeader(header);
1572
+ }
1573
+
1574
+ return deleted;
1663
1575
  }
1664
1576
 
1665
- if (serializedParams) {
1666
- const hashmarkIndex = url.indexOf('#');
1577
+ clear(matcher) {
1578
+ const keys = Object.keys(this);
1579
+ let i = keys.length;
1580
+ let deleted = false;
1667
1581
 
1668
- if (hashmarkIndex !== -1) {
1669
- url = url.slice(0, hashmarkIndex);
1582
+ while (i--) {
1583
+ const key = keys[i];
1584
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1585
+ delete this[key];
1586
+ deleted = true;
1587
+ }
1670
1588
  }
1671
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1589
+
1590
+ return deleted;
1672
1591
  }
1673
1592
 
1674
- return url;
1675
- }
1593
+ normalize(format) {
1594
+ const self = this;
1595
+ const headers = {};
1676
1596
 
1677
- class InterceptorManager {
1678
- constructor() {
1679
- this.handlers = [];
1597
+ utils$1.forEach(this, (value, header) => {
1598
+ const key = utils$1.findKey(headers, header);
1599
+
1600
+ if (key) {
1601
+ self[key] = normalizeValue(value);
1602
+ delete self[header];
1603
+ return;
1604
+ }
1605
+
1606
+ const normalized = format ? formatHeader(header) : String(header).trim();
1607
+
1608
+ if (normalized !== header) {
1609
+ delete self[header];
1610
+ }
1611
+
1612
+ self[normalized] = normalizeValue(value);
1613
+
1614
+ headers[normalized] = true;
1615
+ });
1616
+
1617
+ return this;
1680
1618
  }
1681
1619
 
1682
- /**
1683
- * Add a new interceptor to the stack
1684
- *
1685
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
1686
- * @param {Function} rejected The function to handle `reject` for a `Promise`
1687
- * @param {Object} options The options for the interceptor, synchronous and runWhen
1688
- *
1689
- * @return {Number} An ID used to remove interceptor later
1690
- */
1691
- use(fulfilled, rejected, options) {
1692
- this.handlers.push({
1693
- fulfilled,
1694
- rejected,
1695
- synchronous: options ? options.synchronous : false,
1696
- runWhen: options ? options.runWhen : null,
1620
+ concat(...targets) {
1621
+ return this.constructor.concat(this, ...targets);
1622
+ }
1623
+
1624
+ toJSON(asStrings) {
1625
+ const obj = Object.create(null);
1626
+
1627
+ utils$1.forEach(this, (value, header) => {
1628
+ value != null &&
1629
+ value !== false &&
1630
+ (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1697
1631
  });
1698
- return this.handlers.length - 1;
1632
+
1633
+ return obj;
1699
1634
  }
1700
1635
 
1701
- /**
1702
- * Remove an interceptor from the stack
1703
- *
1704
- * @param {Number} id The ID that was returned by `use`
1705
- *
1706
- * @returns {void}
1707
- */
1708
- eject(id) {
1709
- if (this.handlers[id]) {
1710
- this.handlers[id] = null;
1711
- }
1636
+ [Symbol.iterator]() {
1637
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1712
1638
  }
1713
1639
 
1714
- /**
1715
- * Clear all interceptors from the stack
1716
- *
1717
- * @returns {void}
1718
- */
1719
- clear() {
1720
- if (this.handlers) {
1721
- this.handlers = [];
1722
- }
1640
+ toString() {
1641
+ return Object.entries(this.toJSON())
1642
+ .map(([header, value]) => header + ': ' + value)
1643
+ .join('\n');
1723
1644
  }
1724
1645
 
1725
- /**
1726
- * Iterate over all the registered interceptors
1727
- *
1728
- * This method is particularly useful for skipping over any
1729
- * interceptors that may have become `null` calling `eject`.
1730
- *
1731
- * @param {Function} fn The function to call for each interceptor
1732
- *
1733
- * @returns {void}
1734
- */
1735
- forEach(fn) {
1736
- utils$1.forEach(this.handlers, function forEachHandler(h) {
1737
- if (h !== null) {
1738
- fn(h);
1739
- }
1740
- });
1646
+ getSetCookie() {
1647
+ return this.get('set-cookie') || [];
1741
1648
  }
1742
- }
1743
1649
 
1744
- var transitionalDefaults = {
1745
- silentJSONParsing: true,
1746
- forcedJSONParsing: true,
1747
- clarifyTimeoutError: false,
1748
- legacyInterceptorReqResOrdering: true,
1749
- };
1650
+ get [Symbol.toStringTag]() {
1651
+ return 'AxiosHeaders';
1652
+ }
1750
1653
 
1751
- var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1654
+ static from(thing) {
1655
+ return thing instanceof this ? thing : new this(thing);
1656
+ }
1752
1657
 
1753
- var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1658
+ static concat(first, ...targets) {
1659
+ const computed = new this(first);
1754
1660
 
1755
- var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1661
+ targets.forEach((target) => computed.set(target));
1756
1662
 
1757
- var platform$1 = {
1758
- isBrowser: true,
1759
- classes: {
1760
- URLSearchParams: URLSearchParams$1,
1761
- FormData: FormData$1,
1762
- Blob: Blob$1,
1763
- },
1764
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
1765
- };
1663
+ return computed;
1664
+ }
1766
1665
 
1767
- const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1666
+ static accessor(header) {
1667
+ const internals =
1668
+ (this[$internals] =
1669
+ this[$internals] =
1670
+ {
1671
+ accessors: {},
1672
+ });
1768
1673
 
1769
- const _navigator = (typeof navigator === 'object' && navigator) || undefined;
1674
+ const accessors = internals.accessors;
1675
+ const prototype = this.prototype;
1770
1676
 
1771
- /**
1772
- * Determine if we're running in a standard browser environment
1773
- *
1774
- * This allows axios to run in a web worker, and react-native.
1775
- * Both environments support XMLHttpRequest, but not fully standard globals.
1776
- *
1777
- * web workers:
1778
- * typeof window -> undefined
1779
- * typeof document -> undefined
1780
- *
1781
- * react-native:
1782
- * navigator.product -> 'ReactNative'
1783
- * nativescript
1784
- * navigator.product -> 'NativeScript' or 'NS'
1785
- *
1786
- * @returns {boolean}
1787
- */
1788
- const hasStandardBrowserEnv =
1789
- hasBrowserEnv &&
1790
- (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1677
+ function defineAccessor(_header) {
1678
+ const lHeader = normalizeHeader(_header);
1791
1679
 
1792
- /**
1793
- * Determine if we're running in a standard browser webWorker environment
1794
- *
1795
- * Although the `isStandardBrowserEnv` method indicates that
1796
- * `allows axios to run in a web worker`, the WebWorker will still be
1797
- * filtered out due to its judgment standard
1798
- * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1799
- * This leads to a problem when axios post `FormData` in webWorker
1800
- */
1801
- const hasStandardBrowserWebWorkerEnv = (() => {
1802
- return (
1803
- typeof WorkerGlobalScope !== 'undefined' &&
1804
- // eslint-disable-next-line no-undef
1805
- self instanceof WorkerGlobalScope &&
1806
- typeof self.importScripts === 'function'
1807
- );
1808
- })();
1680
+ if (!accessors[lHeader]) {
1681
+ buildAccessors(prototype, _header);
1682
+ accessors[lHeader] = true;
1683
+ }
1684
+ }
1809
1685
 
1810
- const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
1686
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1811
1687
 
1812
- var utils = /*#__PURE__*/Object.freeze({
1813
- __proto__: null,
1814
- hasBrowserEnv: hasBrowserEnv,
1815
- hasStandardBrowserEnv: hasStandardBrowserEnv,
1816
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1817
- navigator: _navigator,
1818
- origin: origin
1819
- });
1820
-
1821
- var platform = {
1822
- ...utils,
1823
- ...platform$1,
1688
+ return this;
1689
+ }
1824
1690
  };
1825
1691
 
1826
- function toURLEncodedForm(data, options) {
1827
- return toFormData$1(data, new platform.classes.URLSearchParams(), {
1828
- visitor: function (value, key, path, helpers) {
1829
- if (platform.isNode && utils$1.isBuffer(value)) {
1830
- this.append(key, value.toString('base64'));
1831
- return false;
1832
- }
1692
+ AxiosHeaders$1.accessor([
1693
+ 'Content-Type',
1694
+ 'Content-Length',
1695
+ 'Accept',
1696
+ 'Accept-Encoding',
1697
+ 'User-Agent',
1698
+ 'Authorization',
1699
+ ]);
1833
1700
 
1834
- return helpers.defaultVisitor.apply(this, arguments);
1701
+ // reserved names hotfix
1702
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
1703
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1704
+ return {
1705
+ get: () => value,
1706
+ set(headerValue) {
1707
+ this[mapped] = headerValue;
1835
1708
  },
1836
- ...options,
1837
- });
1838
- }
1709
+ };
1710
+ });
1839
1711
 
1840
- /**
1841
- * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1842
- *
1843
- * @param {string} name - The name of the property to get.
1844
- *
1845
- * @returns An array of strings.
1846
- */
1847
- function parsePropPath(name) {
1848
- // foo[x][y][z]
1849
- // foo.x.y.z
1850
- // foo-x-y-z
1851
- // foo x y z
1852
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
1853
- return match[0] === '[]' ? '' : match[1] || match[0];
1854
- });
1855
- }
1712
+ utils$1.freezeMethods(AxiosHeaders$1);
1856
1713
 
1857
- /**
1858
- * Convert an array to an object.
1859
- *
1860
- * @param {Array<any>} arr - The array to convert to an object.
1861
- *
1862
- * @returns An object with the same keys and values as the array.
1863
- */
1864
- function arrayToObject(arr) {
1865
- const obj = {};
1866
- const keys = Object.keys(arr);
1867
- let i;
1868
- const len = keys.length;
1869
- let key;
1870
- for (i = 0; i < len; i++) {
1871
- key = keys[i];
1872
- obj[key] = arr[key];
1714
+ const REDACTED = '[REDACTED ****]';
1715
+
1716
+ function hasOwnOrPrototypeToJSON(source) {
1717
+ if (utils$1.hasOwnProp(source, 'toJSON')) {
1718
+ return true;
1873
1719
  }
1874
- return obj;
1720
+
1721
+ let prototype = Object.getPrototypeOf(source);
1722
+
1723
+ while (prototype && prototype !== Object.prototype) {
1724
+ if (utils$1.hasOwnProp(prototype, 'toJSON')) {
1725
+ return true;
1726
+ }
1727
+
1728
+ prototype = Object.getPrototypeOf(prototype);
1729
+ }
1730
+
1731
+ return false;
1875
1732
  }
1876
1733
 
1877
- /**
1878
- * It takes a FormData object and returns a JavaScript object
1879
- *
1880
- * @param {string} formData The FormData object to convert to JSON.
1881
- *
1882
- * @returns {Object<string, any> | null} The converted object.
1883
- */
1884
- function formDataToJSON(formData) {
1885
- function buildPath(path, value, target, index) {
1886
- let name = path[index++];
1734
+ // Build a plain-object snapshot of `config` and replace the value of any key
1735
+ // (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
1736
+ // and AxiosHeaders, and short-circuits on circular references.
1737
+ function redactConfig(config, redactKeys) {
1738
+ const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
1739
+ const seen = [];
1887
1740
 
1888
- if (name === '__proto__') return true;
1741
+ const visit = (source) => {
1742
+ if (source === null || typeof source !== 'object') return source;
1743
+ if (utils$1.isBuffer(source)) return source;
1744
+ if (seen.indexOf(source) !== -1) return undefined;
1889
1745
 
1890
- const isNumericKey = Number.isFinite(+name);
1891
- const isLast = index >= path.length;
1892
- name = !name && utils$1.isArray(target) ? target.length : name;
1746
+ if (source instanceof AxiosHeaders$1) {
1747
+ source = source.toJSON();
1748
+ }
1893
1749
 
1894
- if (isLast) {
1895
- if (utils$1.hasOwnProp(target, name)) {
1896
- target[name] = [target[name], value];
1897
- } else {
1898
- target[name] = value;
1750
+ seen.push(source);
1751
+
1752
+ let result;
1753
+ if (utils$1.isArray(source)) {
1754
+ result = [];
1755
+ source.forEach((v, i) => {
1756
+ const reducedValue = visit(v);
1757
+ if (!utils$1.isUndefined(reducedValue)) {
1758
+ result[i] = reducedValue;
1759
+ }
1760
+ });
1761
+ } else {
1762
+ if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
1763
+ seen.pop();
1764
+ return source;
1899
1765
  }
1900
1766
 
1901
- return !isNumericKey;
1767
+ result = Object.create(null);
1768
+ for (const [key, value] of Object.entries(source)) {
1769
+ const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
1770
+ if (!utils$1.isUndefined(reducedValue)) {
1771
+ result[key] = reducedValue;
1772
+ }
1773
+ }
1902
1774
  }
1903
1775
 
1904
- if (!target[name] || !utils$1.isObject(target[name])) {
1905
- target[name] = [];
1906
- }
1776
+ seen.pop();
1777
+ return result;
1778
+ };
1907
1779
 
1908
- const result = buildPath(path, value, target[name], index);
1780
+ return visit(config);
1781
+ }
1909
1782
 
1910
- if (result && utils$1.isArray(target[name])) {
1911
- target[name] = arrayToObject(target[name]);
1783
+ let AxiosError$1 = class AxiosError extends Error {
1784
+ static from(error, code, config, request, response, customProps) {
1785
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1786
+ axiosError.cause = error;
1787
+ axiosError.name = error.name;
1788
+
1789
+ // Preserve status from the original error if not already set from response
1790
+ if (error.status != null && axiosError.status == null) {
1791
+ axiosError.status = error.status;
1912
1792
  }
1913
1793
 
1914
- return !isNumericKey;
1794
+ customProps && Object.assign(axiosError, customProps);
1795
+ return axiosError;
1915
1796
  }
1916
1797
 
1917
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1918
- const obj = {};
1919
-
1920
- utils$1.forEachEntry(formData, (name, value) => {
1921
- buildPath(parsePropPath(name), value, obj, 0);
1798
+ /**
1799
+ * Create an Error with the specified message, config, error code, request and response.
1800
+ *
1801
+ * @param {string} message The error message.
1802
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
1803
+ * @param {Object} [config] The config.
1804
+ * @param {Object} [request] The request.
1805
+ * @param {Object} [response] The response.
1806
+ *
1807
+ * @returns {Error} The created error.
1808
+ */
1809
+ constructor(message, code, config, request, response) {
1810
+ super(message);
1811
+
1812
+ // Make message enumerable to maintain backward compatibility
1813
+ // The native Error constructor sets message as non-enumerable,
1814
+ // but axios < v1.13.3 had it as enumerable
1815
+ Object.defineProperty(this, 'message', {
1816
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
1817
+ // this data descriptor into an accessor descriptor on the way in.
1818
+ __proto__: null,
1819
+ value: message,
1820
+ enumerable: true,
1821
+ writable: true,
1822
+ configurable: true,
1922
1823
  });
1923
1824
 
1924
- return obj;
1825
+ this.name = 'AxiosError';
1826
+ this.isAxiosError = true;
1827
+ code && (this.code = code);
1828
+ config && (this.config = config);
1829
+ request && (this.request = request);
1830
+ if (response) {
1831
+ this.response = response;
1832
+ this.status = response.status;
1833
+ }
1925
1834
  }
1926
1835
 
1927
- return null;
1928
- }
1836
+ toJSON() {
1837
+ // Opt-in redaction: when the request config carries a `redact` array, the
1838
+ // value of any matching key (case-insensitive, at any depth) is replaced
1839
+ // with REDACTED in the serialized snapshot. Undefined or empty leaves the
1840
+ // existing serialization behavior unchanged.
1841
+ const config = this.config;
1842
+ const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
1843
+ const serializedConfig =
1844
+ utils$1.isArray(redactKeys) && redactKeys.length > 0
1845
+ ? redactConfig(config, redactKeys)
1846
+ : utils$1.toJSONObject(config);
1847
+
1848
+ return {
1849
+ // Standard
1850
+ message: this.message,
1851
+ name: this.name,
1852
+ // Microsoft
1853
+ description: this.description,
1854
+ number: this.number,
1855
+ // Mozilla
1856
+ fileName: this.fileName,
1857
+ lineNumber: this.lineNumber,
1858
+ columnNumber: this.columnNumber,
1859
+ stack: this.stack,
1860
+ // Axios
1861
+ config: serializedConfig,
1862
+ code: this.code,
1863
+ status: this.status,
1864
+ };
1865
+ }
1866
+ };
1867
+
1868
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
1869
+ AxiosError$1.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
1870
+ AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
1871
+ AxiosError$1.ECONNABORTED = 'ECONNABORTED';
1872
+ AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';
1873
+ AxiosError$1.ECONNREFUSED = 'ECONNREFUSED';
1874
+ AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';
1875
+ AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
1876
+ AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';
1877
+ AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
1878
+ AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
1879
+ AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
1880
+ AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
1881
+ AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
1882
+ AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
1883
+
1884
+ // eslint-disable-next-line strict
1885
+ var httpAdapter = null;
1929
1886
 
1930
1887
  /**
1931
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1932
- * of the input
1888
+ * Determines if the given thing is a array or js object.
1933
1889
  *
1934
- * @param {any} rawValue - The value to be stringified.
1935
- * @param {Function} parser - A function that parses a string into a JavaScript object.
1936
- * @param {Function} encoder - A function that takes a value and returns a string.
1890
+ * @param {string} thing - The object or array to be visited.
1937
1891
  *
1938
- * @returns {string} A stringified version of the rawValue.
1892
+ * @returns {boolean}
1939
1893
  */
1940
- function stringifySafely(rawValue, parser, encoder) {
1941
- if (utils$1.isString(rawValue)) {
1942
- try {
1943
- (parser || JSON.parse)(rawValue);
1944
- return utils$1.trim(rawValue);
1945
- } catch (e) {
1946
- if (e.name !== 'SyntaxError') {
1947
- throw e;
1948
- }
1949
- }
1950
- }
1894
+ function isVisitable(thing) {
1895
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
1896
+ }
1951
1897
 
1952
- return (encoder || JSON.stringify)(rawValue);
1898
+ /**
1899
+ * It removes the brackets from the end of a string
1900
+ *
1901
+ * @param {string} key - The key of the parameter.
1902
+ *
1903
+ * @returns {string} the key without the brackets.
1904
+ */
1905
+ function removeBrackets(key) {
1906
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1953
1907
  }
1954
1908
 
1955
- const defaults = {
1956
- transitional: transitionalDefaults,
1909
+ /**
1910
+ * It takes a path, a key, and a boolean, and returns a string
1911
+ *
1912
+ * @param {string} path - The path to the current key.
1913
+ * @param {string} key - The key of the current object being iterated over.
1914
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
1915
+ *
1916
+ * @returns {string} The path to the current key.
1917
+ */
1918
+ function renderKey(path, key, dots) {
1919
+ if (!path) return key;
1920
+ return path
1921
+ .concat(key)
1922
+ .map(function each(token, i) {
1923
+ // eslint-disable-next-line no-param-reassign
1924
+ token = removeBrackets(token);
1925
+ return !dots && i ? '[' + token + ']' : token;
1926
+ })
1927
+ .join(dots ? '.' : '');
1928
+ }
1957
1929
 
1958
- adapter: ['xhr', 'http', 'fetch'],
1930
+ /**
1931
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
1932
+ *
1933
+ * @param {Array<any>} arr - The array to check
1934
+ *
1935
+ * @returns {boolean}
1936
+ */
1937
+ function isFlatArray(arr) {
1938
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
1939
+ }
1959
1940
 
1960
- transformRequest: [
1961
- function transformRequest(data, headers) {
1962
- const contentType = headers.getContentType() || '';
1963
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
1964
- const isObjectPayload = utils$1.isObject(data);
1941
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1942
+ return /^is[A-Z]/.test(prop);
1943
+ });
1965
1944
 
1966
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
1967
- data = new FormData(data);
1968
- }
1945
+ /**
1946
+ * Convert a data object to FormData
1947
+ *
1948
+ * @param {Object} obj
1949
+ * @param {?Object} [formData]
1950
+ * @param {?Object} [options]
1951
+ * @param {Function} [options.visitor]
1952
+ * @param {Boolean} [options.metaTokens = true]
1953
+ * @param {Boolean} [options.dots = false]
1954
+ * @param {?Boolean} [options.indexes = false]
1955
+ *
1956
+ * @returns {Object}
1957
+ **/
1969
1958
 
1970
- const isFormData = utils$1.isFormData(data);
1959
+ /**
1960
+ * It converts an object into a FormData object
1961
+ *
1962
+ * @param {Object<any, any>} obj - The object to convert to form data.
1963
+ * @param {string} formData - The FormData object to append to.
1964
+ * @param {Object<string, any>} options
1965
+ *
1966
+ * @returns
1967
+ */
1968
+ function toFormData$1(obj, formData, options) {
1969
+ if (!utils$1.isObject(obj)) {
1970
+ throw new TypeError('target must be an object');
1971
+ }
1971
1972
 
1972
- if (isFormData) {
1973
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1974
- }
1973
+ // eslint-disable-next-line no-param-reassign
1974
+ formData = formData || new (FormData)();
1975
1975
 
1976
- if (
1977
- utils$1.isArrayBuffer(data) ||
1978
- utils$1.isBuffer(data) ||
1979
- utils$1.isStream(data) ||
1980
- utils$1.isFile(data) ||
1981
- utils$1.isBlob(data) ||
1982
- utils$1.isReadableStream(data)
1983
- ) {
1984
- return data;
1985
- }
1986
- if (utils$1.isArrayBufferView(data)) {
1987
- return data.buffer;
1988
- }
1989
- if (utils$1.isURLSearchParams(data)) {
1990
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1991
- return data.toString();
1992
- }
1976
+ // eslint-disable-next-line no-param-reassign
1977
+ options = utils$1.toFlatObject(
1978
+ options,
1979
+ {
1980
+ metaTokens: true,
1981
+ dots: false,
1982
+ indexes: false,
1983
+ },
1984
+ false,
1985
+ function defined(option, source) {
1986
+ // eslint-disable-next-line no-eq-null,eqeqeq
1987
+ return !utils$1.isUndefined(source[option]);
1988
+ }
1989
+ );
1993
1990
 
1994
- let isFileList;
1991
+ const metaTokens = options.metaTokens;
1992
+ // eslint-disable-next-line no-use-before-define
1993
+ const visitor = options.visitor || defaultVisitor;
1994
+ const dots = options.dots;
1995
+ const indexes = options.indexes;
1996
+ const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
1997
+ const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
1998
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1995
1999
 
1996
- if (isObjectPayload) {
1997
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1998
- return toURLEncodedForm(data, this.formSerializer).toString();
1999
- }
2000
+ if (!utils$1.isFunction(visitor)) {
2001
+ throw new TypeError('visitor must be a function');
2002
+ }
2000
2003
 
2001
- if (
2002
- (isFileList = utils$1.isFileList(data)) ||
2003
- contentType.indexOf('multipart/form-data') > -1
2004
- ) {
2005
- const _FormData = this.env && this.env.FormData;
2004
+ function convertValue(value) {
2005
+ if (value === null) return '';
2006
2006
 
2007
- return toFormData$1(
2008
- isFileList ? { 'files[]': data } : data,
2009
- _FormData && new _FormData(),
2010
- this.formSerializer
2011
- );
2012
- }
2013
- }
2007
+ if (utils$1.isDate(value)) {
2008
+ return value.toISOString();
2009
+ }
2014
2010
 
2015
- if (isObjectPayload || hasJSONContentType) {
2016
- headers.setContentType('application/json', false);
2017
- return stringifySafely(data);
2018
- }
2011
+ if (utils$1.isBoolean(value)) {
2012
+ return value.toString();
2013
+ }
2019
2014
 
2020
- return data;
2021
- },
2022
- ],
2015
+ if (!useBlob && utils$1.isBlob(value)) {
2016
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
2017
+ }
2023
2018
 
2024
- transformResponse: [
2025
- function transformResponse(data) {
2026
- const transitional = this.transitional || defaults.transitional;
2027
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2028
- const JSONRequested = this.responseType === 'json';
2019
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
2020
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
2021
+ }
2029
2022
 
2030
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2031
- return data;
2032
- }
2023
+ return value;
2024
+ }
2033
2025
 
2034
- if (
2035
- data &&
2036
- utils$1.isString(data) &&
2037
- ((forcedJSONParsing && !this.responseType) || JSONRequested)
2026
+ /**
2027
+ * Default visitor.
2028
+ *
2029
+ * @param {*} value
2030
+ * @param {String|Number} key
2031
+ * @param {Array<String|Number>} path
2032
+ * @this {FormData}
2033
+ *
2034
+ * @returns {boolean} return true to visit the each prop of the value recursively
2035
+ */
2036
+ function defaultVisitor(value, key, path) {
2037
+ let arr = value;
2038
+
2039
+ if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
2040
+ formData.append(renderKey(path, key, dots), convertValue(value));
2041
+ return false;
2042
+ }
2043
+
2044
+ if (value && !path && typeof value === 'object') {
2045
+ if (utils$1.endsWith(key, '{}')) {
2046
+ // eslint-disable-next-line no-param-reassign
2047
+ key = metaTokens ? key : key.slice(0, -2);
2048
+ // eslint-disable-next-line no-param-reassign
2049
+ value = JSON.stringify(value);
2050
+ } else if (
2051
+ (utils$1.isArray(value) && isFlatArray(value)) ||
2052
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
2038
2053
  ) {
2039
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
2040
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
2054
+ // eslint-disable-next-line no-param-reassign
2055
+ key = removeBrackets(key);
2041
2056
 
2042
- try {
2043
- return JSON.parse(data, this.parseReviver);
2044
- } catch (e) {
2045
- if (strictJSONParsing) {
2046
- if (e.name === 'SyntaxError') {
2047
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
2048
- }
2049
- throw e;
2050
- }
2051
- }
2057
+ arr.forEach(function each(el, index) {
2058
+ !(utils$1.isUndefined(el) || el === null) &&
2059
+ formData.append(
2060
+ // eslint-disable-next-line no-nested-ternary
2061
+ indexes === true
2062
+ ? renderKey([key], index, dots)
2063
+ : indexes === null
2064
+ ? key
2065
+ : key + '[]',
2066
+ convertValue(el)
2067
+ );
2068
+ });
2069
+ return false;
2052
2070
  }
2071
+ }
2053
2072
 
2054
- return data;
2055
- },
2056
- ],
2073
+ if (isVisitable(value)) {
2074
+ return true;
2075
+ }
2057
2076
 
2058
- /**
2059
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
2060
- * timeout is not created.
2061
- */
2062
- timeout: 0,
2077
+ formData.append(renderKey(path, key, dots), convertValue(value));
2063
2078
 
2064
- xsrfCookieName: 'XSRF-TOKEN',
2065
- xsrfHeaderName: 'X-XSRF-TOKEN',
2079
+ return false;
2080
+ }
2066
2081
 
2067
- maxContentLength: -1,
2068
- maxBodyLength: -1,
2082
+ const stack = [];
2069
2083
 
2070
- env: {
2071
- FormData: platform.classes.FormData,
2072
- Blob: platform.classes.Blob,
2073
- },
2084
+ const exposedHelpers = Object.assign(predicates, {
2085
+ defaultVisitor,
2086
+ convertValue,
2087
+ isVisitable,
2088
+ });
2074
2089
 
2075
- validateStatus: function validateStatus(status) {
2076
- return status >= 200 && status < 300;
2077
- },
2090
+ function build(value, path, depth = 0) {
2091
+ if (utils$1.isUndefined(value)) return;
2078
2092
 
2079
- headers: {
2080
- common: {
2081
- Accept: 'application/json, text/plain, */*',
2082
- 'Content-Type': undefined,
2083
- },
2084
- },
2085
- };
2093
+ if (depth > maxDepth) {
2094
+ throw new AxiosError$1(
2095
+ 'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
2096
+ AxiosError$1.ERR_FORM_DATA_DEPTH_EXCEEDED
2097
+ );
2098
+ }
2086
2099
 
2087
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
2088
- defaults.headers[method] = {};
2089
- });
2100
+ if (stack.indexOf(value) !== -1) {
2101
+ throw Error('Circular reference detected in ' + path.join('.'));
2102
+ }
2090
2103
 
2091
- // RawAxiosHeaders whose duplicates are ignored by node
2092
- // c.f. https://nodejs.org/api/http.html#http_message_headers
2093
- const ignoreDuplicateOf = utils$1.toObjectSet([
2094
- 'age',
2095
- 'authorization',
2096
- 'content-length',
2097
- 'content-type',
2098
- 'etag',
2099
- 'expires',
2100
- 'from',
2101
- 'host',
2102
- 'if-modified-since',
2103
- 'if-unmodified-since',
2104
- 'last-modified',
2105
- 'location',
2106
- 'max-forwards',
2107
- 'proxy-authorization',
2108
- 'referer',
2109
- 'retry-after',
2110
- 'user-agent',
2111
- ]);
2104
+ stack.push(value);
2112
2105
 
2113
- /**
2114
- * Parse headers into an object
2115
- *
2116
- * ```
2117
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
2118
- * Content-Type: application/json
2119
- * Connection: keep-alive
2120
- * Transfer-Encoding: chunked
2121
- * ```
2122
- *
2123
- * @param {String} rawHeaders Headers needing to be parsed
2124
- *
2125
- * @returns {Object} Headers parsed into an object
2126
- */
2127
- var parseHeaders = (rawHeaders) => {
2128
- const parsed = {};
2129
- let key;
2130
- let val;
2131
- let i;
2132
-
2133
- rawHeaders &&
2134
- rawHeaders.split('\n').forEach(function parser(line) {
2135
- i = line.indexOf(':');
2136
- key = line.substring(0, i).trim().toLowerCase();
2137
- val = line.substring(i + 1).trim();
2138
-
2139
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
2140
- return;
2141
- }
2106
+ utils$1.forEach(value, function each(el, key) {
2107
+ const result =
2108
+ !(utils$1.isUndefined(el) || el === null) &&
2109
+ visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
2142
2110
 
2143
- if (key === 'set-cookie') {
2144
- if (parsed[key]) {
2145
- parsed[key].push(val);
2146
- } else {
2147
- parsed[key] = [val];
2148
- }
2149
- } else {
2150
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
2111
+ if (result === true) {
2112
+ build(el, path ? path.concat(key) : [key], depth + 1);
2151
2113
  }
2152
2114
  });
2153
2115
 
2154
- return parsed;
2155
- };
2156
-
2157
- const $internals = Symbol('internals');
2158
-
2159
- const isValidHeaderValue = (value) => !/[\r\n]/.test(value);
2160
-
2161
- function assertValidHeaderValue(value, header) {
2162
- if (value === false || value == null) {
2163
- return;
2116
+ stack.pop();
2164
2117
  }
2165
2118
 
2166
- if (utils$1.isArray(value)) {
2167
- value.forEach((v) => assertValidHeaderValue(v, header));
2168
- return;
2119
+ if (!utils$1.isObject(obj)) {
2120
+ throw new TypeError('data must be an object');
2169
2121
  }
2170
2122
 
2171
- if (!isValidHeaderValue(String(value))) {
2172
- throw new Error(`Invalid character in header content ["${header}"]`);
2173
- }
2123
+ build(obj);
2124
+
2125
+ return formData;
2174
2126
  }
2175
2127
 
2176
- function normalizeHeader(header) {
2177
- return header && String(header).trim().toLowerCase();
2128
+ /**
2129
+ * It encodes a string by replacing all characters that are not in the unreserved set with
2130
+ * their percent-encoded equivalents
2131
+ *
2132
+ * @param {string} str - The string to encode.
2133
+ *
2134
+ * @returns {string} The encoded string.
2135
+ */
2136
+ function encode$1(str) {
2137
+ const charMap = {
2138
+ '!': '%21',
2139
+ "'": '%27',
2140
+ '(': '%28',
2141
+ ')': '%29',
2142
+ '~': '%7E',
2143
+ '%20': '+',
2144
+ };
2145
+ return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
2146
+ return charMap[match];
2147
+ });
2178
2148
  }
2179
2149
 
2180
- function stripTrailingCRLF(str) {
2181
- let end = str.length;
2150
+ /**
2151
+ * It takes a params object and converts it to a FormData object
2152
+ *
2153
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
2154
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
2155
+ *
2156
+ * @returns {void}
2157
+ */
2158
+ function AxiosURLSearchParams(params, options) {
2159
+ this._pairs = [];
2182
2160
 
2183
- while (end > 0) {
2184
- const charCode = str.charCodeAt(end - 1);
2161
+ params && toFormData$1(params, this, options);
2162
+ }
2185
2163
 
2186
- if (charCode !== 10 && charCode !== 13) {
2187
- break;
2188
- }
2164
+ const prototype = AxiosURLSearchParams.prototype;
2189
2165
 
2190
- end -= 1;
2191
- }
2166
+ prototype.append = function append(name, value) {
2167
+ this._pairs.push([name, value]);
2168
+ };
2192
2169
 
2193
- return end === str.length ? str : str.slice(0, end);
2194
- }
2170
+ prototype.toString = function toString(encoder) {
2171
+ const _encode = encoder
2172
+ ? function (value) {
2173
+ return encoder.call(this, value, encode$1);
2174
+ }
2175
+ : encode$1;
2195
2176
 
2196
- function normalizeValue(value) {
2197
- if (value === false || value == null) {
2198
- return value;
2199
- }
2177
+ return this._pairs
2178
+ .map(function each(pair) {
2179
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
2180
+ }, '')
2181
+ .join('&');
2182
+ };
2200
2183
 
2201
- return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value));
2184
+ /**
2185
+ * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
2186
+ * their plain counterparts (`:`, `$`, `,`, `+`).
2187
+ *
2188
+ * @param {string} val The value to be encoded.
2189
+ *
2190
+ * @returns {string} The encoded value.
2191
+ */
2192
+ function encode(val) {
2193
+ return encodeURIComponent(val)
2194
+ .replace(/%3A/gi, ':')
2195
+ .replace(/%24/g, '$')
2196
+ .replace(/%2C/gi, ',')
2197
+ .replace(/%20/g, '+');
2202
2198
  }
2203
2199
 
2204
- function parseTokens(str) {
2205
- const tokens = Object.create(null);
2206
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
2207
- let match;
2208
-
2209
- while ((match = tokensRE.exec(str))) {
2210
- tokens[match[1]] = match[2];
2200
+ /**
2201
+ * Build a URL by appending params to the end
2202
+ *
2203
+ * @param {string} url The base of the url (e.g., http://www.google.com)
2204
+ * @param {object} [params] The params to be appended
2205
+ * @param {?(object|Function)} options
2206
+ *
2207
+ * @returns {string} The formatted url
2208
+ */
2209
+ function buildURL(url, params, options) {
2210
+ if (!params) {
2211
+ return url;
2211
2212
  }
2212
2213
 
2213
- return tokens;
2214
- }
2215
-
2216
- const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2214
+ const _encode = (options && options.encode) || encode;
2217
2215
 
2218
- function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
2219
- if (utils$1.isFunction(filter)) {
2220
- return filter.call(this, value, header);
2221
- }
2216
+ const _options = utils$1.isFunction(options)
2217
+ ? {
2218
+ serialize: options,
2219
+ }
2220
+ : options;
2222
2221
 
2223
- if (isHeaderNameFilter) {
2224
- value = header;
2225
- }
2222
+ const serializeFn = _options && _options.serialize;
2226
2223
 
2227
- if (!utils$1.isString(value)) return;
2224
+ let serializedParams;
2228
2225
 
2229
- if (utils$1.isString(filter)) {
2230
- return value.indexOf(filter) !== -1;
2226
+ if (serializeFn) {
2227
+ serializedParams = serializeFn(params, _options);
2228
+ } else {
2229
+ serializedParams = utils$1.isURLSearchParams(params)
2230
+ ? params.toString()
2231
+ : new AxiosURLSearchParams(params, _options).toString(_encode);
2231
2232
  }
2232
2233
 
2233
- if (utils$1.isRegExp(filter)) {
2234
- return filter.test(value);
2234
+ if (serializedParams) {
2235
+ const hashmarkIndex = url.indexOf('#');
2236
+
2237
+ if (hashmarkIndex !== -1) {
2238
+ url = url.slice(0, hashmarkIndex);
2239
+ }
2240
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
2235
2241
  }
2236
- }
2237
2242
 
2238
- function formatHeader(header) {
2239
- return header
2240
- .trim()
2241
- .toLowerCase()
2242
- .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2243
- return char.toUpperCase() + str;
2244
- });
2243
+ return url;
2245
2244
  }
2246
2245
 
2247
- function buildAccessors(obj, header) {
2248
- const accessorName = utils$1.toCamelCase(' ' + header);
2246
+ class InterceptorManager {
2247
+ constructor() {
2248
+ this.handlers = [];
2249
+ }
2249
2250
 
2250
- ['get', 'set', 'has'].forEach((methodName) => {
2251
- Object.defineProperty(obj, methodName + accessorName, {
2252
- value: function (arg1, arg2, arg3) {
2253
- return this[methodName].call(this, header, arg1, arg2, arg3);
2254
- },
2255
- configurable: true,
2251
+ /**
2252
+ * Add a new interceptor to the stack
2253
+ *
2254
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
2255
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
2256
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
2257
+ *
2258
+ * @return {Number} An ID used to remove interceptor later
2259
+ */
2260
+ use(fulfilled, rejected, options) {
2261
+ this.handlers.push({
2262
+ fulfilled,
2263
+ rejected,
2264
+ synchronous: options ? options.synchronous : false,
2265
+ runWhen: options ? options.runWhen : null,
2256
2266
  });
2257
- });
2258
- }
2259
-
2260
- let AxiosHeaders$1 = class AxiosHeaders {
2261
- constructor(headers) {
2262
- headers && this.set(headers);
2267
+ return this.handlers.length - 1;
2263
2268
  }
2264
2269
 
2265
- set(header, valueOrRewrite, rewrite) {
2266
- const self = this;
2267
-
2268
- function setHeader(_value, _header, _rewrite) {
2269
- const lHeader = normalizeHeader(_header);
2270
-
2271
- if (!lHeader) {
2272
- throw new Error('header name must be a non-empty string');
2273
- }
2270
+ /**
2271
+ * Remove an interceptor from the stack
2272
+ *
2273
+ * @param {Number} id The ID that was returned by `use`
2274
+ *
2275
+ * @returns {void}
2276
+ */
2277
+ eject(id) {
2278
+ if (this.handlers[id]) {
2279
+ this.handlers[id] = null;
2280
+ }
2281
+ }
2274
2282
 
2275
- const key = utils$1.findKey(self, lHeader);
2283
+ /**
2284
+ * Clear all interceptors from the stack
2285
+ *
2286
+ * @returns {void}
2287
+ */
2288
+ clear() {
2289
+ if (this.handlers) {
2290
+ this.handlers = [];
2291
+ }
2292
+ }
2276
2293
 
2277
- if (
2278
- !key ||
2279
- self[key] === undefined ||
2280
- _rewrite === true ||
2281
- (_rewrite === undefined && self[key] !== false)
2282
- ) {
2283
- assertValidHeaderValue(_value, _header);
2284
- self[key || _header] = normalizeValue(_value);
2294
+ /**
2295
+ * Iterate over all the registered interceptors
2296
+ *
2297
+ * This method is particularly useful for skipping over any
2298
+ * interceptors that may have become `null` calling `eject`.
2299
+ *
2300
+ * @param {Function} fn The function to call for each interceptor
2301
+ *
2302
+ * @returns {void}
2303
+ */
2304
+ forEach(fn) {
2305
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
2306
+ if (h !== null) {
2307
+ fn(h);
2285
2308
  }
2286
- }
2309
+ });
2310
+ }
2311
+ }
2287
2312
 
2288
- const setHeaders = (headers, _rewrite) =>
2289
- utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
2313
+ var transitionalDefaults = {
2314
+ silentJSONParsing: true,
2315
+ forcedJSONParsing: true,
2316
+ clarifyTimeoutError: false,
2317
+ legacyInterceptorReqResOrdering: true,
2318
+ };
2290
2319
 
2291
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
2292
- setHeaders(header, valueOrRewrite);
2293
- } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2294
- setHeaders(parseHeaders(header), valueOrRewrite);
2295
- } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
2296
- let obj = {},
2297
- dest,
2298
- key;
2299
- for (const entry of header) {
2300
- if (!utils$1.isArray(entry)) {
2301
- throw TypeError('Object iterator must return a key-value pair');
2302
- }
2320
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
2303
2321
 
2304
- obj[(key = entry[0])] = (dest = obj[key])
2305
- ? utils$1.isArray(dest)
2306
- ? [...dest, entry[1]]
2307
- : [dest, entry[1]]
2308
- : entry[1];
2309
- }
2322
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
2310
2323
 
2311
- setHeaders(obj, valueOrRewrite);
2312
- } else {
2313
- header != null && setHeader(valueOrRewrite, header, rewrite);
2314
- }
2324
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
2315
2325
 
2316
- return this;
2317
- }
2326
+ var platform$1 = {
2327
+ isBrowser: true,
2328
+ classes: {
2329
+ URLSearchParams: URLSearchParams$1,
2330
+ FormData: FormData$1,
2331
+ Blob: Blob$1,
2332
+ },
2333
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
2334
+ };
2318
2335
 
2319
- get(header, parser) {
2320
- header = normalizeHeader(header);
2336
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2321
2337
 
2322
- if (header) {
2323
- const key = utils$1.findKey(this, header);
2338
+ const _navigator = (typeof navigator === 'object' && navigator) || undefined;
2324
2339
 
2325
- if (key) {
2326
- const value = this[key];
2340
+ /**
2341
+ * Determine if we're running in a standard browser environment
2342
+ *
2343
+ * This allows axios to run in a web worker, and react-native.
2344
+ * Both environments support XMLHttpRequest, but not fully standard globals.
2345
+ *
2346
+ * web workers:
2347
+ * typeof window -> undefined
2348
+ * typeof document -> undefined
2349
+ *
2350
+ * react-native:
2351
+ * navigator.product -> 'ReactNative'
2352
+ * nativescript
2353
+ * navigator.product -> 'NativeScript' or 'NS'
2354
+ *
2355
+ * @returns {boolean}
2356
+ */
2357
+ const hasStandardBrowserEnv =
2358
+ hasBrowserEnv &&
2359
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
2327
2360
 
2328
- if (!parser) {
2329
- return value;
2330
- }
2361
+ /**
2362
+ * Determine if we're running in a standard browser webWorker environment
2363
+ *
2364
+ * Although the `isStandardBrowserEnv` method indicates that
2365
+ * `allows axios to run in a web worker`, the WebWorker will still be
2366
+ * filtered out due to its judgment standard
2367
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
2368
+ * This leads to a problem when axios post `FormData` in webWorker
2369
+ */
2370
+ const hasStandardBrowserWebWorkerEnv = (() => {
2371
+ return (
2372
+ typeof WorkerGlobalScope !== 'undefined' &&
2373
+ // eslint-disable-next-line no-undef
2374
+ self instanceof WorkerGlobalScope &&
2375
+ typeof self.importScripts === 'function'
2376
+ );
2377
+ })();
2331
2378
 
2332
- if (parser === true) {
2333
- return parseTokens(value);
2334
- }
2379
+ const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
2335
2380
 
2336
- if (utils$1.isFunction(parser)) {
2337
- return parser.call(this, value, key);
2338
- }
2381
+ var utils = /*#__PURE__*/Object.freeze({
2382
+ __proto__: null,
2383
+ hasBrowserEnv: hasBrowserEnv,
2384
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
2385
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2386
+ navigator: _navigator,
2387
+ origin: origin
2388
+ });
2339
2389
 
2340
- if (utils$1.isRegExp(parser)) {
2341
- return parser.exec(value);
2342
- }
2390
+ var platform = {
2391
+ ...utils,
2392
+ ...platform$1,
2393
+ };
2343
2394
 
2344
- throw new TypeError('parser must be boolean|regexp|function');
2395
+ function toURLEncodedForm(data, options) {
2396
+ return toFormData$1(data, new platform.classes.URLSearchParams(), {
2397
+ visitor: function (value, key, path, helpers) {
2398
+ if (platform.isNode && utils$1.isBuffer(value)) {
2399
+ this.append(key, value.toString('base64'));
2400
+ return false;
2345
2401
  }
2346
- }
2347
- }
2348
2402
 
2349
- has(header, matcher) {
2350
- header = normalizeHeader(header);
2351
-
2352
- if (header) {
2353
- const key = utils$1.findKey(this, header);
2403
+ return helpers.defaultVisitor.apply(this, arguments);
2404
+ },
2405
+ ...options,
2406
+ });
2407
+ }
2354
2408
 
2355
- return !!(
2356
- key &&
2357
- this[key] !== undefined &&
2358
- (!matcher || matchHeaderValue(this, this[key], key, matcher))
2359
- );
2360
- }
2409
+ /**
2410
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
2411
+ *
2412
+ * @param {string} name - The name of the property to get.
2413
+ *
2414
+ * @returns An array of strings.
2415
+ */
2416
+ function parsePropPath(name) {
2417
+ // foo[x][y][z]
2418
+ // foo.x.y.z
2419
+ // foo-x-y-z
2420
+ // foo x y z
2421
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
2422
+ return match[0] === '[]' ? '' : match[1] || match[0];
2423
+ });
2424
+ }
2361
2425
 
2362
- return false;
2426
+ /**
2427
+ * Convert an array to an object.
2428
+ *
2429
+ * @param {Array<any>} arr - The array to convert to an object.
2430
+ *
2431
+ * @returns An object with the same keys and values as the array.
2432
+ */
2433
+ function arrayToObject(arr) {
2434
+ const obj = {};
2435
+ const keys = Object.keys(arr);
2436
+ let i;
2437
+ const len = keys.length;
2438
+ let key;
2439
+ for (i = 0; i < len; i++) {
2440
+ key = keys[i];
2441
+ obj[key] = arr[key];
2363
2442
  }
2443
+ return obj;
2444
+ }
2445
+
2446
+ /**
2447
+ * It takes a FormData object and returns a JavaScript object
2448
+ *
2449
+ * @param {string} formData The FormData object to convert to JSON.
2450
+ *
2451
+ * @returns {Object<string, any> | null} The converted object.
2452
+ */
2453
+ function formDataToJSON(formData) {
2454
+ function buildPath(path, value, target, index) {
2455
+ let name = path[index++];
2364
2456
 
2365
- delete(header, matcher) {
2366
- const self = this;
2367
- let deleted = false;
2457
+ if (name === '__proto__') return true;
2368
2458
 
2369
- function deleteHeader(_header) {
2370
- _header = normalizeHeader(_header);
2459
+ const isNumericKey = Number.isFinite(+name);
2460
+ const isLast = index >= path.length;
2461
+ name = !name && utils$1.isArray(target) ? target.length : name;
2371
2462
 
2372
- if (_header) {
2373
- const key = utils$1.findKey(self, _header);
2463
+ if (isLast) {
2464
+ if (utils$1.hasOwnProp(target, name)) {
2465
+ target[name] = utils$1.isArray(target[name])
2466
+ ? target[name].concat(value)
2467
+ : [target[name], value];
2468
+ } else {
2469
+ target[name] = value;
2470
+ }
2374
2471
 
2375
- if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
2376
- delete self[key];
2472
+ return !isNumericKey;
2473
+ }
2377
2474
 
2378
- deleted = true;
2379
- }
2380
- }
2475
+ if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
2476
+ target[name] = [];
2381
2477
  }
2382
2478
 
2383
- if (utils$1.isArray(header)) {
2384
- header.forEach(deleteHeader);
2385
- } else {
2386
- deleteHeader(header);
2479
+ const result = buildPath(path, value, target[name], index);
2480
+
2481
+ if (result && utils$1.isArray(target[name])) {
2482
+ target[name] = arrayToObject(target[name]);
2387
2483
  }
2388
2484
 
2389
- return deleted;
2485
+ return !isNumericKey;
2390
2486
  }
2391
2487
 
2392
- clear(matcher) {
2393
- const keys = Object.keys(this);
2394
- let i = keys.length;
2395
- let deleted = false;
2488
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
2489
+ const obj = {};
2396
2490
 
2397
- while (i--) {
2398
- const key = keys[i];
2399
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2400
- delete this[key];
2401
- deleted = true;
2402
- }
2403
- }
2491
+ utils$1.forEachEntry(formData, (name, value) => {
2492
+ buildPath(parsePropPath(name), value, obj, 0);
2493
+ });
2404
2494
 
2405
- return deleted;
2495
+ return obj;
2406
2496
  }
2407
2497
 
2408
- normalize(format) {
2409
- const self = this;
2410
- const headers = {};
2498
+ return null;
2499
+ }
2411
2500
 
2412
- utils$1.forEach(this, (value, header) => {
2413
- const key = utils$1.findKey(headers, header);
2501
+ const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
2414
2502
 
2415
- if (key) {
2416
- self[key] = normalizeValue(value);
2417
- delete self[header];
2418
- return;
2503
+ /**
2504
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2505
+ * of the input
2506
+ *
2507
+ * @param {any} rawValue - The value to be stringified.
2508
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
2509
+ * @param {Function} encoder - A function that takes a value and returns a string.
2510
+ *
2511
+ * @returns {string} A stringified version of the rawValue.
2512
+ */
2513
+ function stringifySafely(rawValue, parser, encoder) {
2514
+ if (utils$1.isString(rawValue)) {
2515
+ try {
2516
+ (parser || JSON.parse)(rawValue);
2517
+ return utils$1.trim(rawValue);
2518
+ } catch (e) {
2519
+ if (e.name !== 'SyntaxError') {
2520
+ throw e;
2419
2521
  }
2522
+ }
2523
+ }
2420
2524
 
2421
- const normalized = format ? formatHeader(header) : String(header).trim();
2422
-
2423
- if (normalized !== header) {
2424
- delete self[header];
2425
- }
2525
+ return (encoder || JSON.stringify)(rawValue);
2526
+ }
2426
2527
 
2427
- self[normalized] = normalizeValue(value);
2528
+ const defaults = {
2529
+ transitional: transitionalDefaults,
2428
2530
 
2429
- headers[normalized] = true;
2430
- });
2531
+ adapter: ['xhr', 'http', 'fetch'],
2431
2532
 
2432
- return this;
2433
- }
2533
+ transformRequest: [
2534
+ function transformRequest(data, headers) {
2535
+ const contentType = headers.getContentType() || '';
2536
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
2537
+ const isObjectPayload = utils$1.isObject(data);
2434
2538
 
2435
- concat(...targets) {
2436
- return this.constructor.concat(this, ...targets);
2437
- }
2539
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
2540
+ data = new FormData(data);
2541
+ }
2438
2542
 
2439
- toJSON(asStrings) {
2440
- const obj = Object.create(null);
2543
+ const isFormData = utils$1.isFormData(data);
2441
2544
 
2442
- utils$1.forEach(this, (value, header) => {
2443
- value != null &&
2444
- value !== false &&
2445
- (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
2446
- });
2545
+ if (isFormData) {
2546
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2547
+ }
2447
2548
 
2448
- return obj;
2449
- }
2549
+ if (
2550
+ utils$1.isArrayBuffer(data) ||
2551
+ utils$1.isBuffer(data) ||
2552
+ utils$1.isStream(data) ||
2553
+ utils$1.isFile(data) ||
2554
+ utils$1.isBlob(data) ||
2555
+ utils$1.isReadableStream(data)
2556
+ ) {
2557
+ return data;
2558
+ }
2559
+ if (utils$1.isArrayBufferView(data)) {
2560
+ return data.buffer;
2561
+ }
2562
+ if (utils$1.isURLSearchParams(data)) {
2563
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2564
+ return data.toString();
2565
+ }
2450
2566
 
2451
- [Symbol.iterator]() {
2452
- return Object.entries(this.toJSON())[Symbol.iterator]();
2453
- }
2567
+ let isFileList;
2454
2568
 
2455
- toString() {
2456
- return Object.entries(this.toJSON())
2457
- .map(([header, value]) => header + ': ' + value)
2458
- .join('\n');
2459
- }
2569
+ if (isObjectPayload) {
2570
+ const formSerializer = own(this, 'formSerializer');
2571
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2572
+ return toURLEncodedForm(data, formSerializer).toString();
2573
+ }
2460
2574
 
2461
- getSetCookie() {
2462
- return this.get('set-cookie') || [];
2463
- }
2575
+ if (
2576
+ (isFileList = utils$1.isFileList(data)) ||
2577
+ contentType.indexOf('multipart/form-data') > -1
2578
+ ) {
2579
+ const env = own(this, 'env');
2580
+ const _FormData = env && env.FormData;
2464
2581
 
2465
- get [Symbol.toStringTag]() {
2466
- return 'AxiosHeaders';
2467
- }
2582
+ return toFormData$1(
2583
+ isFileList ? { 'files[]': data } : data,
2584
+ _FormData && new _FormData(),
2585
+ formSerializer
2586
+ );
2587
+ }
2588
+ }
2468
2589
 
2469
- static from(thing) {
2470
- return thing instanceof this ? thing : new this(thing);
2471
- }
2590
+ if (isObjectPayload || hasJSONContentType) {
2591
+ headers.setContentType('application/json', false);
2592
+ return stringifySafely(data);
2593
+ }
2472
2594
 
2473
- static concat(first, ...targets) {
2474
- const computed = new this(first);
2595
+ return data;
2596
+ },
2597
+ ],
2475
2598
 
2476
- targets.forEach((target) => computed.set(target));
2599
+ transformResponse: [
2600
+ function transformResponse(data) {
2601
+ const transitional = own(this, 'transitional') || defaults.transitional;
2602
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2603
+ const responseType = own(this, 'responseType');
2604
+ const JSONRequested = responseType === 'json';
2477
2605
 
2478
- return computed;
2479
- }
2606
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
2607
+ return data;
2608
+ }
2480
2609
 
2481
- static accessor(header) {
2482
- const internals =
2483
- (this[$internals] =
2484
- this[$internals] =
2485
- {
2486
- accessors: {},
2487
- });
2610
+ if (
2611
+ data &&
2612
+ utils$1.isString(data) &&
2613
+ ((forcedJSONParsing && !responseType) || JSONRequested)
2614
+ ) {
2615
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
2616
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
2488
2617
 
2489
- const accessors = internals.accessors;
2490
- const prototype = this.prototype;
2618
+ try {
2619
+ return JSON.parse(data, own(this, 'parseReviver'));
2620
+ } catch (e) {
2621
+ if (strictJSONParsing) {
2622
+ if (e.name === 'SyntaxError') {
2623
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
2624
+ }
2625
+ throw e;
2626
+ }
2627
+ }
2628
+ }
2491
2629
 
2492
- function defineAccessor(_header) {
2493
- const lHeader = normalizeHeader(_header);
2630
+ return data;
2631
+ },
2632
+ ],
2494
2633
 
2495
- if (!accessors[lHeader]) {
2496
- buildAccessors(prototype, _header);
2497
- accessors[lHeader] = true;
2498
- }
2499
- }
2634
+ /**
2635
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
2636
+ * timeout is not created.
2637
+ */
2638
+ timeout: 0,
2500
2639
 
2501
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2640
+ xsrfCookieName: 'XSRF-TOKEN',
2641
+ xsrfHeaderName: 'X-XSRF-TOKEN',
2502
2642
 
2503
- return this;
2504
- }
2505
- };
2643
+ maxContentLength: -1,
2644
+ maxBodyLength: -1,
2506
2645
 
2507
- AxiosHeaders$1.accessor([
2508
- 'Content-Type',
2509
- 'Content-Length',
2510
- 'Accept',
2511
- 'Accept-Encoding',
2512
- 'User-Agent',
2513
- 'Authorization',
2514
- ]);
2646
+ env: {
2647
+ FormData: platform.classes.FormData,
2648
+ Blob: platform.classes.Blob,
2649
+ },
2515
2650
 
2516
- // reserved names hotfix
2517
- utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
2518
- let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2519
- return {
2520
- get: () => value,
2521
- set(headerValue) {
2522
- this[mapped] = headerValue;
2651
+ validateStatus: function validateStatus(status) {
2652
+ return status >= 200 && status < 300;
2653
+ },
2654
+
2655
+ headers: {
2656
+ common: {
2657
+ Accept: 'application/json, text/plain, */*',
2658
+ 'Content-Type': undefined,
2523
2659
  },
2524
- };
2525
- });
2660
+ },
2661
+ };
2526
2662
 
2527
- utils$1.freezeMethods(AxiosHeaders$1);
2663
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
2664
+ defaults.headers[method] = {};
2665
+ });
2528
2666
 
2529
2667
  /**
2530
2668
  * Transform the data for a request or a response
@@ -2584,22 +2722,18 @@ function settle(resolve, reject, response) {
2584
2722
  if (!response.status || !validateStatus || validateStatus(response.status)) {
2585
2723
  resolve(response);
2586
2724
  } else {
2587
- reject(
2588
- new AxiosError$1(
2589
- 'Request failed with status code ' + response.status,
2590
- [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
2591
- Math.floor(response.status / 100) - 4
2592
- ],
2593
- response.config,
2594
- response.request,
2595
- response
2596
- )
2597
- );
2725
+ reject(new AxiosError$1(
2726
+ 'Request failed with status code ' + response.status,
2727
+ response.status >= 400 && response.status < 500 ? AxiosError$1.ERR_BAD_REQUEST : AxiosError$1.ERR_BAD_RESPONSE,
2728
+ response.config,
2729
+ response.request,
2730
+ response
2731
+ ));
2598
2732
  }
2599
2733
  }
2600
2734
 
2601
2735
  function parseProtocol(url) {
2602
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2736
+ const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
2603
2737
  return (match && match[1]) || '';
2604
2738
  }
2605
2739
 
@@ -2703,13 +2837,16 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2703
2837
  const _speedometer = speedometer(50, 250);
2704
2838
 
2705
2839
  return throttle((e) => {
2706
- const loaded = e.loaded;
2840
+ if (!e || typeof e.loaded !== 'number') {
2841
+ return;
2842
+ }
2843
+ const rawLoaded = e.loaded;
2707
2844
  const total = e.lengthComputable ? e.total : undefined;
2708
- const progressBytes = loaded - bytesNotified;
2845
+ const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
2846
+ const progressBytes = Math.max(0, loaded - bytesNotified);
2709
2847
  const rate = _speedometer(progressBytes);
2710
- const inRange = loaded <= total;
2711
2848
 
2712
- bytesNotified = loaded;
2849
+ bytesNotified = Math.max(bytesNotified, loaded);
2713
2850
 
2714
2851
  const data = {
2715
2852
  loaded,
@@ -2717,7 +2854,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2717
2854
  progress: total ? loaded / total : undefined,
2718
2855
  bytes: progressBytes,
2719
2856
  rate: rate ? rate : undefined,
2720
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2857
+ estimated: rate && total ? (total - loaded) / rate : undefined,
2721
2858
  event: e,
2722
2859
  lengthComputable: total != null,
2723
2860
  [isDownloadStream ? 'download' : 'upload']: true,
@@ -2790,8 +2927,20 @@ var cookies = platform.hasStandardBrowserEnv
2790
2927
 
2791
2928
  read(name) {
2792
2929
  if (typeof document === 'undefined') return null;
2793
- const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
2794
- return match ? decodeURIComponent(match[1]) : null;
2930
+ // Match name=value by splitting on the semicolon separator instead of building a
2931
+ // RegExp from `name` interpolating an unescaped string into a RegExp would let
2932
+ // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
2933
+ // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
2934
+ // "; ", so ignore optional whitespace before each cookie name.
2935
+ const cookies = document.cookie.split(';');
2936
+ for (let i = 0; i < cookies.length; i++) {
2937
+ const cookie = cookies[i].replace(/^\s+/, '');
2938
+ const eq = cookie.indexOf('=');
2939
+ if (eq !== -1 && cookie.slice(0, eq) === name) {
2940
+ return decodeURIComponent(cookie.slice(eq + 1));
2941
+ }
2942
+ }
2943
+ return null;
2795
2944
  },
2796
2945
 
2797
2946
  remove(name) {
@@ -2851,7 +3000,7 @@ function combineURLs(baseURL, relativeURL) {
2851
3000
  */
2852
3001
  function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2853
3002
  let isRelativeUrl = !isAbsoluteURL(requestedURL);
2854
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
3003
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
2855
3004
  return combineURLs(baseURL, requestedURL);
2856
3005
  }
2857
3006
  return requestedURL;
@@ -2871,7 +3020,21 @@ const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing
2871
3020
  function mergeConfig$1(config1, config2) {
2872
3021
  // eslint-disable-next-line no-param-reassign
2873
3022
  config2 = config2 || {};
2874
- const config = {};
3023
+
3024
+ // Use a null-prototype object so that downstream reads such as `config.auth`
3025
+ // or `config.baseURL` cannot inherit polluted values from Object.prototype.
3026
+ // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
3027
+ // ergonomics for user code that relies on it.
3028
+ const config = Object.create(null);
3029
+ Object.defineProperty(config, 'hasOwnProperty', {
3030
+ // Null-proto descriptor so a polluted Object.prototype.get cannot turn
3031
+ // this data descriptor into an accessor descriptor on the way in.
3032
+ __proto__: null,
3033
+ value: Object.prototype.hasOwnProperty,
3034
+ enumerable: false,
3035
+ writable: true,
3036
+ configurable: true,
3037
+ });
2875
3038
 
2876
3039
  function getMergedValue(target, source, prop, caseless) {
2877
3040
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
@@ -2910,9 +3073,9 @@ function mergeConfig$1(config1, config2) {
2910
3073
 
2911
3074
  // eslint-disable-next-line consistent-return
2912
3075
  function mergeDirectKeys(a, b, prop) {
2913
- if (prop in config2) {
3076
+ if (utils$1.hasOwnProp(config2, prop)) {
2914
3077
  return getMergedValue(a, b);
2915
- } else if (prop in config1) {
3078
+ } else if (utils$1.hasOwnProp(config1, prop)) {
2916
3079
  return getMergedValue(undefined, a);
2917
3080
  }
2918
3081
  }
@@ -2944,6 +3107,7 @@ function mergeConfig$1(config1, config2) {
2944
3107
  httpsAgent: defaultToConfig2,
2945
3108
  cancelToken: defaultToConfig2,
2946
3109
  socketPath: defaultToConfig2,
3110
+ allowedSocketPaths: defaultToConfig2,
2947
3111
  responseEncoding: defaultToConfig2,
2948
3112
  validateStatus: mergeDirectKeys,
2949
3113
  headers: (a, b, prop) =>
@@ -2953,22 +3117,64 @@ function mergeConfig$1(config1, config2) {
2953
3117
  utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
2954
3118
  if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
2955
3119
  const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
2956
- const configValue = merge(config1[prop], config2[prop], prop);
3120
+ const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
3121
+ const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
3122
+ const configValue = merge(a, b, prop);
2957
3123
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2958
3124
  });
2959
3125
 
2960
3126
  return config;
2961
3127
  }
2962
3128
 
3129
+ const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
3130
+
3131
+ function setFormDataHeaders(headers, formHeaders, policy) {
3132
+ if (policy !== 'content-only') {
3133
+ headers.set(formHeaders);
3134
+ return;
3135
+ }
3136
+
3137
+ Object.entries(formHeaders).forEach(([key, val]) => {
3138
+ if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
3139
+ headers.set(key, val);
3140
+ }
3141
+ });
3142
+ }
3143
+
3144
+ /**
3145
+ * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
3146
+ * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
3147
+ *
3148
+ * @param {string} str The string to encode
3149
+ *
3150
+ * @returns {string} UTF-8 bytes as a Latin-1 string
3151
+ */
3152
+ const encodeUTF8 = (str) =>
3153
+ encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
3154
+ String.fromCharCode(parseInt(hex, 16))
3155
+ );
3156
+
2963
3157
  var resolveConfig = (config) => {
2964
3158
  const newConfig = mergeConfig$1({}, config);
2965
3159
 
2966
- let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3160
+ // Read only own properties to prevent prototype pollution gadgets
3161
+ // (e.g. Object.prototype.baseURL = 'https://evil.com').
3162
+ const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
3163
+
3164
+ const data = own('data');
3165
+ let withXSRFToken = own('withXSRFToken');
3166
+ const xsrfHeaderName = own('xsrfHeaderName');
3167
+ const xsrfCookieName = own('xsrfCookieName');
3168
+ let headers = own('headers');
3169
+ const auth = own('auth');
3170
+ const baseURL = own('baseURL');
3171
+ const allowAbsoluteUrls = own('allowAbsoluteUrls');
3172
+ const url = own('url');
2967
3173
 
2968
3174
  newConfig.headers = headers = AxiosHeaders$1.from(headers);
2969
3175
 
2970
3176
  newConfig.url = buildURL(
2971
- buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls),
3177
+ buildFullPath(baseURL, url, allowAbsoluteUrls),
2972
3178
  config.params,
2973
3179
  config.paramsSerializer
2974
3180
  );
@@ -2978,11 +3184,7 @@ var resolveConfig = (config) => {
2978
3184
  headers.set(
2979
3185
  'Authorization',
2980
3186
  'Basic ' +
2981
- btoa(
2982
- (auth.username || '') +
2983
- ':' +
2984
- (auth.password ? unescape(encodeURIComponent(auth.password)) : '')
2985
- )
3187
+ btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
2986
3188
  );
2987
3189
  }
2988
3190
 
@@ -2991,14 +3193,7 @@ var resolveConfig = (config) => {
2991
3193
  headers.setContentType(undefined); // browser handles it
2992
3194
  } else if (utils$1.isFunction(data.getHeaders)) {
2993
3195
  // Node.js FormData (like form-data package)
2994
- const formHeaders = data.getHeaders();
2995
- // Only set safe headers to avoid overwriting security headers
2996
- const allowedHeaders = ['content-type', 'content-length'];
2997
- Object.entries(formHeaders).forEach(([key, val]) => {
2998
- if (allowedHeaders.includes(key.toLowerCase())) {
2999
- headers.set(key, val);
3000
- }
3001
- });
3196
+ setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
3002
3197
  }
3003
3198
  }
3004
3199
 
@@ -3007,10 +3202,17 @@ var resolveConfig = (config) => {
3007
3202
  // Specifically not if we're in a web worker, or react-native.
3008
3203
 
3009
3204
  if (platform.hasStandardBrowserEnv) {
3010
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
3205
+ if (utils$1.isFunction(withXSRFToken)) {
3206
+ withXSRFToken = withXSRFToken(newConfig);
3207
+ }
3208
+
3209
+ // Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
3210
+ // and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
3211
+ // the XSRF token cross-origin.
3212
+ const shouldSendXSRF =
3213
+ withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
3011
3214
 
3012
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
3013
- // Add xsrf header
3215
+ if (shouldSendXSRF) {
3014
3216
  const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
3015
3217
 
3016
3218
  if (xsrfValue) {
@@ -3104,7 +3306,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3104
3306
  // will return status as 0 even though it's a successful request
3105
3307
  if (
3106
3308
  request.status === 0 &&
3107
- !(request.responseURL && request.responseURL.indexOf('file:') === 0)
3309
+ !(request.responseURL && request.responseURL.startsWith('file:'))
3108
3310
  ) {
3109
3311
  return;
3110
3312
  }
@@ -3121,6 +3323,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3121
3323
  }
3122
3324
 
3123
3325
  reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
3326
+ done();
3124
3327
 
3125
3328
  // Clean up request
3126
3329
  request = null;
@@ -3136,6 +3339,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3136
3339
  // attach the underlying event for consumers who want details
3137
3340
  err.event = event || null;
3138
3341
  reject(err);
3342
+ done();
3139
3343
  request = null;
3140
3344
  };
3141
3345
 
@@ -3156,6 +3360,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3156
3360
  request
3157
3361
  )
3158
3362
  );
3363
+ done();
3159
3364
 
3160
3365
  // Clean up request
3161
3366
  request = null;
@@ -3166,7 +3371,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3166
3371
 
3167
3372
  // Add headers to the request
3168
3373
  if ('setRequestHeader' in request) {
3169
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
3374
+ utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
3170
3375
  request.setRequestHeader(key, val);
3171
3376
  });
3172
3377
  }
@@ -3205,6 +3410,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3205
3410
  }
3206
3411
  reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
3207
3412
  request.abort();
3413
+ done();
3208
3414
  request = null;
3209
3415
  };
3210
3416
 
@@ -3218,7 +3424,7 @@ var xhrAdapter = isXHRAdapterSupported &&
3218
3424
 
3219
3425
  const protocol = parseProtocol(_config.url);
3220
3426
 
3221
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
3427
+ if (protocol && !platform.protocols.includes(protocol)) {
3222
3428
  reject(
3223
3429
  new AxiosError$1(
3224
3430
  'Unsupported protocol ' + protocol + ':',
@@ -3235,54 +3441,55 @@ var xhrAdapter = isXHRAdapterSupported &&
3235
3441
  };
3236
3442
 
3237
3443
  const composeSignals = (signals, timeout) => {
3238
- const { length } = (signals = signals ? signals.filter(Boolean) : []);
3239
-
3240
- if (timeout || length) {
3241
- let controller = new AbortController();
3242
-
3243
- let aborted;
3244
-
3245
- const onabort = function (reason) {
3246
- if (!aborted) {
3247
- aborted = true;
3248
- unsubscribe();
3249
- const err = reason instanceof Error ? reason : this.reason;
3250
- controller.abort(
3251
- err instanceof AxiosError$1
3252
- ? err
3253
- : new CanceledError$1(err instanceof Error ? err.message : err)
3254
- );
3255
- }
3256
- };
3444
+ signals = signals ? signals.filter(Boolean) : [];
3257
3445
 
3258
- let timer =
3259
- timeout &&
3260
- setTimeout(() => {
3261
- timer = null;
3262
- onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
3263
- }, timeout);
3264
-
3265
- const unsubscribe = () => {
3266
- if (signals) {
3267
- timer && clearTimeout(timer);
3268
- timer = null;
3269
- signals.forEach((signal) => {
3270
- signal.unsubscribe
3271
- ? signal.unsubscribe(onabort)
3272
- : signal.removeEventListener('abort', onabort);
3273
- });
3274
- signals = null;
3275
- }
3276
- };
3446
+ if (!timeout && !signals.length) {
3447
+ return;
3448
+ }
3449
+
3450
+ const controller = new AbortController();
3451
+
3452
+ let aborted = false;
3277
3453
 
3278
- signals.forEach((signal) => signal.addEventListener('abort', onabort));
3454
+ const onabort = function (reason) {
3455
+ if (!aborted) {
3456
+ aborted = true;
3457
+ unsubscribe();
3458
+ const err = reason instanceof Error ? reason : this.reason;
3459
+ controller.abort(
3460
+ err instanceof AxiosError$1
3461
+ ? err
3462
+ : new CanceledError$1(err instanceof Error ? err.message : err)
3463
+ );
3464
+ }
3465
+ };
3466
+
3467
+ let timer =
3468
+ timeout &&
3469
+ setTimeout(() => {
3470
+ timer = null;
3471
+ onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
3472
+ }, timeout);
3473
+
3474
+ const unsubscribe = () => {
3475
+ if (!signals) { return; }
3476
+ timer && clearTimeout(timer);
3477
+ timer = null;
3478
+ signals.forEach((signal) => {
3479
+ signal.unsubscribe
3480
+ ? signal.unsubscribe(onabort)
3481
+ : signal.removeEventListener('abort', onabort);
3482
+ });
3483
+ signals = null;
3484
+ };
3279
3485
 
3280
- const { signal } = controller;
3486
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
3281
3487
 
3282
- signal.unsubscribe = () => utils$1.asap(unsubscribe);
3488
+ const { signal } = controller;
3283
3489
 
3284
- return signal;
3285
- }
3490
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
3491
+
3492
+ return signal;
3286
3493
  };
3287
3494
 
3288
3495
  const streamChunk = function* (chunk, chunkSize) {
@@ -3375,16 +3582,112 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3375
3582
  );
3376
3583
  };
3377
3584
 
3378
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
3585
+ /**
3586
+ * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
3587
+ * - For base64: compute exact decoded size using length and padding;
3588
+ * handle %XX at the character-count level (no string allocation).
3589
+ * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
3590
+ *
3591
+ * @param {string} url
3592
+ * @returns {number}
3593
+ */
3594
+ function estimateDataURLDecodedBytes(url) {
3595
+ if (!url || typeof url !== 'string') return 0;
3596
+ if (!url.startsWith('data:')) return 0;
3379
3597
 
3380
- const { isFunction } = utils$1;
3598
+ const comma = url.indexOf(',');
3599
+ if (comma < 0) return 0;
3600
+
3601
+ const meta = url.slice(5, comma);
3602
+ const body = url.slice(comma + 1);
3603
+ const isBase64 = /;base64/i.test(meta);
3604
+
3605
+ if (isBase64) {
3606
+ let effectiveLen = body.length;
3607
+ const len = body.length; // cache length
3608
+
3609
+ for (let i = 0; i < len; i++) {
3610
+ if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
3611
+ const a = body.charCodeAt(i + 1);
3612
+ const b = body.charCodeAt(i + 2);
3613
+ const isHex =
3614
+ ((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
3615
+ ((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
3616
+
3617
+ if (isHex) {
3618
+ effectiveLen -= 2;
3619
+ i += 2;
3620
+ }
3621
+ }
3622
+ }
3623
+
3624
+ let pad = 0;
3625
+ let idx = len - 1;
3626
+
3627
+ const tailIsPct3D = (j) =>
3628
+ j >= 2 &&
3629
+ body.charCodeAt(j - 2) === 37 && // '%'
3630
+ body.charCodeAt(j - 1) === 51 && // '3'
3631
+ (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
3632
+
3633
+ if (idx >= 0) {
3634
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
3635
+ pad++;
3636
+ idx--;
3637
+ } else if (tailIsPct3D(idx)) {
3638
+ pad++;
3639
+ idx -= 3;
3640
+ }
3641
+ }
3642
+
3643
+ if (pad === 1 && idx >= 0) {
3644
+ if (body.charCodeAt(idx) === 61 /* '=' */) {
3645
+ pad++;
3646
+ } else if (tailIsPct3D(idx)) {
3647
+ pad++;
3648
+ }
3649
+ }
3650
+
3651
+ const groups = Math.floor(effectiveLen / 4);
3652
+ const bytes = groups * 3 - (pad || 0);
3653
+ return bytes > 0 ? bytes : 0;
3654
+ }
3655
+
3656
+ if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
3657
+ return Buffer.byteLength(body, 'utf8');
3658
+ }
3659
+
3660
+ // Compute UTF-8 byte length directly from UTF-16 code units without allocating
3661
+ // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
3662
+ // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
3663
+ // but 3 UTF-8 bytes).
3664
+ let bytes = 0;
3665
+ for (let i = 0, len = body.length; i < len; i++) {
3666
+ const c = body.charCodeAt(i);
3667
+ if (c < 0x80) {
3668
+ bytes += 1;
3669
+ } else if (c < 0x800) {
3670
+ bytes += 2;
3671
+ } else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
3672
+ const next = body.charCodeAt(i + 1);
3673
+ if (next >= 0xdc00 && next <= 0xdfff) {
3674
+ bytes += 4;
3675
+ i++;
3676
+ } else {
3677
+ bytes += 3;
3678
+ }
3679
+ } else {
3680
+ bytes += 3;
3681
+ }
3682
+ }
3683
+ return bytes;
3684
+ }
3685
+
3686
+ const VERSION$1 = "1.16.1";
3381
3687
 
3382
- const globalFetchAPI = (({ Request, Response }) => ({
3383
- Request,
3384
- Response,
3385
- }))(utils$1.global);
3688
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
3386
3689
 
3387
- const { ReadableStream: ReadableStream$1, TextEncoder } = utils$1.global;
3690
+ const { isFunction } = utils$1;
3388
3691
 
3389
3692
  const test = (fn, ...args) => {
3390
3693
  try {
@@ -3395,11 +3698,20 @@ const test = (fn, ...args) => {
3395
3698
  };
3396
3699
 
3397
3700
  const factory = (env) => {
3701
+ const globalObject =
3702
+ utils$1.global !== undefined && utils$1.global !== null
3703
+ ? utils$1.global
3704
+ : globalThis;
3705
+ const { ReadableStream, TextEncoder } = globalObject;
3706
+
3398
3707
  env = utils$1.merge.call(
3399
3708
  {
3400
3709
  skipUndefined: true,
3401
3710
  },
3402
- globalFetchAPI,
3711
+ {
3712
+ Request: globalObject.Request,
3713
+ Response: globalObject.Response,
3714
+ },
3403
3715
  env
3404
3716
  );
3405
3717
 
@@ -3412,7 +3724,7 @@ const factory = (env) => {
3412
3724
  return false;
3413
3725
  }
3414
3726
 
3415
- const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
3727
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
3416
3728
 
3417
3729
  const encodeText =
3418
3730
  isFetchSupported &&
@@ -3429,18 +3741,20 @@ const factory = (env) => {
3429
3741
  test(() => {
3430
3742
  let duplexAccessed = false;
3431
3743
 
3432
- const body = new ReadableStream$1();
3433
-
3434
- const hasContentType = new Request(platform.origin, {
3435
- body,
3744
+ const request = new Request(platform.origin, {
3745
+ body: new ReadableStream(),
3436
3746
  method: 'POST',
3437
3747
  get duplex() {
3438
3748
  duplexAccessed = true;
3439
3749
  return 'half';
3440
3750
  },
3441
- }).headers.has('Content-Type');
3751
+ });
3442
3752
 
3443
- body.cancel();
3753
+ const hasContentType = request.headers.has('Content-Type');
3754
+
3755
+ if (request.body != null) {
3756
+ request.body.cancel();
3757
+ }
3444
3758
 
3445
3759
  return duplexAccessed && !hasContentType;
3446
3760
  });
@@ -3524,8 +3838,13 @@ const factory = (env) => {
3524
3838
  headers,
3525
3839
  withCredentials = 'same-origin',
3526
3840
  fetchOptions,
3841
+ maxContentLength,
3842
+ maxBodyLength,
3527
3843
  } = resolveConfig(config);
3528
3844
 
3845
+ const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
3846
+ const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
3847
+
3529
3848
  let _fetch = envFetch || fetch;
3530
3849
 
3531
3850
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
@@ -3547,6 +3866,41 @@ const factory = (env) => {
3547
3866
  let requestContentLength;
3548
3867
 
3549
3868
  try {
3869
+ // Enforce maxContentLength for data: URLs up-front so we never materialize
3870
+ // an oversized payload. The HTTP adapter applies the same check (see http.js
3871
+ // "if (protocol === 'data:')" branch).
3872
+ if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
3873
+ const estimated = estimateDataURLDecodedBytes(url);
3874
+ if (estimated > maxContentLength) {
3875
+ throw new AxiosError$1(
3876
+ 'maxContentLength size of ' + maxContentLength + ' exceeded',
3877
+ AxiosError$1.ERR_BAD_RESPONSE,
3878
+ config,
3879
+ request
3880
+ );
3881
+ }
3882
+ }
3883
+
3884
+ // Enforce maxBodyLength against the outbound request body before dispatch.
3885
+ // Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
3886
+ // maxBodyLength limit'). Skip when the body length cannot be determined
3887
+ // (e.g. a live ReadableStream supplied by the caller).
3888
+ if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
3889
+ const outboundLength = await resolveBodyLength(headers, data);
3890
+ if (
3891
+ typeof outboundLength === 'number' &&
3892
+ isFinite(outboundLength) &&
3893
+ outboundLength > maxBodyLength
3894
+ ) {
3895
+ throw new AxiosError$1(
3896
+ 'Request body larger than maxBodyLength limit',
3897
+ AxiosError$1.ERR_BAD_REQUEST,
3898
+ config,
3899
+ request
3900
+ );
3901
+ }
3902
+ }
3903
+
3550
3904
  if (
3551
3905
  onUploadProgress &&
3552
3906
  supportsRequestStream &&
@@ -3584,11 +3938,27 @@ const factory = (env) => {
3584
3938
  // see https://github.com/cloudflare/workerd/issues/902
3585
3939
  const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
3586
3940
 
3941
+ // If data is FormData and Content-Type is multipart/form-data without boundary,
3942
+ // delete it so fetch can set it correctly with the boundary
3943
+ if (utils$1.isFormData(data)) {
3944
+ const contentType = headers.getContentType();
3945
+ if (
3946
+ contentType &&
3947
+ /^multipart\/form-data/i.test(contentType) &&
3948
+ !/boundary=/i.test(contentType)
3949
+ ) {
3950
+ headers.delete('content-type');
3951
+ }
3952
+ }
3953
+
3954
+ // Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
3955
+ headers.set('User-Agent', 'axios/' + VERSION$1, false);
3956
+
3587
3957
  const resolvedOptions = {
3588
3958
  ...fetchOptions,
3589
3959
  signal: composedSignal,
3590
3960
  method: method.toUpperCase(),
3591
- headers: headers.normalize().toJSON(),
3961
+ headers: toByteStringHeaderObject(headers.normalize()),
3592
3962
  body: data,
3593
3963
  duplex: 'half',
3594
3964
  credentials: isCredentialsSupported ? withCredentials : undefined,
@@ -3600,10 +3970,28 @@ const factory = (env) => {
3600
3970
  ? _fetch(request, fetchOptions)
3601
3971
  : _fetch(url, resolvedOptions));
3602
3972
 
3973
+ // Cheap pre-check: if the server honestly declares a content-length that
3974
+ // already exceeds the cap, reject before we start streaming.
3975
+ if (hasMaxContentLength) {
3976
+ const declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3977
+ if (declaredLength != null && declaredLength > maxContentLength) {
3978
+ throw new AxiosError$1(
3979
+ 'maxContentLength size of ' + maxContentLength + ' exceeded',
3980
+ AxiosError$1.ERR_BAD_RESPONSE,
3981
+ config,
3982
+ request
3983
+ );
3984
+ }
3985
+ }
3986
+
3603
3987
  const isStreamResponse =
3604
3988
  supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3605
3989
 
3606
- if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3990
+ if (
3991
+ supportsResponseStream &&
3992
+ response.body &&
3993
+ (onDownloadProgress || hasMaxContentLength || (isStreamResponse && unsubscribe))
3994
+ ) {
3607
3995
  const options = {};
3608
3996
 
3609
3997
  ['status', 'statusText', 'headers'].forEach((prop) => {
@@ -3620,8 +4008,24 @@ const factory = (env) => {
3620
4008
  )) ||
3621
4009
  [];
3622
4010
 
4011
+ let bytesRead = 0;
4012
+ const onChunkProgress = (loadedBytes) => {
4013
+ if (hasMaxContentLength) {
4014
+ bytesRead = loadedBytes;
4015
+ if (bytesRead > maxContentLength) {
4016
+ throw new AxiosError$1(
4017
+ 'maxContentLength size of ' + maxContentLength + ' exceeded',
4018
+ AxiosError$1.ERR_BAD_RESPONSE,
4019
+ config,
4020
+ request
4021
+ );
4022
+ }
4023
+ }
4024
+ onProgress && onProgress(loadedBytes);
4025
+ };
4026
+
3623
4027
  response = new Response(
3624
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
4028
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
3625
4029
  flush && flush();
3626
4030
  unsubscribe && unsubscribe();
3627
4031
  }),
@@ -3636,6 +4040,33 @@ const factory = (env) => {
3636
4040
  config
3637
4041
  );
3638
4042
 
4043
+ // Fallback enforcement for environments without ReadableStream support
4044
+ // (legacy runtimes). Detect materialized size from typed output; skip
4045
+ // streams/Response passthrough since the user will read those themselves.
4046
+ if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
4047
+ let materializedSize;
4048
+ if (responseData != null) {
4049
+ if (typeof responseData.byteLength === 'number') {
4050
+ materializedSize = responseData.byteLength;
4051
+ } else if (typeof responseData.size === 'number') {
4052
+ materializedSize = responseData.size;
4053
+ } else if (typeof responseData === 'string') {
4054
+ materializedSize =
4055
+ typeof TextEncoder === 'function'
4056
+ ? new TextEncoder().encode(responseData).byteLength
4057
+ : responseData.length;
4058
+ }
4059
+ }
4060
+ if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
4061
+ throw new AxiosError$1(
4062
+ 'maxContentLength size of ' + maxContentLength + ' exceeded',
4063
+ AxiosError$1.ERR_BAD_RESPONSE,
4064
+ config,
4065
+ request
4066
+ );
4067
+ }
4068
+ }
4069
+
3639
4070
  !isStreamResponse && unsubscribe && unsubscribe();
3640
4071
 
3641
4072
  return await new Promise((resolve, reject) => {
@@ -3651,6 +4082,17 @@ const factory = (env) => {
3651
4082
  } catch (err) {
3652
4083
  unsubscribe && unsubscribe();
3653
4084
 
4085
+ // Safari can surface fetch aborts as a DOMException-like object whose
4086
+ // branded getters throw. Prefer our composed signal reason before reading
4087
+ // the caught error, preserving timeout vs cancellation semantics.
4088
+ if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError$1) {
4089
+ const canceledError = composedSignal.reason;
4090
+ canceledError.config = config;
4091
+ request && (canceledError.request = request);
4092
+ err !== canceledError && (canceledError.cause = err);
4093
+ throw canceledError;
4094
+ }
4095
+
3654
4096
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3655
4097
  throw Object.assign(
3656
4098
  new AxiosError$1(
@@ -3719,11 +4161,13 @@ const knownAdapters = {
3719
4161
  utils$1.forEach(knownAdapters, (fn, value) => {
3720
4162
  if (fn) {
3721
4163
  try {
3722
- Object.defineProperty(fn, 'name', { value });
4164
+ // Null-proto descriptors so a polluted Object.prototype.get cannot turn
4165
+ // these data descriptors into accessor descriptors on the way in.
4166
+ Object.defineProperty(fn, 'name', { __proto__: null, value });
3723
4167
  } catch (e) {
3724
4168
  // eslint-disable-next-line no-empty
3725
4169
  }
3726
- Object.defineProperty(fn, 'adapterName', { value });
4170
+ Object.defineProperty(fn, 'adapterName', { __proto__: null, value });
3727
4171
  }
3728
4172
  });
3729
4173
 
@@ -3865,8 +4309,15 @@ function dispatchRequest(config) {
3865
4309
  function onAdapterResolution(response) {
3866
4310
  throwIfCancellationRequested(config);
3867
4311
 
3868
- // Transform response data
3869
- response.data = transformData.call(config, config.transformResponse, response);
4312
+ // Expose the current response on config so that transformResponse can
4313
+ // attach it to any AxiosError it throws (e.g. on JSON parse failure).
4314
+ // We clean it up afterwards to avoid polluting the config object.
4315
+ config.response = response;
4316
+ try {
4317
+ response.data = transformData.call(config, config.transformResponse, response);
4318
+ } finally {
4319
+ delete config.response;
4320
+ }
3870
4321
 
3871
4322
  response.headers = AxiosHeaders$1.from(response.headers);
3872
4323
 
@@ -3878,11 +4329,16 @@ function dispatchRequest(config) {
3878
4329
 
3879
4330
  // Transform response data
3880
4331
  if (reason && reason.response) {
3881
- reason.response.data = transformData.call(
3882
- config,
3883
- config.transformResponse,
3884
- reason.response
3885
- );
4332
+ config.response = reason.response;
4333
+ try {
4334
+ reason.response.data = transformData.call(
4335
+ config,
4336
+ config.transformResponse,
4337
+ reason.response
4338
+ );
4339
+ } finally {
4340
+ delete config.response;
4341
+ }
3886
4342
  reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3887
4343
  }
3888
4344
  }
@@ -3892,8 +4348,6 @@ function dispatchRequest(config) {
3892
4348
  );
3893
4349
  }
3894
4350
 
3895
- const VERSION$1 = "1.15.0";
3896
-
3897
4351
  const validators$1 = {};
3898
4352
 
3899
4353
  // eslint-disable-next-line func-names
@@ -3977,7 +4431,9 @@ function assertOptions(options, schema, allowUnknown) {
3977
4431
  let i = keys.length;
3978
4432
  while (i-- > 0) {
3979
4433
  const opt = keys[i];
3980
- const validator = schema[opt];
4434
+ // Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
4435
+ // a non-function validator and cause a TypeError.
4436
+ const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
3981
4437
  if (validator) {
3982
4438
  const value = options[opt];
3983
4439
  const result = value === undefined || validator(value, opt, options);
@@ -4136,7 +4592,7 @@ let Axios$1 = class Axios {
4136
4592
  let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
4137
4593
 
4138
4594
  headers &&
4139
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
4595
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
4140
4596
  delete headers[method];
4141
4597
  });
4142
4598
 
@@ -4239,7 +4695,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
4239
4695
  };
4240
4696
  });
4241
4697
 
4242
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
4698
+ utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
4243
4699
  function generateHTTPMethod(isForm) {
4244
4700
  return function httpMethod(url, data, config) {
4245
4701
  return this.request(
@@ -4259,7 +4715,11 @@ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
4259
4715
 
4260
4716
  Axios$1.prototype[method] = generateHTTPMethod();
4261
4717
 
4262
- Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
4718
+ // QUERY is a safe/idempotent read method; multipart form bodies don't fit
4719
+ // its semantics, so no queryForm shorthand is generated.
4720
+ if (method !== 'query') {
4721
+ Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
4722
+ }
4263
4723
  });
4264
4724
 
4265
4725
  /**
@@ -4593,6 +5053,7 @@ const {
4593
5053
  formToJSON,
4594
5054
  getAdapter,
4595
5055
  mergeConfig,
5056
+ create,
4596
5057
  } = axios;
4597
5058
 
4598
5059
  /******************************************************************************
@@ -7680,10 +8141,255 @@ class MayachainProtocol {
7680
8141
  }
7681
8142
  }
7682
8143
 
8144
+ const BASE_URL = 'https://1click.chaindefuser.com';
8145
+ class OneClickApi {
8146
+ constructor(apiKey) {
8147
+ this.headers = { 'Content-Type': 'application/json' };
8148
+ if (apiKey) {
8149
+ this.headers['Authorization'] = `Bearer ${apiKey}`;
8150
+ }
8151
+ }
8152
+ getTokens() {
8153
+ return __awaiter$4(this, void 0, void 0, function* () {
8154
+ const resp = yield fetch(`${BASE_URL}/v0/tokens`, { headers: this.headers });
8155
+ if (!resp.ok)
8156
+ throw new Error(`1Click getTokens failed: ${resp.status}`);
8157
+ return resp.json();
8158
+ });
8159
+ }
8160
+ getQuote(params) {
8161
+ return __awaiter$4(this, void 0, void 0, function* () {
8162
+ const resp = yield fetch(`${BASE_URL}/v0/quote`, {
8163
+ method: 'POST',
8164
+ headers: this.headers,
8165
+ body: JSON.stringify(params),
8166
+ });
8167
+ if (!resp.ok)
8168
+ throw new Error(`1Click getQuote failed: ${resp.status}`);
8169
+ return resp.json();
8170
+ });
8171
+ }
8172
+ submitDeposit(txHash, depositAddress) {
8173
+ return __awaiter$4(this, void 0, void 0, function* () {
8174
+ yield fetch(`${BASE_URL}/v0/deposit/submit`, {
8175
+ method: 'POST',
8176
+ headers: this.headers,
8177
+ body: JSON.stringify({ txHash, depositAddress }),
8178
+ }).catch(() => {
8179
+ // Fire-and-forget
8180
+ });
8181
+ });
8182
+ }
8183
+ }
8184
+
8185
+ const X_TO_ONECLICK = {
8186
+ BTC: 'btc',
8187
+ ETH: 'eth',
8188
+ ARB: 'arb',
8189
+ AVAX: 'avax',
8190
+ BSC: 'bsc',
8191
+ SOL: 'sol',
8192
+ DOGE: 'doge',
8193
+ DASH: 'dash',
8194
+ LTC: 'ltc',
8195
+ BCH: 'bch',
8196
+ XRP: 'xrp',
8197
+ ADA: 'cardano',
8198
+ SUI: 'sui',
8199
+ };
8200
+ const ONECLICK_TO_X = Object.fromEntries(Object.entries(X_TO_ONECLICK).map(([k, v]) => [v, k]));
8201
+ const xChainToOneClickBlockchain = (chain) => {
8202
+ var _a;
8203
+ return (_a = X_TO_ONECLICK[chain]) !== null && _a !== void 0 ? _a : null;
8204
+ };
8205
+ const oneClickBlockchainToXChain = (blockchain) => {
8206
+ var _a;
8207
+ return (_a = ONECLICK_TO_X[blockchain]) !== null && _a !== void 0 ? _a : null;
8208
+ };
8209
+ const findOneClickToken = (asset, tokens) => {
8210
+ if (xchainUtil.isSynthAsset(asset) || xchainUtil.isTradeAsset(asset) || xchainUtil.isSecuredAsset(asset))
8211
+ return undefined;
8212
+ const blockchain = xChainToOneClickBlockchain(asset.chain);
8213
+ if (!blockchain)
8214
+ return undefined;
8215
+ return tokens.find((token) => {
8216
+ if (token.blockchain !== blockchain)
8217
+ return false;
8218
+ if (xchainUtil.isTokenAsset(asset)) {
8219
+ // Match by contract address (case-insensitive)
8220
+ const assetContract = asset.symbol.includes('-') ? asset.symbol.split('-')[1] : undefined;
8221
+ return assetContract && token.contractAddress
8222
+ ? token.contractAddress.toLowerCase() === assetContract.toLowerCase()
8223
+ : false;
8224
+ }
8225
+ // Native asset: match by symbol, ensure no contract address on token
8226
+ return token.symbol.toUpperCase() === asset.symbol.toUpperCase() && !token.contractAddress;
8227
+ });
8228
+ };
8229
+
8230
+ class OneClickProtocol {
8231
+ constructor(configuration) {
8232
+ this.name = 'OneClick';
8233
+ this.api = new OneClickApi(configuration === null || configuration === void 0 ? void 0 : configuration.oneClickApiKey);
8234
+ this.wallet = configuration === null || configuration === void 0 ? void 0 : configuration.wallet;
8235
+ this.affiliateAddress = configuration === null || configuration === void 0 ? void 0 : configuration.affiliateAddress;
8236
+ this.affiliateBps = configuration === null || configuration === void 0 ? void 0 : configuration.affiliateBps;
8237
+ this.tokensCache = new xchainUtil.CachedValue(() => this.api.getTokens(), 24 * 60 * 60 * 1000);
8238
+ }
8239
+ approveRouterToSpend(_params) {
8240
+ return __awaiter$4(this, void 0, void 0, function* () {
8241
+ throw new Error('Not implemented');
8242
+ });
8243
+ }
8244
+ shouldBeApproved(_params) {
8245
+ return __awaiter$4(this, void 0, void 0, function* () {
8246
+ return false;
8247
+ });
8248
+ }
8249
+ isAssetSupported(asset) {
8250
+ return __awaiter$4(this, void 0, void 0, function* () {
8251
+ if (xchainUtil.isSynthAsset(asset) || xchainUtil.isTradeAsset(asset) || xchainUtil.isSecuredAsset(asset))
8252
+ return false;
8253
+ const tokens = yield this.tokensCache.getValue();
8254
+ return findOneClickToken(asset, tokens) !== undefined;
8255
+ });
8256
+ }
8257
+ getSupportedChains() {
8258
+ return __awaiter$4(this, void 0, void 0, function* () {
8259
+ const tokens = yield this.tokensCache.getValue();
8260
+ const chains = new Set();
8261
+ for (const token of tokens) {
8262
+ const chain = oneClickBlockchainToXChain(token.blockchain);
8263
+ if (chain)
8264
+ chains.add(chain);
8265
+ }
8266
+ return Array.from(chains);
8267
+ });
8268
+ }
8269
+ estimateSwap(params) {
8270
+ return __awaiter$4(this, void 0, void 0, function* () {
8271
+ var _a, _b, _c;
8272
+ const tokens = yield this.tokensCache.getValue();
8273
+ const srcToken = findOneClickToken(params.fromAsset, tokens);
8274
+ const destToken = findOneClickToken(params.destinationAsset, tokens);
8275
+ if (!srcToken || !destToken) {
8276
+ return this.errorQuote(params, srcToken ? 'Destination asset not supported' : 'Source asset not supported');
8277
+ }
8278
+ try {
8279
+ const isDry = !(params.fromAddress && params.destinationAddress);
8280
+ const deadline = new Date(Date.now() + 10 * 60 * 1000).toISOString();
8281
+ const appFees = this.affiliateAddress && this.affiliateBps
8282
+ ? [{ recipient: this.affiliateAddress, fee: this.affiliateBps }]
8283
+ : undefined;
8284
+ const resp = yield this.api.getQuote({
8285
+ dry: isDry,
8286
+ swapType: 'EXACT_INPUT',
8287
+ depositType: 'ORIGIN_CHAIN',
8288
+ recipientType: 'DESTINATION_CHAIN',
8289
+ refundType: 'ORIGIN_CHAIN',
8290
+ originAsset: srcToken.assetId,
8291
+ destinationAsset: destToken.assetId,
8292
+ amount: params.amount.baseAmount.amount().toString(),
8293
+ refundTo: params.fromAddress || '',
8294
+ recipient: params.destinationAddress || '',
8295
+ slippageTolerance: (_a = params.toleranceBps) !== null && _a !== void 0 ? _a : 100,
8296
+ deadline,
8297
+ appFees,
8298
+ });
8299
+ if (resp.error || resp.message) {
8300
+ return this.errorQuote(params, resp.error || resp.message || 'Unknown error');
8301
+ }
8302
+ const quote = resp.quote;
8303
+ const toAddress = (_b = quote.depositAddress) !== null && _b !== void 0 ? _b : '';
8304
+ return {
8305
+ protocol: this.name,
8306
+ toAddress,
8307
+ memo: '',
8308
+ expectedAmount: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(quote.amountOut, destToken.decimals), params.destinationAsset),
8309
+ dustThreshold: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.fromAsset),
8310
+ totalSwapSeconds: (_c = quote.timeEstimate) !== null && _c !== void 0 ? _c : 0,
8311
+ maxStreamingQuantity: undefined,
8312
+ canSwap: toAddress !== '',
8313
+ warning: '',
8314
+ errors: [],
8315
+ slipBasisPoints: 0,
8316
+ fees: {
8317
+ asset: params.fromAsset,
8318
+ affiliateFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.fromAsset),
8319
+ outboundFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.destinationAsset),
8320
+ },
8321
+ };
8322
+ }
8323
+ catch (e) {
8324
+ return this.errorQuote(params, e instanceof Error ? e.message : 'Unknown error');
8325
+ }
8326
+ });
8327
+ }
8328
+ doSwap(params) {
8329
+ return __awaiter$4(this, void 0, void 0, function* () {
8330
+ const quoteSwap = yield this.estimateSwap(params);
8331
+ if (!quoteSwap.canSwap) {
8332
+ throw new Error(`Can not make swap. ${quoteSwap.errors.join('\n')}`);
8333
+ }
8334
+ if (!this.wallet)
8335
+ throw new Error('Wallet not configured. Can not do swap');
8336
+ const hash = yield this.wallet.transfer({
8337
+ recipient: quoteSwap.toAddress,
8338
+ amount: params.amount.baseAmount,
8339
+ asset: params.fromAsset,
8340
+ memo: quoteSwap.memo,
8341
+ });
8342
+ // Funds are already on the wire. Awaiting submitDeposit lets callers distinguish
8343
+ // "deposit registered, swap will settle" from "registration silently failed, swap will
8344
+ // never settle" — surface the failure with the broadcast hash so it can be retried.
8345
+ try {
8346
+ yield this.api.submitDeposit(hash, quoteSwap.toAddress);
8347
+ }
8348
+ catch (e) {
8349
+ throw new Error(`1Click deposit tx ${hash} was broadcast, but submitDeposit failed: ${e instanceof Error ? e.message : 'unknown error'}`);
8350
+ }
8351
+ // Explorer URL is best-effort; the hash is what callers actually need for tracking.
8352
+ let url = '';
8353
+ try {
8354
+ url = yield this.wallet.getExplorerTxUrl(params.fromAsset.chain, hash);
8355
+ }
8356
+ catch (_a) {
8357
+ // swallow: explorer URL lookup must not reject a successful swap
8358
+ }
8359
+ return { hash, url };
8360
+ });
8361
+ }
8362
+ getSwapHistory(_params) {
8363
+ return __awaiter$4(this, void 0, void 0, function* () {
8364
+ return { count: 0, swaps: [] };
8365
+ });
8366
+ }
8367
+ errorQuote(params, error) {
8368
+ return {
8369
+ protocol: this.name,
8370
+ toAddress: '',
8371
+ memo: '',
8372
+ expectedAmount: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.destinationAsset),
8373
+ dustThreshold: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.fromAsset),
8374
+ totalSwapSeconds: 0,
8375
+ maxStreamingQuantity: undefined,
8376
+ canSwap: false,
8377
+ warning: '',
8378
+ errors: [error],
8379
+ slipBasisPoints: 0,
8380
+ fees: {
8381
+ asset: params.fromAsset,
8382
+ affiliateFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.fromAsset),
8383
+ outboundFee: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(0), params.destinationAsset),
8384
+ },
8385
+ };
8386
+ }
8387
+ }
8388
+
7683
8389
  /**
7684
8390
  * The base URL for the Midgard API endpoint.
7685
8391
  */
7686
- const MIDGARD_API_URL = 'https://gateway.liquify.com/chain/thorchain_midgard/';
8392
+ const MIDGARD_API_URL = 'https://midgard.thorchain.network/';
7687
8393
 
7688
8394
  /******************************************************************************
7689
8395
  Copyright (c) Microsoft Corporation.
@@ -10512,7 +11218,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
10512
11218
  const defaultMidgardConfig = {
10513
11219
  mainnet: {
10514
11220
  apiRetries: 3,
10515
- midgardBaseUrls: ['https://gateway.liquify.com/chain/thorchain_midgard'],
11221
+ midgardBaseUrls: ['https://midgard.thorchain.network', 'https://gateway.liquify.com/chain/thorchain_midgard'],
10516
11222
  },
10517
11223
  stagenet: {
10518
11224
  apiRetries: 3,
@@ -11065,6 +11771,7 @@ const getProtocolConfig = (name, configuration) => {
11065
11771
  network: configuration.network,
11066
11772
  affiliateBrokers: configuration.affiliateBrokers,
11067
11773
  brokerUrl: configuration.brokerUrl,
11774
+ oneClickApiKey: configuration.oneClickApiKey,
11068
11775
  };
11069
11776
  };
11070
11777
  class ProtocolFactory {
@@ -11077,6 +11784,8 @@ class ProtocolFactory {
11077
11784
  return new MayachainProtocol(protocolConfig);
11078
11785
  case 'Chainflip':
11079
11786
  return new ChainflipProtocol(protocolConfig);
11787
+ case 'OneClick':
11788
+ return new OneClickProtocol(protocolConfig);
11080
11789
  }
11081
11790
  }
11082
11791
  }