@onekeyfe/hwk-trezor-connector-rn-ble 1.1.27-alpha.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,119 @@
1
+ import { TrezorConnectorBase, TrezorConnectorBaseOptions, TrezorConnectorByteTransport } from '@onekeyfe/hwk-trezor-connector';
2
+ import { ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
3
+ import { TrezorBleTransport, TrezorBleDescriptor, TrezorConnectedDevice, TrezorBleTransportFactory } from '@onekeyfe/hwk-trezor-adapter/rn';
4
+
5
+ type BlePlxDevice = {
6
+ id: string;
7
+ name?: string | null;
8
+ localName?: string | null;
9
+ serviceUUIDs?: string[] | null;
10
+ manufacturerData?: string | null;
11
+ rssi?: number | null;
12
+ mtu?: number;
13
+ isConnected?(): Promise<boolean>;
14
+ connect(): Promise<BlePlxDevice>;
15
+ connect(options?: Record<string, unknown>): Promise<BlePlxDevice>;
16
+ cancelConnection(): Promise<BlePlxDevice>;
17
+ discoverAllServicesAndCharacteristics(): Promise<BlePlxDevice | void>;
18
+ characteristicsForService?(serviceUUID: string): Promise<BlePlxCharacteristic[]>;
19
+ requestMTU?(mtu: number): Promise<BlePlxDevice>;
20
+ };
21
+ type BlePlxCharacteristic = {
22
+ uuid?: string;
23
+ deviceID?: string;
24
+ value?: string | null;
25
+ writeWithResponse?(valueBase64: string): Promise<unknown>;
26
+ writeWithoutResponse?(valueBase64: string): Promise<unknown>;
27
+ monitor?(listener: (error: unknown, characteristic: BlePlxCharacteristic | null) => void): BlePlxSubscription;
28
+ };
29
+ type BlePlxSubscription = {
30
+ remove(): void;
31
+ };
32
+ type BlePlxManager = {
33
+ startDeviceScan(serviceUUIDs: string[] | null, options: Record<string, unknown> | null, listener: (error: unknown, scannedDevice: BlePlxDevice | null) => void): void;
34
+ stopDeviceScan(): void;
35
+ devices?(deviceIdentifiers: string[]): Promise<BlePlxDevice[]>;
36
+ connectedDevices?(serviceUUIDs: string[]): Promise<BlePlxDevice[]>;
37
+ connectToDevice(id: string, options?: Record<string, unknown>): Promise<BlePlxDevice>;
38
+ cancelDeviceConnection(id: string): Promise<BlePlxDevice>;
39
+ writeCharacteristicWithResponseForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, valueBase64: string, transactionId?: string): Promise<unknown>;
40
+ writeCharacteristicWithoutResponseForDevice?(deviceId: string, serviceUUID: string, characteristicUUID: string, valueBase64: string, transactionId?: string): Promise<unknown>;
41
+ monitorCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, listener: (error: unknown, characteristic: BlePlxCharacteristic | null) => void, transactionId?: string): BlePlxSubscription;
42
+ onDeviceDisconnected?(deviceId: string, listener: (error: unknown, device: BlePlxDevice | null) => void): BlePlxSubscription;
43
+ cancelTransaction?(transactionId: string): Promise<void>;
44
+ setLogLevel?(logLevel: string): Promise<string | void>;
45
+ logLevel?(): Promise<string>;
46
+ destroy(): void;
47
+ };
48
+ interface RNBlePlxTrezorTransportOptions {
49
+ manager?: BlePlxManager;
50
+ scanTimeoutMs?: number;
51
+ connectTimeoutMs?: number;
52
+ logger?: (entry: {
53
+ level: 'debug' | 'info' | 'warn' | 'error';
54
+ scope: string;
55
+ event: string;
56
+ data?: Record<string, unknown>;
57
+ }) => void;
58
+ }
59
+ declare class RNBlePlxTrezorTransport implements TrezorBleTransport {
60
+ private readonly _manager;
61
+ private readonly _scanTimeoutMs;
62
+ private readonly _connectTimeoutMs;
63
+ private readonly _logger?;
64
+ private readonly _connectedDevices;
65
+ private readonly _notifySubscriptions;
66
+ private readonly _disconnectSubscriptions;
67
+ private readonly _closingDevices;
68
+ private readonly _disconnectHandlers;
69
+ private readonly _pendingNotifications;
70
+ private readonly _pendingReaders;
71
+ constructor(options: RNBlePlxTrezorTransportOptions & {
72
+ manager: BlePlxManager;
73
+ });
74
+ static create(options?: RNBlePlxTrezorTransportOptions): Promise<RNBlePlxTrezorTransport>;
75
+ scan(): Promise<TrezorBleDescriptor[]>;
76
+ connect(connectId: string): Promise<TrezorConnectedDevice>;
77
+ disconnect(connectId: string): Promise<void>;
78
+ write(connectId: string, data: Uint8Array): Promise<void>;
79
+ read(connectId: string, timeoutMs?: number): Promise<Uint8Array>;
80
+ exchange(connectId: string, data: Uint8Array, timeoutMs?: number): Promise<Uint8Array>;
81
+ onDisconnect(connectId: string, handler: () => void): () => void;
82
+ reset(): void;
83
+ private _deviceToDescriptor;
84
+ private _ensureConnected;
85
+ private _enableNativeBleLogs;
86
+ private _connectWithMtu;
87
+ private _discoverAndTestCharacteristics;
88
+ private _getCharacteristics;
89
+ private _pairingProbe;
90
+ private _writeChunk;
91
+ private _startNotifications;
92
+ private _startCharacteristicMonitor;
93
+ private _startDisconnectWatcher;
94
+ private _pushNotification;
95
+ private _rejectReaders;
96
+ private _transactionId;
97
+ private _log;
98
+ }
99
+ declare function createRNBlePlxTrezorTransport(options?: RNBlePlxTrezorTransportOptions): Promise<TrezorBleTransport>;
100
+
101
+ interface TrezorRnBleConnectorOptions {
102
+ transportFactory?: TrezorBleTransportFactory;
103
+ transportOptions?: RNBlePlxTrezorTransportOptions;
104
+ thp?: TrezorConnectorBaseOptions['thp'];
105
+ deviceSessionFactory?: TrezorConnectorBaseOptions['deviceSessionFactory'];
106
+ }
107
+ declare class TrezorRnBleConnector extends TrezorConnectorBase {
108
+ private readonly _transportFactory;
109
+ private _transport;
110
+ constructor(options?: TrezorRnBleConnectorOptions);
111
+ protected enumerateDevices(): Promise<ConnectorDevice[]>;
112
+ protected createByteTransport(device: ConnectorDevice): Promise<TrezorConnectorByteTransport>;
113
+ protected resolveUnlistedDevice(deviceId: string): ConnectorDevice | undefined;
114
+ private _ensureTransport;
115
+ }
116
+
117
+ declare function createTrezorRnBleConnector(options?: TrezorRnBleConnectorOptions): TrezorRnBleConnector;
118
+
119
+ export { RNBlePlxTrezorTransport, type RNBlePlxTrezorTransportOptions, TrezorRnBleConnector, type TrezorRnBleConnectorOptions, createRNBlePlxTrezorTransport, createTrezorRnBleConnector };
@@ -0,0 +1,119 @@
1
+ import { TrezorConnectorBase, TrezorConnectorBaseOptions, TrezorConnectorByteTransport } from '@onekeyfe/hwk-trezor-connector';
2
+ import { ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
3
+ import { TrezorBleTransport, TrezorBleDescriptor, TrezorConnectedDevice, TrezorBleTransportFactory } from '@onekeyfe/hwk-trezor-adapter/rn';
4
+
5
+ type BlePlxDevice = {
6
+ id: string;
7
+ name?: string | null;
8
+ localName?: string | null;
9
+ serviceUUIDs?: string[] | null;
10
+ manufacturerData?: string | null;
11
+ rssi?: number | null;
12
+ mtu?: number;
13
+ isConnected?(): Promise<boolean>;
14
+ connect(): Promise<BlePlxDevice>;
15
+ connect(options?: Record<string, unknown>): Promise<BlePlxDevice>;
16
+ cancelConnection(): Promise<BlePlxDevice>;
17
+ discoverAllServicesAndCharacteristics(): Promise<BlePlxDevice | void>;
18
+ characteristicsForService?(serviceUUID: string): Promise<BlePlxCharacteristic[]>;
19
+ requestMTU?(mtu: number): Promise<BlePlxDevice>;
20
+ };
21
+ type BlePlxCharacteristic = {
22
+ uuid?: string;
23
+ deviceID?: string;
24
+ value?: string | null;
25
+ writeWithResponse?(valueBase64: string): Promise<unknown>;
26
+ writeWithoutResponse?(valueBase64: string): Promise<unknown>;
27
+ monitor?(listener: (error: unknown, characteristic: BlePlxCharacteristic | null) => void): BlePlxSubscription;
28
+ };
29
+ type BlePlxSubscription = {
30
+ remove(): void;
31
+ };
32
+ type BlePlxManager = {
33
+ startDeviceScan(serviceUUIDs: string[] | null, options: Record<string, unknown> | null, listener: (error: unknown, scannedDevice: BlePlxDevice | null) => void): void;
34
+ stopDeviceScan(): void;
35
+ devices?(deviceIdentifiers: string[]): Promise<BlePlxDevice[]>;
36
+ connectedDevices?(serviceUUIDs: string[]): Promise<BlePlxDevice[]>;
37
+ connectToDevice(id: string, options?: Record<string, unknown>): Promise<BlePlxDevice>;
38
+ cancelDeviceConnection(id: string): Promise<BlePlxDevice>;
39
+ writeCharacteristicWithResponseForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, valueBase64: string, transactionId?: string): Promise<unknown>;
40
+ writeCharacteristicWithoutResponseForDevice?(deviceId: string, serviceUUID: string, characteristicUUID: string, valueBase64: string, transactionId?: string): Promise<unknown>;
41
+ monitorCharacteristicForDevice(deviceId: string, serviceUUID: string, characteristicUUID: string, listener: (error: unknown, characteristic: BlePlxCharacteristic | null) => void, transactionId?: string): BlePlxSubscription;
42
+ onDeviceDisconnected?(deviceId: string, listener: (error: unknown, device: BlePlxDevice | null) => void): BlePlxSubscription;
43
+ cancelTransaction?(transactionId: string): Promise<void>;
44
+ setLogLevel?(logLevel: string): Promise<string | void>;
45
+ logLevel?(): Promise<string>;
46
+ destroy(): void;
47
+ };
48
+ interface RNBlePlxTrezorTransportOptions {
49
+ manager?: BlePlxManager;
50
+ scanTimeoutMs?: number;
51
+ connectTimeoutMs?: number;
52
+ logger?: (entry: {
53
+ level: 'debug' | 'info' | 'warn' | 'error';
54
+ scope: string;
55
+ event: string;
56
+ data?: Record<string, unknown>;
57
+ }) => void;
58
+ }
59
+ declare class RNBlePlxTrezorTransport implements TrezorBleTransport {
60
+ private readonly _manager;
61
+ private readonly _scanTimeoutMs;
62
+ private readonly _connectTimeoutMs;
63
+ private readonly _logger?;
64
+ private readonly _connectedDevices;
65
+ private readonly _notifySubscriptions;
66
+ private readonly _disconnectSubscriptions;
67
+ private readonly _closingDevices;
68
+ private readonly _disconnectHandlers;
69
+ private readonly _pendingNotifications;
70
+ private readonly _pendingReaders;
71
+ constructor(options: RNBlePlxTrezorTransportOptions & {
72
+ manager: BlePlxManager;
73
+ });
74
+ static create(options?: RNBlePlxTrezorTransportOptions): Promise<RNBlePlxTrezorTransport>;
75
+ scan(): Promise<TrezorBleDescriptor[]>;
76
+ connect(connectId: string): Promise<TrezorConnectedDevice>;
77
+ disconnect(connectId: string): Promise<void>;
78
+ write(connectId: string, data: Uint8Array): Promise<void>;
79
+ read(connectId: string, timeoutMs?: number): Promise<Uint8Array>;
80
+ exchange(connectId: string, data: Uint8Array, timeoutMs?: number): Promise<Uint8Array>;
81
+ onDisconnect(connectId: string, handler: () => void): () => void;
82
+ reset(): void;
83
+ private _deviceToDescriptor;
84
+ private _ensureConnected;
85
+ private _enableNativeBleLogs;
86
+ private _connectWithMtu;
87
+ private _discoverAndTestCharacteristics;
88
+ private _getCharacteristics;
89
+ private _pairingProbe;
90
+ private _writeChunk;
91
+ private _startNotifications;
92
+ private _startCharacteristicMonitor;
93
+ private _startDisconnectWatcher;
94
+ private _pushNotification;
95
+ private _rejectReaders;
96
+ private _transactionId;
97
+ private _log;
98
+ }
99
+ declare function createRNBlePlxTrezorTransport(options?: RNBlePlxTrezorTransportOptions): Promise<TrezorBleTransport>;
100
+
101
+ interface TrezorRnBleConnectorOptions {
102
+ transportFactory?: TrezorBleTransportFactory;
103
+ transportOptions?: RNBlePlxTrezorTransportOptions;
104
+ thp?: TrezorConnectorBaseOptions['thp'];
105
+ deviceSessionFactory?: TrezorConnectorBaseOptions['deviceSessionFactory'];
106
+ }
107
+ declare class TrezorRnBleConnector extends TrezorConnectorBase {
108
+ private readonly _transportFactory;
109
+ private _transport;
110
+ constructor(options?: TrezorRnBleConnectorOptions);
111
+ protected enumerateDevices(): Promise<ConnectorDevice[]>;
112
+ protected createByteTransport(device: ConnectorDevice): Promise<TrezorConnectorByteTransport>;
113
+ protected resolveUnlistedDevice(deviceId: string): ConnectorDevice | undefined;
114
+ private _ensureTransport;
115
+ }
116
+
117
+ declare function createTrezorRnBleConnector(options?: TrezorRnBleConnectorOptions): TrezorRnBleConnector;
118
+
119
+ export { RNBlePlxTrezorTransport, type RNBlePlxTrezorTransportOptions, TrezorRnBleConnector, type TrezorRnBleConnectorOptions, createRNBlePlxTrezorTransport, createTrezorRnBleConnector };