@onekeyfe/hd-transport-web-device 1.2.0-alpha.18 → 1.2.0-alpha.180

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