@usherlabs/cex-broker 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -289986,7 +289986,9 @@ var log = new Logger({
289986
289986
  // src/helpers/index.ts
289987
289987
  function authenticateRequest(call, whitelistIps) {
289988
289988
  const clientIp = call.getPeer().split(":")[0];
289989
- if (!clientIp || !whitelistIps.includes(clientIp)) {
289989
+ if (whitelistIps.includes("*")) {
289990
+ return true;
289991
+ } else if (!clientIp || !whitelistIps.includes(clientIp)) {
289990
289992
  log.warn(`Blocked access from unauthorized IP: ${clientIp || "unknown"}`);
289991
289993
  return false;
289992
289994
  }
@@ -290234,7 +290236,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290234
290236
  if (deposit) {
290235
290237
  log.info(`Amount ${value.amount} at ${value.transactionHash} . Paid to ${value.recipientAddress}`);
290236
290238
  return callback(null, {
290237
- result: useVerity ? broker.last_proof : JSON.stringify({ ...deposit })
290239
+ proof: broker.last_proof || "",
290240
+ result: JSON.stringify({ ...deposit })
290238
290241
  });
290239
290242
  }
290240
290243
  callback({
@@ -290275,7 +290278,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290275
290278
  });
290276
290279
  if (depositAddresses) {
290277
290280
  return callback(null, {
290278
- result: useVerity ? broker.last_proof : JSON.stringify({ ...depositAddresses })
290281
+ proof: broker.last_proof || "",
290282
+ result: JSON.stringify({ ...depositAddresses })
290279
290283
  });
290280
290284
  }
290281
290285
  callback({
@@ -290325,7 +290329,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290325
290329
  const transaction = await broker.withdraw(symbol, Number(transferValue.amount), transferValue.recipientAddress, undefined, { network: transferValue.chain });
290326
290330
  log.info(`Transfer Transfer: ${JSON.stringify(transaction)}`);
290327
290331
  callback(null, {
290328
- result: useVerity ? broker.last_proof : JSON.stringify({ ...transaction })
290332
+ proof: broker.last_proof || "",
290333
+ result: JSON.stringify({ ...transaction })
290329
290334
  });
290330
290335
  } catch (error) {
290331
290336
  log.error({ error });
@@ -290445,7 +290450,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290445
290450
  });
290446
290451
  const currencyBalance = balance[symbol];
290447
290452
  callback(null, {
290448
- result: useVerity ? broker.last_proof : JSON.stringify({
290453
+ proof: broker.last_proof || "",
290454
+ result: JSON.stringify({
290449
290455
  balance: currencyBalance || 0,
290450
290456
  currency: symbol
290451
290457
  })
@@ -290464,7 +290470,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290464
290470
  ...call.request.payload ?? {}
290465
290471
  });
290466
290472
  callback(null, {
290467
- result: useVerity ? broker.last_proof : JSON.stringify(balance)
290473
+ proof: broker.last_proof || "",
290474
+ result: JSON.stringify(balance)
290468
290475
  });
290469
290476
  } catch (error) {
290470
290477
  log.error(`Error fetching balance from ${cex3}:`, error);
@@ -290482,7 +290489,6 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290482
290489
  }
290483
290490
  },
290484
290491
  Subscribe: async (call) => {
290485
- const request = call.request;
290486
290492
  if (!authenticateRequest(call, whitelistIps)) {
290487
290493
  call.emit("error", {
290488
290494
  code: grpc.status.PERMISSION_DENIED,
@@ -290493,12 +290499,12 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
290493
290499
  const metadata = call.metadata;
290494
290500
  let broker = null;
290495
290501
  try {
290496
- const request2 = call.request;
290497
- const { cex: cex3, symbol, type: type2, options } = request2;
290502
+ const request = call.request;
290503
+ const { cex: cex3, symbol, type: type2, options } = request;
290498
290504
  const subscriptionType = type2 !== undefined ? type2 : SubscriptionType.ORDERBOOK;
290499
290505
  log.info(`Request - Subscribe: ${JSON.stringify({
290500
- cex: request2.cex,
290501
- symbol: request2.symbol,
290506
+ cex: request.cex,
290507
+ symbol: request.symbol,
290502
290508
  type: subscriptionType
290503
290509
  })}`);
290504
290510
  if (!cex3 || !symbol) {
package/dist/index.js CHANGED
@@ -285033,7 +285033,9 @@ var log = new Logger({
285033
285033
  // src/helpers/index.ts
285034
285034
  function authenticateRequest(call, whitelistIps) {
285035
285035
  const clientIp = call.getPeer().split(":")[0];
285036
- if (!clientIp || !whitelistIps.includes(clientIp)) {
285036
+ if (whitelistIps.includes("*")) {
285037
+ return true;
285038
+ } else if (!clientIp || !whitelistIps.includes(clientIp)) {
285037
285039
  log.warn(`Blocked access from unauthorized IP: ${clientIp || "unknown"}`);
285038
285040
  return false;
285039
285041
  }
@@ -285281,7 +285283,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285281
285283
  if (deposit) {
285282
285284
  log.info(`Amount ${value.amount} at ${value.transactionHash} . Paid to ${value.recipientAddress}`);
285283
285285
  return callback(null, {
285284
- result: useVerity ? broker.last_proof : JSON.stringify({ ...deposit })
285286
+ proof: broker.last_proof || "",
285287
+ result: JSON.stringify({ ...deposit })
285285
285288
  });
285286
285289
  }
285287
285290
  callback({
@@ -285322,7 +285325,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285322
285325
  });
285323
285326
  if (depositAddresses) {
285324
285327
  return callback(null, {
285325
- result: useVerity ? broker.last_proof : JSON.stringify({ ...depositAddresses })
285328
+ proof: broker.last_proof || "",
285329
+ result: JSON.stringify({ ...depositAddresses })
285326
285330
  });
285327
285331
  }
285328
285332
  callback({
@@ -285372,7 +285376,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285372
285376
  const transaction = await broker.withdraw(symbol, Number(transferValue.amount), transferValue.recipientAddress, undefined, { network: transferValue.chain });
285373
285377
  log.info(`Transfer Transfer: ${JSON.stringify(transaction)}`);
285374
285378
  callback(null, {
285375
- result: useVerity ? broker.last_proof : JSON.stringify({ ...transaction })
285379
+ proof: broker.last_proof || "",
285380
+ result: JSON.stringify({ ...transaction })
285376
285381
  });
285377
285382
  } catch (error) {
285378
285383
  log.error({ error });
@@ -285492,7 +285497,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285492
285497
  });
285493
285498
  const currencyBalance = balance[symbol];
285494
285499
  callback(null, {
285495
- result: useVerity ? broker.last_proof : JSON.stringify({
285500
+ proof: broker.last_proof || "",
285501
+ result: JSON.stringify({
285496
285502
  balance: currencyBalance || 0,
285497
285503
  currency: symbol
285498
285504
  })
@@ -285511,7 +285517,8 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285511
285517
  ...call.request.payload ?? {}
285512
285518
  });
285513
285519
  callback(null, {
285514
- result: useVerity ? broker.last_proof : JSON.stringify(balance)
285520
+ proof: broker.last_proof || "",
285521
+ result: JSON.stringify(balance)
285515
285522
  });
285516
285523
  } catch (error) {
285517
285524
  log.error(`Error fetching balance from ${cex3}:`, error);
@@ -285529,7 +285536,6 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285529
285536
  }
285530
285537
  },
285531
285538
  Subscribe: async (call) => {
285532
- const request = call.request;
285533
285539
  if (!authenticateRequest(call, whitelistIps)) {
285534
285540
  call.emit("error", {
285535
285541
  code: grpc.status.PERMISSION_DENIED,
@@ -285540,12 +285546,12 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
285540
285546
  const metadata = call.metadata;
285541
285547
  let broker = null;
285542
285548
  try {
285543
- const request2 = call.request;
285544
- const { cex: cex3, symbol, type: type2, options } = request2;
285549
+ const request = call.request;
285550
+ const { cex: cex3, symbol, type: type2, options } = request;
285545
285551
  const subscriptionType = type2 !== undefined ? type2 : SubscriptionType.ORDERBOOK;
285546
285552
  log.info(`Request - Subscribe: ${JSON.stringify({
285547
- cex: request2.cex,
285548
- symbol: request2.symbol,
285553
+ cex: request.cex,
285554
+ symbol: request.symbol,
285549
285555
  type: subscriptionType
285550
285556
  })}`);
285551
285557
  if (!cex3 || !symbol) {
@@ -286119,4 +286125,4 @@ export {
286119
286125
  CEXBroker as default
286120
286126
  };
286121
286127
 
286122
- //# debugId=653E3F4FDCC17C0364756E2164756E21
286128
+ //# debugId=DE92A15E05E8EF9F64756E2164756E21