@onekeyfe/hwk-desktop-noble-ble 1.2.11-alpha.2 → 1.2.11-alpha.4

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.
@@ -23,12 +23,6 @@ var THIRD_PARTY_BLE_CHANNELS = {
23
23
  /** push event: main → renderer when device disconnects unexpectedly */
24
24
  disconnected: "$onekey-3p-ble-disconnected"
25
25
  };
26
- var THIRD_PARTY_BLE_IPC_ERROR_TYPE = "ThirdPartyBleIpcError";
27
- function isThirdPartyBleIpcErrorResponse(response) {
28
- if (!response || typeof response !== "object") return false;
29
- const candidate = response;
30
- return candidate.type === THIRD_PARTY_BLE_IPC_ERROR_TYPE && candidate.success === false && typeof candidate.error?.message === "string";
31
- }
32
26
  var THIRD_PARTY_BLE_SCAN_DURATION_MS = 5e3;
33
27
  var THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 1e4;
34
28
  var THIRD_PARTY_BLE_DEVICE_TTL_MS = 5e3;
@@ -38,12 +32,10 @@ var THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3e3;
38
32
  export {
39
33
  __require,
40
34
  THIRD_PARTY_BLE_CHANNELS,
41
- THIRD_PARTY_BLE_IPC_ERROR_TYPE,
42
- isThirdPartyBleIpcErrorResponse,
43
35
  THIRD_PARTY_BLE_SCAN_DURATION_MS,
44
36
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
45
37
  THIRD_PARTY_BLE_DEVICE_TTL_MS,
46
38
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
47
39
  THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
48
40
  };
49
- //# sourceMappingURL=chunk-O6YS25TV.mjs.map
41
+ //# sourceMappingURL=chunk-ILABAQJY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to\n * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.\n */\nexport const THIRD_PARTY_BLE_CHANNELS = {\n scan: '$onekey-3p-ble-scan',\n stopScan: '$onekey-3p-ble-stop-scan',\n connect: '$onekey-3p-ble-connect',\n disconnect: '$onekey-3p-ble-disconnect',\n write: '$onekey-3p-ble-write',\n subscribe: '$onekey-3p-ble-subscribe',\n unsubscribe: '$onekey-3p-ble-unsubscribe',\n availability: '$onekey-3p-ble-availability',\n getDevice: '$onekey-3p-ble-get-device',\n readRssi: '$onekey-3p-ble-read-rssi',\n cancelPairing: '$onekey-3p-ble-cancel-pairing',\n /** push event: main → renderer with assembled BLE notification payload */\n notification: '$onekey-3p-ble-notification',\n /** push event: main → renderer when device disconnects unexpectedly */\n disconnected: '$onekey-3p-ble-disconnected',\n} as const;\n\nexport type ThirdPartyBleChannel =\n (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];\n\n/** Reconnect scan window for `connect(id)`. */\nexport const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5_000;\n\n/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */\nexport const THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 10_000;\n\n/** Drop a device from the snapshot if it hasn't re-advertised within this window. */\nexport const THIRD_PARTY_BLE_DEVICE_TTL_MS = 5_000;\n\n/** Time we'll wait for noble to reach `poweredOn` before failing init. */\nexport const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10_000;\n\n/** Time an availability check waits for a fresh noble to report its first state. */\nexport const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3_000;\n"],"mappings":";;;;;;;;AAIO,IAAM,2BAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AAAA;AAAA,EAEf,cAAc;AAAA;AAAA,EAEd,cAAc;AAChB;AAMO,IAAM,mCAAmC;AAGzC,IAAM,oCAAoC;AAG1C,IAAM,gCAAgC;AAGtC,IAAM,sCAAsC;AAG5C,IAAM,0CAA0C;","names":[]}
@@ -1,5 +1,3 @@
1
- import { ConnectorSerializedError } from '@onekeyfe/hwk-adapter-core';
2
-
3
1
  /**
4
2
  * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to
5
3
  * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.
@@ -22,15 +20,6 @@ declare const THIRD_PARTY_BLE_CHANNELS: {
22
20
  readonly disconnected: "$onekey-3p-ble-disconnected";
23
21
  };
24
22
  type ThirdPartyBleChannel = (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];
25
- declare const THIRD_PARTY_BLE_IPC_ERROR_TYPE = "ThirdPartyBleIpcError";
26
- /** What a handler wrapped by `withThirdPartyBleIpcErrors` returns instead of throwing. */
27
- interface ThirdPartyBleIpcErrorResponse {
28
- type: typeof THIRD_PARTY_BLE_IPC_ERROR_TYPE;
29
- success: false;
30
- error: ConnectorSerializedError;
31
- }
32
- /** For the preload, which imports this entry: rethrow `response.error` when this matches. */
33
- declare function isThirdPartyBleIpcErrorResponse(response: unknown): response is ThirdPartyBleIpcErrorResponse;
34
23
  /** Reconnect scan window for `connect(id)`. */
