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

@ledgerhq/hw-transport-node-hid-singleton

v6.31.5

Published

Ledger Hardware Wallet Node implementation of the communication layer, using node-hid and node-usb

Downloads

3,595

Readme

GitHub, Ledger Devs Discord, Developer Portal

@ledgerhq/hw-transport-node-hid-singleton

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.


Are you adding Ledger support to your software wallet?

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.

API

Table of Contents

TransportNodeHidSingleton

Extends TransportNodeHidNoEvents

node-hid Transport implementation

Parameters

  • device HID.HID

  • $1 {context: TraceContext?} (optional, default {})

    • $1.context

Examples

import TransportNodeHid from "@ledgerhq/hw-transport-node-hid-singleton";
...
TransportNodeHid.create().then(transport => ...)

exchange

Exchanges with the device using APDU protocol

Parameters

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<void>

isSupported

list

listen

Parameters
  • observer Observer<ListenDescriptorEvent>

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 use the transport instance close 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>

onDisconnect

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.