@onekeyfe/hwk-trezor-connector-electron-ble 1.2.3-alpha.8 → 1.2.3
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.
- package/dist/chunk-CFZTAWFZ.mjs +41 -0
- package/dist/chunk-CFZTAWFZ.mjs.map +1 -0
- package/dist/constants.d.mts +36 -0
- package/dist/constants.d.ts +36 -0
- package/dist/constants.js +62 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +17 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/desktop-api-DDNonbNW.d.mts +77 -0
- package/dist/desktop-api-DDNonbNW.d.ts +77 -0
- package/dist/index.d.mts +7 -21
- package/dist/index.d.ts +7 -21
- package/dist/index.js +36 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -30
- package/dist/index.mjs.map +1 -1
- package/dist/main.d.mts +282 -0
- package/dist/main.d.ts +282 -0
- package/dist/main.js +862 -0
- package/dist/main.js.map +1 -0
- package/dist/main.mjs +826 -0
- package/dist/main.mjs.map +1 -0
- package/package.json +25 -6
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
// src/constants.ts
|
|
9
|
+
var TREZOR_BLE_CHANNELS = {
|
|
10
|
+
scan: "$onekey-trezor-ble-scan",
|
|
11
|
+
stopScan: "$onekey-trezor-ble-stop-scan",
|
|
12
|
+
connect: "$onekey-trezor-ble-connect",
|
|
13
|
+
disconnect: "$onekey-trezor-ble-disconnect",
|
|
14
|
+
write: "$onekey-trezor-ble-write",
|
|
15
|
+
subscribe: "$onekey-trezor-ble-subscribe",
|
|
16
|
+
unsubscribe: "$onekey-trezor-ble-unsubscribe",
|
|
17
|
+
availability: "$onekey-trezor-ble-availability",
|
|
18
|
+
getDevice: "$onekey-trezor-ble-get-device",
|
|
19
|
+
readRssi: "$onekey-trezor-ble-read-rssi",
|
|
20
|
+
cancelPairing: "$onekey-trezor-ble-cancel-pairing",
|
|
21
|
+
/** push event: main → renderer with assembled BLE notification payload */
|
|
22
|
+
notification: "$onekey-trezor-ble-notification",
|
|
23
|
+
/** push event: main → renderer when device disconnects unexpectedly */
|
|
24
|
+
disconnected: "$onekey-trezor-ble-disconnected"
|
|
25
|
+
};
|
|
26
|
+
var TREZOR_BLE_SCAN_DURATION_MS = 5e3;
|
|
27
|
+
var TREZOR_BLE_SCAN_IDLE_STOP_MS = 1e4;
|
|
28
|
+
var TREZOR_BLE_DEVICE_TTL_MS = 5e3;
|
|
29
|
+
var TREZOR_BLE_POWER_ON_TIMEOUT_MS = 1e4;
|
|
30
|
+
var TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
__require,
|
|
34
|
+
TREZOR_BLE_CHANNELS,
|
|
35
|
+
TREZOR_BLE_SCAN_DURATION_MS,
|
|
36
|
+
TREZOR_BLE_SCAN_IDLE_STOP_MS,
|
|
37
|
+
TREZOR_BLE_DEVICE_TTL_MS,
|
|
38
|
+
TREZOR_BLE_POWER_ON_TIMEOUT_MS,
|
|
39
|
+
TREZOR_BLE_WRITE_CHUNK_DELAY_MS
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-CFZTAWFZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * IPC channel names exchanged between renderer and main process.\n * Namespaced under `$onekey-trezor-ble-…` to avoid clashing with the\n * existing OneKey BLE handler (`$onekey-noble-ble-…`) when both run in\n * the same Electron app.\n */\nexport const TREZOR_BLE_CHANNELS = {\n scan: '$onekey-trezor-ble-scan',\n stopScan: '$onekey-trezor-ble-stop-scan',\n connect: '$onekey-trezor-ble-connect',\n disconnect: '$onekey-trezor-ble-disconnect',\n write: '$onekey-trezor-ble-write',\n subscribe: '$onekey-trezor-ble-subscribe',\n unsubscribe: '$onekey-trezor-ble-unsubscribe',\n availability: '$onekey-trezor-ble-availability',\n getDevice: '$onekey-trezor-ble-get-device',\n readRssi: '$onekey-trezor-ble-read-rssi',\n cancelPairing: '$onekey-trezor-ble-cancel-pairing',\n /** push event: main → renderer with assembled BLE notification payload */\n notification: '$onekey-trezor-ble-notification',\n /** push event: main → renderer when device disconnects unexpectedly */\n disconnected: '$onekey-trezor-ble-disconnected',\n} as const;\n\nexport type TrezorBleChannel = (typeof TREZOR_BLE_CHANNELS)[keyof typeof TREZOR_BLE_CHANNELS];\n\n/** Reconnect scan window for `connect(id)`. */\nexport const TREZOR_BLE_SCAN_DURATION_MS = 5_000;\n\n/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */\nexport const TREZOR_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 TREZOR_BLE_DEVICE_TTL_MS = 5_000;\n\n/** Time we'll wait for noble to reach `poweredOn` before failing init. */\nexport const TREZOR_BLE_POWER_ON_TIMEOUT_MS = 10_000;\n\n/** Inter-chunk delay during write, matches OneKey's `UNIFIED_WRITE_DELAY`. */\nexport const TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;\n"],"mappings":";;;;;;;;AAMO,IAAM,sBAAsB;AAAA,EACjC,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,8BAA8B;AAGpC,IAAM,+BAA+B;AAGrC,IAAM,2BAA2B;AAGjC,IAAM,iCAAiC;AAGvC,IAAM,kCAAkC;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPC channel names exchanged between renderer and main process.
|
|
3
|
+
* Namespaced under `$onekey-trezor-ble-…` to avoid clashing with the
|
|
4
|
+
* existing OneKey BLE handler (`$onekey-noble-ble-…`) when both run in
|
|
5
|
+
* the same Electron app.
|
|
6
|
+
*/
|
|
7
|
+
declare const TREZOR_BLE_CHANNELS: {
|
|
8
|
+
readonly scan: "$onekey-trezor-ble-scan";
|
|
9
|
+
readonly stopScan: "$onekey-trezor-ble-stop-scan";
|
|
10
|
+
readonly connect: "$onekey-trezor-ble-connect";
|
|
11
|
+
readonly disconnect: "$onekey-trezor-ble-disconnect";
|
|
12
|
+
readonly write: "$onekey-trezor-ble-write";
|
|
13
|
+
readonly subscribe: "$onekey-trezor-ble-subscribe";
|
|
14
|
+
readonly unsubscribe: "$onekey-trezor-ble-unsubscribe";
|
|
15
|
+
readonly availability: "$onekey-trezor-ble-availability";
|
|
16
|
+
readonly getDevice: "$onekey-trezor-ble-get-device";
|
|
17
|
+
readonly readRssi: "$onekey-trezor-ble-read-rssi";
|
|
18
|
+
readonly cancelPairing: "$onekey-trezor-ble-cancel-pairing";
|
|
19
|
+
/** push event: main → renderer with assembled BLE notification payload */
|
|
20
|
+
readonly notification: "$onekey-trezor-ble-notification";
|
|
21
|
+
/** push event: main → renderer when device disconnects unexpectedly */
|
|
22
|
+
readonly disconnected: "$onekey-trezor-ble-disconnected";
|
|
23
|
+
};
|
|
24
|
+
type TrezorBleChannel = (typeof TREZOR_BLE_CHANNELS)[keyof typeof TREZOR_BLE_CHANNELS];
|
|
25
|
+
/** Reconnect scan window for `connect(id)`. */
|
|
26
|
+
declare const TREZOR_BLE_SCAN_DURATION_MS = 5000;
|
|
27
|
+
/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */
|
|
28
|
+
declare const TREZOR_BLE_SCAN_IDLE_STOP_MS = 10000;
|
|
29
|
+
/** Drop a device from the snapshot if it hasn't re-advertised within this window. */
|
|
30
|
+
declare const TREZOR_BLE_DEVICE_TTL_MS = 5000;
|
|
31
|
+
/** Time we'll wait for noble to reach `poweredOn` before failing init. */
|
|
32
|
+
declare const TREZOR_BLE_POWER_ON_TIMEOUT_MS = 10000;
|
|
33
|
+
/** Inter-chunk delay during write, matches OneKey's `UNIFIED_WRITE_DELAY`. */
|
|
34
|
+
declare const TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
35
|
+
|
|
36
|
+
export { TREZOR_BLE_CHANNELS, TREZOR_BLE_DEVICE_TTL_MS, TREZOR_BLE_POWER_ON_TIMEOUT_MS, TREZOR_BLE_SCAN_DURATION_MS, TREZOR_BLE_SCAN_IDLE_STOP_MS, TREZOR_BLE_WRITE_CHUNK_DELAY_MS, type TrezorBleChannel };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPC channel names exchanged between renderer and main process.
|
|
3
|
+
* Namespaced under `$onekey-trezor-ble-…` to avoid clashing with the
|
|
4
|
+
* existing OneKey BLE handler (`$onekey-noble-ble-…`) when both run in
|
|
5
|
+
* the same Electron app.
|
|
6
|
+
*/
|
|
7
|
+
declare const TREZOR_BLE_CHANNELS: {
|
|
8
|
+
readonly scan: "$onekey-trezor-ble-scan";
|
|
9
|
+
readonly stopScan: "$onekey-trezor-ble-stop-scan";
|
|
10
|
+
readonly connect: "$onekey-trezor-ble-connect";
|
|
11
|
+
readonly disconnect: "$onekey-trezor-ble-disconnect";
|
|
12
|
+
readonly write: "$onekey-trezor-ble-write";
|
|
13
|
+
readonly subscribe: "$onekey-trezor-ble-subscribe";
|
|
14
|
+
readonly unsubscribe: "$onekey-trezor-ble-unsubscribe";
|
|
15
|
+
readonly availability: "$onekey-trezor-ble-availability";
|
|
16
|
+
readonly getDevice: "$onekey-trezor-ble-get-device";
|
|
17
|
+
readonly readRssi: "$onekey-trezor-ble-read-rssi";
|
|
18
|
+
readonly cancelPairing: "$onekey-trezor-ble-cancel-pairing";
|
|
19
|
+
/** push event: main → renderer with assembled BLE notification payload */
|
|
20
|
+
readonly notification: "$onekey-trezor-ble-notification";
|
|
21
|
+
/** push event: main → renderer when device disconnects unexpectedly */
|
|
22
|
+
readonly disconnected: "$onekey-trezor-ble-disconnected";
|
|
23
|
+
};
|
|
24
|
+
type TrezorBleChannel = (typeof TREZOR_BLE_CHANNELS)[keyof typeof TREZOR_BLE_CHANNELS];
|
|
25
|
+
/** Reconnect scan window for `connect(id)`. */
|
|
26
|
+
declare const TREZOR_BLE_SCAN_DURATION_MS = 5000;
|
|
27
|
+
/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */
|
|
28
|
+
declare const TREZOR_BLE_SCAN_IDLE_STOP_MS = 10000;
|
|
29
|
+
/** Drop a device from the snapshot if it hasn't re-advertised within this window. */
|
|
30
|
+
declare const TREZOR_BLE_DEVICE_TTL_MS = 5000;
|
|
31
|
+
/** Time we'll wait for noble to reach `poweredOn` before failing init. */
|
|
32
|
+
declare const TREZOR_BLE_POWER_ON_TIMEOUT_MS = 10000;
|
|
33
|
+
/** Inter-chunk delay during write, matches OneKey's `UNIFIED_WRITE_DELAY`. */
|
|
34
|
+
declare const TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
35
|
+
|
|
36
|
+
export { TREZOR_BLE_CHANNELS, TREZOR_BLE_DEVICE_TTL_MS, TREZOR_BLE_POWER_ON_TIMEOUT_MS, TREZOR_BLE_SCAN_DURATION_MS, TREZOR_BLE_SCAN_IDLE_STOP_MS, TREZOR_BLE_WRITE_CHUNK_DELAY_MS, type TrezorBleChannel };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/constants.ts
|
|
21
|
+
var constants_exports = {};
|
|
22
|
+
__export(constants_exports, {
|
|
23
|
+
TREZOR_BLE_CHANNELS: () => TREZOR_BLE_CHANNELS,
|
|
24
|
+
TREZOR_BLE_DEVICE_TTL_MS: () => TREZOR_BLE_DEVICE_TTL_MS,
|
|
25
|
+
TREZOR_BLE_POWER_ON_TIMEOUT_MS: () => TREZOR_BLE_POWER_ON_TIMEOUT_MS,
|
|
26
|
+
TREZOR_BLE_SCAN_DURATION_MS: () => TREZOR_BLE_SCAN_DURATION_MS,
|
|
27
|
+
TREZOR_BLE_SCAN_IDLE_STOP_MS: () => TREZOR_BLE_SCAN_IDLE_STOP_MS,
|
|
28
|
+
TREZOR_BLE_WRITE_CHUNK_DELAY_MS: () => TREZOR_BLE_WRITE_CHUNK_DELAY_MS
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(constants_exports);
|
|
31
|
+
var TREZOR_BLE_CHANNELS = {
|
|
32
|
+
scan: "$onekey-trezor-ble-scan",
|
|
33
|
+
stopScan: "$onekey-trezor-ble-stop-scan",
|
|
34
|
+
connect: "$onekey-trezor-ble-connect",
|
|
35
|
+
disconnect: "$onekey-trezor-ble-disconnect",
|
|
36
|
+
write: "$onekey-trezor-ble-write",
|
|
37
|
+
subscribe: "$onekey-trezor-ble-subscribe",
|
|
38
|
+
unsubscribe: "$onekey-trezor-ble-unsubscribe",
|
|
39
|
+
availability: "$onekey-trezor-ble-availability",
|
|
40
|
+
getDevice: "$onekey-trezor-ble-get-device",
|
|
41
|
+
readRssi: "$onekey-trezor-ble-read-rssi",
|
|
42
|
+
cancelPairing: "$onekey-trezor-ble-cancel-pairing",
|
|
43
|
+
/** push event: main → renderer with assembled BLE notification payload */
|
|
44
|
+
notification: "$onekey-trezor-ble-notification",
|
|
45
|
+
/** push event: main → renderer when device disconnects unexpectedly */
|
|
46
|
+
disconnected: "$onekey-trezor-ble-disconnected"
|
|
47
|
+
};
|
|
48
|
+
var TREZOR_BLE_SCAN_DURATION_MS = 5e3;
|
|
49
|
+
var TREZOR_BLE_SCAN_IDLE_STOP_MS = 1e4;
|
|
50
|
+
var TREZOR_BLE_DEVICE_TTL_MS = 5e3;
|
|
51
|
+
var TREZOR_BLE_POWER_ON_TIMEOUT_MS = 1e4;
|
|
52
|
+
var TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
TREZOR_BLE_CHANNELS,
|
|
56
|
+
TREZOR_BLE_DEVICE_TTL_MS,
|
|
57
|
+
TREZOR_BLE_POWER_ON_TIMEOUT_MS,
|
|
58
|
+
TREZOR_BLE_SCAN_DURATION_MS,
|
|
59
|
+
TREZOR_BLE_SCAN_IDLE_STOP_MS,
|
|
60
|
+
TREZOR_BLE_WRITE_CHUNK_DELAY_MS
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * IPC channel names exchanged between renderer and main process.\n * Namespaced under `$onekey-trezor-ble-…` to avoid clashing with the\n * existing OneKey BLE handler (`$onekey-noble-ble-…`) when both run in\n * the same Electron app.\n */\nexport const TREZOR_BLE_CHANNELS = {\n scan: '$onekey-trezor-ble-scan',\n stopScan: '$onekey-trezor-ble-stop-scan',\n connect: '$onekey-trezor-ble-connect',\n disconnect: '$onekey-trezor-ble-disconnect',\n write: '$onekey-trezor-ble-write',\n subscribe: '$onekey-trezor-ble-subscribe',\n unsubscribe: '$onekey-trezor-ble-unsubscribe',\n availability: '$onekey-trezor-ble-availability',\n getDevice: '$onekey-trezor-ble-get-device',\n readRssi: '$onekey-trezor-ble-read-rssi',\n cancelPairing: '$onekey-trezor-ble-cancel-pairing',\n /** push event: main → renderer with assembled BLE notification payload */\n notification: '$onekey-trezor-ble-notification',\n /** push event: main → renderer when device disconnects unexpectedly */\n disconnected: '$onekey-trezor-ble-disconnected',\n} as const;\n\nexport type TrezorBleChannel = (typeof TREZOR_BLE_CHANNELS)[keyof typeof TREZOR_BLE_CHANNELS];\n\n/** Reconnect scan window for `connect(id)`. */\nexport const TREZOR_BLE_SCAN_DURATION_MS = 5_000;\n\n/** Continuous scan auto-stops this long after the last poll (reset, not accumulated). */\nexport const TREZOR_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 TREZOR_BLE_DEVICE_TTL_MS = 5_000;\n\n/** Time we'll wait for noble to reach `poweredOn` before failing init. */\nexport const TREZOR_BLE_POWER_ON_TIMEOUT_MS = 10_000;\n\n/** Inter-chunk delay during write, matches OneKey's `UNIFIED_WRITE_DELAY`. */\nexport const TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,sBAAsB;AAAA,EACjC,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,8BAA8B;AAGpC,IAAM,+BAA+B;AAGrC,IAAM,2BAA2B;AAGjC,IAAM,iCAAiC;AAGvC,IAAM,kCAAkC;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TREZOR_BLE_CHANNELS,
|
|
3
|
+
TREZOR_BLE_DEVICE_TTL_MS,
|
|
4
|
+
TREZOR_BLE_POWER_ON_TIMEOUT_MS,
|
|
5
|
+
TREZOR_BLE_SCAN_DURATION_MS,
|
|
6
|
+
TREZOR_BLE_SCAN_IDLE_STOP_MS,
|
|
7
|
+
TREZOR_BLE_WRITE_CHUNK_DELAY_MS
|
|
8
|
+
} from "./chunk-CFZTAWFZ.mjs";
|
|
9
|
+
export {
|
|
10
|
+
TREZOR_BLE_CHANNELS,
|
|
11
|
+
TREZOR_BLE_DEVICE_TTL_MS,
|
|
12
|
+
TREZOR_BLE_POWER_ON_TIMEOUT_MS,
|
|
13
|
+
TREZOR_BLE_SCAN_DURATION_MS,
|
|
14
|
+
TREZOR_BLE_SCAN_IDLE_STOP_MS,
|
|
15
|
+
TREZOR_BLE_WRITE_CHUNK_DELAY_MS
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the API the renderer process talks to. In a real Electron app
|
|
3
|
+
* this is normally exposed via `contextBridge.exposeInMainWorld('desktopApi',
|
|
4
|
+
* { trezorBle: ... })`, but the transport accepts the bridge directly so
|
|
5
|
+
* non-Electron hosts (and unit tests) can plug in their own implementation.
|
|
6
|
+
*/
|
|
7
|
+
interface TrezorBleDeviceInfo {
|
|
8
|
+
/** Stable id (noble peripheral.id) used as connectId. */
|
|
9
|
+
id: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
rssi?: number;
|
|
12
|
+
advertisedServiceUuids?: string[];
|
|
13
|
+
/** Same as `name`, kept explicit to mirror noble's `advertisement.localName`. */
|
|
14
|
+
localName?: string;
|
|
15
|
+
/** Whether the peripheral advertised itself as connectable. */
|
|
16
|
+
isConnectable?: boolean | null;
|
|
17
|
+
serviceSolicitationUuids?: string[];
|
|
18
|
+
txPowerLevel?: number;
|
|
19
|
+
/** Manufacturer-specific advertisement data, hex-encoded (may embed a serial). */
|
|
20
|
+
manufacturerDataHex?: string;
|
|
21
|
+
/** Per-service advertisement data, each hex-encoded. */
|
|
22
|
+
serviceData?: Array<{
|
|
23
|
+
uuid: string;
|
|
24
|
+
dataHex: string;
|
|
25
|
+
}>;
|
|
26
|
+
/** BLE MAC/address when the OS exposes it separately from `id`. */
|
|
27
|
+
address?: string;
|
|
28
|
+
addressType?: string;
|
|
29
|
+
/** noble peripheral connection state at scan time. */
|
|
30
|
+
state?: string;
|
|
31
|
+
}
|
|
32
|
+
interface TrezorBleAvailability {
|
|
33
|
+
available: boolean;
|
|
34
|
+
/** noble state: `poweredOn` / `poweredOff` / `unauthorized` / `unsupported` / `resetting` / `unknown`. */
|
|
35
|
+
state: string;
|
|
36
|
+
initialized: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface TrezorBleScanOptions {
|
|
39
|
+
/**
|
|
40
|
+
* DEPRECATED and ignored by the handler: a native service-UUID filter drops
|
|
41
|
+
* Safe 7 ADV packets on Windows, so the scan is always unfiltered and Trezor
|
|
42
|
+
* matching happens in JS. Kept only so older renderers remain IPC-compatible.
|
|
43
|
+
*/
|
|
44
|
+
serviceUuids?: string[];
|
|
45
|
+
durationMs?: number;
|
|
46
|
+
}
|
|
47
|
+
interface TrezorBleApi {
|
|
48
|
+
scan(options?: TrezorBleScanOptions): Promise<TrezorBleDeviceInfo[]>;
|
|
49
|
+
stopScan(): Promise<void>;
|
|
50
|
+
connect(id: string): Promise<{
|
|
51
|
+
id: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
}>;
|
|
54
|
+
disconnect(id: string): Promise<void>;
|
|
55
|
+
/** Subscribe to the BLE notify characteristic for `id`. */
|
|
56
|
+
subscribe(id: string): Promise<void>;
|
|
57
|
+
unsubscribe(id: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Write a payload (already-framed if Trezor v1, or a single 244-byte chunk
|
|
60
|
+
* for THP). The main process is responsible for splitting it into BLE-MTU
|
|
61
|
+
* chunks before handing it to noble.
|
|
62
|
+
*/
|
|
63
|
+
write(id: string, hexData: string): Promise<void>;
|
|
64
|
+
checkAvailability(): Promise<TrezorBleAvailability>;
|
|
65
|
+
/** Look up a previously-scanned device by id without re-scanning. */
|
|
66
|
+
getDevice(id: string): Promise<TrezorBleDeviceInfo | null>;
|
|
67
|
+
/** Read current RSSI (dBm) of a *connected* peripheral. */
|
|
68
|
+
readRssi(id: string): Promise<number>;
|
|
69
|
+
/** Stop scan + disconnect every in-flight connection. */
|
|
70
|
+
cancelPairing(): Promise<void>;
|
|
71
|
+
/** Register a listener for incoming BLE notifications. Returns an unsubscribe fn. */
|
|
72
|
+
onNotification(handler: (id: string, hexData: string) => void): () => void;
|
|
73
|
+
/** Register a listener for unexpected disconnects. Returns an unsubscribe fn. */
|
|
74
|
+
onDeviceDisconnected(handler: (id: string) => void): () => void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type { TrezorBleApi as T, TrezorBleDeviceInfo as a, TrezorBleAvailability as b };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the API the renderer process talks to. In a real Electron app
|
|
3
|
+
* this is normally exposed via `contextBridge.exposeInMainWorld('desktopApi',
|
|
4
|
+
* { trezorBle: ... })`, but the transport accepts the bridge directly so
|
|
5
|
+
* non-Electron hosts (and unit tests) can plug in their own implementation.
|
|
6
|
+
*/
|
|
7
|
+
interface TrezorBleDeviceInfo {
|
|
8
|
+
/** Stable id (noble peripheral.id) used as connectId. */
|
|
9
|
+
id: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
rssi?: number;
|
|
12
|
+
advertisedServiceUuids?: string[];
|
|
13
|
+
/** Same as `name`, kept explicit to mirror noble's `advertisement.localName`. */
|
|
14
|
+
localName?: string;
|
|
15
|
+
/** Whether the peripheral advertised itself as connectable. */
|
|
16
|
+
isConnectable?: boolean | null;
|
|
17
|
+
serviceSolicitationUuids?: string[];
|
|
18
|
+
txPowerLevel?: number;
|
|
19
|
+
/** Manufacturer-specific advertisement data, hex-encoded (may embed a serial). */
|
|
20
|
+
manufacturerDataHex?: string;
|
|
21
|
+
/** Per-service advertisement data, each hex-encoded. */
|
|
22
|
+
serviceData?: Array<{
|
|
23
|
+
uuid: string;
|
|
24
|
+
dataHex: string;
|
|
25
|
+
}>;
|
|
26
|
+
/** BLE MAC/address when the OS exposes it separately from `id`. */
|
|
27
|
+
address?: string;
|
|
28
|
+
addressType?: string;
|
|
29
|
+
/** noble peripheral connection state at scan time. */
|
|
30
|
+
state?: string;
|
|
31
|
+
}
|
|
32
|
+
interface TrezorBleAvailability {
|
|
33
|
+
available: boolean;
|
|
34
|
+
/** noble state: `poweredOn` / `poweredOff` / `unauthorized` / `unsupported` / `resetting` / `unknown`. */
|
|
35
|
+
state: string;
|
|
36
|
+
initialized: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface TrezorBleScanOptions {
|
|
39
|
+
/**
|
|
40
|
+
* DEPRECATED and ignored by the handler: a native service-UUID filter drops
|
|
41
|
+
* Safe 7 ADV packets on Windows, so the scan is always unfiltered and Trezor
|
|
42
|
+
* matching happens in JS. Kept only so older renderers remain IPC-compatible.
|
|
43
|
+
*/
|
|
44
|
+
serviceUuids?: string[];
|
|
45
|
+
durationMs?: number;
|
|
46
|
+
}
|
|
47
|
+
interface TrezorBleApi {
|
|
48
|
+
scan(options?: TrezorBleScanOptions): Promise<TrezorBleDeviceInfo[]>;
|
|
49
|
+
stopScan(): Promise<void>;
|
|
50
|
+
connect(id: string): Promise<{
|
|
51
|
+
id: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
}>;
|
|
54
|
+
disconnect(id: string): Promise<void>;
|
|
55
|
+
/** Subscribe to the BLE notify characteristic for `id`. */
|
|
56
|
+
subscribe(id: string): Promise<void>;
|
|
57
|
+
unsubscribe(id: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Write a payload (already-framed if Trezor v1, or a single 244-byte chunk
|
|
60
|
+
* for THP). The main process is responsible for splitting it into BLE-MTU
|
|
61
|
+
* chunks before handing it to noble.
|
|
62
|
+
*/
|
|
63
|
+
write(id: string, hexData: string): Promise<void>;
|
|
64
|
+
checkAvailability(): Promise<TrezorBleAvailability>;
|
|
65
|
+
/** Look up a previously-scanned device by id without re-scanning. */
|
|
66
|
+
getDevice(id: string): Promise<TrezorBleDeviceInfo | null>;
|
|
67
|
+
/** Read current RSSI (dBm) of a *connected* peripheral. */
|
|
68
|
+
readRssi(id: string): Promise<number>;
|
|
69
|
+
/** Stop scan + disconnect every in-flight connection. */
|
|
70
|
+
cancelPairing(): Promise<void>;
|
|
71
|
+
/** Register a listener for incoming BLE notifications. Returns an unsubscribe fn. */
|
|
72
|
+
onNotification(handler: (id: string, hexData: string) => void): () => void;
|
|
73
|
+
/** Register a listener for unexpected disconnects. Returns an unsubscribe fn. */
|
|
74
|
+
onDeviceDisconnected(handler: (id: string) => void): () => void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type { TrezorBleApi as T, TrezorBleDeviceInfo as a, TrezorBleAvailability as b };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { TrezorDebugLogger, TrezorConnectorBase, TrezorConnectorBaseOptions, TrezorConnectorByteTransport } from '@onekeyfe/hwk-trezor-connector';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { T as TrezorBleApi, a as TrezorBleDeviceInfo } from './desktop-api-DDNonbNW.mjs';
|
|
3
|
+
export { b as TrezorBleAvailability } from './desktop-api-DDNonbNW.mjs';
|
|
4
|
+
import { ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
|
|
5
|
+
export { TREZOR_BLE_CHANNELS, TREZOR_BLE_POWER_ON_TIMEOUT_MS, TREZOR_BLE_SCAN_DURATION_MS, TREZOR_BLE_WRITE_CHUNK_DELAY_MS, TrezorBleChannel } from './constants.mjs';
|
|
4
6
|
|
|
5
7
|
interface TrezorElectronBleTransportOptions {
|
|
6
8
|
/** The IPC bridge exposed by the main process (typically `window.desktopApi.trezorBle`). */
|
|
7
|
-
bridge?:
|
|
9
|
+
bridge?: TrezorBleApi;
|
|
8
10
|
logger?: TrezorDebugLogger;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
@@ -22,7 +24,7 @@ declare class TrezorElectronBleTransport {
|
|
|
22
24
|
private _disposeDisconnectListener?;
|
|
23
25
|
private readonly _logger?;
|
|
24
26
|
constructor(options?: TrezorElectronBleTransportOptions);
|
|
25
|
-
scan(durationMs?: number): Promise<
|
|
27
|
+
scan(durationMs?: number): Promise<TrezorBleDeviceInfo[]>;
|
|
26
28
|
stopScan(): Promise<void>;
|
|
27
29
|
/** Abandon the in-flight connect/pairing in the main process. */
|
|
28
30
|
cancelPairing(): Promise<void>;
|
|
@@ -60,20 +62,4 @@ declare class TrezorElectronBleConnector extends TrezorConnectorBase {
|
|
|
60
62
|
}
|
|
61
63
|
declare function createTrezorElectronBleConnector(options?: TrezorElectronBleConnectorOptions): TrezorElectronBleConnector;
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
declare const TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
65
|
-
declare const TREZOR_BLE_VENDOR = "trezor";
|
|
66
|
-
/**
|
|
67
|
-
* How the shared desktop handler recognizes a Trezor. The main process holds
|
|
68
|
-
* no vendor knowledge, so the name test that used to live there travels as
|
|
69
|
-
* data: a local name must satisfy every pattern, which reproduces
|
|
70
|
-
* `isTrezorSafe7BleName` — "Trezor" plus either "Safe 7" or "T3W1".
|
|
71
|
-
*/
|
|
72
|
-
declare const TREZOR_BLE_MATCH: ElectronBleMatch;
|
|
73
|
-
/**
|
|
74
|
-
* Trezor firmware expects fixed-size packets: a short final packet is silently
|
|
75
|
-
* dropped, so every write is padded to the full MTU.
|
|
76
|
-
*/
|
|
77
|
-
declare const TREZOR_BLE_CONNECT_PROFILE: ElectronBleConnectOptions;
|
|
78
|
-
|
|
79
|
-
export { TREZOR_BLE_CONNECT_PROFILE, TREZOR_BLE_MATCH, TREZOR_BLE_VENDOR, TREZOR_BLE_WRITE_CHUNK_DELAY_MS, TrezorElectronBleConnector, type TrezorElectronBleConnectorOptions, TrezorElectronBleTransport, type TrezorElectronBleTransportOptions, createTrezorElectronBleConnector, createTrezorElectronBleTransport };
|
|
65
|
+
export { TrezorBleApi, TrezorBleDeviceInfo, TrezorElectronBleConnector, type TrezorElectronBleConnectorOptions, TrezorElectronBleTransport, type TrezorElectronBleTransportOptions, createTrezorElectronBleConnector, createTrezorElectronBleTransport };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { TrezorDebugLogger, TrezorConnectorBase, TrezorConnectorBaseOptions, TrezorConnectorByteTransport } from '@onekeyfe/hwk-trezor-connector';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { T as TrezorBleApi, a as TrezorBleDeviceInfo } from './desktop-api-DDNonbNW.js';
|
|
3
|
+
export { b as TrezorBleAvailability } from './desktop-api-DDNonbNW.js';
|
|
4
|
+
import { ConnectorDevice } from '@onekeyfe/hwk-adapter-core';
|
|
5
|
+
export { TREZOR_BLE_CHANNELS, TREZOR_BLE_POWER_ON_TIMEOUT_MS, TREZOR_BLE_SCAN_DURATION_MS, TREZOR_BLE_WRITE_CHUNK_DELAY_MS, TrezorBleChannel } from './constants.js';
|
|
4
6
|
|
|
5
7
|
interface TrezorElectronBleTransportOptions {
|
|
6
8
|
/** The IPC bridge exposed by the main process (typically `window.desktopApi.trezorBle`). */
|
|
7
|
-
bridge?:
|
|
9
|
+
bridge?: TrezorBleApi;
|
|
8
10
|
logger?: TrezorDebugLogger;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
@@ -22,7 +24,7 @@ declare class TrezorElectronBleTransport {
|
|
|
22
24
|
private _disposeDisconnectListener?;
|
|
23
25
|
private readonly _logger?;
|
|
24
26
|
constructor(options?: TrezorElectronBleTransportOptions);
|
|
25
|
-
scan(durationMs?: number): Promise<
|
|
27
|
+
scan(durationMs?: number): Promise<TrezorBleDeviceInfo[]>;
|
|
26
28
|
stopScan(): Promise<void>;
|
|
27
29
|
/** Abandon the in-flight connect/pairing in the main process. */
|
|
28
30
|
cancelPairing(): Promise<void>;
|
|
@@ -60,20 +62,4 @@ declare class TrezorElectronBleConnector extends TrezorConnectorBase {
|
|
|
60
62
|
}
|
|
61
63
|
declare function createTrezorElectronBleConnector(options?: TrezorElectronBleConnectorOptions): TrezorElectronBleConnector;
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
declare const TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
65
|
-
declare const TREZOR_BLE_VENDOR = "trezor";
|
|
66
|
-
/**
|
|
67
|
-
* How the shared desktop handler recognizes a Trezor. The main process holds
|
|
68
|
-
* no vendor knowledge, so the name test that used to live there travels as
|
|
69
|
-
* data: a local name must satisfy every pattern, which reproduces
|
|
70
|
-
* `isTrezorSafe7BleName` — "Trezor" plus either "Safe 7" or "T3W1".
|
|
71
|
-
*/
|
|
72
|
-
declare const TREZOR_BLE_MATCH: ElectronBleMatch;
|
|
73
|
-
/**
|
|
74
|
-
* Trezor firmware expects fixed-size packets: a short final packet is silently
|
|
75
|
-
* dropped, so every write is padded to the full MTU.
|
|
76
|
-
*/
|
|
77
|
-
declare const TREZOR_BLE_CONNECT_PROFILE: ElectronBleConnectOptions;
|
|
78
|
-
|
|
79
|
-
export { TREZOR_BLE_CONNECT_PROFILE, TREZOR_BLE_MATCH, TREZOR_BLE_VENDOR, TREZOR_BLE_WRITE_CHUNK_DELAY_MS, TrezorElectronBleConnector, type TrezorElectronBleConnectorOptions, TrezorElectronBleTransport, type TrezorElectronBleTransportOptions, createTrezorElectronBleConnector, createTrezorElectronBleTransport };
|
|
65
|
+
export { TrezorBleApi, TrezorBleDeviceInfo, TrezorElectronBleConnector, type TrezorElectronBleConnectorOptions, TrezorElectronBleTransport, type TrezorElectronBleTransportOptions, createTrezorElectronBleConnector, createTrezorElectronBleTransport };
|
package/dist/index.js
CHANGED
|
@@ -20,9 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
TREZOR_BLE_CHANNELS: () => TREZOR_BLE_CHANNELS,
|
|
24
|
+
TREZOR_BLE_POWER_ON_TIMEOUT_MS: () => TREZOR_BLE_POWER_ON_TIMEOUT_MS,
|
|
25
|
+
TREZOR_BLE_SCAN_DURATION_MS: () => TREZOR_BLE_SCAN_DURATION_MS,
|
|
26
26
|
TREZOR_BLE_WRITE_CHUNK_DELAY_MS: () => TREZOR_BLE_WRITE_CHUNK_DELAY_MS,
|
|
27
27
|
TrezorElectronBleConnector: () => TrezorElectronBleConnector,
|
|
28
28
|
TrezorElectronBleTransport: () => TrezorElectronBleTransport,
|
|
@@ -33,7 +33,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
33
33
|
|
|
34
34
|
// src/TrezorElectronBleConnector.ts
|
|
35
35
|
var import_buffer2 = require("buffer");
|
|
36
|
-
var
|
|
36
|
+
var import_hwk_trezor_adapter = require("@onekeyfe/hwk-trezor-adapter");
|
|
37
37
|
var import_hwk_adapter_core2 = require("@onekeyfe/hwk-adapter-core");
|
|
38
38
|
var import_hwk_trezor_connector2 = require("@onekeyfe/hwk-trezor-connector");
|
|
39
39
|
|
|
@@ -41,28 +41,6 @@ var import_hwk_trezor_connector2 = require("@onekeyfe/hwk-trezor-connector");
|
|
|
41
41
|
var import_buffer = require("buffer");
|
|
42
42
|
var import_hwk_adapter_core = require("@onekeyfe/hwk-adapter-core");
|
|
43
43
|
var import_hwk_trezor_connector = require("@onekeyfe/hwk-trezor-connector");
|
|
44
|
-
|
|
45
|
-
// src/bleProfile.ts
|
|
46
|
-
var import_hwk_trezor_adapter = require("@onekeyfe/hwk-trezor-adapter");
|
|
47
|
-
var TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
48
|
-
var TREZOR_BLE_VENDOR = "trezor";
|
|
49
|
-
var TREZOR_BLE_MATCH = {
|
|
50
|
-
serviceUuids: [import_hwk_trezor_adapter.TREZOR_BLE_UUIDS.service],
|
|
51
|
-
namePatterns: ["\\bTrezor\\b", "\\bSafe\\s*7\\b|\\bT3W1\\b"]
|
|
52
|
-
};
|
|
53
|
-
var TREZOR_BLE_CONNECT_PROFILE = {
|
|
54
|
-
vendor: TREZOR_BLE_VENDOR,
|
|
55
|
-
serviceUuid: import_hwk_trezor_adapter.TREZOR_BLE_UUIDS.service,
|
|
56
|
-
writeUuid: import_hwk_trezor_adapter.TREZOR_BLE_UUIDS.write,
|
|
57
|
-
notifyUuid: import_hwk_trezor_adapter.TREZOR_BLE_UUIDS.notify,
|
|
58
|
-
write: {
|
|
59
|
-
mode: "padded",
|
|
60
|
-
chunkSize: import_hwk_trezor_adapter.TREZOR_BLE_PACKET_SIZE,
|
|
61
|
-
chunkDelayMs: TREZOR_BLE_WRITE_CHUNK_DELAY_MS
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// src/TrezorElectronBleTransport.ts
|
|
66
44
|
var disconnectError = (message) => Object.assign(new Error(message), { code: import_hwk_adapter_core.HardwareErrorCode.DeviceDisconnected });
|
|
67
45
|
var notConnectedError = (id) => disconnectError(`Trezor Electron BLE device is not connected: ${id}`);
|
|
68
46
|
var resolveBridge = (options) => {
|
|
@@ -90,8 +68,6 @@ var TrezorElectronBleTransport = class {
|
|
|
90
68
|
async scan(durationMs) {
|
|
91
69
|
try {
|
|
92
70
|
return await this._bridge.scan({
|
|
93
|
-
vendor: TREZOR_BLE_VENDOR,
|
|
94
|
-
match: TREZOR_BLE_MATCH,
|
|
95
71
|
durationMs
|
|
96
72
|
});
|
|
97
73
|
} catch (error) {
|
|
@@ -110,7 +86,7 @@ var TrezorElectronBleTransport = class {
|
|
|
110
86
|
}
|
|
111
87
|
async connect(connectId) {
|
|
112
88
|
if (this._connected.has(connectId)) return;
|
|
113
|
-
await this._bridge.connect(connectId
|
|
89
|
+
await this._bridge.connect(connectId);
|
|
114
90
|
try {
|
|
115
91
|
await this._bridge.subscribe(connectId);
|
|
116
92
|
} catch (error) {
|
|
@@ -222,7 +198,7 @@ var TrezorElectronBleConnector = class extends import_hwk_trezor_connector2.Trez
|
|
|
222
198
|
constructor(options) {
|
|
223
199
|
super({
|
|
224
200
|
connectionType: "ble",
|
|
225
|
-
chunkSize:
|
|
201
|
+
chunkSize: import_hwk_trezor_adapter.TREZOR_BLE_PACKET_SIZE,
|
|
226
202
|
thp: options?.thp,
|
|
227
203
|
deviceSessionFactory: options?.deviceSessionFactory
|
|
228
204
|
});
|
|
@@ -233,13 +209,13 @@ var TrezorElectronBleConnector = class extends import_hwk_trezor_connector2.Trez
|
|
|
233
209
|
async enumerateDevices() {
|
|
234
210
|
const transport = this._ensureTransport();
|
|
235
211
|
const devices = await transport.scan();
|
|
236
|
-
const filtered = devices.filter(
|
|
212
|
+
const filtered = devices.filter(import_hwk_trezor_adapter.isTrezorBleDescriptor);
|
|
237
213
|
if (filtered.length !== devices.length) {
|
|
238
214
|
this._log("info", "ble.connector.enumerate.filtered", {
|
|
239
215
|
transport: "electron-ble",
|
|
240
216
|
descriptorCount: devices.length,
|
|
241
217
|
filteredCount: filtered.length,
|
|
242
|
-
dropped: devices.filter((device) => !(0,
|
|
218
|
+
dropped: devices.filter((device) => !(0, import_hwk_trezor_adapter.isTrezorBleDescriptor)(device)).map(toBleFilterLogSample),
|
|
243
219
|
kept: filtered.map(toBleFilterLogSample)
|
|
244
220
|
});
|
|
245
221
|
}
|
|
@@ -247,7 +223,7 @@ var TrezorElectronBleConnector = class extends import_hwk_trezor_connector2.Trez
|
|
|
247
223
|
connectId: d.id,
|
|
248
224
|
deviceId: "",
|
|
249
225
|
name: d.name ?? d.localName ?? "Trezor Safe 7",
|
|
250
|
-
model:
|
|
226
|
+
model: import_hwk_trezor_adapter.TREZOR_SAFE_7_MODEL,
|
|
251
227
|
connectionType: "ble",
|
|
252
228
|
// Promote the typed BLE fields the device surface already has slots for.
|
|
253
229
|
rssi: d.rssi ?? null,
|
|
@@ -309,7 +285,7 @@ var TrezorElectronBleConnector = class extends import_hwk_trezor_connector2.Trez
|
|
|
309
285
|
connectId,
|
|
310
286
|
deviceId: "",
|
|
311
287
|
name: "Trezor Safe 7",
|
|
312
|
-
model:
|
|
288
|
+
model: import_hwk_trezor_adapter.TREZOR_SAFE_7_MODEL,
|
|
313
289
|
capabilities: { persistentDeviceIdentity: false }
|
|
314
290
|
};
|
|
315
291
|
}
|
|
@@ -356,7 +332,7 @@ function toBleFilterLogSample(device) {
|
|
|
356
332
|
rssi: device.rssi,
|
|
357
333
|
isConnectable: device.isConnectable,
|
|
358
334
|
keys: Object.keys(device).sort(),
|
|
359
|
-
matchesTrezorService: (0,
|
|
335
|
+
matchesTrezorService: (0, import_hwk_trezor_adapter.isTrezorBleDescriptor)(device),
|
|
360
336
|
serviceUUIDs: readStringArrayField(device, "serviceUUIDs"),
|
|
361
337
|
serviceUuids: readStringArrayField(device, "serviceUuids"),
|
|
362
338
|
advertisedServiceUuids: readStringArrayField(device, "advertisedServiceUuids"),
|
|
@@ -369,11 +345,33 @@ function toBleFilterLogSample(device) {
|
|
|
369
345
|
state: device.state
|
|
370
346
|
};
|
|
371
347
|
}
|
|
348
|
+
|
|
349
|
+
// src/constants.ts
|
|
350
|
+
var TREZOR_BLE_CHANNELS = {
|
|
351
|
+
scan: "$onekey-trezor-ble-scan",
|
|
352
|
+
stopScan: "$onekey-trezor-ble-stop-scan",
|
|
353
|
+
connect: "$onekey-trezor-ble-connect",
|
|
354
|
+
disconnect: "$onekey-trezor-ble-disconnect",
|
|
355
|
+
write: "$onekey-trezor-ble-write",
|
|
356
|
+
subscribe: "$onekey-trezor-ble-subscribe",
|
|
357
|
+
unsubscribe: "$onekey-trezor-ble-unsubscribe",
|
|
358
|
+
availability: "$onekey-trezor-ble-availability",
|
|
359
|
+
getDevice: "$onekey-trezor-ble-get-device",
|
|
360
|
+
readRssi: "$onekey-trezor-ble-read-rssi",
|
|
361
|
+
cancelPairing: "$onekey-trezor-ble-cancel-pairing",
|
|
362
|
+
/** push event: main → renderer with assembled BLE notification payload */
|
|
363
|
+
notification: "$onekey-trezor-ble-notification",
|
|
364
|
+
/** push event: main → renderer when device disconnects unexpectedly */
|
|
365
|
+
disconnected: "$onekey-trezor-ble-disconnected"
|
|
366
|
+
};
|
|
367
|
+
var TREZOR_BLE_SCAN_DURATION_MS = 5e3;
|
|
368
|
+
var TREZOR_BLE_POWER_ON_TIMEOUT_MS = 1e4;
|
|
369
|
+
var TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
372
370
|
// Annotate the CommonJS export names for ESM import in node:
|
|
373
371
|
0 && (module.exports = {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
372
|
+
TREZOR_BLE_CHANNELS,
|
|
373
|
+
TREZOR_BLE_POWER_ON_TIMEOUT_MS,
|
|
374
|
+
TREZOR_BLE_SCAN_DURATION_MS,
|
|
377
375
|
TREZOR_BLE_WRITE_CHUNK_DELAY_MS,
|
|
378
376
|
TrezorElectronBleConnector,
|
|
379
377
|
TrezorElectronBleTransport,
|