35
24
  declare const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5000;
36
25
  /** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */
@@ -42,4 +31,4 @@ declare const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10000;
42
31
  /** Time an availability check waits for a fresh noble to report its first state. */
43
32
  declare const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3000;
44
33
 
45
- export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_IPC_ERROR_TYPE, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS, type ThirdPartyBleChannel, type ThirdPartyBleIpcErrorResponse, isThirdPartyBleIpcErrorResponse };
34
+ export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS, type ThirdPartyBleChannel };
@@ -1,5 +1,3 @@
1
- import { ConnectorSerializedError } from '@onekeyfe/hwk-adapter-core';
2
-
3
1
  /**
4
2
  * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to
5
3
  * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.
@@ -22,15 +20,6 @@ declare const THIRD_PARTY_BLE_CHANNELS: {
22
20
  readonly disconnected: "$onekey-3p-ble-disconnected";
23
21
  };
24
22
  type ThirdPartyBleChannel = (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];
25
- declare const THIRD_PARTY_BLE_IPC_ERROR_TYPE = "ThirdPartyBleIpcError";
26
- /** What a handler wrapped by `withThirdPartyBleIpcErrors` returns instead of throwing. */
27
- interface ThirdPartyBleIpcErrorResponse {
28
- type: typeof THIRD_PARTY_BLE_IPC_ERROR_TYPE;
29
- success: false;
30
- error: ConnectorSerializedError;
31
- }
32
- /** For the preload, which imports this entry: rethrow `response.error` when this matches. */
33
- declare function isThirdPartyBleIpcErrorResponse(response: unknown): response is ThirdPartyBleIpcErrorResponse;
34
23
  /** Reconnect scan window for `connect(id)`. */
35
24
  declare const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5000;
36
25
  /** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */
@@ -42,4 +31,4 @@ declare const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10000;
42
31
  /** Time an availability check waits for a fresh noble to report its first state. */
43
32
  declare const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3000;
44
33
 
45
- export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_IPC_ERROR_TYPE, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS, type ThirdPartyBleChannel, type ThirdPartyBleIpcErrorResponse, isThirdPartyBleIpcErrorResponse };
34
+ export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS, type ThirdPartyBleChannel };
package/dist/constants.js CHANGED
@@ -22,12 +22,10 @@ var constants_exports = {};
22
22
  __export(constants_exports, {
23
23
  THIRD_PARTY_BLE_CHANNELS: () => THIRD_PARTY_BLE_CHANNELS,
24
24
  THIRD_PARTY_BLE_DEVICE_TTL_MS: () => THIRD_PARTY_BLE_DEVICE_TTL_MS,
25
- THIRD_PARTY_BLE_IPC_ERROR_TYPE: () => THIRD_PARTY_BLE_IPC_ERROR_TYPE,
26
25
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS: () => THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
27
26
  THIRD_PARTY_BLE_SCAN_DURATION_MS: () => THIRD_PARTY_BLE_SCAN_DURATION_MS,
28
27
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS: () => THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
29
- THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS: () => THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS,
30
- isThirdPartyBleIpcErrorResponse: () => isThirdPartyBleIpcErrorResponse
28
+ THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS: () => THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
31
29
  });
32
30
  module.exports = __toCommonJS(constants_exports);
