import type EventEmitter from 'events'; export type OneKeyDeviceCommType = | 'usb' | 'webusb' | 'ble' | 'webble' | 'electron-ble' | 'bridge' | 'emulator'; export type OneKeyUsbDeviceInfo = { path: string; }; export type OneKeyDeviceInfoWithSession = OneKeyUsbDeviceInfo & { session?: string | null; debugSession?: string | null; debug: boolean; }; export type OneKeyMobileDeviceInfo = { id: string; name: string | null; }; export type OneKeyDeviceInfoBase = { commType: OneKeyDeviceCommType; }; // TODO: sorting type by communication type export type OneKeyDeviceInfo = OneKeyDeviceInfoBase & OneKeyDeviceInfoWithSession & OneKeyMobileDeviceInfo; export type AcquireInput = { path?: string; previous?: string | null; uuid?: string; forceCleanRunPromise?: boolean; }; export type MessageFromOneKey = { type: string; message: Record }; type ITransportInitFn = ( logger?: any, emitter?: EventEmitter, plugin?: LowlevelTransportSharedPlugin ) => Promise; export type Transport = { enumerate(): Promise>; listen(old?: Array): Promise>; acquire(input: AcquireInput): Promise; release(session: string, onclose: boolean): Promise; configure(signedData: JSON | string): Promise; call(session: string, name: string, data: Record): Promise; post(session: string, name: string, data: Record): Promise; read(session: string): Promise; cancel(): Promise; // reset the session of the transport // used to reset the session of the transport when the session is not valid disconnect?: (session: string) => Promise; // web-usb, web-bluetooth request device promptDeviceAccess?: () => Promise; // resolves when the transport can be used; rejects when it cannot init: ITransportInitFn; stop(): void; configured: boolean; version: string; name: string; activeName?: string; isOutdated: boolean; }; export type LowLevelDevice = OneKeyDeviceInfoBase & { id: string; name: string }; export type LowlevelTransportSharedPlugin = { enumerate: () => Promise; send: (uuid: string, data: string) => Promise; receive: () => Promise; connect: (uuid: string) => Promise; disconnect: (uuid: string) => Promise; init: () => Promise; version: string; };