evernode-js-client 0.6.19 → 0.6.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +5 -45
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -53223,7 +53223,6 @@ const { XflHelpers } = __nccwpck_require__(3243);
53223
53223
  const { EvernodeHelpers } = __nccwpck_require__(2523);
53224
53224
  const { StateHelpers } = __nccwpck_require__(3860);
53225
53225
  const { TransactionHelper } = __nccwpck_require__(7071);
53226
- const { UtilHelpers } = __nccwpck_require__(6687);
53227
53226
 
53228
53227
  const OFFER_WAIT_TIMEOUT = 60;
53229
53228
 
@@ -53258,7 +53257,6 @@ const HOST_UPDATE_PARAM_SIZE = 123;
53258
53257
 
53259
53258
  const VOTE_VALIDATION_ERR = "VOTE_VALIDATION_ERR";
53260
53259
 
53261
- const IPV4_FAMILY = 4;
53262
53260
  const IPV6_FAMILY = 6;
53263
53261
 
53264
53262
  class HostClient extends BaseEvernodeClient {
@@ -53343,12 +53341,6 @@ class HostClient extends BaseEvernodeClient {
53343
53341
  */
53344
53342
  async offerLease(leaseIndex, leaseAmount, tosHash, outboundIPAddress = null) {
53345
53343
 
53346
- // If Outbound IP address is not specified resolve the IPV4 address of host using domain.
53347
- if (!outboundIPAddress) {
53348
- const domain = await this.xrplAcc.getDomain();
53349
- outboundIPAddress = await UtilHelpers.resolveIP(domain, { family: 4 });
53350
- }
53351
-
53352
53344
  // <prefix><version tag ("LTV"+uint8)><lease index (uint16)><half of tos hash><lease amount (int64)><identifier (uint32)><ip data>
53353
53345
  // Lengths of sub sections.
53354
53346
  const prefixLen = EvernodeConstants.LEASE_TOKEN_PREFIX_HEX.length / 2;
@@ -53358,7 +53350,7 @@ class HostClient extends BaseEvernodeClient {
53358
53350
  const halfToSLen = tosHash.length / 4;
53359
53351
  const leaseAmountLen = 8;
53360
53352
  const identifierLen = 4;
53361
- const ipDataLen = outboundIPAddress ? 17 : 0; // (Allocating block for considering both IPV6 and IPV4)
53353
+ const ipDataLen = 17;
53362
53354
 
53363
53355
  // Offsets of sub sections
53364
53356
  const versionPrefixOffset = prefixLen;
@@ -53379,7 +53371,7 @@ class HostClient extends BaseEvernodeClient {
53379
53371
  uriBuf.writeBigInt64BE(XflHelpers.getXfl(leaseAmount.toString()), leaseAmountOffset);
53380
53372
  uriBuf.writeUInt32BE((await this.xrplAcc.getSequence()), identifierOffset);
53381
53373
 
53382
- if (ipDataLen > 0) {
53374
+ if (outboundIPAddress) {
53383
53375
  if (outboundIPAddress.includes(":")) {
53384
53376
  uriBuf.writeUInt8(IPV6_FAMILY, ipDataOffset);
53385
53377
  const ipBuf = Buffer.from(outboundIPAddress.split(':').map(v => {
@@ -53392,17 +53384,7 @@ class HostClient extends BaseEvernodeClient {
53392
53384
 
53393
53385
  ipBuf.copy(uriBuf, ipDataOffset + 1, 0, ipDataLen);
53394
53386
  } else {
53395
- uriBuf.writeUInt8(IPV4_FAMILY, ipDataOffset);
53396
-
53397
- const ipBuf = Buffer.from(outboundIPAddress.split('.').map(v => {
53398
- const bytes = [];
53399
- bytes.push(parseInt(v));
53400
- return bytes;
53401
- }).flat());
53402
-
53403
-
53404
- // Last 4 bytes of 17 byte buffer.
53405
- ipBuf.copy(uriBuf, (ipDataOffset + 1) + 12, 0, 4);
53387
+ throw "Invalid outbound IP address was provided";
53406
53388
  }
53407
53389
  }
53408
53390
 
@@ -56263,7 +56245,6 @@ const { XflHelpers } = __nccwpck_require__(3243);
56263
56245
  const { EvernodeConstants } = __nccwpck_require__(9849);
56264
56246
  const { TransactionHelper } = __nccwpck_require__(7071);
56265
56247
  const { EvernodeHelpers } = __nccwpck_require__(2523);
56266
- const dns = __nccwpck_require__(604);
56267
56248
 
56268
56249
  // Utility helper functions.
56269
56250
  class UtilHelpers {
@@ -56299,10 +56280,8 @@ class UtilHelpers {
56299
56280
  halfTos: uriBuf.slice(halfTosHashOffset, halfTosHashOffset + halfToSLen),
56300
56281
  leaseAmount: parseFloat(XflHelpers.toString(uriBuf.readBigInt64BE(leaseAmountOffset))),
56301
56282
  identifier: uriBuf.length > identifierOffset ? uriBuf.readUInt32BE(identifierOffset) : null,
56302
- outboundIP: uriBuf.length > ipDataOffset ?
56303
- (uriBuf.readUint8(ipDataOffset) == 4)
56304
- ? { family: 4, address: uriBuf.slice((ipDataOffset + 13), (ipDataOffset + 13) + ipDataLen).map(b => b.toString()).join('.') }
56305
- : { family: 6, address: uriBuf.slice(ipDataOffset + 1, ipDataOffset + 1 + ipDataLen).toString('hex').toUpperCase().replace(/(.{4})(?!$)/g, "$1:") }
56283
+ outboundIP: (uriBuf.length > ipDataOffset && (uriBuf.readUint8(ipDataOffset) == 6))
56284
+ ? { family: 6, address: uriBuf.slice(ipDataOffset + 1, ipDataOffset + 1 + ipDataLen).toString('hex').toUpperCase().replace(/(.{4})(?!$)/g, "$1:") }
56306
56285
  : null
56307
56286
  }
56308
56287
  }
@@ -56317,17 +56296,6 @@ class UtilHelpers {
56317
56296
  }
56318
56297
  }
56319
56298
 
56320
- static async resolveIP(domain, options) {
56321
- return new Promise((resolve, reject) => {
56322
- dns.lookup(domain, options, (err, address) => {
56323
- if (err) {
56324
- reject(null);
56325
- } else {
56326
- resolve(address);
56327
- }
56328
- });
56329
- });
56330
- }
56331
56299
  }
56332
56300
 
56333
56301
  module.exports = {
@@ -57891,14 +57859,6 @@ module.exports = require("node:crypto");
57891
57859
 
57892
57860
  /***/ }),
57893
57861
 
57894
- /***/ 604:
57895
- /***/ ((module) => {
57896
-
57897
- "use strict";
57898
- module.exports = require("node:dns");
57899
-
57900
- /***/ }),
57901
-
57902
57862
  /***/ 2037:
57903
57863
  /***/ ((module) => {
57904
57864
 
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  ],
7
7
  "homepage": "https://github.com/HotPocketDev/evernode-js-client",
8
8
  "license": "MIT",
9
- "version": "0.6.19",
9
+ "version": "0.6.20",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",