33
31
  var THIRD_PARTY_BLE_CHANNELS = {
@@ -47,12 +45,6 @@ var THIRD_PARTY_BLE_CHANNELS = {
47
45
  /** push event: main → renderer when device disconnects unexpectedly */
48
46
  disconnected: "$onekey-3p-ble-disconnected"
49
47
  };
50
- var THIRD_PARTY_BLE_IPC_ERROR_TYPE = "ThirdPartyBleIpcError";
51
- function isThirdPartyBleIpcErrorResponse(response) {
52
- if (!response || typeof response !== "object") return false;
53
- const candidate = response;
54
- return candidate.type === THIRD_PARTY_BLE_IPC_ERROR_TYPE && candidate.success === false && typeof candidate.error?.message === "string";
55
- }
56
48
  var THIRD_PARTY_BLE_SCAN_DURATION_MS = 5e3;
57
49
  var THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 1e4;
58
50
  var THIRD_PARTY_BLE_DEVICE_TTL_MS = 5e3;
@@ -62,11 +54,9 @@ var THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3e3;
62
54
  0 && (module.exports = {
63
55
  THIRD_PARTY_BLE_CHANNELS,
64
56
  THIRD_PARTY_BLE_DEVICE_TTL_MS,
65
- THIRD_PARTY_BLE_IPC_ERROR_TYPE,
66
57
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
67
58
  THIRD_PARTY_BLE_SCAN_DURATION_MS,
68
59
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
69
- THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS,
70
- isThirdPartyBleIpcErrorResponse
60
+ THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
71
61
  });
72
62
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["import type { ConnectorSerializedError } from '@onekeyfe/hwk-adapter-core';\n\n/**\n * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to\n * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.\n */\nexport const THIRD_PARTY_BLE_CHANNELS = {\n scan: '$onekey-3p-ble-scan',\n stopScan: '$onekey-3p-ble-stop-scan',\n connect: '$onekey-3p-ble-connect',\n disconnect: '$onekey-3p-ble-disconnect',\n write: '$onekey-3p-ble-write',\n subscribe: '$onekey-3p-ble-subscribe',\n unsubscribe: '$onekey-3p-ble-unsubscribe',\n availability: '$onekey-3p-ble-availability',\n getDevice: '$onekey-3p-ble-get-device',\n readRssi: '$onekey-3p-ble-read-rssi',\n cancelPairing: '$onekey-3p-ble-cancel-pairing',\n /** push event: main → renderer with assembled BLE notification payload */\n notification: '$onekey-3p-ble-notification',\n /** push event: main → renderer when device disconnects unexpectedly */\n disconnected: '$onekey-3p-ble-disconnected',\n} as const;\n\nexport type ThirdPartyBleChannel =\n (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];\n\nexport const THIRD_PARTY_BLE_IPC_ERROR_TYPE = 'ThirdPartyBleIpcError';\n\n/** What a handler wrapped by `withThirdPartyBleIpcErrors` returns instead of throwing. */\nexport interface ThirdPartyBleIpcErrorResponse {\n type: typeof THIRD_PARTY_BLE_IPC_ERROR_TYPE;\n success: false;\n error: ConnectorSerializedError;\n}\n\n/** For the preload, which imports this entry: rethrow `response.error` when this matches. */\nexport function isThirdPartyBleIpcErrorResponse(\n response: unknown\n): response is ThirdPartyBleIpcErrorResponse {\n if (!response || typeof response !== 'object') return false;\n const candidate = response as Partial<ThirdPartyBleIpcErrorResponse>;\n return (\n candidate.type === THIRD_PARTY_BLE_IPC_ERROR_TYPE &&\n candidate.success === false &&\n typeof candidate.error?.message === 'string'\n );\n}\n\n/** Reconnect scan window for `connect(id)`. */\nexport const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5_000;\n\n/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */\nexport const THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 10_000;\n\n/** Drop a device from the snapshot if it hasn't re-advertised within this window. */\nexport const THIRD_PARTY_BLE_DEVICE_TTL_MS = 5_000;\n\n/** Time we'll wait for noble to reach `poweredOn` before failing init. */\nexport const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10_000;\n\n/** Time an availability check waits for a fresh noble to report its first state. */\nexport const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3_000;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,2BAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AAAA;AAAA,EAEf,cAAc;AAAA;AAAA,EAEd,cAAc;AAChB;AAKO,IAAM,iCAAiC;AAUvC,SAAS,gCACd,UAC2C;AAC3C,MAAI,CAAC,YAAY,OAAO,aAAa,SAAU,QAAO;AACtD,QAAM,YAAY;AAClB,SACE,UAAU,SAAS,kCACnB,UAAU,YAAY,SACtB,OAAO,UAAU,OAAO,YAAY;AAExC;AAGO,IAAM,mCAAmC;AAGzC,IAAM,oCAAoC;AAG1C,IAAM,gCAAgC;AAGtC,IAAM,sCAAsC;AAG5C,IAAM,0CAA0C;","names":[]}
1
+ {"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Renderer/main IPC channels shared by every third-party BLE vendor; prefixed to\n * avoid clashing with the OneKey handler (`$onekey-noble-ble-*`) in one app.\n */\nexport const THIRD_PARTY_BLE_CHANNELS = {\n scan: '$onekey-3p-ble-scan',\n stopScan: '$onekey-3p-ble-stop-scan',\n connect: '$onekey-3p-ble-connect',\n disconnect: '$onekey-3p-ble-disconnect',\n write: '$onekey-3p-ble-write',\n subscribe: '$onekey-3p-ble-subscribe',\n unsubscribe: '$onekey-3p-ble-unsubscribe',\n availability: '$onekey-3p-ble-availability',\n getDevice: '$onekey-3p-ble-get-device',\n readRssi: '$onekey-3p-ble-read-rssi',\n cancelPairing: '$onekey-3p-ble-cancel-pairing',\n /** push event: main → renderer with assembled BLE notification payload */\n notification: '$onekey-3p-ble-notification',\n /** push event: main → renderer when device disconnects unexpectedly */\n disconnected: '$onekey-3p-ble-disconnected',\n} as const;\n\nexport type ThirdPartyBleChannel =\n (typeof THIRD_PARTY_BLE_CHANNELS)[keyof typeof THIRD_PARTY_BLE_CHANNELS];\n\n/** Reconnect scan window for `connect(id)`. */\nexport const THIRD_PARTY_BLE_SCAN_DURATION_MS = 5_000;\n\n/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */\nexport const THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS = 10_000;\n\n/** Drop a device from the snapshot if it hasn't re-advertised within this window. */\nexport const THIRD_PARTY_BLE_DEVICE_TTL_MS = 5_000;\n\n/** Time we'll wait for noble to reach `poweredOn` before failing init. */\nexport const THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS = 10_000;\n\n/** Time an availability check waits for a fresh noble to report its first state. */\nexport const THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS = 3_000;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,IAAM,2BAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAAA,EACd,WAAW;AAAA,EACX,UAAU;AAAA,EACV,eAAe;AAAA;AAAA,EAEf,cAAc;AAAA;AAAA,EAEd,cAAc;AAChB;AAMO,IAAM,mCAAmC;AAGzC,IAAM,oCAAoC;AAG1C,IAAM,gCAAgC;AAGtC,IAAM,sCAAsC;AAG5C,IAAM,0CAA0C;","names":[]}
@@ -1,21 +1,17 @@
1
1
  import {
2
2
  THIRD_PARTY_BLE_CHANNELS,
3
3
  THIRD_PARTY_BLE_DEVICE_TTL_MS,
4
- THIRD_PARTY_BLE_IPC_ERROR_TYPE,
5
4
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
6
5
  THIRD_PARTY_BLE_SCAN_DURATION_MS,
7
6
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
8
- THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS,
9
- isThirdPartyBleIpcErrorResponse
10
- } from "./chunk-O6YS25TV.mjs";
7
+ THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
8
+ } from "./chunk-ILABAQJY.mjs";
11
9
  export {
12
10
  THIRD_PARTY_BLE_CHANNELS,
13
11
  THIRD_PARTY_BLE_DEVICE_TTL_MS,
14
- THIRD_PARTY_BLE_IPC_ERROR_TYPE,
15
12
  THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS,
16
13
  THIRD_PARTY_BLE_SCAN_DURATION_MS,
17
14
  THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS,
18
- THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS,
19
- isThirdPartyBleIpcErrorResponse
15
+ THIRD_PARTY_BLE_STATE_SETTLE_TIMEOUT_MS
20
16
  };
