@onekeyfe/hwk-adapter-core 1.2.4-alpha.2 → 1.2.5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-U63HTLGJ.mjs → chunk-AYA6FQES.mjs} +44 -12
- package/dist/chunk-AYA6FQES.mjs.map +1 -0
- package/dist/chunk-DB4JOPZO.mjs +74 -0
- package/dist/chunk-DB4JOPZO.mjs.map +1 -0
- package/dist/{chunk-BAGEFFFY.js → chunk-H7BZ2C6J.js} +45 -13
- package/dist/chunk-H7BZ2C6J.js.map +1 -0
- package/dist/{chunk-YA4BWFTZ.mjs → chunk-KTRQZ5AJ.mjs} +155 -55
- package/dist/chunk-KTRQZ5AJ.mjs.map +1 -0
- package/dist/{chunk-SZZF623R.js → chunk-T5HIQPNG.js} +155 -55
- package/dist/chunk-T5HIQPNG.js.map +1 -0
- package/dist/chunk-YLCHSNXO.js +74 -0
- package/dist/chunk-YLCHSNXO.js.map +1 -0
- package/dist/errors-BgJ4kzRx.d.mts +276 -0
- package/dist/errors-BgJ4kzRx.d.ts +276 -0
- package/dist/errors.d.mts +1 -207
- package/dist/errors.d.ts +1 -207
- package/dist/errors.js +8 -2
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +9 -3
- package/dist/index.d.mts +578 -104
- package/dist/index.d.ts +578 -104
- package/dist/index.js +635 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +626 -76
- package/dist/index.mjs.map +1 -1
- package/dist/{ui-events-Cb7haAeE.d.mts → ui-events-DdttFKj9.d.mts} +37 -3
- package/dist/{ui-events-Cb7haAeE.d.ts → ui-events-DdttFKj9.d.ts} +37 -3
- package/dist/ui-events.d.mts +1 -1
- package/dist/ui-events.d.ts +1 -1
- package/dist/ui-events.js +3 -2
- package/dist/ui-events.js.map +1 -1
- package/dist/ui-events.mjs +2 -1
- package/package.json +2 -2
- package/dist/chunk-BAGEFFFY.js.map +0 -1
- package/dist/chunk-SZZF623R.js.map +0 -1
- package/dist/chunk-U63HTLGJ.mjs.map +0 -1
- package/dist/chunk-YA4BWFTZ.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-T5HIQPNG.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;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,sBA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;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;ADxPA;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-T5HIQPNG.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 // --- 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 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.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"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HWK HardwareErrorCode — independent namespace from the legacy
|
|
3
|
+
* `@onekeyfe/shared` HardwareErrorCode (which occupies 0-902).
|
|
4
|
+
*
|
|
5
|
+
* All HWK codes are 5-digit (>= 10000) so the two tables never collide
|
|
6
|
+
* even if either side grows. Each sub-category gets a 100-slot block.
|
|
7
|
+
*
|
|
8
|
+
* 10000-10099 Generic / cross-cutting primitives
|
|
9
|
+
* 10100-10199 Device state
|
|
10
|
+
* 10200-10299 Firmware
|
|
11
|
+
* 10300-10399 Transport + OS-level permission
|
|
12
|
+
* 10400-10499 PIN / Passphrase
|
|
13
|
+
* 10500-10599 App lifecycle (wrong app, not open, too old)
|
|
14
|
+
* 10600-10699 Payload / framing limits (adapter-level)
|
|
15
|
+
* 10700-10999 RESERVED, future adapter-level categories
|
|
16
|
+
*
|
|
17
|
+
* 11000-11099 EVM APDU (reactive mapping)
|
|
18
|
+
* 11100-11199 Solana APDU
|
|
19
|
+
* 11200-11299 Tron APDU
|
|
20
|
+
* 11300-11399 BTC APDU
|
|
21
|
+
* 11400-11999 RESERVED — future chain APDU blocks (100 per chain)
|
|
22
|
+
*
|
|
23
|
+
* 12000-99999 RESERVED — future major categories
|
|
24
|
+
*/
|
|
25
|
+
declare enum HardwareErrorCode {
|
|
26
|
+
UnknownError = 10000,
|
|
27
|
+
UserRejected = 10001,
|
|
28
|
+
InvalidParams = 10002,
|
|
29
|
+
OperationTimeout = 10003,
|
|
30
|
+
MethodNotSupported = 10004,
|
|
31
|
+
/** User dismissed in-app cancel UI. Distinct from UserRejected (on-device). */
|
|
32
|
+
UserAborted = 10005,
|
|
33
|
+
DeviceNotFound = 10100,
|
|
34
|
+
DeviceDisconnected = 10101,
|
|
35
|
+
DeviceBusy = 10102,
|
|
36
|
+
DeviceLocked = 10103,
|
|
37
|
+
DeviceNotInitialized = 10104,
|
|
38
|
+
DeviceInBootloader = 10105,
|
|
39
|
+
DeviceMismatch = 10106,
|
|
40
|
+
/** Chain app wedged (e.g. Ledger BTC 0x6901). User must exit app on device. */
|
|
41
|
+
DeviceAppStuck = 10107,
|
|
42
|
+
/** Vendor (Ledger / Trezor) doesn't support the chain at all. */
|
|
43
|
+
ChainNotSupported = 10108,
|
|
44
|
+
/** Current operation supports only one connected device. */
|
|
45
|
+
DeviceOneDeviceOnly = 10109,
|
|
46
|
+
/**
|
|
47
|
+
* The device rejected the requested derivation path (Trezor Failure_DataError
|
|
48
|
+
* "Forbidden key path") — the path is non-standard or its index is outside the
|
|
49
|
+
* range the device's safety checks allow. Distinct from ChainNotSupported
|
|
50
|
+
* (whole chain) and MethodNotSupported (the operation/method itself).
|
|
51
|
+
*/
|
|
52
|
+
DevicePathForbidden = 10110,
|
|
53
|
+
/** Busy with our own in-flight request (queue guard / firmware Failure_Busy), not another app — wait and retry, don't close other apps. */
|
|
54
|
+
DeviceBusyInternal = 10111,
|
|
55
|
+
/** The supplied runtime-only operation id is unknown to this adapter instance. */
|
|
56
|
+
OperationNotFound = 10112,
|
|
57
|
+
/** The supplied operation ended and can never be resumed. */
|
|
58
|
+
OperationEnded = 10113,
|
|
59
|
+
/**
|
|
60
|
+
* Discovery found devices but none is the expected wallet (wrong unit connected). DeviceMismatch
|
|
61
|
+
* is for reaching the expected device and finding a different identity on it.
|
|
62
|
+
*/
|
|
63
|
+
DeviceSearchMismatch = 10114,
|
|
64
|
+
FirmwareTooOld = 10200,
|
|
65
|
+
FirmwareUpdateRequired = 10201,
|
|
66
|
+
TransportError = 10300,
|
|
67
|
+
BridgeNotFound = 10301,
|
|
68
|
+
TransportNotAvailable = 10302,
|
|
69
|
+
/**
|
|
70
|
+
* OS-level permission (Bluetooth / USB / etc.) — denied, blocked,
|
|
71
|
+
* unavailable, or dismissed. Consumers surface a single "please grant
|
|
72
|
+
* permission" toast and let the user retry manually.
|
|
73
|
+
*/
|
|
74
|
+
DevicePermissionDenied = 10303,
|
|
75
|
+
/**
|
|
76
|
+
* BLE SMP pairing did not complete within the GATT bonding window.
|
|
77
|
+
* GATT connected but the device didn't acknowledge SMP — typically
|
|
78
|
+
* because the user didn't confirm the passkey on the device, or the
|
|
79
|
+
* device went out of range mid-pairing. Distinct from OperationTimeout
|
|
80
|
+
* (generic) and from DeviceLocked (Secure Element actually locked).
|
|
81
|
+
*/
|
|
82
|
+
BlePairingTimeout = 10304,
|
|
83
|
+
/** Remote network failure reaching a vendor's servers (HTTP/WS). Distinct from TransportError (local USB/BLE link). */
|
|
84
|
+
NetworkError = 10305,
|
|
85
|
+
/**
|
|
86
|
+
* Host-managed pairing handshake failed (Trezor THP). The device rejected the
|
|
87
|
+
* pairing exchange — e.g. CodeEntry: the user mistyped the code shown on the
|
|
88
|
+
* device, so the CPace tag didn't match ("Unexpected Code Entry Tag").
|
|
89
|
+
* Recoverable: the user re-pairs and re-enters the code. Distinct from
|
|
90
|
+
* BlePairingTimeout (BLE SMP bonding window) and UserRejected (on-device
|
|
91
|
+
* reject button).
|
|
92
|
+
*/
|
|
93
|
+
ThpPairingFailed = 10306,
|
|
94
|
+
/**
|
|
95
|
+
* The OS-level BLE bond is stale/invalid, so the device rejected link
|
|
96
|
+
* encryption: Android GATT_INSUF_AUTHENTICATION (status 5) or iOS "Peer
|
|
97
|
+
* removed pairing information". Happens after the device is wiped/re-flashed
|
|
98
|
+
* or unpaired elsewhere while the host still holds an old bond. The SDK cannot
|
|
99
|
+
* remove an OS bond — the user must forget the device in system Bluetooth
|
|
100
|
+
* settings and re-pair. Distinct from BlePairingTimeout (SMP window) and
|
|
101
|
+
* ThpPairingFailed (THP code mismatch).
|
|
102
|
+
*/
|
|
103
|
+
BleBondInvalid = 10307,
|
|
104
|
+
/**
|
|
105
|
+
* A stored THP pairing credential was rejected by the device during the
|
|
106
|
+
* handshake (device returned completion `state=0`), so the autoconnect session
|
|
107
|
+
* could not be established. The SDK discards the stale credential; recovery is
|
|
108
|
+
* a fresh pairing. Distinct from ThpPairingFailed (user mistyped the code
|
|
109
|
+
* during an *active* pairing) and BleBondInvalid (OS-level BLE bond).
|
|
110
|
+
*/
|
|
111
|
+
ThpPairingRequired = 10308,
|
|
112
|
+
/**
|
|
113
|
+
* Generic BLE connect failure where the OS dropped the specific reason. On
|
|
114
|
+
* macOS the noble native binding hardcodes "connection failed" (and a connect
|
|
115
|
+
* timeout) and discards the CoreBluetooth NSError, so the SDK cannot tell a
|
|
116
|
+
* stale bond from an out-of-range / unresponsive device. Surfaced as a
|
|
117
|
+
* generic "couldn't connect — check the device, re-pair if paired before".
|
|
118
|
+
* Distinct from BleBondInvalid (a *known* stale-bond signal, iOS/Android only)
|
|
119
|
+
* and BlePairingTimeout (the SMP bonding window).
|
|
120
|
+
*/
|
|
121
|
+
BleConnectFailed = 10309,
|
|
122
|
+
/**
|
|
123
|
+
* The user cancelled BLE pairing from the app while the connect was still
|
|
124
|
+
* waiting on the OS pairing window. Not a failure to report — the flow ends
|
|
125
|
+
* because they asked it to. Distinct from UserAborted (generic in-app cancel)
|
|
126
|
+
* so the pairing UI can close quietly instead of surfacing a connect error,
|
|
127
|
+
* and from BlePairingTimeout (the SMP window elapsed on its own).
|
|
128
|
+
*/
|
|
129
|
+
BlePairingCancelled = 10310,
|
|
130
|
+
/**
|
|
131
|
+
* Ledger manager-api WebSocket (app install/uninstall, genuine check) broke while relaying APDUs.
|
|
132
|
+
* The device link is fine, so retry; NetworkError never carried device traffic.
|
|
133
|
+
*/
|
|
134
|
+
LedgerSecureChannelError = 10311,
|
|
135
|
+
/**
|
|
136
|
+
* Vendor metadata service returned an unusable payload (Ledger firmware metadata, app catalog).
|
|
137
|
+
* The request succeeded, so callers must not treat it as a dropped link.
|
|
138
|
+
*/
|
|
139
|
+
LedgerFirmwareMetadataError = 10312,
|
|
140
|
+
PinInvalid = 10400,
|
|
141
|
+
PinCancelled = 10401,
|
|
142
|
+
PassphraseRejected = 10402,
|
|
143
|
+
/**
|
|
144
|
+
* The passphrase entered produced a different wallet (`passphraseState`) than
|
|
145
|
+
* the one the caller asked to operate on. Trezor-only: the host pins a wallet
|
|
146
|
+
* by its derived state and the SDK refuses to sign with a mismatched
|
|
147
|
+
* passphrase session. Surfaced by TrezorAdapter.getPassphraseState.
|
|
148
|
+
*/
|
|
149
|
+
PassphraseStateMismatch = 10403,
|
|
150
|
+
/**
|
|
151
|
+
* The two new-PIN entries did not match during set/change PIN. Only host-input
|
|
152
|
+
* models (Trezor Model One matrix) surface this; on-device-input models show
|
|
153
|
+
* the mismatch on the device and never return it.
|
|
154
|
+
*/
|
|
155
|
+
PinMismatch = 10404,
|
|
156
|
+
/** Standard wallet is unavailable while Trezor enforces on-device passphrase entry. */
|
|
157
|
+
PassphraseAlwaysOnDevice = 10405,
|
|
158
|
+
/** Chain app NOT INSTALLED on device. User must install via Ledger Live. */
|
|
159
|
+
AppNotInstalled = 10500,
|
|
160
|
+
WrongApp = 10501,
|
|
161
|
+
/** 0x911c Command code not supported — app predates current SDK. */
|
|
162
|
+
AppTooOld = 10502,
|
|
163
|
+
/** Not enough free storage for install/update; user must uninstall apps first. */
|
|
164
|
+
DeviceOutOfMemory = 10503,
|
|
165
|
+
/** Install refused, the app is already on the device; benign when the caller only needs it. */
|
|
166
|
+
AppAlreadyInstalled = 10504,
|
|
167
|
+
/**
|
|
168
|
+
* Payload exceeds a transport's framing cap (Keystone USB: ~12.5KB, 200 frames of 64 bytes).
|
|
169
|
+
* Retrying on the same transport fails the same way; switch channel or shrink the payload.
|
|
170
|
+
*/
|
|
171
|
+
PayloadTooLarge = 10600,
|
|
172
|
+
/** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the
|
|
173
|
+
* user has not enabled Blind signing on the device. */
|
|
174
|
+
EvmBlindSigningRequired = 11000,
|
|
175
|
+
/** 0x6984 Plugin not installed */
|
|
176
|
+
EvmClearSignPluginMissing = 11001,
|
|
177
|
+
/** 0x6a84 Insufficient memory (typical on Nano S with large calldata) */
|
|
178
|
+
EvmDataTooLarge = 11002,
|
|
179
|
+
/** 0x6501 TransactionType not supported (app too old for EIP-1559 / blob / 7702) */
|
|
180
|
+
EvmTxTypeNotSupported = 11003,
|
|
181
|
+
/** 0x6808 Blind signing disabled for this instruction. */
|
|
182
|
+
SolanaBlindSigningRequired = 11100,
|
|
183
|
+
/** 0x6a8d Custom Contracts setting disabled (blocks TRC-20 etc.). */
|
|
184
|
+
TronCustomContractRequired = 11200,
|
|
185
|
+
/** 0x6a8b Transactions Data setting disabled. */
|
|
186
|
+
TronDataSigningRequired = 11201,
|
|
187
|
+
/** 0x6a8c Sign by Hash setting disabled (hash-signing fallback). */
|
|
188
|
+
TronSignByHashRequired = 11202,
|
|
189
|
+
/** 0xb008 Wallet policy HMAC mismatch or not registered. */
|
|
190
|
+
BtcWalletPolicyHmacMismatch = 11300,
|
|
191
|
+
/** 0xb007 Aborted due to unexpected state (malformed PSBT / missing UTXO). */
|
|
192
|
+
BtcUnexpectedState = 11301
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Device-level failures the SDK cannot self-recover from — affect the entire
|
|
196
|
+
* batch (vs per-chain failures like AppNotInstalled / WrongApp which soft-
|
|
197
|
+
* skip in onboarding). Combined with `accounts.length === 0`, signals
|
|
198
|
+
* genuine orphan. Also reused as the batch-abort whitelist for HWK.
|
|
199
|
+
* Single source of truth.
|
|
200
|
+
*
|
|
201
|
+
* UserRejected (device-side reject) is included: pressing reject is an
|
|
202
|
+
* explicit "I don't consent" — continuing the batch to ask again on the
|
|
203
|
+
* next chain is harassment, not helpful.
|
|
204
|
+
*/
|
|
205
|
+
declare const ORPHAN_ELIGIBLE_ERROR_CODES: number[];
|
|
206
|
+
/**
|
|
207
|
+
* Where a failure came from; code ranges can't tell (UserRejected=10001 is the device,
|
|
208
|
+
* DevicePermissionDenied=10303 is the host).
|
|
209
|
+
* `device`: the firmware answered (rejection, locked, wrong PIN); surface verbatim, never
|
|
210
|
+
* auto-reconnect, switch channels, or drop a healthy session.
|
|
211
|
+
* `transport`: the pipe failed (cable pulled, bus reset); reconnecting is fair game.
|
|
212
|
+
* `host`: the environment refused (permission, picker, bad params); fix it, not the link.
|
|
213
|
+
* A mapper that can't tell leaves it unset so consumers fall back to code-based tables.
|
|
214
|
+
*/
|
|
215
|
+
type HwkErrorOrigin = 'device' | 'transport' | 'host';
|
|
216
|
+
/**
|
|
217
|
+
* Smallest resource to replace before retrying; never permission to auto-replay a signing command.
|
|
218
|
+
* `call`: nothing. `operation`: rebind from the target if its identity is persistent.
|
|
219
|
+
* `search-target`: rediscover and reselect. `transport`: repair or switch transport.
|
|
220
|
+
* `not-recoverable`: retrying cannot succeed. `unknown`: no safe claim.
|
|
221
|
+
*/
|
|
222
|
+
type HwkRecoveryScope = 'call' | 'operation' | 'search-target' | 'transport' | 'not-recoverable' | 'unknown';
|
|
223
|
+
interface HwkRecoveryHint {
|
|
224
|
+
scope: HwkRecoveryScope;
|
|
225
|
+
}
|
|
226
|
+
declare function isHwkRecoveryHint(value: unknown): value is HwkRecoveryHint;
|
|
227
|
+
/** Vendor-neutral fallback; adapters may stamp a narrower hint when session state is clear. */
|
|
228
|
+
declare function defaultRecoveryForCode(code: HardwareErrorCode): HwkRecoveryHint;
|
|
229
|
+
/**
|
|
230
|
+
* Default code-to-origin table; vendors override only where their mapping knows better.
|
|
231
|
+
* Context-dependent codes (UnknownError, OperationTimeout, DeviceBusy) return undefined.
|
|
232
|
+
*/
|
|
233
|
+
declare function defaultOriginForCode(code: HardwareErrorCode): HwkErrorOrigin | undefined;
|
|
234
|
+
interface IHwkErrorPayload {
|
|
235
|
+
code: HardwareErrorCode;
|
|
236
|
+
message: string;
|
|
237
|
+
origin?: HwkErrorOrigin;
|
|
238
|
+
recovery?: HwkRecoveryHint;
|
|
239
|
+
appName?: string;
|
|
240
|
+
_tag?: string;
|
|
241
|
+
params?: Record<string, unknown>;
|
|
242
|
+
}
|
|
243
|
+
interface IOperationMayHaveCompletedParams extends Record<string, unknown> {
|
|
244
|
+
operationMayHaveCompleted: true;
|
|
245
|
+
method: string;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Marks an unsafe request whose response was lost after dispatch; the transport error is not proof
|
|
249
|
+
* that the device rejected or skipped it.
|
|
250
|
+
*/
|
|
251
|
+
declare function operationMayHaveCompletedParams(method: string, params?: Record<string, unknown>): IOperationMayHaveCompletedParams;
|
|
252
|
+
type HwkError = Error & {
|
|
253
|
+
code: HardwareErrorCode;
|
|
254
|
+
/** See {@link HwkErrorOrigin}. Survives serializeConnectorError/rehydrate via `params`. */
|
|
255
|
+
origin?: HwkErrorOrigin;
|
|
256
|
+
recovery?: HwkRecoveryHint;
|
|
257
|
+
appName?: string;
|
|
258
|
+
_tag?: string;
|
|
259
|
+
params?: Record<string, unknown>;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* Canonical throwable for HWK adapters. Plain Error + canonical extra fields,
|
|
263
|
+
* shape-compatible with `rehydrateConnectorError` so locally-thrown and
|
|
264
|
+
* cross-boundary errors are indistinguishable to downstream classifiers
|
|
265
|
+
* (`err.code` / `err._tag` / `err.appName`). Do NOT mutate caught errors
|
|
266
|
+
* with `Object.assign` — construct a fresh one via this factory.
|
|
267
|
+
*/
|
|
268
|
+
declare function createHwkError(payload: IHwkErrorPayload): HwkError;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Enrich a hardware error message with actionable recovery hints.
|
|
272
|
+
* Shared across adapters (Ledger, Trezor, etc.).
|
|
273
|
+
*/
|
|
274
|
+
declare function enrichErrorMessage(code: HardwareErrorCode, originalMessage: string): string;
|
|
275
|
+
|
|
276
|
+
export { HardwareErrorCode as H, type IHwkErrorPayload as I, ORPHAN_ELIGIBLE_ERROR_CODES as O, type HwkErrorOrigin as a, type HwkRecoveryHint as b, type HwkError as c, type HwkRecoveryScope as d, type IOperationMayHaveCompletedParams as e, createHwkError as f, defaultOriginForCode as g, defaultRecoveryForCode as h, enrichErrorMessage as i, isHwkRecoveryHint as j, operationMayHaveCompletedParams as o };
|