@onekeyfe/hwk-adapter-core 1.1.28 → 1.1.29-alpha.2
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-6JWUE3GT.mjs +151 -0
- package/dist/chunk-6JWUE3GT.mjs.map +1 -0
- package/dist/chunk-D5OZT7RZ.mjs +138 -0
- package/dist/chunk-D5OZT7RZ.mjs.map +1 -0
- package/dist/chunk-LYVS67EX.js +151 -0
- package/dist/chunk-LYVS67EX.js.map +1 -0
- package/dist/chunk-QD4EQWQA.js +138 -0
- package/dist/chunk-QD4EQWQA.js.map +1 -0
- package/dist/errors.d.mts +164 -0
- package/dist/errors.d.ts +164 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +13 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.d.mts +610 -292
- package/dist/index.d.ts +610 -292
- package/dist/index.js +452 -368
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +400 -258
- package/dist/index.mjs.map +1 -1
- package/dist/ui-events-BzkI1wZk.d.mts +132 -0
- package/dist/ui-events-BzkI1wZk.d.ts +132 -0
- package/dist/ui-events.d.mts +1 -0
- package/dist/ui-events.d.ts +1 -0
- package/dist/ui-events.js +21 -0
- package/dist/ui-events.js.map +1 -0
- package/dist/ui-events.mjs +21 -0
- package/dist/ui-events.mjs.map +1 -0
- package/package.json +22 -2
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/types/errors.ts
|
|
2
|
+
var HardwareErrorCode = /* @__PURE__ */ ((HardwareErrorCode2) => {
|
|
3
|
+
HardwareErrorCode2[HardwareErrorCode2["UnknownError"] = 1e4] = "UnknownError";
|
|
4
|
+
HardwareErrorCode2[HardwareErrorCode2["UserRejected"] = 10001] = "UserRejected";
|
|
5
|
+
HardwareErrorCode2[HardwareErrorCode2["InvalidParams"] = 10002] = "InvalidParams";
|
|
6
|
+
HardwareErrorCode2[HardwareErrorCode2["OperationTimeout"] = 10003] = "OperationTimeout";
|
|
7
|
+
HardwareErrorCode2[HardwareErrorCode2["MethodNotSupported"] = 10004] = "MethodNotSupported";
|
|
8
|
+
HardwareErrorCode2[HardwareErrorCode2["UserAborted"] = 10005] = "UserAborted";
|
|
9
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceNotFound"] = 10100] = "DeviceNotFound";
|
|
10
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceDisconnected"] = 10101] = "DeviceDisconnected";
|
|
11
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceBusy"] = 10102] = "DeviceBusy";
|
|
12
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceLocked"] = 10103] = "DeviceLocked";
|
|
13
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceNotInitialized"] = 10104] = "DeviceNotInitialized";
|
|
14
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceInBootloader"] = 10105] = "DeviceInBootloader";
|
|
15
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceMismatch"] = 10106] = "DeviceMismatch";
|
|
16
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceAppStuck"] = 10107] = "DeviceAppStuck";
|
|
17
|
+
HardwareErrorCode2[HardwareErrorCode2["ChainNotSupported"] = 10108] = "ChainNotSupported";
|
|
18
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceOneDeviceOnly"] = 10109] = "DeviceOneDeviceOnly";
|
|
19
|
+
HardwareErrorCode2[HardwareErrorCode2["FirmwareTooOld"] = 10200] = "FirmwareTooOld";
|
|
20
|
+
HardwareErrorCode2[HardwareErrorCode2["FirmwareUpdateRequired"] = 10201] = "FirmwareUpdateRequired";
|
|
21
|
+
HardwareErrorCode2[HardwareErrorCode2["TransportError"] = 10300] = "TransportError";
|
|
22
|
+
HardwareErrorCode2[HardwareErrorCode2["BridgeNotFound"] = 10301] = "BridgeNotFound";
|
|
23
|
+
HardwareErrorCode2[HardwareErrorCode2["TransportNotAvailable"] = 10302] = "TransportNotAvailable";
|
|
24
|
+
HardwareErrorCode2[HardwareErrorCode2["DevicePermissionDenied"] = 10303] = "DevicePermissionDenied";
|
|
25
|
+
HardwareErrorCode2[HardwareErrorCode2["BlePairingTimeout"] = 10304] = "BlePairingTimeout";
|
|
26
|
+
HardwareErrorCode2[HardwareErrorCode2["NetworkError"] = 10305] = "NetworkError";
|
|
27
|
+
HardwareErrorCode2[HardwareErrorCode2["ThpPairingFailed"] = 10306] = "ThpPairingFailed";
|
|
28
|
+
HardwareErrorCode2[HardwareErrorCode2["BleBondInvalid"] = 10307] = "BleBondInvalid";
|
|
29
|
+
HardwareErrorCode2[HardwareErrorCode2["PinInvalid"] = 10400] = "PinInvalid";
|
|
30
|
+
HardwareErrorCode2[HardwareErrorCode2["PinCancelled"] = 10401] = "PinCancelled";
|
|
31
|
+
HardwareErrorCode2[HardwareErrorCode2["PassphraseRejected"] = 10402] = "PassphraseRejected";
|
|
32
|
+
HardwareErrorCode2[HardwareErrorCode2["PassphraseStateMismatch"] = 10403] = "PassphraseStateMismatch";
|
|
33
|
+
HardwareErrorCode2[HardwareErrorCode2["AppNotInstalled"] = 10500] = "AppNotInstalled";
|
|
34
|
+
HardwareErrorCode2[HardwareErrorCode2["WrongApp"] = 10501] = "WrongApp";
|
|
35
|
+
HardwareErrorCode2[HardwareErrorCode2["AppTooOld"] = 10502] = "AppTooOld";
|
|
36
|
+
HardwareErrorCode2[HardwareErrorCode2["DeviceOutOfMemory"] = 10503] = "DeviceOutOfMemory";
|
|
37
|
+
HardwareErrorCode2[HardwareErrorCode2["EvmBlindSigningRequired"] = 11e3] = "EvmBlindSigningRequired";
|
|
38
|
+
HardwareErrorCode2[HardwareErrorCode2["EvmClearSignPluginMissing"] = 11001] = "EvmClearSignPluginMissing";
|
|
39
|
+
HardwareErrorCode2[HardwareErrorCode2["EvmDataTooLarge"] = 11002] = "EvmDataTooLarge";
|
|
40
|
+
HardwareErrorCode2[HardwareErrorCode2["EvmTxTypeNotSupported"] = 11003] = "EvmTxTypeNotSupported";
|
|
41
|
+
HardwareErrorCode2[HardwareErrorCode2["SolanaBlindSigningRequired"] = 11100] = "SolanaBlindSigningRequired";
|
|
42
|
+
HardwareErrorCode2[HardwareErrorCode2["TronCustomContractRequired"] = 11200] = "TronCustomContractRequired";
|
|
43
|
+
HardwareErrorCode2[HardwareErrorCode2["TronDataSigningRequired"] = 11201] = "TronDataSigningRequired";
|
|
44
|
+
HardwareErrorCode2[HardwareErrorCode2["TronSignByHashRequired"] = 11202] = "TronSignByHashRequired";
|
|
45
|
+
HardwareErrorCode2[HardwareErrorCode2["BtcWalletPolicyHmacMismatch"] = 11300] = "BtcWalletPolicyHmacMismatch";
|
|
46
|
+
HardwareErrorCode2[HardwareErrorCode2["BtcUnexpectedState"] = 11301] = "BtcUnexpectedState";
|
|
47
|
+
return HardwareErrorCode2;
|
|
48
|
+
})(HardwareErrorCode || {});
|
|
49
|
+
var ORPHAN_ELIGIBLE_ERROR_CODES = [
|
|
50
|
+
10005 /* UserAborted */,
|
|
51
|
+
10001 /* UserRejected */,
|
|
52
|
+
10100 /* DeviceNotFound */,
|
|
53
|
+
10101 /* DeviceDisconnected */,
|
|
54
|
+
10106 /* DeviceMismatch */,
|
|
55
|
+
10107 /* DeviceAppStuck */,
|
|
56
|
+
10109 /* DeviceOneDeviceOnly */,
|
|
57
|
+
10300 /* TransportError */,
|
|
58
|
+
10303 /* DevicePermissionDenied */,
|
|
59
|
+
10304 /* BlePairingTimeout */,
|
|
60
|
+
10306 /* ThpPairingFailed */,
|
|
61
|
+
10307 /* BleBondInvalid */
|
|
62
|
+
];
|
|
63
|
+
function createHwkError(payload) {
|
|
64
|
+
return Object.assign(new Error(payload.message), {
|
|
65
|
+
code: payload.code,
|
|
66
|
+
...payload._tag !== void 0 && { _tag: payload._tag },
|
|
67
|
+
...payload.appName !== void 0 && { appName: payload.appName },
|
|
68
|
+
...payload.params !== void 0 && { params: payload.params }
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/utils/errorMessages.ts
|
|
73
|
+
function enrichErrorMessage(code, originalMessage) {
|
|
74
|
+
switch (code) {
|
|
75
|
+
case 10400 /* PinInvalid */:
|
|
76
|
+
return `${originalMessage}. Please re-enter your PIN.`;
|
|
77
|
+
case 10401 /* PinCancelled */:
|
|
78
|
+
return `${originalMessage}. PIN entry was cancelled.`;
|
|
79
|
+
case 10102 /* DeviceBusy */:
|
|
80
|
+
return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;
|
|
81
|
+
case 10101 /* DeviceDisconnected */:
|
|
82
|
+
return `${originalMessage}. Please reconnect the device and try again.`;
|
|
83
|
+
case 10103 /* DeviceLocked */:
|
|
84
|
+
return `${originalMessage}. Please unlock your device and try again.`;
|
|
85
|
+
case 10109 /* DeviceOneDeviceOnly */:
|
|
86
|
+
return `${originalMessage}. Disconnect the extra device and try again.`;
|
|
87
|
+
case 10001 /* UserRejected */:
|
|
88
|
+
return `${originalMessage}. The request was rejected on the device.`;
|
|
89
|
+
case 10501 /* WrongApp */:
|
|
90
|
+
return `${originalMessage}. Please open the correct app on your device.`;
|
|
91
|
+
case 10500 /* AppNotInstalled */:
|
|
92
|
+
return `${originalMessage}. The required app is not installed on the device.`;
|
|
93
|
+
case 10503 /* DeviceOutOfMemory */:
|
|
94
|
+
return `${originalMessage}. Not enough free space on the device. Please uninstall some apps and try again.`;
|
|
95
|
+
case 10302 /* TransportNotAvailable */:
|
|
96
|
+
return `${originalMessage}. Ensure the device bridge/transport is available and running.`;
|
|
97
|
+
case 10305 /* NetworkError */:
|
|
98
|
+
return `${originalMessage}. Network error \u2014 check your internet connection and try again.`;
|
|
99
|
+
case 10200 /* FirmwareTooOld */:
|
|
100
|
+
return `${originalMessage}. Please update your device firmware.`;
|
|
101
|
+
case 10104 /* DeviceNotInitialized */:
|
|
102
|
+
return `${originalMessage}. The device may need to be set up first.`;
|
|
103
|
+
case 10003 /* OperationTimeout */:
|
|
104
|
+
return `${originalMessage}. The operation timed out. Please try again.`;
|
|
105
|
+
case 11e3 /* EvmBlindSigningRequired */:
|
|
106
|
+
return "Ledger: Blind signing not enabled in Ethereum app.";
|
|
107
|
+
case 11001 /* EvmClearSignPluginMissing */:
|
|
108
|
+
return "Ledger: Required plugin not installed (install via Ledger Live).";
|
|
109
|
+
case 11002 /* EvmDataTooLarge */:
|
|
110
|
+
return "Ledger: Transaction data too large for device memory.";
|
|
111
|
+
case 11003 /* EvmTxTypeNotSupported */:
|
|
112
|
+
return "Ledger: Transaction type not supported by current Ethereum app.";
|
|
113
|
+
case 10502 /* AppTooOld */:
|
|
114
|
+
return "Ledger: App out of date (update via Ledger Live).";
|
|
115
|
+
case 11100 /* SolanaBlindSigningRequired */:
|
|
116
|
+
return "Blind signing disabled in the Solana app.";
|
|
117
|
+
case 11200 /* TronCustomContractRequired */:
|
|
118
|
+
return "Custom Contracts setting disabled in the Tron app.";
|
|
119
|
+
case 11201 /* TronDataSigningRequired */:
|
|
120
|
+
return "Transactions Data setting disabled in the Tron app.";
|
|
121
|
+
case 11202 /* TronSignByHashRequired */:
|
|
122
|
+
return "Sign by Hash setting disabled in the Tron app.";
|
|
123
|
+
case 11300 /* BtcWalletPolicyHmacMismatch */:
|
|
124
|
+
return "Wallet policy not registered or HMAC mismatch.";
|
|
125
|
+
case 11301 /* BtcUnexpectedState */:
|
|
126
|
+
return "Signing aborted due to unexpected device state.";
|
|
127
|
+
default:
|
|
128
|
+
return originalMessage;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
exports.HardwareErrorCode = HardwareErrorCode; exports.ORPHAN_ELIGIBLE_ERROR_CODES = ORPHAN_ELIGIBLE_ERROR_CODES; exports.createHwkError = createHwkError; exports.enrichErrorMessage = enrichErrorMessage;
|
|
138
|
+
//# sourceMappingURL=chunk-QD4EQWQA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-QD4EQWQA.js","../src/types/errors.ts","../src/utils/errorMessages.ts"],"names":["HardwareErrorCode"],"mappings":"AAAA;ACuBO,IAAK,kBAAA,kBAAL,CAAA,CAAKA,kBAAAA,EAAAA,GAAL;AAEL,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,cAAA,EAAA,EAAe,GAAA,EAAA,EAAf,cAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,cAAA,EAAA,EAAe,KAAA,EAAA,EAAf,cAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,eAAA,EAAA,EAAgB,KAAA,EAAA,EAAhB,eAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,kBAAA,EAAA,EAAmB,KAAA,EAAA,EAAnB,kBAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,oBAAA,EAAA,EAAqB,KAAA,EAAA,EAArB,oBAAA;AAEA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,aAAA,EAAA,EAAc,KAAA,EAAA,EAAd,aAAA;AAGA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,gBAAA,EAAA,EAAiB,KAAA,EAAA,EAAjB,gBAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,oBAAA,EAAA,EAAqB,KAAA,EAAA,EAArB,oBAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,YAAA,EAAA,EAAa,KAAA,EAAA,EAAb,YAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,cAAA,EAAA,EAAe,KAAA,EAAA,EAAf,cAAA;AACA,EAAAA,kBAAAA,CAAAA,kBAAAA,CAAA,sBAAA,EAAA,EAAuB,KAAA,EAAA,EAAvB,sBAAA;AACA,EAAAA,kBAAAA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AAE,MAAA,EAAQ,OAAA,CAAQ,OAAO;AAAA,EAC/D,CAAC,CAAA;AACH;ADpIA;AACA;AEjEO,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;AACX,EAAA;AACF;AFmEc;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/chunk-QD4EQWQA.js","sourcesContent":[null,"/**\n * HWK HardwareErrorCode — independent namespace from the legacy\n * `@onekeyfe/shared` HardwareErrorCode (which occupies 0-902).\n *\n * All HWK codes are 5-digit (>= 10000) so the two tables never collide\n * even if either side grows. Each sub-category gets a 100-slot block.\n *\n * 10000-10099 Generic / cross-cutting primitives\n * 10100-10199 Device state\n * 10200-10299 Firmware\n * 10300-10399 Transport + OS-level permission\n * 10400-10499 PIN / Passphrase\n * 10500-10599 App lifecycle (wrong app, not open, too old)\n * 10600-10999 RESERVED — future adapter-level categories\n *\n * 11000-11099 EVM APDU (reactive mapping)\n * 11100-11199 Solana APDU\n * 11200-11299 Tron APDU\n * 11300-11399 BTC APDU\n * 11400-11999 RESERVED — future chain APDU blocks (100 per chain)\n *\n * 12000-99999 RESERVED — future major categories\n */\nexport enum HardwareErrorCode {\n // --- 10000s Generic ---\n UnknownError = 10000,\n UserRejected = 10001,\n InvalidParams = 10002,\n OperationTimeout = 10003,\n MethodNotSupported = 10004,\n /** User dismissed in-app cancel UI. Distinct from UserRejected (on-device). */\n UserAborted = 10005,\n\n // --- 10100s Device state ---\n DeviceNotFound = 10100,\n DeviceDisconnected = 10101,\n DeviceBusy = 10102,\n DeviceLocked = 10103,\n DeviceNotInitialized = 10104,\n DeviceInBootloader = 10105,\n DeviceMismatch = 10106,\n /** Chain app wedged (e.g. Ledger BTC 0x6901). User must exit app on device. */\n DeviceAppStuck = 10107,\n /** Vendor (Ledger / Trezor) doesn't support the chain at all. */\n ChainNotSupported = 10108,\n /** Current operation supports only one connected device. */\n DeviceOneDeviceOnly = 10109,\n\n // --- 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 // --- 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 // --- 10500s App lifecycle ---\n /** Chain app NOT INSTALLED on device. User must install via Ledger Live. */\n AppNotInstalled = 10500,\n WrongApp = 10501,\n /** 0x911c Command code not supported — app predates current SDK. */\n AppTooOld = 10502,\n /** Not enough free storage for install/update; user must uninstall apps first. */\n DeviceOutOfMemory = 10503,\n\n // --- 11000s EVM (Ledger Ethereum App) APDU-specific ---\n /** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the\n * user has not enabled Blind signing on the device. */\n EvmBlindSigningRequired = 11000,\n /** 0x6984 Plugin not installed */\n EvmClearSignPluginMissing = 11001,\n /** 0x6a84 Insufficient memory (typical on Nano S with large calldata) */\n EvmDataTooLarge = 11002,\n /** 0x6501 TransactionType not supported (app too old for EIP-1559 / blob / 7702) */\n EvmTxTypeNotSupported = 11003,\n\n // --- 11100s Solana ---\n /** 0x6808 Blind signing disabled for this instruction. */\n SolanaBlindSigningRequired = 11100,\n\n // --- 11200s Tron ---\n /** 0x6a8d Custom Contracts setting disabled (blocks TRC-20 etc.). */\n TronCustomContractRequired = 11200,\n /** 0x6a8b Transactions Data setting disabled. */\n TronDataSigningRequired = 11201,\n /** 0x6a8c Sign by Hash setting disabled (hash-signing fallback). */\n TronSignByHashRequired = 11202,\n\n // --- 11300s BTC ---\n /** 0xb008 Wallet policy HMAC mismatch or not registered. */\n BtcWalletPolicyHmacMismatch = 11300,\n /** 0xb007 Aborted due to unexpected state (malformed PSBT / missing UTXO). */\n BtcUnexpectedState = 11301,\n}\n\n/**\n * Device-level failures the SDK cannot self-recover from — affect the entire\n * batch (vs per-chain failures like AppNotInstalled / WrongApp which soft-\n * skip in onboarding). Combined with `accounts.length === 0`, signals\n * genuine orphan. Also reused as the batch-abort whitelist for HWK.\n * Single source of truth.\n *\n * UserRejected (device-side reject) is included: pressing reject is an\n * explicit \"I don't consent\" — continuing the batch to ask again on the\n * next chain is harassment, not helpful.\n */\nexport const ORPHAN_ELIGIBLE_ERROR_CODES: number[] = [\n HardwareErrorCode.UserAborted,\n HardwareErrorCode.UserRejected,\n HardwareErrorCode.DeviceNotFound,\n HardwareErrorCode.DeviceDisconnected,\n HardwareErrorCode.DeviceMismatch,\n HardwareErrorCode.DeviceAppStuck,\n HardwareErrorCode.DeviceOneDeviceOnly,\n HardwareErrorCode.TransportError,\n HardwareErrorCode.DevicePermissionDenied,\n HardwareErrorCode.BlePairingTimeout,\n HardwareErrorCode.ThpPairingFailed,\n HardwareErrorCode.BleBondInvalid,\n];\n\n// ---------------------------------------------------------------------------\n// Standard throwable for HWK adapters\n// ---------------------------------------------------------------------------\n\nexport interface IHwkErrorPayload {\n code: HardwareErrorCode;\n message: string;\n appName?: string;\n _tag?: string;\n params?: Record<string, unknown>;\n}\n\nexport type HwkError = Error & {\n code: HardwareErrorCode;\n appName?: string;\n _tag?: string;\n params?: Record<string, unknown>;\n};\n\n/**\n * Canonical throwable for HWK adapters. Plain Error + canonical extra fields,\n * shape-compatible with `rehydrateConnectorError` so locally-thrown and\n * cross-boundary errors are indistinguishable to downstream classifiers\n * (`err.code` / `err._tag` / `err.appName`). Do NOT mutate caught errors\n * with `Object.assign` — construct a fresh one via this factory.\n */\nexport function createHwkError(payload: IHwkErrorPayload): HwkError {\n return Object.assign(new Error(payload.message), {\n code: payload.code,\n ...(payload._tag !== undefined && { _tag: payload._tag }),\n ...(payload.appName !== undefined && { appName: payload.appName }),\n ...(payload.params !== undefined && { params: payload.params }),\n });\n}\n","import { HardwareErrorCode } from '../types/errors';\n\n/**\n * Enrich a hardware error message with actionable recovery hints.\n * Shared across adapters (Ledger, Trezor, etc.).\n */\nexport function enrichErrorMessage(code: HardwareErrorCode, originalMessage: string): string {\n switch (code) {\n case HardwareErrorCode.PinInvalid:\n return `${originalMessage}. Please re-enter your PIN.`;\n case HardwareErrorCode.PinCancelled:\n return `${originalMessage}. PIN entry was cancelled.`;\n case HardwareErrorCode.DeviceBusy:\n return `${originalMessage}. The device is in use by another application. Close other wallet apps and try again.`;\n case HardwareErrorCode.DeviceDisconnected:\n return `${originalMessage}. Please reconnect the device and try again.`;\n case HardwareErrorCode.DeviceLocked:\n return `${originalMessage}. Please unlock your device and try again.`;\n case HardwareErrorCode.DeviceOneDeviceOnly:\n return `${originalMessage}. Disconnect the extra device and try again.`;\n case HardwareErrorCode.UserRejected:\n return `${originalMessage}. The request was rejected on the device.`;\n case HardwareErrorCode.WrongApp:\n return `${originalMessage}. Please open the correct app on your device.`;\n case HardwareErrorCode.AppNotInstalled:\n return `${originalMessage}. The required app is not installed on the device.`;\n case HardwareErrorCode.DeviceOutOfMemory:\n return `${originalMessage}. Not enough free space on the device. Please uninstall some apps and try again.`;\n case HardwareErrorCode.TransportNotAvailable:\n return `${originalMessage}. Ensure the device bridge/transport is available and running.`;\n case HardwareErrorCode.NetworkError:\n return `${originalMessage}. Network error — check your internet connection and try again.`;\n case HardwareErrorCode.FirmwareTooOld:\n return `${originalMessage}. Please update your device firmware.`;\n case HardwareErrorCode.DeviceNotInitialized:\n return `${originalMessage}. The device may need to be set up first.`;\n case HardwareErrorCode.OperationTimeout:\n return `${originalMessage}. The operation timed out. Please try again.`;\n case HardwareErrorCode.EvmBlindSigningRequired:\n return 'Ledger: Blind signing not enabled in Ethereum app.';\n case HardwareErrorCode.EvmClearSignPluginMissing:\n return 'Ledger: Required plugin not installed (install via Ledger Live).';\n case HardwareErrorCode.EvmDataTooLarge:\n return 'Ledger: Transaction data too large for device memory.';\n case HardwareErrorCode.EvmTxTypeNotSupported:\n return 'Ledger: Transaction type not supported by current Ethereum app.';\n case HardwareErrorCode.AppTooOld:\n return 'Ledger: App out of date (update via Ledger Live).';\n case HardwareErrorCode.SolanaBlindSigningRequired:\n return 'Blind signing disabled in the Solana app.';\n case HardwareErrorCode.TronCustomContractRequired:\n return 'Custom Contracts setting disabled in the Tron app.';\n case HardwareErrorCode.TronDataSigningRequired:\n return 'Transactions Data setting disabled in the Tron app.';\n case HardwareErrorCode.TronSignByHashRequired:\n return 'Sign by Hash setting disabled in the Tron app.';\n case HardwareErrorCode.BtcWalletPolicyHmacMismatch:\n return 'Wallet policy not registered or HMAC mismatch.';\n case HardwareErrorCode.BtcUnexpectedState:\n return 'Signing aborted due to unexpected device state.';\n default:\n return originalMessage;\n }\n}\n"]}
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
FirmwareTooOld = 10200,
|
|
46
|
+
FirmwareUpdateRequired = 10201,
|
|
47
|
+
TransportError = 10300,
|
|
48
|
+
BridgeNotFound = 10301,
|
|
49
|
+
TransportNotAvailable = 10302,
|
|
50
|
+
/**
|
|
51
|
+
* OS-level permission (Bluetooth / USB / etc.) — denied, blocked,
|
|
52
|
+
* unavailable, or dismissed. Consumers surface a single "please grant
|
|
53
|
+
* permission" toast and let the user retry manually.
|
|
54
|
+
*/
|
|
55
|
+
DevicePermissionDenied = 10303,
|
|
56
|
+
/**
|
|
57
|
+
* BLE SMP pairing did not complete within the GATT bonding window.
|
|
58
|
+
* GATT connected but the device didn't acknowledge SMP — typically
|
|
59
|
+
* because the user didn't confirm the passkey on the device, or the
|
|
60
|
+
* device went out of range mid-pairing. Distinct from OperationTimeout
|
|
61
|
+
* (generic) and from DeviceLocked (Secure Element actually locked).
|
|
62
|
+
*/
|
|
63
|
+
BlePairingTimeout = 10304,
|
|
64
|
+
/** Remote network failure reaching a vendor's servers (HTTP/WS). Distinct from TransportError (local USB/BLE link). */
|
|
65
|
+
NetworkError = 10305,
|
|
66
|
+
/**
|
|
67
|
+
* Host-managed pairing handshake failed (Trezor THP). The device rejected the
|
|
68
|
+
* pairing exchange — e.g. CodeEntry: the user mistyped the code shown on the
|
|
69
|
+
* device, so the CPace tag didn't match ("Unexpected Code Entry Tag").
|
|
70
|
+
* Recoverable: the user re-pairs and re-enters the code. Distinct from
|
|
71
|
+
* BlePairingTimeout (BLE SMP bonding window) and UserRejected (on-device
|
|
72
|
+
* reject button).
|
|
73
|
+
*/
|
|
74
|
+
ThpPairingFailed = 10306,
|
|
75
|
+
/**
|
|
76
|
+
* The OS-level BLE bond is stale/invalid, so the device rejected link
|
|
77
|
+
* encryption: Android GATT_INSUF_AUTHENTICATION (status 5) or iOS "Peer
|
|
78
|
+
* removed pairing information". Happens after the device is wiped/re-flashed
|
|
79
|
+
* or unpaired elsewhere while the host still holds an old bond. The SDK cannot
|
|
80
|
+
* remove an OS bond — the user must forget the device in system Bluetooth
|
|
81
|
+
* settings and re-pair. Distinct from BlePairingTimeout (SMP window) and
|
|
82
|
+
* ThpPairingFailed (THP code mismatch).
|
|
83
|
+
*/
|
|
84
|
+
BleBondInvalid = 10307,
|
|
85
|
+
PinInvalid = 10400,
|
|
86
|
+
PinCancelled = 10401,
|
|
87
|
+
PassphraseRejected = 10402,
|
|
88
|
+
/**
|
|
89
|
+
* The passphrase entered produced a different wallet (`passphraseState`) than
|
|
90
|
+
* the one the caller asked to operate on. Trezor-only: the host pins a wallet
|
|
91
|
+
* by its derived state and the SDK refuses to sign with a mismatched
|
|
92
|
+
* passphrase session. Surfaced by TrezorAdapter.getPassphraseState.
|
|
93
|
+
*/
|
|
94
|
+
PassphraseStateMismatch = 10403,
|
|
95
|
+
/** Chain app NOT INSTALLED on device. User must install via Ledger Live. */
|
|
96
|
+
AppNotInstalled = 10500,
|
|
97
|
+
WrongApp = 10501,
|
|
98
|
+
/** 0x911c Command code not supported — app predates current SDK. */
|
|
99
|
+
AppTooOld = 10502,
|
|
100
|
+
/** Not enough free storage for install/update; user must uninstall apps first. */
|
|
101
|
+
DeviceOutOfMemory = 10503,
|
|
102
|
+
/** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the
|
|
103
|
+
* user has not enabled Blind signing on the device. */
|
|
104
|
+
EvmBlindSigningRequired = 11000,
|
|
105
|
+
/** 0x6984 Plugin not installed */
|
|
106
|
+
EvmClearSignPluginMissing = 11001,
|
|
107
|
+
/** 0x6a84 Insufficient memory (typical on Nano S with large calldata) */
|
|
108
|
+
EvmDataTooLarge = 11002,
|
|
109
|
+
/** 0x6501 TransactionType not supported (app too old for EIP-1559 / blob / 7702) */
|
|
110
|
+
EvmTxTypeNotSupported = 11003,
|
|
111
|
+
/** 0x6808 Blind signing disabled for this instruction. */
|
|
112
|
+
SolanaBlindSigningRequired = 11100,
|
|
113
|
+
/** 0x6a8d Custom Contracts setting disabled (blocks TRC-20 etc.). */
|
|
114
|
+
TronCustomContractRequired = 11200,
|
|
115
|
+
/** 0x6a8b Transactions Data setting disabled. */
|
|
116
|
+
TronDataSigningRequired = 11201,
|
|
117
|
+
/** 0x6a8c Sign by Hash setting disabled (hash-signing fallback). */
|
|
118
|
+
TronSignByHashRequired = 11202,
|
|
119
|
+
/** 0xb008 Wallet policy HMAC mismatch or not registered. */
|
|
120
|
+
BtcWalletPolicyHmacMismatch = 11300,
|
|
121
|
+
/** 0xb007 Aborted due to unexpected state (malformed PSBT / missing UTXO). */
|
|
122
|
+
BtcUnexpectedState = 11301
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Device-level failures the SDK cannot self-recover from — affect the entire
|
|
126
|
+
* batch (vs per-chain failures like AppNotInstalled / WrongApp which soft-
|
|
127
|
+
* skip in onboarding). Combined with `accounts.length === 0`, signals
|
|
128
|
+
* genuine orphan. Also reused as the batch-abort whitelist for HWK.
|
|
129
|
+
* Single source of truth.
|
|
130
|
+
*
|
|
131
|
+
* UserRejected (device-side reject) is included: pressing reject is an
|
|
132
|
+
* explicit "I don't consent" — continuing the batch to ask again on the
|
|
133
|
+
* next chain is harassment, not helpful.
|
|
134
|
+
*/
|
|
135
|
+
declare const ORPHAN_ELIGIBLE_ERROR_CODES: number[];
|
|
136
|
+
interface IHwkErrorPayload {
|
|
137
|
+
code: HardwareErrorCode;
|
|
138
|
+
message: string;
|
|
139
|
+
appName?: string;
|
|
140
|
+
_tag?: string;
|
|
141
|
+
params?: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
type HwkError = Error & {
|
|
144
|
+
code: HardwareErrorCode;
|
|
145
|
+
appName?: string;
|
|
146
|
+
_tag?: string;
|
|
147
|
+
params?: Record<string, unknown>;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Canonical throwable for HWK adapters. Plain Error + canonical extra fields,
|
|
151
|
+
* shape-compatible with `rehydrateConnectorError` so locally-thrown and
|
|
152
|
+
* cross-boundary errors are indistinguishable to downstream classifiers
|
|
153
|
+
* (`err.code` / `err._tag` / `err.appName`). Do NOT mutate caught errors
|
|
154
|
+
* with `Object.assign` — construct a fresh one via this factory.
|
|
155
|
+
*/
|
|
156
|
+
declare function createHwkError(payload: IHwkErrorPayload): HwkError;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Enrich a hardware error message with actionable recovery hints.
|
|
160
|
+
* Shared across adapters (Ledger, Trezor, etc.).
|
|
161
|
+
*/
|
|
162
|
+
declare function enrichErrorMessage(code: HardwareErrorCode, originalMessage: string): string;
|
|
163
|
+
|
|
164
|
+
export { HardwareErrorCode, type HwkError, type IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage };
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
FirmwareTooOld = 10200,
|
|
46
|
+
FirmwareUpdateRequired = 10201,
|
|
47
|
+
TransportError = 10300,
|
|
48
|
+
BridgeNotFound = 10301,
|
|
49
|
+
TransportNotAvailable = 10302,
|
|
50
|
+
/**
|
|
51
|
+
* OS-level permission (Bluetooth / USB / etc.) — denied, blocked,
|
|
52
|
+
* unavailable, or dismissed. Consumers surface a single "please grant
|
|
53
|
+
* permission" toast and let the user retry manually.
|
|
54
|
+
*/
|
|
55
|
+
DevicePermissionDenied = 10303,
|
|
56
|
+
/**
|
|
57
|
+
* BLE SMP pairing did not complete within the GATT bonding window.
|
|
58
|
+
* GATT connected but the device didn't acknowledge SMP — typically
|
|
59
|
+
* because the user didn't confirm the passkey on the device, or the
|
|
60
|
+
* device went out of range mid-pairing. Distinct from OperationTimeout
|
|
61
|
+
* (generic) and from DeviceLocked (Secure Element actually locked).
|
|
62
|
+
*/
|
|
63
|
+
BlePairingTimeout = 10304,
|
|
64
|
+
/** Remote network failure reaching a vendor's servers (HTTP/WS). Distinct from TransportError (local USB/BLE link). */
|
|
65
|
+
NetworkError = 10305,
|
|
66
|
+
/**
|
|
67
|
+
* Host-managed pairing handshake failed (Trezor THP). The device rejected the
|
|
68
|
+
* pairing exchange — e.g. CodeEntry: the user mistyped the code shown on the
|
|
69
|
+
* device, so the CPace tag didn't match ("Unexpected Code Entry Tag").
|
|
70
|
+
* Recoverable: the user re-pairs and re-enters the code. Distinct from
|
|
71
|
+
* BlePairingTimeout (BLE SMP bonding window) and UserRejected (on-device
|
|
72
|
+
* reject button).
|
|
73
|
+
*/
|
|
74
|
+
ThpPairingFailed = 10306,
|
|
75
|
+
/**
|
|
76
|
+
* The OS-level BLE bond is stale/invalid, so the device rejected link
|
|
77
|
+
* encryption: Android GATT_INSUF_AUTHENTICATION (status 5) or iOS "Peer
|
|
78
|
+
* removed pairing information". Happens after the device is wiped/re-flashed
|
|
79
|
+
* or unpaired elsewhere while the host still holds an old bond. The SDK cannot
|
|
80
|
+
* remove an OS bond — the user must forget the device in system Bluetooth
|
|
81
|
+
* settings and re-pair. Distinct from BlePairingTimeout (SMP window) and
|
|
82
|
+
* ThpPairingFailed (THP code mismatch).
|
|
83
|
+
*/
|
|
84
|
+
BleBondInvalid = 10307,
|
|
85
|
+
PinInvalid = 10400,
|
|
86
|
+
PinCancelled = 10401,
|
|
87
|
+
PassphraseRejected = 10402,
|
|
88
|
+
/**
|
|
89
|
+
* The passphrase entered produced a different wallet (`passphraseState`) than
|
|
90
|
+
* the one the caller asked to operate on. Trezor-only: the host pins a wallet
|
|
91
|
+
* by its derived state and the SDK refuses to sign with a mismatched
|
|
92
|
+
* passphrase session. Surfaced by TrezorAdapter.getPassphraseState.
|
|
93
|
+
*/
|
|
94
|
+
PassphraseStateMismatch = 10403,
|
|
95
|
+
/** Chain app NOT INSTALLED on device. User must install via Ledger Live. */
|
|
96
|
+
AppNotInstalled = 10500,
|
|
97
|
+
WrongApp = 10501,
|
|
98
|
+
/** 0x911c Command code not supported — app predates current SDK. */
|
|
99
|
+
AppTooOld = 10502,
|
|
100
|
+
/** Not enough free storage for install/update; user must uninstall apps first. */
|
|
101
|
+
DeviceOutOfMemory = 10503,
|
|
102
|
+
/** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the
|
|
103
|
+
* user has not enabled Blind signing on the device. */
|
|
104
|
+
EvmBlindSigningRequired = 11000,
|
|
105
|
+
/** 0x6984 Plugin not installed */
|
|
106
|
+
EvmClearSignPluginMissing = 11001,
|
|
107
|
+
/** 0x6a84 Insufficient memory (typical on Nano S with large calldata) */
|
|
108
|
+
EvmDataTooLarge = 11002,
|
|
109
|
+
/** 0x6501 TransactionType not supported (app too old for EIP-1559 / blob / 7702) */
|
|
110
|
+
EvmTxTypeNotSupported = 11003,
|
|
111
|
+
/** 0x6808 Blind signing disabled for this instruction. */
|
|
112
|
+
SolanaBlindSigningRequired = 11100,
|
|
113
|
+
/** 0x6a8d Custom Contracts setting disabled (blocks TRC-20 etc.). */
|
|
114
|
+
TronCustomContractRequired = 11200,
|
|
115
|
+
/** 0x6a8b Transactions Data setting disabled. */
|
|
116
|
+
TronDataSigningRequired = 11201,
|
|
117
|
+
/** 0x6a8c Sign by Hash setting disabled (hash-signing fallback). */
|
|
118
|
+
TronSignByHashRequired = 11202,
|
|
119
|
+
/** 0xb008 Wallet policy HMAC mismatch or not registered. */
|
|
120
|
+
BtcWalletPolicyHmacMismatch = 11300,
|
|
121
|
+
/** 0xb007 Aborted due to unexpected state (malformed PSBT / missing UTXO). */
|
|
122
|
+
BtcUnexpectedState = 11301
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Device-level failures the SDK cannot self-recover from — affect the entire
|
|
126
|
+
* batch (vs per-chain failures like AppNotInstalled / WrongApp which soft-
|
|
127
|
+
* skip in onboarding). Combined with `accounts.length === 0`, signals
|
|
128
|
+
* genuine orphan. Also reused as the batch-abort whitelist for HWK.
|
|
129
|
+
* Single source of truth.
|
|
130
|
+
*
|
|
131
|
+
* UserRejected (device-side reject) is included: pressing reject is an
|
|
132
|
+
* explicit "I don't consent" — continuing the batch to ask again on the
|
|
133
|
+
* next chain is harassment, not helpful.
|
|
134
|
+
*/
|
|
135
|
+
declare const ORPHAN_ELIGIBLE_ERROR_CODES: number[];
|
|
136
|
+
interface IHwkErrorPayload {
|
|
137
|
+
code: HardwareErrorCode;
|
|
138
|
+
message: string;
|
|
139
|
+
appName?: string;
|
|
140
|
+
_tag?: string;
|
|
141
|
+
params?: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
type HwkError = Error & {
|
|
144
|
+
code: HardwareErrorCode;
|
|
145
|
+
appName?: string;
|
|
146
|
+
_tag?: string;
|
|
147
|
+
params?: Record<string, unknown>;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Canonical throwable for HWK adapters. Plain Error + canonical extra fields,
|
|
151
|
+
* shape-compatible with `rehydrateConnectorError` so locally-thrown and
|
|
152
|
+
* cross-boundary errors are indistinguishable to downstream classifiers
|
|
153
|
+
* (`err.code` / `err._tag` / `err.appName`). Do NOT mutate caught errors
|
|
154
|
+
* with `Object.assign` — construct a fresh one via this factory.
|
|
155
|
+
*/
|
|
156
|
+
declare function createHwkError(payload: IHwkErrorPayload): HwkError;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Enrich a hardware error message with actionable recovery hints.
|
|
160
|
+
* Shared across adapters (Ledger, Trezor, etc.).
|
|
161
|
+
*/
|
|
162
|
+
declare function enrichErrorMessage(code: HardwareErrorCode, originalMessage: string): string;
|
|
163
|
+
|
|
164
|
+
export { HardwareErrorCode, type HwkError, type IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage };
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkQD4EQWQAjs = require('./chunk-QD4EQWQA.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.HardwareErrorCode = _chunkQD4EQWQAjs.HardwareErrorCode; exports.ORPHAN_ELIGIBLE_ERROR_CODES = _chunkQD4EQWQAjs.ORPHAN_ELIGIBLE_ERROR_CODES; exports.createHwkError = _chunkQD4EQWQAjs.createHwkError; exports.enrichErrorMessage = _chunkQD4EQWQAjs.enrichErrorMessage;
|
|
13
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/errors.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACF,+QAAC","file":"/home/runner/work/hardware-js-sdk/hardware-js-sdk/packages/hwk-adapter-core/dist/errors.js"}
|
package/dist/errors.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HardwareErrorCode,
|
|
3
|
+
ORPHAN_ELIGIBLE_ERROR_CODES,
|
|
4
|
+
createHwkError,
|
|
5
|
+
enrichErrorMessage
|
|
6
|
+
} from "./chunk-D5OZT7RZ.mjs";
|
|
7
|
+
export {
|
|
8
|
+
HardwareErrorCode,
|
|
9
|
+
ORPHAN_ELIGIBLE_ERROR_CODES,
|
|
10
|
+
createHwkError,
|
|
11
|
+
enrichErrorMessage
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|