@onekeyfe/hwk-adapter-core 1.1.29-alpha.7 → 1.1.29-alpha.9
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-LYVS67EX.js → chunk-BAGEFFFY.js} +3 -3
- package/dist/chunk-BAGEFFFY.js.map +1 -0
- package/dist/{chunk-6JWUE3GT.mjs → chunk-U63HTLGJ.mjs} +3 -3
- package/dist/chunk-U63HTLGJ.mjs.map +1 -0
- package/dist/index.d.mts +33 -16
- package/dist/index.d.ts +33 -16
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{ui-events-BzkI1wZk.d.mts → ui-events-Cb7haAeE.d.mts} +0 -4
- package/dist/{ui-events-BzkI1wZk.d.ts → ui-events-Cb7haAeE.d.ts} +0 -4
- package/dist/ui-events.d.mts +1 -1
- package/dist/ui-events.d.ts +1 -1
- package/dist/ui-events.js +2 -2
- package/dist/ui-events.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-6JWUE3GT.mjs.map +0 -1
- package/dist/chunk-LYVS67EX.js.map +0 -1
|
@@ -3,6 +3,8 @@ var UI_EVENT = "UI_EVENT";
|
|
|
3
3
|
var UI_REQUEST = {
|
|
4
4
|
REQUEST_PIN: "ui-request-pin",
|
|
5
5
|
REQUEST_PASSPHRASE: "ui-request-passphrase",
|
|
6
|
+
// One-way UI notification: device is waiting for passphrase entry on-device.
|
|
7
|
+
// The prompt response path remains RECEIVE_PASSPHRASE with passphraseOnDevice=true.
|
|
6
8
|
REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device",
|
|
7
9
|
REQUEST_BUTTON: "ui-request-button",
|
|
8
10
|
REQUEST_QR_DISPLAY: "ui-request-qr-display",
|
|
@@ -26,7 +28,6 @@ var UI_REQUEST = {
|
|
|
26
28
|
var UI_RESPONSE = {
|
|
27
29
|
RECEIVE_PIN: "receive-pin",
|
|
28
30
|
RECEIVE_PASSPHRASE: "receive-passphrase",
|
|
29
|
-
RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device",
|
|
30
31
|
RECEIVE_QR_RESPONSE: "receive-qr-response",
|
|
31
32
|
RECEIVE_SELECT_DEVICE: "receive-select-device",
|
|
32
33
|
RECEIVE_DEVICE_CONNECT: "receive-device-connect",
|
|
@@ -43,7 +44,6 @@ var UI_REQUEST_DEFAULT_TIMEOUT_MS = 6e5;
|
|
|
43
44
|
var RESPONSE_TO_REQUEST = {
|
|
44
45
|
[UI_RESPONSE.RECEIVE_PIN]: UI_REQUEST.REQUEST_PIN,
|
|
45
46
|
[UI_RESPONSE.RECEIVE_PASSPHRASE]: UI_REQUEST.REQUEST_PASSPHRASE,
|
|
46
|
-
[UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE]: UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE,
|
|
47
47
|
[UI_RESPONSE.RECEIVE_SELECT_DEVICE]: UI_REQUEST.REQUEST_SELECT_DEVICE,
|
|
48
48
|
[UI_RESPONSE.RECEIVE_DEVICE_CONNECT]: UI_REQUEST.REQUEST_DEVICE_CONNECT,
|
|
49
49
|
[UI_RESPONSE.RECEIVE_DEVICE_PERMISSION]: UI_REQUEST.REQUEST_DEVICE_PERMISSION,
|
|
@@ -148,4 +148,4 @@ var UiRequestRegistry = class {
|
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
exports.UI_EVENT = UI_EVENT; exports.UI_REQUEST = UI_REQUEST; exports.UI_RESPONSE = UI_RESPONSE; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_CANCELLED_TAG = UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = UI_REQUEST_TIMEOUT_TAG; exports.UiRequestRegistry = UiRequestRegistry;
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
151
|
+
//# sourceMappingURL=chunk-BAGEFFFY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-BAGEFFFY.js","../src/events/ui-request.ts","../src/utils/UiRequestRegistry.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,SAAA,EAAW,UAAA;AAEjB,IAAM,WAAA,EAAa;AAAA,EACxB,WAAA,EAAa,gBAAA;AAAA,EACb,kBAAA,EAAoB,uBAAA;AAAA;AAAA;AAAA,EAGpB,4BAAA,EAA8B,iCAAA;AAAA,EAC9B,cAAA,EAAgB,mBAAA;AAAA,EAChB,kBAAA,EAAoB,uBAAA;AAAA,EACpB,eAAA,EAAiB,oBAAA;AAAA,EACjB,yBAAA,EAA2B,8BAAA;AAAA,EAC3B,qBAAA,EAAuB,0BAAA;AAAA,EACvB,sBAAA,EAAwB,2BAAA;AAAA;AAAA;AAAA,EAGxB,8BAAA,EAAgC,mCAAA;AAAA;AAAA;AAAA,EAGhC,mBAAA,EAAqB,wBAAA;AAAA,EACrB,kBAAA,EAAoB,uBAAA;AAAA,EACpB,0BAAA,EAA4B,+BAAA;AAAA,EAC5B,eAAA,EAAiB,UAAA;AAAA,EACjB,eAAA,EAAiB,oBAAA;AAAA,EACjB,iBAAA,EAAmB,sBAAA;AAAA,EACnB,YAAA,EAAc;AAChB,CAAA;AAEO,IAAM,YAAA,EAAc;AAAA,EACzB,WAAA,EAAa,aAAA;AAAA,EACb,kBAAA,EAAoB,oBAAA;AAAA,EACpB,mBAAA,EAAqB,qBAAA;AAAA,EACrB,qBAAA,EAAuB,uBAAA;AAAA,EACvB,sBAAA,EAAwB,wBAAA;AAAA,EACxB,yBAAA,EAA2B,2BAAA;AAAA,EAC3B,8BAAA,EAAgC,gCAAA;AAAA,EAChC,mBAAA,EAAqB,qBAAA;AAAA,EACrB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,0B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IAAA,EAAM,KAAK,EAAA,GAAK,IAAA,CAAK,OAAA,EAAS;AACxC,MAAA,YAAA,CAAa,KAAA,CAAM,KAAK,CAAA;AACxB,MAAA,KAAA,CAAM,MAAA;AAAA,QACJ,MAAA,CAAO,MAAA,CAAO,IAAI,KAAA,CAAM,CAAA,YAAA,EAAe,IAAI,CAAA,eAAA,CAAiB,CAAA,EAAG;AAAA,UAC7D,IAAA,EAAM;AAAA,QACR,CAAC;AAAA,MACH,CAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,CAAA;AAAA,EACrB;AAAA,EAEA,KAAA,CAAA,EAAc;AACZ,IAAA,IAAA,CAAK,MAAA,CAAO,CAAA;AAAA,EACd;AAAA,EAEA,UAAA,CAAW,WAAA,EAA+B;AACxC,IAAA,GAAA,CAAI,WAAA,EAAa,OAAO,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,WAAW,CAAA;AACpD,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA;AAAA,EAC7B;AACF,CAAA;AFYA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yYAAC","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-BAGEFFFY.js","sourcesContent":[null,"import type { QrResponseData } from '../types/qr';\n\nexport const UI_EVENT = 'UI_EVENT';\n\nexport const UI_REQUEST = {\n REQUEST_PIN: 'ui-request-pin',\n REQUEST_PASSPHRASE: 'ui-request-passphrase',\n // One-way UI notification: device is waiting for passphrase entry on-device.\n // The prompt response path remains RECEIVE_PASSPHRASE with passphraseOnDevice=true.\n REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request-passphrase-on-device',\n REQUEST_BUTTON: 'ui-request-button',\n REQUEST_QR_DISPLAY: 'ui-request-qr-display',\n REQUEST_QR_SCAN: 'ui-request-qr-scan',\n REQUEST_DEVICE_PERMISSION: 'ui-request-device-permission',\n REQUEST_SELECT_DEVICE: 'ui-request-select-device',\n REQUEST_DEVICE_CONNECT: 'ui-request-device-connect',\n // Ledger BTC App: account index >= 100 requires display=true. Adapter asks\n // the user once per session before promoting the call.\n REQUEST_BTC_HIGH_INDEX_CONFIRM: 'ui-request-btc-high-index-confirm',\n // Required app is not installed; with autoInstallApp on, ask the user\n // whether to install it before retrying the operation.\n REQUEST_INSTALL_APP: 'ui-request-install-app',\n REQUEST_PREEMPTION: 'ui-request-preemption',\n REQUEST_TREZOR_THP_PAIRING: 'ui-request-trezor-thp-pairing',\n CLOSE_UI_WINDOW: 'ui-close',\n DEVICE_PROGRESS: 'ui-device_progress',\n FIRMWARE_PROGRESS: 'ui-firmware-progress',\n FIRMWARE_TIP: 'ui-firmware-tip',\n} as const;\n\nexport const UI_RESPONSE = {\n RECEIVE_PIN: 'receive-pin',\n RECEIVE_PASSPHRASE: 'receive-passphrase',\n RECEIVE_QR_RESPONSE: 'receive-qr-response',\n RECEIVE_SELECT_DEVICE: 'receive-select-device',\n RECEIVE_DEVICE_CONNECT: 'receive-device-connect',\n RECEIVE_DEVICE_PERMISSION: 'receive-device-permission',\n RECEIVE_BTC_HIGH_INDEX_CONFIRM: 'receive-btc-high-index-confirm',\n RECEIVE_INSTALL_APP: 'receive-install-app',\n RECEIVE_PREEMPTION: 'receive-preemption',\n RECEIVE_TREZOR_THP_PAIRING: 'receive-trezor-thp-pairing',\n CANCEL: 'cancel',\n} as const;\n\nexport type DevicePermissionDeniedReason =\n | 'bluetoothTurnedOff'\n | 'permissionDenied'\n | (string & Record<never, never>);\n\nexport type DevicePermissionResponse = {\n granted: boolean;\n reason?: DevicePermissionDeniedReason;\n message?: string;\n};\n\nexport type UiResponseEvent =\n | {\n type: typeof UI_RESPONSE.RECEIVE_PIN;\n payload: string;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;\n payload: {\n value: string;\n passphraseOnDevice?: boolean;\n save?: boolean;\n };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;\n payload: QrResponseData;\n }\n | {\n // sdkConnectId echoes one of the DeviceInfo.connectId values emitted in\n // the REQUEST_SELECT_DEVICE event's `devices` list. Scope is the current\n // search session; may be ephemeral (e.g. Ledger USB DMK UUID).\n type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;\n payload: { sdkConnectId: string };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_DEVICE_PERMISSION;\n payload: DevicePermissionResponse;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_INSTALL_APP;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PREEMPTION;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING;\n payload: {\n selectedMethod?: number | string;\n tag?: string;\n };\n }\n | {\n type: typeof UI_RESPONSE.CANCEL;\n payload?: undefined;\n };\n","import { UI_REQUEST, UI_RESPONSE } from '../events/ui-request';\n\n/** 10 min — every UI request is human-in-the-loop; bias toward \"wait long\". */\nexport const UI_REQUEST_DEFAULT_TIMEOUT_MS = 600_000;\n\nconst RESPONSE_TO_REQUEST: Record<string, string> = {\n [UI_RESPONSE.RECEIVE_PIN]: UI_REQUEST.REQUEST_PIN,\n [UI_RESPONSE.RECEIVE_PASSPHRASE]: UI_REQUEST.REQUEST_PASSPHRASE,\n [UI_RESPONSE.RECEIVE_SELECT_DEVICE]: UI_REQUEST.REQUEST_SELECT_DEVICE,\n [UI_RESPONSE.RECEIVE_DEVICE_CONNECT]: UI_REQUEST.REQUEST_DEVICE_CONNECT,\n [UI_RESPONSE.RECEIVE_DEVICE_PERMISSION]: UI_REQUEST.REQUEST_DEVICE_PERMISSION,\n [UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM]: UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM,\n [UI_RESPONSE.RECEIVE_INSTALL_APP]: UI_REQUEST.REQUEST_INSTALL_APP,\n [UI_RESPONSE.RECEIVE_PREEMPTION]: UI_REQUEST.REQUEST_PREEMPTION,\n [UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING]: UI_REQUEST.REQUEST_TREZOR_THP_PAIRING,\n // RECEIVE_QR_RESPONSE maps to QR_DISPLAY or QR_SCAN — resolved dynamically below.\n};\n\nexport const UI_REQUEST_PREEMPTED_TAG = 'UiRequestPreempted';\nexport const UI_REQUEST_CANCELLED_TAG = 'UiRequestCancelled';\nexport const UI_REQUEST_TIMEOUT_TAG = 'UiRequestTimeout';\n\ntype PendingEntry = {\n resolve: (payload: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n};\n\n/**\n * Per-type single-slot registry for adapter-level UI requests. A new `wait`\n * of the same type supersedes (rejects) the prior pending entry. With the\n * job queue running globally serially, cross-type collisions don't occur in\n * normal flow — same-type preemption is a defensive measure for callers\n * that fire the same request twice without waiting on the first.\n *\n * Unknown response types are dropped silently so the public `uiResponse`\n * entry never throws.\n */\nexport class UiRequestRegistry {\n private pending = new Map<string, PendingEntry>();\n\n wait<T = unknown>(requestType: string, options?: { timeoutMs?: number }): Promise<T> {\n const existing = this.pending.get(requestType);\n if (existing) {\n clearTimeout(existing.timer);\n this.pending.delete(requestType);\n existing.reject(\n Object.assign(new Error(`UI request '${requestType}' was superseded by a new request`), {\n _tag: UI_REQUEST_PREEMPTED_TAG,\n })\n );\n }\n\n const timeoutMs = options?.timeoutMs ?? UI_REQUEST_DEFAULT_TIMEOUT_MS;\n\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n if (this.pending.get(requestType)?.timer === timer) {\n this.pending.delete(requestType);\n reject(\n Object.assign(new Error(`UI request '${requestType}' timed out after ${timeoutMs}ms`), {\n _tag: UI_REQUEST_TIMEOUT_TAG,\n })\n );\n }\n }, timeoutMs);\n\n this.pending.set(requestType, {\n resolve: resolve as (payload: unknown) => void,\n reject,\n timer,\n });\n });\n }\n\n resolve(responseType: string, payload: unknown): void {\n let requestType = RESPONSE_TO_REQUEST[responseType];\n if (responseType === UI_RESPONSE.RECEIVE_QR_RESPONSE) {\n if (this.pending.has(UI_REQUEST.REQUEST_QR_DISPLAY)) {\n requestType = UI_REQUEST.REQUEST_QR_DISPLAY;\n } else if (this.pending.has(UI_REQUEST.REQUEST_QR_SCAN)) {\n requestType = UI_REQUEST.REQUEST_QR_SCAN;\n }\n }\n if (!requestType) return;\n\n const entry = this.pending.get(requestType);\n if (!entry) return;\n\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.resolve(payload);\n }\n\n cancel(requestType?: string): void {\n if (requestType) {\n const entry = this.pending.get(requestType);\n if (!entry) return;\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.reject(\n Object.assign(new Error(`UI request '${requestType}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n return;\n }\n\n for (const [type, entry] of this.pending) {\n clearTimeout(entry.timer);\n entry.reject(\n Object.assign(new Error(`UI request '${type}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n }\n this.pending.clear();\n }\n\n reset(): void {\n this.cancel();\n }\n\n hasPending(requestType?: string): boolean {\n if (requestType) return this.pending.has(requestType);\n return this.pending.size > 0;\n }\n}\n"]}
|
|
@@ -3,6 +3,8 @@ var UI_EVENT = "UI_EVENT";
|
|
|
3
3
|
var UI_REQUEST = {
|
|
4
4
|
REQUEST_PIN: "ui-request-pin",
|
|
5
5
|
REQUEST_PASSPHRASE: "ui-request-passphrase",
|
|
6
|
+
// One-way UI notification: device is waiting for passphrase entry on-device.
|
|
7
|
+
// The prompt response path remains RECEIVE_PASSPHRASE with passphraseOnDevice=true.
|
|
6
8
|
REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device",
|
|
7
9
|
REQUEST_BUTTON: "ui-request-button",
|
|
8
10
|
REQUEST_QR_DISPLAY: "ui-request-qr-display",
|
|
@@ -26,7 +28,6 @@ var UI_REQUEST = {
|
|
|
26
28
|
var UI_RESPONSE = {
|
|
27
29
|
RECEIVE_PIN: "receive-pin",
|
|
28
30
|
RECEIVE_PASSPHRASE: "receive-passphrase",
|
|
29
|
-
RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device",
|
|
30
31
|
RECEIVE_QR_RESPONSE: "receive-qr-response",
|
|
31
32
|
RECEIVE_SELECT_DEVICE: "receive-select-device",
|
|
32
33
|
RECEIVE_DEVICE_CONNECT: "receive-device-connect",
|
|
@@ -43,7 +44,6 @@ var UI_REQUEST_DEFAULT_TIMEOUT_MS = 6e5;
|
|
|
43
44
|
var RESPONSE_TO_REQUEST = {
|
|
44
45
|
[UI_RESPONSE.RECEIVE_PIN]: UI_REQUEST.REQUEST_PIN,
|
|
45
46
|
[UI_RESPONSE.RECEIVE_PASSPHRASE]: UI_REQUEST.REQUEST_PASSPHRASE,
|
|
46
|
-
[UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE]: UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE,
|
|
47
47
|
[UI_RESPONSE.RECEIVE_SELECT_DEVICE]: UI_REQUEST.REQUEST_SELECT_DEVICE,
|
|
48
48
|
[UI_RESPONSE.RECEIVE_DEVICE_CONNECT]: UI_REQUEST.REQUEST_DEVICE_CONNECT,
|
|
49
49
|
[UI_RESPONSE.RECEIVE_DEVICE_PERMISSION]: UI_REQUEST.REQUEST_DEVICE_PERMISSION,
|
|
@@ -148,4 +148,4 @@ export {
|
|
|
148
148
|
UI_REQUEST_TIMEOUT_TAG,
|
|
149
149
|
UiRequestRegistry
|
|
150
150
|
};
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
151
|
+
//# sourceMappingURL=chunk-U63HTLGJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/events/ui-request.ts","../src/utils/UiRequestRegistry.ts"],"sourcesContent":["import type { QrResponseData } from '../types/qr';\n\nexport const UI_EVENT = 'UI_EVENT';\n\nexport const UI_REQUEST = {\n REQUEST_PIN: 'ui-request-pin',\n REQUEST_PASSPHRASE: 'ui-request-passphrase',\n // One-way UI notification: device is waiting for passphrase entry on-device.\n // The prompt response path remains RECEIVE_PASSPHRASE with passphraseOnDevice=true.\n REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request-passphrase-on-device',\n REQUEST_BUTTON: 'ui-request-button',\n REQUEST_QR_DISPLAY: 'ui-request-qr-display',\n REQUEST_QR_SCAN: 'ui-request-qr-scan',\n REQUEST_DEVICE_PERMISSION: 'ui-request-device-permission',\n REQUEST_SELECT_DEVICE: 'ui-request-select-device',\n REQUEST_DEVICE_CONNECT: 'ui-request-device-connect',\n // Ledger BTC App: account index >= 100 requires display=true. Adapter asks\n // the user once per session before promoting the call.\n REQUEST_BTC_HIGH_INDEX_CONFIRM: 'ui-request-btc-high-index-confirm',\n // Required app is not installed; with autoInstallApp on, ask the user\n // whether to install it before retrying the operation.\n REQUEST_INSTALL_APP: 'ui-request-install-app',\n REQUEST_PREEMPTION: 'ui-request-preemption',\n REQUEST_TREZOR_THP_PAIRING: 'ui-request-trezor-thp-pairing',\n CLOSE_UI_WINDOW: 'ui-close',\n DEVICE_PROGRESS: 'ui-device_progress',\n FIRMWARE_PROGRESS: 'ui-firmware-progress',\n FIRMWARE_TIP: 'ui-firmware-tip',\n} as const;\n\nexport const UI_RESPONSE = {\n RECEIVE_PIN: 'receive-pin',\n RECEIVE_PASSPHRASE: 'receive-passphrase',\n RECEIVE_QR_RESPONSE: 'receive-qr-response',\n RECEIVE_SELECT_DEVICE: 'receive-select-device',\n RECEIVE_DEVICE_CONNECT: 'receive-device-connect',\n RECEIVE_DEVICE_PERMISSION: 'receive-device-permission',\n RECEIVE_BTC_HIGH_INDEX_CONFIRM: 'receive-btc-high-index-confirm',\n RECEIVE_INSTALL_APP: 'receive-install-app',\n RECEIVE_PREEMPTION: 'receive-preemption',\n RECEIVE_TREZOR_THP_PAIRING: 'receive-trezor-thp-pairing',\n CANCEL: 'cancel',\n} as const;\n\nexport type DevicePermissionDeniedReason =\n | 'bluetoothTurnedOff'\n | 'permissionDenied'\n | (string & Record<never, never>);\n\nexport type DevicePermissionResponse = {\n granted: boolean;\n reason?: DevicePermissionDeniedReason;\n message?: string;\n};\n\nexport type UiResponseEvent =\n | {\n type: typeof UI_RESPONSE.RECEIVE_PIN;\n payload: string;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;\n payload: {\n value: string;\n passphraseOnDevice?: boolean;\n save?: boolean;\n };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;\n payload: QrResponseData;\n }\n | {\n // sdkConnectId echoes one of the DeviceInfo.connectId values emitted in\n // the REQUEST_SELECT_DEVICE event's `devices` list. Scope is the current\n // search session; may be ephemeral (e.g. Ledger USB DMK UUID).\n type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;\n payload: { sdkConnectId: string };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_DEVICE_PERMISSION;\n payload: DevicePermissionResponse;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_INSTALL_APP;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PREEMPTION;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING;\n payload: {\n selectedMethod?: number | string;\n tag?: string;\n };\n }\n | {\n type: typeof UI_RESPONSE.CANCEL;\n payload?: undefined;\n };\n","import { UI_REQUEST, UI_RESPONSE } from '../events/ui-request';\n\n/** 10 min — every UI request is human-in-the-loop; bias toward \"wait long\". */\nexport const UI_REQUEST_DEFAULT_TIMEOUT_MS = 600_000;\n\nconst RESPONSE_TO_REQUEST: Record<string, string> = {\n [UI_RESPONSE.RECEIVE_PIN]: UI_REQUEST.REQUEST_PIN,\n [UI_RESPONSE.RECEIVE_PASSPHRASE]: UI_REQUEST.REQUEST_PASSPHRASE,\n [UI_RESPONSE.RECEIVE_SELECT_DEVICE]: UI_REQUEST.REQUEST_SELECT_DEVICE,\n [UI_RESPONSE.RECEIVE_DEVICE_CONNECT]: UI_REQUEST.REQUEST_DEVICE_CONNECT,\n [UI_RESPONSE.RECEIVE_DEVICE_PERMISSION]: UI_REQUEST.REQUEST_DEVICE_PERMISSION,\n [UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM]: UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM,\n [UI_RESPONSE.RECEIVE_INSTALL_APP]: UI_REQUEST.REQUEST_INSTALL_APP,\n [UI_RESPONSE.RECEIVE_PREEMPTION]: UI_REQUEST.REQUEST_PREEMPTION,\n [UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING]: UI_REQUEST.REQUEST_TREZOR_THP_PAIRING,\n // RECEIVE_QR_RESPONSE maps to QR_DISPLAY or QR_SCAN — resolved dynamically below.\n};\n\nexport const UI_REQUEST_PREEMPTED_TAG = 'UiRequestPreempted';\nexport const UI_REQUEST_CANCELLED_TAG = 'UiRequestCancelled';\nexport const UI_REQUEST_TIMEOUT_TAG = 'UiRequestTimeout';\n\ntype PendingEntry = {\n resolve: (payload: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n};\n\n/**\n * Per-type single-slot registry for adapter-level UI requests. A new `wait`\n * of the same type supersedes (rejects) the prior pending entry. With the\n * job queue running globally serially, cross-type collisions don't occur in\n * normal flow — same-type preemption is a defensive measure for callers\n * that fire the same request twice without waiting on the first.\n *\n * Unknown response types are dropped silently so the public `uiResponse`\n * entry never throws.\n */\nexport class UiRequestRegistry {\n private pending = new Map<string, PendingEntry>();\n\n wait<T = unknown>(requestType: string, options?: { timeoutMs?: number }): Promise<T> {\n const existing = this.pending.get(requestType);\n if (existing) {\n clearTimeout(existing.timer);\n this.pending.delete(requestType);\n existing.reject(\n Object.assign(new Error(`UI request '${requestType}' was superseded by a new request`), {\n _tag: UI_REQUEST_PREEMPTED_TAG,\n })\n );\n }\n\n const timeoutMs = options?.timeoutMs ?? UI_REQUEST_DEFAULT_TIMEOUT_MS;\n\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n if (this.pending.get(requestType)?.timer === timer) {\n this.pending.delete(requestType);\n reject(\n Object.assign(new Error(`UI request '${requestType}' timed out after ${timeoutMs}ms`), {\n _tag: UI_REQUEST_TIMEOUT_TAG,\n })\n );\n }\n }, timeoutMs);\n\n this.pending.set(requestType, {\n resolve: resolve as (payload: unknown) => void,\n reject,\n timer,\n });\n });\n }\n\n resolve(responseType: string, payload: unknown): void {\n let requestType = RESPONSE_TO_REQUEST[responseType];\n if (responseType === UI_RESPONSE.RECEIVE_QR_RESPONSE) {\n if (this.pending.has(UI_REQUEST.REQUEST_QR_DISPLAY)) {\n requestType = UI_REQUEST.REQUEST_QR_DISPLAY;\n } else if (this.pending.has(UI_REQUEST.REQUEST_QR_SCAN)) {\n requestType = UI_REQUEST.REQUEST_QR_SCAN;\n }\n }\n if (!requestType) return;\n\n const entry = this.pending.get(requestType);\n if (!entry) return;\n\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.resolve(payload);\n }\n\n cancel(requestType?: string): void {\n if (requestType) {\n const entry = this.pending.get(requestType);\n if (!entry) return;\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.reject(\n Object.assign(new Error(`UI request '${requestType}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n return;\n }\n\n for (const [type, entry] of this.pending) {\n clearTimeout(entry.timer);\n entry.reject(\n Object.assign(new Error(`UI request '${type}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n }\n this.pending.clear();\n }\n\n reset(): void {\n this.cancel();\n }\n\n hasPending(requestType?: string): boolean {\n if (requestType) return this.pending.has(requestType);\n return this.pending.size > 0;\n }\n}\n"],"mappings":";AAEO,IAAM,WAAW;AAEjB,IAAM,aAAa;AAAA,EACxB,aAAa;AAAA,EACb,oBAAoB;AAAA;AAAA;AAAA,EAGpB,8BAA8B;AAAA,EAC9B,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,2BAA2B;AAAA,EAC3B,uBAAuB;AAAA,EACvB,wBAAwB;AAAA;AAAA;AAAA,EAGxB,gCAAgC;AAAA;AAAA;AAAA,EAGhC,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,4BAA4B;AAAA,EAC5B,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,cAAc;AAChB;AAEO,IAAM,cAAc;AAAA,EACzB,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,gCAAgC;AAAA,EAChC,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,4BAA4B;AAAA,EAC5B,QAAQ;AACV;;;ACvCO,IAAM,gCAAgC;AAE7C,IAAM,sBAA8C;AAAA,EAClD,CAAC,YAAY,WAAW,GAAG,WAAW;AAAA,EACtC,CAAC,YAAY,kBAAkB,GAAG,WAAW;AAAA,EAC7C,CAAC,YAAY,qBAAqB,GAAG,WAAW;AAAA,EAChD,CAAC,YAAY,sBAAsB,GAAG,WAAW;AAAA,EACjD,CAAC,YAAY,yBAAyB,GAAG,WAAW;AAAA,EACpD,CAAC,YAAY,8BAA8B,GAAG,WAAW;AAAA,EACzD,CAAC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I,WAAW,eAAe,GAAG;AACvD,sBAAc,WAAW;AAAA,MAC3B;AAAA,IACF;AACA,QAAI,CAAC,YAAa;AAElB,UAAM,QAAQ,KAAK,QAAQ,IAAI,WAAW;AAC1C,QAAI,CAAC,MAAO;AAEZ,iBAAa,MAAM,KAAK;AACxB,SAAK,QAAQ,OAAO,WAAW;AAC/B,UAAM,QAAQ,OAAO;AAAA,EACvB;AAAA,EAEA,OAAO,aAA4B;AACjC,QAAI,aAAa;AACf,YAAM,QAAQ,KAAK,QAAQ,IAAI,WAAW;AAC1C,UAAI,CAAC,MAAO;AACZ,mBAAa,MAAM,KAAK;AACxB,WAAK,QAAQ,OAAO,WAAW;AAC/B,YAAM;AAAA,QACJ,OAAO,OAAO,IAAI,MAAM,eAAe,WAAW,iBAAiB,GAAG;AAAA,UACpE,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AACA;AAAA,IACF;AAEA,eAAW,CAAC,MAAM,KAAK,KAAK,KAAK,SAAS;AACxC,mBAAa,MAAM,KAAK;AACxB,YAAM;AAAA,QACJ,OAAO,OAAO,IAAI,MAAM,eAAe,IAAI,iBAAiB,GAAG;AAAA,UAC7D,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AAAA,IACF;AACA,SAAK,QAAQ,MAAM;AAAA,EACrB;AAAA,EAEA,QAAc;AACZ,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,WAAW,aAA+B;AACxC,QAAI,YAAa,QAAO,KAAK,QAAQ,IAAI,WAAW;AACpD,WAAO,KAAK,QAAQ,OAAO;AAAA,EAC7B;AACF;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HardwareErrorCode } from './errors.mjs';
|
|
2
2
|
export { HwkError, IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage } from './errors.mjs';
|
|
3
|
-
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-
|
|
4
|
-
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, c as QrResponseData, d as UI_EVENT, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry } from './ui-events-
|
|
3
|
+
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-Cb7haAeE.mjs';
|
|
4
|
+
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, c as QrResponseData, d as UI_EVENT, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry } from './ui-events-Cb7haAeE.mjs';
|
|
5
5
|
|
|
6
6
|
interface Success<T> {
|
|
7
7
|
success: true;
|
|
@@ -547,7 +547,8 @@ interface SolSignTxParams extends PassphraseStateAware {
|
|
|
547
547
|
/** Hex-encoded serialized transaction bytes (no 0x prefix) */
|
|
548
548
|
serializedTx: string;
|
|
549
549
|
additionalInfo?: {
|
|
550
|
-
|
|
550
|
+
/** Trezor Solana token definition bytes as a hex string. */
|
|
551
|
+
encodedToken?: string;
|
|
551
552
|
tokenAccountsInfos?: Array<{
|
|
552
553
|
baseAddress: string;
|
|
553
554
|
tokenProgram: string;
|
|
@@ -1298,18 +1299,32 @@ interface EvmAddress {
|
|
|
1298
1299
|
/** Device-reported secp256k1 public key; populated when the transport exposes it. */
|
|
1299
1300
|
publicKey?: string;
|
|
1300
1301
|
}
|
|
1301
|
-
interface
|
|
1302
|
+
interface EvmSignTxBaseParams extends PassphraseStateAware {
|
|
1302
1303
|
path: string;
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1304
|
+
chainId?: number;
|
|
1305
|
+
}
|
|
1306
|
+
/** Ledger shape: the whole RLP-serialized tx (0x-prefixed or plain hex); structured fields forbidden. */
|
|
1307
|
+
interface EvmSignTxLedgerParams extends EvmSignTxBaseParams {
|
|
1308
|
+
serializedTx: string;
|
|
1309
|
+
to?: never;
|
|
1310
|
+
value?: never;
|
|
1311
|
+
nonce?: never;
|
|
1312
|
+
gasLimit?: never;
|
|
1313
|
+
gasPrice?: never;
|
|
1314
|
+
txType?: never;
|
|
1315
|
+
maxFeePerGas?: never;
|
|
1316
|
+
maxPriorityFeePerGas?: never;
|
|
1317
|
+
accessList?: never;
|
|
1318
|
+
data?: never;
|
|
1319
|
+
paymentRequest?: never;
|
|
1320
|
+
ethereumDefinitions?: never;
|
|
1321
|
+
}
|
|
1322
|
+
/** Trezor shape: structured EthereumSignTx protobuf fields; serializedTx forbidden. */
|
|
1323
|
+
interface EvmSignTxTrezorParams extends EvmSignTxBaseParams {
|
|
1324
|
+
serializedTx?: never;
|
|
1309
1325
|
/** Contract address or recipient. Optional for contract deployment transactions. */
|
|
1310
1326
|
to?: string;
|
|
1311
1327
|
value?: string;
|
|
1312
|
-
chainId?: number;
|
|
1313
1328
|
nonce?: string;
|
|
1314
1329
|
gasLimit?: string;
|
|
1315
1330
|
gasPrice?: string;
|
|
@@ -1324,11 +1339,13 @@ interface EvmSignTxParams extends PassphraseStateAware {
|
|
|
1324
1339
|
paymentRequest?: EvmPaymentRequest;
|
|
1325
1340
|
ethereumDefinitions?: EvmEthereumDefinitions;
|
|
1326
1341
|
}
|
|
1342
|
+
/** Mutually exclusive vendor shapes; each adapter narrows to its own. */
|
|
1343
|
+
type EvmSignTxParams = EvmSignTxLedgerParams | EvmSignTxTrezorParams;
|
|
1327
1344
|
interface EvmEthereumDefinitions {
|
|
1328
|
-
/** Trezor Ethereum network definition
|
|
1329
|
-
encodedNetwork?:
|
|
1330
|
-
/** Trezor Ethereum token definition
|
|
1331
|
-
encodedToken?:
|
|
1345
|
+
/** Trezor Ethereum network definition bytes as a hex string. */
|
|
1346
|
+
encodedNetwork?: string;
|
|
1347
|
+
/** Trezor Ethereum token definition bytes as a hex string. */
|
|
1348
|
+
encodedToken?: string;
|
|
1332
1349
|
}
|
|
1333
1350
|
interface EvmPaymentRequestMemo {
|
|
1334
1351
|
textMemo?: {
|
|
@@ -1633,4 +1650,4 @@ declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams):
|
|
|
1633
1650
|
|
|
1634
1651
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
1635
1652
|
|
|
1636
|
-
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPaymentRequest, type BtcPaymentRequestMemo, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorCallResult, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_CONNECT_RETRY_DELAY_MS, DEVICE_EVENT, type DetectableHardwareVendor, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareMethodMetadata, type HardwareMethodName, type HardwareUiEvent, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareWallet, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type JobOptions, type NullableCallArg, type PassphraseResponse, type PassphraseStateAware, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, type SdkEvent, type SearchDevicesOptions, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiResponseEvent, type VendorType, batchCall, buildUnsupportedMethodResponse, bytesToHex, compareSemver, createBridgedConnector, createCombinedConnector, deriveDeviceFingerprint, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hexToBytes, isAllNetworkMethodName, isKnownNonTargetHardwareVendor, padHex64, rehydrateConnectorError, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };
|
|
1653
|
+
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPaymentRequest, type BtcPaymentRequestMemo, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorCallResult, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_CONNECT_RETRY_DELAY_MS, DEVICE_EVENT, type DetectableHardwareVendor, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxLedgerParams, type EvmSignTxParams, type EvmSignTxTrezorParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareMethodMetadata, type HardwareMethodName, type HardwareUiEvent, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareWallet, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type JobOptions, type NullableCallArg, type PassphraseResponse, type PassphraseStateAware, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, type SdkEvent, type SearchDevicesOptions, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiResponseEvent, type VendorType, batchCall, buildUnsupportedMethodResponse, bytesToHex, compareSemver, createBridgedConnector, createCombinedConnector, deriveDeviceFingerprint, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hexToBytes, isAllNetworkMethodName, isKnownNonTargetHardwareVendor, padHex64, rehydrateConnectorError, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HardwareErrorCode } from './errors.js';
|
|
2
2
|
export { HwkError, IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage } from './errors.js';
|
|
3
|
-
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-
|
|
4
|
-
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, c as QrResponseData, d as UI_EVENT, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry } from './ui-events-
|
|
3
|
+
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-Cb7haAeE.js';
|
|
4
|
+
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, c as QrResponseData, d as UI_EVENT, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry } from './ui-events-Cb7haAeE.js';
|
|
5
5
|
|
|
6
6
|
interface Success<T> {
|
|
7
7
|
success: true;
|
|
@@ -547,7 +547,8 @@ interface SolSignTxParams extends PassphraseStateAware {
|
|
|
547
547
|
/** Hex-encoded serialized transaction bytes (no 0x prefix) */
|
|
548
548
|
serializedTx: string;
|
|
549
549
|
additionalInfo?: {
|
|
550
|
-
|
|
550
|
+
/** Trezor Solana token definition bytes as a hex string. */
|
|
551
|
+
encodedToken?: string;
|
|
551
552
|
tokenAccountsInfos?: Array<{
|
|
552
553
|
baseAddress: string;
|
|
553
554
|
tokenProgram: string;
|
|
@@ -1298,18 +1299,32 @@ interface EvmAddress {
|
|
|
1298
1299
|
/** Device-reported secp256k1 public key; populated when the transport exposes it. */
|
|
1299
1300
|
publicKey?: string;
|
|
1300
1301
|
}
|
|
1301
|
-
interface
|
|
1302
|
+
interface EvmSignTxBaseParams extends PassphraseStateAware {
|
|
1302
1303
|
path: string;
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1304
|
+
chainId?: number;
|
|
1305
|
+
}
|
|
1306
|
+
/** Ledger shape: the whole RLP-serialized tx (0x-prefixed or plain hex); structured fields forbidden. */
|
|
1307
|
+
interface EvmSignTxLedgerParams extends EvmSignTxBaseParams {
|
|
1308
|
+
serializedTx: string;
|
|
1309
|
+
to?: never;
|
|
1310
|
+
value?: never;
|
|
1311
|
+
nonce?: never;
|
|
1312
|
+
gasLimit?: never;
|
|
1313
|
+
gasPrice?: never;
|
|
1314
|
+
txType?: never;
|
|
1315
|
+
maxFeePerGas?: never;
|
|
1316
|
+
maxPriorityFeePerGas?: never;
|
|
1317
|
+
accessList?: never;
|
|
1318
|
+
data?: never;
|
|
1319
|
+
paymentRequest?: never;
|
|
1320
|
+
ethereumDefinitions?: never;
|
|
1321
|
+
}
|
|
1322
|
+
/** Trezor shape: structured EthereumSignTx protobuf fields; serializedTx forbidden. */
|
|
1323
|
+
interface EvmSignTxTrezorParams extends EvmSignTxBaseParams {
|
|
1324
|
+
serializedTx?: never;
|
|
1309
1325
|
/** Contract address or recipient. Optional for contract deployment transactions. */
|
|
1310
1326
|
to?: string;
|
|
1311
1327
|
value?: string;
|
|
1312
|
-
chainId?: number;
|
|
1313
1328
|
nonce?: string;
|
|
1314
1329
|
gasLimit?: string;
|
|
1315
1330
|
gasPrice?: string;
|
|
@@ -1324,11 +1339,13 @@ interface EvmSignTxParams extends PassphraseStateAware {
|
|
|
1324
1339
|
paymentRequest?: EvmPaymentRequest;
|
|
1325
1340
|
ethereumDefinitions?: EvmEthereumDefinitions;
|
|
1326
1341
|
}
|
|
1342
|
+
/** Mutually exclusive vendor shapes; each adapter narrows to its own. */
|
|
1343
|
+
type EvmSignTxParams = EvmSignTxLedgerParams | EvmSignTxTrezorParams;
|
|
1327
1344
|
interface EvmEthereumDefinitions {
|
|
1328
|
-
/** Trezor Ethereum network definition
|
|
1329
|
-
encodedNetwork?:
|
|
1330
|
-
/** Trezor Ethereum token definition
|
|
1331
|
-
encodedToken?:
|
|
1345
|
+
/** Trezor Ethereum network definition bytes as a hex string. */
|
|
1346
|
+
encodedNetwork?: string;
|
|
1347
|
+
/** Trezor Ethereum token definition bytes as a hex string. */
|
|
1348
|
+
encodedToken?: string;
|
|
1332
1349
|
}
|
|
1333
1350
|
interface EvmPaymentRequestMemo {
|
|
1334
1351
|
textMemo?: {
|
|
@@ -1633,4 +1650,4 @@ declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams):
|
|
|
1633
1650
|
|
|
1634
1651
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
1635
1652
|
|
|
1636
|
-
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPaymentRequest, type BtcPaymentRequestMemo, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorCallResult, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_CONNECT_RETRY_DELAY_MS, DEVICE_EVENT, type DetectableHardwareVendor, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareMethodMetadata, type HardwareMethodName, type HardwareUiEvent, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareWallet, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type JobOptions, type NullableCallArg, type PassphraseResponse, type PassphraseStateAware, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, type SdkEvent, type SearchDevicesOptions, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiResponseEvent, type VendorType, batchCall, buildUnsupportedMethodResponse, bytesToHex, compareSemver, createBridgedConnector, createCombinedConnector, deriveDeviceFingerprint, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hexToBytes, isAllNetworkMethodName, isKnownNonTargetHardwareVendor, padHex64, rehydrateConnectorError, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };
|
|
1653
|
+
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPaymentRequest, type BtcPaymentRequestMemo, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorCallResult, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_CONNECT_RETRY_DELAY_MS, DEVICE_EVENT, type DetectableHardwareVendor, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxLedgerParams, type EvmSignTxParams, type EvmSignTxTrezorParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareMethodMetadata, type HardwareMethodName, type HardwareUiEvent, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareWallet, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type JobOptions, type NullableCallArg, type PassphraseResponse, type PassphraseStateAware, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, type SdkEvent, type SearchDevicesOptions, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiResponseEvent, type VendorType, batchCall, buildUnsupportedMethodResponse, bytesToHex, compareSemver, createBridgedConnector, createCombinedConnector, deriveDeviceFingerprint, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hexToBytes, isAllNetworkMethodName, isKnownNonTargetHardwareVendor, padHex64, rehydrateConnectorError, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var _chunkFQQ2N5EWjs = require('./chunk-FQQ2N5EW.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkBAGEFFFYjs = require('./chunk-BAGEFFFY.js');
|
|
17
17
|
|
|
18
18
|
// src/types/response.ts
|
|
19
19
|
function success(payload) {
|
|
@@ -760,5 +760,5 @@ var DEVICE_CONNECT_RETRY_DELAY_MS = 1e3;
|
|
|
760
760
|
|
|
761
761
|
|
|
762
762
|
|
|
763
|
-
exports.ALL_NETWORK_METHOD_NAMES = ALL_NETWORK_METHOD_NAMES; exports.CHAIN_FINGERPRINT_PATHS = CHAIN_FINGERPRINT_PATHS; exports.DEVICE = DEVICE; exports.DEVICE_CONNECT_RETRY_DELAY_MS = DEVICE_CONNECT_RETRY_DELAY_MS; exports.DEVICE_EVENT = DEVICE_EVENT; exports.DeviceJobQueue = DeviceJobQueue; exports.EConnectorInteraction = EConnectorInteraction; exports.HARDWARE_METHOD_CATALOG = HARDWARE_METHOD_CATALOG; exports.HardwareErrorCode = _chunkFQQ2N5EWjs.HardwareErrorCode; exports.ORPHAN_ELIGIBLE_ERROR_CODES = _chunkFQQ2N5EWjs.ORPHAN_ELIGIBLE_ERROR_CODES; exports.SDK = SDK; exports.TypedEventEmitter = TypedEventEmitter; exports.UI_EVENT =
|
|
763
|
+
exports.ALL_NETWORK_METHOD_NAMES = ALL_NETWORK_METHOD_NAMES; exports.CHAIN_FINGERPRINT_PATHS = CHAIN_FINGERPRINT_PATHS; exports.DEVICE = DEVICE; exports.DEVICE_CONNECT_RETRY_DELAY_MS = DEVICE_CONNECT_RETRY_DELAY_MS; exports.DEVICE_EVENT = DEVICE_EVENT; exports.DeviceJobQueue = DeviceJobQueue; exports.EConnectorInteraction = EConnectorInteraction; exports.HARDWARE_METHOD_CATALOG = HARDWARE_METHOD_CATALOG; exports.HardwareErrorCode = _chunkFQQ2N5EWjs.HardwareErrorCode; exports.ORPHAN_ELIGIBLE_ERROR_CODES = _chunkFQQ2N5EWjs.ORPHAN_ELIGIBLE_ERROR_CODES; exports.SDK = SDK; exports.TypedEventEmitter = TypedEventEmitter; exports.UI_EVENT = _chunkBAGEFFFYjs.UI_EVENT; exports.UI_REQUEST = _chunkBAGEFFFYjs.UI_REQUEST; exports.UI_REQUEST_CANCELLED_TAG = _chunkBAGEFFFYjs.UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = _chunkBAGEFFFYjs.UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = _chunkBAGEFFFYjs.UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = _chunkBAGEFFFYjs.UI_REQUEST_TIMEOUT_TAG; exports.UI_RESPONSE = _chunkBAGEFFFYjs.UI_RESPONSE; exports.UiRequestRegistry = _chunkBAGEFFFYjs.UiRequestRegistry; exports.batchCall = batchCall; exports.buildUnsupportedMethodResponse = buildUnsupportedMethodResponse; exports.bytesToHex = bytesToHex2; exports.compareSemver = compareSemver; exports.createBridgedConnector = createBridgedConnector; exports.createCombinedConnector = createCombinedConnector; exports.createHwkError = _chunkFQQ2N5EWjs.createHwkError; exports.deriveDeviceFingerprint = deriveDeviceFingerprint; exports.detectHardwareVendorFromDescriptor = detectHardwareVendorFromDescriptor; exports.enrichErrorMessage = _chunkFQQ2N5EWjs.enrichErrorMessage; exports.ensure0x = ensure0x; exports.failure = failure; exports.getAllNetworkMethodChain = getAllNetworkMethodChain; exports.getHardwareMethodMetadata = getHardwareMethodMetadata; exports.hexToBytes = hexToBytes; exports.isAllNetworkMethodName = isAllNetworkMethodName; exports.isKnownNonTargetHardwareVendor = isKnownNonTargetHardwareVendor; exports.padHex64 = padHex64; exports.rehydrateConnectorError = rehydrateConnectorError; exports.runAllNetworkGetAddress = runAllNetworkGetAddress; exports.serializeConnectorError = serializeConnectorError; exports.stripHex = stripHex; exports.success = success;
|
|
764
764
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -31,7 +31,6 @@ declare const UI_REQUEST: {
|
|
|
31
31
|
declare const UI_RESPONSE: {
|
|
32
32
|
readonly RECEIVE_PIN: "receive-pin";
|
|
33
33
|
readonly RECEIVE_PASSPHRASE: "receive-passphrase";
|
|
34
|
-
readonly RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device";
|
|
35
34
|
readonly RECEIVE_QR_RESPONSE: "receive-qr-response";
|
|
36
35
|
readonly RECEIVE_SELECT_DEVICE: "receive-select-device";
|
|
37
36
|
readonly RECEIVE_DEVICE_CONNECT: "receive-device-connect";
|
|
@@ -58,9 +57,6 @@ type UiResponseEvent = {
|
|
|
58
57
|
passphraseOnDevice?: boolean;
|
|
59
58
|
save?: boolean;
|
|
60
59
|
};
|
|
61
|
-
} | {
|
|
62
|
-
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE;
|
|
63
|
-
payload?: undefined;
|
|
64
60
|
} | {
|
|
65
61
|
type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;
|
|
66
62
|
payload: QrResponseData;
|
|
@@ -31,7 +31,6 @@ declare const UI_REQUEST: {
|
|
|
31
31
|
declare const UI_RESPONSE: {
|
|
32
32
|
readonly RECEIVE_PIN: "receive-pin";
|
|
33
33
|
readonly RECEIVE_PASSPHRASE: "receive-passphrase";
|
|
34
|
-
readonly RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device";
|
|
35
34
|
readonly RECEIVE_QR_RESPONSE: "receive-qr-response";
|
|
36
35
|
readonly RECEIVE_SELECT_DEVICE: "receive-select-device";
|
|
37
36
|
readonly RECEIVE_DEVICE_CONNECT: "receive-device-connect";
|
|
@@ -58,9 +57,6 @@ type UiResponseEvent = {
|
|
|
58
57
|
passphraseOnDevice?: boolean;
|
|
59
58
|
save?: boolean;
|
|
60
59
|
};
|
|
61
|
-
} | {
|
|
62
|
-
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE;
|
|
63
|
-
payload?: undefined;
|
|
64
60
|
} | {
|
|
65
61
|
type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;
|
|
66
62
|
payload: QrResponseData;
|
package/dist/ui-events.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, d as UI_EVENT, a as UI_REQUEST, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry, U as UiResponseEvent } from './ui-events-
|
|
1
|
+
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, d as UI_EVENT, a as UI_REQUEST, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry, U as UiResponseEvent } from './ui-events-Cb7haAeE.mjs';
|
package/dist/ui-events.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, d as UI_EVENT, a as UI_REQUEST, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry, U as UiResponseEvent } from './ui-events-
|
|
1
|
+
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, d as UI_EVENT, a as UI_REQUEST, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry, U as UiResponseEvent } from './ui-events-Cb7haAeE.js';
|
package/dist/ui-events.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkBAGEFFFYjs = require('./chunk-BAGEFFFY.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -17,5 +17,5 @@ var _chunkLYVS67EXjs = require('./chunk-LYVS67EX.js');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
exports.UI_EVENT =
|
|
20
|
+
exports.UI_EVENT = _chunkBAGEFFFYjs.UI_EVENT; exports.UI_REQUEST = _chunkBAGEFFFYjs.UI_REQUEST; exports.UI_REQUEST_CANCELLED_TAG = _chunkBAGEFFFYjs.UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = _chunkBAGEFFFYjs.UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = _chunkBAGEFFFYjs.UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = _chunkBAGEFFFYjs.UI_REQUEST_TIMEOUT_TAG; exports.UI_RESPONSE = _chunkBAGEFFFYjs.UI_RESPONSE; exports.UiRequestRegistry = _chunkBAGEFFFYjs.UiRequestRegistry;
|
|
21
21
|
//# sourceMappingURL=ui-events.js.map
|
package/dist/ui-events.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hwk-adapter-core",
|
|
3
|
-
"version": "1.1.29-alpha.
|
|
3
|
+
"version": "1.1.29-alpha.9",
|
|
4
4
|
"description": "Shared types and utilities for OneKey hardware wallet kit",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"tsup": "^8.0.0",
|
|
71
71
|
"typescript": "^5.4.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "5995ca8b4e66f1a5949273087a5c80338f8af3c5"
|
|
74
74
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/events/ui-request.ts","../src/utils/UiRequestRegistry.ts"],"sourcesContent":["import type { QrResponseData } from '../types/qr';\n\nexport const UI_EVENT = 'UI_EVENT';\n\nexport const UI_REQUEST = {\n REQUEST_PIN: 'ui-request-pin',\n REQUEST_PASSPHRASE: 'ui-request-passphrase',\n REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request-passphrase-on-device',\n REQUEST_BUTTON: 'ui-request-button',\n REQUEST_QR_DISPLAY: 'ui-request-qr-display',\n REQUEST_QR_SCAN: 'ui-request-qr-scan',\n REQUEST_DEVICE_PERMISSION: 'ui-request-device-permission',\n REQUEST_SELECT_DEVICE: 'ui-request-select-device',\n REQUEST_DEVICE_CONNECT: 'ui-request-device-connect',\n // Ledger BTC App: account index >= 100 requires display=true. Adapter asks\n // the user once per session before promoting the call.\n REQUEST_BTC_HIGH_INDEX_CONFIRM: 'ui-request-btc-high-index-confirm',\n // Required app is not installed; with autoInstallApp on, ask the user\n // whether to install it before retrying the operation.\n REQUEST_INSTALL_APP: 'ui-request-install-app',\n REQUEST_PREEMPTION: 'ui-request-preemption',\n REQUEST_TREZOR_THP_PAIRING: 'ui-request-trezor-thp-pairing',\n CLOSE_UI_WINDOW: 'ui-close',\n DEVICE_PROGRESS: 'ui-device_progress',\n FIRMWARE_PROGRESS: 'ui-firmware-progress',\n FIRMWARE_TIP: 'ui-firmware-tip',\n} as const;\n\nexport const UI_RESPONSE = {\n RECEIVE_PIN: 'receive-pin',\n RECEIVE_PASSPHRASE: 'receive-passphrase',\n RECEIVE_PASSPHRASE_ON_DEVICE: 'receive-passphrase-on-device',\n RECEIVE_QR_RESPONSE: 'receive-qr-response',\n RECEIVE_SELECT_DEVICE: 'receive-select-device',\n RECEIVE_DEVICE_CONNECT: 'receive-device-connect',\n RECEIVE_DEVICE_PERMISSION: 'receive-device-permission',\n RECEIVE_BTC_HIGH_INDEX_CONFIRM: 'receive-btc-high-index-confirm',\n RECEIVE_INSTALL_APP: 'receive-install-app',\n RECEIVE_PREEMPTION: 'receive-preemption',\n RECEIVE_TREZOR_THP_PAIRING: 'receive-trezor-thp-pairing',\n CANCEL: 'cancel',\n} as const;\n\nexport type DevicePermissionDeniedReason =\n | 'bluetoothTurnedOff'\n | 'permissionDenied'\n | (string & Record<never, never>);\n\nexport type DevicePermissionResponse = {\n granted: boolean;\n reason?: DevicePermissionDeniedReason;\n message?: string;\n};\n\nexport type UiResponseEvent =\n | {\n type: typeof UI_RESPONSE.RECEIVE_PIN;\n payload: string;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;\n payload: {\n value: string;\n passphraseOnDevice?: boolean;\n save?: boolean;\n };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE;\n payload?: undefined;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;\n payload: QrResponseData;\n }\n | {\n // sdkConnectId echoes one of the DeviceInfo.connectId values emitted in\n // the REQUEST_SELECT_DEVICE event's `devices` list. Scope is the current\n // search session; may be ephemeral (e.g. Ledger USB DMK UUID).\n type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;\n payload: { sdkConnectId: string };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_DEVICE_PERMISSION;\n payload: DevicePermissionResponse;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_INSTALL_APP;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PREEMPTION;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING;\n payload: {\n selectedMethod?: number | string;\n tag?: string;\n };\n }\n | {\n type: typeof UI_RESPONSE.CANCEL;\n payload?: undefined;\n };\n","import { UI_REQUEST, UI_RESPONSE } from '../events/ui-request';\n\n/** 10 min — every UI request is human-in-the-loop; bias toward \"wait long\". */\nexport const UI_REQUEST_DEFAULT_TIMEOUT_MS = 600_000;\n\nconst RESPONSE_TO_REQUEST: Record<string, string> = {\n [UI_RESPONSE.RECEIVE_PIN]: UI_REQUEST.REQUEST_PIN,\n [UI_RESPONSE.RECEIVE_PASSPHRASE]: UI_REQUEST.REQUEST_PASSPHRASE,\n [UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE]: UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE,\n [UI_RESPONSE.RECEIVE_SELECT_DEVICE]: UI_REQUEST.REQUEST_SELECT_DEVICE,\n [UI_RESPONSE.RECEIVE_DEVICE_CONNECT]: UI_REQUEST.REQUEST_DEVICE_CONNECT,\n [UI_RESPONSE.RECEIVE_DEVICE_PERMISSION]: UI_REQUEST.REQUEST_DEVICE_PERMISSION,\n [UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM]: UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM,\n [UI_RESPONSE.RECEIVE_INSTALL_APP]: UI_REQUEST.REQUEST_INSTALL_APP,\n [UI_RESPONSE.RECEIVE_PREEMPTION]: UI_REQUEST.REQUEST_PREEMPTION,\n [UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING]: UI_REQUEST.REQUEST_TREZOR_THP_PAIRING,\n // RECEIVE_QR_RESPONSE maps to QR_DISPLAY or QR_SCAN — resolved dynamically below.\n};\n\nexport const UI_REQUEST_PREEMPTED_TAG = 'UiRequestPreempted';\nexport const UI_REQUEST_CANCELLED_TAG = 'UiRequestCancelled';\nexport const UI_REQUEST_TIMEOUT_TAG = 'UiRequestTimeout';\n\ntype PendingEntry = {\n resolve: (payload: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n};\n\n/**\n * Per-type single-slot registry for adapter-level UI requests. A new `wait`\n * of the same type supersedes (rejects) the prior pending entry. With the\n * job queue running globally serially, cross-type collisions don't occur in\n * normal flow — same-type preemption is a defensive measure for callers\n * that fire the same request twice without waiting on the first.\n *\n * Unknown response types are dropped silently so the public `uiResponse`\n * entry never throws.\n */\nexport class UiRequestRegistry {\n private pending = new Map<string, PendingEntry>();\n\n wait<T = unknown>(requestType: string, options?: { timeoutMs?: number }): Promise<T> {\n const existing = this.pending.get(requestType);\n if (existing) {\n clearTimeout(existing.timer);\n this.pending.delete(requestType);\n existing.reject(\n Object.assign(new Error(`UI request '${requestType}' was superseded by a new request`), {\n _tag: UI_REQUEST_PREEMPTED_TAG,\n })\n );\n }\n\n const timeoutMs = options?.timeoutMs ?? UI_REQUEST_DEFAULT_TIMEOUT_MS;\n\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n if (this.pending.get(requestType)?.timer === timer) {\n this.pending.delete(requestType);\n reject(\n Object.assign(new Error(`UI request '${requestType}' timed out after ${timeoutMs}ms`), {\n _tag: UI_REQUEST_TIMEOUT_TAG,\n })\n );\n }\n }, timeoutMs);\n\n this.pending.set(requestType, {\n resolve: resolve as (payload: unknown) => void,\n reject,\n timer,\n });\n });\n }\n\n resolve(responseType: string, payload: unknown): void {\n let requestType = RESPONSE_TO_REQUEST[responseType];\n if (responseType === UI_RESPONSE.RECEIVE_QR_RESPONSE) {\n if (this.pending.has(UI_REQUEST.REQUEST_QR_DISPLAY)) {\n requestType = UI_REQUEST.REQUEST_QR_DISPLAY;\n } else if (this.pending.has(UI_REQUEST.REQUEST_QR_SCAN)) {\n requestType = UI_REQUEST.REQUEST_QR_SCAN;\n }\n }\n if (!requestType) return;\n\n const entry = this.pending.get(requestType);\n if (!entry) return;\n\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.resolve(payload);\n }\n\n cancel(requestType?: string): void {\n if (requestType) {\n const entry = this.pending.get(requestType);\n if (!entry) return;\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.reject(\n Object.assign(new Error(`UI request '${requestType}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n return;\n }\n\n for (const [type, entry] of this.pending) {\n clearTimeout(entry.timer);\n entry.reject(\n Object.assign(new Error(`UI request '${type}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n }\n this.pending.clear();\n }\n\n reset(): void {\n this.cancel();\n }\n\n hasPending(requestType?: string): boolean {\n if (requestType) return this.pending.has(requestType);\n return this.pending.size > 0;\n }\n}\n"],"mappings":";AAEO,IAAM,WAAW;AAEjB,IAAM,aAAa;AAAA,EACxB,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,8BAA8B;AAAA,EAC9B,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,2BAA2B;AAAA,EAC3B,uBAAuB;AAAA,EACvB,wBAAwB;AAAA;AAAA;AAAA,EAGxB,gCAAgC;AAAA;AAAA;AAAA,EAGhC,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,4BAA4B;AAAA,EAC5B,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,cAAc;AAChB;AAEO,IAAM,cAAc;AAAA,EACzB,aAAa;AAAA,EACb,o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AM;AAAA,QACJ,OAAO,OAAO,IAAI,MAAM,eAAe,IAAI,iBAAiB,GAAG;AAAA,UAC7D,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AAAA,IACF;AACA,SAAK,QAAQ,MAAM;AAAA,EACrB;AAAA,EAEA,QAAc;AACZ,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,WAAW,aAA+B;AACxC,QAAI,YAAa,QAAO,KAAK,QAAQ,IAAI,WAAW;AACpD,WAAO,KAAK,QAAQ,OAAO;AAAA,EAC7B;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-LYVS67EX.js","../src/events/ui-request.ts","../src/utils/UiRequestRegistry.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,SAAA,EAAW,UAAA;AAEjB,IAAM,WAAA,EAAa;AAAA,EACxB,WAAA,EAAa,gBAAA;AAAA,EACb,kBAAA,EAAoB,uBAAA;AAAA,EACpB,4BAAA,EAA8B,iCAAA;AAAA,EAC9B,cAAA,EAAgB,mBAAA;AAAA,EAChB,kBAAA,EAAoB,uBAAA;AAAA,EACpB,eAAA,EAAiB,oBAAA;AAAA,EACjB,yBAAA,EAA2B,8BAAA;AAAA,EAC3B,qBAAA,EAAuB,0BAAA;AAAA,EACvB,sBAAA,EAAwB,2BAAA;AAAA;AAAA;AAAA,EAGxB,8BAAA,EAAgC,mCAAA;AAAA;AAAA;AAAA,EAGhC,mBAAA,EAAqB,wBAAA;AAAA,EACrB,kBAAA,EAAoB,uBAAA;AAAA,EACpB,0BAAA,EAA4B,+BAAA;AAAA,EAC5B,eAAA,EAAiB,UAAA;AAAA,EACjB,eAAA,EAAiB,oBAAA;AAAA,EACjB,iBAAA,EAAmB,sBAAA;AAAA,EACnB,YAAA,EAAc;AAChB,CAAA;AAEO,IAAM,YAAA,EAAc;AAAA,EACzB,WAAA,EAAa,aAAA;AAAA,EACb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MAAA;AACZ,MAAA,YAAA,CAAa,KAAA,CAAM,KAAK,CAAA;AACxB,MAAA,IAAA,CAAK,OAAA,CAAQ,MAAA,CAAO,WAAW,CAAA;AAC/B,MAAA,KAAA,CAAM,MAAA;AAAA,QACJ,MAAA,CAAO,MAAA,CAAO,IAAI,KAAA,CAAM,CAAA,YAAA,EAAe,WAAW,CAAA,eAAA,CAAiB,CAAA,EAAG;AAAA,UACpE,IAAA,EAAM;AAAA,QACR,CAAC;AAAA,MACH,CAAA;AACA,MAAA,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAA,MAAW,CAAC,IAAA,EAAM,KAAK,EAAA,GAAK,IAAA,CAAK,OAAA,EAAS;AACxC,MAAA,YAAA,CAAa,KAAA,CAAM,KAAK,CAAA;AACxB,MAAA,KAAA,CAAM,MAAA;AAAA,QACJ,MAAA,CAAO,MAAA,CAAO,IAAI,KAAA,CAAM,CAAA,YAAA,EAAe,IAAI,CAAA,eAAA,CAAiB,CAAA,EAAG;AAAA,UAC7D,IAAA,EAAM;AAAA,QACR,CAAC;AAAA,MACH,CAAA;AAAA,IACF;AACA,IAAA,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,CAAA;AAAA,EACrB;AAAA,EAEA,KAAA,CAAA,EAAc;AACZ,IAAA,IAAA,CAAK,MAAA,CAAO,CAAA;AAAA,EACd;AAAA,EAEA,UAAA,CAAW,WAAA,EAA+B;AACxC,IAAA,GAAA,CAAI,WAAA,EAAa,OAAO,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,WAAW,CAAA;AACpD,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA;AAAA,EAC7B;AACF,CAAA;AFWA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yYAAC","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-LYVS67EX.js","sourcesContent":[null,"import type { QrResponseData } from '../types/qr';\n\nexport const UI_EVENT = 'UI_EVENT';\n\nexport const UI_REQUEST = {\n REQUEST_PIN: 'ui-request-pin',\n REQUEST_PASSPHRASE: 'ui-request-passphrase',\n REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request-passphrase-on-device',\n REQUEST_BUTTON: 'ui-request-button',\n REQUEST_QR_DISPLAY: 'ui-request-qr-display',\n REQUEST_QR_SCAN: 'ui-request-qr-scan',\n REQUEST_DEVICE_PERMISSION: 'ui-request-device-permission',\n REQUEST_SELECT_DEVICE: 'ui-request-select-device',\n REQUEST_DEVICE_CONNECT: 'ui-request-device-connect',\n // Ledger BTC App: account index >= 100 requires display=true. Adapter asks\n // the user once per session before promoting the call.\n REQUEST_BTC_HIGH_INDEX_CONFIRM: 'ui-request-btc-high-index-confirm',\n // Required app is not installed; with autoInstallApp on, ask the user\n // whether to install it before retrying the operation.\n REQUEST_INSTALL_APP: 'ui-request-install-app',\n REQUEST_PREEMPTION: 'ui-request-preemption',\n REQUEST_TREZOR_THP_PAIRING: 'ui-request-trezor-thp-pairing',\n CLOSE_UI_WINDOW: 'ui-close',\n DEVICE_PROGRESS: 'ui-device_progress',\n FIRMWARE_PROGRESS: 'ui-firmware-progress',\n FIRMWARE_TIP: 'ui-firmware-tip',\n} as const;\n\nexport const UI_RESPONSE = {\n RECEIVE_PIN: 'receive-pin',\n RECEIVE_PASSPHRASE: 'receive-passphrase',\n RECEIVE_PASSPHRASE_ON_DEVICE: 'receive-passphrase-on-device',\n RECEIVE_QR_RESPONSE: 'receive-qr-response',\n RECEIVE_SELECT_DEVICE: 'receive-select-device',\n RECEIVE_DEVICE_CONNECT: 'receive-device-connect',\n RECEIVE_DEVICE_PERMISSION: 'receive-device-permission',\n RECEIVE_BTC_HIGH_INDEX_CONFIRM: 'receive-btc-high-index-confirm',\n RECEIVE_INSTALL_APP: 'receive-install-app',\n RECEIVE_PREEMPTION: 'receive-preemption',\n RECEIVE_TREZOR_THP_PAIRING: 'receive-trezor-thp-pairing',\n CANCEL: 'cancel',\n} as const;\n\nexport type DevicePermissionDeniedReason =\n | 'bluetoothTurnedOff'\n | 'permissionDenied'\n | (string & Record<never, never>);\n\nexport type DevicePermissionResponse = {\n granted: boolean;\n reason?: DevicePermissionDeniedReason;\n message?: string;\n};\n\nexport type UiResponseEvent =\n | {\n type: typeof UI_RESPONSE.RECEIVE_PIN;\n payload: string;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;\n payload: {\n value: string;\n passphraseOnDevice?: boolean;\n save?: boolean;\n };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE;\n payload?: undefined;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;\n payload: QrResponseData;\n }\n | {\n // sdkConnectId echoes one of the DeviceInfo.connectId values emitted in\n // the REQUEST_SELECT_DEVICE event's `devices` list. Scope is the current\n // search session; may be ephemeral (e.g. Ledger USB DMK UUID).\n type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;\n payload: { sdkConnectId: string };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_DEVICE_PERMISSION;\n payload: DevicePermissionResponse;\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_INSTALL_APP;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_PREEMPTION;\n payload: { confirmed: boolean };\n }\n | {\n type: typeof UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING;\n payload: {\n selectedMethod?: number | string;\n tag?: string;\n };\n }\n | {\n type: typeof UI_RESPONSE.CANCEL;\n payload?: undefined;\n };\n","import { UI_REQUEST, UI_RESPONSE } from '../events/ui-request';\n\n/** 10 min — every UI request is human-in-the-loop; bias toward \"wait long\". */\nexport const UI_REQUEST_DEFAULT_TIMEOUT_MS = 600_000;\n\nconst RESPONSE_TO_REQUEST: Record<string, string> = {\n [UI_RESPONSE.RECEIVE_PIN]: UI_REQUEST.REQUEST_PIN,\n [UI_RESPONSE.RECEIVE_PASSPHRASE]: UI_REQUEST.REQUEST_PASSPHRASE,\n [UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE]: UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE,\n [UI_RESPONSE.RECEIVE_SELECT_DEVICE]: UI_REQUEST.REQUEST_SELECT_DEVICE,\n [UI_RESPONSE.RECEIVE_DEVICE_CONNECT]: UI_REQUEST.REQUEST_DEVICE_CONNECT,\n [UI_RESPONSE.RECEIVE_DEVICE_PERMISSION]: UI_REQUEST.REQUEST_DEVICE_PERMISSION,\n [UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM]: UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM,\n [UI_RESPONSE.RECEIVE_INSTALL_APP]: UI_REQUEST.REQUEST_INSTALL_APP,\n [UI_RESPONSE.RECEIVE_PREEMPTION]: UI_REQUEST.REQUEST_PREEMPTION,\n [UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING]: UI_REQUEST.REQUEST_TREZOR_THP_PAIRING,\n // RECEIVE_QR_RESPONSE maps to QR_DISPLAY or QR_SCAN — resolved dynamically below.\n};\n\nexport const UI_REQUEST_PREEMPTED_TAG = 'UiRequestPreempted';\nexport const UI_REQUEST_CANCELLED_TAG = 'UiRequestCancelled';\nexport const UI_REQUEST_TIMEOUT_TAG = 'UiRequestTimeout';\n\ntype PendingEntry = {\n resolve: (payload: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n};\n\n/**\n * Per-type single-slot registry for adapter-level UI requests. A new `wait`\n * of the same type supersedes (rejects) the prior pending entry. With the\n * job queue running globally serially, cross-type collisions don't occur in\n * normal flow — same-type preemption is a defensive measure for callers\n * that fire the same request twice without waiting on the first.\n *\n * Unknown response types are dropped silently so the public `uiResponse`\n * entry never throws.\n */\nexport class UiRequestRegistry {\n private pending = new Map<string, PendingEntry>();\n\n wait<T = unknown>(requestType: string, options?: { timeoutMs?: number }): Promise<T> {\n const existing = this.pending.get(requestType);\n if (existing) {\n clearTimeout(existing.timer);\n this.pending.delete(requestType);\n existing.reject(\n Object.assign(new Error(`UI request '${requestType}' was superseded by a new request`), {\n _tag: UI_REQUEST_PREEMPTED_TAG,\n })\n );\n }\n\n const timeoutMs = options?.timeoutMs ?? UI_REQUEST_DEFAULT_TIMEOUT_MS;\n\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n if (this.pending.get(requestType)?.timer === timer) {\n this.pending.delete(requestType);\n reject(\n Object.assign(new Error(`UI request '${requestType}' timed out after ${timeoutMs}ms`), {\n _tag: UI_REQUEST_TIMEOUT_TAG,\n })\n );\n }\n }, timeoutMs);\n\n this.pending.set(requestType, {\n resolve: resolve as (payload: unknown) => void,\n reject,\n timer,\n });\n });\n }\n\n resolve(responseType: string, payload: unknown): void {\n let requestType = RESPONSE_TO_REQUEST[responseType];\n if (responseType === UI_RESPONSE.RECEIVE_QR_RESPONSE) {\n if (this.pending.has(UI_REQUEST.REQUEST_QR_DISPLAY)) {\n requestType = UI_REQUEST.REQUEST_QR_DISPLAY;\n } else if (this.pending.has(UI_REQUEST.REQUEST_QR_SCAN)) {\n requestType = UI_REQUEST.REQUEST_QR_SCAN;\n }\n }\n if (!requestType) return;\n\n const entry = this.pending.get(requestType);\n if (!entry) return;\n\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.resolve(payload);\n }\n\n cancel(requestType?: string): void {\n if (requestType) {\n const entry = this.pending.get(requestType);\n if (!entry) return;\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.reject(\n Object.assign(new Error(`UI request '${requestType}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n return;\n }\n\n for (const [type, entry] of this.pending) {\n clearTimeout(entry.timer);\n entry.reject(\n Object.assign(new Error(`UI request '${type}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n }\n this.pending.clear();\n }\n\n reset(): void {\n this.cancel();\n }\n\n hasPending(requestType?: string): boolean {\n if (requestType) return this.pending.has(requestType);\n return this.pending.size > 0;\n }\n}\n"]}
|