@ledgerhq/hw-transport-webusb
Ledger Hardware Wallet WebUSB implementation of the communication layer
Last updated a day ago by gre .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @ledgerhq/hw-transport-webusb 
SYNC missed versions from official npm registry.

Github, Ledger Devs Slack

@ledgerhq/hw-transport-webusb

Allows to communicate with Ledger Hardware Wallets.

[Web] (WebUSB) – WebUSB check browser support.

FAQ: "DOM Exception" is triggered when creating the transport

The transport functions create() and listen() must be called in the context of an user interaction (like a "click" event), otherwise it fails with DOM Exception. This is by WebUSB design. You also must run on HTTPS.

How to use this transport regarding WebUSB paradigm?

In WebUSB, we have a "permission native" modal that appears when we need to "request" a device. This is required at-least-once for the user to accept, and then we can open the transport without triggering this modal. However, in both cases, it must happen in context of a click like explain above. Our current implementation tradeoff is to abstract this out and only trigger the permission modal if no device are listed. This might change in the future.

In term of UX, there are two classical usecases:

  1. you only need the device at key times, like once to get the address. once to sign a transaction,...
  2. your app lifecycle requires that you need to access the device at the beginning and/or at any time (like you want to ping with getAddress to get the wallet address)

in (1) case, you can just do your logic in each button (Get Address / Sign Transaction) time (create it, do the logic, close it). in (2) case, you will need to have a Connect button that appear when you don’t have the connection yet. and you need to hook to the “disconnect” event to potentially make the UI reflect that and require user to click again on that Connect button, because you can’t automatically create()/open() again.

Support status

WebUSB is currently only supported on Google Chrome / Chromium.

API

Table of Contents

TransportWebUSB

Extends Transport

WebUSB Transport implementation

Parameters

  • device USBDevice
  • interfaceNumber number

Examples

import TransportWebUSB from "@ledgerhq/hw-transport-webusb";
...
TransportWebUSB.create().then(transport => ...)

close

Release the transport device

Returns Promise<void>

exchange

Exchange with the device using APDU protocol.

Parameters

Returns Promise<Buffer> a promise of apdu response

isSupported

Check if WebUSB transport is supported.

list

List the WebUSB devices that was previously authorized by the user.

listen

Actively listen to WebUSB devices and emit ONE device that was either accepted before, if not it will trigger the native permission UI.

Important: it must be called in the context of a UI click!

Parameters
  • observer Observer<DescriptorEvent<USBDevice>>

Returns Subscription

request

Similar to create() except it will always display the device permission (even if some devices are already accepted).

openConnected

Similar to create() except it will never display the device permission (it returns a Promise<?Transport>, null if it fails to find a device).

open

Create a Ledger transport with a USBDevice

Parameters
  • device USBDevice

Current Tags

  • 5.1.1-alpha.2                                ...           canary (9 months ago)
  • 5.25.0                                ...           latest (a day ago)

