@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.
Files changed (37) hide show
  1. package/dist/{chunk-U63HTLGJ.mjs → chunk-AYA6FQES.mjs} +44 -12
  2. package/dist/chunk-AYA6FQES.mjs.map +1 -0
  3. package/dist/chunk-DB4JOPZO.mjs +74 -0
  4. package/dist/chunk-DB4JOPZO.mjs.map +1 -0
  5. package/dist/{chunk-BAGEFFFY.js → chunk-H7BZ2C6J.js} +45 -13
  6. package/dist/chunk-H7BZ2C6J.js.map +1 -0
  7. package/dist/{chunk-YA4BWFTZ.mjs → chunk-KTRQZ5AJ.mjs} +155 -55
  8. package/dist/chunk-KTRQZ5AJ.mjs.map +1 -0
  9. package/dist/{chunk-SZZF623R.js → chunk-T5HIQPNG.js} +155 -55
  10. package/dist/chunk-T5HIQPNG.js.map +1 -0
  11. package/dist/chunk-YLCHSNXO.js +74 -0
  12. package/dist/chunk-YLCHSNXO.js.map +1 -0
  13. package/dist/errors-BgJ4kzRx.d.mts +276 -0
  14. package/dist/errors-BgJ4kzRx.d.ts +276 -0
  15. package/dist/errors.d.mts +1 -207
  16. package/dist/errors.d.ts +1 -207
  17. package/dist/errors.js +8 -2
  18. package/dist/errors.js.map +1 -1
  19. package/dist/errors.mjs +9 -3
  20. package/dist/index.d.mts +578 -104
  21. package/dist/index.d.ts +578 -104
  22. package/dist/index.js +635 -85
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +626 -76
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/{ui-events-Cb7haAeE.d.mts → ui-events-DdttFKj9.d.mts} +37 -3
  27. package/dist/{ui-events-Cb7haAeE.d.ts → ui-events-DdttFKj9.d.ts} +37 -3
  28. package/dist/ui-events.d.mts +1 -1
  29. package/dist/ui-events.d.ts +1 -1
  30. package/dist/ui-events.js +3 -2
  31. package/dist/ui-events.js.map +1 -1
  32. package/dist/ui-events.mjs +2 -1
  33. package/package.json +2 -2
  34. package/dist/chunk-BAGEFFFY.js.map +0 -1
  35. package/dist/chunk-SZZF623R.js.map +0 -1
  36. package/dist/chunk-U63HTLGJ.mjs.map +0 -1
  37. package/dist/chunk-YA4BWFTZ.mjs.map +0 -1
