ledger-transport-hid
v0.1.2
Published
Ledger transport for browser using HID
Downloads
13
Readme
Ledger Transport HID
This package provides a alternative to @ledgerhq/hw-transport-webhid
. I would suggest using that package instead unless you are having problems with it.
Main features of this package:
- Smaller bundle size (No dependencies)
- Only using web-natives so no polyfills needed
- Better error recovery
Usage
import { LedgerTransport, StatusCodes } from "ledger-transport-hid";
const [device] = await navigator.hid.requestDevice({
filters: [{ vendorId: 0x2c97 }],
});
const transport = new LedgerTransport(device);
Example methods
// Read the version and name of the currently open app
// Throws an error if no app is open
const response = await transport.send(
0x00,
0x00,
0x00,
0x00,
new Uint8Array(230),
[StatusCodes.OK]
);
const [major, minor, patch, ...appName] = response.data;
const result = {
major,
minor,
patch,
appName: new TextDecoder().decode(new Uint8Array(appName)),
};