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