@onekeyfe/hwk-adapter-core 1.2.5-alpha.3 → 1.2.5-alpha.4
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 +579 -104
- package/dist/index.d.ts +579 -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,77 @@ 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 host must persist this endpoint before acknowledging. */
|
|
1145
|
+
interface SaveDeviceBindingRequest extends UiRequestOperationAttribution {
|
|
1146
|
+
requestId: string;
|
|
1147
|
+
selectionRequestId: string;
|
|
1148
|
+
connection: {
|
|
1149
|
+
transport: 'ble';
|
|
1150
|
+
connectId: string;
|
|
1151
|
+
};
|
|
1152
|
+
/** Omitted when the vendor binds the selected BLE endpoint without checking its wallet (Ledger). */
|
|
1153
|
+
identity?: Extract<WalletIdentity, {
|
|
1154
|
+
vendor: 'ledger' | 'trezor';
|
|
1155
|
+
}>;
|
|
1156
|
+
extra?: HardwareCallExtra;
|
|
1157
|
+
}
|
|
1158
|
+
type BindBleDeviceParams = Pick<SaveDeviceBindingRequest, 'identity' | 'extra'>;
|
|
1159
|
+
interface DeviceBindingStatus {
|
|
1160
|
+
selectionRequestId: string;
|
|
1161
|
+
status: 'verifying' | 'saved' | 'failed' | 'cancelled';
|
|
1162
|
+
}
|
|
917
1163
|
/**
|
|
918
1164
|
* Cross-chain / cross-vendor options passed alongside any chain method's
|
|
919
1165
|
* own params (the optional last argument). Holds operation-level switches
|
|
920
1166
|
* that aren't specific to one chain. Vendor-specific options can be added
|
|
921
1167
|
* as typed sub-fields here when a vendor actually needs them.
|
|
922
1168
|
*/
|
|
923
|
-
interface ICommonCallParams {
|
|
1169
|
+
interface ICommonCallParams extends IHardwareConnectionContext {
|
|
924
1170
|
/**
|
|
925
1171
|
* When the required device app is missing, prompt the user (UI request)
|
|
926
1172
|
* to install it, stream install progress, then retry the operation once.
|
|
927
1173
|
* Off by default — preserves the plain "app not installed" failure.
|
|
928
1174
|
*/
|
|
929
1175
|
autoInstallApp?: boolean;
|
|
1176
|
+
/** Runtime-only id from connectDevice(); when present, discovery and fallback are disabled. */
|
|
1177
|
+
operationId?: string;
|
|
930
1178
|
}
|
|
931
1179
|
type NullableCallArg<T> = T | null | undefined;
|
|
932
1180
|
interface IPassphraseCallParams {
|
|
@@ -935,6 +1183,14 @@ interface IPassphraseCallParams {
|
|
|
935
1183
|
}
|
|
936
1184
|
type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
|
|
937
1185
|
type IHardwareCallParams<T> = T & IHardwareCommonCallParams;
|
|
1186
|
+
/**
|
|
1187
|
+
* Runtime-only device-manager context, never forwarded to firmware. The expected identity lets an
|
|
1188
|
+
* adapter fail closed before replaying a read or mutation after a reconnect.
|
|
1189
|
+
*/
|
|
1190
|
+
interface IDeviceManagerOperationContext extends IHardwareConnectionContext {
|
|
1191
|
+
operationId?: string;
|
|
1192
|
+
expectedDeviceIdentity?: WalletIdentity;
|
|
1193
|
+
}
|
|
938
1194
|
interface AllNetworkAddressParams {
|
|
939
1195
|
network: string;
|
|
940
1196
|
path: string;
|
|
@@ -945,16 +1201,7 @@ interface AllNetworkAddressParams {
|
|
|
945
1201
|
interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
|
|
946
1202
|
bundle: AllNetworkAddressParams[];
|
|
947
1203
|
}
|
|
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
|
-
};
|
|
1204
|
+
type AllNetworkDeviceIdentity = WalletIdentity;
|
|
958
1205
|
type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
959
1206
|
error?: string;
|
|
960
1207
|
code?: HardwareErrorCode | number;
|
|
@@ -962,6 +1209,7 @@ type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
|
962
1209
|
connectId?: string;
|
|
963
1210
|
deviceId?: string;
|
|
964
1211
|
deviceIdentity?: AllNetworkDeviceIdentity;
|
|
1212
|
+
rootFingerprint?: number;
|
|
965
1213
|
chainFingerprint?: string;
|
|
966
1214
|
chainFingerprintChain?: ChainForFingerprint;
|
|
967
1215
|
params?: Record<string, unknown>;
|
|
@@ -1010,46 +1258,50 @@ type UiRequestEvent = {
|
|
|
1010
1258
|
device?: DeviceInfo;
|
|
1011
1259
|
connectId?: string;
|
|
1012
1260
|
type?: string;
|
|
1013
|
-
};
|
|
1261
|
+
} & UiRequestOperationAttribution;
|
|
1014
1262
|
} | {
|
|
1015
1263
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
1016
1264
|
payload: {
|
|
1017
1265
|
device: DeviceInfo;
|
|
1018
|
-
};
|
|
1266
|
+
} & UiRequestOperationAttribution;
|
|
1019
1267
|
} | {
|
|
1020
1268
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1021
1269
|
payload: {
|
|
1022
1270
|
device: DeviceInfo;
|
|
1023
|
-
};
|
|
1271
|
+
} & UiRequestOperationAttribution;
|
|
1024
1272
|
} | {
|
|
1025
1273
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1026
1274
|
payload: {
|
|
1027
1275
|
device: DeviceInfo;
|
|
1028
1276
|
code?: string;
|
|
1029
|
-
};
|
|
1277
|
+
} & UiRequestOperationAttribution;
|
|
1030
1278
|
} | {
|
|
1031
1279
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1032
1280
|
payload: {
|
|
1033
1281
|
device: DeviceInfo;
|
|
1034
1282
|
data: QrDisplayData;
|
|
1035
|
-
};
|
|
1283
|
+
} & UiRequestOperationAttribution;
|
|
1036
1284
|
} | {
|
|
1037
1285
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1038
1286
|
payload: {
|
|
1039
1287
|
device: DeviceInfo;
|
|
1040
|
-
};
|
|
1288
|
+
} & UiRequestOperationAttribution;
|
|
1041
1289
|
} | {
|
|
1042
1290
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
1043
1291
|
payload: {
|
|
1044
1292
|
transportType: TransportType;
|
|
1045
1293
|
connectId?: string;
|
|
1046
1294
|
deviceId?: string;
|
|
1047
|
-
};
|
|
1295
|
+
} & UiRequestOperationAttribution;
|
|
1048
1296
|
} | {
|
|
1049
1297
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1050
|
-
payload:
|
|
1051
|
-
|
|
1052
|
-
|
|
1298
|
+
payload: DeviceSelectionRequest;
|
|
1299
|
+
} | {
|
|
1300
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1301
|
+
payload: SaveDeviceBindingRequest;
|
|
1302
|
+
} | {
|
|
1303
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1304
|
+
payload: DeviceBindingStatus;
|
|
1053
1305
|
} | {
|
|
1054
1306
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
1055
1307
|
payload: {
|
|
@@ -1069,13 +1321,13 @@ type UiRequestEvent = {
|
|
|
1069
1321
|
* isn't recognized.
|
|
1070
1322
|
*/
|
|
1071
1323
|
message: string;
|
|
1072
|
-
};
|
|
1324
|
+
} & UiRequestOperationAttribution;
|
|
1073
1325
|
} | {
|
|
1074
1326
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1075
1327
|
payload: {
|
|
1076
1328
|
vendor: string;
|
|
1077
1329
|
appName: string;
|
|
1078
|
-
};
|
|
1330
|
+
} & UiRequestOperationAttribution;
|
|
1079
1331
|
} | {
|
|
1080
1332
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
1081
1333
|
payload: {
|
|
@@ -1083,10 +1335,10 @@ type UiRequestEvent = {
|
|
|
1083
1335
|
availableMethods: number[];
|
|
1084
1336
|
selectedMethod: number;
|
|
1085
1337
|
nfcData?: string;
|
|
1086
|
-
};
|
|
1338
|
+
} & UiRequestOperationAttribution;
|
|
1087
1339
|
} | {
|
|
1088
1340
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1089
|
-
payload:
|
|
1341
|
+
payload: UiRequestOperationAttribution;
|
|
1090
1342
|
};
|
|
1091
1343
|
type SdkEvent = {
|
|
1092
1344
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1109,6 +1361,12 @@ type SdkEvent = {
|
|
|
1109
1361
|
payload: {
|
|
1110
1362
|
connectId: string;
|
|
1111
1363
|
};
|
|
1364
|
+
} | {
|
|
1365
|
+
type: typeof SDK.OPERATION_ENDED;
|
|
1366
|
+
payload: {
|
|
1367
|
+
operationId: string;
|
|
1368
|
+
reason: OperationEndReason;
|
|
1369
|
+
};
|
|
1112
1370
|
};
|
|
1113
1371
|
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent | HardwareUiEvent;
|
|
1114
1372
|
type DeviceEventListener = (event: HardwareEvent) => void;
|
|
@@ -1119,6 +1377,14 @@ type DeviceEventListener = (event: HardwareEvent) => void;
|
|
|
1119
1377
|
* and the value is the narrowed event object the listener will receive.
|
|
1120
1378
|
*/
|
|
1121
1379
|
interface HardwareEventMap {
|
|
1380
|
+
[UI_REQUEST.DEVICE_BINDING_STATUS]: {
|
|
1381
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1382
|
+
payload: DeviceBindingStatus;
|
|
1383
|
+
};
|
|
1384
|
+
[UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING]: {
|
|
1385
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1386
|
+
payload: SaveDeviceBindingRequest;
|
|
1387
|
+
};
|
|
1122
1388
|
'ui-event': HardwareUiEvent;
|
|
1123
1389
|
[DEVICE.CONNECT]: {
|
|
1124
1390
|
type: typeof DEVICE.CONNECT;
|
|
@@ -1159,7 +1425,7 @@ interface HardwareEventMap {
|
|
|
1159
1425
|
device?: DeviceInfo;
|
|
1160
1426
|
connectId?: string;
|
|
1161
1427
|
type?: string;
|
|
1162
|
-
};
|
|
1428
|
+
} & UiRequestOperationAttribution;
|
|
1163
1429
|
};
|
|
1164
1430
|
[UI_REQUEST.REQUEST_PASSPHRASE]: {
|
|
1165
1431
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
@@ -1168,33 +1434,33 @@ interface HardwareEventMap {
|
|
|
1168
1434
|
connectId?: string;
|
|
1169
1435
|
passphraseState?: string;
|
|
1170
1436
|
useEmptyPassphrase?: boolean;
|
|
1171
|
-
};
|
|
1437
|
+
} & UiRequestOperationAttribution;
|
|
1172
1438
|
};
|
|
1173
1439
|
[UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
|
|
1174
1440
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1175
1441
|
payload: {
|
|
1176
1442
|
device: DeviceInfo;
|
|
1177
|
-
};
|
|
1443
|
+
} & UiRequestOperationAttribution;
|
|
1178
1444
|
};
|
|
1179
1445
|
[UI_REQUEST.REQUEST_BUTTON]: {
|
|
1180
1446
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1181
1447
|
payload: {
|
|
1182
1448
|
device: DeviceInfo;
|
|
1183
1449
|
code?: string;
|
|
1184
|
-
};
|
|
1450
|
+
} & UiRequestOperationAttribution;
|
|
1185
1451
|
};
|
|
1186
1452
|
[UI_REQUEST.REQUEST_QR_DISPLAY]: {
|
|
1187
1453
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1188
1454
|
payload: {
|
|
1189
1455
|
device: DeviceInfo;
|
|
1190
1456
|
data: QrDisplayData;
|
|
1191
|
-
};
|
|
1457
|
+
} & UiRequestOperationAttribution;
|
|
1192
1458
|
};
|
|
1193
1459
|
[UI_REQUEST.REQUEST_QR_SCAN]: {
|
|
1194
1460
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1195
1461
|
payload: {
|
|
1196
1462
|
device: DeviceInfo;
|
|
1197
|
-
};
|
|
1463
|
+
} & UiRequestOperationAttribution;
|
|
1198
1464
|
};
|
|
1199
1465
|
[UI_REQUEST.REQUEST_DEVICE_PERMISSION]: {
|
|
1200
1466
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
@@ -1202,13 +1468,11 @@ interface HardwareEventMap {
|
|
|
1202
1468
|
transportType: TransportType;
|
|
1203
1469
|
connectId?: string;
|
|
1204
1470
|
deviceId?: string;
|
|
1205
|
-
};
|
|
1471
|
+
} & UiRequestOperationAttribution;
|
|
1206
1472
|
};
|
|
1207
1473
|
[UI_REQUEST.REQUEST_SELECT_DEVICE]: {
|
|
1208
1474
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1209
|
-
payload:
|
|
1210
|
-
devices: DeviceInfo[];
|
|
1211
|
-
};
|
|
1475
|
+
payload: DeviceSelectionRequest;
|
|
1212
1476
|
};
|
|
1213
1477
|
[UI_REQUEST.REQUEST_DEVICE_CONNECT]: {
|
|
1214
1478
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
@@ -1216,7 +1480,7 @@ interface HardwareEventMap {
|
|
|
1216
1480
|
vendor: string;
|
|
1217
1481
|
reason: string;
|
|
1218
1482
|
message: string;
|
|
1219
|
-
};
|
|
1483
|
+
} & UiRequestOperationAttribution;
|
|
1220
1484
|
};
|
|
1221
1485
|
[UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM]: {
|
|
1222
1486
|
type: typeof UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM;
|
|
@@ -1224,14 +1488,14 @@ interface HardwareEventMap {
|
|
|
1224
1488
|
vendor: string;
|
|
1225
1489
|
path: string;
|
|
1226
1490
|
accountIndex: number;
|
|
1227
|
-
};
|
|
1491
|
+
} & UiRequestOperationAttribution;
|
|
1228
1492
|
};
|
|
1229
1493
|
[UI_REQUEST.REQUEST_INSTALL_APP]: {
|
|
1230
1494
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1231
1495
|
payload: {
|
|
1232
1496
|
vendor: string;
|
|
1233
1497
|
appName: string;
|
|
1234
|
-
};
|
|
1498
|
+
} & UiRequestOperationAttribution;
|
|
1235
1499
|
};
|
|
1236
1500
|
[UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
|
|
1237
1501
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
@@ -1240,11 +1504,11 @@ interface HardwareEventMap {
|
|
|
1240
1504
|
availableMethods: number[];
|
|
1241
1505
|
selectedMethod: number;
|
|
1242
1506
|
nfcData?: string;
|
|
1243
|
-
};
|
|
1507
|
+
} & UiRequestOperationAttribution;
|
|
1244
1508
|
};
|
|
1245
1509
|
[UI_REQUEST.CLOSE_UI_WINDOW]: {
|
|
1246
1510
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1247
|
-
payload:
|
|
1511
|
+
payload: UiRequestOperationAttribution;
|
|
1248
1512
|
};
|
|
1249
1513
|
[SDK.DEVICE_INTERACTION]: {
|
|
1250
1514
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1271,16 +1535,23 @@ interface HardwareEventMap {
|
|
|
1271
1535
|
connectId: string;
|
|
1272
1536
|
};
|
|
1273
1537
|
};
|
|
1538
|
+
[SDK.OPERATION_ENDED]: {
|
|
1539
|
+
type: typeof SDK.OPERATION_ENDED;
|
|
1540
|
+
payload: {
|
|
1541
|
+
operationId: string;
|
|
1542
|
+
reason: OperationEndReason;
|
|
1543
|
+
};
|
|
1544
|
+
};
|
|
1274
1545
|
}
|
|
1275
1546
|
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>>>;
|
|
1547
|
+
getFeatures?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1548
|
+
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1549
|
+
setBrightness?(connectId: string, params?: TrezorBrightnessParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1550
|
+
changePin?(connectId: string, params?: TrezorChangePinParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1551
|
+
wipeDevice?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1281
1552
|
authenticateDevice?(connectId: string, params: {
|
|
1282
1553
|
challenge: string;
|
|
1283
|
-
}): Promise<Response<Record<string, unknown>>>;
|
|
1554
|
+
}, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1284
1555
|
}
|
|
1285
1556
|
interface IWalletStateMethods {
|
|
1286
1557
|
/**
|
|
@@ -1307,20 +1578,37 @@ interface IWalletStateMethods {
|
|
|
1307
1578
|
* Optional: vendors without host-managed passphrase sessions (Ledger) omit
|
|
1308
1579
|
* it. Implemented by `TrezorAdapter`.
|
|
1309
1580
|
*/
|
|
1310
|
-
getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
|
|
1581
|
+
getPassphraseState?(connectId: string, passphraseState?: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<string | null>>;
|
|
1311
1582
|
}
|
|
1583
|
+
/**
|
|
1584
|
+
* `stops-waiting`: an on-device confirmation stays up until answered or timed out.
|
|
1585
|
+
* `interrupts-device`: the command on the wire is withdrawn. No vendor reports it, so hosts
|
|
1586
|
+
* should say "stopped waiting, answer on the device", not "cancelled".
|
|
1587
|
+
*/
|
|
1588
|
+
type CancelCapability = 'interrupts-device' | 'stops-waiting';
|
|
1312
1589
|
interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
|
|
1313
1590
|
readonly vendor: string;
|
|
1314
1591
|
readonly activeTransport: TransportType | null;
|
|
1592
|
+
/** What `cancel()` reaches on this vendor. Declared, never inferred. */
|
|
1593
|
+
readonly cancelCapability: CancelCapability;
|
|
1315
1594
|
init(config: TConfig): Promise<void>;
|
|
1316
1595
|
dispose(): Promise<void>;
|
|
1317
1596
|
getAvailableTransports(): TransportType[];
|
|
1318
1597
|
switchTransport(type: TransportType): Promise<void>;
|
|
1319
1598
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
1320
|
-
|
|
1321
|
-
|
|
1599
|
+
/** Discover selectable hardware entries without claiming identified devices or wallets. */
|
|
1600
|
+
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
1601
|
+
/** @deprecated Use searchDeviceTargets(). */
|
|
1602
|
+
listConnectionTargets(options?: SearchDevicesOptions): Promise<ConnectionTarget[]>;
|
|
1603
|
+
/** Connect or logically bind a selected search result and return a runtime-only operation id. */
|
|
1604
|
+
connectDevice(searchTargetId: string): Promise<Response<string>>;
|
|
1605
|
+
/** Device Manager rebind: verify the existing identity before replacing its BLE locator. */
|
|
1606
|
+
bindBleDevice?(params: BindBleDeviceParams): Promise<Response<string>>;
|
|
1607
|
+
/** Resolve and pin operation routing; the caller verifies wallet identity before business calls. */
|
|
1608
|
+
acquireOperation?(connectId: string, context: IHardwareConnectionContext): Promise<Response<string>>;
|
|
1609
|
+
/** Release a caller-owned operation. Disconnect events end matching operations automatically. */
|
|
1610
|
+
releaseOperation(operationId: string): Promise<void>;
|
|
1322
1611
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
1323
|
-
getSupportedChains(): ChainCapability[];
|
|
1324
1612
|
/** Abort the in-flight call. Omit connectId to cancel whatever is active. */
|
|
1325
1613
|
cancel(connectId?: string): void;
|
|
1326
1614
|
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
@@ -1357,6 +1645,11 @@ interface SearchDevicesOptions {
|
|
|
1357
1645
|
* was discovered first.
|
|
1358
1646
|
*/
|
|
1359
1647
|
waitForAllTransports?: boolean;
|
|
1648
|
+
/**
|
|
1649
|
+
* Restrict discovery to one transport. A virtual target (Keystone QR) must not start any wallet
|
|
1650
|
+
* interaction during discovery; `connectDevice()` resolves it.
|
|
1651
|
+
*/
|
|
1652
|
+
transportType?: ConnectionType;
|
|
1360
1653
|
}
|
|
1361
1654
|
|
|
1362
1655
|
interface EvmGetAddressParams extends PassphraseStateAware {
|
|
@@ -1480,6 +1773,11 @@ interface EvmSignTypedDataFull extends PassphraseStateAware {
|
|
|
1480
1773
|
primaryType: string;
|
|
1481
1774
|
message: Record<string, unknown>;
|
|
1482
1775
|
};
|
|
1776
|
+
/**
|
|
1777
|
+
* The dApp's original EIP-712 JSON, byte for byte. Serializing vendors (Keystone) must prefer it:
|
|
1778
|
+
* re-stringifying `data` rewrites integers wider than 2^53 and exponent forms.
|
|
1779
|
+
*/
|
|
1780
|
+
dataJson?: string;
|
|
1483
1781
|
metamaskV4Compat?: boolean;
|
|
1484
1782
|
showMessageHash?: boolean;
|
|
1485
1783
|
/**
|
|
@@ -1518,6 +1816,33 @@ interface IEvmMethods {
|
|
|
1518
1816
|
evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
|
|
1519
1817
|
}
|
|
1520
1818
|
|
|
1819
|
+
/** Which `GET_VK` encoding the Ledger Zcash app should return. */
|
|
1820
|
+
type ZcashFullViewingKeyMode = 'ufvk' | 'orchardFvk';
|
|
1821
|
+
interface ZcashGetFullViewingKeyParams extends PassphraseStateAware {
|
|
1822
|
+
/** BIP44 account path `m/44'/133'/a'`; a deeper transparent path is accepted, only `a'` is used. */
|
|
1823
|
+
path: string;
|
|
1824
|
+
/** Default `ufvk`. */
|
|
1825
|
+
mode?: ZcashFullViewingKeyMode;
|
|
1826
|
+
}
|
|
1827
|
+
interface ZcashFullViewingKey {
|
|
1828
|
+
path: string;
|
|
1829
|
+
mode: ZcashFullViewingKeyMode;
|
|
1830
|
+
/** ZIP-316 bech32m UFVK string (mode `ufvk`). */
|
|
1831
|
+
ufvk?: string;
|
|
1832
|
+
/** 96-byte raw Orchard FVK as hex (mode `orchardFvk`). */
|
|
1833
|
+
orchardFvk?: string;
|
|
1834
|
+
}
|
|
1835
|
+
interface ZcashGetShieldedAddressParams extends PassphraseStateAware {
|
|
1836
|
+
/** Full 5-level transparent path `m/44'/133'/a'/0/i`; the Orchard path is derived from it. */
|
|
1837
|
+
path: string;
|
|
1838
|
+
showOnDevice?: boolean;
|
|
1839
|
+
}
|
|
1840
|
+
interface ZcashShieldedAddress {
|
|
1841
|
+
/** Unified address with a single Orchard receiver. */
|
|
1842
|
+
address: string;
|
|
1843
|
+
path: string;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1521
1846
|
/**
|
|
1522
1847
|
* Low-level device descriptor from Transport layer.
|
|
1523
1848
|
* Represents a physical device detected by USB/BLE scanning.
|
|
@@ -1563,14 +1888,13 @@ interface DeviceDisconnectEvent {
|
|
|
1563
1888
|
type DeviceChangeEvent = DeviceConnectEvent | DeviceDisconnectEvent;
|
|
1564
1889
|
|
|
1565
1890
|
/**
|
|
1566
|
-
*
|
|
1567
|
-
*
|
|
1568
|
-
*
|
|
1569
|
-
*
|
|
1570
|
-
*
|
|
1571
|
-
*
|
|
1572
|
-
*
|
|
1573
|
-
* synchronously, without racing against in-flight enqueues.
|
|
1891
|
+
* Serializes every device call and gives callers one handle to cancel them. Ordering is already
|
|
1892
|
+
* guaranteed by awaiting callers, so what this adds is an AbortController per job, a busy check
|
|
1893
|
+
* that rejects double-submits, and generation tracking so a job queued before a teardown doesn't
|
|
1894
|
+
* start after it; these races exist even for a sequential caller because cleanup is async.
|
|
1895
|
+
*
|
|
1896
|
+
* Interrupt-or-ask policy belongs to the caller; `getActiveJob()` is synchronous so a UI handler
|
|
1897
|
+
* can look, decide, and submit in one turn without racing an in-flight enqueue.
|
|
1574
1898
|
*/
|
|
1575
1899
|
interface JobOptions {
|
|
1576
1900
|
label?: string;
|
|
@@ -1582,10 +1906,15 @@ interface ActiveJobInfo {
|
|
|
1582
1906
|
label?: string;
|
|
1583
1907
|
startedAt: number;
|
|
1584
1908
|
}
|
|
1909
|
+
interface CancelScopeHandle {
|
|
1910
|
+
signal: AbortSignal;
|
|
1911
|
+
release: () => void;
|
|
1912
|
+
}
|
|
1585
1913
|
declare class DeviceJobQueue {
|
|
1586
1914
|
private _tail;
|
|
1587
1915
|
private _active;
|
|
1588
1916
|
private readonly _jobs;
|
|
1917
|
+
private readonly _cancelScopes;
|
|
1589
1918
|
/** Incremented on clear() so queued-but-not-yet-running jobs detect invalidation. */
|
|
1590
1919
|
private _generation;
|
|
1591
1920
|
private readonly _generationCancelReasons;
|
|
@@ -1594,21 +1923,57 @@ declare class DeviceJobQueue {
|
|
|
1594
1923
|
* `deviceId` is a label only — used by inspection / cancellation routing.
|
|
1595
1924
|
*/
|
|
1596
1925
|
enqueue<T>(deviceId: string, job: (signal: AbortSignal) => Promise<T>, options?: JobOptions): Promise<T>;
|
|
1597
|
-
/**
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1926
|
+
/**
|
|
1927
|
+
* Holds a cancel across the gaps between a bundle's per-item jobs, when the queue is empty.
|
|
1928
|
+
* Callers must `release()` when the bundle ends.
|
|
1929
|
+
*/
|
|
1930
|
+
createCancelScope(deviceId: string): CancelScopeHandle;
|
|
1931
|
+
/**
|
|
1932
|
+
* Cancels the running job only; `reason` becomes signal.reason. Adapters use
|
|
1933
|
+
* `cancelActiveAndPending`; this stays for a connector layer that stops only what is on the wire.
|
|
1934
|
+
*/
|
|
1935
|
+
cancelActive(deviceId?: string, reason?: Error): boolean;
|
|
1936
|
+
/**
|
|
1937
|
+
* Cancels the active job and unstarted queued jobs; returns whether anything was reached. Only
|
|
1938
|
+
* `undefined` means everything: an empty key matches nothing instead of tearing the queue down.
|
|
1939
|
+
*/
|
|
1604
1940
|
cancelActiveAndPending(deviceId?: string, reason?: Error): boolean;
|
|
1605
1941
|
/** Get info about the currently active job, or null if idle. */
|
|
1606
1942
|
getActiveJob(deviceId?: string): ActiveJobInfo | null;
|
|
1607
|
-
/** True if any job is currently running. */
|
|
1608
|
-
isBusy(): boolean;
|
|
1609
1943
|
clear(reason?: Error): void;
|
|
1610
1944
|
}
|
|
1611
1945
|
|
|
1946
|
+
declare const HARDWARE_RUNTIME_ID_PREFIX = "hwk:runtime";
|
|
1947
|
+
/**
|
|
1948
|
+
* `search-target`: one device in one discovery snapshot, dead on the next search of that kind.
|
|
1949
|
+
* `link`: one open transport. `operation`: one business operation, outliving links via `rebind()`.
|
|
1950
|
+
*/
|
|
1951
|
+
type HardwareRuntimeIdKind = 'operation' | 'search-target' | 'link';
|
|
1952
|
+
type HardwareRuntimeId = {
|
|
1953
|
+
kind: HardwareRuntimeIdKind;
|
|
1954
|
+
vendor: VendorType;
|
|
1955
|
+
};
|
|
1956
|
+
/** Runtime ids are opaque and must never be persisted as device identity. */
|
|
1957
|
+
declare function createHardwareOperationId(vendor: VendorType): string;
|
|
1958
|
+
/** Search targets are valid only for the adapter's current discovery snapshot. */
|
|
1959
|
+
declare function createHardwareSearchTargetId(vendor: VendorType): string;
|
|
1960
|
+
declare function createHardwareLinkId(vendor: VendorType): string;
|
|
1961
|
+
declare function hasHardwareRuntimeIdPrefix(value: unknown): value is string;
|
|
1962
|
+
declare function parseHardwareRuntimeId(value: unknown): HardwareRuntimeId | undefined;
|
|
1963
|
+
declare function isHardwareOperationId(value: unknown): value is string;
|
|
1964
|
+
|
|
1965
|
+
interface HardwareOperationTarget {
|
|
1966
|
+
/** Effective target accepted by existing adapter/connector call paths. */
|
|
1967
|
+
targetId: string | undefined;
|
|
1968
|
+
/** Present when this operation is pinned to a live operation. */
|
|
1969
|
+
operationId: string | undefined;
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Normalizes the transitional positional operation id and the canonical
|
|
1973
|
+
* common-params field. All vendors must reject conflicting bindings.
|
|
1974
|
+
*/
|
|
1975
|
+
declare function resolveHardwareOperationTarget(positionalTargetId: string | null | undefined, commonOperationId: string | null | undefined, expectedVendor?: VendorType): Response<HardwareOperationTarget>;
|
|
1976
|
+
|
|
1612
1977
|
/**
|
|
1613
1978
|
* Minimal typed event emitter using Map<string, Set<listener>>.
|
|
1614
1979
|
* Each adapter uses this for device events (connect, disconnect, pin, etc.).
|
|
@@ -1635,6 +2000,101 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
|
|
|
1635
2000
|
listenerCount(event: string): number;
|
|
1636
2001
|
}
|
|
1637
2002
|
|
|
2003
|
+
/** Serializable BLE transport data shared by Electron main and renderer runtimes. */
|
|
2004
|
+
interface ElectronBleDeviceInfo {
|
|
2005
|
+
id: string;
|
|
2006
|
+
name?: string;
|
|
2007
|
+
rssi?: number;
|
|
2008
|
+
advertisedServiceUuids?: string[];
|
|
2009
|
+
}
|
|
2010
|
+
/**
|
|
2011
|
+
* IPC-safe peripheral match: advertises one of `serviceUuids`, or its local name matches every
|
|
2012
|
+
* `namePatterns` entry (case-insensitive regex sources).
|
|
2013
|
+
*/
|
|
2014
|
+
interface ElectronBleMatch {
|
|
2015
|
+
serviceUuids?: string[];
|
|
2016
|
+
namePatterns?: string[];
|
|
2017
|
+
}
|
|
2018
|
+
interface ElectronBleScanOptions {
|
|
2019
|
+
/** Opaque partition key: results and connected devices never mix across it. */
|
|
2020
|
+
vendor?: string;
|
|
2021
|
+
match?: ElectronBleMatch;
|
|
2022
|
+
/** @deprecated Superseded by `match.serviceUuids`. */
|
|
2023
|
+
serviceUuids?: string[];
|
|
2024
|
+
durationMs?: number;
|
|
2025
|
+
}
|
|
2026
|
+
/** GATT profile plus the write framing this vendor's firmware expects. */
|
|
2027
|
+
interface ElectronBleConnectOptions {
|
|
2028
|
+
vendor: string;
|
|
2029
|
+
serviceUuid: string;
|
|
2030
|
+
writeUuid: string;
|
|
2031
|
+
notifyUuid: string;
|
|
2032
|
+
/**
|
|
2033
|
+
* `padded`: fixed `chunkSize` packets, last zero-filled (Trezor firmware drops short packets).
|
|
2034
|
+
* `raw`: the buffer as given, for self-length-framed protocols (Ledger).
|
|
2035
|
+
*/
|
|
2036
|
+
write?: {
|
|
2037
|
+
mode: 'padded' | 'raw';
|
|
2038
|
+
chunkSize?: number;
|
|
2039
|
+
chunkDelayMs?: number;
|
|
2040
|
+
maxLength?: number;
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
/** Native code handles GATT only; framing, identity checks and wallet calls stay in the SDK. */
|
|
2044
|
+
interface ElectronBleApi {
|
|
2045
|
+
scan(options?: ElectronBleScanOptions): Promise<ElectronBleDeviceInfo[]>;
|
|
2046
|
+
stopScan(vendor?: string): Promise<void>;
|
|
2047
|
+
connect(id: string, options?: ElectronBleConnectOptions): Promise<{
|
|
2048
|
+
id: string;
|
|
2049
|
+
name?: string;
|
|
2050
|
+
}>;
|
|
2051
|
+
disconnect(id: string): Promise<void>;
|
|
2052
|
+
subscribe(id: string): Promise<void>;
|
|
2053
|
+
unsubscribe(id: string): Promise<void>;
|
|
2054
|
+
write(id: string, hexData: string): Promise<void>;
|
|
2055
|
+
checkAvailability(): Promise<{
|
|
2056
|
+
available: boolean;
|
|
2057
|
+
state: string;
|
|
2058
|
+
initialized: boolean;
|
|
2059
|
+
}>;
|
|
2060
|
+
getDevice(id: string): Promise<ElectronBleDeviceInfo | null>;
|
|
2061
|
+
onNotification(handler: (id: string, hexData: string) => void): () => void;
|
|
2062
|
+
onDeviceDisconnected(handler: (id: string) => void): () => void;
|
|
2063
|
+
/** Abandon an in-flight connect in the main process. Optional for hosts that cannot cancel. */
|
|
2064
|
+
cancelPairing?(options?: {
|
|
2065
|
+
vendor: string;
|
|
2066
|
+
id?: string;
|
|
2067
|
+
}): Promise<void>;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
/**
|
|
2071
|
+
* A host refusal is reported, never thrown: the device is already connected, so a lost binding
|
|
2072
|
+
* is worth a warning and a retry, not failing the user's work.
|
|
2073
|
+
*/
|
|
2074
|
+
type SaveDeviceBindingOutcome = {
|
|
2075
|
+
saved: true;
|
|
2076
|
+
} | {
|
|
2077
|
+
saved: false;
|
|
2078
|
+
reason: SaveDeviceBindingDeclineReason;
|
|
2079
|
+
};
|
|
2080
|
+
/** Persist a binding through the host. Only a user abort throws. */
|
|
2081
|
+
declare function requestSaveDeviceBinding(emitter: TypedEventEmitter<HardwareEventMap>, registry: UiRequestRegistry, binding: Omit<SaveDeviceBindingRequest, 'requestId'>, signal?: AbortSignal): Promise<SaveDeviceBindingOutcome>;
|
|
2082
|
+
|
|
2083
|
+
/** Discovery and selection share one owner; never connect until the last scan has drained. */
|
|
2084
|
+
declare function requestBleDeviceSelection({ emitter, registry, request, scan, signal, allowUsbFallback, pollIntervalMs, }: {
|
|
2085
|
+
emitter: TypedEventEmitter<HardwareEventMap>;
|
|
2086
|
+
registry: UiRequestRegistry;
|
|
2087
|
+
request: Omit<DeviceSelectionRequest, 'requestId' | 'scanning'>;
|
|
2088
|
+
scan: () => Promise<DeviceInfo[]>;
|
|
2089
|
+
signal: AbortSignal;
|
|
2090
|
+
/** The adapter must verify a returned USB candidate before dispatching any business call. */
|
|
2091
|
+
allowUsbFallback?: boolean;
|
|
2092
|
+
pollIntervalMs?: number;
|
|
2093
|
+
}): Promise<{
|
|
2094
|
+
device: DeviceInfo;
|
|
2095
|
+
requestId: string;
|
|
2096
|
+
}>;
|
|
2097
|
+
|
|
1638
2098
|
/**
|
|
1639
2099
|
* Compare two semver strings (e.g. "2.1.0" vs "2.3.1").
|
|
1640
2100
|
* Returns -1 if a < b, 0 if equal, 1 if a > b.
|
|
@@ -1655,7 +2115,18 @@ declare function hexToBytes(hex: string): Uint8Array;
|
|
|
1655
2115
|
/** Convert a Uint8Array to a hex string (no 0x prefix). */
|
|
1656
2116
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
1657
2117
|
|
|
1658
|
-
|
|
2118
|
+
interface PrepareSolanaOffchainMessageV1Params {
|
|
2119
|
+
message: Uint8Array;
|
|
2120
|
+
requiredSigners: readonly string[];
|
|
2121
|
+
}
|
|
2122
|
+
interface PreparedSolanaOffchainMessageV1 {
|
|
2123
|
+
messageText: string;
|
|
2124
|
+
requiredSigners: string[];
|
|
2125
|
+
serializedMessage: Uint8Array;
|
|
2126
|
+
}
|
|
2127
|
+
declare function prepareSolanaOffchainMessageV1({ message, requiredSigners, }: PrepareSolanaOffchainMessageV1Params): PreparedSolanaOffchainMessageV1;
|
|
2128
|
+
|
|
2129
|
+
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger' | 'keystone';
|
|
1659
2130
|
type HardwareDeviceIdentityInput = {
|
|
1660
2131
|
name?: string | null;
|
|
1661
2132
|
localName?: string | null;
|
|
@@ -1718,8 +2189,12 @@ type RunAllNetworkGetAddressOptions = {
|
|
|
1718
2189
|
buildTopLevelFailure?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => Response<AllNetworkAddressResponse[]>;
|
|
1719
2190
|
};
|
|
1720
2191
|
declare function runAllNetworkGetAddress({ connectId, deviceId, params, getMethodChain, normalizeItem, buildUnsupportedNetworkResponse, callItem, attachIdentity, shouldAbortBundle, buildTopLevelFailure, }: RunAllNetworkGetAddressOptions): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
2192
|
+
/** An SDK-dialog cancel or on-device reject ends the bundle; the user already answered "no". */
|
|
2193
|
+
declare function isUserRefusal(code: HardwareErrorCode | number | undefined): boolean;
|
|
2194
|
+
/** The bundle's session is gone, so the remaining items have nothing to run against. */
|
|
2195
|
+
declare function isConnectionLost(code: HardwareErrorCode | number | undefined): boolean;
|
|
1721
2196
|
declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams): AllNetworkAddressResponse;
|
|
1722
2197
|
|
|
1723
2198
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
1724
2199
|
|
|
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 };
|
|
2200
|
+
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 };
|