@onekeyfe/hwk-adapter-core 1.2.3-alpha.8 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{chunk-WUIWRX56.js → chunk-BAGEFFFY.js} +13 -49
  2. package/dist/chunk-BAGEFFFY.js.map +1 -0
  3. package/dist/{chunk-CQM2P5IG.js → chunk-SZZF623R.js} +55 -155
  4. package/dist/chunk-SZZF623R.js.map +1 -0
  5. package/dist/{chunk-EQYPRCWU.mjs → chunk-U63HTLGJ.mjs} +12 -48
  6. package/dist/chunk-U63HTLGJ.mjs.map +1 -0
  7. package/dist/{chunk-IOFMG7YO.mjs → chunk-YA4BWFTZ.mjs} +55 -155
  8. package/dist/chunk-YA4BWFTZ.mjs.map +1 -0
  9. package/dist/errors.d.mts +207 -1
  10. package/dist/errors.d.ts +207 -1
  11. package/dist/errors.js +2 -8
  12. package/dist/errors.js.map +1 -1
  13. package/dist/errors.mjs +3 -9
  14. package/dist/index.d.mts +98 -635
  15. package/dist/index.d.ts +98 -635
  16. package/dist/index.js +82 -680
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +73 -671
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/{ui-events-BGUpXxvP.d.ts → ui-events-Cb7haAeE.d.mts} +3 -44
  21. package/dist/{ui-events-BGUpXxvP.d.mts → ui-events-Cb7haAeE.d.ts} +3 -44
  22. package/dist/ui-events.d.mts +1 -1
  23. package/dist/ui-events.d.ts +1 -1
  24. package/dist/ui-events.js +2 -3
  25. package/dist/ui-events.js.map +1 -1
  26. package/dist/ui-events.mjs +1 -2
  27. package/package.json +2 -2
  28. package/dist/chunk-CQM2P5IG.js.map +0 -1
  29. package/dist/chunk-DB4JOPZO.mjs +0 -74
  30. package/dist/chunk-DB4JOPZO.mjs.map +0 -1
  31. package/dist/chunk-EQYPRCWU.mjs.map +0 -1
  32. package/dist/chunk-IOFMG7YO.mjs.map +0 -1
  33. package/dist/chunk-WUIWRX56.js.map +0 -1
  34. package/dist/chunk-YLCHSNXO.js +0 -74
  35. package/dist/chunk-YLCHSNXO.js.map +0 -1
  36. package/dist/errors-Cm8XpjmX.d.mts +0 -321
  37. package/dist/errors-Cm8XpjmX.d.ts +0 -321
