@usherlabs/cex-broker 0.1.12 → 0.1.15

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/dist/index.js CHANGED
@@ -31980,6 +31980,7 @@ var require_form_data = __commonJS((exports, module) => {
31980
31980
  var parseUrl = __require("url").parse;
31981
31981
  var fs = __require("fs");
31982
31982
  var Stream2 = __require("stream").Stream;
31983
+ var crypto3 = __require("crypto");
31983
31984
  var mime = require_mime_types();
31984
31985
  var asynckit = require_asynckit();
31985
31986
  var setToStringTag = require_es_set_tostringtag();
@@ -32184,11 +32185,7 @@ var require_form_data = __commonJS((exports, module) => {
32184
32185
  return Buffer.concat([dataBuffer, Buffer.from(this._lastBoundary())]);
32185
32186
  };
32186
32187
  FormData2.prototype._generateBoundary = function() {
32187
- var boundary = "--------------------------";
32188
- for (var i2 = 0;i2 < 24; i2++) {
32189
- boundary += Math.floor(Math.random() * 10).toString(16);
32190
- }
32191
- this._boundary = boundary;
32188
+ this._boundary = "--------------------------" + crypto3.randomBytes(12).toString("hex");
32192
32189
  };
32193
32190
  FormData2.prototype.getLengthSync = function() {
32194
32191
  var knownLength = this._overheadLength + this._valueLength;
@@ -33256,7 +33253,7 @@ var require_follow_redirects = __commonJS((exports, module) => {
33256
33253
 
33257
33254
  // node_modules/axios/dist/node/axios.cjs
33258
33255
  var require_axios = __commonJS((exports, module) => {
33259
- /*! Axios v1.10.0 Copyright (c) 2025 Matt Zabriskie and contributors */
33256
+ /*! Axios v1.11.0 Copyright (c) 2025 Matt Zabriskie and contributors */
33260
33257
  var FormData$1 = require_form_data();
33261
33258
  var crypto4 = __require("crypto");
33262
33259
  var url2 = __require("url");
@@ -33325,6 +33322,16 @@ var require_axios = __commonJS((exports, module) => {
33325
33322
  const prototype4 = getPrototypeOf2(val);
33326
33323
  return (prototype4 === null || prototype4 === Object.prototype || Object.getPrototypeOf(prototype4) === null) && !(toStringTag2 in val) && !(iterator2 in val);
33327
33324
  };
33325
+ var isEmptyObject2 = (val) => {
33326
+ if (!isObject3(val) || isBuffer2(val)) {
33327
+ return false;
33328
+ }
33329
+ try {
33330
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
33331
+ } catch (e) {
33332
+ return false;
33333
+ }
33334
+ };
33328
33335
  var isDate2 = kindOfTest2("Date");
33329
33336
  var isFile2 = kindOfTest2("File");
33330
33337
  var isBlob2 = kindOfTest2("Blob");
@@ -33351,6 +33358,9 @@ var require_axios = __commonJS((exports, module) => {
33351
33358
  fn.call(null, obj[i2], i2, obj);
33352
33359
  }
33353
33360
  } else {
33361
+ if (isBuffer2(obj)) {
33362
+ return;
33363
+ }
33354
33364
  const keys2 = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
33355
33365
  const len = keys2.length;
33356
33366
  let key;
@@ -33361,6 +33371,9 @@ var require_axios = __commonJS((exports, module) => {
33361
33371
  }
33362
33372
  }
33363
33373
  function findKey2(obj, key) {
33374
+ if (isBuffer2(obj)) {
33375
+ return null;
33376
+ }
33364
33377
  key = key.toLowerCase();
33365
33378
  const keys2 = Object.keys(obj);
33366
33379
  let i2 = keys2.length;
@@ -33553,6 +33566,9 @@ var require_axios = __commonJS((exports, module) => {
33553
33566
  if (stack.indexOf(source) >= 0) {
33554
33567
  return;
33555
33568
  }
33569
+ if (isBuffer2(source)) {
33570
+ return source;
33571
+ }
33556
33572
  if (!("toJSON" in source)) {
33557
33573
  stack[i2] = source;
33558
33574
  const target = isArray3(source) ? [] : {};
@@ -33599,6 +33615,7 @@ var require_axios = __commonJS((exports, module) => {
33599
33615
  isBoolean: isBoolean3,
33600
33616
  isObject: isObject3,
33601
33617
  isPlainObject: isPlainObject2,
33618
+ isEmptyObject: isEmptyObject2,
33602
33619
  isReadableStream: isReadableStream2,
33603
33620
  isRequest: isRequest2,
33604
33621
  isResponse: isResponse2,
@@ -33964,15 +33981,16 @@ var require_axios = __commonJS((exports, module) => {
33964
33981
  ...platform$1
33965
33982
  };
33966
33983
  function toURLEncodedForm2(data, options) {
33967
- return toFormData2(data, new platform2.classes.URLSearchParams, Object.assign({
33984
+ return toFormData2(data, new platform2.classes.URLSearchParams, {
33968
33985
  visitor: function(value, key, path, helpers) {
33969
33986
  if (platform2.isNode && utils$1.isBuffer(value)) {
33970
33987
  this.append(key, value.toString("base64"));
33971
33988
  return false;
33972
33989
  }
33973
33990
  return helpers.defaultVisitor.apply(this, arguments);
33974
- }
33975
- }, options));
33991
+ },
33992
+ ...options
33993
+ });
33976
33994
  }
33977
33995
  function parsePropPath2(name) {
33978
33996
  return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
@@ -34440,7 +34458,7 @@ var require_axios = __commonJS((exports, module) => {
34440
34458
  }
34441
34459
  return requestedURL;
34442
34460
  }
34443
- var VERSION2 = "1.10.0";
34461
+ var VERSION2 = "1.11.0";
34444
34462
  function parseProtocol2(url3) {
34445
34463
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url3);
34446
34464
  return match && match[1] || "";
@@ -34755,7 +34773,7 @@ var require_axios = __commonJS((exports, module) => {
34755
34773
  clearTimeout(timer);
34756
34774
  timer = null;
34757
34775
  }
34758
- fn.apply(null, args);
34776
+ fn(...args);
34759
34777
  };
34760
34778
  const throttled = (...args) => {
34761
34779
  const now2 = Date.now();
@@ -35356,7 +35374,7 @@ var require_axios = __commonJS((exports, module) => {
35356
35374
  validateStatus: mergeDirectKeys,
35357
35375
  headers: (a, b2, prop3) => mergeDeepProperties(headersToObject2(a), headersToObject2(b2), prop3, true)
35358
35376
  };
35359
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop3) {
35377
+ utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop3) {
35360
35378
  const merge4 = mergeMap[prop3] || mergeDeepProperties;
35361
35379
  const configValue = merge4(config1[prop3], config2[prop3], prop3);
35362
35380
  utils$1.isUndefined(configValue) && merge4 !== mergeDirectKeys || (config[prop3] = configValue);
@@ -35995,8 +36013,8 @@ var require_axios = __commonJS((exports, module) => {
35995
36013
  let len;
35996
36014
  if (!synchronousRequestInterceptors) {
35997
36015
  const chain2 = [dispatchRequest2.bind(this), undefined];
35998
- chain2.unshift.apply(chain2, requestInterceptorChain);
35999
- chain2.push.apply(chain2, responseInterceptorChain);
36016
+ chain2.unshift(...requestInterceptorChain);
36017
+ chain2.push(...responseInterceptorChain);
36000
36018
  len = chain2.length;
36001
36019
  promise = Promise.resolve(config);
36002
36020
  while (i2 < len) {
@@ -63227,6 +63245,16 @@ var isPlainObject = (val) => {
63227
63245
  const prototype = getPrototypeOf(val);
63228
63246
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
63229
63247
  };
63248
+ var isEmptyObject = (val) => {
63249
+ if (!isObject2(val) || isBuffer(val)) {
63250
+ return false;
63251
+ }
63252
+ try {
63253
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
63254
+ } catch (e) {
63255
+ return false;
63256
+ }
63257
+ };
63230
63258
  var isDate = kindOfTest("Date");
63231
63259
  var isFile = kindOfTest("File");
63232
63260
  var isBlob = kindOfTest("Blob");
@@ -63253,6 +63281,9 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
63253
63281
  fn.call(null, obj[i2], i2, obj);
63254
63282
  }
63255
63283
  } else {
63284
+ if (isBuffer(obj)) {
63285
+ return;
63286
+ }
63256
63287
  const keys2 = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
63257
63288
  const len = keys2.length;
63258
63289
  let key;
@@ -63263,6 +63294,9 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
63263
63294
  }
63264
63295
  }
63265
63296
  function findKey(obj, key) {
63297
+ if (isBuffer(obj)) {
63298
+ return null;
63299
+ }
63266
63300
  key = key.toLowerCase();
63267
63301
  const keys2 = Object.keys(obj);
63268
63302
  let i2 = keys2.length;
@@ -63455,6 +63489,9 @@ var toJSONObject = (obj) => {
63455
63489
  if (stack.indexOf(source) >= 0) {
63456
63490
  return;
63457
63491
  }
63492
+ if (isBuffer(source)) {
63493
+ return source;
63494
+ }
63458
63495
  if (!("toJSON" in source)) {
63459
63496
  stack[i2] = source;
63460
63497
  const target = isArray2(source) ? [] : {};
@@ -63501,6 +63538,7 @@ var utils_default = {
63501
63538
  isBoolean: isBoolean2,
63502
63539
  isObject: isObject2,
63503
63540
  isPlainObject,
63541
+ isEmptyObject,
63504
63542
  isReadableStream,
63505
63543
  isRequest,
63506
63544
  isResponse,
@@ -63898,15 +63936,16 @@ var platform_default = {
63898
63936
 
63899
63937
  // node_modules/axios/lib/helpers/toURLEncodedForm.js
63900
63938
  function toURLEncodedForm(data, options) {
63901
- return toFormData_default(data, new platform_default.classes.URLSearchParams, Object.assign({
63939
+ return toFormData_default(data, new platform_default.classes.URLSearchParams, {
63902
63940
  visitor: function(value, key, path, helpers) {
63903
63941
  if (platform_default.isNode && utils_default.isBuffer(value)) {
63904
63942
  this.append(key, value.toString("base64"));
63905
63943
  return false;
63906
63944
  }
63907
63945
  return helpers.defaultVisitor.apply(this, arguments);
63908
- }
63909
- }, options));
63946
+ },
63947
+ ...options
63948
+ });
63910
63949
  }
63911
63950
 
63912
63951
  // node_modules/axios/lib/helpers/formDataToJSON.js
@@ -64408,7 +64447,7 @@ import util2 from "util";
64408
64447
  import zlib from "zlib";
64409
64448
 
64410
64449
  // node_modules/axios/lib/env/data.js
64411
- var VERSION = "1.10.0";
64450
+ var VERSION = "1.11.0";
64412
64451
 
64413
64452
  // node_modules/axios/lib/helpers/parseProtocol.js
64414
64453
  function parseProtocol(url2) {
@@ -64754,7 +64793,7 @@ function throttle2(fn, freq) {
64754
64793
  clearTimeout(timer);
64755
64794
  timer = null;
64756
64795
  }
64757
- fn.apply(null, args);
64796
+ fn(...args);
64758
64797
  };
64759
64798
  const throttled = (...args) => {
64760
64799
  const now2 = Date.now();
@@ -65364,7 +65403,7 @@ function mergeConfig(config1, config2) {
65364
65403
  validateStatus: mergeDirectKeys,
65365
65404
  headers: (a, b2, prop3) => mergeDeepProperties(headersToObject(a), headersToObject(b2), prop3, true)
65366
65405
  };
65367
- utils_default.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop3) {
65406
+ utils_default.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop3) {
65368
65407
  const merge3 = mergeMap[prop3] || mergeDeepProperties;
65369
65408
  const configValue = merge3(config1[prop3], config2[prop3], prop3);
65370
65409
  utils_default.isUndefined(configValue) && merge3 !== mergeDirectKeys || (config[prop3] = configValue);
@@ -66019,8 +66058,8 @@ class Axios {
66019
66058
  let len;
66020
66059
  if (!synchronousRequestInterceptors) {
66021
66060
  const chain2 = [dispatchRequest.bind(this), undefined];
66022
- chain2.unshift.apply(chain2, requestInterceptorChain);
66023
- chain2.push.apply(chain2, responseInterceptorChain);
66061
+ chain2.unshift(...requestInterceptorChain);
66062
+ chain2.push(...responseInterceptorChain);
66024
66063
  len = chain2.length;
66025
66064
  promise = Promise.resolve(config);
66026
66065
  while (i2 < len) {
@@ -68512,7 +68551,6 @@ class Exchange {
68512
68551
  this.countries = undefined;
68513
68552
  this.userAgent = undefined;
68514
68553
  this.user_agent = undefined;
68515
- this.redact_exclusion = "api-key";
68516
68554
  this.userAgents = {
68517
68555
  chrome: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",
68518
68556
  chrome39: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36",
@@ -68528,6 +68566,8 @@ class Exchange {
68528
68566
  this.useVerity = false;
68529
68567
  this.verityProverUrl = "http://localhost:8080";
68530
68568
  this.verityMethods = ["fetchBalance", "fetchDepositAddress", "fetchDepositAddress", "fetchDepositAddresses", "fetchDepositAddressesByNetwork", "fetchDeposits", "withdraw", "fetchFundingHistory", "fetchWithdrawals", "fetchWithdrawal"];
68569
+ this.verityRequestOptions = { redact: "" };
68570
+ //! ------------------------------
68531
68571
  this.minFundingAddressLength = 1;
68532
68572
  this.substituteCommonCurrencyCodes = true;
68533
68573
  this.quoteJsonNumbers = true;
@@ -68948,6 +68988,9 @@ class Exchange {
68948
68988
  }
68949
68989
  return;
68950
68990
  }
68991
+ addVerityRequestOptions(options) {
68992
+ this.verityRequestOptions = options;
68993
+ }
68951
68994
  async fetch(url2, method = "GET", headers = undefined, body = undefined) {
68952
68995
  if (isNode2) {
68953
68996
  if (!this.nodeHttpModuleLoaded) {
@@ -69024,8 +69067,7 @@ RequestBody:
69024
69067
  }
69025
69068
  if (this.useVerity && ["get", "post"].includes(method.toLowerCase()) && this.verityMethods.includes(methodCalled)) {
69026
69069
  const client = new import_verity_client.default.VerityClient({ prover_url: this.verityProverUrl });
69027
- const lowercase = Object.keys(axiosConfig.headers).filter((header) => !header.toLowerCase().includes(this.redact_exclusion.toLowerCase())).map((h) => `req:header:${h.toLowerCase()}`).join(",");
69028
- const response = await client.get(axiosConfig.url, axiosConfig).redact(lowercase);
69070
+ const response = await client.get(axiosConfig.url, axiosConfig).redact(this.verityRequestOptions.redact || "");
69029
69071
  if (this.verbose) {
69030
69072
  this.log("verityProof:", response.proof, `
69031
69073
 
@@ -284270,7 +284312,7 @@ class xt2 extends xt {
284270
284312
  }
284271
284313
 
284272
284314
  // node_modules/@usherlabs/ccxt/js/ccxt.js
284273
- var version2 = "0.0.6";
284315
+ var version2 = "0.0.10";
284274
284316
  Exchange.ccxtVersion = version2;
284275
284317
  var exchanges = {
284276
284318
  alpaca,
@@ -285026,7 +285068,7 @@ class Logger extends BaseLogger {
285026
285068
  // src/helpers/logger.ts
285027
285069
  var log = new Logger({
285028
285070
  type: "pretty",
285029
- stylePrettyLogs: false,
285071
+ stylePrettyLogs: true,
285030
285072
  minLevel: process.env.LOG_LEVEL === "debug" ? 0 : 3
285031
285073
  });
285032
285074
 
@@ -285067,7 +285109,6 @@ function createBroker(cex3, metadata, useVerity, verityProverUrl) {
285067
285109
  exchange.setSandboxMode(true);
285068
285110
  }
285069
285111
  exchange.options.recvWindow = 60000;
285070
- exchange.redact_exclusion = "key";
285071
285112
  return exchange;
285072
285113
  }
285073
285114
  function selectBroker(brokers, metadata) {
@@ -285237,11 +285278,11 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285237
285278
  const server = new grpc.Server;
285238
285279
  server.addService(cexNode.cex_service.service, {
285239
285280
  ExecuteAction: async (call, callback) => {
285240
- log.info(`Request - ExecuteAction: ${JSON.stringify({
285281
+ log.info(`Request - ExecuteAction:`, {
285241
285282
  action: call.request.action,
285242
285283
  cex: call.request.cex,
285243
285284
  symbol: call.request.symbol
285244
- })}`);
285285
+ });
285245
285286
  if (!authenticateRequest(call, whitelistIps)) {
285246
285287
  return callback({
285247
285288
  code: grpc.status.PERMISSION_DENIED,
@@ -285250,10 +285291,10 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285250
285291
  }
285251
285292
  const metadata = call.metadata;
285252
285293
  const { action, cex: cex3, symbol } = call.request;
285253
- if (!action || !cex3 || !symbol) {
285294
+ if (!action || !cex3) {
285254
285295
  return callback({
285255
285296
  code: grpc.status.INVALID_ARGUMENT,
285256
- message: "action, cex, symbol, and cex are required"
285297
+ message: "`action` AND `cex` fields are required"
285257
285298
  }, null);
285258
285299
  }
285259
285300
  const broker = selectBroker(brokers[cex3], metadata) ?? createBroker(cex3, metadata, useVerity, verityProverUrl);
@@ -285263,6 +285304,13 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285263
285304
  message: `This Exchange is not registered and No API metadata ws found`
285264
285305
  }, null);
285265
285306
  }
285307
+ if (useVerity && broker.useVerity) {
285308
+ const redact = metadata.get("verity-t-redacted")?.[0]?.toString() || "";
285309
+ log.info(`Verity Options: Redact`, { redact });
285310
+ broker.addVerityRequestOptions({
285311
+ redact
285312
+ });
285313
+ }
285266
285314
  switch (action) {
285267
285315
  case Action.Deposit: {
285268
285316
  const transactionSchema = import_joi2.default.object({
@@ -285303,6 +285351,12 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285303
285351
  break;
285304
285352
  }
285305
285353
  case Action.FetchDepositAddresses: {
285354
+ if (!symbol) {
285355
+ return callback({
285356
+ code: grpc.status.INVALID_ARGUMENT,
285357
+ message: `ValidationError: Symbol requied`
285358
+ }, null);
285359
+ }
285306
285360
  const fetchDepositAddressesSchema = import_joi2.default.object({
285307
285361
  chain: import_joi2.default.string().required(),
285308
285362
  params: import_joi2.default.object().pattern(import_joi2.default.string(), import_joi2.default.string()).default({})
@@ -285346,6 +285400,12 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285346
285400
  break;
285347
285401
  }
285348
285402
  case Action.Transfer: {
285403
+ if (!symbol) {
285404
+ return callback({
285405
+ code: grpc.status.INVALID_ARGUMENT,
285406
+ message: `ValidationError: Symbol requied`
285407
+ }, null);
285408
+ }
285349
285409
  const transferSchema = import_joi2.default.object({
285350
285410
  recipientAddress: import_joi2.default.string().required(),
285351
285411
  amount: import_joi2.default.number().positive().required(),
@@ -285497,7 +285557,7 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285497
285557
  const balance = await broker.fetchFreeBalance({
285498
285558
  ...call.request.payload ?? {}
285499
285559
  });
285500
- const currencyBalance = balance[symbol];
285560
+ const currencyBalance = symbol ? balance[symbol] : balance;
285501
285561
  callback(null, {
285502
285562
  proof: broker.last_proof || "",
285503
285563
  result: JSON.stringify({
@@ -285531,6 +285591,12 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285531
285591
  }
285532
285592
  break;
285533
285593
  case Action.FetchTicker:
285594
+ if (!symbol) {
285595
+ return callback({
285596
+ code: grpc.status.INVALID_ARGUMENT,
285597
+ message: `ValidationError: Symbol requied`
285598
+ }, null);
285599
+ }
285534
285600
  try {
285535
285601
  const ticker = await broker.fetchTicker(symbol);
285536
285602
  callback(null, {
@@ -285941,7 +286007,7 @@ class CEXBroker {
285941
286007
  }
285942
286008
  }
285943
286009
  if (Object.keys(configMap).length === 0) {
285944
- log.error(`\u274C NO CEX Broker Key Found`);
286010
+ log.warn(`\u274C NO CEX Broker Key Found`);
285945
286011
  }
285946
286012
  for (const [broker, creds] of Object.entries(configMap)) {
285947
286013
  const hasKey = !!creds.apiKey;
@@ -285974,7 +286040,6 @@ class CEXBroker {
285974
286040
  recvWindow: 60000
285975
286041
  }
285976
286042
  });
285977
- exchange.redact_exclusion = "key";
285978
286043
  secondaryBrokers[+index2] = exchange;
285979
286044
  } else {
285980
286045
  log.warn(`\u26A0\uFE0F Incomplete secondary credentials for broker "${broker}" at index ${index2}`);
@@ -286053,7 +286118,6 @@ class CEXBroker {
286053
286118
  recvWindow: 60000
286054
286119
  }
286055
286120
  });
286056
- exchange.redact_exclusion = "key";
286057
286121
  secondaryBroker[+index2] = exchange;
286058
286122
  } else {
286059
286123
  log.warn(`\u26A0\uFE0F Incomplete secondary credentials for broker "${broker}" at index ${index2}`);
@@ -286077,7 +286141,6 @@ class CEXBroker {
286077
286141
  recvWindow: 60000
286078
286142
  }
286079
286143
  });
286080
- client.redact_exclusion = "key";
286081
286144
  this.brokers[broker] = {
286082
286145
  primary: client,
286083
286146
  secondaryBrokers: secondaryBroker
@@ -286146,4 +286209,4 @@ export {
286146
286209
  CEXBroker as default
286147
286210
  };
286148
286211
 
286149
- //# debugId=16AAAD0D4E9C3C9564756E2164756E21
286212
+ //# debugId=B8A4C9180DDADCBA64756E2164756E21