@onekeyfe/hd-transport-electron 1.2.0-alpha.151 → 1.2.0-alpha.153

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.
@@ -32,7 +32,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
32
32
 
33
33
  function initNobleBleSupport(webContents) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
- const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-efd3df55.js'); });
35
+ const { setupNobleBleHandlers } = yield Promise.resolve().then(function () { return require('./noble-ble-handler-78adadea.js'); });
36
36
  setupNobleBleHandlers(webContents);
37
37
  });
38
38
  }
package/dist/index.d.ts CHANGED
@@ -24,6 +24,7 @@ interface NobleModule {
24
24
  interface Logger {
25
25
  info(message: string, ...args: any[]): void;
26
26
  debug(message: string, ...args: any[]): void;
27
+ warn(message: string, ...args: any[]): void;
27
28
  error(message: string, ...args: any[]): void;
28
29
  }
29
30
 
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-70b4a97d.js');
5
+ var index = require('./index-c28cc24a.js');
6
6
 
7
7
 
8
8
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-70b4a97d.js');
3
+ var index = require('./index-c28cc24a.js');
4
4
  var hdShared = require('@onekeyfe/hd-shared');
5
5
  var pRetry = require('p-retry');
6
6
 
@@ -116,6 +116,7 @@ const DEVICE_SCAN_TIMEOUT = 5000;
116
116
  const DEVICE_CHECK_INTERVAL = 500;
117
117
  const SERVICE_DISCOVERY_TIMEOUT = 10000;
118
118
  const BLE_CLEANUP_TIMEOUT = 250;
119
+ const BLE_DISCONNECT_CONFIRM_TIMEOUT_MS = 3000;
119
120
  const BLE_IDLE_DISCONNECT_MS = 3 * 60000;
120
121
  const BLE_BUSY_BACKSTOP_MS = 10 * 60000;
121
122
  const BLE_PACKET_SIZE_FALLBACK = 192;
@@ -336,7 +337,14 @@ function armIdleDisconnect(deviceId, ms = BLE_IDLE_DISCONNECT_MS, reason = 'idle
336
337
  logger === null || logger === void 0 ? void 0 : logger.info('[NobleBLE] Keep-alive timeout, disconnecting device', { deviceId, reason });
337
338
  const peripheral = connectedDevices.get(deviceId);
338
339
  const deviceName = ((_a = peripheral === null || peripheral === void 0 ? void 0 : peripheral.advertisement) === null || _a === void 0 ? void 0 : _a.localName) || 'Unknown Device';
339
- const pending = disconnectDevice(deviceId)
340
+ const pending = unsubscribeNotifications(deviceId)
341
+ .catch(error => {
342
+ logger === null || logger === void 0 ? void 0 : logger.warn('[NobleBLE] Keep-alive unsubscribe failed, disconnecting anyway', {
343
+ deviceId,
344
+ error: error instanceof Error ? error.message : String(error),
345
+ });
346
+ })
347
+ .then(() => disconnectDevice(deviceId))
340
348
  .then(() => {
341
349
  broadcastToAllWebContents(hdShared.EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, {
342
350
  id: deviceId,
@@ -1175,9 +1183,12 @@ function disconnectDevice(deviceId) {
1175
1183
  deviceDisconnectListeners.delete(deviceId);
1176
1184
  }
1177
1185
  yield runBleCallbackOperation(callback => peripheral.disconnect(() => callback()), {
1178
- timeoutMs: BLE_CLEANUP_TIMEOUT,
1186
+ timeoutMs: BLE_DISCONNECT_CONFIRM_TIMEOUT_MS,
1179
1187
  timeoutBehavior: 'resolve',
1180
1188
  });
1189
+ if (peripheral.state === 'connected') {
1190
+ logger === null || logger === void 0 ? void 0 : logger.warn('[NobleBLE] Physical disconnect did not confirm in time', { deviceId });
1191
+ }
1181
1192
  cleanupDevice(deviceId, undefined, {
1182
1193
  cleanupConnection: true,
1183
1194
  cleanupDiscoveredCache: true,
@@ -1 +1 @@
1
- {"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AA0EhE,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE,oBAAoB,UAI7E;AAumDD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAkMpE"}
1
+ {"version":3,"file":"noble-ble-handler.d.ts","sourceRoot":"","sources":["../src/noble-ble-handler.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAA+B,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AA8EhE,wBAAgB,+BAA+B,CAAC,OAAO,CAAC,EAAE,oBAAoB,UAI7E;AAwnDD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAkMpE"}
@@ -22,6 +22,7 @@ export interface NobleModule {
22
22
  export interface Logger {
23
23
  info(message: string, ...args: any[]): void;
24
24
  debug(message: string, ...args: any[]): void;
25
+ warn(message: string, ...args: any[]): void;
25
26
  error(message: string, ...args: any[]): void;
26
27
  }
27
28
  export declare function safeLog(logger: Logger | null, level: 'info' | 'debug' | 'error', message: string, ...args: any[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"noble-extended.d.ts","sourceRoot":"","sources":["../../src/types/noble-extended.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,MAAM,WAAW,UAAW,SAAQ,oBAAoB;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAGD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,E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,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC9C;AAGD,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,EACjC,OAAO,EAAE,MAAM,EACf,GAAG,IAAI,EAAE,GAAG,EAAE,GACb,IAAI,CAMN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-electron",
3
- "version": "1.2.0-alpha.151",
3
+ "version": "1.2.0-alpha.153",
4
4
  "author": "OneKey",
5
5
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
6
6
  "license": "MIT",
@@ -25,9 +25,9 @@
25
25
  "electron-log": ">=4.0.0"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-core": "1.2.0-alpha.151",
29
- "@onekeyfe/hd-shared": "1.2.0-alpha.151",
30
- "@onekeyfe/hd-transport": "1.2.0-alpha.151",
28
+ "@onekeyfe/hd-core": "1.2.0-alpha.153",
29
+ "@onekeyfe/hd-shared": "1.2.0-alpha.153",
30
+ "@onekeyfe/hd-transport": "1.2.0-alpha.153",
31
31
  "@stoprocent/noble": "2.3.16",
32
32
  "p-retry": "^4.6.2"
33
33
  },
@@ -36,5 +36,5 @@
36
36
  "electron": "^25.0.0",
37
37
  "typescript": "^5.3.3"
38
38
  },
39
- "gitHead": "d1fa81c92deb1bfa3903e3963a82edd6384d568a"
39
+ "gitHead": "2544b0bde0835515911c2c1b8c8b631788557300"
40
40
  }
@@ -89,6 +89,10 @@ const DEVICE_SCAN_TIMEOUT = 5000; // 5 seconds for device scanning
89
89
  const DEVICE_CHECK_INTERVAL = 500; // 500ms interval for periodic device checks
90
90
  const SERVICE_DISCOVERY_TIMEOUT = 10000; // 10 seconds for service discovery
91
91
  const BLE_CLEANUP_TIMEOUT = 250;
92
+ // A physical teardown must actually reach the OS before the device can return
93
+ // to a clean state; 250ms routinely declared success while CoreBluetooth was
94
+ // still disconnecting, leaving no trace when the teardown never completed.
95
+ const BLE_DISCONNECT_CONFIRM_TIMEOUT_MS = 3000;
92
96
  // Renderer release is logical only; this timer physically frees the device.
93
97
  const BLE_IDLE_DISCONNECT_MS = 3 * 60_000;
94
98
  // Ceiling while a call is in flight: no outstanding write, but not forever.
@@ -393,7 +397,21 @@ function armIdleDisconnect(
393
397
  logger?.info('[NobleBLE] Keep-alive timeout, disconnecting device', { deviceId, reason });
394
398
  const peripheral = connectedDevices.get(deviceId);
395
399
  const deviceName = peripheral?.advertisement?.localName || 'Unknown Device';
396
- const pending = disconnectDevice(deviceId)
400
+ // Unsubscribe CCCD before dropping the link, matching every other
401
+ // teardown path: the 1S leaves its notify session half-open when the
402
+ // link drops without an unsubscribe and then ignores application
403
+ // protocol traffic on NEW links for tens of minutes (field log
404
+ // 2026-08-19: the lone unsubscribe-skipping idle teardown caused a
405
+ // 6-attempt reconnect loop; unsubscribe-first teardowns reconnected
406
+ // instantly).
407
+ const pending = unsubscribeNotifications(deviceId)
408
+ .catch(error => {
409
+ logger?.warn('[NobleBLE] Keep-alive unsubscribe failed, disconnecting anyway', {
410
+ deviceId,
411
+ error: error instanceof Error ? error.message : String(error),
412
+ });
413
+ })
414
+ .then(() => disconnectDevice(deviceId))
397
415
  .then(() => {
398
416
  // A call is still in flight here; it must reject, not hang.
399
417
  broadcastToAllWebContents(EOneKeyBleMessageKeys.BLE_DEVICE_DISCONNECTED, {
@@ -1588,9 +1606,12 @@ async function disconnectDevice(deviceId: string): Promise<void> {
1588
1606
  }
1589
1607
 
1590
1608
  await runBleCallbackOperation(callback => peripheral.disconnect(() => callback()), {
1591
- timeoutMs: BLE_CLEANUP_TIMEOUT,
1609
+ timeoutMs: BLE_DISCONNECT_CONFIRM_TIMEOUT_MS,
1592
1610
  timeoutBehavior: 'resolve',
1593
1611
  });
1612
+ if (peripheral.state === 'connected') {
1613
+ logger?.warn('[NobleBLE] Physical disconnect did not confirm in time', { deviceId });
1614
+ }
1594
1615
  cleanupDevice(deviceId, undefined, {
1595
1616
  cleanupConnection: true,
1596
1617
  // macOS returns zero GATT services when a previously-disconnected
@@ -39,6 +39,7 @@ export interface NobleModule {
39
39
  export interface Logger {
40
40
  info(message: string, ...args: any[]): void;
41
41
  debug(message: string, ...args: any[]): void;
42
+ warn(message: string, ...args: any[]): void;
42
43
  error(message: string, ...args: any[]): void;
43
44
  }
44
45