@onekeyfe/hwk-adapter-core 1.1.29 → 1.1.31-alpha.0
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-BAGEFFFY.js +151 -0
- package/dist/chunk-BAGEFFFY.js.map +1 -0
- package/dist/chunk-FT3SZP2W.js +149 -0
- package/dist/chunk-FT3SZP2W.js.map +1 -0
- package/dist/chunk-U63HTLGJ.mjs +151 -0
- package/dist/chunk-U63HTLGJ.mjs.map +1 -0
- package/dist/chunk-XGIIA4A4.mjs +149 -0
- package/dist/chunk-XGIIA4A4.mjs.map +1 -0
- package/dist/errors.d.mts +197 -0
- package/dist/errors.d.ts +197 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +13 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.d.mts +634 -299
- package/dist/index.d.ts +634 -299
- package/dist/index.js +452 -368
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +400 -258
- package/dist/index.mjs.map +1 -1
- package/dist/ui-events-Cb7haAeE.d.mts +128 -0
- package/dist/ui-events-Cb7haAeE.d.ts +128 -0
- package/dist/ui-events.d.mts +1 -0
- package/dist/ui-events.d.ts +1 -0
- package/dist/ui-events.js +21 -0
- package/dist/ui-events.js.map +1 -0
- package/dist/ui-events.mjs +21 -0
- package/dist/ui-events.mjs.map +1 -0
- package/package.json +22 -2
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/events/ui-request.ts
|
|
2
|
+
var UI_EVENT = "UI_EVENT";
|
|
3
|
+
var UI_REQUEST = {
|
|
4
|
+
REQUEST_PIN: "ui-request-pin",
|
|
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.
|
|
8
|
+
REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device",
|
|
9
|
+
REQUEST_BUTTON: "ui-request-button",
|
|
10
|
+
REQUEST_QR_DISPLAY: "ui-request-qr-display",
|
|
11
|
+
REQUEST_QR_SCAN: "ui-request-qr-scan",
|
|
12
|
+
REQUEST_DEVICE_PERMISSION: "ui-request-device-permission",
|
|
13
|
+
REQUEST_SELECT_DEVICE: "ui-request-select-device",
|
|
14
|
+
REQUEST_DEVICE_CONNECT: "ui-request-device-connect",
|
|
15
|
+
// Ledger BTC App: account index >= 100 requires display=true. Adapter asks
|
|
16
|
+
// the user once per session before promoting the call.
|
|
17
|
+
REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm",
|
|
18
|
+
// Required app is not installed; with autoInstallApp on, ask the user
|
|
19
|
+
// whether to install it before retrying the operation.
|
|
20
|
+
REQUEST_INSTALL_APP: "ui-request-install-app",
|
|
21
|
+
REQUEST_PREEMPTION: "ui-request-preemption",
|
|
22
|
+
REQUEST_TREZOR_THP_PAIRING: "ui-request-trezor-thp-pairing",
|
|
23
|
+
CLOSE_UI_WINDOW: "ui-close",
|
|
24
|
+
DEVICE_PROGRESS: "ui-device_progress",
|
|
25
|
+
FIRMWARE_PROGRESS: "ui-firmware-progress",
|
|
26
|
+
FIRMWARE_TIP: "ui-firmware-tip"
|
|
27
|
+
};
|
|
28
|
+
var UI_RESPONSE = {
|
|
29
|
+
RECEIVE_PIN: "receive-pin",
|
|
30
|
+
RECEIVE_PASSPHRASE: "receive-passphrase",
|
|
31
|
+
RECEIVE_QR_RESPONSE: "receive-qr-response",
|
|
32
|
+
RECEIVE_SELECT_DEVICE: "receive-select-device",
|
|
33
|
+
RECEIVE_DEVICE_CONNECT: "receive-device-connect",
|
|
34
|
+
RECEIVE_DEVICE_PERMISSION: "receive-device-permission",
|
|
35
|
+
RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm",
|
|
36
|
+
RECEIVE_INSTALL_APP: "receive-install-app",
|
|
37
|
+
RECEIVE_PREEMPTION: "receive-preemption",
|
|
38
|
+
RECEIVE_TREZOR_THP_PAIRING: "receive-trezor-thp-pairing",
|
|
39
|
+
CANCEL: "cancel"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/utils/UiRequestRegistry.ts
|
|
43
|
+
var UI_REQUEST_DEFAULT_TIMEOUT_MS = 6e5;
|
|
44
|
+
var RESPONSE_TO_REQUEST = {
|
|
45
|
+
[UI_RESPONSE.RECEIVE_PIN]: UI_REQUEST.REQUEST_PIN,
|
|
46
|
+
[UI_RESPONSE.RECEIVE_PASSPHRASE]: UI_REQUEST.REQUEST_PASSPHRASE,
|
|
47
|
+
[UI_RESPONSE.RECEIVE_SELECT_DEVICE]: UI_REQUEST.REQUEST_SELECT_DEVICE,
|
|
48
|
+
[UI_RESPONSE.RECEIVE_DEVICE_CONNECT]: UI_REQUEST.REQUEST_DEVICE_CONNECT,
|
|
49
|
+
[UI_RESPONSE.RECEIVE_DEVICE_PERMISSION]: UI_REQUEST.REQUEST_DEVICE_PERMISSION,
|
|
50
|
+
[UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM]: UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM,
|
|
51
|
+
[UI_RESPONSE.RECEIVE_INSTALL_APP]: UI_REQUEST.REQUEST_INSTALL_APP,
|
|
52
|
+
[UI_RESPONSE.RECEIVE_PREEMPTION]: UI_REQUEST.REQUEST_PREEMPTION,
|
|
53
|
+
[UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING]: UI_REQUEST.REQUEST_TREZOR_THP_PAIRING
|
|
54
|
+
// RECEIVE_QR_RESPONSE maps to QR_DISPLAY or QR_SCAN — resolved dynamically below.
|
|
55
|
+
};
|
|
56
|
+
var UI_REQUEST_PREEMPTED_TAG = "UiRequestPreempted";
|
|
57
|
+
var UI_REQUEST_CANCELLED_TAG = "UiRequestCancelled";
|
|
58
|
+
var UI_REQUEST_TIMEOUT_TAG = "UiRequestTimeout";
|
|
59
|
+
var UiRequestRegistry = class {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
62
|
+
}
|
|
63
|
+
wait(requestType, options) {
|
|
64
|
+
const existing = this.pending.get(requestType);
|
|
65
|
+
if (existing) {
|
|
66
|
+
clearTimeout(existing.timer);
|
|
67
|
+
this.pending.delete(requestType);
|
|
68
|
+
existing.reject(
|
|
69
|
+
Object.assign(new Error(`UI request '${requestType}' was superseded by a new request`), {
|
|
70
|
+
_tag: UI_REQUEST_PREEMPTED_TAG
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.timeoutMs]), () => ( UI_REQUEST_DEFAULT_TIMEOUT_MS));
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
const timer = setTimeout(() => {
|
|
77
|
+
if (_optionalChain([this, 'access', _2 => _2.pending, 'access', _3 => _3.get, 'call', _4 => _4(requestType), 'optionalAccess', _5 => _5.timer]) === timer) {
|
|
78
|
+
this.pending.delete(requestType);
|
|
79
|
+
reject(
|
|
80
|
+
Object.assign(new Error(`UI request '${requestType}' timed out after ${timeoutMs}ms`), {
|
|
81
|
+
_tag: UI_REQUEST_TIMEOUT_TAG
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}, timeoutMs);
|
|
86
|
+
this.pending.set(requestType, {
|
|
87
|
+
resolve,
|
|
88
|
+
reject,
|
|
89
|
+
timer
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
resolve(responseType, payload) {
|
|
94
|
+
let requestType = RESPONSE_TO_REQUEST[responseType];
|
|
95
|
+
if (responseType === UI_RESPONSE.RECEIVE_QR_RESPONSE) {
|
|
96
|
+
if (this.pending.has(UI_REQUEST.REQUEST_QR_DISPLAY)) {
|
|
97
|
+
requestType = UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
98
|
+
} else if (this.pending.has(UI_REQUEST.REQUEST_QR_SCAN)) {
|
|
99
|
+
requestType = UI_REQUEST.REQUEST_QR_SCAN;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!requestType) return;
|
|
103
|
+
const entry = this.pending.get(requestType);
|
|
104
|
+
if (!entry) return;
|
|
105
|
+
clearTimeout(entry.timer);
|
|
106
|
+
this.pending.delete(requestType);
|
|
107
|
+
entry.resolve(payload);
|
|
108
|
+
}
|
|
109
|
+
cancel(requestType) {
|
|
110
|
+
if (requestType) {
|
|
111
|
+
const entry = this.pending.get(requestType);
|
|
112
|
+
if (!entry) return;
|
|
113
|
+
clearTimeout(entry.timer);
|
|
114
|
+
this.pending.delete(requestType);
|
|
115
|
+
entry.reject(
|
|
116
|
+
Object.assign(new Error(`UI request '${requestType}' was cancelled`), {
|
|
117
|
+
_tag: UI_REQUEST_CANCELLED_TAG
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
for (const [type, entry] of this.pending) {
|
|
123
|
+
clearTimeout(entry.timer);
|
|
124
|
+
entry.reject(
|
|
125
|
+
Object.assign(new Error(`UI request '${type}' was cancelled`), {
|
|
126
|
+
_tag: UI_REQUEST_CANCELLED_TAG
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
this.pending.clear();
|
|
131
|
+
}
|
|
132
|
+
reset() {
|
|
133
|
+
this.cancel();
|
|
134
|
+
}
|
|
135
|
+
hasPending(requestType) {
|
|
136
|
+
if (requestType) return this.pending.has(requestType);
|
|
137
|
+
return this.pending.size > 0;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
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-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,2B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D,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"]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/types/errors.ts
|
|
2
|
+
var HardwareErrorCode = /* @__PURE__ */ ((HardwareErrorCode2) => {
|
|
3
|
+
HardwareErrorCode2[HardwareErrorCode2["UnknownError"] = 1e4] = "UnknownError";
|
|
4
|
+
HardwareErrorCode2[HardwareErrorCode2["UserRejected"] = 10001] = "UserRejected";
|
|
5
|
+
HardwareErrorCode2[HardwareErrorCode2["InvalidParams"] = 10002] = "InvalidParams";
|
|
6
|
+
HardwareErrorCode2[HardwareErrorCode2["OperationTimeout"] = 10003] = "OperationTimeout";
|
|
7
|
+
HardwareErrorCode2[HardwareErrorCode2["MethodNotSupported"] = 10004] = "MethodNotSupported";
|
|
8
|
+
HardwareErrorCode2[HardwareErrorCode2["UserAborted"] = 10005] = "UserAborted";
|
|
9
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceNotFound"] = 10100] = "DeviceNotFound";
|
|
10
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceDisconnected"] = 10101] = "DeviceDisconnected";
|
|
11
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceBusy"] = 10102] = "DeviceBusy";
|
|
12
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceLocked"] = 10103] = "DeviceLocked";
|
|
13
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceNotInitialized"] = 10104] = "DeviceNotInitialized";
|
|
14
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceInBootloader"] = 10105] = "DeviceInBootloader";
|
|
15
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceMismatch"] = 10106] = "DeviceMismatch";
|
|
16
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceAppStuck"] = 10107] = "DeviceAppStuck";
|
|
17
|
+
HardwareErrorCode2[HardwareErrorCode2["ChainNotSupported"] = 10108] = "ChainNotSupported";
|
|
18
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceOneDeviceOnly"] = 10109] = "DeviceOneDeviceOnly";
|
|
19
|
+
HardwareErrorCode2[HardwareErrorCode2["DevicePathForbidden"] = 10110] = "DevicePathForbidden";
|
|
20
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceBusyInternal"] = 10111] = "DeviceBusyInternal";
|
|
21
|
+
HardwareErrorCode2[HardwareErrorCode2["FirmwareTooOld"] = 10200] = "FirmwareTooOld";
|
|
22
|
+
HardwareErrorCode2[HardwareErrorCode2["FirmwareUpdateRequired"] = 10201] = "FirmwareUpdateRequired";
|
|
23
|
+
HardwareErrorCode2[HardwareErrorCode2["TransportError"] = 10300] = "TransportError";
|
|
24
|
+
HardwareErrorCode2[HardwareErrorCode2["BridgeNotFound"] = 10301] = "BridgeNotFound";
|
|
25
|
+
HardwareErrorCode2[HardwareErrorCode2["TransportNotAvailable"] = 10302] = "TransportNotAvailable";
|
|
26
|
+
HardwareErrorCode2[HardwareErrorCode2["DevicePermissionDenied"] = 10303] = "DevicePermissionDenied";
|
|
27
|
+
HardwareErrorCode2[HardwareErrorCode2["BlePairingTimeout"] = 10304] = "BlePairingTimeout";
|
|
28
|
+
HardwareErrorCode2[HardwareErrorCode2["NetworkError"] = 10305] = "NetworkError";
|
|
29
|
+
HardwareErrorCode2[HardwareErrorCode2["ThpPairingFailed"] = 10306] = "ThpPairingFailed";
|
|
30
|
+
HardwareErrorCode2[HardwareErrorCode2["BleBondInvalid"] = 10307] = "BleBondInvalid";
|
|
31
|
+
HardwareErrorCode2[HardwareErrorCode2["ThpPairingRequired"] = 10308] = "ThpPairingRequired";
|
|
32
|
+
HardwareErrorCode2[HardwareErrorCode2["BleConnectFailed"] = 10309] = "BleConnectFailed";
|
|
33
|
+
HardwareErrorCode2[HardwareErrorCode2["PinInvalid"] = 10400] = "PinInvalid";
|
|
34
|
+
HardwareErrorCode2[HardwareErrorCode2["PinCancelled"] = 10401] = "PinCancelled";
|
|
35
|
+
HardwareErrorCode2[HardwareErrorCode2["PassphraseRejected"] = 10402] = "PassphraseRejected";
|
|
36
|
+
HardwareErrorCode2[HardwareErrorCode2["PassphraseStateMismatch"] = 10403] = "PassphraseStateMismatch";
|
|
37
|
+
HardwareErrorCode2[HardwareErrorCode2["PinMismatch"] = 10404] = "PinMismatch";
|
|
38
|
+
HardwareErrorCode2[HardwareErrorCode2["AppNotInstalled"] = 10500] = "AppNotInstalled";
|
|
39
|
+
HardwareErrorCode2[HardwareErrorCode2["WrongApp"] = 10501] = "WrongApp";
|
|
40
|
+
HardwareErrorCode2[HardwareErrorCode2["AppTooOld"] = 10502] = "AppTooOld";
|
|
41
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceOutOfMemory"] = 10503] = "DeviceOutOfMemory";
|
|
42
|
+
HardwareErrorCode2[HardwareErrorCode2["EvmBlindSigningRequired"] = 11e3] = "EvmBlindSigningRequired";
|
|
43
|
+
HardwareErrorCode2[HardwareErrorCode2["EvmClearSignPluginMissing"] = 11001] = "EvmClearSignPluginMissing";
|
|
44
|
+
HardwareErrorCode2[HardwareErrorCode2["EvmDataTooLarge"] = 11002] = "EvmDataTooLarge";
|
|
45
|
+
HardwareErrorCode2[HardwareErrorCode2["EvmTxTypeNotSupported"] = 11003] = "EvmTxTypeNotSupported";
|
|
46
|
+
HardwareErrorCode2[HardwareErrorCode2["SolanaBlindSigningRequired"] = 11100] = "SolanaBlindSigningRequired";
|
|
47
|
+
HardwareErrorCode2[HardwareErrorCode2["TronCustomContractRequired"] = 11200] = "TronCustomContractRequired";
|
|
48
|
+
HardwareErrorCode2[HardwareErrorCode2["TronDataSigningRequired"] = 11201] = "TronDataSigningRequired";
|
|
49
|
+
HardwareErrorCode2[HardwareErrorCode2["TronSignByHashRequired"] = 11202] = "TronSignByHashRequired";
|
|
50
|
+
HardwareErrorCode2[HardwareErrorCode2["BtcWalletPolicyHmacMismatch"] = 11300] = "BtcWalletPolicyHmacMismatch";
|
|
51
|
+
HardwareErrorCode2[HardwareErrorCode2["BtcUnexpectedState"] = 11301] = "BtcUnexpectedState";
|
|
52
|
+
return HardwareErrorCode2;
|
|
53
|
+
})(HardwareErrorCode || {});
|
|
54
|
+
var ORPHAN_ELIGIBLE_ERROR_CODES = [
|
|
55
|
+
10005 /* UserAborted */,
|
|
56
|
+
10001 /* UserRejected */,
|
|
57
|
+
10100 /* DeviceNotFound */,
|
|
58
|
+
10101 /* DeviceDisconnected */,
|
|
59
|
+
10106 /* DeviceMismatch */,
|
|
60
|
+
10107 /* DeviceAppStuck */,
|
|
61
|
+
10109 /* DeviceOneDeviceOnly */,
|
|
62
|
+
10300 /* TransportError */,
|
|
63
|
+
10303 /* DevicePermissionDenied */,
|
|
64
|
+
10304 /* BlePairingTimeout */,
|
|
65
|
+
10306 /* ThpPairingFailed */,
|
|
66
|
+
10308 /* ThpPairingRequired */,
|
|
67
|
+
10307 /* BleBondInvalid */,
|
|
68
|
+
10309 /* BleConnectFailed */
|
|
69
|
+
];
|
|
70
|
+
function createHwkError(payload) {
|
|
71
|
+
return Object.assign(new Error(payload.message), {
|
|
72
|
+
code: payload.code,
|
|
73
|
+
...payload._tag !== void 0 && { _tag: payload._tag },
|
|
74
|
+
...payload.appName !== void 0 && { appName: payload.appName },
|
|
75
|
+
...payload.params !== void 0 && { params: payload.params }
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/utils/errorMessages.ts
|
|
80
|
+
function enrichErrorMessage(code, originalMessage) {
|
|
81
|
+
switch (code) {
|
|
82
|
+
case 10400 /* PinInvalid */:
|
|
83
|
+
return `${originalMessage}. Please re-enter your PIN.`;
|
|
84
|
+
case 10401 /* PinCancelled */:
|
|
85
|
+
return `${originalMessage}. PIN entry was cancelled.`;
|
|
86
|
+
case 10404 /* PinMismatch */:
|
|
87
|
+
return `${originalMessage}. The entered PINs do not match. Please try again.`;
|
|
88
|
+
case 10102 /* DeviceBusy */:
|
|
89
|
+
return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;
|
|
90
|
+
case 10111 /* DeviceBusyInternal */:
|
|
91
|
+
return `${originalMessage}. The device is busy. Please try again in a moment.`;
|
|
92
|
+
case 10101 /* DeviceDisconnected */:
|
|
93
|
+
return `${originalMessage}. Please reconnect the device and try again.`;
|
|
94
|
+
case 10103 /* DeviceLocked */:
|
|
95
|
+
return `${originalMessage}. Please unlock your device and try again.`;
|
|
96
|
+
case 10109 /* DeviceOneDeviceOnly */:
|
|
97
|
+
return `${originalMessage}. Disconnect the extra device and try again.`;
|
|
98
|
+
case 10001 /* UserRejected */:
|
|
99
|
+
return `${originalMessage}. The request was rejected on the device.`;
|
|
100
|
+
case 10501 /* WrongApp */:
|
|
101
|
+
return `${originalMessage}. Please open the correct app on your device.`;
|
|
102
|
+
case 10500 /* AppNotInstalled */:
|
|
103
|
+
return `${originalMessage}. The required app is not installed on the device.`;
|
|
104
|
+
case 10503 /* DeviceOutOfMemory */:
|
|
105
|
+
return `${originalMessage}. Not enough free space on the device. Please uninstall some apps and try again.`;
|
|
106
|
+
case 10302 /* TransportNotAvailable */:
|
|
107
|
+
return `${originalMessage}. Ensure the device bridge/transport is available and running.`;
|
|
108
|
+
case 10305 /* NetworkError */:
|
|
109
|
+
return `${originalMessage}. Network error \u2014 check your internet connection and try again.`;
|
|
110
|
+
case 10200 /* FirmwareTooOld */:
|
|
111
|
+
return `${originalMessage}. Please update your device firmware.`;
|
|
112
|
+
case 10104 /* DeviceNotInitialized */:
|
|
113
|
+
return `${originalMessage}. The device may need to be set up first.`;
|
|
114
|
+
case 10003 /* OperationTimeout */:
|
|
115
|
+
return `${originalMessage}. The operation timed out. Please try again.`;
|
|
116
|
+
case 11e3 /* EvmBlindSigningRequired */:
|
|
117
|
+
return "Ledger: Blind signing not enabled in Ethereum app.";
|
|
118
|
+
case 11001 /* EvmClearSignPluginMissing */:
|
|
119
|
+
return "Ledger: Required plugin not installed (install via Ledger Live).";
|
|
120
|
+
case 11002 /* EvmDataTooLarge */:
|
|
121
|
+
return "Ledger: Transaction data too large for device memory.";
|
|
122
|
+
case 11003 /* EvmTxTypeNotSupported */:
|
|
123
|
+
return "Ledger: Transaction type not supported by current Ethereum app.";
|
|
124
|
+
case 10502 /* AppTooOld */:
|
|
125
|
+
return "Ledger: App out of date (update via Ledger Live).";
|
|
126
|
+
case 11100 /* SolanaBlindSigningRequired */:
|
|
127
|
+
return "Blind signing disabled in the Solana app.";
|
|
128
|
+
case 11200 /* TronCustomContractRequired */:
|
|
129
|
+
return "Custom Contracts setting disabled in the Tron app.";
|
|
130
|
+
case 11201 /* TronDataSigningRequired */:
|
|
131
|
+
return "Transactions Data setting disabled in the Tron app.";
|
|
132
|
+
case 11202 /* TronSignByHashRequired */:
|
|
133
|
+
return "Sign by Hash setting disabled in the Tron app.";
|
|
134
|
+
case 11300 /* BtcWalletPolicyHmacMismatch */:
|
|
135
|
+
return "Wallet policy not registered or HMAC mismatch.";
|
|
136
|
+
case 11301 /* BtcUnexpectedState */:
|
|
137
|
+
return "Signing aborted due to unexpected device state.";
|
|
138
|
+
default:
|
|
139
|
+
return originalMessage;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
exports.HardwareErrorCode = HardwareErrorCode; exports.ORPHAN_ELIGIBLE_ERROR_CODES = ORPHAN_ELIGIBLE_ERROR_CODES; exports.createHwkError = createHwkError; exports.enrichErrorMessage = enrichErrorMessage;
|
|
149
|
+
//# sourceMappingURL=chunk-FT3SZP2W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-FT3SZP2W.js","../src/types/errors.ts","../src/utils/errorMessages.ts"],"names":["HardwareErrorCode"],"mappings":"AAAA;ACuBO,IAAK,kBAAA,kBAAL,CAAA,CAAKA,kBAAAA,EAAAA,GAAL;AAEL,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,cAAA,EAAA,EAAe,GAAA,EAAA,EAAf,cAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,cAAA,EAAA,EAAe,KAAA,EAAA,EAAf,cAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,eAAA,EAAA,EAAgB,KAAA,EAAA,EAAhB,eAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,kBAAA,EAAA,EAAmB,KAAA,EAAA,EAAnB,kBAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,oBAAA,EAAA,EAAqB,KAAA,EAAA,EAArB,oBAAA;AAEA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,aAAA,EAAA,EAAc,KAAA,EAAA,EAAd,aAAA;AAGA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,gBAAA,EAAA,EAAiB,KAAA,EAAA,EAAjB,gBAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,oBAAA,EAAA,EAAqB,KAAA,EAAA,EAArB,oBAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,YAAA,EAAA,EAAa,KAAA,EAAA,EAAb,YAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,cAAA,EAAA,EAAe,KAAA,EAAA,EAAf,cAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,sBAAA,EAAA,EA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;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACX,EAAA;AACF;AF0Ec;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-FT3SZP2W.js","sourcesContent":[null,"/**\n * HWK HardwareErrorCode — independent namespace from the legacy\n * `@onekeyfe/shared` HardwareErrorCode (which occupies 0-902).\n *\n * All HWK codes are 5-digit (>= 10000) so the two tables never collide\n * even if either side grows. Each sub-category gets a 100-slot block.\n *\n * 10000-10099 Generic / cross-cutting primitives\n * 10100-10199 Device state\n * 10200-10299 Firmware\n * 10300-10399 Transport + OS-level permission\n * 10400-10499 PIN / Passphrase\n * 10500-10599 App lifecycle (wrong app, not open, too old)\n * 10600-10999 RESERVED — future adapter-level categories\n *\n * 11000-11099 EVM APDU (reactive mapping)\n * 11100-11199 Solana APDU\n * 11200-11299 Tron APDU\n * 11300-11399 BTC APDU\n * 11400-11999 RESERVED — future chain APDU blocks (100 per chain)\n *\n * 12000-99999 RESERVED — future major categories\n */\nexport enum HardwareErrorCode {\n // --- 10000s Generic ---\n UnknownError = 10000,\n UserRejected = 10001,\n InvalidParams = 10002,\n OperationTimeout = 10003,\n MethodNotSupported = 10004,\n /** User dismissed in-app cancel UI. Distinct from UserRejected (on-device). */\n UserAborted = 10005,\n\n // --- 10100s Device state ---\n DeviceNotFound = 10100,\n DeviceDisconnected = 10101,\n DeviceBusy = 10102,\n DeviceLocked = 10103,\n DeviceNotInitialized = 10104,\n DeviceInBootloader = 10105,\n DeviceMismatch = 10106,\n /** Chain app wedged (e.g. Ledger BTC 0x6901). User must exit app on device. */\n DeviceAppStuck = 10107,\n /** Vendor (Ledger / Trezor) doesn't support the chain at all. */\n ChainNotSupported = 10108,\n /** Current operation supports only one connected device. */\n DeviceOneDeviceOnly = 10109,\n /**\n * The device rejected the requested derivation path (Trezor Failure_DataError\n * \"Forbidden key path\") — the path is non-standard or its index is outside the\n * range the device's safety checks allow. Distinct from ChainNotSupported\n * (whole chain) and MethodNotSupported (the operation/method itself).\n */\n DevicePathForbidden = 10110,\n /** Busy with our own in-flight request (queue guard / firmware Failure_Busy), not another app — wait and retry, don't close other apps. */\n DeviceBusyInternal = 10111,\n\n // --- 10200s Firmware ---\n FirmwareTooOld = 10200,\n FirmwareUpdateRequired = 10201,\n\n // --- 10300s Transport + permission ---\n TransportError = 10300,\n BridgeNotFound = 10301,\n TransportNotAvailable = 10302,\n /**\n * OS-level permission (Bluetooth / USB / etc.) — denied, blocked,\n * unavailable, or dismissed. Consumers surface a single \"please grant\n * permission\" toast and let the user retry manually.\n */\n DevicePermissionDenied = 10303,\n /**\n * BLE SMP pairing did not complete within the GATT bonding window.\n * GATT connected but the device didn't acknowledge SMP — typically\n * because the user didn't confirm the passkey on the device, or the\n * device went out of range mid-pairing. Distinct from OperationTimeout\n * (generic) and from DeviceLocked (Secure Element actually locked).\n */\n BlePairingTimeout = 10304,\n /** Remote network failure reaching a vendor's servers (HTTP/WS). Distinct from TransportError (local USB/BLE link). */\n NetworkError = 10305,\n /**\n * Host-managed pairing handshake failed (Trezor THP). The device rejected the\n * pairing exchange — e.g. CodeEntry: the user mistyped the code shown on the\n * device, so the CPace tag didn't match (\"Unexpected Code Entry Tag\").\n * Recoverable: the user re-pairs and re-enters the code. Distinct from\n * BlePairingTimeout (BLE SMP bonding window) and UserRejected (on-device\n * reject button).\n */\n ThpPairingFailed = 10306,\n /**\n * The OS-level BLE bond is stale/invalid, so the device rejected link\n * encryption: Android GATT_INSUF_AUTHENTICATION (status 5) or iOS \"Peer\n * removed pairing information\". Happens after the device is wiped/re-flashed\n * or unpaired elsewhere while the host still holds an old bond. The SDK cannot\n * remove an OS bond — the user must forget the device in system Bluetooth\n * settings and re-pair. Distinct from BlePairingTimeout (SMP window) and\n * ThpPairingFailed (THP code mismatch).\n */\n BleBondInvalid = 10307,\n /**\n * A stored THP pairing credential was rejected by the device during the\n * handshake (device returned completion `state=0`), so the autoconnect session\n * could not be established. The SDK discards the stale credential; recovery is\n * a fresh pairing. Distinct from ThpPairingFailed (user mistyped the code\n * during an *active* pairing) and BleBondInvalid (OS-level BLE bond).\n */\n ThpPairingRequired = 10308,\n /**\n * Generic BLE connect failure where the OS dropped the specific reason. On\n * macOS the noble native binding hardcodes \"connection failed\" (and a connect\n * timeout) and discards the CoreBluetooth NSError, so the SDK cannot tell a\n * stale bond from an out-of-range / unresponsive device. Surfaced as a\n * generic \"couldn't connect — check the device, re-pair if paired before\".\n * Distinct from BleBondInvalid (a *known* stale-bond signal, iOS/Android only)\n * and BlePairingTimeout (the SMP bonding window).\n */\n BleConnectFailed = 10309,\n\n // --- 10400s PIN / Passphrase ---\n PinInvalid = 10400,\n PinCancelled = 10401,\n PassphraseRejected = 10402,\n /**\n * The passphrase entered produced a different wallet (`passphraseState`) than\n * the one the caller asked to operate on. Trezor-only: the host pins a wallet\n * by its derived state and the SDK refuses to sign with a mismatched\n * passphrase session. Surfaced by TrezorAdapter.getPassphraseState.\n */\n PassphraseStateMismatch = 10403,\n /**\n * The two new-PIN entries did not match during set/change PIN. Only host-input\n * models (Trezor Model One matrix) surface this; on-device-input models show\n * the mismatch on the device and never return it.\n */\n PinMismatch = 10404,\n\n // --- 10500s App lifecycle ---\n /** Chain app NOT INSTALLED on device. User must install via Ledger Live. */\n AppNotInstalled = 10500,\n WrongApp = 10501,\n /** 0x911c Command code not supported — app predates current SDK. */\n AppTooOld = 10502,\n /** Not enough free storage for install/update; user must uninstall apps first. */\n DeviceOutOfMemory = 10503,\n\n // --- 11000s EVM (Ledger Ethereum App) APDU-specific ---\n /** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the\n * user has not enabled Blind signing on the device. */\n EvmBlindSigningRequired = 11000,\n /** 0x6984 Plugin not installed */\n EvmClearSignPluginMissing = 11001,\n /** 0x6a84 Insufficient memory (typical on Nano S with large calldata) */\n EvmDataTooLarge = 11002,\n /** 0x6501 TransactionType not supported (app too old for EIP-1559 / blob / 7702) */\n EvmTxTypeNotSupported = 11003,\n\n // --- 11100s Solana ---\n /** 0x6808 Blind signing disabled for this instruction. */\n SolanaBlindSigningRequired = 11100,\n\n // --- 11200s Tron ---\n /** 0x6a8d Custom Contracts setting disabled (blocks TRC-20 etc.). */\n TronCustomContractRequired = 11200,\n /** 0x6a8b Transactions Data setting disabled. */\n TronDataSigningRequired = 11201,\n /** 0x6a8c Sign by Hash setting disabled (hash-signing fallback). */\n TronSignByHashRequired = 11202,\n\n // --- 11300s BTC ---\n /** 0xb008 Wallet policy HMAC mismatch or not registered. */\n BtcWalletPolicyHmacMismatch = 11300,\n /** 0xb007 Aborted due to unexpected state (malformed PSBT / missing UTXO). */\n BtcUnexpectedState = 11301,\n}\n\n/**\n * Device-level failures the SDK cannot self-recover from — affect the entire\n * batch (vs per-chain failures like AppNotInstalled / WrongApp which soft-\n * skip in onboarding). Combined with `accounts.length === 0`, signals\n * genuine orphan. Also reused as the batch-abort whitelist for HWK.\n * Single source of truth.\n *\n * UserRejected (device-side reject) is included: pressing reject is an\n * explicit \"I don't consent\" — continuing the batch to ask again on the\n * next chain is harassment, not helpful.\n */\nexport const ORPHAN_ELIGIBLE_ERROR_CODES: number[] = [\n HardwareErrorCode.UserAborted,\n HardwareErrorCode.UserRejected,\n HardwareErrorCode.DeviceNotFound,\n HardwareErrorCode.DeviceDisconnected,\n HardwareErrorCode.DeviceMismatch,\n HardwareErrorCode.DeviceAppStuck,\n HardwareErrorCode.DeviceOneDeviceOnly,\n HardwareErrorCode.TransportError,\n HardwareErrorCode.DevicePermissionDenied,\n HardwareErrorCode.BlePairingTimeout,\n HardwareErrorCode.ThpPairingFailed,\n HardwareErrorCode.ThpPairingRequired,\n HardwareErrorCode.BleBondInvalid,\n HardwareErrorCode.BleConnectFailed,\n];\n\n// ---------------------------------------------------------------------------\n// Standard throwable for HWK adapters\n// ---------------------------------------------------------------------------\n\nexport interface IHwkErrorPayload {\n code: HardwareErrorCode;\n message: string;\n appName?: string;\n _tag?: string;\n params?: Record<string, unknown>;\n}\n\nexport type HwkError = Error & {\n code: HardwareErrorCode;\n appName?: string;\n _tag?: string;\n params?: Record<string, unknown>;\n};\n\n/**\n * Canonical throwable for HWK adapters. Plain Error + canonical extra fields,\n * shape-compatible with `rehydrateConnectorError` so locally-thrown and\n * cross-boundary errors are indistinguishable to downstream classifiers\n * (`err.code` / `err._tag` / `err.appName`). Do NOT mutate caught errors\n * with `Object.assign` — construct a fresh one via this factory.\n */\nexport function createHwkError(payload: IHwkErrorPayload): HwkError {\n return Object.assign(new Error(payload.message), {\n code: payload.code,\n ...(payload._tag !== undefined && { _tag: payload._tag }),\n ...(payload.appName !== undefined && { appName: payload.appName }),\n ...(payload.params !== undefined && { params: payload.params }),\n });\n}\n","import { HardwareErrorCode } from '../types/errors';\n\n/**\n * Enrich a hardware error message with actionable recovery hints.\n * Shared across adapters (Ledger, Trezor, etc.).\n */\nexport function enrichErrorMessage(code: HardwareErrorCode, originalMessage: string): string {\n switch (code) {\n case HardwareErrorCode.PinInvalid:\n return `${originalMessage}. Please re-enter your PIN.`;\n case HardwareErrorCode.PinCancelled:\n return `${originalMessage}. PIN entry was cancelled.`;\n case HardwareErrorCode.PinMismatch:\n return `${originalMessage}. The entered PINs do not match. Please try again.`;\n case HardwareErrorCode.DeviceBusy:\n return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;\n case HardwareErrorCode.DeviceBusyInternal:\n return `${originalMessage}. The device is busy. Please try again in a moment.`;\n case HardwareErrorCode.DeviceDisconnected:\n return `${originalMessage}. Please reconnect the device and try again.`;\n case HardwareErrorCode.DeviceLocked:\n return `${originalMessage}. Please unlock your device and try again.`;\n case HardwareErrorCode.DeviceOneDeviceOnly:\n return `${originalMessage}. Disconnect the extra device and try again.`;\n case HardwareErrorCode.UserRejected:\n return `${originalMessage}. The request was rejected on the device.`;\n case HardwareErrorCode.WrongApp:\n return `${originalMessage}. Please open the correct app on your device.`;\n case HardwareErrorCode.AppNotInstalled:\n return `${originalMessage}. The required app is not installed on the device.`;\n case HardwareErrorCode.DeviceOutOfMemory:\n return `${originalMessage}. Not enough free space on the device. Please uninstall some apps and try again.`;\n case HardwareErrorCode.TransportNotAvailable:\n return `${originalMessage}. Ensure the device bridge/transport is available and running.`;\n case HardwareErrorCode.NetworkError:\n return `${originalMessage}. Network error — check your internet connection and try again.`;\n case HardwareErrorCode.FirmwareTooOld:\n return `${originalMessage}. Please update your device firmware.`;\n case HardwareErrorCode.DeviceNotInitialized:\n return `${originalMessage}. The device may need to be set up first.`;\n case HardwareErrorCode.OperationTimeout:\n return `${originalMessage}. The operation timed out. Please try again.`;\n case HardwareErrorCode.EvmBlindSigningRequired:\n return 'Ledger: Blind signing not enabled in Ethereum app.';\n case HardwareErrorCode.EvmClearSignPluginMissing:\n return 'Ledger: Required plugin not installed (install via Ledger Live).';\n case HardwareErrorCode.EvmDataTooLarge:\n return 'Ledger: Transaction data too large for device memory.';\n case HardwareErrorCode.EvmTxTypeNotSupported:\n return 'Ledger: Transaction type not supported by current Ethereum app.';\n case HardwareErrorCode.AppTooOld:\n return 'Ledger: App out of date (update via Ledger Live).';\n case HardwareErrorCode.SolanaBlindSigningRequired:\n return 'Blind signing disabled in the Solana app.';\n case HardwareErrorCode.TronCustomContractRequired:\n return 'Custom Contracts setting disabled in the Tron app.';\n case HardwareErrorCode.TronDataSigningRequired:\n return 'Transactions Data setting disabled in the Tron app.';\n case HardwareErrorCode.TronSignByHashRequired:\n return 'Sign by Hash setting disabled in the Tron app.';\n case HardwareErrorCode.BtcWalletPolicyHmacMismatch:\n return 'Wallet policy not registered or HMAC mismatch.';\n case HardwareErrorCode.BtcUnexpectedState:\n return 'Signing aborted due to unexpected device state.';\n default:\n return originalMessage;\n }\n}\n"]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// src/events/ui-request.ts
|
|
2
|
+
var UI_EVENT = "UI_EVENT";
|
|
3
|
+
var UI_REQUEST = {
|
|
4
|
+
REQUEST_PIN: "ui-request-pin",
|
|
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.
|
|
8
|
+
REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device",
|
|
9
|
+
REQUEST_BUTTON: "ui-request-button",
|
|
10
|
+
REQUEST_QR_DISPLAY: "ui-request-qr-display",
|
|
11
|
+
REQUEST_QR_SCAN: "ui-request-qr-scan",
|
|
12
|
+
REQUEST_DEVICE_PERMISSION: "ui-request-device-permission",
|
|
13
|
+
REQUEST_SELECT_DEVICE: "ui-request-select-device",
|
|
14
|
+
REQUEST_DEVICE_CONNECT: "ui-request-device-connect",
|
|
15
|
+
// Ledger BTC App: account index >= 100 requires display=true. Adapter asks
|
|
16
|
+
// the user once per session before promoting the call.
|
|
17
|
+
REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm",
|
|
18
|
+
// Required app is not installed; with autoInstallApp on, ask the user
|
|
19
|
+
// whether to install it before retrying the operation.
|
|
20
|
+
REQUEST_INSTALL_APP: "ui-request-install-app",
|
|
21
|
+
REQUEST_PREEMPTION: "ui-request-preemption",
|
|
22
|
+
REQUEST_TREZOR_THP_PAIRING: "ui-request-trezor-thp-pairing",
|
|
23
|
+
CLOSE_UI_WINDOW: "ui-close",
|
|
24
|
+
DEVICE_PROGRESS: "ui-device_progress",
|
|
25
|
+
FIRMWARE_PROGRESS: "ui-firmware-progress",
|
|
26
|
+
FIRMWARE_TIP: "ui-firmware-tip"
|
|
27
|
+
};
|
|
28
|
+
var UI_RESPONSE = {
|
|
29
|
+
RECEIVE_PIN: "receive-pin",
|
|
30
|
+
RECEIVE_PASSPHRASE: "receive-passphrase",
|
|
31
|
+
RECEIVE_QR_RESPONSE: "receive-qr-response",
|
|
32
|
+
RECEIVE_SELECT_DEVICE: "receive-select-device",
|
|
33
|
+
RECEIVE_DEVICE_CONNECT: "receive-device-connect",
|
|
34
|
+
RECEIVE_DEVICE_PERMISSION: "receive-device-permission",
|
|
35
|
+
RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm",
|
|
36
|
+
RECEIVE_INSTALL_APP: "receive-install-app",
|
|
37
|
+
RECEIVE_PREEMPTION: "receive-preemption",
|
|
38
|
+
RECEIVE_TREZOR_THP_PAIRING: "receive-trezor-thp-pairing",
|
|
39
|
+
CANCEL: "cancel"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/utils/UiRequestRegistry.ts
|
|
43
|
+
var UI_REQUEST_DEFAULT_TIMEOUT_MS = 6e5;
|
|
44
|
+
var RESPONSE_TO_REQUEST = {
|
|
45
|
+
[UI_RESPONSE.RECEIVE_PIN]: UI_REQUEST.REQUEST_PIN,
|
|
46
|
+
[UI_RESPONSE.RECEIVE_PASSPHRASE]: UI_REQUEST.REQUEST_PASSPHRASE,
|
|
47
|
+
[UI_RESPONSE.RECEIVE_SELECT_DEVICE]: UI_REQUEST.REQUEST_SELECT_DEVICE,
|
|
48
|
+
[UI_RESPONSE.RECEIVE_DEVICE_CONNECT]: UI_REQUEST.REQUEST_DEVICE_CONNECT,
|
|
49
|
+
[UI_RESPONSE.RECEIVE_DEVICE_PERMISSION]: UI_REQUEST.REQUEST_DEVICE_PERMISSION,
|
|
50
|
+
[UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM]: UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM,
|
|
51
|
+
[UI_RESPONSE.RECEIVE_INSTALL_APP]: UI_REQUEST.REQUEST_INSTALL_APP,
|
|
52
|
+
[UI_RESPONSE.RECEIVE_PREEMPTION]: UI_REQUEST.REQUEST_PREEMPTION,
|
|
53
|
+
[UI_RESPONSE.RECEIVE_TREZOR_THP_PAIRING]: UI_REQUEST.REQUEST_TREZOR_THP_PAIRING
|
|
54
|
+
// RECEIVE_QR_RESPONSE maps to QR_DISPLAY or QR_SCAN — resolved dynamically below.
|
|
55
|
+
};
|
|
56
|
+
var UI_REQUEST_PREEMPTED_TAG = "UiRequestPreempted";
|
|
57
|
+
var UI_REQUEST_CANCELLED_TAG = "UiRequestCancelled";
|
|
58
|
+
var UI_REQUEST_TIMEOUT_TAG = "UiRequestTimeout";
|
|
59
|
+
var UiRequestRegistry = class {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
62
|
+
}
|
|
63
|
+
wait(requestType, options) {
|
|
64
|
+
const existing = this.pending.get(requestType);
|
|
65
|
+
if (existing) {
|
|
66
|
+
clearTimeout(existing.timer);
|
|
67
|
+
this.pending.delete(requestType);
|
|
68
|
+
existing.reject(
|
|
69
|
+
Object.assign(new Error(`UI request '${requestType}' was superseded by a new request`), {
|
|
70
|
+
_tag: UI_REQUEST_PREEMPTED_TAG
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const timeoutMs = options?.timeoutMs ?? UI_REQUEST_DEFAULT_TIMEOUT_MS;
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
const timer = setTimeout(() => {
|
|
77
|
+
if (this.pending.get(requestType)?.timer === timer) {
|
|
78
|
+
this.pending.delete(requestType);
|
|
79
|
+
reject(
|
|
80
|
+
Object.assign(new Error(`UI request '${requestType}' timed out after ${timeoutMs}ms`), {
|
|
81
|
+
_tag: UI_REQUEST_TIMEOUT_TAG
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}, timeoutMs);
|
|
86
|
+
this.pending.set(requestType, {
|
|
87
|
+
resolve,
|
|
88
|
+
reject,
|
|
89
|
+
timer
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
resolve(responseType, payload) {
|
|
94
|
+
let requestType = RESPONSE_TO_REQUEST[responseType];
|
|
95
|
+
if (responseType === UI_RESPONSE.RECEIVE_QR_RESPONSE) {
|
|
96
|
+
if (this.pending.has(UI_REQUEST.REQUEST_QR_DISPLAY)) {
|
|
97
|
+
requestType = UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
98
|
+
} else if (this.pending.has(UI_REQUEST.REQUEST_QR_SCAN)) {
|
|
99
|
+
requestType = UI_REQUEST.REQUEST_QR_SCAN;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!requestType) return;
|
|
103
|
+
const entry = this.pending.get(requestType);
|
|
104
|
+
if (!entry) return;
|
|
105
|
+
clearTimeout(entry.timer);
|
|
106
|
+
this.pending.delete(requestType);
|
|
107
|
+
entry.resolve(payload);
|
|
108
|
+
}
|
|
109
|
+
cancel(requestType) {
|
|
110
|
+
if (requestType) {
|
|
111
|
+
const entry = this.pending.get(requestType);
|
|
112
|
+
if (!entry) return;
|
|
113
|
+
clearTimeout(entry.timer);
|
|
114
|
+
this.pending.delete(requestType);
|
|
115
|
+
entry.reject(
|
|
116
|
+
Object.assign(new Error(`UI request '${requestType}' was cancelled`), {
|
|
117
|
+
_tag: UI_REQUEST_CANCELLED_TAG
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
for (const [type, entry] of this.pending) {
|
|
123
|
+
clearTimeout(entry.timer);
|
|
124
|
+
entry.reject(
|
|
125
|
+
Object.assign(new Error(`UI request '${type}' was cancelled`), {
|
|
126
|
+
_tag: UI_REQUEST_CANCELLED_TAG
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
this.pending.clear();
|
|
131
|
+
}
|
|
132
|
+
reset() {
|
|
133
|
+
this.cancel();
|
|
134
|
+
}
|
|
135
|
+
hasPending(requestType) {
|
|
136
|
+
if (requestType) return this.pending.has(requestType);
|
|
137
|
+
return this.pending.size > 0;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
UI_EVENT,
|
|
143
|
+
UI_REQUEST,
|
|
144
|
+
UI_RESPONSE,
|
|
145
|
+
UI_REQUEST_DEFAULT_TIMEOUT_MS,
|
|
146
|
+
UI_REQUEST_PREEMPTED_TAG,
|
|
147
|
+
UI_REQUEST_CANCELLED_TAG,
|
|
148
|
+
UI_REQUEST_TIMEOUT_TAG,
|
|
149
|
+
UiRequestRegistry
|
|
150
|
+
};
|
|
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;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