@choppu/shelljs-web-hid
v1.0.1
Published
Keycard Shell WebHID implementation of the communication layer
Readme
ShellJS Web HID
ShellJS Web HID is an implementation of the communication layer.
Installation
npm install @choppu/shelljs-web-hidUsage example
import TransportWebHID from "shelljs-web-hid";
...
let transport: any;
transport = await TransportWebHID.create();
...Live Demo
You can check a demo at Shell Web HID Example Page.
Support status
WebUSB is currently only supported on Google Chrome / Chromium DEV version and by explicitly enabling chrome://flags/#enable-experimental-web-platform-features
API
Table of Contents
TransportWebHID
Extends Transport
WebHID Transport implementation
Parameters
deviceHIDDevice
close
Release the transport device
Returns Promise<void>
exchange
Exchange with the device using APDU protocol.
Parameters
apduBuffer
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
observerObserver<DescriptorEvent<HIDDevice>>
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 Shell transport with a HIDDevice
Parameters
deviceHIDDevice