21
17
  //# sourceMappingURL=constants.mjs.map
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ElectronBleConnectOptions, ElectronBleScanOptions } from '@onekeyfe/hwk-adapter-core';
2
- import { ThirdPartyBleIpcErrorResponse } from './constants.mjs';
3
- export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_IPC_ERROR_TYPE, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, ThirdPartyBleChannel, isThirdPartyBleIpcErrorResponse } from './constants.mjs';
2
+ export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, ThirdPartyBleChannel } from './constants.mjs';
4
3
 
5
4
  type BleDebugLogLevel = 'debug' | 'info' | 'warn' | 'error';
6
5
  type BleDebugLogEntry = {
@@ -13,22 +12,6 @@ type BleDebugLogger = (entry: BleDebugLogEntry) => void;
13
12
  /** Replace sensitive values at any depth; everything else is forwarded verbatim. */
14
13
  declare function redactBleDebugLogData(data?: Record<string, unknown>): Record<string, unknown> | undefined;
15
14
 
16
- type WindowsBlePairingDecision = 'confirm' | 'cancel';
17
- interface WindowsBlePairingRequest {
18
- id: string;
19
- vendor: string;
20
- /** Numeric comparison only. Never persist or log this value. */
21
- pin: string;
22
- /** Close the prompt immediately when aborted; ignore any later UI answer. */
23
- signal: AbortSignal;
24
- }
25
- interface WindowsBlePairingOptions {
26
- /** Absolute path to the host-provided helper, copied outside Electron's ASAR. */
27
- helperPath: string;
28
- /** Resolve only after the user compares the code and confirms or cancels. */
29
- onPairingRequest(request: WindowsBlePairingRequest): Promise<WindowsBlePairingDecision>;
30
- }
31
-
32
15
  /**
33
16
  * Main-process allowlist entry for one vendor key. The renderer only names the vendor; which
34
17
  * peripherals it may see and which GATT profile and framing it may use are decided here, so an
@@ -51,7 +34,7 @@ declare const DEFAULT_THIRD_PARTY_BLE_VENDORS: Readonly<Record<string, ThirdPart
51
34
 
52
35
  /** Device info the main process returns to the renderer over IPC. */
53
36
  interface ThirdPartyBleDeviceInfo {
54
- /** Discovery locator (noble peripheral.id), used as connectId. May rotate; not wallet identity. */
37
+ /** Stable id (noble peripheral.id) used as connectId. */
55
38
  id: string;
56
39
  name?: string;
57
40
  rssi?: number;
@@ -171,14 +154,10 @@ interface NobleCharacteristicLike {
171
154
  }
172
155
  type NobleFactory = () => NobleLike;
173
156
  interface NobleBleHandlerOptions {
174
- /** Windows OS bonding before GATT connect. Omit to retain native-only behavior. */
175
- windowsPairing?: WindowsBlePairingOptions;
176
157
  /** Override for tests; defaults to `require('@stoprocent/noble')`. */
177
158
  nobleFactory?: NobleFactory;
178
- /** Override GATT connect timeout (tests only; defaults to 31s), excluding OS pairing. */
159
+ /** Override the overall connect timeout (tests only; defaults to 31s). */
179
160
  connectTimeoutMs?: number;
180
- /** Override the subscribe timeout (tests only; defaults to 60s). */
181
- subscribeTimeoutMs?: number;
182
161
  logger?: BleDebugLogger;
183
162
  /**
184
163
  * Vendors served over IPC, keyed by the `vendor` the renderer sends. Replaces the default map
@@ -190,21 +169,16 @@ interface NobleBleHandlerOptions {
190
169
  declare class NobleBleHandler {
191
170
  private _noble;
192
171
  private readonly _factory;
193
- private readonly _windowsPairing?;
194
172
  private readonly _connectTimeoutMs;
195
- private readonly _subscribeTimeoutMs;
196
173
  private readonly _logger?;
197
174
  private readonly _vendors;
198
175
  private readonly _discovered;
199
176
  private readonly _lastSeen;
200
- private readonly _advertisedUuids;
201
- private readonly _keptByMemory;
202
177
  private readonly _connected;
203
178
  private _discoverHandler?;
204
179
  private _scanning;
205
180
  private readonly _scanOwners;
206
181
  private _scanTransition;
207
- private _pairingScanPauses;
208
182
  private _idleStopTimer?;
209
183
  private _onNotification?;
210
184
  private _onDeviceDisconnected?;
@@ -229,7 +203,6 @@ declare class NobleBleHandler {
229
203
  * packet, and a Safe 7 ADV carries only its name (UUID is in the scan response).
230
204
  */
231
205
  scan(options?: ElectronBleScanOptions): Promise<ThirdPartyBleDeviceInfo[]>;
232
- private _rememberServiceUuids;
233
206
  /**
234
207
  * In-range devices matching the caller, minus TTL-expired ones. `_discovered`
235
208
  * is only a cache; a missing device can still be reached by `_directConnect`.
@@ -247,7 +220,6 @@ declare class NobleBleHandler {
247
220
  private _setScanning;
248
221
  /** Stop scanning but keep the discovered cache (used before connect). */
249
222
  private _pauseScan;
250
- private _pauseScanForPairing;
251
223
  /** Stop scanning and forget discovered devices (idle timeout / teardown). */
252
224
  private _stopContinuousScan;
253
225
  /** A vendor releasing discovery must not stop another vendor's scan. */
@@ -279,11 +251,9 @@ declare class NobleBleHandler {
279
251
  id: string;
280
252
  name?: string;
281
253
  }>;
282
- private _connectWithTimeout;
283
254
  private _connectInner;
284
255
  disconnect(id: string): Promise<void>;
285
256
  subscribe(id: string): Promise<void>;
286
- private _withSubscribeTimeout;
287
257
  unsubscribe(id: string): Promise<void>;
288
258
  write(id: string, hexData: string): Promise<void>;
289
259
  /** Retire a renderer's handler without stopping a process-wide native manager. */
@@ -327,21 +297,10 @@ interface ThirdPartyBleSupportHandle {
327
297
  stop?(): void;
328
298
  }) => void): Promise<void>;
329
299
  }
