How to use the @ledgerhq/hw-transport-mocker.createTransportReplayer function in @ledgerhq/hw-transport-mocker

To help you get started, we’ve selected a few @ledgerhq/hw-transport-mocker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledger-live-common / cli / src / commands / proxy.js View on Github external
if (file) {
      if (record) {
        log("proxy", `the APDUs will be recorded in ${file}`);
        saveToFile = file;
        recordStore = new RecordStore([]);
        Transport = createTransportRecorder(getTransportLike(), recordStore);
      } else {
        recordStore = RecordStore.fromString(fs.readFileSync(file, "utf8"));
        if (recordStore.isEmpty()) {
          process.exit(0);
        }
        log(
          "proxy",
          `${recordStore.queue.length} mocked APDUs will be replayed from ${file}`
        );
        Transport = createTransportReplayer(recordStore);
      }
    } else {
      Transport = getTransportLike();
    }

    const ifaces = os.networkInterfaces();
    const ips = Object.keys(ifaces)
      .reduce(
        (acc, ifname) =>
          acc.concat(
            ifaces[ifname].map(iface => {
              if (iface.family !== "IPv4" || iface.internal !== false) {
                // skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
                return;
              }
              return iface.address;
github LedgerHQ / ledgerjs / packages / hw-http-proxy-devserver / src / cmd.js View on Github external
recordStore = new RecordStore([]);
    Transport = createTransportRecorder(
      require("@ledgerhq/hw-transport-node-hid").default,
      recordStore
    );
  } else {
    recordStore = RecordStore.fromString(
      fs.readFileSync(mainOptions.file, "utf8")
    );
    if (recordStore.isEmpty()) {
      process.exit(0);
    }
    log(
      `${recordStore.queue.length} mocked APDUs will be replayed from ${mainOptions.file}`
    );
    Transport = createTransportReplayer(recordStore);
  }
} else {
  Transport = require("@ledgerhq/hw-transport-node-hid").default;
}

const ifaces = os.networkInterfaces();
export const ips = Object.keys(ifaces)
  .reduce(
    (acc, ifname) =>
      acc.concat(
        ifaces[ifname].map(iface => {
          if ("IPv4" !== iface.family || iface.internal !== false) {
            // skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
            return;
          }
          return iface.address;
github LedgerHQ / ledger-live-common / src / __tests__ / hw / getDeviceInfo.js View on Github external
test("1.6 bootloader", async () => {
  const Transport = createTransportReplayer(
    RecordStore.fromString(`
    => e001000000
    <= 0100000103302e36080030009000
    `)
  );
  const t = await Transport.create();
  const res = await getDeviceInfo(t);
  expect(res).toMatchObject({
    isBootloader: true,
    isOSU: false,
    majMin: "0.6",
    version: "0.6",
    mcuVersion: ""
  });
});
github LedgerHQ / ledger-live-common / src / __tests__ / hw / getLatestFirmwareForDevice.js View on Github external
test("OSU 1.5.5", async () => {
  const Transport = createTransportReplayer(
    RecordStore.fromString(`
    => e001000000
    <= 3110000409312e352e352d6f7375042400000004312e35002000000000000000000000000000000000000000000000000000000000000000009000
    `)
  );
  const t = await Transport.create();
  const deviceInfo = await getDeviceInfo(t);
  const next = await fetchNextFirmware(deviceInfo).toPromise();
  expect(next).toBeDefined();
  expect(next.firmware).toBeTruthy();
});

@ledgerhq/hw-transport-mocker

Ledger Hardware Wallet mocker utilities used for tests

MIT
Latest version published 1 month ago

Package Health Score

90 / 100
Full package analysis