@@ -18,8 +18,6 @@ declare const UI_REQUEST: {
18
18
  readonly REQUEST_QR_SCAN: "ui-request-qr-scan";
19
19
  readonly REQUEST_DEVICE_PERMISSION: "ui-request-device-permission";
20
20
  readonly REQUEST_SELECT_DEVICE: "ui-request-select-device";
21
- readonly REQUEST_SAVE_DEVICE_BINDING: "ui-request-save-device-binding";
22
- readonly DEVICE_BINDING_STATUS: "ui-device-binding-status";
23
21
  readonly REQUEST_DEVICE_CONNECT: "ui-request-device-connect";
24
22
  readonly REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm";
25
23
  readonly REQUEST_INSTALL_APP: "ui-request-install-app";
@@ -35,7 +33,6 @@ declare const UI_RESPONSE: {
35
33
  readonly RECEIVE_PASSPHRASE: "receive-passphrase";
36
34
  readonly RECEIVE_QR_RESPONSE: "receive-qr-response";
37
35
  readonly RECEIVE_SELECT_DEVICE: "receive-select-device";
38
- readonly RECEIVE_SAVE_DEVICE_BINDING: "receive-save-device-binding";
39
36
  readonly RECEIVE_DEVICE_CONNECT: "receive-device-connect";
40
37
  readonly RECEIVE_DEVICE_PERMISSION: "receive-device-permission";
41
38
  readonly RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm";
@@ -44,37 +41,13 @@ declare const UI_RESPONSE: {
44
41
  readonly RECEIVE_TREZOR_THP_PAIRING: "receive-trezor-thp-pairing";
45
42
  readonly CANCEL: "cancel";
46
43
  };
47
- /**
48
- * Which operation a UI request was opened under. Optional: a request emitted
49
- * outside any operation (cold start, teardown) has none, and a host that does
50
- * not track operations can ignore it. It is what lets a cancel aimed at one
51
- * operation leave another operation's prompts alone.
52
- */
53
- type UiRequestOperationAttribution = {
54
- operationId?: string;
55
- };
56
44
  type DevicePermissionDeniedReason = 'bluetoothTurnedOff' | 'permissionDenied' | (string & Record<never, never>);
57
45
  type DevicePermissionResponse = {
58
46
  granted: boolean;
59
47
  reason?: DevicePermissionDeniedReason;
60
48
  message?: string;
61
49
  };
62
- /**
63
- * Why a host refused to persist a binding.
64
- * - `mismatch`: the selected device is not the one this operation belongs to —
65
- * a user-facing outcome, surfaced as `DeviceMismatch`.
66
- * - `skipped`: the host had nothing to bind (no record for this call). A host
67
- * contract problem, not something the user did.
68
- */
69
- type SaveDeviceBindingDeclineReason = 'mismatch' | 'skipped';
70
50
  type UiResponseEvent = {
71
- type: typeof UI_RESPONSE.RECEIVE_SAVE_DEVICE_BINDING;
72
- payload: {
73
- requestId: string;
74
- saved: boolean;
75
- reason?: SaveDeviceBindingDeclineReason;
76
- };
77
- } | {
78
51
  type: typeof UI_RESPONSE.RECEIVE_PIN;
79
52
  payload: string;
80
53
  } | {
@@ -90,13 +63,8 @@ type UiResponseEvent = {
90
63
  } | {
91
64
  type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;
92
65
  payload: {
93
- requestId?: string;
94
- } & ({
95
66
  sdkConnectId: string;
96
- cancelled?: false;
97
- } | {
98
- cancelled: true;
99
- });
67
+ };
100
68
  } | {
101
69
  type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;
102
70
  payload: {
@@ -148,22 +116,13 @@ declare const UI_REQUEST_TIMEOUT_TAG = "UiRequestTimeout";
148
116
  */
149
117
  declare class UiRequestRegistry {
150
118
  private pending;
151
- createRequestId(): string;
152
119
  wait<T = unknown>(requestType: string, options?: {
153
120
  timeoutMs?: number;
154
- requestId?: string;
155
- operationId?: string;
156
121
  }): Promise<T>;
157
122
  resolve(responseType: string, payload: unknown): void;
158
- /**
159
- * Cancel pending waiters. Each argument narrows what is reached: no argument
160
- * at all rejects every waiter and belongs to teardown, while an `operationId`
161
- * alone rejects only the prompts that operation opened and leaves another
162
- * operation's PIN or QR wait untouched.
163
- */
164
- cancel(requestType?: string, requestId?: string, operationId?: string): void;
123
+ cancel(requestType?: string): void;
165
124
  reset(): void;
166
125
  hasPending(requestType?: string): boolean;
167
126
  }
168
127
 
169
- export { type DevicePermissionDeniedReason as D, type QrDisplayData as Q, type SaveDeviceBindingDeclineReason as S, type UiResponseEvent as U, type UiRequestOperationAttribution as a, UI_REQUEST as b, UiRequestRegistry as c, type DevicePermissionResponse as d, type QrResponseData as e, UI_EVENT as f, UI_REQUEST_CANCELLED_TAG as g, UI_REQUEST_DEFAULT_TIMEOUT_MS as h, UI_REQUEST_PREEMPTED_TAG as i, UI_REQUEST_TIMEOUT_TAG as j, UI_RESPONSE as k };
128
+ export { type DevicePermissionDeniedReason as D, type QrDisplayData as Q, type UiResponseEvent as U, UI_REQUEST as a, type DevicePermissionResponse as b, type QrResponseData as c, UI_EVENT as d, UI_REQUEST_CANCELLED_TAG as e, UI_REQUEST_DEFAULT_TIMEOUT_MS as f, UI_REQUEST_PREEMPTED_TAG as g, UI_REQUEST_TIMEOUT_TAG as h, UI_RESPONSE as i, UiRequestRegistry as j };
@@ -1 +1 @@
1
- export { D as DevicePermissionDeniedReason, d as DevicePermissionResponse, f as UI_EVENT, b as UI_REQUEST, g as UI_REQUEST_CANCELLED_TAG, h as UI_REQUEST_DEFAULT_TIMEOUT_MS, i as UI_REQUEST_PREEMPTED_TAG, j as UI_REQUEST_TIMEOUT_TAG, k as UI_RESPONSE, a as UiRequestOperationAttribution, c as UiRequestRegistry, U as UiResponseEvent } from './ui-events-BGUpXxvP.mjs';
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';
@@ -1 +1 @@
1
- export { D as DevicePermissionDeniedReason, d as DevicePermissionResponse, f as UI_EVENT, b as UI_REQUEST, g as UI_REQUEST_CANCELLED_TAG, h as UI_REQUEST_DEFAULT_TIMEOUT_MS, i as UI_REQUEST_PREEMPTED_TAG, j as UI_REQUEST_TIMEOUT_TAG, k as UI_RESPONSE, a as UiRequestOperationAttribution, c as UiRequestRegistry, U as UiResponseEvent } from './ui-events-BGUpXxvP.js';
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,8 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkWUIWRX56js = require('./chunk-WUIWRX56.js');
11
- require('./chunk-CQM2P5IG.js');
10
+ var _chunkBAGEFFFYjs = require('./chunk-BAGEFFFY.js');
12
11
 
13
12
 
14
13
 
@@ -18,5 +17,5 @@ require('./chunk-CQM2P5IG.js');
18
17
 
19
18
 
20
19
 
21
- exports.UI_EVENT = _chunkWUIWRX56js.UI_EVENT; exports.UI_REQUEST = _chunkWUIWRX56js.UI_REQUEST; exports.UI_REQUEST_CANCELLED_TAG = _chunkWUIWRX56js.UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = _chunkWUIWRX56js.UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = _chunkWUIWRX56js.UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = _chunkWUIWRX56js.UI_REQUEST_TIMEOUT_TAG; exports.UI_RESPONSE = _chunkWUIWRX56js.UI_RESPONSE; exports.UiRequestRegistry = _chunkWUIWRX56js.UiRequestRegistry;
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;
22
21
  //# sourceMappingURL=ui-events.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/ui-events.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B,+BAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,ihBAAC","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/ui-events.js"}
1
+ {"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/ui-events.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,ihBAAC","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/ui-events.js"}
@@ -7,8 +7,7 @@ import {
7
7
  UI_REQUEST_TIMEOUT_TAG,
8
8
  UI_RESPONSE,
9
9
  UiRequestRegistry
10
- } from "./chunk-EQYPRCWU.mjs";
11
- import "./chunk-IOFMG7YO.mjs";
10
+ } from "./chunk-U63HTLGJ.mjs";
12
11
  export {
13
12
  UI_EVENT,
14
13
  UI_REQUEST,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hwk-adapter-core",
3
- "version": "1.2.3-alpha.8",
3
+ "version": "1.2.3",
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": "170aac4b7ca98bf24b5dd36b9729c98a10389161"
73
+ "gitHead": "de8e0beb9d993464fbcac6231d7efe501d789c7d"
74
74
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-CQM2P5IG.js","../src/types/errors.ts"],"names":["HardwareErrorCode"],"mappings":"AAAA;ACwBO,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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;AACA;AACA;AACF,kYAAC","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-CQM2P5IG.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-10699 Payload / framing limits (adapter-level)\n * 10700-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 /** The supplied runtime-only operation id is unknown to this adapter instance. */\n OperationNotFound = 10112,\n /** The supplied operation ended and can never be resumed. */\n OperationEnded = 10113,\n /**\n * Discovery found devices but none of them is the wallet being looked for.\n * Milder than DeviceMismatch: nothing about the known wallet has changed, the\n * user simply has the wrong unit connected. DeviceMismatch stays reserved for\n * reaching the expected device and finding a different identity on it, which\n * can mean it was wiped, reseeded, or swapped.\n */\n DeviceSearchMismatch = 10114,\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 * The user cancelled BLE pairing from the app while the connect was still\n * waiting on the OS pairing window. Not a failure to report — the flow ends\n * because they asked it to. Distinct from UserAborted (generic in-app cancel)\n * so the pairing UI can close quietly instead of surfacing a connect error,\n * and from BlePairingTimeout (the SMP window elapsed on its own).\n */\n BlePairingCancelled = 10310,\n /**\n * The vendor's remote secure channel broke while it was relaying APDUs to the\n * device (Ledger: the manager-api script-runner WebSocket behind app install,\n * uninstall and genuine check). The device link itself is still usable, so\n * this is not a disconnect: retry the same call. Distinct from NetworkError,\n * which is a plain HTTP/WS request that never carried device traffic.\n */\n LedgerSecureChannelError = 10311,\n /**\n * The vendor's metadata service answered with a payload the SDK cannot use\n * (Ledger: firmware metadata or the application catalog). Not a connectivity\n * failure — the request succeeded and the response was unusable — so callers\n * must not treat it as a dropped link.\n */\n LedgerFirmwareMetadataError = 10312,\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 /** Standard wallet is unavailable while Trezor enforces on-device passphrase entry. */\n PassphraseAlwaysOnDevice = 10405,\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 /** Install refused because the app is already on the device. Benign for callers that only need it present. */\n AppAlreadyInstalled = 10504,\n\n // --- 10600s Payload / framing limits ---\n /**\n * The call payload exceeds a transport's fixed framing capacity (e.g.\n * Keystone USB's ~12.5KB per-request cap — 200 frames of 64 bytes). Distinct\n * from a generic TransportError: the request never reached the device, and\n * retrying with the same payload over the same transport will fail the same\n * way. Callers should route the call over a different channel (e.g. Keystone\n * QR) or reduce the payload (e.g. a smaller PSBT) instead of retrying as-is.\n */\n PayloadTooLarge = 10600,\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.OperationNotFound,\n HardwareErrorCode.OperationEnded,\n HardwareErrorCode.DeviceMismatch,\n HardwareErrorCode.DeviceSearchMismatch,\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 HardwareErrorCode.BlePairingCancelled,\n HardwareErrorCode.PassphraseAlwaysOnDevice,\n];\n\n// ---------------------------------------------------------------------------\n// Standard throwable for HWK adapters\n// ---------------------------------------------------------------------------\n\n/**\n * Where a failure came from. The distinction the numeric code ranges cannot\n * make reliably (UserRejected=10001 sits in the general range but is the\n * device speaking; DevicePermissionDenied=10303 sits in the transport range\n * but is the browser speaking), and the one recovery logic actually needs:\n *\n * - `device` the firmware ANSWERED: rejection, locked screen, wrong\n * wallet, bad PIN. It is a result, not a malfunction — surface\n * it to the user verbatim; never auto-reconnect, never switch\n * channels, never drop a healthy session over it.\n * - `transport` the pipe failed: cable pulled, bus reset, bridge gone.\n * Reconnecting or falling back to another channel is fair game.\n * - `host` the host environment refused: browser permission, picker\n * dismissed, bad parameters. Fix the environment, not the link.\n *\n * Optional on purpose: a mapper that cannot tell MUST leave it unset rather\n * than guess — consumers fall back to their existing code-based tables, so an\n * unset origin degrades to today's behavior instead of mislabeling.\n */\nexport type HwkErrorOrigin = 'device' | 'transport' | 'host';\n\n/**\n * Smallest runtime resource a consumer must replace before retrying a failed\n * operation. This is connection-lifecycle metadata, not UI navigation and not\n * permission to replay a signing command automatically.\n *\n * - `call`: nothing needs replacing; re-issuing the same call is eligible,\n * usually after the user fixes device state.\n * - `operation`: the operation binding is no longer usable; the selected target\n * may be used to establish a new one when its identity is persistent.\n * - `search-target`: the selected discovery result is stale or untrusted;\n * rediscover on the same transport and let the user select again.\n * - `transport`: the selected transport is unavailable or unsuitable; repair\n * it or choose another transport.\n * - `not-recoverable`: retrying the same operation/context cannot succeed.\n * - `unknown`: the SDK cannot make a safe recovery claim.\n */\nexport type HwkRecoveryScope =\n | 'call'\n | 'operation'\n | 'search-target'\n | 'transport'\n | 'not-recoverable'\n | 'unknown';\n\nexport interface HwkRecoveryHint {\n scope: HwkRecoveryScope;\n}\n\nconst RECOVERY_SCOPES = new Set<HwkRecoveryScope>([\n 'call',\n 'operation',\n 'search-target',\n 'transport',\n 'not-recoverable',\n 'unknown',\n]);\n\nexport function isHwkRecoveryHint(value: unknown): value is HwkRecoveryHint {\n if (!value || typeof value !== 'object') return false;\n const { scope } = value as { scope?: unknown };\n return typeof scope === 'string' && RECOVERY_SCOPES.has(scope as HwkRecoveryScope);\n}\n\nconst RECOVERY_CALL: HwkRecoveryHint = Object.freeze({ scope: 'call' });\nconst RECOVERY_OPERATION: HwkRecoveryHint = Object.freeze({ scope: 'operation' });\nconst RECOVERY_SEARCH_TARGET: HwkRecoveryHint = Object.freeze({ scope: 'search-target' });\nconst RECOVERY_TRANSPORT: HwkRecoveryHint = Object.freeze({ scope: 'transport' });\nconst RECOVERY_NOT_RECOVERABLE: HwkRecoveryHint = Object.freeze({\n scope: 'not-recoverable',\n});\nconst RECOVERY_UNKNOWN: HwkRecoveryHint = Object.freeze({ scope: 'unknown' });\n\n/**\n * Vendor-neutral fallback used when an adapter has no more precise runtime\n * knowledge. Adapters may stamp a narrower hint when transport/session state\n * makes the correct scope unambiguous.\n */\nexport function defaultRecoveryForCode(code: HardwareErrorCode): HwkRecoveryHint {\n switch (code) {\n case HardwareErrorCode.UserRejected:\n case HardwareErrorCode.UserAborted:\n case HardwareErrorCode.DeviceBusy:\n case HardwareErrorCode.DeviceLocked:\n case HardwareErrorCode.DeviceNotInitialized:\n case HardwareErrorCode.DeviceInBootloader:\n case HardwareErrorCode.DeviceAppStuck:\n case HardwareErrorCode.DeviceBusyInternal:\n case HardwareErrorCode.NetworkError:\n case HardwareErrorCode.LedgerSecureChannelError:\n case HardwareErrorCode.LedgerFirmwareMetadataError:\n case HardwareErrorCode.PinInvalid:\n case HardwareErrorCode.PinCancelled:\n case HardwareErrorCode.PassphraseRejected:\n case HardwareErrorCode.PassphraseStateMismatch:\n case HardwareErrorCode.PinMismatch:\n case HardwareErrorCode.FirmwareTooOld:\n case HardwareErrorCode.FirmwareUpdateRequired:\n case HardwareErrorCode.AppNotInstalled:\n case HardwareErrorCode.WrongApp:\n case HardwareErrorCode.AppTooOld:\n case HardwareErrorCode.DeviceOutOfMemory:\n case HardwareErrorCode.AppAlreadyInstalled:\n case HardwareErrorCode.EvmBlindSigningRequired:\n case HardwareErrorCode.EvmClearSignPluginMissing:\n case HardwareErrorCode.EvmDataTooLarge:\n case HardwareErrorCode.EvmTxTypeNotSupported:\n case HardwareErrorCode.SolanaBlindSigningRequired:\n case HardwareErrorCode.TronCustomContractRequired:\n case HardwareErrorCode.TronDataSigningRequired:\n case HardwareErrorCode.TronSignByHashRequired:\n case HardwareErrorCode.BtcWalletPolicyHmacMismatch:\n case HardwareErrorCode.BtcUnexpectedState:\n return RECOVERY_CALL;\n case HardwareErrorCode.DeviceNotFound:\n case HardwareErrorCode.DeviceDisconnected:\n case HardwareErrorCode.OperationNotFound:\n case HardwareErrorCode.OperationEnded:\n case HardwareErrorCode.TransportError:\n case HardwareErrorCode.BlePairingTimeout:\n case HardwareErrorCode.ThpPairingFailed:\n case HardwareErrorCode.ThpPairingRequired:\n case HardwareErrorCode.BleConnectFailed:\n case HardwareErrorCode.BlePairingCancelled:\n return RECOVERY_OPERATION;\n case HardwareErrorCode.DeviceMismatch:\n case HardwareErrorCode.DeviceSearchMismatch:\n case HardwareErrorCode.DeviceOneDeviceOnly:\n case HardwareErrorCode.BleBondInvalid:\n return RECOVERY_SEARCH_TARGET;\n case HardwareErrorCode.BridgeNotFound:\n case HardwareErrorCode.TransportNotAvailable:\n case HardwareErrorCode.DevicePermissionDenied:\n case HardwareErrorCode.PayloadTooLarge:\n return RECOVERY_TRANSPORT;\n case HardwareErrorCode.InvalidParams:\n case HardwareErrorCode.MethodNotSupported:\n case HardwareErrorCode.ChainNotSupported:\n case HardwareErrorCode.DevicePathForbidden:\n return RECOVERY_NOT_RECOVERABLE;\n case HardwareErrorCode.UnknownError:\n case HardwareErrorCode.OperationTimeout:\n default:\n return RECOVERY_UNKNOWN;\n }\n}\n\n/**\n * The authoritative code→origin table. Most codes imply their origin by\n * definition (UserRejected IS the device speaking; BridgeNotFound IS the\n * pipe). Vendors use this as the default and override only where their\n * mapping context knows better. Codes whose origin genuinely depends on\n * context (UnknownError, OperationTimeout — the device may be waiting for a\n * human, or the pipe may be dead — and DeviceBusy) return undefined: an\n * honest \"can't tell\" beats a plausible mislabel, because consumers fall\n * back to their existing behavior instead of taking the wrong recovery.\n */\nexport function defaultOriginForCode(code: HardwareErrorCode): HwkErrorOrigin | undefined {\n // Chain APDU blocks (11000+) are, without exception, the chain app on the\n // device answering a request it understood and refused/qualified.\n if (code >= 11_000) return 'device';\n switch (code) {\n case HardwareErrorCode.UserRejected:\n case HardwareErrorCode.DeviceLocked:\n case HardwareErrorCode.DeviceNotInitialized:\n case HardwareErrorCode.DeviceInBootloader:\n case HardwareErrorCode.DeviceMismatch:\n case HardwareErrorCode.DeviceSearchMismatch:\n case HardwareErrorCode.DeviceAppStuck:\n case HardwareErrorCode.DevicePathForbidden:\n case HardwareErrorCode.DeviceBusyInternal:\n case HardwareErrorCode.ChainNotSupported:\n case HardwareErrorCode.FirmwareTooOld:\n case HardwareErrorCode.FirmwareUpdateRequired:\n case HardwareErrorCode.PinInvalid:\n case HardwareErrorCode.PinMismatch:\n case HardwareErrorCode.PassphraseRejected:\n case HardwareErrorCode.PassphraseStateMismatch:\n case HardwareErrorCode.ThpPairingFailed:\n case HardwareErrorCode.ThpPairingRequired:\n case HardwareErrorCode.WrongApp:\n case HardwareErrorCode.AppNotInstalled:\n case HardwareErrorCode.AppTooOld:\n case HardwareErrorCode.DeviceOutOfMemory:\n case HardwareErrorCode.AppAlreadyInstalled:\n return 'device';\n case HardwareErrorCode.DeviceNotFound:\n case HardwareErrorCode.DeviceDisconnected:\n case HardwareErrorCode.TransportError:\n case HardwareErrorCode.BridgeNotFound:\n case HardwareErrorCode.TransportNotAvailable:\n case HardwareErrorCode.BlePairingTimeout:\n case HardwareErrorCode.NetworkError:\n case HardwareErrorCode.LedgerSecureChannelError:\n case HardwareErrorCode.LedgerFirmwareMetadataError:\n case HardwareErrorCode.BleBondInvalid:\n case HardwareErrorCode.BleConnectFailed:\n return 'transport';\n case HardwareErrorCode.DevicePermissionDenied:\n case HardwareErrorCode.UserAborted:\n case HardwareErrorCode.InvalidParams:\n case HardwareErrorCode.MethodNotSupported:\n case HardwareErrorCode.PinCancelled:\n case HardwareErrorCode.BlePairingCancelled:\n case HardwareErrorCode.PayloadTooLarge:\n case HardwareErrorCode.DeviceOneDeviceOnly:\n return 'host';\n default:\n return undefined;\n }\n}\n\nexport interface IHwkErrorPayload {\n code: HardwareErrorCode;\n message: string;\n origin?: HwkErrorOrigin;\n recovery?: HwkRecoveryHint;\n appName?: string;\n _tag?: string;\n params?: Record<string, unknown>;\n}\n\nexport interface IOperationMayHaveCompletedParams extends Record<string, unknown> {\n operationMayHaveCompleted: true;\n method: string;\n}\n\n/**\n * Marks an unsafe hardware request whose response was lost after dispatch.\n * Callers must not interpret the resulting transport error as proof that the\n * device rejected or did not execute the operation.\n */\nexport function operationMayHaveCompletedParams(\n method: string,\n params?: Record<string, unknown>\n): IOperationMayHaveCompletedParams {\n return {\n ...params,\n operationMayHaveCompleted: true,\n method,\n };\n}\n\nexport type HwkError = Error & {\n code: HardwareErrorCode;\n /** See {@link HwkErrorOrigin}. Survives serializeConnectorError/rehydrate\n * automatically (own fields outside the top-level whitelist travel via\n * `params` and are lifted back). */\n origin?: HwkErrorOrigin;\n recovery?: HwkRecoveryHint;\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 const recovery = payload.recovery ?? defaultRecoveryForCode(payload.code);\n return Object.assign(new Error(payload.message), {\n code: payload.code,\n ...(payload.origin !== undefined && { origin: payload.origin }),\n recovery,\n ...(payload._tag !== undefined && { _tag: payload._tag }),\n ...(payload.appName !== undefined && { appName: payload.appName }),\n ...(payload.params !== undefined && { params: payload.params }),\n });\n}\n"]}
@@ -1,74 +0,0 @@
1
- // src/utils/errorMessages.ts
2
- function enrichErrorMessage(code, originalMessage) {
3
- switch (code) {
4
- case 10400 /* PinInvalid */:
5
- return `${originalMessage}. Please re-enter your PIN.`;
6
- case 10401 /* PinCancelled */:
7
- return `${originalMessage}. PIN entry was cancelled.`;
8
- case 10404 /* PinMismatch */:
9
- return `${originalMessage}. The entered PINs do not match. Please try again.`;
10
- case 10102 /* DeviceBusy */:
11
- return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;
12
- case 10111 /* DeviceBusyInternal */:
13
- return `${originalMessage}. The device is busy. Please try again in a moment.`;
14
- case 10101 /* DeviceDisconnected */:
15
- return `${originalMessage}. Please reconnect the device and try again.`;
16
- case 10103 /* DeviceLocked */:
17
- return `${originalMessage}. Please unlock your device and try again.`;
18
- case 10109 /* DeviceOneDeviceOnly */:
19
- return `${originalMessage}. Disconnect the extra device and try again.`;
20
- case 10001 /* UserRejected */:
21
- return `${originalMessage}. The request was rejected on the device.`;
22
- case 10501 /* WrongApp */:
23
- return `${originalMessage}. Please open the correct app on your device.`;
24
- case 10500 /* AppNotInstalled */:
25
- return `${originalMessage}. The required app is not installed on the device.`;
26
- case 10503 /* DeviceOutOfMemory */:
27
- return `${originalMessage}. Not enough free space on the device. Please uninstall some apps and try again.`;
28
- case 10302 /* TransportNotAvailable */:
29
- return `${originalMessage}. Ensure the device bridge/transport is available and running.`;
30
- case 10305 /* NetworkError */:
31
- return `${originalMessage}. Network error \u2014 check your internet connection and try again.`;
32
- case 10311 /* LedgerSecureChannelError */:
33
- return `${originalMessage}. The secure connection to Ledger's servers was interrupted. Keep the device unlocked on the dashboard and try again.`;
34
- case 10312 /* LedgerFirmwareMetadataError */:
35
- return `${originalMessage}. Ledger's app catalog returned an unusable response. Please try again later.`;
36
- case 10504 /* AppAlreadyInstalled */:
37
- return `${originalMessage}. The app is already installed on the device.`;
38
- case 10200 /* FirmwareTooOld */:
39
- return `${originalMessage}. Please update your device firmware.`;
40
- case 10104 /* DeviceNotInitialized */:
41
- return `${originalMessage}. The device may need to be set up first.`;
42
- case 10003 /* OperationTimeout */:
43
- return `${originalMessage}. The operation timed out. Please try again.`;
44
- case 11e3 /* EvmBlindSigningRequired */:
45
- return "Ledger: Blind signing not enabled in Ethereum app.";
46
- case 11001 /* EvmClearSignPluginMissing */:
47
- return "Ledger: Required plugin not installed (install via Ledger Live).";
48
- case 11002 /* EvmDataTooLarge */:
49
- return "Ledger: Transaction data too large for device memory.";
50
- case 11003 /* EvmTxTypeNotSupported */:
51
- return "Ledger: Transaction type not supported by current Ethereum app.";
52
- case 10502 /* AppTooOld */:
53
- return "Ledger: App out of date (update via Ledger Live).";
54
- case 11100 /* SolanaBlindSigningRequired */:
55
- return "Blind signing disabled in the Solana app.";
56
- case 11200 /* TronCustomContractRequired */:
57
- return "Custom Contracts setting disabled in the Tron app.";
58
- case 11201 /* TronDataSigningRequired */:
59
- return "Transactions Data setting disabled in the Tron app.";
60
- case 11202 /* TronSignByHashRequired */:
61
- return "Sign by Hash setting disabled in the Tron app.";
62
- case 11300 /* BtcWalletPolicyHmacMismatch */:
63
- return "Wallet policy not registered or HMAC mismatch.";
64
- case 11301 /* BtcUnexpectedState */:
65
- return "Signing aborted due to unexpected device state.";
66
- default:
67
- return originalMessage;
68
- }
69
- }
70
-
71
- export {
72
- enrichErrorMessage
73
- };
74
- //# sourceMappingURL=chunk-DB4JOPZO.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/errorMessages.ts"],"sourcesContent":["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.LedgerSecureChannelError:\n return `${originalMessage}. The secure connection to Ledger's servers was interrupted. Keep the device unlocked on the dashboard and try again.`;\n case HardwareErrorCode.LedgerFirmwareMetadataError:\n return `${originalMessage}. Ledger's app catalog returned an unusable response. Please try again later.`;\n case HardwareErrorCode.AppAlreadyInstalled:\n return `${originalMessage}. The app is already installed on the device.`;\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"],"mappings":";AAMO,SAAS,mBAAmB,MAAyB,iBAAiC;AAC3F,UAAQ,MAAM;AAAA,IACZ;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO,GAAG,eAAe;AAAA,IAC3B;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
@@ -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 // 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_SAVE_DEVICE_BINDING: 'ui-request-save-device-binding',\n DEVICE_BINDING_STATUS: 'ui-device-binding-status',\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_SAVE_DEVICE_BINDING: 'receive-save-device-binding',\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\n/**\n * Which operation a UI request was opened under. Optional: a request emitted\n * outside any operation (cold start, teardown) has none, and a host that does\n * not track operations can ignore it. It is what lets a cancel aimed at one\n * operation leave another operation's prompts alone.\n */\nexport type UiRequestOperationAttribution = {\n operationId?: string;\n};\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\n/**\n * Why a host refused to persist a binding.\n * - `mismatch`: the selected device is not the one this operation belongs to —\n * a user-facing outcome, surfaced as `DeviceMismatch`.\n * - `skipped`: the host had nothing to bind (no record for this call). A host\n * contract problem, not something the user did.\n */\nexport type SaveDeviceBindingDeclineReason = 'mismatch' | 'skipped';\n\nexport type UiResponseEvent =\n | {\n type: typeof UI_RESPONSE.RECEIVE_SAVE_DEVICE_BINDING;\n payload: {\n requestId: string;\n saved: boolean;\n reason?: SaveDeviceBindingDeclineReason;\n };\n }\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: { requestId?: string } & (\n | { sdkConnectId: string; cancelled?: false }\n | { cancelled: true }\n );\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';\nimport { createHwkError, HardwareErrorCode } from '../types/errors';\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_SAVE_DEVICE_BINDING]: UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING,\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\nlet requestSequence = 0;\n\ntype PendingEntry = {\n requestId?: string;\n /** The operation this waiter belongs to, when it was opened under one. */\n operationId?: string;\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 createRequestId(): string {\n requestSequence += 1;\n return `hwk-ui-${Date.now()}-${requestSequence}`;\n }\n\n wait<T = unknown>(\n requestType: string,\n options?: { timeoutMs?: number; requestId?: string; operationId?: string }\n ): 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 requestId: options?.requestId,\n operationId: options?.operationId,\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 const response =\n payload && typeof payload === 'object'\n ? (payload as { requestId?: unknown; cancelled?: unknown })\n : undefined;\n // A late response must not resolve (or cancel) a newer request of the same type.\n if (entry.requestId !== undefined && response?.requestId !== entry.requestId) return;\n if (requestType === UI_REQUEST.REQUEST_SELECT_DEVICE && response?.cancelled === true) {\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.reject(\n createHwkError({\n code: HardwareErrorCode.UserAborted,\n message: 'Device selection was cancelled',\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n return;\n }\n\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.resolve(payload);\n }\n\n /**\n * Cancel pending waiters. Each argument narrows what is reached: no argument\n * at all rejects every waiter and belongs to teardown, while an `operationId`\n * alone rejects only the prompts that operation opened and leaves another\n * operation's PIN or QR wait untouched.\n */\n cancel(requestType?: string, requestId?: string, operationId?: string): void {\n const reject = (type: string, entry: PendingEntry) => {\n clearTimeout(entry.timer);\n this.pending.delete(type);\n entry.reject(\n Object.assign(new Error(`UI request '${type}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n };\n\n if (requestType) {\n const entry = this.pending.get(requestType);\n if (!entry) return;\n if (requestId !== undefined && entry.requestId !== requestId) return;\n if (operationId !== undefined && entry.operationId !== operationId) return;\n reject(requestType, entry);\n return;\n }\n\n for (const [type, entry] of [...this.pending]) {\n if (operationId === undefined || entry.operationId === operationId) {\n reject(type, entry);\n }\n }\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,6BAA6B;AAAA,EAC7B,uBAAuB;AAAA,EACvB,wBAAwB;AAAA;AAAA;AAAA,EAGxB,gCAAgC;AAAA;AAAA;AAAA,EAGhC,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,4BAA4B;AAAA,EAC5B,iBAAiB;AAAA,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YAAM;AAAA,QACJ,eAAe;AAAA,UACb;AAAA,UACA,SAAS;AAAA,UACT,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AACA;AAAA,IACF;AAEA,iBAAa,MAAM,KAAK;AACxB,SAAK,QAAQ,OAAO,WAAW;AAC/B,UAAM,QAAQ,OAAO;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,aAAsB,WAAoB,aAA4B;AAC3E,UAAM,SAAS,CAAC,MAAc,UAAwB;AACpD,mBAAa,MAAM,KAAK;AACxB,WAAK,QAAQ,OAAO,IAAI;AACxB,YAAM;AAAA,QACJ,OAAO,OAAO,IAAI,MAAM,eAAe,IAAI,iBAAiB,GAAG;AAAA,UAC7D,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AAAA,IACF;AAEA,QAAI,aAAa;AACf,YAAM,QAAQ,KAAK,QAAQ,IAAI,WAAW;AAC1C,UAAI,CAAC,MAAO;AACZ,UAAI,cAAc,UAAa,MAAM,cAAc,UAAW;AAC9D,UAAI,gBAAgB,UAAa,MAAM,gBAAgB,YAAa;AACpE,aAAO,aAAa,KAAK;AACzB;AAAA,IACF;AAEA,eAAW,CAAC,MAAM,KAAK,KAAK,CAAC,GAAG,KAAK,OAAO,GAAG;AAC7C,UAAI,gBAAgB,UAAa,MAAM,gBAAgB,aAAa;AAClE,eAAO,MAAM,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,EACF;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":["../src/types/errors.ts"],"sourcesContent":["/**\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-10699 Payload / framing limits (adapter-level)\n * 10700-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 /** The supplied runtime-only operation id is unknown to this adapter instance. */\n OperationNotFound = 10112,\n /** The supplied operation ended and can never be resumed. */\n OperationEnded = 10113,\n /**\n * Discovery found devices but none of them is the wallet being looked for.\n * Milder than DeviceMismatch: nothing about the known wallet has changed, the\n * user simply has the wrong unit connected. DeviceMismatch stays reserved for\n * reaching the expected device and finding a different identity on it, which\n * can mean it was wiped, reseeded, or swapped.\n */\n DeviceSearchMismatch = 10114,\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 * The user cancelled BLE pairing from the app while the connect was still\n * waiting on the OS pairing window. Not a failure to report — the flow ends\n * because they asked it to. Distinct from UserAborted (generic in-app cancel)\n * so the pairing UI can close quietly instead of surfacing a connect error,\n * and from BlePairingTimeout (the SMP window elapsed on its own).\n */\n BlePairingCancelled = 10310,\n /**\n * The vendor's remote secure channel broke while it was relaying APDUs to the\n * device (Ledger: the manager-api script-runner WebSocket behind app install,\n * uninstall and genuine check). The device link itself is still usable, so\n * this is not a disconnect: retry the same call. Distinct from NetworkError,\n * which is a plain HTTP/WS request that never carried device traffic.\n */\n LedgerSecureChannelError = 10311,\n /**\n * The vendor's metadata service answered with a payload the SDK cannot use\n * (Ledger: firmware metadata or the application catalog). Not a connectivity\n * failure — the request succeeded and the response was unusable — so callers\n * must not treat it as a dropped link.\n */\n LedgerFirmwareMetadataError = 10312,\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 /** Standard wallet is unavailable while Trezor enforces on-device passphrase entry. */\n PassphraseAlwaysOnDevice = 10405,\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 /** Install refused because the app is already on the device. Benign for callers that only need it present. */\n AppAlreadyInstalled = 10504,\n\n // --- 10600s Payload / framing limits ---\n /**\n * The call payload exceeds a transport's fixed framing capacity (e.g.\n * Keystone USB's ~12.5KB per-request cap — 200 frames of 64 bytes). Distinct\n * from a generic TransportError: the request never reached the device, and\n * retrying with the same payload over the same transport will fail the same\n * way. Callers should route the call over a different channel (e.g. Keystone\n * QR) or reduce the payload (e.g. a smaller PSBT) instead of retrying as-is.\n */\n PayloadTooLarge = 10600,\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.OperationNotFound,\n HardwareErrorCode.OperationEnded,\n HardwareErrorCode.DeviceMismatch,\n HardwareErrorCode.DeviceSearchMismatch,\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 HardwareErrorCode.BlePairingCancelled,\n HardwareErrorCode.PassphraseAlwaysOnDevice,\n];\n\n// ---------------------------------------------------------------------------\n// Standard throwable for HWK adapters\n// ---------------------------------------------------------------------------\n\n/**\n * Where a failure came from. The distinction the numeric code ranges cannot\n * make reliably (UserRejected=10001 sits in the general range but is the\n * device speaking; DevicePermissionDenied=10303 sits in the transport range\n * but is the browser speaking), and the one recovery logic actually needs:\n *\n * - `device` the firmware ANSWERED: rejection, locked screen, wrong\n * wallet, bad PIN. It is a result, not a malfunction — surface\n * it to the user verbatim; never auto-reconnect, never switch\n * channels, never drop a healthy session over it.\n * - `transport` the pipe failed: cable pulled, bus reset, bridge gone.\n * Reconnecting or falling back to another channel is fair game.\n * - `host` the host environment refused: browser permission, picker\n * dismissed, bad parameters. Fix the environment, not the link.\n *\n * Optional on purpose: a mapper that cannot tell MUST leave it unset rather\n * than guess — consumers fall back to their existing code-based tables, so an\n * unset origin degrades to today's behavior instead of mislabeling.\n */\nexport type HwkErrorOrigin = 'device' | 'transport' | 'host';\n\n/**\n * Smallest runtime resource a consumer must replace before retrying a failed\n * operation. This is connection-lifecycle metadata, not UI navigation and not\n * permission to replay a signing command automatically.\n *\n * - `call`: nothing needs replacing; re-issuing the same call is eligible,\n * usually after the user fixes device state.\n * - `operation`: the operation binding is no longer usable; the selected target\n * may be used to establish a new one when its identity is persistent.\n * - `search-target`: the selected discovery result is stale or untrusted;\n * rediscover on the same transport and let the user select again.\n * - `transport`: the selected transport is unavailable or unsuitable; repair\n * it or choose another transport.\n * - `not-recoverable`: retrying the same operation/context cannot succeed.\n * - `unknown`: the SDK cannot make a safe recovery claim.\n */\nexport type HwkRecoveryScope =\n | 'call'\n | 'operation'\n | 'search-target'\n | 'transport'\n | 'not-recoverable'\n | 'unknown';\n\nexport interface HwkRecoveryHint {\n scope: HwkRecoveryScope;\n}\n\nconst RECOVERY_SCOPES = new Set<HwkRecoveryScope>([\n 'call',\n 'operation',\n 'search-target',\n 'transport',\n 'not-recoverable',\n 'unknown',\n]);\n\nexport function isHwkRecoveryHint(value: unknown): value is HwkRecoveryHint {\n if (!value || typeof value !== 'object') return false;\n const { scope } = value as { scope?: unknown };\n return typeof scope === 'string' && RECOVERY_SCOPES.has(scope as HwkRecoveryScope);\n}\n\nconst RECOVERY_CALL: HwkRecoveryHint = Object.freeze({ scope: 'call' });\nconst RECOVERY_OPERATION: HwkRecoveryHint = Object.freeze({ scope: 'operation' });\nconst RECOVERY_SEARCH_TARGET: HwkRecoveryHint = Object.freeze({ scope: 'search-target' });\nconst RECOVERY_TRANSPORT: HwkRecoveryHint = Object.freeze({ scope: 'transport' });\nconst RECOVERY_NOT_RECOVERABLE: HwkRecoveryHint = Object.freeze({\n scope: 'not-recoverable',\n});\nconst RECOVERY_UNKNOWN: HwkRecoveryHint = Object.freeze({ scope: 'unknown' });\n\n/**\n * Vendor-neutral fallback used when an adapter has no more precise runtime\n * knowledge. Adapters may stamp a narrower hint when transport/session state\n * makes the correct scope unambiguous.\n */\nexport function defaultRecoveryForCode(code: HardwareErrorCode): HwkRecoveryHint {\n switch (code) {\n case HardwareErrorCode.UserRejected:\n case HardwareErrorCode.UserAborted:\n case HardwareErrorCode.DeviceBusy:\n case HardwareErrorCode.DeviceLocked:\n case HardwareErrorCode.DeviceNotInitialized:\n case HardwareErrorCode.DeviceInBootloader:\n case HardwareErrorCode.DeviceAppStuck:\n case HardwareErrorCode.DeviceBusyInternal:\n case HardwareErrorCode.NetworkError:\n case HardwareErrorCode.LedgerSecureChannelError:\n case HardwareErrorCode.LedgerFirmwareMetadataError:\n case HardwareErrorCode.PinInvalid:\n case HardwareErrorCode.PinCancelled:\n case HardwareErrorCode.PassphraseRejected:\n case HardwareErrorCode.PassphraseStateMismatch:\n case HardwareErrorCode.PinMismatch:\n case HardwareErrorCode.FirmwareTooOld:\n case HardwareErrorCode.FirmwareUpdateRequired:\n case HardwareErrorCode.AppNotInstalled:\n case HardwareErrorCode.WrongApp:\n case HardwareErrorCode.AppTooOld:\n case HardwareErrorCode.DeviceOutOfMemory:\n case HardwareErrorCode.AppAlreadyInstalled:\n case HardwareErrorCode.EvmBlindSigningRequired:\n case HardwareErrorCode.EvmClearSignPluginMissing:\n case HardwareErrorCode.EvmDataTooLarge:\n case HardwareErrorCode.EvmTxTypeNotSupported:\n case HardwareErrorCode.SolanaBlindSigningRequired:\n case HardwareErrorCode.TronCustomContractRequired:\n case HardwareErrorCode.TronDataSigningRequired:\n case HardwareErrorCode.TronSignByHashRequired:\n case HardwareErrorCode.BtcWalletPolicyHmacMismatch:\n case HardwareErrorCode.BtcUnexpectedState:\n return RECOVERY_CALL;\n case HardwareErrorCode.DeviceNotFound:\n case HardwareErrorCode.DeviceDisconnected:\n case HardwareErrorCode.OperationNotFound:\n case HardwareErrorCode.OperationEnded:\n case HardwareErrorCode.TransportError:\n case HardwareErrorCode.BlePairingTimeout:\n case HardwareErrorCode.ThpPairingFailed:\n case HardwareErrorCode.ThpPairingRequired:\n case HardwareErrorCode.BleConnectFailed:\n case HardwareErrorCode.BlePairingCancelled:\n return RECOVERY_OPERATION;\n case HardwareErrorCode.DeviceMismatch:\n case HardwareErrorCode.DeviceSearchMismatch:\n case HardwareErrorCode.DeviceOneDeviceOnly:\n case HardwareErrorCode.BleBondInvalid:\n return RECOVERY_SEARCH_TARGET;\n case HardwareErrorCode.BridgeNotFound:\n case HardwareErrorCode.TransportNotAvailable:\n case HardwareErrorCode.DevicePermissionDenied:\n case HardwareErrorCode.PayloadTooLarge:\n return RECOVERY_TRANSPORT;\n case HardwareErrorCode.InvalidParams:\n case HardwareErrorCode.MethodNotSupported:\n case HardwareErrorCode.ChainNotSupported:\n case HardwareErrorCode.DevicePathForbidden:\n return RECOVERY_NOT_RECOVERABLE;\n case HardwareErrorCode.UnknownError:\n case HardwareErrorCode.OperationTimeout:\n default:\n return RECOVERY_UNKNOWN;\n }\n}\n\n/**\n * The authoritative code→origin table. Most codes imply their origin by\n * definition (UserRejected IS the device speaking; BridgeNotFound IS the\n * pipe). Vendors use this as the default and override only where their\n * mapping context knows better. Codes whose origin genuinely depends on\n * context (UnknownError, OperationTimeout — the device may be waiting for a\n * human, or the pipe may be dead — and DeviceBusy) return undefined: an\n * honest \"can't tell\" beats a plausible mislabel, because consumers fall\n * back to their existing behavior instead of taking the wrong recovery.\n */\nexport function defaultOriginForCode(code: HardwareErrorCode): HwkErrorOrigin | undefined {\n // Chain APDU blocks (11000+) are, without exception, the chain app on the\n // device answering a request it understood and refused/qualified.\n if (code >= 11_000) return 'device';\n switch (code) {\n case HardwareErrorCode.UserRejected:\n case HardwareErrorCode.DeviceLocked:\n case HardwareErrorCode.DeviceNotInitialized:\n case HardwareErrorCode.DeviceInBootloader:\n case HardwareErrorCode.DeviceMismatch:\n case HardwareErrorCode.DeviceSearchMismatch:\n case HardwareErrorCode.DeviceAppStuck:\n case HardwareErrorCode.DevicePathForbidden:\n case HardwareErrorCode.DeviceBusyInternal:\n case HardwareErrorCode.ChainNotSupported:\n case HardwareErrorCode.FirmwareTooOld:\n case HardwareErrorCode.FirmwareUpdateRequired:\n case HardwareErrorCode.PinInvalid:\n case HardwareErrorCode.PinMismatch:\n case HardwareErrorCode.PassphraseRejected:\n case HardwareErrorCode.PassphraseStateMismatch:\n case HardwareErrorCode.ThpPairingFailed:\n case HardwareErrorCode.ThpPairingRequired:\n case HardwareErrorCode.WrongApp:\n case HardwareErrorCode.AppNotInstalled:\n case HardwareErrorCode.AppTooOld:\n case HardwareErrorCode.DeviceOutOfMemory:\n case HardwareErrorCode.AppAlreadyInstalled:\n return 'device';\n case HardwareErrorCode.DeviceNotFound:\n case HardwareErrorCode.DeviceDisconnected:\n case HardwareErrorCode.TransportError:\n case HardwareErrorCode.BridgeNotFound:\n case HardwareErrorCode.TransportNotAvailable:\n case HardwareErrorCode.BlePairingTimeout:\n case HardwareErrorCode.NetworkError:\n case HardwareErrorCode.LedgerSecureChannelError:\n case HardwareErrorCode.LedgerFirmwareMetadataError:\n case HardwareErrorCode.BleBondInvalid:\n case HardwareErrorCode.BleConnectFailed:\n return 'transport';\n case HardwareErrorCode.DevicePermissionDenied:\n case HardwareErrorCode.UserAborted:\n case HardwareErrorCode.InvalidParams:\n case HardwareErrorCode.MethodNotSupported:\n case HardwareErrorCode.PinCancelled:\n case HardwareErrorCode.BlePairingCancelled:\n case HardwareErrorCode.PayloadTooLarge:\n case HardwareErrorCode.DeviceOneDeviceOnly:\n return 'host';\n default:\n return undefined;\n }\n}\n\nexport interface IHwkErrorPayload {\n code: HardwareErrorCode;\n message: string;\n origin?: HwkErrorOrigin;\n recovery?: HwkRecoveryHint;\n appName?: string;\n _tag?: string;\n params?: Record<string, unknown>;\n}\n\nexport interface IOperationMayHaveCompletedParams extends Record<string, unknown> {\n operationMayHaveCompleted: true;\n method: string;\n}\n\n/**\n * Marks an unsafe hardware request whose response was lost after dispatch.\n * Callers must not interpret the resulting transport error as proof that the\n * device rejected or did not execute the operation.\n */\nexport function operationMayHaveCompletedParams(\n method: string,\n params?: Record<string, unknown>\n): IOperationMayHaveCompletedParams {\n return {\n ...params,\n operationMayHaveCompleted: true,\n method,\n };\n}\n\nexport type HwkError = Error & {\n code: HardwareErrorCode;\n /** See {@link HwkErrorOrigin}. Survives serializeConnectorError/rehydrate\n * automatically (own fields outside the top-level whitelist travel via\n * `params` and are lifted back). */\n origin?: HwkErrorOrigin;\n recovery?: HwkRecoveryHint;\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 const recovery = payload.recovery ?? defaultRecoveryForCode(payload.code);\n return Object.assign(new Error(payload.message), {\n code: payload.code,\n ...(payload.origin !== undefined && { origin: payload.origin }),\n recovery,\n ...(payload._tag !== undefined && { _tag: payload._tag }),\n ...(payload.appName !== undefined && { appName: payload.appName }),\n ...(payload.params !== undefined && { params: payload.params }),\n });\n}\n"],"mappings":";AAwBO,IAAK,oBAAL,kBAAKA,uBAAL;AAEL,EAAAA,sCAAA,kBAAe,OAAf;AACA,EAAAA,sCAAA,kBAAe,SAAf;AACA,EAAAA,sCAAA,mBAAgB,SAAhB;AACA,EAAAA,sCAAA,sBAAmB,SAAnB;AACA,EAAAA,sCAAA,wBAAqB,SAArB;AAEA,EAAAA,sCAAA,iB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AAAA,IAC/C,MAAM,QAAQ;AAAA,IACd,GAAI,QAAQ,WAAW,UAAa,EAAE,QAAQ,QAAQ,OAAO;AAAA,IAC7D;AAAA,IACA,GAAI,QAAQ,SAAS,UAAa,EAAE,MAAM,QAAQ,KAAK;AAAA,IACvD,GAAI,QAAQ,YAAY,UAAa,EAAE,SAAS,QAAQ,QAAQ;AAAA,IAChE,GAAI,QAAQ,WAAW,UAAa,EAAE,QAAQ,QAAQ,OAAO;AAAA,EAC/D,CAAC;AACH;","names":["HardwareErrorCode"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-WUIWRX56.js","../src/events/ui-request.ts","../src/utils/UiRequestRegistry.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACFO,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,2BAAA,EAA6B,gCAAA;AAAA,EAC7B,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,E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B,IAAA;AAC5B,MAAA;AACA,MAAA;AAClB,MAAA;AACuC,QAAA;AACnC,UAAA;AACP,QAAA;AACH,MAAA;AACF,IAAA;AAEiB,IAAA;AAC2B,MAAA;AAC9B,MAAA;AACyB,MAAA;AACE,MAAA;AACd,MAAA;AACzB,MAAA;AACF,IAAA;AAE+C,IAAA;AACN,MAAA;AACnB,QAAA;AACpB,MAAA;AACF,IAAA;AACF,EAAA;AAEc,EAAA;AACA,IAAA;AACd,EAAA;AAE0C,EAAA;AACC,IAAA;AACd,IAAA;AAC7B,EAAA;AACF;AFImD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-WUIWRX56.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_SAVE_DEVICE_BINDING: 'ui-request-save-device-binding',\n DEVICE_BINDING_STATUS: 'ui-device-binding-status',\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_SAVE_DEVICE_BINDING: 'receive-save-device-binding',\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\n/**\n * Which operation a UI request was opened under. Optional: a request emitted\n * outside any operation (cold start, teardown) has none, and a host that does\n * not track operations can ignore it. It is what lets a cancel aimed at one\n * operation leave another operation's prompts alone.\n */\nexport type UiRequestOperationAttribution = {\n operationId?: string;\n};\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\n/**\n * Why a host refused to persist a binding.\n * - `mismatch`: the selected device is not the one this operation belongs to —\n * a user-facing outcome, surfaced as `DeviceMismatch`.\n * - `skipped`: the host had nothing to bind (no record for this call). A host\n * contract problem, not something the user did.\n */\nexport type SaveDeviceBindingDeclineReason = 'mismatch' | 'skipped';\n\nexport type UiResponseEvent =\n | {\n type: typeof UI_RESPONSE.RECEIVE_SAVE_DEVICE_BINDING;\n payload: {\n requestId: string;\n saved: boolean;\n reason?: SaveDeviceBindingDeclineReason;\n };\n }\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: { requestId?: string } & (\n | { sdkConnectId: string; cancelled?: false }\n | { cancelled: true }\n );\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';\nimport { createHwkError, HardwareErrorCode } from '../types/errors';\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_SAVE_DEVICE_BINDING]: UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING,\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\nlet requestSequence = 0;\n\ntype PendingEntry = {\n requestId?: string;\n /** The operation this waiter belongs to, when it was opened under one. */\n operationId?: string;\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 createRequestId(): string {\n requestSequence += 1;\n return `hwk-ui-${Date.now()}-${requestSequence}`;\n }\n\n wait<T = unknown>(\n requestType: string,\n options?: { timeoutMs?: number; requestId?: string; operationId?: string }\n ): 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 requestId: options?.requestId,\n operationId: options?.operationId,\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 const response =\n payload && typeof payload === 'object'\n ? (payload as { requestId?: unknown; cancelled?: unknown })\n : undefined;\n // A late response must not resolve (or cancel) a newer request of the same type.\n if (entry.requestId !== undefined && response?.requestId !== entry.requestId) return;\n if (requestType === UI_REQUEST.REQUEST_SELECT_DEVICE && response?.cancelled === true) {\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.reject(\n createHwkError({\n code: HardwareErrorCode.UserAborted,\n message: 'Device selection was cancelled',\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n return;\n }\n\n clearTimeout(entry.timer);\n this.pending.delete(requestType);\n entry.resolve(payload);\n }\n\n /**\n * Cancel pending waiters. Each argument narrows what is reached: no argument\n * at all rejects every waiter and belongs to teardown, while an `operationId`\n * alone rejects only the prompts that operation opened and leaves another\n * operation's PIN or QR wait untouched.\n */\n cancel(requestType?: string, requestId?: string, operationId?: string): void {\n const reject = (type: string, entry: PendingEntry) => {\n clearTimeout(entry.timer);\n this.pending.delete(type);\n entry.reject(\n Object.assign(new Error(`UI request '${type}' was cancelled`), {\n _tag: UI_REQUEST_CANCELLED_TAG,\n })\n );\n };\n\n if (requestType) {\n const entry = this.pending.get(requestType);\n if (!entry) return;\n if (requestId !== undefined && entry.requestId !== requestId) return;\n if (operationId !== undefined && entry.operationId !== operationId) return;\n reject(requestType, entry);\n return;\n }\n\n for (const [type, entry] of [...this.pending]) {\n if (operationId === undefined || entry.operationId === operationId) {\n reject(type, entry);\n }\n }\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"]}
@@ -1,74 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/errorMessages.ts
2
- function enrichErrorMessage(code, originalMessage) {
3
- switch (code) {
4
- case 10400 /* PinInvalid */:
5
- return `${originalMessage}. Please re-enter your PIN.`;
6
- case 10401 /* PinCancelled */:
7
- return `${originalMessage}. PIN entry was cancelled.`;
8
- case 10404 /* PinMismatch */:
9
- return `${originalMessage}. The entered PINs do not match. Please try again.`;
10
- case 10102 /* DeviceBusy */:
11
- return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;
12
- case 10111 /* DeviceBusyInternal */:
13
- return `${originalMessage}. The device is busy. Please try again in a moment.`;
14
- case 10101 /* DeviceDisconnected */:
15
- return `${originalMessage}. Please reconnect the device and try again.`;
16
- case 10103 /* DeviceLocked */:
17
- return `${originalMessage}. Please unlock your device and try again.`;
18
- case 10109 /* DeviceOneDeviceOnly */:
19
- return `${originalMessage}. Disconnect the extra device and try again.`;
20
- case 10001 /* UserRejected */:
21
- return `${originalMessage}. The request was rejected on the device.`;
22
- case 10501 /* WrongApp */:
23
- return `${originalMessage}. Please open the correct app on your device.`;
24
- case 10500 /* AppNotInstalled */:
25
- return `${originalMessage}. The required app is not installed on the device.`;
26
- case 10503 /* DeviceOutOfMemory */:
27
- return `${originalMessage}. Not enough free space on the device. Please uninstall some apps and try again.`;
28
- case 10302 /* TransportNotAvailable */:
29
- return `${originalMessage}. Ensure the device bridge/transport is available and running.`;
30
- case 10305 /* NetworkError */:
31
- return `${originalMessage}. Network error \u2014 check your internet connection and try again.`;
32
- case 10311 /* LedgerSecureChannelError */:
33
- return `${originalMessage}. The secure connection to Ledger's servers was interrupted. Keep the device unlocked on the dashboard and try again.`;
34
- case 10312 /* LedgerFirmwareMetadataError */:
35
- return `${originalMessage}. Ledger's app catalog returned an unusable response. Please try again later.`;
36
- case 10504 /* AppAlreadyInstalled */:
37
- return `${originalMessage}. The app is already installed on the device.`;
38
- case 10200 /* FirmwareTooOld */:
39
- return `${originalMessage}. Please update your device firmware.`;
40
- case 10104 /* DeviceNotInitialized */:
41
- return `${originalMessage}. The device may need to be set up first.`;
42
- case 10003 /* OperationTimeout */:
43
- return `${originalMessage}. The operation timed out. Please try again.`;
44
- case 11e3 /* EvmBlindSigningRequired */:
45
- return "Ledger: Blind signing not enabled in Ethereum app.";
46
- case 11001 /* EvmClearSignPluginMissing */:
47
- return "Ledger: Required plugin not installed (install via Ledger Live).";
48
- case 11002 /* EvmDataTooLarge */:
49
- return "Ledger: Transaction data too large for device memory.";
50
- case 11003 /* EvmTxTypeNotSupported */:
51
- return "Ledger: Transaction type not supported by current Ethereum app.";
52
- case 10502 /* AppTooOld */:
53
- return "Ledger: App out of date (update via Ledger Live).";
54
- case 11100 /* SolanaBlindSigningRequired */:
55
- return "Blind signing disabled in the Solana app.";
56
- case 11200 /* TronCustomContractRequired */:
57
- return "Custom Contracts setting disabled in the Tron app.";
58
- case 11201 /* TronDataSigningRequired */:
59
- return "Transactions Data setting disabled in the Tron app.";
60
- case 11202 /* TronSignByHashRequired */:
61
- return "Sign by Hash setting disabled in the Tron app.";
62
- case 11300 /* BtcWalletPolicyHmacMismatch */:
63
- return "Wallet policy not registered or HMAC mismatch.";
64
- case 11301 /* BtcUnexpectedState */:
65
- return "Signing aborted due to unexpected device state.";
66
- default:
67
- return originalMessage;
68
- }
69
- }
70
-
71
-
72
-
73
- exports.enrichErrorMessage = enrichErrorMessage;
74
- //# sourceMappingURL=chunk-YLCHSNXO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-YLCHSNXO.js","../src/utils/errorMessages.ts"],"names":[],"mappings":"AAAA;ACMO,SAAS,kBAAA,CAAmB,IAAA,EAAyB,eAAA,EAAiC;AAC3F,EAAA,OAAA,CAAQ,IAAA,EAAM;AAAA,IACZ,KAAA,sBAAA;AACE,MAAA,OAAO,CAAA,EAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;AACT,IAAA;AACS,MAAA;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;ADJc;AACA;AACA;AACA","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-YLCHSNXO.js","sourcesContent":[null,"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.LedgerSecureChannelError:\n return `${originalMessage}. The secure connection to Ledger's servers was interrupted. Keep the device unlocked on the dashboard and try again.`;\n case HardwareErrorCode.LedgerFirmwareMetadataError:\n return `${originalMessage}. Ledger's app catalog returned an unusable response. Please try again later.`;\n case HardwareErrorCode.AppAlreadyInstalled:\n return `${originalMessage}. The app is already installed on the device.`;\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"]}