Ledgerjs
⛔️ MOVED to monorepo "ledger-live"
Install / Use
/learn @LedgerHQ/LedgerjsREADME
⛔️ DEPRECATED
This repository is now deprecated. We moved to a new mono repository architecture containing all of Ledger Live JavaScript Ecosystem that you can find here. You can follow the migration guide to help you make the transition.
We are hiring, join us! 👨💻👩💻
<img src="https://user-images.githubusercontent.com/3273751/151214602-f5153588-1911-4456-ae65-604d56821b36.png" height="80" /> <img src="https://user-images.githubusercontent.com/211411/52533081-e679d380-2d2e-11e9-9c5e-571e4ad0107b.png" height="80" />
Welcome to Ledger's JavaScript libraries.
See also:
- Changelog
- LedgerJS examples
- Ledger Live Desktop
- Ledger Live Mobile
- live-common
- Deprecated libraries are archived in https://github.com/LedgerHQ/ledgerjs-legacy
@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 | DEPRECATED<sup>1</sup> | YES | NO | NO | | Nano S | DEPRECATED<sup>1</sup> | YES | YES | NO | | Nano X | DEPRECATED<sup>1</sup> | YES | YES | YES |
- 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-hid<sup>1</sup> | NO | @ledgerhq/hw-transport-node-ble |
| iOS | NO | NO | NO | @ledgerhq/react-native-hw-transport-ble |
| Android | @ledgerhq/hw-transport-u2f<sup>2</sup> | @ledgerhq/react-native-hid | @ledgerhq/hw-transport-webusb<sup>2</sup> | @ledgerhq/react-native-hw-transport-ble |
- 3 implementations available
- via Android Chrome
Beware the current web support:
| Channels | U2F | WebHID. | WebUSB | WebBluetooth | |----------|-------------------|-----------------|--------------------|--------------| | Windows | DEPRECATED<sup>1</sup> | YES | OK BUT<sup>2</sup> | YES | | Mac | DEPRECATED<sup>1</sup> | YES | YES | YES | | Linux | DEPRECATED<sup>1</sup> | YES | YES | YES | | Chrome | DEPRECATED<sup>1</sup> | YES<sup>3</sup> | YES | YES | | Safari | DEPRECATED<sup>1</sup> | NO | NO | NO | | Firefox | DEPRECATED<sup>1</sup> | NO | NO | NO | | IE. | DEPRECATED<sup>1</sup> | NO | NO | NO |
- U2F is deprecated. See https://github.com/LedgerHQ/ledgerjs/blob/master/docs/migrate_webusb.md
- instabilities has been reported
- WebHID supported under Chrome experimental flags
Please find respective documentation for each transport:
@ledgerhq/hw-transport-u2f [Web] (U2F) (legacy but reliable) – FIDO U2F api. check browser support.
@ledgerhq/hw-transport-webauthn [Web] (WebAuthn) (experimental) – WebAuthn api. check browser support.
@ledgerhq/hw-transport-webusb [Web] (WebUSB) – WebUSB check browser support.
@ledgerhq/hw-transport-webhid [Web] (WebHID) – WebHID check browser support.
@ledgerhq/hw-transport-web-ble [Web] (Bluetooth) – check browser support.
@ledgerhq/hw-transport-node-hid [Node]/Electron (HID) – historical implementation – uses
node-hidandusb.@ledgerhq/hw-transport-node-hid-noevents [Node]/Electron (HID) – uses only
node-hid. Does not provide USB events.@ledgerhq/hw-transport-node-hid-singleton [Node]/Electron (HID) – uses
node-hidandusb-detection. Focus on supporting one device at a time (potentially will have more robust events and less blocking cases)@ledgerhq/hw-transport-node-ble [Node]/Electron (BLE) (experimental) – uses
@abandonware/noble.@ledgerhq/react-native-hw-transport-ble [React Native] (Bluetooth) – uses
react-native-ble-plx@ledgerhq/react-native-hid [React Native] (HID) Android – Ledger's native implementation
@ledgerhq/hw-transport-http [DEV only] universal HTTP channel. NOT for PROD.
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)=>SubscriptionTransport.open: (descriptor)=>Promise<Transport>transport.exchange(apdu: Buffer): Promise<Buffer>transport.close()
and some derivates:
transport.create(): Promise<Transport>: make use oflistenandopenfor the most simple scenario.transport.send(cla, ins, p1, p2, data): Promise<Buffer>: a small abstraction ofexchange
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:
@ledgerhq/hw-app-eth: Ethereum Application API
@ledgerhq/hw-app-btc: Bitcoin Application API
- [
](https://www.npmjs.com/package/@ledgerhq/hw-app-xr