@@ -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 };
package/dist/errors.d.mts CHANGED
@@ -1,207 +1 @@
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-10999 RESERVED — future adapter-level categories
15
- *
16
- * 11000-11099 EVM APDU (reactive mapping)
17
- * 11100-11199 Solana APDU
18
- * 11200-11299 Tron APDU
19
- * 11300-11399 BTC APDU
20
- * 11400-11999 RESERVED — future chain APDU blocks (100 per chain)
21
- *
22
- * 12000-99999 RESERVED — future major categories
23
- */
24
- declare enum HardwareErrorCode {
25
- UnknownError = 10000,
26
- UserRejected = 10001,
27
- InvalidParams = 10002,
28
- OperationTimeout = 10003,
29
- MethodNotSupported = 10004,
30
- /** User dismissed in-app cancel UI. Distinct from UserRejected (on-device). */
31
- UserAborted = 10005,
32
- DeviceNotFound = 10100,
33
- DeviceDisconnected = 10101,
34
- DeviceBusy = 10102,
35
- DeviceLocked = 10103,
36
- DeviceNotInitialized = 10104,
37
- DeviceInBootloader = 10105,
38
- DeviceMismatch = 10106,
39
- /** Chain app wedged (e.g. Ledger BTC 0x6901). User must exit app on device. */
40
- DeviceAppStuck = 10107,
41
- /** Vendor (Ledger / Trezor) doesn't support the chain at all. */
42
- ChainNotSupported = 10108,
43
- /** Current operation supports only one connected device. */
44
- DeviceOneDeviceOnly = 10109,
45
- /**
46
- * The device rejected the requested derivation path (Trezor Failure_DataError
47
- * "Forbidden key path") — the path is non-standard or its index is outside the
48
- * range the device's safety checks allow. Distinct from ChainNotSupported
49
- * (whole chain) and MethodNotSupported (the operation/method itself).
50
- */
51
- DevicePathForbidden = 10110,
52
- /** Busy with our own in-flight request (queue guard / firmware Failure_Busy), not another app — wait and retry, don't close other apps. */
53
- DeviceBusyInternal = 10111,
54
- FirmwareTooOld = 10200,
55
- FirmwareUpdateRequired = 10201,
56
- TransportError = 10300,
57
- BridgeNotFound = 10301,
58
- TransportNotAvailable = 10302,
59
- /**
60
- * OS-level permission (Bluetooth / USB / etc.) — denied, blocked,
61
- * unavailable, or dismissed. Consumers surface a single "please grant
62
- * permission" toast and let the user retry manually.
63
- */
64
- DevicePermissionDenied = 10303,
65
- /**
66
- * BLE SMP pairing did not complete within the GATT bonding window.
67
- * GATT connected but the device didn't acknowledge SMP — typically
68
- * because the user didn't confirm the passkey on the device, or the
69
- * device went out of range mid-pairing. Distinct from OperationTimeout
70
- * (generic) and from DeviceLocked (Secure Element actually locked).
71
- */
72
- BlePairingTimeout = 10304,
73
- /** Remote network failure reaching a vendor's servers (HTTP/WS). Distinct from TransportError (local USB/BLE link). */
74
- NetworkError = 10305,
75
- /**
76
- * Host-managed pairing handshake failed (Trezor THP). The device rejected the
77
- * pairing exchange — e.g. CodeEntry: the user mistyped the code shown on the
78
- * device, so the CPace tag didn't match ("Unexpected Code Entry Tag").
79
- * Recoverable: the user re-pairs and re-enters the code. Distinct from
80
- * BlePairingTimeout (BLE SMP bonding window) and UserRejected (on-device
81
- * reject button).
82
- */
83
- ThpPairingFailed = 10306,
84
- /**
85
- * The OS-level BLE bond is stale/invalid, so the device rejected link
86
- * encryption: Android GATT_INSUF_AUTHENTICATION (status 5) or iOS "Peer
87
- * removed pairing information". Happens after the device is wiped/re-flashed
88
- * or unpaired elsewhere while the host still holds an old bond. The SDK cannot
89
- * remove an OS bond — the user must forget the device in system Bluetooth
90
- * settings and re-pair. Distinct from BlePairingTimeout (SMP window) and
91
- * ThpPairingFailed (THP code mismatch).
92
- */
93
- BleBondInvalid = 10307,
94
- /**
95
- * A stored THP pairing credential was rejected by the device during the
96
- * handshake (device returned completion `state=0`), so the autoconnect session
97
- * could not be established. The SDK discards the stale credential; recovery is
98
- * a fresh pairing. Distinct from ThpPairingFailed (user mistyped the code
99
- * during an *active* pairing) and BleBondInvalid (OS-level BLE bond).
100
- */
101
- ThpPairingRequired = 10308,
102
- /**
103
- * Generic BLE connect failure where the OS dropped the specific reason. On
104
- * macOS the noble native binding hardcodes "connection failed" (and a connect
105
- * timeout) and discards the CoreBluetooth NSError, so the SDK cannot tell a
106
- * stale bond from an out-of-range / unresponsive device. Surfaced as a
107
- * generic "couldn't connect — check the device, re-pair if paired before".
108
- * Distinct from BleBondInvalid (a *known* stale-bond signal, iOS/Android only)
109
- * and BlePairingTimeout (the SMP bonding window).
110
- */
111
- BleConnectFailed = 10309,
112
- /**
113
- * The user cancelled BLE pairing from the app while the connect was still
114
- * waiting on the OS pairing window. Not a failure to report — the flow ends
115
- * because they asked it to. Distinct from UserAborted (generic in-app cancel)
116
- * so the pairing UI can close quietly instead of surfacing a connect error,
117
- * and from BlePairingTimeout (the SMP window elapsed on its own).
118
- */
119
- BlePairingCancelled = 10310,
120
- PinInvalid = 10400,
121
- PinCancelled = 10401,
122
- PassphraseRejected = 10402,
123
- /**
124
- * The passphrase entered produced a different wallet (`passphraseState`) than
125
- * the one the caller asked to operate on. Trezor-only: the host pins a wallet
126
- * by its derived state and the SDK refuses to sign with a mismatched
127
- * passphrase session. Surfaced by TrezorAdapter.getPassphraseState.
128
- */
129
- PassphraseStateMismatch = 10403,
130
- /**
131
- * The two new-PIN entries did not match during set/change PIN. Only host-input
132
- * models (Trezor Model One matrix) surface this; on-device-input models show
133
- * the mismatch on the device and never return it.
134
- */
135
- PinMismatch = 10404,
136
- /** Standard wallet is unavailable while Trezor enforces on-device passphrase entry. */
137
- PassphraseAlwaysOnDevice = 10405,
138
- /** Chain app NOT INSTALLED on device. User must install via Ledger Live. */
139
- AppNotInstalled = 10500,
140
- WrongApp = 10501,
141
- /** 0x911c Command code not supported — app predates current SDK. */
142
- AppTooOld = 10502,
143
- /** Not enough free storage for install/update; user must uninstall apps first. */
144
- DeviceOutOfMemory = 10503,
145
- /** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the
146
- * user has not enabled Blind signing on the device. */
147
- EvmBlindSigningRequired = 11000,
148
- /** 0x6984 Plugin not installed */
149
- EvmClearSignPluginMissing = 11001,
150
- /** 0x6a84 Insufficient memory (typical on Nano S with large calldata) */
151
- EvmDataTooLarge = 11002,
152
- /** 0x6501 TransactionType not supported (app too old for EIP-1559 / blob / 7702) */
153
- EvmTxTypeNotSupported = 11003,
154
- /** 0x6808 Blind signing disabled for this instruction. */
155
- SolanaBlindSigningRequired = 11100,
156
- /** 0x6a8d Custom Contracts setting disabled (blocks TRC-20 etc.). */
157
- TronCustomContractRequired = 11200,
158
- /** 0x6a8b Transactions Data setting disabled. */
159
- TronDataSigningRequired = 11201,
160
- /** 0x6a8c Sign by Hash setting disabled (hash-signing fallback). */
161
- TronSignByHashRequired = 11202,
162
- /** 0xb008 Wallet policy HMAC mismatch or not registered. */
163
- BtcWalletPolicyHmacMismatch = 11300,
164
- /** 0xb007 Aborted due to unexpected state (malformed PSBT / missing UTXO). */
165
- BtcUnexpectedState = 11301
166
- }
167
- /**
168
- * Device-level failures the SDK cannot self-recover from — affect the entire
169
- * batch (vs per-chain failures like AppNotInstalled / WrongApp which soft-
170
- * skip in onboarding). Combined with `accounts.length === 0`, signals
171
- * genuine orphan. Also reused as the batch-abort whitelist for HWK.
172
- * Single source of truth.
173
- *
174
- * UserRejected (device-side reject) is included: pressing reject is an
175
- * explicit "I don't consent" — continuing the batch to ask again on the
176
- * next chain is harassment, not helpful.
177
- */
178
- declare const ORPHAN_ELIGIBLE_ERROR_CODES: number[];
179
- interface IHwkErrorPayload {
180
- code: HardwareErrorCode;
181
- message: string;
182
- appName?: string;
183
- _tag?: string;
184
- params?: Record<string, unknown>;
185
- }
186
- type HwkError = Error & {
187
- code: HardwareErrorCode;
188
- appName?: string;
189
- _tag?: string;
190
- params?: Record<string, unknown>;
191
- };
192
- /**
193
- * Canonical throwable for HWK adapters. Plain Error + canonical extra fields,
194
- * shape-compatible with `rehydrateConnectorError` so locally-thrown and
195
- * cross-boundary errors are indistinguishable to downstream classifiers
196
- * (`err.code` / `err._tag` / `err.appName`). Do NOT mutate caught errors
197
- * with `Object.assign` — construct a fresh one via this factory.
198
- */
199
- declare function createHwkError(payload: IHwkErrorPayload): HwkError;
200
-
201
- /**
202
- * Enrich a hardware error message with actionable recovery hints.
203
- * Shared across adapters (Ledger, Trezor, etc.).
204
- */
205
- declare function enrichErrorMessage(code: HardwareErrorCode, originalMessage: string): string;
206
-
207
- export { HardwareErrorCode, type HwkError, type IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage };
1
+ export { H as HardwareErrorCode, c as HwkError, b as HwkRecoveryHint, d as HwkRecoveryScope, I as IHwkErrorPayload, O as ORPHAN_ELIGIBLE_ERROR_CODES, f as createHwkError, h as defaultRecoveryForCode, i as enrichErrorMessage, j as isHwkRecoveryHint } from './errors-BgJ4kzRx.mjs';