@onekeyfe/hwk-trezor-connector-electron-ble 1.2.5-alpha.4 → 1.2.5
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 +8 -22
- package/dist/index.d.ts +8 -22
- package/dist/index.js +57 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -86
- 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
|
/**
|
|
@@ -15,7 +17,6 @@ interface TrezorElectronBleTransportOptions {
|
|
|
15
17
|
declare class TrezorElectronBleTransport {
|
|
16
18
|
private readonly _bridge;
|
|
17
19
|
private readonly _connected;
|
|
18
|
-
private readonly _connecting;
|
|
19
20
|
private readonly _readQueues;
|
|
20
21
|
private readonly _pendingReads;
|
|
21
22
|
private readonly _disconnectHandlers;
|
|
@@ -23,10 +24,10 @@ declare class TrezorElectronBleTransport {
|
|
|
23
24
|
private _disposeDisconnectListener?;
|
|
24
25
|
private readonly _logger?;
|
|
25
26
|
constructor(options?: TrezorElectronBleTransportOptions);
|
|
26
|
-
scan(durationMs?: number): Promise<
|
|
27
|
+
scan(durationMs?: number): Promise<TrezorBleDeviceInfo[]>;
|
|
27
28
|
stopScan(): Promise<void>;
|
|
28
29
|
/** Abandon the in-flight connect/pairing in the main process. */
|
|
29
|
-
cancelPairing(
|
|
30
|
+
cancelPairing(): Promise<void>;
|
|
30
31
|
connect(connectId: string): Promise<void>;
|
|
31
32
|
disconnect(connectId: string): Promise<void>;
|
|
32
33
|
write(connectId: string, data: Uint8Array): Promise<void>;
|
|
@@ -35,7 +36,6 @@ declare class TrezorElectronBleTransport {
|
|
|
35
36
|
/** Tear down global listeners — called by the connector's `reset()`. */
|
|
36
37
|
reset(): void;
|
|
37
38
|
private _wireGlobalListeners;
|
|
38
|
-
private _handleDeviceDisconnected;
|
|
39
39
|
private _failPendingReads;
|
|
40
40
|
private _log;
|
|
41
41
|
}
|
|
@@ -62,18 +62,4 @@ declare class TrezorElectronBleConnector extends TrezorConnectorBase {
|
|
|
62
62
|
}
|
|
63
63
|
declare function createTrezorElectronBleConnector(options?: TrezorElectronBleConnectorOptions): TrezorElectronBleConnector;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
declare const TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
67
|
-
declare const TREZOR_BLE_VENDOR = "trezor";
|
|
68
|
-
/**
|
|
69
|
-
* Trezor matcher sent to the vendor-agnostic main process. A name must match every
|
|
70
|
-
* pattern, like `isTrezorSafe7BleName`: "Trezor" plus "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
|
/**
|
|
@@ -15,7 +17,6 @@ interface TrezorElectronBleTransportOptions {
|
|
|
15
17
|
declare class TrezorElectronBleTransport {
|
|
16
18
|
private readonly _bridge;
|
|
17
19
|
private readonly _connected;
|
|
18
|
-
private readonly _connecting;
|
|
19
20
|
private readonly _readQueues;
|
|
20
21
|
private readonly _pendingReads;
|
|
21
22
|
private readonly _disconnectHandlers;
|
|
@@ -23,10 +24,10 @@ declare class TrezorElectronBleTransport {
|
|
|
23
24
|
private _disposeDisconnectListener?;
|
|
24
25
|
private readonly _logger?;
|
|
25
26
|
constructor(options?: TrezorElectronBleTransportOptions);
|
|
26
|
-
scan(durationMs?: number): Promise<
|
|
27
|
+
scan(durationMs?: number): Promise<TrezorBleDeviceInfo[]>;
|
|
27
28
|
stopScan(): Promise<void>;
|
|
28
29
|
/** Abandon the in-flight connect/pairing in the main process. */
|
|
29
|
-
cancelPairing(
|
|
30
|
+
cancelPairing(): Promise<void>;
|
|
30
31
|
connect(connectId: string): Promise<void>;
|
|
31
32
|
disconnect(connectId: string): Promise<void>;
|
|
32
33
|
write(connectId: string, data: Uint8Array): Promise<void>;
|
|
@@ -35,7 +36,6 @@ declare class TrezorElectronBleTransport {
|
|
|
35
36
|
/** Tear down global listeners — called by the connector's `reset()`. */
|
|
36
37
|
reset(): void;
|
|
37
38
|
private _wireGlobalListeners;
|
|
38
|
-
private _handleDeviceDisconnected;
|
|
39
39
|
private _failPendingReads;
|
|
40
40
|
private _log;
|
|
41
41
|
}
|
|
@@ -62,18 +62,4 @@ declare class TrezorElectronBleConnector extends TrezorConnectorBase {
|
|
|
62
62
|
}
|
|
63
63
|
declare function createTrezorElectronBleConnector(options?: TrezorElectronBleConnectorOptions): TrezorElectronBleConnector;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
declare const TREZOR_BLE_WRITE_CHUNK_DELAY_MS = 5;
|
|
67
|
-
declare const TREZOR_BLE_VENDOR = "trezor";
|
|
68
|
-
/**
|
|
69
|
-
* Trezor matcher sent to the vendor-agnostic main process. A name must match every
|
|
70
|
-
* pattern, like `isTrezorSafe7BleName`: "Trezor" plus "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 };
|