@onekeyfe/hd-transport-lowlevel 1.2.0-alpha.147 → 1.2.0-alpha.148

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.
@@ -249,7 +249,11 @@ describe('LowlevelTransport protocol framing', () => {
249
249
  );
250
250
  const plugin = createPlugin({
251
251
  devices: [{ id: 'pro2-id', name: 'OneKey Pro 2', commType: 'ble' }],
252
- responses: [...splitFrame(probeResponse, 4), ...splitFrame(callResponse, 5)],
252
+ responses: [
253
+ new Error('Protocol V1 probe timed out'),
254
+ ...splitFrame(probeResponse, 4),
255
+ ...splitFrame(callResponse, 5),
256
+ ],
253
257
  });
254
258
  const lowlevel = configureTransport(plugin);
255
259
 
@@ -269,9 +273,9 @@ describe('LowlevelTransport protocol framing', () => {
269
273
  },
270
274
  });
271
275
  expect(plugin.send).toHaveBeenCalled();
272
- const sentSeqs = plugin.send.mock.calls.map(([, hex]) =>
273
- Number.parseInt(hex.slice(12, 14), 16)
274
- );
276
+ const sentSeqs = plugin.send.mock.calls
277
+ .map(([, hex]) => Number.parseInt(hex.slice(12, 14), 16))
278
+ .filter(seq => seq > 0);
275
279
  expect(sentSeqs).toEqual([1, 2]);
276
280
  });
277
281
 
@@ -295,7 +299,7 @@ describe('LowlevelTransport protocol framing', () => {
295
299
  expect(lowlevel.getProtocolType('unknown-pro2-id')).toBe('V2');
296
300
  });
297
301
 