330
- /**
331
- * Electron IPC keeps only an Error's message; as data, a `createHwkError`'s code and params
332
- * survive. Only those cross, so the renderer rebuilds exactly what the host threw.
333
- */
334
- declare function createThirdPartyBleIpcErrorResponse(error: unknown): ThirdPartyBleIpcErrorResponse;
335
- /**
336
- * Handlers registered through this resolve failures as `ThirdPartyBleIpcErrorResponse`.
337
- * Wrap the `ipcMain` that registers with Electron so inner wrappers still see throws, and
338
- * pair it with a preload that rethrows `response.error`.
339
- */
340
- declare function withThirdPartyBleIpcErrors(ipcMain: IpcMainLike): IpcMainLike;
341
300
  /**
342
301
  * Wire a `NobleBleHandler` to Electron IPC once `BrowserWindow` is ready. Call dispose()
343
302
  * when retiring a renderer and disposeForAppQuit() before Node teardown.
344
303
  */
345
304
  declare function initThirdPartyBleSupport(webContents: WebContentsLike, options?: InitThirdPartyBleSupportOptions): ThirdPartyBleSupportHandle;
346
305
 
347
- export { type BleDebugLogEntry, type BleDebugLogLevel, type BleDebugLogger, DEFAULT_THIRD_PARTY_BLE_VENDORS, type InitThirdPartyBleSupportOptions, type IpcMainLike, NobleBleHandler, type NobleBleHandlerOptions, type ThirdPartyBleApi, type ThirdPartyBleAvailability, type ThirdPartyBleDeviceInfo, ThirdPartyBleIpcErrorResponse, type ThirdPartyBleSupportHandle, type ThirdPartyBleVendorProfile, type WindowsBlePairingDecision, type WindowsBlePairingOptions, type WindowsBlePairingRequest, createThirdPartyBleIpcErrorResponse, initThirdPartyBleSupport, redactBleDebugLogData, withThirdPartyBleIpcErrors };
306
+ export { type BleDebugLogEntry, type BleDebugLogLevel, type BleDebugLogger, DEFAULT_THIRD_PARTY_BLE_VENDORS, type InitThirdPartyBleSupportOptions, type IpcMainLike, NobleBleHandler, type NobleBleHandlerOptions, type ThirdPartyBleApi, type ThirdPartyBleAvailability, type ThirdPartyBleDeviceInfo, type ThirdPartyBleSupportHandle, type ThirdPartyBleVendorProfile, initThirdPartyBleSupport, redactBleDebugLogData };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ElectronBleConnectOptions, ElectronBleScanOptions } from '@onekeyfe/hwk-adapter-core';
2
- import { ThirdPartyBleIpcErrorResponse } from './constants.js';
3
- export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_IPC_ERROR_TYPE, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, ThirdPartyBleChannel, isThirdPartyBleIpcErrorResponse } from './constants.js';
2
+ export { THIRD_PARTY_BLE_CHANNELS, THIRD_PARTY_BLE_DEVICE_TTL_MS, THIRD_PARTY_BLE_POWER_ON_TIMEOUT_MS, THIRD_PARTY_BLE_SCAN_DURATION_MS, THIRD_PARTY_BLE_SCAN_IDLE_STOP_MS, ThirdPartyBleChannel } from './constants.js';
4
3
 
