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