npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@owdin/ledger-libs

v0.0.6

Published

**To communicate with a Ledger device, you first need to identify which transport(s) to use.**

Downloads

15

Readme

We are hiring, join us! 👨‍💻👩‍💻

Ledger Devs Slack License

Welcome to Ledger's JavaScript libraries.

See also:

@ledgerhq/hw-transport-*

To communicate with a Ledger device, you first need to identify which transport(s) to use.

The hw-transport libraries implement communication protocol for our hardware wallet devices (Ledger Nano / Ledger Nano S / Ledger Nano X / Ledger Blue) in many platforms: Web, Node, Electron, React Native,... and using many different communication channels: U2F, HID, WebUSB, Bluetooth,...

| Channels | U2F/WebAuthn | HID | WebUSB | Bluetooth | |----------|--------------|-----|--------|-----------| | Blue | DEPRECATED1 | YES | NO | NO | | Nano S | DEPRECATED1 | YES | YES | NO | | Nano X | DEPRECATED1 | YES | YES | YES |

  1. U2F is deprecated. See https://github.com/LedgerHQ/ledgerjs/blob/master/docs/migrate_webusb.md

Summary of implementations available per platform

| Platforms | U2F/WebAuthn | HID | WebUSB | Bluetooth | |------------------|------------------|-----------------------------------|---------------------|-------------------------------| | Web | @ledgerhq/hw-transport-u2f | @ledgerhq/hw-transport-webhid | @ledgerhq/hw-transport-webusb | @ledgerhq/hw-transport-web-ble | | Electron/Node.js | NO | @ledgerhq/hw-transport-node-hid1 | NO | @ledgerhq/hw-transport-node-ble | | iOS | NO | NO | NO | @ledgerhq/react-native-hw-transport-ble | | Android | @ledgerhq/hw-transport-u2f2 | @ledgerhq/react-native-hid | @ledgerhq/hw-transport-webusb2 | @ledgerhq/react-native-hw-transport-ble |

  1. 3 implementations available
  2. via Android Chrome

Beware the current web support:

| Channels | U2F | WebHID. | WebUSB | WebBluetooth | |----------|-------------------|-----------------|--------------------|--------------| | Windows | DEPRECATED1 | YES | OK BUT2 | YES | | Mac | DEPRECATED1 | YES | YES | YES | | Linux | DEPRECATED1 | YES | YES | YES | | Chrome | DEPRECATED1 | YES3 | YES | YES | | Safari | DEPRECATED1 | NO | NO | NO | | Firefox | DEPRECATED1 | NO | NO | NO | | IE. | DEPRECATED1 | NO | NO | NO |

  1. U2F is deprecated. See https://github.com/LedgerHQ/ledgerjs/blob/master/docs/migrate_webusb.md
  2. instabilities has been reported
  3. WebHID supported under Chrome experimental flags

Please find respective documentation for each transport:

An unified Transport interface

All these transports implement a generic interface exposed by @ledgerhq/hw-transport. There are specifics for each transport which are explained in each package.

A Transport is essentially:

  • Transport.listen: (observer)=>Subscription
  • Transport.open: (descriptor)=>Promise<Transport>
  • transport.exchange(apdu: Buffer): Promise<Buffer>
  • transport.close()

and some derivates:

  • transport.create(): Promise<Transport>: make use of listen and open for the most simple scenario.
  • transport.send(cla, ins, p1, p2, data): Promise<Buffer>: a small abstraction of exchange

NB: APDU is the encoding primitive for all binary exchange with the devices. (it comes from smart card industry)

@ledgerhq/hw-app-*

As soon as your Transport is created, you can already communicate by implementing the apps protocol (refer to application documentations, for instance BTC app and ETH app ones).

We also provide libraries that help implementing the low level exchanges. These higher level APIs are split per app:

Community packages:

We invite all third party app developers to not send PR to this repository to provide more implementations but instead to maintain your own version in your own repository and we would be happy to reference them here ♥.

Other packages

Published Packages

| Package | Version | Description | | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | create-dapp | npm | Ledger DApp Ethereum starter kit | | @ledgerhq/web3-subprovider | npm | web3 subprovider implementation for web3-provider-engine | | Development Tools | | @ledgerhq/hw-transport-mocker | npm | Tool used for test to record and replay APDU calls. |