5
4
  type BleDebugLogLevel = 'debug' | 'info' | 'warn' | 'error';
6
5
  type BleDebugLogEntry = {
@@ -13,22 +12,6 @@ type BleDebugLogger = (entry: BleDebugLogEntry) => void;
13
12
  /** Replace sensitive values at any depth; everything else is forwarded verbatim. */
14
13
  declare function redactBleDebugLogData(data?: Record<string, unknown>): Record<string, unknown> | undefined;
15
14
 
16
- type WindowsBlePairingDecision = 'confirm' | 'cancel';
17
- interface WindowsBlePairingRequest {
18
- id: string;
19
- vendor: string;
20
- /** Numeric comparison only. Never persist or log this value. */
21
- pin: string;
22
- /** Close the prompt immediately when aborted; ignore any later UI answer. */
23
- signal: AbortSignal;
24
- }
25
- interface WindowsBlePairingOptions {
26
- /** Absolute path to the host-provided helper, copied outside Electron's ASAR. */
27
- helperPath: string;
28
- /** Resolve only after the user compares the code and confirms or cancels. */
29
- onPairingRequest(request: WindowsBlePairingRequest): Promise<WindowsBlePairingDecision>;
30
- }
31
-
32
15
  /**
33
16
  * Main-process allowlist entry for one vendor key. The renderer only names the vendor; which
34
17
  * peripherals it may see and which GATT profile and framing it may use are decided here, so an
@@ -51,7 +34,7 @@ declare const DEFAULT_THIRD_PARTY_BLE_VENDORS: Readonly<Record<string, ThirdPart
51
34
 
52
35
  /** Device info the main process returns to the renderer over IPC. */
53
36
  interface ThirdPartyBleDeviceInfo {
54
- /** Discovery locator (noble peripheral.id), used as connectId. May rotate; not wallet identity. */
37
+ /** Stable id (noble peripheral.id) used as connectId. */
55
38
  id: string;
56
39
  name?: string;
57
40
  rssi?: number;
@@ -171,14 +154,10 @@ interface NobleCharacteristicLike {
171
154
  }
172
155
  type NobleFactory = () => NobleLike;
173
156
  interface NobleBleHandlerOptions {
174
- /** Windows OS bonding before GATT connect. Omit to retain native-only behavior. */
175
- windowsPairing?: WindowsBlePairingOptions;
176
157
  /** Override for tests; defaults to `require('@stoprocent/noble')`. */
177
158
  nobleFactory?: NobleFactory;
178
- /** Override GATT connect timeout (tests only; defaults to 31s), excluding OS pairing. */
159
+ /** Override the overall connect timeout (tests only; defaults to 31s). */
179
160
  connectTimeoutMs?: number;
180
- /** Override the subscribe timeout (tests only; defaults to 60s). */
181
- subscribeTimeoutMs?: number;
182
161
  logger?: BleDebugLogger;
183
162
  /**
184
163
  * Vendors served over IPC, keyed by the `vendor` the renderer sends. Replaces the default map
@@ -190,21 +169,16 @@ interface NobleBleHandlerOptions {
190
169
  declare class NobleBleHandler {
191
170
  private _noble;
192
171
  private readonly _factory;
193
- private readonly _windowsPairing?;
194
172
  private readonly _connectTimeoutMs;
195
- private readonly _subscribeTimeoutMs;
196
173
  private readonly _logger?;
197
174
  private readonly _vendors;
198
175
  private readonly _discovered;
199
176
  private readonly _lastSeen;
200
- private readonly _advertisedUuids;
201
- private readonly _keptByMemory;
202
177
  private readonly _connected;
203
178
  private _discoverHandler?;
204
179
  private _scanning;
205
180
  private readonly _scanOwners;
206
181
  private _scanTransition;
207
- private _pairingScanPauses;
208
182
  private _idleStopTimer?;
209
183
  private _onNotification?;
210
184
  private _onDeviceDisconnected?;
@@ -229,7 +203,6 @@ declare class NobleBleHandler {
229
203
  * packet, and a Safe 7 ADV carries only its name (UUID is in the scan response).
230
204
  */
231
205
  scan(options?: ElectronBleScanOptions): Promise<ThirdPartyBleDeviceInfo[]>;
232
- private _rememberServiceUuids;
233
206
  /**
234
207
  * In-range devices matching the caller, minus TTL-expired ones. `_discovered`
235
208
  * is only a cache; a missing device can still be reached by `_directConnect`.
@@ -247,7 +220,6 @@ declare class NobleBleHandler {
247
220
  private _setScanning;
248
221
  /** Stop scanning but keep the discovered cache (used before connect). */
249
222
  private _pauseScan;
250
- private _pauseScanForPairing;
251
223
  /** Stop scanning and forget discovered devices (idle timeout / teardown). */
252
224
  private _stopContinuousScan;
253
225
  /** A vendor releasing discovery must not stop another vendor's scan. */
@@ -279,11 +251,9 @@ declare class NobleBleHandler {
279
251
  id: string;
280
252
  name?: string;
281
253
  }>;
282
- private _connectWithTimeout;
283
254
  private _connectInner;
284
255
  disconnect(id: string): Promise<void>;
285
256
  subscribe(id: string): Promise<void>;
286
- private _withSubscribeTimeout;
287
257
  unsubscribe(id: string): Promise<void>;
288
258
  write(id: string, hexData: string): Promise<void>;
289
259
  /** Retire a renderer's handler without stopping a process-wide native manager. */
@@ -327,21 +297,10 @@ interface ThirdPartyBleSupportHandle {
327
297
  stop?(): void;
328
298
  }) => void): Promise<void>;
329
299
  }
