1 |
|
2 |
|
3 | import Transport from "@ledgerhq/hw-transport";
|
4 | import type { Observer, DescriptorEvent, Subscription } from "@ledgerhq/hw-transport";
|
5 | import type { DeviceModel } from "@ledgerhq/devices";
|
6 | import { getLedgerDevices } from "./webusb";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export default class TransportWebUSB extends Transport {
|
15 | device: USBDevice;
|
16 | deviceModel: DeviceModel | null | undefined;
|
17 | channel: number;
|
18 | packetSize: number;
|
19 | interfaceNumber: number;
|
20 | constructor(device: USBDevice, interfaceNumber: number);
|
21 | /**
|
22 | * Check if WebUSB transport is supported.
|
23 | */
|
24 | static isSupported: () => Promise<boolean>;
|
25 | /**
|
26 | * List the WebUSB devices that was previously authorized by the user.
|
27 | */
|
28 | static list: typeof getLedgerDevices;
|
29 | /**
|
30 | * Actively listen to WebUSB devices and emit ONE device
|
31 | * that was either accepted before, if not it will trigger the native permission UI.
|
32 | *
|
33 | * Important: it must be called in the context of a UI click!
|
34 | */
|
35 | static listen: (observer: Observer<DescriptorEvent<USBDevice>>) => Subscription;
|
36 | /**
|
37 | * Similar to create() except it will always display the device permission (even if some devices are already accepted).
|
38 | */
|
39 | static request(): Promise<TransportWebUSB>;
|
40 | /**
|
41 | * Similar to create() except it will never display the device permission (it returns a Promise<?Transport>, null if it fails to find a device).
|
42 | */
|
43 | static openConnected(): Promise<TransportWebUSB | null>;
|
44 | /**
|
45 | * Create a Ledger transport with a USBDevice
|
46 | */
|
47 | static open(device: USBDevice): Promise<TransportWebUSB>;
|
48 | _disconnectEmitted: boolean;
|
49 | _emitDisconnect: (e: Error) => void;
|
50 | /**
|
51 | * Release the transport device
|
52 | */
|
53 | close(): Promise<void>;
|
54 | /**
|
55 | * Exchange with the device using APDU protocol.
|
56 | * @param apdu
|
57 | * @returns a promise of apdu response
|
58 | */
|
59 | exchange(apdu: Buffer): Promise<Buffer>;
|
60 | setScrambleKey(): void;
|
61 | }
|
62 | //# sourceMappingURL=TransportWebUSB.d.ts.map |
\ | No newline at end of file |