Basic gist

import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-webusb";
// import Transport from "@ledgerhq/react-native-hw-transport-ble";
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));

Contributing

Please read our contribution guidelines before getting started.

You need to have a recent Node.js and Yarn installed.

Install dependencies

yarn

Build

Build all packages

yarn build

Watch

Watch all packages change. Very useful during development to build only file that changes.

yarn watch

Lint

Lint all packages

yarn lint

Run Tests

First of all, this ensure the libraries are correctly building, and passing lint and flow:

yarn test

then to test on a real device...

Plug a device like the Nano S and open Bitcoin app.

Then run the test and accept the commands on the devices for the tests to continue.

yarn test-node

You can also test on the web:

yarn test-browser

make sure to configure your device app with "Browser support" set to "YES".

Deploy

Checklist before deploying a new release:

  • you have the right in the LedgerHQ org on NPM
  • you have run npm login once (check npm whoami)
  • Go to master branch
    • your master point on LedgerHQ repository (check with git config remote.$(git config branch.master.remote).url and fix it with git branch --set-upstream master origin/master)
    • you are in sync (git pull) and there is no changes in git status
  • Run yarn once, there is still no changes in git status

deploy a new release

 yarn run publish

then, go to /releases and create a release with change logs.

alternatively:

deploy a canary release (beta, etc)

 yarn run publish -c

NB: if there is a new package, AFAIK you need to manually npm publish it once on NPM.

VSCode settings

Here is a example config for a workspace file to handle the monorepo setup.
Just add project.code-workspace to your .vscode folder

{
  "folders": [
    {
      "name": "root",
      "path": "../"
    },
    {
      "name": "cryptoassets",
      "path": "../packages/cryptoassets"
    },
    {
      "name": "devices",
      "path": "../packages/devices"
    },
    {
      "name": "errors",
      "path": "../packages/errors"
    },
    {
      "name": "hw-app-algorand",
      "path": "../packages/hw-app-algorand"
    },
    {
      "name": "hw-app-btc",
      "path": "../packages/hw-app-btc"
    },
    {
      "name": "hw-app-cosmos",
      "path": "../packages/hw-app-cosmos"
    },
    {
      "name": "hw-app-eth",
      "path": "../packages/hw-app-eth"
    },
    {
      "name": "hw-app-polkadot",
      "path": "../packages/hw-app-polkadot"
    },
    {
      "name": "hw-app-str",
      "path": "../packages/hw-app-str"
    },
    {
      "name": "hw-app-tezos",
      "path": "../packages/hw-app-tezos"
    },
    {
      "name": "hw-app-trx",
      "path": "../packages/hw-app-trx"
    },
    {
      "name": "hw-app-xrp",
      "path": "../packages/hw-app-xrp"
    },
    {
      "name": "hw-transport",
      "path": "../packages/hw-transport"
    },
    {
      "name": "hw-transport-http",
      "path": "../packages/hw-transport-http"
    },
    {
      "name": "hw-transport-mocker",
      "path": "../packages/hw-transport-mocker"
    },
    {
      "name": "hw-transport-node-ble",
      "path": "../packages/hw-transport-node-ble"
    },
    {
      "name": "hw-transport-node-hid",
      "path": "../packages/hw-transport-node-hid"
    },
    {
      "name": "hw-transport-node-hid-noevents",
      "path": "../packages/hw-transport-node-hid-noevents"
    },
    {
      "name": "hw-transport-node-hid-singleton",
      "path": "../packages/hw-transport-node-hid-singleton"
    },
    {
      "name": "hw-transport-node-speculos",
      "path": "../packages/hw-transport-node-speculos"
    },
    {
      "name": "hw-transport-web-ble",
      "path": "../packages/hw-transport-web-ble"
    },
    {
      "name": "hw-transport-webhid",
      "path": "../packages/hw-transport-webhid"
    },
    {
      "name": "hw-transport-webusb",
      "path": "../packages/hw-transport-webusb"
    },
    {
      "name": "logs",
      "path": "../packages/logs"
    },
    {
      "name": "react-native-hid",
      "path": "../packages/react-native-hid"
    },
    {
      "name": "react-native-hw-transport-ble",
      "path": "../packages/react-native-hw-transport-ble"
    }
  ],
}