@ledgerhq/hw-http-proxy-devserver

5.0.0 • Public • Published

@ledgerhq/hw-http-proxy-devserver

Proxy a Ledger device plugged in USB over HTTP / WebSocket.

  • Plug your Ledger device on your computer
  • Run a HTTP server with the ledger-hw-http-proxy-devserver command
  • Use @ledgerhq/hw-transport-http in your code like a normal transport so you can run Legder device APDU over http.

Goal: This library is meant for DEV & testing purpose only. It is not designed to be used in PROD.

Setup

Install with one of these:

npm i -g @ledgerhq/hw-http-proxy-devserver
yarn global add @ledgerhq/hw-http-proxy-devserver

Run the server

In a console, simply run:

ledger-hw-http-proxy-devserver

hw-transport-http to communicate with the server

To communicate with this server, there is a dedicated Transport library. You can use it like any other Ledger transport like hw-transport-node-hid, hw-transport-u2f, ...

import withStaticURL from "@ledgerhq/hw-transport-http";

// you can change localhost to a local IP (e.g. to use from a Phone)
const Transport = withStaticURL("ws://localhost:8435");

// ... normal @ledgerhq/* code

import AppBtc from "@ledgerhq/hw-app-btc";
const getBtcAddress = async () => {
  const transport = await Transport.create();
  const btc = new AppBtc(transport);
  const result = await btc.getWalletPublicKey("44'/0'/0'/0/0");
  return result.bitcoinAddress;
};
getBtcAddress().then(a => console.log(a));

More information

Github, Ledger Devs Slack

Package Sidebar

Install

npm i @ledgerhq/hw-http-proxy-devserver

Weekly Downloads

112

Version

5.0.0

License

Apache-2.0

Unpacked Size

49.5 kB

Total Files

9

Last publish

Collaborators

  • thomas.coudray
  • ldg-github-ci
  • aboissiere
  • vbouzon
  • gbrahm-ledger
  • sergii-shkolin
  • phenry-ledger