330
- /**
331
- * Electron IPC keeps only an Error's message; as data, a `createHwkError`'s code and params
332
- * survive. Only those cross, so the renderer rebuilds exactly what the host threw.
333
- */
334
- declare function createThirdPartyBleIpcErrorResponse(error: unknown): ThirdPartyBleIpcErrorResponse;
335
- /**
336
- * Handlers registered through this resolve failures as `ThirdPartyBleIpcErrorResponse`.
337
- * Wrap the `ipcMain` that registers with Electron so inner wrappers still see throws, and
338
- * pair it with a preload that rethrows `response.error`.
339
- */
340
- declare function withThirdPartyBleIpcErrors(ipcMain: IpcMainLike): IpcMainLike;
341
300
  /**
342
301
  * Wire a `NobleBleHandler` to Electron IPC once `BrowserWindow` is ready. Call dispose()
343
302
  * when retiring a renderer and disposeForAppQuit() before Node teardown.
344
303
  */
345
304
  declare function initThirdPartyBleSupport(webContents: WebContentsLike, options?: InitThirdPartyBleSupportOptions): ThirdPartyBleSupportHandle;
346
305
 
347
- export { type BleDebugLogEntry, type BleDebugLogLevel, type BleDebugLogger, DEFAULT_THIRD_PARTY_BLE_VENDORS, type InitThirdPartyBleSupportOptions, type IpcMainLike, NobleBleHandler, type NobleBleHandlerOptions, type ThirdPartyBleApi, type ThirdPartyBleAvailability, type ThirdPartyBleDeviceInfo, ThirdPartyBleIpcErrorResponse, type ThirdPartyBleSupportHandle, type ThirdPartyBleVendorProfile, type WindowsBlePairingDecision, type WindowsBlePairingOptions, type WindowsBlePairingRequest, createThirdPartyBleIpcErrorResponse, initThirdPartyBleSupport, redactBleDebugLogData, withThirdPartyBleIpcErrors };
306
+ export { type BleDebugLogEntry, type BleDebugLogLevel, type BleDebugLogger, DEFAULT_THIRD_PARTY_BLE_VENDORS, type InitThirdPartyBleSupportOptions, type IpcMainLike, NobleBleHandler, type NobleBleHandlerOptions, type ThirdPartyBleApi, type ThirdPartyBleAvailability, type ThirdPartyBleDeviceInfo, type ThirdPartyBleSupportHandle, type ThirdPartyBleVendorProfile, initThirdPartyBleSupport, redactBleDebugLogData };