@onekeyfe/hd-transport-web-device 1.2.0-alpha.113 → 1.2.0-alpha.114

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.
@@ -299,7 +299,7 @@ describe('ElectronBleTransport protocol detection', () => {
299
299
  }
300
300
  });
301
301
 
302
- test('reconnects Protocol V1 with a non-destructive GetFeatures probe', async () => {
302
+ test('reconnects Protocol V1 with an Initialize probe', async () => {
303
303
  const device = { id: 'classic-id', name: 'OneKey Classic' };
304
304
  const nobleBle = createNobleBle(device);
305
305
  let notificationHandler: ((deviceId: string, data: string) => void) | undefined;
@@ -313,7 +313,7 @@ describe('ElectronBleTransport protocol detection', () => {
313
313
  return jest.fn();
314
314
  });
315
315
  nobleBle.write.mockImplementation(() => {
316
- // The first write is the V1 GetFeatures probe; answer with a V1 Success response.
316
+ // The first write is the V1 Initialize probe; answer with a V1 Success response.
317
317
  setTimeout(() => notificationHandler?.(device.id, v1ResponseHex), 0);
318
318
  return Promise.resolve();
319
319
  });
@@ -333,7 +333,7 @@ describe('ElectronBleTransport protocol detection', () => {
333
333
  })
334
334
  );
335
335
  expect(nobleBle.write).toHaveBeenCalledTimes(2);
336
- expect(nobleBle.write.mock.calls.every(([, hex]) => /^3f23230037/.test(hex))).toBe(true);
336
+ expect(nobleBle.write.mock.calls.every(([, hex]) => /^3f23230001/.test(hex))).toBe(true);
337
337
  expect(protocolV2Writer).not.toHaveBeenCalled();
338
338
  } finally {
339
339
  await transport.release(device.id);
@@ -1 +1 @@
1
- {"version":3,"file":"electron-ble-transport.d.ts","sourceRoot":"","sources":["../src/electron-ble-transport.ts"],"names":[],"mappings":";AAsBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EAEZ,oBAAoB,EACrB,MAAM,wBAAwB,CA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AShB,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;YAuBlB,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
@@ -161,7 +161,7 @@ type BleAcquireInput = {
161
161
  * Desktop Electron BLE transport with automatic Protocol V1/V2 detection.
162
162
  *
163
163
  * Protocol V1 devices continue using chunked packets. Protocol V2 is detected
164
- * after a Protocol V1 GetFeatures timeout by probing Protocol V2 Ping.
164
+ * after a Protocol V1 Initialize timeout by probing Protocol V2 Ping.
165
165
  */
166
166
  declare class ElectronBleTransport {
167
167
  private _messages;
package/dist/index.js CHANGED
@@ -1052,7 +1052,7 @@ class ElectronBleTransport {
1052
1052
  return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Device protocol mismatch: expected ${expected}, but device did not respond to expected protocol`);
1053
1053
  }
1054
1054
  createProtocolDetectionError() {
1055
- return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, 'Unable to detect BLE protocol: device did not respond to Protocol V1 GetFeatures or Protocol V2 Ping');
1055
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleTimeoutError, 'Unable to detect BLE protocol: device did not respond to Protocol V1 Initialize or Protocol V2 Ping');
1056
1056
  }
1057
1057
  clearProbeProtocol(uuid, protocol) {
1058
1058
  if (this.deviceProtocol.get(uuid) === protocol) {
@@ -1163,12 +1163,12 @@ class ElectronBleTransport {
1163
1163
  }
1164
1164
  try {
1165
1165
  this.deviceProtocol.set(uuid, 'V1');
1166
- yield this.callProtocolV1(uuid, 'GetFeatures', {}, { timeoutMs: PROTOCOL_PROBE_TIMEOUT_MS });
1166
+ yield this.callProtocolV1(uuid, 'Initialize', {}, { timeoutMs: PROTOCOL_PROBE_TIMEOUT_MS });
1167
1167
  return true;
1168
1168
  }
1169
1169
  catch (error) {
1170
1170
  this.clearProbeProtocol(uuid, 'V1');
1171
- (_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug('[Electron BLE] Protocol V1 GetFeatures probe failed:', error);
1171
+ (_a = this.Log) === null || _a === void 0 ? void 0 : _a.debug('[Electron BLE] Protocol V1 Initialize probe failed:', error);
1172
1172
  return false;
1173
1173
  }
1174
1174
  });
@@ -1428,7 +1428,7 @@ class ElectronBleTransport {
1428
1428
  }
1429
1429
  catch (e) {
1430
1430
  (_b = this.Log) === null || _b === void 0 ? void 0 : _b.error('[Electron BLE] Protocol V1 call error:', e);
1431
- const isProbeTimeout = name === 'GetFeatures' && (options === null || options === void 0 ? void 0 : options.timeoutMs) === PROTOCOL_PROBE_TIMEOUT_MS;
1431
+ const isProbeTimeout = name === 'Initialize' && (options === null || options === void 0 ? void 0 : options.timeoutMs) === PROTOCOL_PROBE_TIMEOUT_MS;
1432
1432
  if ((e === null || e === void 0 ? void 0 : e.errorCode) === hdShared.HardwareErrorCode.BleTimeoutError) {
1433
1433
  this.v1Buffers.set(uuid, { buffer: [], bufferLength: 0 });
1434
1434
  const notifyCleanup = this.notificationCleanups.get(uuid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-web-device",
3
- "version": "1.2.0-alpha.113",
3
+ "version": "1.2.0-alpha.114",
4
4
  "author": "OneKey",
5
5
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
6
6
  "license": "MIT",
@@ -21,13 +21,13 @@
21
21
  "lint:fix": "eslint . --fix"
22
22
  },
23
23
  "dependencies": {
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.113",
25
- "@onekeyfe/hd-transport": "1.2.0-alpha.113"
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.114",
25
+ "@onekeyfe/hd-transport": "1.2.0-alpha.114"
26
26
  },
27
27
  "devDependencies": {
28
- "@onekeyfe/hd-transport-electron": "1.2.0-alpha.113",
28
+ "@onekeyfe/hd-transport-electron": "1.2.0-alpha.114",
29
29
  "@types/w3c-web-usb": "^1.0.6",
30
30
  "@types/web-bluetooth": "^0.0.17"
31
31
  },
32
- "gitHead": "859d0105877f964acb536cd6f337d2d3999d22d5"
32
+ "gitHead": "7035991e1c0237e375dec03e5b9d99f45d4aa550"
33
33
  }
@@ -78,7 +78,7 @@ const PROTOCOL_V2_PROBE_TIMEOUT_MS = 5000;
78
78
  * Desktop Electron BLE transport with automatic Protocol V1/V2 detection.
79
79
  *
80
80
  * Protocol V1 devices continue using chunked packets. Protocol V2 is detected
81
- * after a Protocol V1 GetFeatures timeout by probing Protocol V2 Ping.
81
+ * after a Protocol V1 Initialize timeout by probing Protocol V2 Ping.
82
82
  */
83
83
  export default class ElectronBleTransport {
84
84
  private _messages: ReturnType<typeof transport.parseConfigure> | undefined;
@@ -452,7 +452,7 @@ export default class ElectronBleTransport {
452
452
  private createProtocolDetectionError() {
453
453
  return ERRORS.TypedError(
454
454
  HardwareErrorCode.BleTimeoutError,
455
- 'Unable to detect BLE protocol: device did not respond to Protocol V1 GetFeatures or Protocol V2 Ping'
455
+ 'Unable to detect BLE protocol: device did not respond to Protocol V1 Initialize or Protocol V2 Ping'
456
456
  );
457
457
  }
458
458
 
@@ -579,13 +579,11 @@ export default class ElectronBleTransport {
579
579
 
580
580
  try {
581
581
  this.deviceProtocol.set(uuid, 'V1');
582
- // GetFeatures identifies Protocol V1 without resetting an existing wallet
583
- // session before Core has a chance to restore a hidden wallet.
584
- await this.callProtocolV1(uuid, 'GetFeatures', {}, { timeoutMs: PROTOCOL_PROBE_TIMEOUT_MS });
582
+ await this.callProtocolV1(uuid, 'Initialize', {}, { timeoutMs: PROTOCOL_PROBE_TIMEOUT_MS });
585
583
  return true;
586
584
  } catch (error) {
587
585
  this.clearProbeProtocol(uuid, 'V1');
588
- this.Log?.debug('[Electron BLE] Protocol V1 GetFeatures probe failed:', error);
586
+ this.Log?.debug('[Electron BLE] Protocol V1 Initialize probe failed:', error);
589
587
  return false;
590
588
  }
591
589
  }
@@ -875,7 +873,7 @@ export default class ElectronBleTransport {
875
873
  } catch (e) {
876
874
  this.Log?.error('[Electron BLE] Protocol V1 call error:', e);
877
875
  const isProbeTimeout =
878
- name === 'GetFeatures' && options?.timeoutMs === PROTOCOL_PROBE_TIMEOUT_MS;
876
+ name === 'Initialize' && options?.timeoutMs === PROTOCOL_PROBE_TIMEOUT_MS;
879
877
  if ((e as { errorCode?: unknown })?.errorCode === HardwareErrorCode.BleTimeoutError) {
880
878
  this.v1Buffers.set(uuid, { buffer: [], bufferLength: 0 });
881
879
  const notifyCleanup = this.notificationCleanups.get(uuid);