95 Versions

  • 5.25.0                                ...           a day ago
  • 5.23.0                                ...           19 days ago
  • 5.22.0                                ...           2 months ago
  • 5.21.0                                ...           2 months ago
  • 5.19.1                                ...           2 months ago
  • 5.19.0                                ...           3 months ago
  • 5.17.0                                ...           3 months ago
  • 5.16.0                                ...           4 months ago
  • 5.15.0                                ...           5 months ago
  • 5.13.1                                ...           5 months ago
  • 5.13.0                                ...           6 months ago
  • 5.12.0                                ...           6 months ago
  • 5.11.0                                ...           7 months ago
  • 5.9.0                                ...           7 months ago
  • 5.8.0                                ...           8 months ago
  • 5.7.0                                ...           8 months ago
  • 5.6.0                                ...           8 months ago
  • 5.5.0                                ...           8 months ago
  • 5.3.0                                ...           9 months ago
  • 5.2.0                                ...           9 months ago
  • 5.1.1-alpha.2                                ...           9 months ago
  • 5.0.0                                ...           9 months ago
  • 5.0.0-rc.4                                ...           9 months ago
  • 5.0.0-babel7.4                                ...           10 months ago
  • 4.78.0                                ...           10 months ago
  • 5.0.0-babel7.3                                ...           10 months ago
  • 5.0.0-babel7.1                                ...           10 months ago
  • 4.77.0                                ...           10 months ago
  • 5.0.0-alpha.7                                ...           10 months ago
  • 4.74.3-alpha.6                                ...           10 months ago
  • 5.0.0-alpha.5                                ...           10 months ago
  • 5.0.0-alpha.4                                ...           10 months ago
  • 5.0.0-alpha.3                                ...           10 months ago
  • 4.74.2                                ...           10 months ago
  • 4.74.1                                ...           10 months ago
  • 4.74.0                                ...           10 months ago
  • 4.73.7                                ...           10 months ago
  • 4.73.5                                ...           a year ago
  • 4.73.4                                ...           a year ago
  • 4.73.3                                ...           a year ago
  • 4.73.2                                ...           a year ago
  • 4.73.1                                ...           a year ago
  • 4.72.2                                ...           a year ago
  • 4.72.1                                ...           a year ago
  • 4.72.0                                ...           a year ago
  • 4.71.0                                ...           a year ago
  • 4.70.1-alpha.4                                ...           a year ago
  • 4.70.3                                ...           a year ago
  • 4.70.2                                ...           a year ago
  • 4.70.0                                ...           a year ago
  • 4.69.0                                ...           a year ago
  • 4.68.4                                ...           a year ago
  • 4.68.2                                ...           a year ago
  • 4.68.0                                ...           a year ago
  • 4.66.0                                ...           a year ago
  • 4.64.1                                ...           a year ago
  • 4.64.0                                ...           a year ago
  • 4.63.2                                ...           a year ago
  • 4.63.1                                ...           a year ago
  • 4.62.0                                ...           a year ago
  • 4.61.0                                ...           a year ago
  • 4.60.3                                ...           a year ago
  • 4.60.2                                ...           a year ago
  • 4.60.0                                ...           a year ago
  • 4.59.1-alpha.2                                ...           a year ago
  • 4.58.0                                ...           a year ago
  • 4.57.0                                ...           a year ago
  • 4.56.0                                ...           a year ago
  • 4.55.1-alpha.2                                ...           a year ago
  • 4.55.0                                ...           a year ago
  • 4.54.0                                ...           a year ago
  • 4.53.0                                ...           a year ago
  • 4.52.0                                ...           a year ago
  • 4.50.0                                ...           a year ago
  • 4.48.0                                ...           2 years ago
  • 4.47.0                                ...           2 years ago
  • 4.46.0                                ...           2 years ago
  • 4.45.0                                ...           2 years ago
  • 4.44.2                                ...           2 years ago
  • 4.44.1                                ...           2 years ago
  • 4.44.0                                ...           2 years ago
  • 4.43.1-alpha.0                                ...           2 years ago
  • 4.43.0                                ...           2 years ago
  • 4.41.1                                ...           2 years ago
  • 4.39.0                                ...           2 years ago
  • 4.38.6                                ...           2 years ago
  • 4.38.0                                ...           2 years ago
  • 4.36.2                                ...           2 years ago
  • 4.37.0                                ...           2 years ago
  • 4.35.1-beta.28                                ...           2 years ago
  • 4.37.0-beta.2b8718d2                                ...           2 years ago
  • 4.35.0                                ...           2 years ago
  • 4.33.4                                ...           2 years ago
  • 4.32.0                                ...           2 years ago
  • 0.0.0                                ...           3 years ago
Downloads
Today 3
This Week 38
This Month 169
Last Day 9
Last Week 37
Last Month 171
Dependencies (4)
Dev Dependencies (1)

Copyright 2014 - 2017 © taobao.org |