@ledgerhq/hw-transport-node-hid-noevents
v6.36.0
Published
Ledger Hardware Wallet Node implementation of the communication layer, using node-hid. without usb events
Downloads
374,939
Readme
GitHub, Ledger Devs Discord, Developer Portal
@ledgerhq/hw-transport-node-hid-noevents
Allows to communicate with Ledger Hardware Wallets.
[Node]/Electron (HID) – uses only node-hid. Does not provide USB events.
API
Table of Contents
createHIDframing
Object to handle HID frames (encoding and decoding)
Parameters
makeBlocks
Frames/encodes an APDU message into HID USB packets/frames
Parameters
apduBuffer The APDU message to send, in a Buffer containing [cla, ins, p1, p2, data length, data(if not empty)]
Returns Array<Uint8Array<ArrayBuffer>> an array of HID USB frames ready to be sent
reduceResponse
Reduces HID USB packets/frames to one response.
Parameters
accResponseAcc The value resulting from (accumulating) the previous call of reduceResponse. On first call initialized toinitialAcc. The accumulator enables handling multi-frames messages.chunkBuffer Current chunk to reduce into accumulator
Returns ResponseAcc An accumulator value updated with the current chunk
getReducedResult
Returns the response message that has been reduced from the HID USB frames
Parameters
accResponseAcc The accumulator
Returns (Buffer | null | undefined) A Buffer containing the cleaned response message, or null if no response message, or undefined if the accumulator is incorrect (message length is not valid)
TransportNodeHidNoEvents
Extends Transport
node-hid Transport minimal implementation
Parameters
deviceHID.HID$1{context: TraceContext?, logType: LogType?} (optional, default{})$1.context$1.logType
Examples
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid-noevents";
...
TransportNodeHid.create().then(transport => ...)exchange
Exchange with the device using APDU protocol.
Parameters
apduBuffer
Returns Promise<Buffer> a promise of apdu response
close
release the USB device.
Returns Promise<void>
isSupported
list
Returns Promise<any>
listen
Parameters
observerObserver<DescriptorEvent<any>>
Returns Subscription
open
if path="" is not provided, the library will take the first device
