@onekeyfe/hd-transport-web-device 1.2.0-alpha.16 → 1.2.0-alpha.161
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.
- package/__tests__/electron-ble-transport.test.ts +551 -27
- package/__tests__/webusb-protocol-cache.test.ts +244 -0
- package/__tests__/webusb-protocol-v2-timeout.test.ts +363 -11
- package/dist/ble-packet-capacity.d.ts +2 -0
- package/dist/ble-packet-capacity.d.ts.map +1 -0
- package/dist/electron-ble-transport.d.ts +19 -4
- package/dist/electron-ble-transport.d.ts.map +1 -1
- package/dist/index.d.ts +169 -15
- package/dist/index.js +451 -296
- package/dist/transportLog.d.ts +1 -6
- package/dist/transportLog.d.ts.map +1 -1
- package/dist/webusb.d.ts +25 -11
- package/dist/webusb.d.ts.map +1 -1
- package/jest.config.js +5 -0
- package/package.json +6 -5
- package/src/ble-packet-capacity.ts +13 -0
- package/src/electron-ble-transport.ts +291 -130
- package/src/transportLog.ts +1 -11
- package/src/webusb.ts +327 -205
|
@@ -12,30 +12,39 @@ export type BleAcquireInput = {
|
|
|
12
12
|
uuid: string;
|
|
13
13
|
forceCleanRunPromise?: boolean;
|
|
14
14
|
expectedProtocol?: ProtocolType;
|
|
15
|
+
protocolHint?: ProtocolType;
|
|
15
16
|
};
|
|
16
17
|
export default class ElectronBleTransport {
|
|
17
18
|
private _messages;
|
|
18
19
|
private _messagesV2;
|
|
20
|
+
private protocolV2SchemaConfiguration;
|
|
19
21
|
name: string;
|
|
20
22
|
configured: boolean;
|
|
21
23
|
runPromise: Deferred<Uint8Array | string> | null;
|
|
24
|
+
private runPromiseDeviceId;
|
|
22
25
|
Log?: any;
|
|
23
26
|
emitter?: EventEmitter;
|
|
24
27
|
private connectedDevices;
|
|
25
28
|
private deviceProtocol;
|
|
26
29
|
private deviceProtocolHints;
|
|
30
|
+
private confirmedProtocolV2;
|
|
31
|
+
private deviceMtus;
|
|
32
|
+
private devicePacketCapacities;
|
|
27
33
|
private v1Buffers;
|
|
28
34
|
private v2Assemblers;
|
|
29
35
|
private v2FrameQueues;
|
|
30
36
|
private v2FramePromises;
|
|
31
37
|
private protocolV2Links;
|
|
38
|
+
private warnedMissingRelease;
|
|
32
39
|
private notificationCleanups;
|
|
33
|
-
private
|
|
40
|
+
private mtuCleanups;
|
|
41
|
+
private hostDisconnectCleanup?;
|
|
34
42
|
private notificationTokens;
|
|
35
43
|
private nextNotificationToken;
|
|
36
44
|
private handleBluetoothError;
|
|
37
45
|
private cleanupDeviceState;
|
|
38
46
|
init(logger: any, emitter?: EventEmitter): void;
|
|
47
|
+
private subscribeHostDisconnects;
|
|
39
48
|
configure(signedData: any): void;
|
|
40
49
|
configureProtocolV2(signedData: any): void;
|
|
41
50
|
listen(): Promise<OneKeyDeviceInfo[]>;
|
|
@@ -51,7 +60,10 @@ export default class ElectronBleTransport {
|
|
|
51
60
|
name: string | null;
|
|
52
61
|
protocolType?: ProtocolType | undefined;
|
|
53
62
|
}>;
|
|
54
|
-
release(id: string): Promise<void>;
|
|
63
|
+
release(id: string, _onclose?: boolean, keepSession?: boolean): Promise<void>;
|
|
64
|
+
disconnect(id: string): Promise<void>;
|
|
65
|
+
private releaseNative;
|
|
66
|
+
private releaseLogical;
|
|
55
67
|
private createProtocolMismatchError;
|
|
56
68
|
private createProtocolDetectionError;
|
|
57
69
|
private clearProbeProtocol;
|
|
@@ -60,18 +72,21 @@ export default class ElectronBleTransport {
|
|
|
60
72
|
private resetProbeStateAfterProtocolProbe;
|
|
61
73
|
private probeProtocolV1;
|
|
62
74
|
private probeProtocolV2;
|
|
63
|
-
private writeWithChunking;
|
|
64
75
|
private writeOnce;
|
|
76
|
+
private refreshBlePacketCapacity;
|
|
77
|
+
private updateBlePacketCapacity;
|
|
78
|
+
private createMtuSubscription;
|
|
79
|
+
private writeProtocolV2Frame;
|
|
65
80
|
private handleNotification;
|
|
66
81
|
private handleProtocolV2Notification;
|
|
67
82
|
private getProtocolV2FrameQueue;
|
|
68
83
|
private resolveProtocolV2Frame;
|
|
69
|
-
private rejectAllProtocolV2Frames;
|
|
70
84
|
private resetProtocolV2Frames;
|
|
71
85
|
private rejectProtocolV2Frames;
|
|
72
86
|
private readProtocolV2Frame;
|
|
73
87
|
private handleProtocolV1Notification;
|
|
74
88
|
call(uuid: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<import("@onekeyfe/hd-transport").MessageFromOneKey>;
|
|
89
|
+
post(uuid: string, name: string, data: Record<string, unknown>): Promise<void>;
|
|
75
90
|
private callProtocolV1;
|
|
76
91
|
private callProtocolV2;
|
|
77
92
|
private createProtocolV2Adapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,51 +1,142 @@
|
|
|
1
1
|
import * as _onekeyfe_hd_transport from '@onekeyfe/hd-transport';
|
|
2
|
-
import _onekeyfe_hd_transport__default, { AcquireInput, TransportCallOptions, ProtocolType, OneKeyDeviceInfoBase, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
|
|
2
|
+
import _onekeyfe_hd_transport__default, { ProtocolV2UsbTransportBase, AcquireInput, TransportCallOptions, ProtocolV2Schemas, ProtocolV2CallContext, ProtocolType, OneKeyDeviceInfoBase, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
|
|
3
|
+
import EventEmitter from 'events';
|
|
3
4
|
import { Deferred } from '@onekeyfe/hd-shared';
|
|
4
5
|
import { DesktopAPI } from '@onekeyfe/hd-transport-electron';
|
|
5
|
-
import EventEmitter from 'events';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Device information with path and WebUSB device instance
|
|
9
|
+
*/
|
|
7
10
|
interface DeviceInfo extends OneKeyDeviceInfoBase {
|
|
8
11
|
path: string;
|
|
9
12
|
device: USBDevice;
|
|
10
13
|
protocolType?: ProtocolType;
|
|
11
14
|
}
|
|
12
|
-
declare class WebUsbTransport {
|
|
15
|
+
declare class WebUsbTransport extends ProtocolV2UsbTransportBase<string> {
|
|
13
16
|
messages: ReturnType<typeof _onekeyfe_hd_transport__default.parseConfigure> | undefined;
|
|
17
|
+
/** Protobuf schema for Protocol V2 transports. */
|
|
14
18
|
messagesV2: ReturnType<typeof _onekeyfe_hd_transport__default.parseConfigure> | undefined;
|
|
19
|
+
private protocolV2SchemaSource;
|
|
20
|
+
/** Per-path protocol type detected by active wire-level probe. */
|
|
15
21
|
private deviceProtocol;
|
|
16
22
|
private deviceProtocolHints;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Paths whose cached protocol must be re-probed on the next acquire (a USB
|
|
25
|
+
* disconnect was seen, or a transfer-level reconnect happened mid-call).
|
|
26
|
+
*/
|
|
27
|
+
private staleProtocolPaths;
|
|
28
|
+
/** Paths currently acquired (between a successful acquire() and its release()). */
|
|
29
|
+
private acquiredPaths;
|
|
30
|
+
/**
|
|
31
|
+
* The exact USBDevice object each cached protocol was probed against. The
|
|
32
|
+
* browser returns the same object identity for a device as long as it stays
|
|
33
|
+
* connected, and a replug/reboot always yields a new object — so an identity
|
|
34
|
+
* mismatch proves the device was re-enumerated since the probe, even when the
|
|
35
|
+
* disconnect event itself was delayed or missed.
|
|
36
|
+
*/
|
|
37
|
+
private probedDeviceObjects;
|
|
38
|
+
/** Per-path USB endpoint / interface numbers (discovered from USB descriptors) */
|
|
20
39
|
private deviceEndpoints;
|
|
21
|
-
private mockSerialPaths;
|
|
22
|
-
private mockSerialCounter;
|
|
23
40
|
name: string;
|
|
24
41
|
stopped: boolean;
|
|
25
42
|
configured: boolean;
|
|
26
43
|
Log?: any;
|
|
27
44
|
usb?: USB;
|
|
45
|
+
emitter?: EventEmitter;
|
|
46
|
+
/**
|
|
47
|
+
* Cached list of connected devices
|
|
48
|
+
* This is essential for maintaining device references between operations
|
|
49
|
+
*/
|
|
28
50
|
deviceList: Array<DeviceInfo>;
|
|
29
51
|
configurationId: number;
|
|
30
52
|
endpointId: number;
|
|
31
53
|
interfaceId: number;
|
|
32
|
-
|
|
54
|
+
constructor();
|
|
55
|
+
/**
|
|
56
|
+
* Initialize WebUSB transport
|
|
57
|
+
*/
|
|
58
|
+
init(logger: any, emitter?: EventEmitter): void;
|
|
59
|
+
/**
|
|
60
|
+
* Announce that a USB device left. Called from the module-scoped disconnect
|
|
61
|
+
* listener, which is why it is public rather than inlined.
|
|
62
|
+
*/
|
|
63
|
+
emitDeviceDisconnect(path: string, device?: USBDevice): void;
|
|
64
|
+
/**
|
|
65
|
+
* Protocol type is a property of the physical device keyed by USB serial number.
|
|
66
|
+
* It can only change across a device reboot (e.g. normal ↔ bootloader mode), and
|
|
67
|
+
* a reboot always surfaces as a USB disconnect. Disconnects (and transfer-level
|
|
68
|
+
* reconnects, which cover a missed disconnect event) only MARK the cached probe
|
|
69
|
+
* result stale instead of deleting it: an in-flight session keeps using the old
|
|
70
|
+
* value so the transfer-level reconnect retries can absorb a transient
|
|
71
|
+
* re-enumeration exactly as they did before the cache existed, while the next
|
|
72
|
+
* acquire re-probes from scratch.
|
|
73
|
+
*/
|
|
74
|
+
markProtocolStale(path: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Configure Protocol V1 protobuf schema (legacy chunked 0x3F framing).
|
|
77
|
+
*/
|
|
33
78
|
configure(signedData: any): void;
|
|
79
|
+
/**
|
|
80
|
+
* Cache the Protocol V2 protobuf schema.
|
|
81
|
+
*/
|
|
34
82
|
configureProtocolV2(signedData: any): void;
|
|
83
|
+
/**
|
|
84
|
+
* Request user to select a device
|
|
85
|
+
* This method must be called in response to a user action
|
|
86
|
+
* to comply with WebUSB security requirements
|
|
87
|
+
*/
|
|
35
88
|
promptDeviceAccess(): Promise<USBDevice | null>;
|
|
89
|
+
/**
|
|
90
|
+
* Enumerate already connected devices
|
|
91
|
+
* This method only returns devices that are already authorized by the browser
|
|
92
|
+
* It does NOT prompt the user to select a device
|
|
93
|
+
*/
|
|
36
94
|
enumerate(): Promise<DeviceInfo[]>;
|
|
37
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Get list of connected devices
|
|
97
|
+
*/
|
|
38
98
|
getConnectedDevices(): Promise<DeviceInfo[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Acquire device control
|
|
101
|
+
*/
|
|
39
102
|
acquire(input: AcquireInput): Promise<string | undefined>;
|
|
103
|
+
/**
|
|
104
|
+
* Determine protocol type after connect.
|
|
105
|
+
* Probe Protocol V1 first with Initialize. If it does not answer in time,
|
|
106
|
+
* fall back to a Protocol V2 Ping probe.
|
|
107
|
+
*/
|
|
40
108
|
private createProtocolMismatchError;
|
|
109
|
+
private createProtocolProbeTimeoutError;
|
|
41
110
|
private createProtocolDetectionError;
|
|
42
111
|
private detectProtocol;
|
|
112
|
+
/**
|
|
113
|
+
* Find device by path
|
|
114
|
+
*/
|
|
43
115
|
findDevice(path: string): Promise<USBDevice>;
|
|
116
|
+
/**
|
|
117
|
+
* Connect to device with retry mechanism
|
|
118
|
+
*/
|
|
44
119
|
connect(path: string, first: boolean): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Discover vendor-class (0xFF) interface and its IN/OUT endpoint numbers from USB descriptors.
|
|
122
|
+
* Falls back to legacy hardcoded values if no vendor interface is found.
|
|
123
|
+
*/
|
|
45
124
|
private discoverEndpoints;
|
|
125
|
+
/**
|
|
126
|
+
* Connect to specific device.
|
|
127
|
+
* Discovers interface/endpoint numbers from USB descriptors on first connection.
|
|
128
|
+
*/
|
|
46
129
|
connectToDevice(path: string, first: boolean): Promise<void>;
|
|
47
130
|
private closeOpenDevice;
|
|
48
131
|
private clearEndpointHalt;
|
|
132
|
+
/**
|
|
133
|
+
* With the protocol cache surviving release(), deviceProtocol presence no
|
|
134
|
+
* longer implies an active session. Guard call()/post() explicitly so a
|
|
135
|
+
* post-release straggler fails fast instead of silently reopening the device
|
|
136
|
+
* and driving it outside any session (pre-cache behavior: the deleted
|
|
137
|
+
* protocol entry produced the same fail-fast).
|
|
138
|
+
*/
|
|
139
|
+
private assertAcquired;
|
|
49
140
|
post(session: string, name: string, data: Record<string, unknown>): Promise<void>;
|
|
50
141
|
private getErrorMessage;
|
|
51
142
|
private isRetryablePacketIoError;
|
|
@@ -55,16 +146,43 @@ declare class WebUsbTransport {
|
|
|
55
146
|
private transferOutWithRetry;
|
|
56
147
|
private transferOutOnce;
|
|
57
148
|
private transferInWithRetry;
|
|
149
|
+
private transferInOnce;
|
|
150
|
+
private closeConnectionAfterProbe;
|
|
58
151
|
private resetConnectionAfterProbe;
|
|
59
152
|
private withProtocolReadTimeout;
|
|
60
153
|
private probeProtocolV1;
|
|
61
154
|
private probeProtocolV2;
|
|
155
|
+
/**
|
|
156
|
+
* Call device method — branches to Protocol V1 or Protocol V2 based on active probe.
|
|
157
|
+
*/
|
|
62
158
|
call(path: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<_onekeyfe_hd_transport.MessageFromOneKey>;
|
|
63
159
|
private callProtocolV1;
|
|
160
|
+
/**
|
|
161
|
+
* Send/receive a single call over Protocol V2 (0x5A framing).
|
|
162
|
+
*
|
|
163
|
+
* Encoding: protobuf message → 2-byte LE messageTypeId + pb bytes → Protocol V2 frame
|
|
164
|
+
* Decoding: Protocol V2 frame → messageTypeId + pb bytes → protobuf message
|
|
165
|
+
*/
|
|
64
166
|
private callProtocolV2;
|
|
65
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Receive data from device
|
|
169
|
+
*/
|
|
66
170
|
receiveData(path: string, timeoutMs?: number): Promise<string>;
|
|
171
|
+
/**
|
|
172
|
+
* Release device
|
|
173
|
+
*/
|
|
67
174
|
release(path: string): Promise<void>;
|
|
175
|
+
protected getProtocolV2UsbSchemas(): ProtocolV2Schemas;
|
|
176
|
+
protected getProtocolV2UsbLogger(): any;
|
|
177
|
+
protected writeProtocolV2UsbPacket(path: string, frame: Uint8Array, _context: ProtocolV2CallContext): Promise<void>;
|
|
178
|
+
protected readProtocolV2UsbPacket(path: string, _context: ProtocolV2CallContext): Promise<Uint8Array>;
|
|
179
|
+
protected resetProtocolV2UsbNativeLink(path: string, _reason: string): Promise<void>;
|
|
180
|
+
protected onProtocolV2UsbLinkInvalidated(path: string, reason: string): void;
|
|
181
|
+
protected createProtocolV2UsbTimeoutError(name: string, timeoutMs: number): Error;
|
|
182
|
+
/**
|
|
183
|
+
* Expose the detected protocol type for a given device path.
|
|
184
|
+
* Used by upper layers (e.g. TransportManager) to select the correct schema.
|
|
185
|
+
*/
|
|
68
186
|
getProtocolType(path: string): ProtocolType | undefined;
|
|
69
187
|
}
|
|
70
188
|
|
|
@@ -77,30 +195,60 @@ type BleAcquireInput = {
|
|
|
77
195
|
uuid: string;
|
|
78
196
|
forceCleanRunPromise?: boolean;
|
|
79
197
|
expectedProtocol?: ProtocolType;
|
|
198
|
+
protocolHint?: ProtocolType;
|
|
80
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* Desktop Electron BLE transport with automatic Protocol V1/V2 detection.
|
|
202
|
+
*
|
|
203
|
+
* Protocol V1 devices continue using chunked packets. Protocol V2 is detected
|
|
204
|
+
* after a Protocol V1 GetFeatures timeout by probing Protocol V2 Ping.
|
|
205
|
+
*/
|
|
81
206
|
declare class ElectronBleTransport {
|
|
82
207
|
private _messages;
|
|
83
208
|
private _messagesV2;
|
|
209
|
+
private protocolV2SchemaConfiguration;
|
|
84
210
|
name: string;
|
|
85
211
|
configured: boolean;
|
|
86
212
|
runPromise: Deferred<Uint8Array | string> | null;
|
|
213
|
+
private runPromiseDeviceId;
|
|
87
214
|
Log?: any;
|
|
88
215
|
emitter?: EventEmitter;
|
|
89
216
|
private connectedDevices;
|
|
90
217
|
private deviceProtocol;
|
|
91
218
|
private deviceProtocolHints;
|
|
219
|
+
/** Endpoints that answered a V2 probe in this transport lifetime. Survives disconnect. */
|
|
220
|
+
private confirmedProtocolV2;
|
|
221
|
+
private deviceMtus;
|
|
222
|
+
private devicePacketCapacities;
|
|
92
223
|
private v1Buffers;
|
|
93
224
|
private v2Assemblers;
|
|
94
225
|
private v2FrameQueues;
|
|
95
226
|
private v2FramePromises;
|
|
96
227
|
private protocolV2Links;
|
|
228
|
+
/** One-shot guard so a missing preload `release` bridge is reported once. */
|
|
229
|
+
private warnedMissingRelease;
|
|
97
230
|
private notificationCleanups;
|
|
98
|
-
private
|
|
231
|
+
private mtuCleanups;
|
|
232
|
+
/**
|
|
233
|
+
* Transport-lifetime subscription to host BLE disconnects.
|
|
234
|
+
*
|
|
235
|
+
* This must NOT be scoped to acquire()/release(): a logical release keeps the
|
|
236
|
+
* native link alive for the keep-alive window, so a device that drops while
|
|
237
|
+
* idle would otherwise go unobserved and consumers would never learn it left
|
|
238
|
+
* (OK-60486).
|
|
239
|
+
*/
|
|
240
|
+
private hostDisconnectCleanup?;
|
|
99
241
|
private notificationTokens;
|
|
100
242
|
private nextNotificationToken;
|
|
101
243
|
private handleBluetoothError;
|
|
102
244
|
private cleanupDeviceState;
|
|
103
245
|
init(logger: any, emitter?: EventEmitter): void;
|
|
246
|
+
/**
|
|
247
|
+
* One host subscription for the whole transport lifetime. init() can run
|
|
248
|
+
* again after an SDK reset, so drop the previous listener first rather than
|
|
249
|
+
* stacking duplicates.
|
|
250
|
+
*/
|
|
251
|
+
private subscribeHostDisconnects;
|
|
104
252
|
configure(signedData: any): void;
|
|
105
253
|
configureProtocolV2(signedData: any): void;
|
|
106
254
|
listen(): Promise<OneKeyDeviceInfo[]>;
|
|
@@ -116,7 +264,10 @@ declare class ElectronBleTransport {
|
|
|
116
264
|
name: string | null;
|
|
117
265
|
protocolType?: ProtocolType | undefined;
|
|
118
266
|
}>;
|
|
119
|
-
release(id: string): Promise<void>;
|
|
267
|
+
release(id: string, _onclose?: boolean, keepSession?: boolean): Promise<void>;
|
|
268
|
+
disconnect(id: string): Promise<void>;
|
|
269
|
+
private releaseNative;
|
|
270
|
+
private releaseLogical;
|
|
120
271
|
private createProtocolMismatchError;
|
|
121
272
|
private createProtocolDetectionError;
|
|
122
273
|
private clearProbeProtocol;
|
|
@@ -125,18 +276,21 @@ declare class ElectronBleTransport {
|
|
|
125
276
|
private resetProbeStateAfterProtocolProbe;
|
|
126
277
|
private probeProtocolV1;
|
|
127
278
|
private probeProtocolV2;
|
|
128
|
-
private writeWithChunking;
|
|
129
279
|
private writeOnce;
|
|
280
|
+
private refreshBlePacketCapacity;
|
|
281
|
+
private updateBlePacketCapacity;
|
|
282
|
+
private createMtuSubscription;
|
|
283
|
+
private writeProtocolV2Frame;
|
|
130
284
|
private handleNotification;
|
|
131
285
|
private handleProtocolV2Notification;
|
|
132
286
|
private getProtocolV2FrameQueue;
|
|
133
287
|
private resolveProtocolV2Frame;
|
|
134
|
-
private rejectAllProtocolV2Frames;
|
|
135
288
|
private resetProtocolV2Frames;
|
|
136
289
|
private rejectProtocolV2Frames;
|
|
137
290
|
private readProtocolV2Frame;
|
|
138
291
|
private handleProtocolV1Notification;
|
|
139
292
|
call(uuid: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<_onekeyfe_hd_transport.MessageFromOneKey>;
|
|
293
|
+
post(uuid: string, name: string, data: Record<string, unknown>): Promise<void>;
|
|
140
294
|
private callProtocolV1;
|
|
141
295
|
private callProtocolV2;
|
|
142
296
|
private createProtocolV2Adapter;
|