298
- test('retains the Protocol V2 hint and sequence cursor across release and reacquire', async () => {
302
+ test('detects Protocol V2 again after release without a name-derived hint', async () => {
299
303
  const probeResponse = ProtocolV2.encodeFrame(
300
304
  schemas,
301
305
  'Success',
@@ -304,7 +308,12 @@ describe('LowlevelTransport protocol framing', () => {
304
308
  );
305
309
  const plugin = createPlugin({
306
310
  devices: [{ id: 'reconnect-pro2-id', name: 'OneKey Pro 2', commType: 'ble' }],
307
- responses: [bytesToHex(probeResponse), bytesToHex(probeResponse)],
311
+ responses: [
312
+ new Error('Protocol V1 probe timed out'),
313
+ bytesToHex(probeResponse),
314
+ new Error('Protocol V1 probe timed out'),
315
+ bytesToHex(probeResponse),
316
+ ],
308
317
  });
309
318
  const lowlevel = configureTransport(plugin);
310
319
 
@@ -319,9 +328,9 @@ describe('LowlevelTransport protocol framing', () => {
319
328
  protocolType: 'V2',
320
329
  });
321
330
 
322
- const sentSeqs = plugin.send.mock.calls.map(([, hex]) =>
323
- Number.parseInt(hex.slice(12, 14), 16)
324
- );
331
+ const sentSeqs = plugin.send.mock.calls
332
+ .map(([, hex]) => Number.parseInt(hex.slice(12, 14), 16))
333
+ .filter(seq => seq > 0);
325
334
  expect(sentSeqs).toEqual([1, 2]);
326
335
  });
327
336
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as transport from '@onekeyfe/hd-transport';
2
- import transport__default, { ProtocolType, LowlevelTransportSharedPlugin, LowLevelDevice, TransportCallOptions } from '@onekeyfe/hd-transport';
2
+ import transport__default, { ProtocolType, LowlevelTransportSharedPlugin, TransportCallOptions } from '@onekeyfe/hd-transport';
3
3
  import EventEmitter from 'events';
4
4
 
5
5
  type LowLevelAcquireInput = {
@@ -36,7 +36,7 @@ declare class LowlevelTransport {
36
36
  configure(signedData: any): void;
37
37
  configureProtocolV2(signedData: any): void;
38
38
  listen(): void;
39
- enumerate(): Promise<LowLevelDevice[]>;
39
+ enumerate(): Promise<transport.LowLevelDevice[]>;
40
40
  acquire(input: LowLevelAcquireInput): Promise<{
41
41
  uuid: string;
42
42
  protocolType: ProtocolType;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,SAYN,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,YAAY,EAEZ,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,oBAAoB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;YAgBf,eAAe;YA6Bf,UAAU;YAUV,qBAAqB;YAmBrB,mBAAmB;YAqBnB,oBAAoB;YAgBpB,cAAc;IAwB5B,OAAO,CAAC,uBAAuB;IAgC/B,OAAO,CAAC,2BAA2B;IAMnC,MAAM;CAGP"}
package/dist/index.js CHANGED
@@ -53,9 +53,6 @@ function shouldLogFirmwareUploadProgress({ percent, lastLoggedPercent, now, last
53
53
  function getProtocolV1SendOptions(name) {
54
54
  return name === 'FirmwareUpload' ? { withoutResponse: false } : undefined;
55
55
  }
56
- function inferProtocolHintFromDeviceName(name) {
57
- return /\bpro\s*2\b/i.test(name !== null && name !== void 0 ? name : '') ? 'V2' : undefined;
58
- }
59
56
  function isProtocolV1TransportChunk(data) {
60
57
  return data.length >= 9 && data[0] === 0x3f && data[1] === 0x23 && data[2] === 0x23;
61
58
  }
@@ -135,13 +132,7 @@ class LowlevelTransport {
135
132
  enumerate() {
136
133
  return __awaiter(this, void 0, void 0, function* () {
137
134
  const devices = yield this.plugin.enumerate();
138
- return devices.map((device) => {
139
- const protocolHint = inferProtocolHintFromDeviceName(device.name);
140
- if (protocolHint) {
141
- this.deviceProtocolHints.set(device.id, protocolHint);
142
- }
143
- return device;
144
- });
135
+ return devices;
145
136
  });
146
137
  }
147
138
  acquire(input) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-lowlevel",
3
- "version": "1.2.0-alpha.147",
3
+ "version": "1.2.0-alpha.148",
4
4
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,8 +20,8 @@
20
20
  "lint:fix": "eslint . --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@onekeyfe/hd-shared": "1.2.0-alpha.147",
24
- "@onekeyfe/hd-transport": "1.2.0-alpha.147"
23
+ "@onekeyfe/hd-shared": "1.2.0-alpha.148",
24
+ "@onekeyfe/hd-transport": "1.2.0-alpha.148"
25
25
  },
26
- "gitHead": "a34e98865e6be227cf3e00d486146e6592761db0"
26
+ "gitHead": "0538b18c48292741d9b7c29a87851227bc3e229b"
27
27
  }
package/src/index.ts CHANGED
@@ -15,7 +15,6 @@ import transport, {
15
15
 
16
16
  import type EventEmitter from 'events';
17
17
  import type {
18
- LowLevelDevice,
19
18
  LowlevelTransportSharedPlugin,
20
19
  ProtocolType,
21
20
  ProtocolV2CallContext,
@@ -53,10 +52,6 @@ export function getProtocolV1SendOptions(name: string) {
53
52
  return name === 'FirmwareUpload' ? { withoutResponse: false } : undefined;
54
53
  }
55
54
 
56
- function inferProtocolHintFromDeviceName(name?: string | null): ProtocolType | undefined {
57
- return /\bpro\s*2\b/i.test(name ?? '') ? 'V2' : undefined;
58
- }
59
-
60
55
  function isProtocolV1TransportChunk(data: Uint8Array) {
61
56
  return data.length >= 9 && data[0] === 0x3f && data[1] === 0x23 && data[2] === 0x23;
62
57
  }
@@ -161,13 +156,7 @@ export default class LowlevelTransport {
161
156
 
162
157
  async enumerate() {
163
158
  const devices = await this.plugin.enumerate();
164
- return devices.map((device: LowLevelDevice) => {
165
- const protocolHint = inferProtocolHintFromDeviceName(device.name);
166
- if (protocolHint) {
167
- this.deviceProtocolHints.set(device.id, protocolHint);
168
- }
169
- return device;
170
- });
159
+ return devices;
171
160
  }
172
161
 
173
162
  async acquire(input: LowLevelAcquireInput) {
@@ -227,8 +216,7 @@ export default class LowlevelTransport {
227
216
  await this.plugin.disconnect(uuid);
228
217
  this.connectedDevices.delete(uuid);
229
218
  this.deviceProtocol.delete(uuid);
230
- // A name-derived protocol hint survives disconnect and lets fast reconnect probe
231
- // Protocol V2 first without sending a redundant V1 Initialize.
219
+ // Confirmed protocol stays on the device endpoint; BLE names are not a probe hint.
232
220
  this.protocolV2Assemblers.delete(uuid);
233
221
  return true;
234
222
  } catch (error) {