@onekeyfe/hd-transport-web-device 1.1.27-alpha.4 → 1.1.27-alpha.41

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,231 @@
1
+ import transport, { PROTOCOL_V2_CHANNEL_BLE_UART, bytesToHex } from '@onekeyfe/hd-transport';
2
+
3
+ import ElectronBleTransport from '../src/electron-ble-transport';
4
+
5
+ const { ProtocolV1, ProtocolV2, parseConfigure } = transport;
6
+
7
+ const protocolV1Schema = {
8
+ nested: {
9
+ Initialize: {
10
+ fields: {},
11
+ },
12
+ Success: {
13
+ fields: {
14
+ message: {
15
+ type: 'string',
16
+ id: 1,
17
+ },
18
+ },
19
+ },
20
+ MessageType: {
21
+ values: {
22
+ MessageType_Initialize: 1,
23
+ MessageType_Success: 2,
24
+ },
25
+ },
26
+ },
27
+ };
28
+
29
+ const protocolV2Schema = {
30
+ nested: {
31
+ Ping: {
32
+ fields: {
33
+ message: {
34
+ type: 'string',
35
+ id: 1,
36
+ },
37
+ },
38
+ },
39
+ Success: {
40
+ fields: {
41
+ message: {
42
+ type: 'string',
43
+ id: 1,
44
+ },
45
+ },
46
+ },
47
+ MessageType: {
48
+ values: {
49
+ MessageType_Ping: 60206,
50
+ MessageType_Success: 60207,
51
+ },
52
+ },
53
+ },
54
+ };
55
+
56
+ const schemas = {
57
+ protocolV1: parseConfigure(protocolV1Schema),
58
+ protocolV2: parseConfigure(protocolV2Schema),
59
+ };
60
+
61
+ jest.setTimeout(10_000);
62
+
63
+ const createLogger = () => ({
64
+ debug: jest.fn(),
65
+ error: jest.fn(),
66
+ });
67
+
68
+ const createNobleBle = (device = { id: 'flaky-pro2-id', name: 'Unknown BLE Device' }) => ({
69
+ enumerate: jest.fn(() => Promise.resolve([device])),
70
+ getDevice: jest.fn(() => Promise.resolve(device)),
71
+ connect: jest.fn(() => Promise.resolve()),
72
+ disconnect: jest.fn(() => Promise.resolve()),
73
+ subscribe: jest.fn(() => Promise.resolve()),
74
+ unsubscribe: jest.fn(() => Promise.resolve()),
75
+ write: jest.fn(() => Promise.resolve()),
76
+ onNotification: jest.fn(() => jest.fn()),
77
+ onDeviceDisconnected: jest.fn(() => jest.fn()),
78
+ checkAvailability: jest.fn(() =>
79
+ Promise.resolve({
80
+ available: true,
81
+ state: 'poweredOn',
82
+ unsupported: false,
83
+ initialized: true,
84
+ })
85
+ ),
86
+ });
87
+
88
+ const configureTransport = (nobleBle: ReturnType<typeof createNobleBle>) => {
89
+ (global as any).window = {
90
+ desktopApi: {
91
+ nobleBle,
92
+ },
93
+ };
94
+
95
+ const transport = new ElectronBleTransport();
96
+ transport.init(createLogger());
97
+ transport.configure(protocolV1Schema);
98
+ transport.configureProtocolV2(protocolV2Schema);
99
+ return transport;
100
+ };
101
+
102
+ describe('ElectronBleTransport protocol detection', () => {
103
+ afterEach(() => {
104
+ delete (global as any).window;
105
+ jest.clearAllMocks();
106
+ });
107
+
108
+ test('detects Protocol V2 after Protocol V1 probe timeout', async () => {
109
+ const device = { id: 'unknown-pro2-id', name: 'Unknown BLE Device' };
110
+ const nobleBle = createNobleBle(device);
111
+ let notificationHandler: ((deviceId: string, data: string) => void) | undefined;
112
+ let writeCount = 0;
113
+ const probeResponse = ProtocolV2.encodeFrame(
114
+ schemas,
115
+ 'Success',
116
+ {
117
+ message: 'probe',
118
+ },
119
+ { router: PROTOCOL_V2_CHANNEL_BLE_UART }
120
+ );
121
+
122
+ nobleBle.onNotification.mockImplementation(handler => {
123
+ notificationHandler = handler;
124
+ return jest.fn();
125
+ });
126
+ nobleBle.write.mockImplementation(() => {
127
+ writeCount += 1;
128
+ if (writeCount > 1) {
129
+ setTimeout(() => notificationHandler?.(device.id, bytesToHex(probeResponse)), 0);
130
+ }
131
+ return Promise.resolve();
132
+ });
133
+ const transport = configureTransport(nobleBle);
134
+
135
+ try {
136
+ await expect(transport.acquire({ uuid: device.id })).resolves.toEqual(
137
+ expect.objectContaining({
138
+ uuid: device.id,
139
+ protocolType: 'V2',
140
+ })
141
+ );
142
+ expect(transport.getProtocolType(device.id)).toBe('V2');
143
+ } finally {
144
+ await transport.release(device.id);
145
+ }
146
+ });
147
+
148
+ test('detects Protocol V1 when device responds to Initialize', async () => {
149
+ const device = { id: 'classic-id', name: 'OneKey Classic' };
150
+ const nobleBle = createNobleBle(device);
151
+ let notificationHandler: ((deviceId: string, data: string) => void) | undefined;
152
+
153
+ // Build a V1 Success notification (no 64-byte padding, matching real BLE behaviour).
154
+ // Format: ?## (3f2323) + typeId BE (0002) + length BE (00000004) + protobuf payload (0a026f6b)
155
+ const v1ResponseHex = '3f23230002000000040a026f6b';
156
+
157
+ nobleBle.onNotification.mockImplementation(handler => {
158
+ notificationHandler = handler;
159
+ return jest.fn();
160
+ });
161
+ nobleBle.write.mockImplementation(() => {
162
+ // Respond to first write (V1 Initialize probe) with V1 Success
163
+ setTimeout(() => notificationHandler?.(device.id, v1ResponseHex), 0);
164
+ return Promise.resolve();
165
+ });
166
+ const transport = configureTransport(nobleBle);
167
+
168
+ try {
169
+ await expect(transport.acquire({ uuid: device.id })).resolves.toEqual(
170
+ expect.objectContaining({
171
+ uuid: device.id,
172
+ })
173
+ );
174
+ expect(transport.getProtocolType(device.id)).toBe('V1');
175
+ } finally {
176
+ await transport.release(device.id);
177
+ }
178
+ });
179
+
180
+ test('throws when both protocol probes fail', async () => {
181
+ const device = { id: 'dead-device-id', name: 'Unknown Device' };
182
+ const nobleBle = createNobleBle(device);
183
+
184
+ // Never respond to writes — both probes will timeout
185
+ nobleBle.onNotification.mockImplementation(() => jest.fn());
186
+
187
+ const transport = configureTransport(nobleBle);
188
+
189
+ await expect(transport.acquire({ uuid: device.id })).rejects.toThrow(
190
+ /Unable to detect BLE protocol/
191
+ );
192
+ expect(transport.getProtocolType(device.id)).toBeUndefined();
193
+ });
194
+
195
+ test('probes Protocol V2 instead of trusting the Pro2 name hint', async () => {
196
+ const device = { id: 'named-pro2-id', name: 'OneKey Pro 2' };
197
+ const nobleBle = createNobleBle(device);
198
+ let notificationHandler: ((deviceId: string, data: string) => void) | undefined;
199
+ const probeResponse = ProtocolV2.encodeFrame(
200
+ schemas,
201
+ 'Success',
202
+ {
203
+ message: 'probe',
204
+ },
205
+ { router: PROTOCOL_V2_CHANNEL_BLE_UART }
206
+ );
207
+
208
+ nobleBle.onNotification.mockImplementation(handler => {
209
+ notificationHandler = handler;
210
+ return jest.fn();
211
+ });
212
+ nobleBle.write.mockImplementation(() => {
213
+ setTimeout(() => notificationHandler?.(device.id, bytesToHex(probeResponse)), 0);
214
+ return Promise.resolve();
215
+ });
216
+ const transport = configureTransport(nobleBle);
217
+
218
+ try {
219
+ await expect(transport.acquire({ uuid: device.id })).resolves.toEqual(
220
+ expect.objectContaining({
221
+ uuid: device.id,
222
+ protocolType: 'V2',
223
+ })
224
+ );
225
+ expect(nobleBle.write).toHaveBeenCalledTimes(1);
226
+ expect(transport.getProtocolType(device.id)).toBe('V2');
227
+ } finally {
228
+ await transport.release(device.id);
229
+ }
230
+ });
231
+ });
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
- import transport from '@onekeyfe/hd-transport';
3
2
  import type { Deferred } from '@onekeyfe/hd-shared';
