Ledger Hardware Wallet Node implementation of the communication layer, using node-hid and node-usb
npm install @ledgerhq/hw-transport-node-hid-singleton
GitHub,
Ledger Devs Discord,
Developer Portal
Allows to communicate with Ledger Hardware Wallets.
\[Node]/Electron (HID) – uses node-hid and node-usb. Keep transport opened and re-use it as a singleton, one device at a time on a computer but more robust implementation.
*
You may be using this package to open a USB connection between your desktop application and the device.
For a smooth and quick integration:
* See the developers’ documentation on the Developer Portal and
* Go on Discord to chat with developer support and the developer community.
*
#### Table of Contents
* TransportNodeHidSingleton
* Parameters
* Examples
* exchange
* Parameters
* close
* isSupported
* list
* listen
* Parameters
* setDisconnectAfterInactivityTimeout
* disconnect
* open
* Parameters
* onDisconnect
Extends TransportNodeHidNoEvents
node-hid Transport implementation
#### Parameters
* device HID.HID
* $1 {context: TraceContext?} (optional, default {})
* $1.context
#### Examples
``javascript`
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid-singleton";
...
TransportNodeHid.create().then(transport => ...)
#### exchange
Exchanges with the device using APDU protocol
##### Parameters
* apdu Buffer
Returns Promise<Buffer> a promise of apdu response
#### close
Closes the transport instance by triggering a disconnection after some inactivity (no new open).
Intentionally not disconnecting the device/closing the hid connection directly:
The HID connection will only be closed after some inactivity.
Returns Promise\
#### isSupported
#### list
#### listen
##### Parameters
* observer Observer\
Returns Subscription
#### setDisconnectAfterInactivityTimeout
Disconnects device from singleton instance after some inactivity (no new open).
Currently, there is only one transport instance (for only one device connected via USB).
#### disconnect
Disconnects from the HID device associated to the transport singleton.
If you want to try to re-use the same transport instance at the next action (when calling open again), you can useclose
the transport instance method: it will only enable a disconnect after some inactivity.
#### open
Connects to the first Ledger device connected via USB
Reusing the same TransportNodeHidSingleton instance until a disconnection happens.
Pitfall: this implementation only handles 1 device connected via USB
Legacy: _descriptor is needed to follow the Transport definition
##### Parameters
* _descriptor string _timeoutMs
* number? context` TraceContext?
*
Returns Promise<TransportNodeHidSingleton>
Disconnect event received from the transport instance.
It could be after a disconnection coming from the HID library (e.g. device unplugged) or from the transport instance itself (e.g. close).
Clearing the singleton instance.
Currently, only 1 device at a time is supported.