@onekeyfe/hwk-adapter-core 1.2.5 → 1.2.6-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 +583 -104
- package/dist/index.d.ts +583 -104
- package/dist/index.js +642 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +633 -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
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HardwareErrorCode } from './errors.mjs';
|
|
2
|
-
export { HwkError, IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage } from './errors.mjs';
|
|
3
|
-
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-
|
|
4
|
-
export { D as DevicePermissionDeniedReason,
|
|
1
|
+
import { H as HardwareErrorCode, a as HwkErrorOrigin, b as HwkRecoveryHint } from './errors-BgJ4kzRx.mjs';
|
|
2
|
+
export { c as HwkError, d as HwkRecoveryScope, I as IHwkErrorPayload, e as IOperationMayHaveCompletedParams, O as ORPHAN_ELIGIBLE_ERROR_CODES, f as createHwkError, g as defaultOriginForCode, h as defaultRecoveryForCode, i as enrichErrorMessage, j as isHwkRecoveryHint, o as operationMayHaveCompletedParams } from './errors-BgJ4kzRx.mjs';
|
|
3
|
+
import { U as UiResponseEvent, a as UiRequestOperationAttribution, b as UI_REQUEST, Q as QrDisplayData, c as UiRequestRegistry, S as SaveDeviceBindingDeclineReason } from './ui-events-DdttFKj9.mjs';
|
|
4
|
+
export { D as DevicePermissionDeniedReason, d as DevicePermissionResponse, e as QrResponseData, f as UI_EVENT, g as UI_REQUEST_CANCELLED_TAG, h as UI_REQUEST_DEFAULT_TIMEOUT_MS, i as UI_REQUEST_PREEMPTED_TAG, j as UI_REQUEST_TIMEOUT_TAG, k as UI_RESPONSE } from './ui-events-DdttFKj9.mjs';
|
|
5
5
|
|
|
6
6
|
interface Success<T> {
|
|
7
7
|
success: true;
|
|
@@ -12,16 +12,56 @@ interface Failure {
|
|
|
12
12
|
payload: {
|
|
13
13
|
error: string;
|
|
14
14
|
code: HardwareErrorCode;
|
|
15
|
+
/** See HwkErrorOrigin, who the failure came from. Optional so an
|
|
16
|
+
* unclassified failure degrades to code-based handling, never a guess. */
|
|
17
|
+
origin?: HwkErrorOrigin;
|
|
18
|
+
/** Connection-lifecycle recovery semantics. Optional for wire compatibility
|
|
19
|
+
* with SDK versions that predate this field. SDK failure helpers populate it. */
|
|
20
|
+
recovery?: HwkRecoveryHint;
|
|
15
21
|
params?: Record<string, unknown>;
|
|
16
22
|
};
|
|
17
23
|
}
|
|
18
24
|
type Response<T> = Success<T> | Failure;
|
|
19
25
|
declare function success<T>(payload: T): Success<T>;
|
|
20
|
-
declare function failure(code: HardwareErrorCode, error: string, params?: Record<string, unknown
|
|
26
|
+
declare function failure(code: HardwareErrorCode, error: string, params?: Record<string, unknown>, origin?: HwkErrorOrigin, recovery?: HwkRecoveryHint): Failure;
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Fixed derivation paths used to generate chain fingerprints.
|
|
30
|
+
* Uses standard index 0 — Ledger firmware shows device confirmation for
|
|
31
|
+
* non-standard paths (e.g., index=100), which would interrupt wallet creation.
|
|
32
|
+
* The address is hashed into a 16-char fingerprint, not exposed directly.
|
|
33
|
+
* - EVM: cointype 60 (Ledger ETH App only supports 60)
|
|
34
|
+
* - BTC: cointype 1 (testnet)
|
|
35
|
+
* - SOL: cointype 501, standard 3-level hardened
|
|
36
|
+
*/
|
|
37
|
+
declare const CHAIN_FINGERPRINT_PATHS: Record<ChainForFingerprint, string>;
|
|
38
|
+
type ChainForFingerprint = 'evm' | 'btc' | 'sol' | 'tron' | 'zcash';
|
|
39
|
+
/**
|
|
40
|
+
* Parses the complete BIP32 master fingerprint wire value: 4 bytes encoded
|
|
41
|
+
* as exactly 8 hexadecimal characters. This is protocol metadata, not a
|
|
42
|
+
* collision-resistant wallet identity.
|
|
43
|
+
*/
|
|
44
|
+
declare function parseBip32MasterFingerprint(value: unknown): string | undefined;
|
|
45
|
+
/** Four zero bytes is how a missing master fingerprint is encoded; never a wallet identity. */
|
|
46
|
+
declare const MISSING_BIP32_MASTER_FINGERPRINT = "00000000";
|
|
47
|
+
/** A master fingerprint usable as a wallet identity: well-formed and not the missing marker. */
|
|
48
|
+
declare function parseWalletMasterFingerprint(value: unknown): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* 16-char SHA-256 fingerprint for device-identity verification.
|
|
51
|
+
* Callers must canonicalize input (e.g. EVM address → lowercase) —
|
|
52
|
+
* encoding variations otherwise cause false DeviceMismatch.
|
|
53
|
+
*/
|
|
54
|
+
declare function deriveDeviceFingerprint(value: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Domain-separated 256-bit wallet id. Input must be one fixed, vendor-defined public source, never
|
|
57
|
+
* a variable subset of exported accounts, or one wallet would get several ids.
|
|
58
|
+
*/
|
|
59
|
+
declare function deriveWalletId(canonicalPublicMaterial: string): string;
|
|
60
|
+
|
|
61
|
+
type VendorType = 'trezor' | 'ledger' | 'keystone';
|
|
62
|
+
/** 'qr' is a virtual channel: UR payloads travel via app-rendered/scanned QR codes. */
|
|
63
|
+
type ConnectionType = 'usb' | 'ble' | 'qr';
|
|
64
|
+
type TransportType = 'usb' | 'ble' | 'hid' | 'bridge' | 'qr';
|
|
25
65
|
/**
|
|
26
66
|
* Device capabilities — describes what a specific device/connection
|
|
27
67
|
* combination can or cannot do. Varies by vendor, model, and connection type.
|
|
@@ -31,12 +71,8 @@ type TransportType = 'usb' | 'ble' | 'hid' | 'bridge';
|
|
|
31
71
|
*/
|
|
32
72
|
interface DeviceCapabilities {
|
|
33
73
|
/**
|
|
34
|
-
* Whether
|
|
35
|
-
*
|
|
36
|
-
* - `true`: IDs are stable (e.g., OneKey USB, Trezor USB).
|
|
37
|
-
* Business logic can match devices by stored connectId/deviceId.
|
|
38
|
-
* - `false`: IDs are ephemeral, regenerated each session (e.g., Ledger WebHID).
|
|
39
|
-
* Business logic should NOT rely on stored connectId/deviceId for matching.
|
|
74
|
+
* Whether the discovery handle can be reused to reconnect; `false` requires rediscovery. Says
|
|
75
|
+
* nothing about identity (Trezor BLE is false yet its device_id is stable); verify it separately.
|
|
40
76
|
*/
|
|
41
77
|
persistentDeviceIdentity: boolean;
|
|
42
78
|
}
|
|
@@ -73,6 +109,52 @@ interface DeviceTarget {
|
|
|
73
109
|
connectId: string;
|
|
74
110
|
deviceId: string;
|
|
75
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* How long a discovery handle remains safe to use for a new connection.
|
|
114
|
+
* This is deliberately separate from post-connect device identity.
|
|
115
|
+
*/
|
|
116
|
+
type SearchTargetReusePolicy = 'current-discovery' | 'reconnectable' | 'rediscover';
|
|
117
|
+
declare function resolveSearchTargetReusePolicy(device: Pick<DeviceInfo, 'connectionType' | 'capabilities'>): SearchTargetReusePolicy;
|
|
118
|
+
/**
|
|
119
|
+
* A selectable result from hardware discovery. It may represent a physical
|
|
120
|
+
* transport endpoint or an interactive entry such as Keystone QR; it is not a
|
|
121
|
+
* physical-device or wallet identity.
|
|
122
|
+
*/
|
|
123
|
+
interface DeviceSearchTarget {
|
|
124
|
+
/** Opaque handle scoped to the adapter's current discovery state. */
|
|
125
|
+
searchTargetId: string;
|
|
126
|
+
/** Whether the handle itself may be retried; never inferred from a stored connectId. */
|
|
127
|
+
searchTargetReusePolicy?: SearchTargetReusePolicy;
|
|
128
|
+
vendor: VendorType;
|
|
129
|
+
connectionType: ConnectionType;
|
|
130
|
+
kind: 'physical' | 'interactive';
|
|
131
|
+
label?: string;
|
|
132
|
+
model?: string;
|
|
133
|
+
modelName?: string;
|
|
134
|
+
serialNumber?: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @deprecated Use DeviceSearchTarget. Kept for consumers of the pre-release
|
|
138
|
+
* connection-target API.
|
|
139
|
+
*/
|
|
140
|
+
type ConnectionTarget = Omit<DeviceSearchTarget, 'searchTargetId'> & {
|
|
141
|
+
targetId: string;
|
|
142
|
+
searchTargetId?: string;
|
|
143
|
+
};
|
|
144
|
+
type WalletIdentity = {
|
|
145
|
+
vendor: 'ledger';
|
|
146
|
+
type: 'chainFingerprint';
|
|
147
|
+
chain: ChainForFingerprint;
|
|
148
|
+
value: string;
|
|
149
|
+
} | {
|
|
150
|
+
vendor: 'trezor';
|
|
151
|
+
type: 'deviceId';
|
|
152
|
+
value: string;
|
|
153
|
+
} | {
|
|
154
|
+
vendor: 'keystone';
|
|
155
|
+
type: 'walletId';
|
|
156
|
+
value: string;
|
|
157
|
+
};
|
|
76
158
|
|
|
77
159
|
/**
|
|
78
160
|
* Mixin for chain-operation params that can be pinned to a specific passphrase
|
|
@@ -133,6 +215,15 @@ interface ConnectorSession {
|
|
|
133
215
|
sessionId: string;
|
|
134
216
|
deviceInfo: DeviceInfo;
|
|
135
217
|
}
|
|
218
|
+
type ConnectorConnectTarget = {
|
|
219
|
+
type: 'default';
|
|
220
|
+
} | {
|
|
221
|
+
type: 'search-target';
|
|
222
|
+
searchTargetId: string;
|
|
223
|
+
} | {
|
|
224
|
+
type: 'expected-device-identity';
|
|
225
|
+
deviceIdentity: string;
|
|
226
|
+
};
|
|
136
227
|
/**
|
|
137
228
|
* Vendor-agnostic bag of extra error fields. Known keys are documented for
|
|
138
229
|
* discoverability; the index signature keeps it open so any connector can
|
|
@@ -253,12 +344,16 @@ interface ConnectorEventMap {
|
|
|
253
344
|
'ui-event': ConnectorUiEvent;
|
|
254
345
|
}
|
|
255
346
|
interface ConnectorSearchDevicesOptions {
|
|
347
|
+
/** Select a child transport without waking/scanning the others. */
|
|
348
|
+
transportType?: ConnectionType;
|
|
256
349
|
/**
|
|
257
350
|
* Wait for every child transport in a fused connector. Default discovery can
|
|
258
351
|
* return shortly after USB appears so BLE does not slow down USB flows;
|
|
259
352
|
* binding pickers can opt in when they need BLE candidates too.
|
|
260
353
|
*/
|
|
261
354
|
waitForAll?: boolean;
|
|
355
|
+
/** Availability probes must not invalidate user-selectable discovery targets. */
|
|
356
|
+
purpose?: 'selection' | 'availability';
|
|
262
357
|
}
|
|
263
358
|
interface ConnectorConfig {
|
|
264
359
|
/**
|
|
@@ -273,8 +368,16 @@ interface ConnectorConfig {
|
|
|
273
368
|
interface IConnector {
|
|
274
369
|
/** Physical connection type this connector uses. Fixed at construction. */
|
|
275
370
|
readonly connectionType: ConnectionType;
|
|
371
|
+
readonly availableTransports?: readonly ConnectionType[];
|
|
276
372
|
searchDevices(options?: ConnectorSearchDevicesOptions): Promise<ConnectorDevice[]>;
|
|
277
|
-
connect(deviceId?: string
|
|
373
|
+
connect(deviceId?: string, options?: {
|
|
374
|
+
transportType: ConnectionType;
|
|
375
|
+
}): Promise<ConnectorSession>;
|
|
376
|
+
/**
|
|
377
|
+
* Structured form for connectors where a discovery handle and a stable device identity are
|
|
378
|
+
* different concepts. The string form remains for bridge and legacy compatibility.
|
|
379
|
+
*/
|
|
380
|
+
connectTarget?(target: ConnectorConnectTarget): Promise<ConnectorSession>;
|
|
278
381
|
disconnect(sessionId: string): Promise<void>;
|
|
279
382
|
call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
|
|
280
383
|
cancel(sessionId: string): Promise<void>;
|
|
@@ -299,6 +402,9 @@ interface IHardwareBridge {
|
|
|
299
402
|
connect(params: {
|
|
300
403
|
vendor: VendorType;
|
|
301
404
|
deviceId?: string;
|
|
405
|
+
options?: {
|
|
406
|
+
transportType: ConnectionType;
|
|
407
|
+
};
|
|
302
408
|
}): Promise<ConnectorSession>;
|
|
303
409
|
disconnect(params: {
|
|
304
410
|
vendor: VendorType;
|
|
@@ -581,11 +687,21 @@ interface SolSignedTx {
|
|
|
581
687
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
582
688
|
signature: string;
|
|
583
689
|
}
|
|
584
|
-
interface
|
|
690
|
+
interface SolSignMessageBaseParams extends PassphraseStateAware {
|
|
585
691
|
path: string;
|
|
586
692
|
/** Message bytes as hex string (no 0x prefix) */
|
|
587
693
|
message: string;
|
|
588
694
|
}
|
|
695
|
+
interface SolOffchainMessageV1Params {
|
|
696
|
+
/** Finalized Solana off-chain message format. */
|
|
697
|
+
messageVersion: 1;
|
|
698
|
+
/** Complete signer set as 32-byte hex public keys. */
|
|
699
|
+
requiredSigners: string[];
|
|
700
|
+
}
|
|
701
|
+
type SolSignMsgParams = SolSignMessageBaseParams & ({
|
|
702
|
+
messageVersion?: undefined;
|
|
703
|
+
requiredSigners?: undefined;
|
|
704
|
+
} | SolOffchainMessageV1Params);
|
|
589
705
|
interface SolSignature {
|
|
590
706
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
591
707
|
signature: string;
|
|
@@ -712,6 +828,12 @@ interface TronSignMsgParams extends PassphraseStateAware {
|
|
|
712
828
|
path: string;
|
|
713
829
|
/** Message hex (no 0x prefix) */
|
|
714
830
|
messageHex: string;
|
|
831
|
+
/**
|
|
832
|
+
* TRON message scheme: 'V1' = legacy signMessage (prefix + 32-byte hash),
|
|
833
|
+
* 'V2' = TIP-191 signMessageV2 (prefix + byte length + message). Adapters
|
|
834
|
+
* that only implement one scheme reject the other with MethodNotSupported.
|
|
835
|
+
*/
|
|
836
|
+
messageType?: 'V1' | 'V2';
|
|
715
837
|
}
|
|
716
838
|
interface TronSignature {
|
|
717
839
|
/** 65-byte hex-encoded signature (no 0x prefix) */
|
|
@@ -723,100 +845,167 @@ interface ITronMethods {
|
|
|
723
845
|
tronSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignMsgParams>>): Promise<Response<TronSignature>>;
|
|
724
846
|
}
|
|
725
847
|
|
|
726
|
-
/**
|
|
727
|
-
* Fixed derivation paths used to generate chain fingerprints.
|
|
728
|
-
* Uses standard index 0 — Ledger firmware shows device confirmation for
|
|
729
|
-
* non-standard paths (e.g., index=100), which would interrupt wallet creation.
|
|
730
|
-
* The address is hashed into a 16-char fingerprint, not exposed directly.
|
|
731
|
-
* - EVM: cointype 60 (Ledger ETH App only supports 60)
|
|
732
|
-
* - BTC: cointype 1 (testnet)
|
|
733
|
-
* - SOL: cointype 501, standard 3-level hardened
|
|
734
|
-
*/
|
|
735
|
-
declare const CHAIN_FINGERPRINT_PATHS: Record<ChainForFingerprint, string>;
|
|
736
|
-
type ChainForFingerprint = 'evm' | 'btc' | 'sol' | 'tron';
|
|
737
|
-
/**
|
|
738
|
-
* 16-char SHA-256 fingerprint for device-identity verification.
|
|
739
|
-
* Callers must canonicalize input (e.g. EVM address → lowercase) —
|
|
740
|
-
* encoding variations otherwise cause false DeviceMismatch.
|
|
741
|
-
*/
|
|
742
|
-
declare function deriveDeviceFingerprint(value: string): string;
|
|
743
|
-
|
|
744
848
|
/** Events generated by SDK internal detection (not from hardware directly). */
|
|
745
849
|
declare const SDK: {
|
|
746
850
|
readonly DEVICE_STUCK: "device-stuck";
|
|
747
851
|
readonly DEVICE_UNRESPONSIVE: "device-unresponsive";
|
|
748
852
|
readonly DEVICE_RECOVERED: "device-recovered";
|
|
749
853
|
readonly DEVICE_INTERACTION: "device-interaction";
|
|
854
|
+
readonly OPERATION_ENDED: "operation-ended";
|
|
750
855
|
};
|
|
751
856
|
|
|
857
|
+
declare const OPERATION_DEFAULT_TTL_MS = 600000;
|
|
858
|
+
type OperationEndReason = 'explicit' | 'disconnect' | 'timeout' | 'runtime-reset';
|
|
859
|
+
type HardwareOperation = {
|
|
860
|
+
operationId: string;
|
|
861
|
+
connectId: string;
|
|
862
|
+
device: DeviceInfo;
|
|
863
|
+
/**
|
|
864
|
+
* The channel this operation runs on, set by the adapter that picked it. Never read it off
|
|
865
|
+
* `device`: a combined connector fills that snapshot with a nominal value.
|
|
866
|
+
*/
|
|
867
|
+
connectionType: ConnectionType;
|
|
868
|
+
connectionKeys: string[];
|
|
869
|
+
createdAt: number;
|
|
870
|
+
lastActiveAt: number;
|
|
871
|
+
};
|
|
872
|
+
type OperationRegistryOptions = {
|
|
873
|
+
vendor: VendorType;
|
|
874
|
+
ttlMs?: number;
|
|
875
|
+
onEnded?: (operation: HardwareOperation, reason: OperationEndReason) => void;
|
|
876
|
+
};
|
|
877
|
+
/** Runtime-only association between a public operation id and one live target. */
|
|
878
|
+
declare class OperationRegistry {
|
|
879
|
+
private readonly _vendor;
|
|
880
|
+
private readonly _ttlMs;
|
|
881
|
+
private readonly _onEnded?;
|
|
882
|
+
private readonly _active;
|
|
883
|
+
private readonly _ended;
|
|
884
|
+
constructor(options: OperationRegistryOptions);
|
|
885
|
+
create(params: {
|
|
886
|
+
searchTargetId: string;
|
|
887
|
+
connectId: string;
|
|
888
|
+
device: DeviceInfo;
|
|
889
|
+
connectionType: ConnectionType;
|
|
890
|
+
connectionKeys?: string[];
|
|
891
|
+
}): HardwareOperation;
|
|
892
|
+
resolve(operationId: string): HardwareOperation;
|
|
893
|
+
/** Keep an operation alive while one device job is actively using it. */
|
|
894
|
+
retain(operationId: string): () => void;
|
|
895
|
+
/** Return active or tombstoned binding data without refreshing its TTL. */
|
|
896
|
+
find(operationId: string): HardwareOperation | undefined;
|
|
897
|
+
findActiveByConnectionKey(connectionKey: string): HardwareOperation | undefined;
|
|
898
|
+
/** Replace the live transport binding after the same target was reconnected. */
|
|
899
|
+
rebind(operationId: string, params: {
|
|
900
|
+
connectId: string;
|
|
901
|
+
device: DeviceInfo;
|
|
902
|
+
connectionType: ConnectionType;
|
|
903
|
+
connectionKeys?: string[];
|
|
904
|
+
}): HardwareOperation;
|
|
905
|
+
end(operationId: string, reason: OperationEndReason): HardwareOperation | undefined;
|
|
906
|
+
endByConnectionKey(connectionKey: string, reason: OperationEndReason, exceptOperationId?: string): void;
|
|
907
|
+
endAll(reason: OperationEndReason, exceptOperationId?: string): void;
|
|
908
|
+
private _touch;
|
|
909
|
+
private _createTimer;
|
|
910
|
+
private _rememberEnded;
|
|
911
|
+
}
|
|
912
|
+
|
|
752
913
|
type HardwareMethodMetadata = {
|
|
753
914
|
chain: ChainForFingerprint;
|
|
754
915
|
allNetwork: boolean;
|
|
916
|
+
/** Whether repeating the method after an ambiguous transport failure is safe. */
|
|
917
|
+
replayAfterTransportFailure: 'safe' | 'unsafe';
|
|
755
918
|
};
|
|
756
919
|
declare const HARDWARE_METHOD_CATALOG: {
|
|
757
920
|
readonly evmGetAddress: {
|
|
758
921
|
readonly chain: "evm";
|
|
759
922
|
readonly allNetwork: true;
|
|
923
|
+
readonly replayAfterTransportFailure: "safe";
|
|
760
924
|
};
|
|
761
925
|
readonly evmSignTransaction: {
|
|
762
926
|
readonly chain: "evm";
|
|
763
927
|
readonly allNetwork: false;
|
|
928
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
764
929
|
};
|
|
765
930
|
readonly evmSignMessage: {
|
|
766
931
|
readonly chain: "evm";
|
|
767
932
|
readonly allNetwork: false;
|
|
933
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
768
934
|
};
|
|
769
935
|
readonly evmSignTypedData: {
|
|
770
936
|
readonly chain: "evm";
|
|
771
937
|
readonly allNetwork: false;
|
|
938
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
772
939
|
};
|
|
773
940
|
readonly btcGetAddress: {
|
|
774
941
|
readonly chain: "btc";
|
|
775
942
|
readonly allNetwork: true;
|
|
943
|
+
readonly replayAfterTransportFailure: "safe";
|
|
776
944
|
};
|
|
777
945
|
readonly btcGetPublicKey: {
|
|
778
946
|
readonly chain: "btc";
|
|
779
947
|
readonly allNetwork: true;
|
|
948
|
+
readonly replayAfterTransportFailure: "safe";
|
|
780
949
|
};
|
|
781
950
|
readonly btcSignTransaction: {
|
|
782
951
|
readonly chain: "btc";
|
|
783
952
|
readonly allNetwork: false;
|
|
953
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
784
954
|
};
|
|
785
955
|
readonly btcSignPsbt: {
|
|
786
956
|
readonly chain: "btc";
|
|
787
957
|
readonly allNetwork: false;
|
|
958
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
788
959
|
};
|
|
789
960
|
readonly btcSignMessage: {
|
|
790
961
|
readonly chain: "btc";
|
|
791
962
|
readonly allNetwork: false;
|
|
963
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
792
964
|
};
|
|
793
965
|
readonly btcGetMasterFingerprint: {
|
|
794
966
|
readonly chain: "btc";
|
|
795
967
|
readonly allNetwork: false;
|
|
968
|
+
readonly replayAfterTransportFailure: "safe";
|
|
796
969
|
};
|
|
797
970
|
readonly solGetAddress: {
|
|
798
971
|
readonly chain: "sol";
|
|
799
972
|
readonly allNetwork: true;
|
|
973
|
+
readonly replayAfterTransportFailure: "safe";
|
|
800
974
|
};
|
|
801
975
|
readonly solSignTransaction: {
|
|
802
976
|
readonly chain: "sol";
|
|
803
977
|
readonly allNetwork: false;
|
|
978
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
804
979
|
};
|
|
805
980
|
readonly solSignMessage: {
|
|
806
981
|
readonly chain: "sol";
|
|
807
982
|
readonly allNetwork: false;
|
|
983
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
808
984
|
};
|
|
809
985
|
readonly tronGetAddress: {
|
|
810
986
|
readonly chain: "tron";
|
|
811
987
|
readonly allNetwork: true;
|
|
988
|
+
readonly replayAfterTransportFailure: "safe";
|
|
812
989
|
};
|
|
813
990
|
readonly tronSignTransaction: {
|
|
814
991
|
readonly chain: "tron";
|
|
815
992
|
readonly allNetwork: false;
|
|
993
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
816
994
|
};
|
|
817
995
|
readonly tronSignMessage: {
|
|
818
996
|
readonly chain: "tron";
|
|
819
997
|
readonly allNetwork: false;
|
|
998
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
999
|
+
};
|
|
1000
|
+
readonly zcashGetFullViewingKey: {
|
|
1001
|
+
readonly chain: "zcash";
|
|
1002
|
+
readonly allNetwork: false;
|
|
1003
|
+
readonly replayAfterTransportFailure: "safe";
|
|
1004
|
+
};
|
|
1005
|
+
readonly zcashGetShieldedAddress: {
|
|
1006
|
+
readonly chain: "zcash";
|
|
1007
|
+
readonly allNetwork: false;
|
|
1008
|
+
readonly replayAfterTransportFailure: "safe";
|
|
820
1009
|
};
|
|
821
1010
|
};
|
|
822
1011
|
type HardwareMethodName = keyof typeof HARDWARE_METHOD_CATALOG;
|
|
@@ -825,6 +1014,11 @@ type AllNetworkMethodName = {
|
|
|
825
1014
|
}[HardwareMethodName];
|
|
826
1015
|
declare const ALL_NETWORK_METHOD_NAMES: AllNetworkMethodName[];
|
|
827
1016
|
declare function getHardwareMethodMetadata(method: string): HardwareMethodMetadata | undefined;
|
|
1017
|
+
/**
|
|
1018
|
+
* Conservative replay gate used only after a call may have reached hardware.
|
|
1019
|
+
* Unknown methods and device mutations are unsafe by default.
|
|
1020
|
+
*/
|
|
1021
|
+
declare function canReplayHardwareMethodAfterTransportFailure(method: string): boolean;
|
|
828
1022
|
declare function isAllNetworkMethodName(method: string): method is AllNetworkMethodName;
|
|
829
1023
|
declare function getAllNetworkMethodChain(method: AllNetworkMethodName): ChainForFingerprint;
|
|
830
1024
|
|
|
@@ -843,7 +1037,7 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
|
|
|
843
1037
|
progress: number;
|
|
844
1038
|
};
|
|
845
1039
|
};
|
|
846
|
-
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron';
|
|
1040
|
+
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron' | 'zcash';
|
|
847
1041
|
type TrezorDisplayRotation = 'North' | 'East' | 'South' | 'West';
|
|
848
1042
|
type TrezorSafetyCheckLevel = 'Strict' | 'PromptAlways' | 'PromptTemporarily';
|
|
849
1043
|
type TrezorDeviceSettingsParams = {
|
|
@@ -914,19 +1108,77 @@ type DeviceAuthenticityResult = {
|
|
|
914
1108
|
};
|
|
915
1109
|
};
|
|
916
1110
|
};
|
|
1111
|
+
/** Persisted connection hints, never proof of device or wallet identity. */
|
|
1112
|
+
type KnownDeviceConnection = {
|
|
1113
|
+
transport: 'usb' | 'ble';
|
|
1114
|
+
connectId: string;
|
|
1115
|
+
} | {
|
|
1116
|
+
transport: 'qr';
|
|
1117
|
+
};
|
|
1118
|
+
/** Opaque host lookup identifiers. Never forward these to firmware or logs. */
|
|
1119
|
+
type HardwareCallExtra = Readonly<Record<string, string>>;
|
|
1120
|
+
interface IHardwareConnectionContext {
|
|
1121
|
+
knownConnections?: readonly KnownDeviceConnection[];
|
|
1122
|
+
extra?: HardwareCallExtra;
|
|
1123
|
+
/** False makes discovery fail instead of asking the user to select a new endpoint. */
|
|
1124
|
+
allowDeviceSelection?: boolean;
|
|
1125
|
+
/** Transports the host's model table allows; discovery never opens others. Omitted = any. */
|
|
1126
|
+
supportedTransports?: readonly ('usb' | 'ble')[];
|
|
1127
|
+
}
|
|
1128
|
+
type DeviceSelectionContext = {
|
|
1129
|
+
kind: 'select-device';
|
|
1130
|
+
transport: 'usb';
|
|
1131
|
+
reason: 'multiple-candidates';
|
|
1132
|
+
} | {
|
|
1133
|
+
kind: 'bind-connection';
|
|
1134
|
+
transport: 'ble';
|
|
1135
|
+
reason: 'missing-binding' | 'known-connection-unavailable' | 'manual-rebind';
|
|
1136
|
+
};
|
|
1137
|
+
interface DeviceSelectionRequest extends UiRequestOperationAttribution {
|
|
1138
|
+
devices: DeviceInfo[];
|
|
1139
|
+
requestId: string;
|
|
1140
|
+
context: DeviceSelectionContext;
|
|
1141
|
+
extra?: HardwareCallExtra;
|
|
1142
|
+
/** Repeated snapshots with this requestId update one SDK-owned binding scan. */
|
|
1143
|
+
scanning?: boolean;
|
|
1144
|
+
bindingSessionId?: string;
|
|
1145
|
+
/** A candidate rejected by SDK identity verification in this binding session. */
|
|
1146
|
+
rejectedConnectId?: string;
|
|
1147
|
+
}
|
|
1148
|
+
/** The host must persist this endpoint before acknowledging. */
|
|
1149
|
+
interface SaveDeviceBindingRequest extends UiRequestOperationAttribution {
|
|
1150
|
+
requestId: string;
|
|
1151
|
+
selectionRequestId: string;
|
|
1152
|
+
connection: {
|
|
1153
|
+
transport: 'ble';
|
|
1154
|
+
connectId: string;
|
|
1155
|
+
};
|
|
1156
|
+
/** Omitted when the vendor binds the selected BLE endpoint without checking its wallet (Ledger). */
|
|
1157
|
+
identity?: Extract<WalletIdentity, {
|
|
1158
|
+
vendor: 'ledger' | 'trezor';
|
|
1159
|
+
}>;
|
|
1160
|
+
extra?: HardwareCallExtra;
|
|
1161
|
+
}
|
|
1162
|
+
type BindBleDeviceParams = Pick<SaveDeviceBindingRequest, 'identity' | 'extra'>;
|
|
1163
|
+
interface DeviceBindingStatus {
|
|
1164
|
+
selectionRequestId: string;
|
|
1165
|
+
status: 'verifying' | 'saved' | 'failed' | 'cancelled';
|
|
1166
|
+
}
|
|
917
1167
|
/**
|
|
918
1168
|
* Cross-chain / cross-vendor options passed alongside any chain method's
|
|
919
1169
|
* own params (the optional last argument). Holds operation-level switches
|
|
920
1170
|
* that aren't specific to one chain. Vendor-specific options can be added
|
|
921
1171
|
* as typed sub-fields here when a vendor actually needs them.
|
|
922
1172
|
*/
|
|
923
|
-
interface ICommonCallParams {
|
|
1173
|
+
interface ICommonCallParams extends IHardwareConnectionContext {
|
|
924
1174
|
/**
|
|
925
1175
|
* When the required device app is missing, prompt the user (UI request)
|
|
926
1176
|
* to install it, stream install progress, then retry the operation once.
|
|
927
1177
|
* Off by default — preserves the plain "app not installed" failure.
|
|
928
1178
|
*/
|
|
929
1179
|
autoInstallApp?: boolean;
|
|
1180
|
+
/** Runtime-only id from connectDevice(); when present, discovery and fallback are disabled. */
|
|
1181
|
+
operationId?: string;
|
|
930
1182
|
}
|
|
931
1183
|
type NullableCallArg<T> = T | null | undefined;
|
|
932
1184
|
interface IPassphraseCallParams {
|
|
@@ -935,6 +1187,14 @@ interface IPassphraseCallParams {
|
|
|
935
1187
|
}
|
|
936
1188
|
type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
|
|
937
1189
|
type IHardwareCallParams<T> = T & IHardwareCommonCallParams;
|
|
1190
|
+
/**
|
|
1191
|
+
* Runtime-only device-manager context, never forwarded to firmware. The expected identity lets an
|
|
1192
|
+
* adapter fail closed before replaying a read or mutation after a reconnect.
|
|
1193
|
+
*/
|
|
1194
|
+
interface IDeviceManagerOperationContext extends IHardwareConnectionContext {
|
|
1195
|
+
operationId?: string;
|
|
1196
|
+
expectedDeviceIdentity?: WalletIdentity;
|
|
1197
|
+
}
|
|
938
1198
|
interface AllNetworkAddressParams {
|
|
939
1199
|
network: string;
|
|
940
1200
|
path: string;
|
|
@@ -945,16 +1205,7 @@ interface AllNetworkAddressParams {
|
|
|
945
1205
|
interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
|
|
946
1206
|
bundle: AllNetworkAddressParams[];
|
|
947
1207
|
}
|
|
948
|
-
type AllNetworkDeviceIdentity =
|
|
949
|
-
vendor: 'ledger';
|
|
950
|
-
type: 'chainFingerprint';
|
|
951
|
-
chain: ChainForFingerprint;
|
|
952
|
-
value: string;
|
|
953
|
-
} | {
|
|
954
|
-
vendor: 'trezor';
|
|
955
|
-
type: 'deviceId';
|
|
956
|
-
value: string;
|
|
957
|
-
};
|
|
1208
|
+
type AllNetworkDeviceIdentity = WalletIdentity;
|
|
958
1209
|
type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
959
1210
|
error?: string;
|
|
960
1211
|
code?: HardwareErrorCode | number;
|
|
@@ -962,6 +1213,7 @@ type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
|
962
1213
|
connectId?: string;
|
|
963
1214
|
deviceId?: string;
|
|
964
1215
|
deviceIdentity?: AllNetworkDeviceIdentity;
|
|
1216
|
+
rootFingerprint?: number;
|
|
965
1217
|
chainFingerprint?: string;
|
|
966
1218
|
chainFingerprintChain?: ChainForFingerprint;
|
|
967
1219
|
params?: Record<string, unknown>;
|
|
@@ -1010,46 +1262,50 @@ type UiRequestEvent = {
|
|
|
1010
1262
|
device?: DeviceInfo;
|
|
1011
1263
|
connectId?: string;
|
|
1012
1264
|
type?: string;
|
|
1013
|
-
};
|
|
1265
|
+
} & UiRequestOperationAttribution;
|
|
1014
1266
|
} | {
|
|
1015
1267
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
1016
1268
|
payload: {
|
|
1017
1269
|
device: DeviceInfo;
|
|
1018
|
-
};
|
|
1270
|
+
} & UiRequestOperationAttribution;
|
|
1019
1271
|
} | {
|
|
1020
1272
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1021
1273
|
payload: {
|
|
1022
1274
|
device: DeviceInfo;
|
|
1023
|
-
};
|
|
1275
|
+
} & UiRequestOperationAttribution;
|
|
1024
1276
|
} | {
|
|
1025
1277
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1026
1278
|
payload: {
|
|
1027
1279
|
device: DeviceInfo;
|
|
1028
1280
|
code?: string;
|
|
1029
|
-
};
|
|
1281
|
+
} & UiRequestOperationAttribution;
|
|
1030
1282
|
} | {
|
|
1031
1283
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1032
1284
|
payload: {
|
|
1033
1285
|
device: DeviceInfo;
|
|
1034
1286
|
data: QrDisplayData;
|
|
1035
|
-
};
|
|
1287
|
+
} & UiRequestOperationAttribution;
|
|
1036
1288
|
} | {
|
|
1037
1289
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1038
1290
|
payload: {
|
|
1039
1291
|
device: DeviceInfo;
|
|
1040
|
-
};
|
|
1292
|
+
} & UiRequestOperationAttribution;
|
|
1041
1293
|
} | {
|
|
1042
1294
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
1043
1295
|
payload: {
|
|
1044
1296
|
transportType: TransportType;
|
|
1045
1297
|
connectId?: string;
|
|
1046
1298
|
deviceId?: string;
|
|
1047
|
-
};
|
|
1299
|
+
} & UiRequestOperationAttribution;
|
|
1048
1300
|
} | {
|
|
1049
1301
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1050
|
-
payload:
|
|
1051
|
-
|
|
1052
|
-
|
|
1302
|
+
payload: DeviceSelectionRequest;
|
|
1303
|
+
} | {
|
|
1304
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1305
|
+
payload: SaveDeviceBindingRequest;
|
|
1306
|
+
} | {
|
|
1307
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1308
|
+
payload: DeviceBindingStatus;
|
|
1053
1309
|
} | {
|
|
1054
1310
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
1055
1311
|
payload: {
|
|
@@ -1069,13 +1325,13 @@ type UiRequestEvent = {
|
|
|
1069
1325
|
* isn't recognized.
|
|
1070
1326
|
*/
|
|
1071
1327
|
message: string;
|
|
1072
|
-
};
|
|
1328
|
+
} & UiRequestOperationAttribution;
|
|
1073
1329
|
} | {
|
|
1074
1330
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1075
1331
|
payload: {
|
|
1076
1332
|
vendor: string;
|
|
1077
1333
|
appName: string;
|
|
1078
|
-
};
|
|
1334
|
+
} & UiRequestOperationAttribution;
|
|
1079
1335
|
} | {
|
|
1080
1336
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
1081
1337
|
payload: {
|
|
@@ -1083,10 +1339,10 @@ type UiRequestEvent = {
|
|
|
1083
1339
|
availableMethods: number[];
|
|
1084
1340
|
selectedMethod: number;
|
|
1085
1341
|
nfcData?: string;
|
|
1086
|
-
};
|
|
1342
|
+
} & UiRequestOperationAttribution;
|
|
1087
1343
|
} | {
|
|
1088
1344
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1089
|
-
payload:
|
|
1345
|
+
payload: UiRequestOperationAttribution;
|
|
1090
1346
|
};
|
|
1091
1347
|
type SdkEvent = {
|
|
1092
1348
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1109,6 +1365,12 @@ type SdkEvent = {
|
|
|
1109
1365
|
payload: {
|
|
1110
1366
|
connectId: string;
|
|
1111
1367
|
};
|
|
1368
|
+
} | {
|
|
1369
|
+
type: typeof SDK.OPERATION_ENDED;
|
|
1370
|
+
payload: {
|
|
1371
|
+
operationId: string;
|
|
1372
|
+
reason: OperationEndReason;
|
|
1373
|
+
};
|
|
1112
1374
|
};
|
|
1113
1375
|
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent | HardwareUiEvent;
|
|
1114
1376
|
type DeviceEventListener = (event: HardwareEvent) => void;
|
|
@@ -1119,6 +1381,14 @@ type DeviceEventListener = (event: HardwareEvent) => void;
|
|
|
1119
1381
|
* and the value is the narrowed event object the listener will receive.
|
|
1120
1382
|
*/
|
|
1121
1383
|
interface HardwareEventMap {
|
|
1384
|
+
[UI_REQUEST.DEVICE_BINDING_STATUS]: {
|
|
1385
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1386
|
+
payload: DeviceBindingStatus;
|
|
1387
|
+
};
|
|
1388
|
+
[UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING]: {
|
|
1389
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1390
|
+
payload: SaveDeviceBindingRequest;
|
|
1391
|
+
};
|
|
1122
1392
|
'ui-event': HardwareUiEvent;
|
|
1123
1393
|
[DEVICE.CONNECT]: {
|
|
1124
1394
|
type: typeof DEVICE.CONNECT;
|
|
@@ -1159,7 +1429,7 @@ interface HardwareEventMap {
|
|
|
1159
1429
|
device?: DeviceInfo;
|
|
1160
1430
|
connectId?: string;
|
|
1161
1431
|
type?: string;
|
|
1162
|
-
};
|
|
1432
|
+
} & UiRequestOperationAttribution;
|
|
1163
1433
|
};
|
|
1164
1434
|
[UI_REQUEST.REQUEST_PASSPHRASE]: {
|
|
1165
1435
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
@@ -1168,33 +1438,33 @@ interface HardwareEventMap {
|
|
|
1168
1438
|
connectId?: string;
|
|
1169
1439
|
passphraseState?: string;
|
|
1170
1440
|
useEmptyPassphrase?: boolean;
|
|
1171
|
-
};
|
|
1441
|
+
} & UiRequestOperationAttribution;
|
|
1172
1442
|
};
|
|
1173
1443
|
[UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
|
|
1174
1444
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1175
1445
|
payload: {
|
|
1176
1446
|
device: DeviceInfo;
|
|
1177
|
-
};
|
|
1447
|
+
} & UiRequestOperationAttribution;
|
|
1178
1448
|
};
|
|
1179
1449
|
[UI_REQUEST.REQUEST_BUTTON]: {
|
|
1180
1450
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1181
1451
|
payload: {
|
|
1182
1452
|
device: DeviceInfo;
|
|
1183
1453
|
code?: string;
|
|
1184
|
-
};
|
|
1454
|
+
} & UiRequestOperationAttribution;
|
|
1185
1455
|
};
|
|
1186
1456
|
[UI_REQUEST.REQUEST_QR_DISPLAY]: {
|
|
1187
1457
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1188
1458
|
payload: {
|
|
1189
1459
|
device: DeviceInfo;
|
|
1190
1460
|
data: QrDisplayData;
|
|
1191
|
-
};
|
|
1461
|
+
} & UiRequestOperationAttribution;
|
|
1192
1462
|
};
|
|
1193
1463
|
[UI_REQUEST.REQUEST_QR_SCAN]: {
|
|
1194
1464
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1195
1465
|
payload: {
|
|
1196
1466
|
device: DeviceInfo;
|
|
1197
|
-
};
|
|
1467
|
+
} & UiRequestOperationAttribution;
|
|
1198
1468
|
};
|
|
1199
1469
|
[UI_REQUEST.REQUEST_DEVICE_PERMISSION]: {
|
|
1200
1470
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
@@ -1202,13 +1472,11 @@ interface HardwareEventMap {
|
|
|
1202
1472
|
transportType: TransportType;
|
|
1203
1473
|
connectId?: string;
|
|
1204
1474
|
deviceId?: string;
|
|
1205
|
-
};
|
|
1475
|
+
} & UiRequestOperationAttribution;
|
|
1206
1476
|
};
|
|
1207
1477
|
[UI_REQUEST.REQUEST_SELECT_DEVICE]: {
|
|
1208
1478
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1209
|
-
payload:
|
|
1210
|
-
devices: DeviceInfo[];
|
|
1211
|
-
};
|
|
1479
|
+
payload: DeviceSelectionRequest;
|
|
1212
1480
|
};
|
|
1213
1481
|
[UI_REQUEST.REQUEST_DEVICE_CONNECT]: {
|
|
1214
1482
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
@@ -1216,7 +1484,7 @@ interface HardwareEventMap {
|
|
|
1216
1484
|
vendor: string;
|
|
1217
1485
|
reason: string;
|
|
1218
1486
|
message: string;
|
|
1219
|
-
};
|
|
1487
|
+
} & UiRequestOperationAttribution;
|
|
1220
1488
|
};
|
|
1221
1489
|
[UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM]: {
|
|
1222
1490
|
type: typeof UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM;
|
|
@@ -1224,14 +1492,14 @@ interface HardwareEventMap {
|
|
|
1224
1492
|
vendor: string;
|
|
1225
1493
|
path: string;
|
|
1226
1494
|
accountIndex: number;
|
|
1227
|
-
};
|
|
1495
|
+
} & UiRequestOperationAttribution;
|
|
1228
1496
|
};
|
|
1229
1497
|
[UI_REQUEST.REQUEST_INSTALL_APP]: {
|
|
1230
1498
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1231
1499
|
payload: {
|
|
1232
1500
|
vendor: string;
|
|
1233
1501
|
appName: string;
|
|
1234
|
-
};
|
|
1502
|
+
} & UiRequestOperationAttribution;
|
|
1235
1503
|
};
|
|
1236
1504
|
[UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
|
|
1237
1505
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
@@ -1240,11 +1508,11 @@ interface HardwareEventMap {
|
|
|
1240
1508
|
availableMethods: number[];
|
|
1241
1509
|
selectedMethod: number;
|
|
1242
1510
|
nfcData?: string;
|
|
1243
|
-
};
|
|
1511
|
+
} & UiRequestOperationAttribution;
|
|
1244
1512
|
};
|
|
1245
1513
|
[UI_REQUEST.CLOSE_UI_WINDOW]: {
|
|
1246
1514
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1247
|
-
payload:
|
|
1515
|
+
payload: UiRequestOperationAttribution;
|
|
1248
1516
|
};
|
|
1249
1517
|
[SDK.DEVICE_INTERACTION]: {
|
|
1250
1518
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1271,16 +1539,23 @@ interface HardwareEventMap {
|
|
|
1271
1539
|
connectId: string;
|
|
1272
1540
|
};
|
|
1273
1541
|
};
|
|
1542
|
+
[SDK.OPERATION_ENDED]: {
|
|
1543
|
+
type: typeof SDK.OPERATION_ENDED;
|
|
1544
|
+
payload: {
|
|
1545
|
+
operationId: string;
|
|
1546
|
+
reason: OperationEndReason;
|
|
1547
|
+
};
|
|
1548
|
+
};
|
|
1274
1549
|
}
|
|
1275
1550
|
interface IDeviceManagerMethods {
|
|
1276
|
-
getFeatures?(connectId: string): Promise<Response<Record<string, unknown>>>;
|
|
1277
|
-
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams): Promise<Response<Record<string, unknown>>>;
|
|
1278
|
-
setBrightness?(connectId: string, params?: TrezorBrightnessParams): Promise<Response<Record<string, unknown>>>;
|
|
1279
|
-
changePin?(connectId: string, params?: TrezorChangePinParams): Promise<Response<Record<string, unknown>>>;
|
|
1280
|
-
wipeDevice?(connectId: string): Promise<Response<Record<string, unknown>>>;
|
|
1551
|
+
getFeatures?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1552
|
+
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1553
|
+
setBrightness?(connectId: string, params?: TrezorBrightnessParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1554
|
+
changePin?(connectId: string, params?: TrezorChangePinParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1555
|
+
wipeDevice?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1281
1556
|
authenticateDevice?(connectId: string, params: {
|
|
1282
1557
|
challenge: string;
|
|
1283
|
-
}): Promise<Response<Record<string, unknown>>>;
|
|
1558
|
+
}, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1284
1559
|
}
|
|
1285
1560
|
interface IWalletStateMethods {
|
|
1286
1561
|
/**
|
|
@@ -1307,20 +1582,37 @@ interface IWalletStateMethods {
|
|
|
1307
1582
|
* Optional: vendors without host-managed passphrase sessions (Ledger) omit
|
|
1308
1583
|
* it. Implemented by `TrezorAdapter`.
|
|
1309
1584
|
*/
|
|
1310
|
-
getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
|
|
1585
|
+
getPassphraseState?(connectId: string, passphraseState?: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<string | null>>;
|
|
1311
1586
|
}
|
|
1587
|
+
/**
|
|
1588
|
+
* `stops-waiting`: an on-device confirmation stays up until answered or timed out.
|
|
1589
|
+
* `interrupts-device`: the command on the wire is withdrawn. No vendor reports it, so hosts
|
|
1590
|
+
* should say "stopped waiting, answer on the device", not "cancelled".
|
|
1591
|
+
*/
|
|
1592
|
+
type CancelCapability = 'interrupts-device' | 'stops-waiting';
|
|
1312
1593
|
interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
|
|
1313
1594
|
readonly vendor: string;
|
|
1314
1595
|
readonly activeTransport: TransportType | null;
|
|
1596
|
+
/** What `cancel()` reaches on this vendor. Declared, never inferred. */
|
|
1597
|
+
readonly cancelCapability: CancelCapability;
|
|
1315
1598
|
init(config: TConfig): Promise<void>;
|
|
1316
1599
|
dispose(): Promise<void>;
|
|
1317
1600
|
getAvailableTransports(): TransportType[];
|
|
1318
1601
|
switchTransport(type: TransportType): Promise<void>;
|
|
1319
1602
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
1320
|
-
|
|
1321
|
-
|
|
1603
|
+
/** Discover selectable hardware entries without claiming identified devices or wallets. */
|
|
1604
|
+
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
1605
|
+
/** @deprecated Use searchDeviceTargets(). */
|
|
1606
|
+
listConnectionTargets(options?: SearchDevicesOptions): Promise<ConnectionTarget[]>;
|
|
1607
|
+
/** Connect or logically bind a selected search result and return a runtime-only operation id. */
|
|
1608
|
+
connectDevice(searchTargetId: string): Promise<Response<string>>;
|
|
1609
|
+
/** Device Manager rebind: verify the existing identity before replacing its BLE locator. */
|
|
1610
|
+
bindBleDevice?(params: BindBleDeviceParams): Promise<Response<string>>;
|
|
1611
|
+
/** Resolve and pin operation routing; the caller verifies wallet identity before business calls. */
|
|
1612
|
+
acquireOperation?(connectId: string, context: IHardwareConnectionContext): Promise<Response<string>>;
|
|
1613
|
+
/** Release a caller-owned operation. Disconnect events end matching operations automatically. */
|
|
1614
|
+
releaseOperation(operationId: string): Promise<void>;
|
|
1322
1615
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
1323
|
-
getSupportedChains(): ChainCapability[];
|
|
1324
1616
|
/** Abort the in-flight call. Omit connectId to cancel whatever is active. */
|
|
1325
1617
|
cancel(connectId?: string): void;
|
|
1326
1618
|
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
@@ -1357,6 +1649,11 @@ interface SearchDevicesOptions {
|
|
|
1357
1649
|
* was discovered first.
|
|
1358
1650
|
*/
|
|
1359
1651
|
waitForAllTransports?: boolean;
|
|
1652
|
+
/**
|
|
1653
|
+
* Restrict discovery to one transport. A virtual target (Keystone QR) must not start any wallet
|
|
1654
|
+
* interaction during discovery; `connectDevice()` resolves it.
|
|
1655
|
+
*/
|
|
1656
|
+
transportType?: ConnectionType;
|
|
1360
1657
|
}
|
|
1361
1658
|
|
|
1362
1659
|
interface EvmGetAddressParams extends PassphraseStateAware {
|
|
@@ -1480,6 +1777,11 @@ interface EvmSignTypedDataFull extends PassphraseStateAware {
|
|
|
1480
1777
|
primaryType: string;
|
|
1481
1778
|
message: Record<string, unknown>;
|
|
1482
1779
|
};
|
|
1780
|
+
/**
|
|
1781
|
+
* The dApp's original EIP-712 JSON, byte for byte. Serializing vendors (Keystone) must prefer it:
|
|
1782
|
+
* re-stringifying `data` rewrites integers wider than 2^53 and exponent forms.
|
|
1783
|
+
*/
|
|
1784
|
+
dataJson?: string;
|
|
1483
1785
|
metamaskV4Compat?: boolean;
|
|
1484
1786
|
showMessageHash?: boolean;
|
|
1485
1787
|
/**
|
|
@@ -1518,6 +1820,33 @@ interface IEvmMethods {
|
|
|
1518
1820
|
evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
|
|
1519
1821
|
}
|
|
1520
1822
|
|
|
1823
|
+
/** Which `GET_VK` encoding the Ledger Zcash app should return. */
|
|
1824
|
+
type ZcashFullViewingKeyMode = 'ufvk' | 'orchardFvk';
|
|
1825
|
+
interface ZcashGetFullViewingKeyParams extends PassphraseStateAware {
|
|
1826
|
+
/** BIP44 account path `m/44'/133'/a'`; a deeper transparent path is accepted, only `a'` is used. */
|
|
1827
|
+
path: string;
|
|
1828
|
+
/** Default `ufvk`. */
|
|
1829
|
+
mode?: ZcashFullViewingKeyMode;
|
|
1830
|
+
}
|
|
1831
|
+
interface ZcashFullViewingKey {
|
|
1832
|
+
path: string;
|
|
1833
|
+
mode: ZcashFullViewingKeyMode;
|
|
1834
|
+
/** ZIP-316 bech32m UFVK string (mode `ufvk`). */
|
|
1835
|
+
ufvk?: string;
|
|
1836
|
+
/** 96-byte raw Orchard FVK as hex (mode `orchardFvk`). */
|
|
1837
|
+
orchardFvk?: string;
|
|
1838
|
+
}
|
|
1839
|
+
interface ZcashGetShieldedAddressParams extends PassphraseStateAware {
|
|
1840
|
+
/** Full 5-level transparent path `m/44'/133'/a'/0/i`; the Orchard path is derived from it. */
|
|
1841
|
+
path: string;
|
|
1842
|
+
showOnDevice?: boolean;
|
|
1843
|
+
}
|
|
1844
|
+
interface ZcashShieldedAddress {
|
|
1845
|
+
/** Unified address with a single Orchard receiver. */
|
|
1846
|
+
address: string;
|
|
1847
|
+
path: string;
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1521
1850
|
/**
|
|
1522
1851
|
* Low-level device descriptor from Transport layer.
|
|
1523
1852
|
* Represents a physical device detected by USB/BLE scanning.
|
|
@@ -1563,14 +1892,13 @@ interface DeviceDisconnectEvent {
|
|
|
1563
1892
|
type DeviceChangeEvent = DeviceConnectEvent | DeviceDisconnectEvent;
|
|
1564
1893
|
|
|
1565
1894
|
/**
|
|
1566
|
-
*
|
|
1567
|
-
*
|
|
1568
|
-
*
|
|
1569
|
-
*
|
|
1570
|
-
*
|
|
1571
|
-
*
|
|
1572
|
-
*
|
|
1573
|
-
* synchronously, without racing against in-flight enqueues.
|
|
1895
|
+
* Serializes every device call and gives callers one handle to cancel them. Ordering is already
|
|
1896
|
+
* guaranteed by awaiting callers, so what this adds is an AbortController per job, a busy check
|
|
1897
|
+
* that rejects double-submits, and generation tracking so a job queued before a teardown doesn't
|
|
1898
|
+
* start after it; these races exist even for a sequential caller because cleanup is async.
|
|
1899
|
+
*
|
|
1900
|
+
* Interrupt-or-ask policy belongs to the caller; `getActiveJob()` is synchronous so a UI handler
|
|
1901
|
+
* can look, decide, and submit in one turn without racing an in-flight enqueue.
|
|
1574
1902
|
*/
|
|
1575
1903
|
interface JobOptions {
|
|
1576
1904
|
label?: string;
|
|
@@ -1582,10 +1910,15 @@ interface ActiveJobInfo {
|
|
|
1582
1910
|
label?: string;
|
|
1583
1911
|
startedAt: number;
|
|
1584
1912
|
}
|
|
1913
|
+
interface CancelScopeHandle {
|
|
1914
|
+
signal: AbortSignal;
|
|
1915
|
+
release: () => void;
|
|
1916
|
+
}
|
|
1585
1917
|
declare class DeviceJobQueue {
|
|
1586
1918
|
private _tail;
|
|
1587
1919
|
private _active;
|
|
1588
1920
|
private readonly _jobs;
|
|
1921
|
+
private readonly _cancelScopes;
|
|
1589
1922
|
/** Incremented on clear() so queued-but-not-yet-running jobs detect invalidation. */
|
|
1590
1923
|
private _generation;
|
|
1591
1924
|
private readonly _generationCancelReasons;
|
|
@@ -1594,21 +1927,57 @@ declare class DeviceJobQueue {
|
|
|
1594
1927
|
* `deviceId` is a label only — used by inspection / cancellation routing.
|
|
1595
1928
|
*/
|
|
1596
1929
|
enqueue<T>(deviceId: string, job: (signal: AbortSignal) => Promise<T>, options?: JobOptions): Promise<T>;
|
|
1597
|
-
/**
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1930
|
+
/**
|
|
1931
|
+
* Holds a cancel across the gaps between a bundle's per-item jobs, when the queue is empty.
|
|
1932
|
+
* Callers must `release()` when the bundle ends.
|
|
1933
|
+
*/
|
|
1934
|
+
createCancelScope(deviceId: string): CancelScopeHandle;
|
|
1935
|
+
/**
|
|
1936
|
+
* Cancels the running job only; `reason` becomes signal.reason. Adapters use
|
|
1937
|
+
* `cancelActiveAndPending`; this stays for a connector layer that stops only what is on the wire.
|
|
1938
|
+
*/
|
|
1939
|
+
cancelActive(deviceId?: string, reason?: Error): boolean;
|
|
1940
|
+
/**
|
|
1941
|
+
* Cancels the active job and unstarted queued jobs; returns whether anything was reached. Only
|
|
1942
|
+
* `undefined` means everything: an empty key matches nothing instead of tearing the queue down.
|
|
1943
|
+
*/
|
|
1604
1944
|
cancelActiveAndPending(deviceId?: string, reason?: Error): boolean;
|
|
1605
1945
|
/** Get info about the currently active job, or null if idle. */
|
|
1606
1946
|
getActiveJob(deviceId?: string): ActiveJobInfo | null;
|
|
1607
|
-
/** True if any job is currently running. */
|
|
1608
|
-
isBusy(): boolean;
|
|
1609
1947
|
clear(reason?: Error): void;
|
|
1610
1948
|
}
|
|
1611
1949
|
|
|
1950
|
+
declare const HARDWARE_RUNTIME_ID_PREFIX = "hwk:runtime";
|
|
1951
|
+
/**
|
|
1952
|
+
* `search-target`: one device in one discovery snapshot, dead on the next search of that kind.
|
|
1953
|
+
* `link`: one open transport. `operation`: one business operation, outliving links via `rebind()`.
|
|
1954
|
+
*/
|
|
1955
|
+
type HardwareRuntimeIdKind = 'operation' | 'search-target' | 'link';
|
|
1956
|
+
type HardwareRuntimeId = {
|
|
1957
|
+
kind: HardwareRuntimeIdKind;
|
|
1958
|
+
vendor: VendorType;
|
|
1959
|
+
};
|
|
1960
|
+
/** Runtime ids are opaque and must never be persisted as device identity. */
|
|
1961
|
+
declare function createHardwareOperationId(vendor: VendorType): string;
|
|
1962
|
+
/** Search targets are valid only for the adapter's current discovery snapshot. */
|
|
1963
|
+
declare function createHardwareSearchTargetId(vendor: VendorType): string;
|
|
1964
|
+
declare function createHardwareLinkId(vendor: VendorType): string;
|
|
1965
|
+
declare function hasHardwareRuntimeIdPrefix(value: unknown): value is string;
|
|
1966
|
+
declare function parseHardwareRuntimeId(value: unknown): HardwareRuntimeId | undefined;
|
|
1967
|
+
declare function isHardwareOperationId(value: unknown): value is string;
|
|
1968
|
+
|
|
1969
|
+
interface HardwareOperationTarget {
|
|
1970
|
+
/** Effective target accepted by existing adapter/connector call paths. */
|
|
1971
|
+
targetId: string | undefined;
|
|
1972
|
+
/** Present when this operation is pinned to a live operation. */
|
|
1973
|
+
operationId: string | undefined;
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Normalizes the transitional positional operation id and the canonical
|
|
1977
|
+
* common-params field. All vendors must reject conflicting bindings.
|
|
1978
|
+
*/
|
|
1979
|
+
declare function resolveHardwareOperationTarget(positionalTargetId: string | null | undefined, commonOperationId: string | null | undefined, expectedVendor?: VendorType): Response<HardwareOperationTarget>;
|
|
1980
|
+
|
|
1612
1981
|
/**
|
|
1613
1982
|
* Minimal typed event emitter using Map<string, Set<listener>>.
|
|
1614
1983
|
* Each adapter uses this for device events (connect, disconnect, pin, etc.).
|
|
@@ -1635,6 +2004,101 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
|
|
|
1635
2004
|
listenerCount(event: string): number;
|
|
1636
2005
|
}
|
|
1637
2006
|
|
|
2007
|
+
/** Serializable BLE transport data shared by Electron main and renderer runtimes. */
|
|
2008
|
+
interface ElectronBleDeviceInfo {
|
|
2009
|
+
id: string;
|
|
2010
|
+
name?: string;
|
|
2011
|
+
rssi?: number;
|
|
2012
|
+
advertisedServiceUuids?: string[];
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* IPC-safe peripheral match: advertises one of `serviceUuids`, or its local name matches every
|
|
2016
|
+
* `namePatterns` entry (case-insensitive regex sources).
|
|
2017
|
+
*/
|
|
2018
|
+
interface ElectronBleMatch {
|
|
2019
|
+
serviceUuids?: string[];
|
|
2020
|
+
namePatterns?: string[];
|
|
2021
|
+
}
|
|
2022
|
+
interface ElectronBleScanOptions {
|
|
2023
|
+
/** Opaque partition key: results and connected devices never mix across it. */
|
|
2024
|
+
vendor?: string;
|
|
2025
|
+
match?: ElectronBleMatch;
|
|
2026
|
+
/** @deprecated Superseded by `match.serviceUuids`. */
|
|
2027
|
+
serviceUuids?: string[];
|
|
2028
|
+
durationMs?: number;
|
|
2029
|
+
}
|
|
2030
|
+
/** GATT profile plus the write framing this vendor's firmware expects. */
|
|
2031
|
+
interface ElectronBleConnectOptions {
|
|
2032
|
+
vendor: string;
|
|
2033
|
+
serviceUuid: string;
|
|
2034
|
+
writeUuid: string;
|
|
2035
|
+
notifyUuid: string;
|
|
2036
|
+
/**
|
|
2037
|
+
* `padded`: fixed `chunkSize` packets, last zero-filled (Trezor firmware drops short packets).
|
|
2038
|
+
* `raw`: the buffer as given, for self-length-framed protocols (Ledger).
|
|
2039
|
+
*/
|
|
2040
|
+
write?: {
|
|
2041
|
+
mode: 'padded' | 'raw';
|
|
2042
|
+
chunkSize?: number;
|
|
2043
|
+
chunkDelayMs?: number;
|
|
2044
|
+
maxLength?: number;
|
|
2045
|
+
};
|
|
2046
|
+
}
|
|
2047
|
+
/** Native code handles GATT only; framing, identity checks and wallet calls stay in the SDK. */
|
|
2048
|
+
interface ElectronBleApi {
|
|
2049
|
+
scan(options?: ElectronBleScanOptions): Promise<ElectronBleDeviceInfo[]>;
|
|
2050
|
+
stopScan(vendor?: string): Promise<void>;
|
|
2051
|
+
connect(id: string, options?: ElectronBleConnectOptions): Promise<{
|
|
2052
|
+
id: string;
|
|
2053
|
+
name?: string;
|
|
2054
|
+
}>;
|
|
2055
|
+
disconnect(id: string): Promise<void>;
|
|
2056
|
+
subscribe(id: string): Promise<void>;
|
|
2057
|
+
unsubscribe(id: string): Promise<void>;
|
|
2058
|
+
write(id: string, hexData: string): Promise<void>;
|
|
2059
|
+
checkAvailability(): Promise<{
|
|
2060
|
+
available: boolean;
|
|
2061
|
+
state: string;
|
|
2062
|
+
initialized: boolean;
|
|
2063
|
+
}>;
|
|
2064
|
+
getDevice(id: string): Promise<ElectronBleDeviceInfo | null>;
|
|
2065
|
+
onNotification(handler: (id: string, hexData: string) => void): () => void;
|
|
2066
|
+
onDeviceDisconnected(handler: (id: string) => void): () => void;
|
|
2067
|
+
/** Abandon an in-flight connect in the main process. Optional for hosts that cannot cancel. */
|
|
2068
|
+
cancelPairing?(options?: {
|
|
2069
|
+
vendor: string;
|
|
2070
|
+
id?: string;
|
|
2071
|
+
}): Promise<void>;
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
/**
|
|
2075
|
+
* A host refusal is reported, never thrown: the device is already connected, so a lost binding
|
|
2076
|
+
* is worth a warning and a retry, not failing the user's work.
|
|
2077
|
+
*/
|
|
2078
|
+
type SaveDeviceBindingOutcome = {
|
|
2079
|
+
saved: true;
|
|
2080
|
+
} | {
|
|
2081
|
+
saved: false;
|
|
2082
|
+
reason: SaveDeviceBindingDeclineReason;
|
|
2083
|
+
};
|
|
2084
|
+
/** Persist a binding through the host. Only a user abort throws. */
|
|
2085
|
+
declare function requestSaveDeviceBinding(emitter: TypedEventEmitter<HardwareEventMap>, registry: UiRequestRegistry, binding: Omit<SaveDeviceBindingRequest, 'requestId'>, signal?: AbortSignal): Promise<SaveDeviceBindingOutcome>;
|
|
2086
|
+
|
|
2087
|
+
/** Discovery and selection share one owner; never connect until the last scan has drained. */
|
|
2088
|
+
declare function requestBleDeviceSelection({ emitter, registry, request, scan, signal, allowUsbFallback, pollIntervalMs, }: {
|
|
2089
|
+
emitter: TypedEventEmitter<HardwareEventMap>;
|
|
2090
|
+
registry: UiRequestRegistry;
|
|
2091
|
+
request: Omit<DeviceSelectionRequest, 'requestId' | 'scanning'>;
|
|
2092
|
+
scan: () => Promise<DeviceInfo[]>;
|
|
2093
|
+
signal: AbortSignal;
|
|
2094
|
+
/** The adapter must verify a returned USB candidate before dispatching any business call. */
|
|
2095
|
+
allowUsbFallback?: boolean;
|
|
2096
|
+
pollIntervalMs?: number;
|
|
2097
|
+
}): Promise<{
|
|
2098
|
+
device: DeviceInfo;
|
|
2099
|
+
requestId: string;
|
|
2100
|
+
}>;
|
|
2101
|
+
|
|
1638
2102
|
/**
|
|
1639
2103
|
* Compare two semver strings (e.g. "2.1.0" vs "2.3.1").
|
|
1640
2104
|
* Returns -1 if a < b, 0 if equal, 1 if a > b.
|
|
@@ -1655,7 +2119,18 @@ declare function hexToBytes(hex: string): Uint8Array;
|
|
|
1655
2119
|
/** Convert a Uint8Array to a hex string (no 0x prefix). */
|
|
1656
2120
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
1657
2121
|
|
|
1658
|
-
|
|
2122
|
+
interface PrepareSolanaOffchainMessageV1Params {
|
|
2123
|
+
message: Uint8Array;
|
|
2124
|
+
requiredSigners: readonly string[];
|
|
2125
|
+
}
|
|
2126
|
+
interface PreparedSolanaOffchainMessageV1 {
|
|
2127
|
+
messageText: string;
|
|
2128
|
+
requiredSigners: string[];
|
|
2129
|
+
serializedMessage: Uint8Array;
|
|
2130
|
+
}
|
|
2131
|
+
declare function prepareSolanaOffchainMessageV1({ message, requiredSigners, }: PrepareSolanaOffchainMessageV1Params): PreparedSolanaOffchainMessageV1;
|
|
2132
|
+
|
|
2133
|
+
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger' | 'keystone';
|
|
1659
2134
|
type HardwareDeviceIdentityInput = {
|
|
1660
2135
|
name?: string | null;
|
|
1661
2136
|
localName?: string | null;
|
|
@@ -1718,8 +2193,12 @@ type RunAllNetworkGetAddressOptions = {
|
|
|
1718
2193
|
buildTopLevelFailure?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => Response<AllNetworkAddressResponse[]>;
|
|
1719
2194
|
};
|
|
1720
2195
|
declare function runAllNetworkGetAddress({ connectId, deviceId, params, getMethodChain, normalizeItem, buildUnsupportedNetworkResponse, callItem, attachIdentity, shouldAbortBundle, buildTopLevelFailure, }: RunAllNetworkGetAddressOptions): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
2196
|
+
/** An SDK-dialog cancel or on-device reject ends the bundle; the user already answered "no". */
|
|
2197
|
+
declare function isUserRefusal(code: HardwareErrorCode | number | undefined): boolean;
|
|
2198
|
+
/** The bundle's session is gone, so the remaining items have nothing to run against. */
|
|
2199
|
+
declare function isConnectionLost(code: HardwareErrorCode | number | undefined): boolean;
|
|
1721
2200
|
declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams): AllNetworkAddressResponse;
|
|
1722
2201
|
|
|
1723
2202
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
1724
2203
|
|
|
1725
|
-
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPaymentRequest, type BtcPaymentRequestMemo, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorCallResult, type ConnectorConfig, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_CONNECT_RETRY_DELAY_MS, DEVICE_EVENT, type DetectableHardwareVendor, type DeviceAuthenticityParams, type DeviceAuthenticityResult, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxLedgerParams, type EvmSignTxParams, type EvmSignTxTrezorParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareMethodMetadata, type HardwareMethodName, type HardwareUiEvent, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareWallet, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type JobOptions, type NullableCallArg, type PassphraseResponse, type PassphraseStateAware, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, type SdkEvent, type SearchDevicesOptions, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiResponseEvent, type VendorType, batchCall, buildUnsupportedMethodResponse, bytesToHex, compareSemver, createBridgedConnector, createCombinedConnector, deriveDeviceFingerprint, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hexToBytes, isAllNetworkMethodName, isKnownNonTargetHardwareVendor, padHex64, rehydrateConnectorError, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };
|
|
2204
|
+
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkDeviceIdentity, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type BindBleDeviceParams, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPaymentRequest, type BtcPaymentRequestMemo, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type CancelCapability, type CancelScopeHandle, type ChainCapability, type ChainForFingerprint, type ConnectionTarget, type ConnectionType, type ConnectorCallResult, type ConnectorConfig, type ConnectorConnectTarget, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSearchDevicesOptions, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_CONNECT_RETRY_DELAY_MS, DEVICE_EVENT, type DetectableHardwareVendor, type DeviceAuthenticityParams, type DeviceAuthenticityResult, type DeviceBindingStatus, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DeviceSearchTarget, type DeviceSelectionContext, type DeviceSelectionRequest, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type ElectronBleApi, type ElectronBleConnectOptions, type ElectronBleDeviceInfo, type ElectronBleMatch, type ElectronBleScanOptions, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxLedgerParams, type EvmSignTxParams, type EvmSignTxTrezorParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, HARDWARE_RUNTIME_ID_PREFIX, type HardwareCallExtra, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareMethodMetadata, type HardwareMethodName, type HardwareOperation, type HardwareOperationTarget, type HardwareRuntimeId, type HardwareRuntimeIdKind, type HardwareUiEvent, HwkErrorOrigin, HwkRecoveryHint, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IDeviceManagerOperationContext, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareConnectionContext, type IHardwareWallet, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type JobOptions, type KnownDeviceConnection, MISSING_BIP32_MASTER_FINGERPRINT, type NullableCallArg, OPERATION_DEFAULT_TTL_MS, type OperationEndReason, OperationRegistry, type PassphraseResponse, type PassphraseStateAware, type PrepareSolanaOffchainMessageV1Params, type PreparedSolanaOffchainMessageV1, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, SaveDeviceBindingDeclineReason, type SaveDeviceBindingRequest, type SdkEvent, type SearchDevicesOptions, type SearchTargetReusePolicy, type SolAddress, type SolGetAddressParams, type SolOffchainMessageV1Params, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiRequestOperationAttribution, UiRequestRegistry, UiResponseEvent, type VendorType, type WalletIdentity, type ZcashFullViewingKey, type ZcashFullViewingKeyMode, type ZcashGetFullViewingKeyParams, type ZcashGetShieldedAddressParams, type ZcashShieldedAddress, batchCall, buildUnsupportedMethodResponse, bytesToHex, canReplayHardwareMethodAfterTransportFailure, compareSemver, createBridgedConnector, createCombinedConnector, createHardwareLinkId, createHardwareOperationId, createHardwareSearchTargetId, deriveDeviceFingerprint, deriveWalletId, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hasHardwareRuntimeIdPrefix, hexToBytes, isAllNetworkMethodName, isConnectionLost, isHardwareOperationId, isKnownNonTargetHardwareVendor, isUserRefusal, padHex64, parseBip32MasterFingerprint, parseHardwareRuntimeId, parseWalletMasterFingerprint, prepareSolanaOffchainMessageV1, rehydrateConnectorError, requestBleDeviceSelection, requestSaveDeviceBinding, resolveHardwareOperationTarget, resolveSearchTargetReusePolicy, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };
|