4
- import type EventEmitter from 'events';
5
3
  import type { DesktopAPI } from '@onekeyfe/hd-transport-electron';
4
+ import type { OneKeyDeviceInfo, ProtocolType, TransportCallOptions } from '@onekeyfe/hd-transport';
5
+ import type EventEmitter from 'events';
6
6
  declare global {
7
7
  interface Window {
8
8
  desktopApi?: DesktopAPI;
@@ -11,34 +11,71 @@ declare global {
11
11
  export type BleAcquireInput = {
12
12
  uuid: string;
13
13
  forceCleanRunPromise?: boolean;
14
+ expectedProtocol?: ProtocolType;
14
15
  };
15
16
  export default class ElectronBleTransport {
16
- _messages: ReturnType<typeof transport.parseConfigure> | undefined;
17
+ private _messages;
18
+ private _messagesV2;
17
19
  name: string;
18
20
  configured: boolean;
19
- runPromise: Deferred<any> | null;
21
+ runPromise: Deferred<Uint8Array | string> | null;
20
22
  Log?: any;
21
23
  emitter?: EventEmitter;
22
24
  private connectedDevices;
23
- private dataBuffers;
25
+ private deviceProtocol;
26
+ private deviceProtocolHints;
27
+ private v1Buffers;
28
+ private v2Assemblers;
29
+ private v2FrameQueues;
30
+ private v2FramePromises;
31
+ private activeProtocolV2Call;
32
+ private nextProtocolV2CallToken;
24
33
  private notificationCleanups;
25
34
  private disconnectCleanups;
35
+ private notificationTokens;
36
+ private nextNotificationToken;
26
37
  private handleBluetoothError;
27
38
  private cleanupDeviceState;
28
39
  init(logger: any, emitter?: EventEmitter): void;
29
40
  configure(signedData: any): void;
30
- listen(): void;
31
- enumerate(): Promise<{
32
- id: string;
33
- name: string;
34
- }[]>;
41
+ configureProtocolV2(signedData: any): void;
42
+ listen(): Promise<OneKeyDeviceInfo[]>;
43
+ enumerate(): Promise<OneKeyDeviceInfo[]>;
35
44
  acquire(input: BleAcquireInput): Promise<{
36
45
  uuid: string;
46
+ commType: import("@onekeyfe/hd-transport").OneKeyDeviceCommType;
37
47
  path: string;
48
+ session?: string | null | undefined;
49
+ debugSession?: string | null | undefined;
50
+ debug: boolean;
51
+ id: string;
52
+ name: string | null;
53
+ protocolType?: ProtocolType | undefined;
38
54
  }>;
39
55
  release(id: string): Promise<void>;
40
- private handleNotificationData;
41
- call(uuid: string, name: string, data: Record<string, unknown>): Promise<import("@onekeyfe/hd-transport").MessageFromOneKey>;
42
- private processNotificationPacket;
56
+ private createProtocolMismatchError;
57
+ private createProtocolDetectionError;
58
+ private clearProbeProtocol;
59
+ private detectProtocol;
60
+ private createNotificationSubscription;
61
+ private resetProbeStateAfterProtocolProbe;
62
+ private probeProtocolV1;
63
+ private probeProtocolV2;
64
+ private writeWithChunking;
65
+ private writeWithRetry;
66
+ private handleNotification;
67
+ private handleProtocolV2Notification;
68
+ private getProtocolV2FrameQueue;
69
+ private resolveProtocolV2Frame;
70
+ private rejectAllProtocolV2Frames;
71
+ private resetProtocolV2Frames;
72
+ private isActiveProtocolV2Call;
73
+ private readProtocolV2Frame;
74
+ private handleProtocolV1Notification;
75
+ call(uuid: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<import("@onekeyfe/hd-transport").MessageFromOneKey>;
76
+ private callProtocolV1;
77
+ private callProtocolV2;
78
+ private processProtocolV1Notification;
79
+ getProtocolType(path: string): ProtocolType | undefined;
43
80
  }
44
81
  //# sourceMappingURL=electron-ble-transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";AAAA,OAAO,SAAkD,MAAM,wBAAwB,CAAC;AASxF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAKlE,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;CAChC,CAAC;AASF,MAAM,CAAC,OAAO,OAAO,oBAAoB;IACvC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,IAAI,SAA0B;IAE9B,UAAU,UAAS;IAEnB,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAExC,GAAG,CAAC,EAAE,GAAG,CAAC;IAEV,OAAO,CAAC,EAAE,YAAY,CAAC;IAGvB,OAAO,CAAC,gBAAgB,CAA0B;IAGlD,OAAO,CAAC,WAAW,CAAsE;IAGzF,OAAO,CAAC,oBAAoB,CAAsC;IAGlE,OAAO,CAAC,kBAAkB,CAAsC;IAGhE,OAAO,CAAC,oBAAoB;IAmC5B,OAAO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AsB;IAU9B,OAAO,CAAC,yBAAyB;IAQjC,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,sBAAsB;YAIhB,mBAAmB;IAiBjC,OAAO,CAAC,4BAA4B;IAgB9B,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,oBAAoB;YA+BlB,cAAc;YAuEd,cAAc;IAmF5B,OAAO,CAAC,6BAA6B;IAsCrC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAGxD"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,21 @@
1
- import * as transport from '@onekeyfe/hd-transport';
2
- import transport__default, { AcquireInput, OneKeyDeviceInfoBase } from '@onekeyfe/hd-transport';
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';
3
3
  import { Deferred } from '@onekeyfe/hd-shared';
4
- import EventEmitter from 'events';
5
4
  import { DesktopAPI } from '@onekeyfe/hd-transport-electron';
5
+ import EventEmitter from 'events';
6
6
 
7
7
  interface DeviceInfo extends OneKeyDeviceInfoBase {
8
8
  path: string;
9
9
  device: USBDevice;
10
+ protocolType?: ProtocolType;
10
11
  }
11
12
  declare class WebUsbTransport {
12
- messages: ReturnType<typeof transport__default.parseConfigure> | undefined;
13
+ messages: ReturnType<typeof _onekeyfe_hd_transport__default.parseConfigure> | undefined;
14
+ messagesV2: ReturnType<typeof _onekeyfe_hd_transport__default.parseConfigure> | undefined;
15
+ private deviceProtocol;
16
+ private deviceProtocolHints;
17
+ private protocolV2Assemblers;
18
+ private deviceEndpoints;
13
19
  name: string;
14
20
  stopped: boolean;
15
21
  configured: boolean;
@@ -21,12 +27,17 @@ declare class WebUsbTransport {
21
27
  interfaceId: number;
22
28
  init(logger: any): void;
23
29
  configure(signedData: any): void;
30
+ configureProtocolV2(signedData: any): void;
24
31
  promptDeviceAccess(): Promise<USBDevice | null>;
25
32
  enumerate(): Promise<DeviceInfo[]>;
26
33
  getConnectedDevices(): Promise<DeviceInfo[]>;
27
34
  acquire(input: AcquireInput): Promise<string | undefined>;
35
+ private createProtocolMismatchError;
36
+ private createProtocolDetectionError;
37
+ private detectProtocol;
28
38
  findDevice(path: string): Promise<USBDevice>;
29
39
  connect(path: string, first: boolean): Promise<void>;
40
+ private discoverEndpoints;
30
41
  connectToDevice(path: string, first: boolean): Promise<void>;
31
42
  post(session: string, name: string, data: Record<string, unknown>): Promise<void>;
32
43
  private getErrorMessage;
@@ -36,9 +47,17 @@ declare class WebUsbTransport {
36
47
  private toArrayBuffer;
37
48
  private transferOutWithRetry;
38
49
  private transferInWithRetry;
39
- call(path: string, name: string, data: Record<string, unknown>): Promise<transport.MessageFromOneKey>;
40
- receiveData(path: string): Promise<string>;
50
+ private resetConnectionAfterProbe;
51
+ private withProtocolReadTimeout;
52
+ private probeProtocolV1;
53
+ private probeProtocolV2;
54
+ call(path: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<_onekeyfe_hd_transport.MessageFromOneKey>;
55
+ private callProtocolV1;
56
+ private callProtocolV2;
57
+ private receiveProtocolV2Frame;
58
+ receiveData(path: string, timeoutMs?: number): Promise<string>;
41
59
  release(path: string): Promise<void>;
60
+ getProtocolType(path: string): ProtocolType | undefined;
42
61
  }
43
62
 
44
63
  declare global {
@@ -49,35 +68,72 @@ declare global {
49
68
  type BleAcquireInput = {
50
69
  uuid: string;
51
70
  forceCleanRunPromise?: boolean;
71
+ expectedProtocol?: ProtocolType;
52
72
  };
53
73
  declare class ElectronBleTransport {
54
- _messages: ReturnType<typeof transport__default.parseConfigure> | undefined;
74
+ private _messages;
75
+ private _messagesV2;
55
76
  name: string;
56
77
  configured: boolean;
57
- runPromise: Deferred<any> | null;
78
+ runPromise: Deferred<Uint8Array | string> | null;
58
79
  Log?: any;
59
80
  emitter?: EventEmitter;
60
81
  private connectedDevices;
61
- private dataBuffers;
82
+ private deviceProtocol;
83
+ private deviceProtocolHints;
84
+ private v1Buffers;
85
+ private v2Assemblers;
86
+ private v2FrameQueues;
87
+ private v2FramePromises;
88
+ private activeProtocolV2Call;
89
+ private nextProtocolV2CallToken;
62
90
  private notificationCleanups;
63
91
  private disconnectCleanups;
92
+ private notificationTokens;
93
+ private nextNotificationToken;
64
94
  private handleBluetoothError;
65
95
  private cleanupDeviceState;
66
96
  init(logger: any, emitter?: EventEmitter): void;
67
97
  configure(signedData: any): void;
68
- listen(): void;
69
- enumerate(): Promise<{
70
- id: string;
71
- name: string;
72
- }[]>;
98
+ configureProtocolV2(signedData: any): void;
99
+ listen(): Promise<OneKeyDeviceInfo[]>;
100
+ enumerate(): Promise<OneKeyDeviceInfo[]>;
73
101
  acquire(input: BleAcquireInput): Promise<{
74
102
  uuid: string;
103
+ commType: _onekeyfe_hd_transport.OneKeyDeviceCommType;
75
104
  path: string;
105
+ session?: string | null | undefined;
106
+ debugSession?: string | null | undefined;
107
+ debug: boolean;
108
+ id: string;
109
+ name: string | null;
110
+ protocolType?: ProtocolType | undefined;
76
111
  }>;
77
112
  release(id: string): Promise<void>;
78
- private handleNotificationData;
79
- call(uuid: string, name: string, data: Record<string, unknown>): Promise<transport.MessageFromOneKey>;
80
- private processNotificationPacket;
113
+ private createProtocolMismatchError;
114
+ private createProtocolDetectionError;
115
+ private clearProbeProtocol;
116
+ private detectProtocol;
117
+ private createNotificationSubscription;
118
+ private resetProbeStateAfterProtocolProbe;
119
+ private probeProtocolV1;
120
+ private probeProtocolV2;
121
+ private writeWithChunking;
122
+ private writeWithRetry;
123
+ private handleNotification;
124
+ private handleProtocolV2Notification;
125
+ private getProtocolV2FrameQueue;
126
+ private resolveProtocolV2Frame;
127
+ private rejectAllProtocolV2Frames;
128
+ private resetProtocolV2Frames;
129
+ private isActiveProtocolV2Call;
130
+ private readProtocolV2Frame;
131
+ private handleProtocolV1Notification;
132
+ call(uuid: string, name: string, data: Record<string, unknown>, options?: TransportCallOptions): Promise<_onekeyfe_hd_transport.MessageFromOneKey>;
133
+ private callProtocolV1;
134
+ private callProtocolV2;
135
+ private processProtocolV1Notification;
136
+ getProtocolType(path: string): ProtocolType | undefined;
81
137
  }
82
138
 
83
139
  export { ElectronBleTransport, WebUsbTransport };