@onekeyfe/hwk-adapter-core 1.2.8-alpha.114 → 1.2.8-alpha.115

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.
@@ -38,7 +38,6 @@ declare const UI_REQUEST: {
38
38
  readonly REQUEST_DEVICE_CONNECT: "ui-request-device-connect";
39
39
  readonly REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm";
40
40
  readonly REQUEST_INSTALL_APP: "ui-request-install-app";
41
- readonly REQUEST_QR_FALLBACK_CONFIRM: "ui-request-qr-fallback-confirm";
42
41
  readonly REQUEST_PREEMPTION: "ui-request-preemption";
43
42
  readonly REQUEST_TREZOR_THP_PAIRING: "ui-request-trezor-thp-pairing";
44
43
  readonly CLOSE_UI_WINDOW: "ui-close";
@@ -56,7 +55,6 @@ declare const UI_RESPONSE: {
56
55
  readonly RECEIVE_DEVICE_PERMISSION: "receive-device-permission";
57
56
  readonly RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm";
58
57
  readonly RECEIVE_INSTALL_APP: "receive-install-app";
59
- readonly RECEIVE_QR_FALLBACK_CONFIRM: "receive-qr-fallback-confirm";
60
58
  readonly RECEIVE_PREEMPTION: "receive-preemption";
61
59
  readonly RECEIVE_TREZOR_THP_PAIRING: "receive-trezor-thp-pairing";
62
60
  readonly CANCEL: "cancel";
@@ -142,11 +140,6 @@ type UiResponseEvent = {
142
140
  payload: {
143
141
  confirmed: boolean;
144
142
  };
145
- } | {
146
- type: typeof UI_RESPONSE.RECEIVE_QR_FALLBACK_CONFIRM;
147
- payload: {
148
- confirmed: boolean;
149
- };
150
143
  } | {
151
144
  type: typeof UI_RESPONSE.RECEIVE_PREEMPTION;
152
145
  payload: {
@@ -38,7 +38,6 @@ declare const UI_REQUEST: {
38
38
  readonly REQUEST_DEVICE_CONNECT: "ui-request-device-connect";
39
39
  readonly REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm";
40
40
  readonly REQUEST_INSTALL_APP: "ui-request-install-app";
41
- readonly REQUEST_QR_FALLBACK_CONFIRM: "ui-request-qr-fallback-confirm";
42
41
  readonly REQUEST_PREEMPTION: "ui-request-preemption";
43
42
  readonly REQUEST_TREZOR_THP_PAIRING: "ui-request-trezor-thp-pairing";
44
43
  readonly CLOSE_UI_WINDOW: "ui-close";
@@ -56,7 +55,6 @@ declare const UI_RESPONSE: {
56
55
  readonly RECEIVE_DEVICE_PERMISSION: "receive-device-permission";
57
56
  readonly RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm";
58
57
  readonly RECEIVE_INSTALL_APP: "receive-install-app";
59
- readonly RECEIVE_QR_FALLBACK_CONFIRM: "receive-qr-fallback-confirm";
60
58
  readonly RECEIVE_PREEMPTION: "receive-preemption";
61
59
  readonly RECEIVE_TREZOR_THP_PAIRING: "receive-trezor-thp-pairing";
62
60
  readonly CANCEL: "cancel";
@@ -142,11 +140,6 @@ type UiResponseEvent = {
142
140
  payload: {
143
141
  confirmed: boolean;
144
142
  };
145
- } | {
146
- type: typeof UI_RESPONSE.RECEIVE_QR_FALLBACK_CONFIRM;
147
- payload: {
148
- confirmed: boolean;
149
- };
150
143
  } | {
151
144
  type: typeof UI_RESPONSE.RECEIVE_PREEMPTION;
152
145
  payload: {
@@ -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-DLIHLLRw.mjs';
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-C61GTilK.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-DLIHLLRw.js';
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-C61GTilK.js';
package/dist/ui-events.js CHANGED
@@ -7,8 +7,8 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkVVAN3W2Cjs = require('./chunk-VVAN3W2C.js');
11
- require('./chunk-UFNTICCX.js');
10
+ var _chunkAYS7A7Z3js = require('./chunk-AYS7A7Z3.js');
11
+ require('./chunk-T5HIQPNG.js');
12
12
 
13
13
 
14
14
 
@@ -18,5 +18,5 @@ require('./chunk-UFNTICCX.js');
18
18
 
19
19
 
20
20
 
21
- exports.UI_EVENT = _chunkVVAN3W2Cjs.UI_EVENT; exports.UI_REQUEST = _chunkVVAN3W2Cjs.UI_REQUEST; exports.UI_REQUEST_CANCELLED_TAG = _chunkVVAN3W2Cjs.UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = _chunkVVAN3W2Cjs.UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = _chunkVVAN3W2Cjs.UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = _chunkVVAN3W2Cjs.UI_REQUEST_TIMEOUT_TAG; exports.UI_RESPONSE = _chunkVVAN3W2Cjs.UI_RESPONSE; exports.UiRequestRegistry = _chunkVVAN3W2Cjs.UiRequestRegistry;
21
+ exports.UI_EVENT = _chunkAYS7A7Z3js.UI_EVENT; exports.UI_REQUEST = _chunkAYS7A7Z3js.UI_REQUEST; exports.UI_REQUEST_CANCELLED_TAG = _chunkAYS7A7Z3js.UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = _chunkAYS7A7Z3js.UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = _chunkAYS7A7Z3js.UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = _chunkAYS7A7Z3js.UI_REQUEST_TIMEOUT_TAG; exports.UI_RESPONSE = _chunkAYS7A7Z3js.UI_RESPONSE; exports.UiRequestRegistry = _chunkAYS7A7Z3js.UiRequestRegistry;
22
22
  //# sourceMappingURL=ui-events.js.map
@@ -7,8 +7,8 @@ import {
7
7
  UI_REQUEST_TIMEOUT_TAG,
8
8
  UI_RESPONSE,
9
9
  UiRequestRegistry
10
- } from "./chunk-VWVDPWNI.mjs";
11
- import "./chunk-V2OHL2JS.mjs";
10
+ } from "./chunk-G5EU7VRW.mjs";
11
+ import "./chunk-KTRQZ5AJ.mjs";
12
12
  export {
13
13
  UI_EVENT,
14
14
  UI_REQUEST,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hwk-adapter-core",
3
- "version": "1.2.8-alpha.114",
3
+ "version": "1.2.8-alpha.115",
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": "272fd40094bac0425bd824b82b5b74c54d220bd7"
73
+ "gitHead": "4f30138a51d564cd664fa9886f30229bebe469a5"
74
74
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-UFNTICCX.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,CAAAA,kBAAAA,CAAA,gBAAA,EAAA,EAAiB,KAAA,EAAA,EAAjB,gBAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,oBAAA,EAAA,EAAqB,KAAA,EAAA,EAArB,oBAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,YAAA,EAAA,EAAa,KAAA,EAAA,EAAb,YAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,cAAA,EAAA,EAAe,KAAA,EAAA,EAAf,cAAA;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K,6BAAA;AAAA,IACL,KAAK,+BAAA;AACH,MAAA,OAAO,MAAA;AAAA,IACT,OAAA;AACE,MAAA,OAAO,KAAA,CAAA;AAAA,EACX;AACF;AAqBO,SAAS,+BAAA,CACd,MAAA,EACA,MAAA,EACkC;AAClC,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,yBAAA,EAA2B,IAAA;AAAA,IAC3B;AAAA,EACF,CAAA;AACF;AAmBO,SAAS,cAAA,CAAe,OAAA,EAAqC;AAClE,EAAA,MAAM,SAAA,mBAAW,OAAA,CAAQ,QAAA,UAAY,sBAAA,CAAuB,OAAA,CAAQ,IAAI,GAAA;AACxE,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG;AAAA,IAC/C,IAAA,EAAM,OAAA,CAAQ,IAAA;AAAA,IACd,GAAI,OAAA,CAAQ,OAAA,IAAW,KAAA,EAAA,GAAa,EAAE,MAAA,EAAQ,OAAA,CAAQ,OAAO,CAAA;AAAA,IAC7D,QAAA;AAAA,IACA,GAAI,OAAA,CAAQ,KAAA,IAAS,KAAA,EAAA,GAAa,EAAE,IAAA,EAAM,OAAA,CAAQ,KAAK,CAAA;AAAA,IACvD,GAAI,OAAA,CAAQ,QAAA,IAAY,KAAA,EAAA,GAAa,EAAE,OAAA,EAAS,OAAA,CAAQ,QAAQ,CAAA;AAAA,IAChE,GAAI,OAAA,CAAQ,OAAA,IAAW,KAAA,EAAA,GAAa,EAAE,MAAA,EAAQ,OAAA,CAAQ,OAAO;AAAA,EAC/D,CAAC,CAAA;AACH;AD5PA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,kYAAC","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-UFNTICCX.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 is the expected wallet (wrong unit connected). DeviceMismatch\n * is for reaching the expected device and finding a different identity on it.\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 * Ledger manager-api WebSocket (app install/uninstall, genuine check) broke while relaying APDUs.\n * The device link is fine, so retry; NetworkError never carried device traffic.\n */\n LedgerSecureChannelError = 10311,\n /**\n * Vendor metadata service returned an unusable payload (Ledger firmware metadata, app catalog).\n * The request succeeded, so callers 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, the app is already on the device; benign when the caller only needs it. */\n AppAlreadyInstalled = 10504,\n\n // --- 10600s Payload / framing limits ---\n /**\n * Payload exceeds a transport's framing cap (Keystone USB: ~12.5KB, 200 frames of 64 bytes).\n * Retrying on the same transport fails the same way; switch channel or shrink the payload.\n */\n PayloadTooLarge = 10600,\n /**\n * One QR request would ask the device for more keys than it accepts (Keystone: 24 account\n * paths). Nothing is sent; USB asks per key and is not limited this way.\n */\n QrRequestTooLarge = 10601,\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; code ranges can't tell (UserRejected=10001 is the device,\n * DevicePermissionDenied=10303 is the host).\n * `device`: the firmware answered (rejection, locked, wrong PIN); surface verbatim, never\n * auto-reconnect, switch channels, or drop a healthy session.\n * `transport`: the pipe failed (cable pulled, bus reset); reconnecting is fair game.\n * `host`: the environment refused (permission, picker, bad params); fix it, not the link.\n * A mapper that can't tell leaves it unset so consumers fall back to code-based tables.\n */\nexport type HwkErrorOrigin = 'device' | 'transport' | 'host';\n\n/**\n * Smallest resource to replace before retrying; never permission to auto-replay a signing command.\n * `call`: nothing. `operation`: rebind from the target if its identity is persistent.\n * `search-target`: rediscover and reselect. `transport`: repair or switch transport.\n * `not-recoverable`: retrying cannot succeed. `unknown`: no safe 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/** Vendor-neutral fallback; adapters may stamp a narrower hint when session state is clear. */\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 case HardwareErrorCode.QrRequestTooLarge:\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 * Default code-to-origin table; vendors override only where their mapping knows better.\n * Context-dependent codes (UnknownError, OperationTimeout, DeviceBusy) return undefined.\n */\nexport function defaultOriginForCode(code: HardwareErrorCode): HwkErrorOrigin | undefined {\n // Chain APDU codes (11000+) are always the device's chain app refusing or qualifying a request.\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.QrRequestTooLarge:\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 request whose response was lost after dispatch; the transport error is not proof\n * that the device rejected or skipped it.\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 via `params`. */\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 +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 is the expected wallet (wrong unit connected). DeviceMismatch\n * is for reaching the expected device and finding a different identity on it.\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 * Ledger manager-api WebSocket (app install/uninstall, genuine check) broke while relaying APDUs.\n * The device link is fine, so retry; NetworkError never carried device traffic.\n */\n LedgerSecureChannelError = 10311,\n /**\n * Vendor metadata service returned an unusable payload (Ledger firmware metadata, app catalog).\n * The request succeeded, so callers 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, the app is already on the device; benign when the caller only needs it. */\n AppAlreadyInstalled = 10504,\n\n // --- 10600s Payload / framing limits ---\n /**\n * Payload exceeds a transport's framing cap (Keystone USB: ~12.5KB, 200 frames of 64 bytes).\n * Retrying on the same transport fails the same way; switch channel or shrink the payload.\n */\n PayloadTooLarge = 10600,\n /**\n * One QR request would ask the device for more keys than it accepts (Keystone: 24 account\n * paths). Nothing is sent; USB asks per key and is not limited this way.\n */\n QrRequestTooLarge = 10601,\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; code ranges can't tell (UserRejected=10001 is the device,\n * DevicePermissionDenied=10303 is the host).\n * `device`: the firmware answered (rejection, locked, wrong PIN); surface verbatim, never\n * auto-reconnect, switch channels, or drop a healthy session.\n * `transport`: the pipe failed (cable pulled, bus reset); reconnecting is fair game.\n * `host`: the environment refused (permission, picker, bad params); fix it, not the link.\n * A mapper that can't tell leaves it unset so consumers fall back to code-based tables.\n */\nexport type HwkErrorOrigin = 'device' | 'transport' | 'host';\n\n/**\n * Smallest resource to replace before retrying; never permission to auto-replay a signing command.\n * `call`: nothing. `operation`: rebind from the target if its identity is persistent.\n * `search-target`: rediscover and reselect. `transport`: repair or switch transport.\n * `not-recoverable`: retrying cannot succeed. `unknown`: no safe 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/** Vendor-neutral fallback; adapters may stamp a narrower hint when session state is clear. */\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 case HardwareErrorCode.QrRequestTooLarge:\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 * Default code-to-origin table; vendors override only where their mapping knows better.\n * Context-dependent codes (UnknownError, OperationTimeout, DeviceBusy) return undefined.\n */\nexport function defaultOriginForCode(code: HardwareErrorCode): HwkErrorOrigin | undefined {\n // Chain APDU codes (11000+) are always the device's chain app refusing or qualifying a request.\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.QrRequestTooLarge:\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 request whose response was lost after dispatch; the transport error is not proof\n * that the device rejected or skipped it.\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 via `params`. */\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,iBAAc,SAAd;AAGA,EAAAA,sCAAA,oBAAiB,SAAjB;AACA,EAAAA,sCAAA,wBAAqB,SAArB;AACA,EAAAA,sCAAA,gBAAa,SAAb;AACA,EAAAA,sCAAA,kBAAe,SAAf;AACA,EAAAA,sCAAA,0BAAuB,SAAvB;AACA,EAAAA,sCAAA,wBAAqB,SAArB;AACA,EAAAA,sCAAA,oBAAiB,SAAjB;AAEA,EAAAA,sCAAA,oBAAiB,SAAjB;AAEA,EAAAA,sCAAA,uBAAoB,SAApB;AAEA,EAAAA,sCAAA,yBAAsB,SAAtB;AAOA,EAAAA,sCAAA,yBAAsB,SAAtB;AAEA,EAAAA,sCAAA,wBAAqB,SAArB;AAEA,EAAAA,sCAAA,uBAAoB,SAApB;AAEA,EAAAA,sCAAA,oBAAiB,SAAjB;AAKA,EAAAA,sCAAA,0BAAuB,SAAvB;AAGA,EAAAA,sCAAA,oBAAiB,SAAjB;AACA,EAAAA,sCAAA,4BAAyB,SAAzB;AAGA,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KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAqBO,SAAS,gCACd,QACA,QACkC;AAClC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,2BAA2B;AAAA,IAC3B;AAAA,EACF;AACF;AAmBO,SAAS,eAAe,SAAqC;AAClE,QAAM,WAAW,QAAQ,YAAY,uBAAuB,QAAQ,IAAI;AACxE,SAAO,OAAO,OAAO,IAAI,MAAM,QAAQ,OAAO,GAAG;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-VVAN3W2C.js","../src/events/ui-request.ts","../src/utils/UiRequestRegistry.ts"],"names":[],"mappings":"AAAA;AACE;AACF,sDAA4B;AAC5B;AACA;ACFO,IAAM,SA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/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-VVAN3W2C.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 // The request is over the USB transport's size limit; ask whether to show it as a QR instead.\n REQUEST_QR_FALLBACK_CONFIRM: 'ui-request-qr-fallback-confirm',\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_QR_FALLBACK_CONFIRM: 'receive-qr-fallback-confirm',\n RECEIVE_PREEMPTION: 'receive-preemption',\n RECEIVE_TREZOR_THP_PAIRING: 'receive-trezor-thp-pairing',\n CANCEL: 'cancel',\n} as const;\n\n/**\n * The operation a UI request was opened under, so a cancel for one operation spares another's\n * prompts. Absent outside any operation (cold start, teardown).\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 * `mismatch`: the host's own records do not match the selected device.\n * `skipped`: the host had nothing to bind, a host contract problem rather than a user action.\n *\n * Either way the binding is not saved and `DEVICE_BINDING_STATUS` reports `failed`. A business\n * call continues; an explicit `bindBleDevice` fails because saving was its whole purpose.\n *\n * The SDK has checked the device's wallet before asking only when the request carries `identity`,\n * i.e. the call named an expected wallet (a `deviceId`); Ledger asks without one for a call that\n * names no wallet. A decline does not retire the endpoint: its session, any operation bound to it,\n * and the adapter's in-memory reconnect target for it stay in place, and later wallet-checked calls\n * still verify the wallet on it. A host that must not use the endpoint again discards the result,\n * releases the operation, and has the user select a device again.\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 /**\n * `requestId` must echo the `REQUEST_SELECT_DEVICE` request's id. It stays optional in the\n * type for compatibility, but an answer without it (or with another id) is ignored and the\n * selection keeps waiting until its timeout.\n */\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_QR_FALLBACK_CONFIRM;\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 { HardwareErrorCode, createHwkError } 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_QR_FALLBACK_CONFIRM]: UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM,\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 clearTimeout(entry.timer);\n this.pending.delete(requestType);\n if (requestType === UI_REQUEST.REQUEST_SELECT_DEVICE && response?.cancelled === true) {\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 entry.resolve(payload);\n }\n\n /**\n * Each argument narrows the cancel: none rejects every waiter (teardown); an `operationId` alone\n * rejects only that operation's prompts and leaves another 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 +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 // The request is over the USB transport's size limit; ask whether to show it as a QR instead.\n REQUEST_QR_FALLBACK_CONFIRM: 'ui-request-qr-fallback-confirm',\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_QR_FALLBACK_CONFIRM: 'receive-qr-fallback-confirm',\n RECEIVE_PREEMPTION: 'receive-preemption',\n RECEIVE_TREZOR_THP_PAIRING: 'receive-trezor-thp-pairing',\n CANCEL: 'cancel',\n} as const;\n\n/**\n * The operation a UI request was opened under, so a cancel for one operation spares another's\n * prompts. Absent outside any operation (cold start, teardown).\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 * `mismatch`: the host's own records do not match the selected device.\n * `skipped`: the host had nothing to bind, a host contract problem rather than a user action.\n *\n * Either way the binding is not saved and `DEVICE_BINDING_STATUS` reports `failed`. A business\n * call continues; an explicit `bindBleDevice` fails because saving was its whole purpose.\n *\n * The SDK has checked the device's wallet before asking only when the request carries `identity`,\n * i.e. the call named an expected wallet (a `deviceId`); Ledger asks without one for a call that\n * names no wallet. A decline does not retire the endpoint: its session, any operation bound to it,\n * and the adapter's in-memory reconnect target for it stay in place, and later wallet-checked calls\n * still verify the wallet on it. A host that must not use the endpoint again discards the result,\n * releases the operation, and has the user select a device again.\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 /**\n * `requestId` must echo the `REQUEST_SELECT_DEVICE` request's id. It stays optional in the\n * type for compatibility, but an answer without it (or with another id) is ignored and the\n * selection keeps waiting until its timeout.\n */\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_QR_FALLBACK_CONFIRM;\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 { HardwareErrorCode, createHwkError } 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_QR_FALLBACK_CONFIRM]: UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM,\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 clearTimeout(entry.timer);\n this.pending.delete(requestType);\n if (requestType === UI_REQUEST.REQUEST_SELECT_DEVICE && response?.cancelled === true) {\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 entry.resolve(payload);\n }\n\n /**\n * Each argument narrows the cancel: none rejects every waiter (teardown); an `operationId` alone\n * rejects only that operation's prompts and leaves another 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;AAAA,EAErB,6BAA6B;AAAA,EAC7B,oBAAoB;AAAA,EACpB,4BAA4B;AAAA,EAC5B,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,cAAc;AAChB;AAEO,IAAM,cAA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