@onekeyfe/hwk-adapter-core 1.2.8-alpha.103 → 1.2.8-alpha.104
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-BAGEFFFY.js → chunk-AYS7A7Z3.js} +45 -13
- package/dist/chunk-AYS7A7Z3.js.map +1 -0
- package/dist/chunk-DB4JOPZO.mjs +74 -0
- package/dist/chunk-DB4JOPZO.mjs.map +1 -0
- package/dist/{chunk-U63HTLGJ.mjs → chunk-G5EU7VRW.mjs} +44 -12
- package/dist/chunk-G5EU7VRW.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-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 +646 -104
- package/dist/index.d.ts +646 -104
- package/dist/index.js +1095 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1087 -78
- package/dist/index.mjs.map +1 -1
- package/dist/{ui-events-Cb7haAeE.d.ts → ui-events-C61GTilK.d.mts} +67 -3
- package/dist/{ui-events-Cb7haAeE.d.mts → ui-events-C61GTilK.d.ts} +67 -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, E as ExportedAccountKey, a as UiRequestOperationAttribution, b as UI_REQUEST, Q as QrDisplayData, c as UiRequestRegistry, S as SaveDeviceBindingDeclineReason } from './ui-events-C61GTilK.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-C61GTilK.mjs';
|
|
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;
|
|
@@ -400,6 +497,10 @@ interface BtcGetAddressParams extends PassphraseStateAware {
|
|
|
400
497
|
path: string;
|
|
401
498
|
coin?: string;
|
|
402
499
|
showOnDevice?: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* Trezor only. Ledger and Keystone ignore it and derive the script of the path's purpose
|
|
502
|
+
* (44' P2PKH, 49' P2SH-P2WPKH, 84' P2WPKH, 86' P2TR; Keystone does not support 86' yet).
|
|
503
|
+
*/
|
|
403
504
|
scriptType?: 'p2pkh' | 'p2sh' | 'p2wpkh' | 'p2wsh' | 'p2tr';
|
|
404
505
|
addressIndex?: number;
|
|
405
506
|
change?: boolean;
|
|
@@ -407,6 +508,8 @@ interface BtcGetAddressParams extends PassphraseStateAware {
|
|
|
407
508
|
interface BtcAddress {
|
|
408
509
|
address: string;
|
|
409
510
|
path: string;
|
|
511
|
+
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
512
|
+
accountKey?: ExportedAccountKey;
|
|
410
513
|
}
|
|
411
514
|
interface BtcGetPublicKeyParams extends PassphraseStateAware {
|
|
412
515
|
path: string;
|
|
@@ -421,6 +524,8 @@ interface BtcPublicKey {
|
|
|
421
524
|
chainCode: string;
|
|
422
525
|
path: string;
|
|
423
526
|
depth: number;
|
|
527
|
+
/** Set by air-gapped wallets (Keystone): the exported key, for pinning by the host. */
|
|
528
|
+
accountKey?: ExportedAccountKey;
|
|
424
529
|
}
|
|
425
530
|
interface BtcSignTxParams extends PassphraseStateAware {
|
|
426
531
|
psbt?: string;
|
|
@@ -561,6 +666,8 @@ interface SolAddress {
|
|
|
561
666
|
/** Base58-encoded Solana address — this is also the Ed25519 public key. */
|
|
562
667
|
address: string;
|
|
563
668
|
path: string;
|
|
669
|
+
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
670
|
+
accountKey?: ExportedAccountKey;
|
|
564
671
|
}
|
|
565
672
|
interface SolSignTxParams extends PassphraseStateAware {
|
|
566
673
|
path: string;
|
|
@@ -581,11 +688,21 @@ interface SolSignedTx {
|
|
|
581
688
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
582
689
|
signature: string;
|
|
583
690
|
}
|
|
584
|
-
interface
|
|
691
|
+
interface SolSignMessageBaseParams extends PassphraseStateAware {
|
|
585
692
|
path: string;
|
|
586
693
|
/** Message bytes as hex string (no 0x prefix) */
|
|
587
694
|
message: string;
|
|
588
695
|
}
|
|
696
|
+
interface SolOffchainMessageV1Params {
|
|
697
|
+
/** Finalized Solana off-chain message format. */
|
|
698
|
+
messageVersion: 1;
|
|
699
|
+
/** Complete signer set as 32-byte hex public keys. */
|
|
700
|
+
requiredSigners: string[];
|
|
701
|
+
}
|
|
702
|
+
type SolSignMsgParams = SolSignMessageBaseParams & ({
|
|
703
|
+
messageVersion?: undefined;
|
|
704
|
+
requiredSigners?: undefined;
|
|
705
|
+
} | SolOffchainMessageV1Params);
|
|
589
706
|
interface SolSignature {
|
|
590
707
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
591
708
|
signature: string;
|
|
@@ -604,6 +721,8 @@ interface TronAddress {
|
|
|
604
721
|
/** Base58check-encoded TRON address (starts with 'T') */
|
|
605
722
|
address: string;
|
|
606
723
|
path: string;
|
|
724
|
+
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
725
|
+
accountKey?: ExportedAccountKey;
|
|
607
726
|
}
|
|
608
727
|
/** TRON network resource, used by freeze/unfreeze contracts. */
|
|
609
728
|
type TronResource = 'BANDWIDTH' | 'ENERGY';
|
|
@@ -712,6 +831,12 @@ interface TronSignMsgParams extends PassphraseStateAware {
|
|
|
712
831
|
path: string;
|
|
713
832
|
/** Message hex (no 0x prefix) */
|
|
714
833
|
messageHex: string;
|
|
834
|
+
/**
|
|
835
|
+
* TRON message scheme: 'V1' = legacy signMessage (prefix + 32-byte hash),
|
|
836
|
+
* 'V2' = TIP-191 signMessageV2 (prefix + byte length + message). Adapters
|
|
837
|
+
* that only implement one scheme reject the other with MethodNotSupported.
|
|
838
|
+
*/
|
|
839
|
+
messageType?: 'V1' | 'V2';
|
|
715
840
|
}
|
|
716
841
|
interface TronSignature {
|
|
717
842
|
/** 65-byte hex-encoded signature (no 0x prefix) */
|
|
@@ -723,100 +848,167 @@ interface ITronMethods {
|
|
|
723
848
|
tronSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignMsgParams>>): Promise<Response<TronSignature>>;
|
|
724
849
|
}
|
|
725
850
|
|
|
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
851
|
/** Events generated by SDK internal detection (not from hardware directly). */
|
|
745
852
|
declare const SDK: {
|
|
746
853
|
readonly DEVICE_STUCK: "device-stuck";
|
|
747
854
|
readonly DEVICE_UNRESPONSIVE: "device-unresponsive";
|
|
748
855
|
readonly DEVICE_RECOVERED: "device-recovered";
|
|
749
856
|
readonly DEVICE_INTERACTION: "device-interaction";
|
|
857
|
+
readonly OPERATION_ENDED: "operation-ended";
|
|
750
858
|
};
|
|
751
859
|
|
|
860
|
+
declare const OPERATION_DEFAULT_TTL_MS = 600000;
|
|
861
|
+
type OperationEndReason = 'explicit' | 'disconnect' | 'timeout' | 'runtime-reset';
|
|
862
|
+
type HardwareOperation = {
|
|
863
|
+
operationId: string;
|
|
864
|
+
connectId: string;
|
|
865
|
+
device: DeviceInfo;
|
|
866
|
+
/**
|
|
867
|
+
* The channel this operation runs on, set by the adapter that picked it. Never read it off
|
|
868
|
+
* `device`: a combined connector fills that snapshot with a nominal value.
|
|
869
|
+
*/
|
|
870
|
+
connectionType: ConnectionType;
|
|
871
|
+
connectionKeys: string[];
|
|
872
|
+
};
|
|
873
|
+
type OperationRegistryOptions = {
|
|
874
|
+
vendor: VendorType;
|
|
875
|
+
ttlMs?: number;
|
|
876
|
+
onEnded?: (operation: HardwareOperation, reason: OperationEndReason) => void;
|
|
877
|
+
};
|
|
878
|
+
/** Runtime-only association between a public operation id and one live target. */
|
|
879
|
+
declare class OperationRegistry {
|
|
880
|
+
private readonly _vendor;
|
|
881
|
+
private readonly _ttlMs;
|
|
882
|
+
private readonly _onEnded?;
|
|
883
|
+
private readonly _active;
|
|
884
|
+
private readonly _ended;
|
|
885
|
+
constructor(options: OperationRegistryOptions);
|
|
886
|
+
create(params: {
|
|
887
|
+
searchTargetId: string;
|
|
888
|
+
connectId: string;
|
|
889
|
+
device: DeviceInfo;
|
|
890
|
+
connectionType: ConnectionType;
|
|
891
|
+
connectionKeys?: string[];
|
|
892
|
+
}): HardwareOperation;
|
|
893
|
+
resolve(operationId: string): HardwareOperation;
|
|
894
|
+
/** Keep an operation alive while one device job is actively using it. */
|
|
895
|
+
retain(operationId: string): () => void;
|
|
896
|
+
/** Return a live operation without refreshing its TTL; ended and unknown ids give undefined. */
|
|
897
|
+
findActive(operationId: string): HardwareOperation | undefined;
|
|
898
|
+
/** Return active or tombstoned binding data without refreshing its TTL. */
|
|
899
|
+
find(operationId: string): HardwareOperation | undefined;
|
|
900
|
+
findActiveByConnectionKey(connectionKey: string): HardwareOperation | undefined;
|
|
901
|
+
/** Map a job queue key (an operation id or a connection key) to its live operation id. */
|
|
902
|
+
findOperationIdByJobKey(jobKey: string | undefined): string | undefined;
|
|
903
|
+
/**
|
|
904
|
+
* End an operation on the caller's explicit release. Throws for an unknown id; returns undefined
|
|
905
|
+
* when it had already ended.
|
|
906
|
+
*/
|
|
907
|
+
release(operationId: string): HardwareOperation | undefined;
|
|
908
|
+
end(operationId: string, reason: OperationEndReason): HardwareOperation | undefined;
|
|
909
|
+
endByConnectionKey(connectionKey: string, reason: OperationEndReason, exceptOperationId?: string): void;
|
|
910
|
+
endAll(reason: OperationEndReason, exceptOperationId?: string): void;
|
|
911
|
+
private _touch;
|
|
912
|
+
private _createTimer;
|
|
913
|
+
private _rememberEnded;
|
|
914
|
+
}
|
|
915
|
+
|
|
752
916
|
type HardwareMethodMetadata = {
|
|
753
917
|
chain: ChainForFingerprint;
|
|
754
918
|
allNetwork: boolean;
|
|
919
|
+
/** Whether repeating the method after an ambiguous transport failure is safe. */
|
|
920
|
+
replayAfterTransportFailure: 'safe' | 'unsafe';
|
|
755
921
|
};
|
|
756
922
|
declare const HARDWARE_METHOD_CATALOG: {
|
|
757
923
|
readonly evmGetAddress: {
|
|
758
924
|
readonly chain: "evm";
|
|
759
925
|
readonly allNetwork: true;
|
|
926
|
+
readonly replayAfterTransportFailure: "safe";
|
|
760
927
|
};
|
|
761
928
|
readonly evmSignTransaction: {
|
|
762
929
|
readonly chain: "evm";
|
|
763
930
|
readonly allNetwork: false;
|
|
931
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
764
932
|
};
|
|
765
933
|
readonly evmSignMessage: {
|
|
766
934
|
readonly chain: "evm";
|
|
767
935
|
readonly allNetwork: false;
|
|
936
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
768
937
|
};
|
|
769
938
|
readonly evmSignTypedData: {
|
|
770
939
|
readonly chain: "evm";
|
|
771
940
|
readonly allNetwork: false;
|
|
941
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
772
942
|
};
|
|
773
943
|
readonly btcGetAddress: {
|
|
774
944
|
readonly chain: "btc";
|
|
775
945
|
readonly allNetwork: true;
|
|
946
|
+
readonly replayAfterTransportFailure: "safe";
|
|
776
947
|
};
|
|
777
948
|
readonly btcGetPublicKey: {
|
|
778
949
|
readonly chain: "btc";
|
|
779
950
|
readonly allNetwork: true;
|
|
951
|
+
readonly replayAfterTransportFailure: "safe";
|
|
780
952
|
};
|
|
781
953
|
readonly btcSignTransaction: {
|
|
782
954
|
readonly chain: "btc";
|
|
783
955
|
readonly allNetwork: false;
|
|
956
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
784
957
|
};
|
|
785
958
|
readonly btcSignPsbt: {
|
|
786
959
|
readonly chain: "btc";
|
|
787
960
|
readonly allNetwork: false;
|
|
961
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
788
962
|
};
|
|
789
963
|
readonly btcSignMessage: {
|
|
790
964
|
readonly chain: "btc";
|
|
791
965
|
readonly allNetwork: false;
|
|
966
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
792
967
|
};
|
|
793
968
|
readonly btcGetMasterFingerprint: {
|
|
794
969
|
readonly chain: "btc";
|
|
795
970
|
readonly allNetwork: false;
|
|
971
|
+
readonly replayAfterTransportFailure: "safe";
|
|
796
972
|
};
|
|
797
973
|
readonly solGetAddress: {
|
|
798
974
|
readonly chain: "sol";
|
|
799
975
|
readonly allNetwork: true;
|
|
976
|
+
readonly replayAfterTransportFailure: "safe";
|
|
800
977
|
};
|
|
801
978
|
readonly solSignTransaction: {
|
|
802
979
|
readonly chain: "sol";
|
|
803
980
|
readonly allNetwork: false;
|
|
981
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
804
982
|
};
|
|
805
983
|
readonly solSignMessage: {
|
|
806
984
|
readonly chain: "sol";
|
|
807
985
|
readonly allNetwork: false;
|
|
986
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
808
987
|
};
|
|
809
988
|
readonly tronGetAddress: {
|
|
810
989
|
readonly chain: "tron";
|
|
811
990
|
readonly allNetwork: true;
|
|
991
|
+
readonly replayAfterTransportFailure: "safe";
|
|
812
992
|
};
|
|
813
993
|
readonly tronSignTransaction: {
|
|
814
994
|
readonly chain: "tron";
|
|
815
995
|
readonly allNetwork: false;
|
|
996
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
816
997
|
};
|
|
817
998
|
readonly tronSignMessage: {
|
|
818
999
|
readonly chain: "tron";
|
|
819
1000
|
readonly allNetwork: false;
|
|
1001
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
1002
|
+
};
|
|
1003
|
+
readonly zcashGetFullViewingKey: {
|
|
1004
|
+
readonly chain: "zcash";
|
|
1005
|
+
readonly allNetwork: false;
|
|
1006
|
+
readonly replayAfterTransportFailure: "safe";
|
|
1007
|
+
};
|
|
1008
|
+
readonly zcashGetShieldedAddress: {
|
|
1009
|
+
readonly chain: "zcash";
|
|
1010
|
+
readonly allNetwork: false;
|
|
1011
|
+
readonly replayAfterTransportFailure: "safe";
|
|
820
1012
|
};
|
|
821
1013
|
};
|
|
822
1014
|
type HardwareMethodName = keyof typeof HARDWARE_METHOD_CATALOG;
|
|
@@ -825,6 +1017,11 @@ type AllNetworkMethodName = {
|
|
|
825
1017
|
}[HardwareMethodName];
|
|
826
1018
|
declare const ALL_NETWORK_METHOD_NAMES: AllNetworkMethodName[];
|
|
827
1019
|
declare function getHardwareMethodMetadata(method: string): HardwareMethodMetadata | undefined;
|
|
1020
|
+
/**
|
|
1021
|
+
* Conservative replay gate used only after a call may have reached hardware.
|
|
1022
|
+
* Unknown methods and device mutations are unsafe by default.
|
|
1023
|
+
*/
|
|
1024
|
+
declare function canReplayHardwareMethodAfterTransportFailure(method: string): boolean;
|
|
828
1025
|
declare function isAllNetworkMethodName(method: string): method is AllNetworkMethodName;
|
|
829
1026
|
declare function getAllNetworkMethodChain(method: AllNetworkMethodName): ChainForFingerprint;
|
|
830
1027
|
|
|
@@ -843,7 +1040,7 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
|
|
|
843
1040
|
progress: number;
|
|
844
1041
|
};
|
|
845
1042
|
};
|
|
846
|
-
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron';
|
|
1043
|
+
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron' | 'zcash';
|
|
847
1044
|
type TrezorDisplayRotation = 'North' | 'East' | 'South' | 'West';
|
|
848
1045
|
type TrezorSafetyCheckLevel = 'Strict' | 'PromptAlways' | 'PromptTemporarily';
|
|
849
1046
|
type TrezorDeviceSettingsParams = {
|
|
@@ -914,19 +1111,78 @@ type DeviceAuthenticityResult = {
|
|
|
914
1111
|
};
|
|
915
1112
|
};
|
|
916
1113
|
};
|
|
1114
|
+
/** Persisted connection hints, never proof of device or wallet identity. */
|
|
1115
|
+
type KnownDeviceConnection = {
|
|
1116
|
+
transport: 'usb' | 'ble';
|
|
1117
|
+
connectId: string;
|
|
1118
|
+
} | {
|
|
1119
|
+
transport: 'qr';
|
|
1120
|
+
};
|
|
1121
|
+
/** Opaque host lookup identifiers. Never forward these to firmware or logs. */
|
|
1122
|
+
type HardwareCallExtra = Readonly<Record<string, string>>;
|
|
1123
|
+
interface IHardwareConnectionContext {
|
|
1124
|
+
knownConnections?: readonly KnownDeviceConnection[];
|
|
1125
|
+
extra?: HardwareCallExtra;
|
|
1126
|
+
/** False makes discovery fail instead of asking the user to select a new endpoint. */
|
|
1127
|
+
allowDeviceSelection?: boolean;
|
|
1128
|
+
/** Transports the host's model table allows; discovery never opens others. Omitted = any. */
|
|
1129
|
+
supportedTransports?: readonly ('usb' | 'ble')[];
|
|
1130
|
+
}
|
|
1131
|
+
type DeviceSelectionContext = {
|
|
1132
|
+
kind: 'select-device';
|
|
1133
|
+
transport: 'usb';
|
|
1134
|
+
reason: 'multiple-candidates';
|
|
1135
|
+
} | {
|
|
1136
|
+
kind: 'bind-connection';
|
|
1137
|
+
transport: 'ble';
|
|
1138
|
+
reason: 'missing-binding' | 'known-connection-unavailable' | 'manual-rebind';
|
|
1139
|
+
};
|
|
1140
|
+
interface DeviceSelectionRequest extends UiRequestOperationAttribution {
|
|
1141
|
+
devices: DeviceInfo[];
|
|
1142
|
+
/** Echo this in the `RECEIVE_SELECT_DEVICE` answer; an answer without it is ignored. */
|
|
1143
|
+
requestId: string;
|
|
1144
|
+
context: DeviceSelectionContext;
|
|
1145
|
+
extra?: HardwareCallExtra;
|
|
1146
|
+
/** Repeated snapshots with this requestId update one SDK-owned binding scan. */
|
|
1147
|
+
scanning?: boolean;
|
|
1148
|
+
bindingSessionId?: string;
|
|
1149
|
+
/** A candidate rejected by SDK identity verification in this binding session. */
|
|
1150
|
+
rejectedConnectId?: string;
|
|
1151
|
+
}
|
|
1152
|
+
/** The host must persist this endpoint before acknowledging. */
|
|
1153
|
+
interface SaveDeviceBindingRequest extends UiRequestOperationAttribution {
|
|
1154
|
+
requestId: string;
|
|
1155
|
+
selectionRequestId: string;
|
|
1156
|
+
connection: {
|
|
1157
|
+
transport: 'ble';
|
|
1158
|
+
connectId: string;
|
|
1159
|
+
};
|
|
1160
|
+
/** Omitted when the vendor binds the selected BLE endpoint without checking its wallet (Ledger). */
|
|
1161
|
+
identity?: Extract<WalletIdentity, {
|
|
1162
|
+
vendor: 'ledger' | 'trezor';
|
|
1163
|
+
}>;
|
|
1164
|
+
extra?: HardwareCallExtra;
|
|
1165
|
+
}
|
|
1166
|
+
type BindBleDeviceParams = Pick<SaveDeviceBindingRequest, 'identity' | 'extra'>;
|
|
1167
|
+
interface DeviceBindingStatus {
|
|
1168
|
+
selectionRequestId: string;
|
|
1169
|
+
status: 'verifying' | 'saved' | 'failed' | 'cancelled';
|
|
1170
|
+
}
|
|
917
1171
|
/**
|
|
918
1172
|
* Cross-chain / cross-vendor options passed alongside any chain method's
|
|
919
1173
|
* own params (the optional last argument). Holds operation-level switches
|
|
920
1174
|
* that aren't specific to one chain. Vendor-specific options can be added
|
|
921
1175
|
* as typed sub-fields here when a vendor actually needs them.
|
|
922
1176
|
*/
|
|
923
|
-
interface ICommonCallParams {
|
|
1177
|
+
interface ICommonCallParams extends IHardwareConnectionContext {
|
|
924
1178
|
/**
|
|
925
1179
|
* When the required device app is missing, prompt the user (UI request)
|
|
926
1180
|
* to install it, stream install progress, then retry the operation once.
|
|
927
1181
|
* Off by default — preserves the plain "app not installed" failure.
|
|
928
1182
|
*/
|
|
929
1183
|
autoInstallApp?: boolean;
|
|
1184
|
+
/** Runtime-only id from connectDevice(); when present, discovery and fallback are disabled. */
|
|
1185
|
+
operationId?: string;
|
|
930
1186
|
}
|
|
931
1187
|
type NullableCallArg<T> = T | null | undefined;
|
|
932
1188
|
interface IPassphraseCallParams {
|
|
@@ -935,6 +1191,14 @@ interface IPassphraseCallParams {
|
|
|
935
1191
|
}
|
|
936
1192
|
type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
|
|
937
1193
|
type IHardwareCallParams<T> = T & IHardwareCommonCallParams;
|
|
1194
|
+
/**
|
|
1195
|
+
* Runtime-only device-manager context, never forwarded to firmware. The expected identity lets an
|
|
1196
|
+
* adapter fail closed before replaying a read or mutation after a reconnect.
|
|
1197
|
+
*/
|
|
1198
|
+
interface IDeviceManagerOperationContext extends IHardwareConnectionContext {
|
|
1199
|
+
operationId?: string;
|
|
1200
|
+
expectedDeviceIdentity?: WalletIdentity;
|
|
1201
|
+
}
|
|
938
1202
|
interface AllNetworkAddressParams {
|
|
939
1203
|
network: string;
|
|
940
1204
|
path: string;
|
|
@@ -945,16 +1209,7 @@ interface AllNetworkAddressParams {
|
|
|
945
1209
|
interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
|
|
946
1210
|
bundle: AllNetworkAddressParams[];
|
|
947
1211
|
}
|
|
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
|
-
};
|
|
1212
|
+
type AllNetworkDeviceIdentity = WalletIdentity;
|
|
958
1213
|
type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
959
1214
|
error?: string;
|
|
960
1215
|
code?: HardwareErrorCode | number;
|
|
@@ -962,6 +1217,7 @@ type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
|
962
1217
|
connectId?: string;
|
|
963
1218
|
deviceId?: string;
|
|
964
1219
|
deviceIdentity?: AllNetworkDeviceIdentity;
|
|
1220
|
+
rootFingerprint?: number;
|
|
965
1221
|
chainFingerprint?: string;
|
|
966
1222
|
chainFingerprintChain?: ChainForFingerprint;
|
|
967
1223
|
params?: Record<string, unknown>;
|
|
@@ -1002,6 +1258,7 @@ type DeviceEvent = {
|
|
|
1002
1258
|
connectId: string;
|
|
1003
1259
|
deviceId?: string;
|
|
1004
1260
|
credentials: Record<string, unknown>[];
|
|
1261
|
+
removed?: Record<string, unknown>[];
|
|
1005
1262
|
};
|
|
1006
1263
|
};
|
|
1007
1264
|
type UiRequestEvent = {
|
|
@@ -1010,46 +1267,50 @@ type UiRequestEvent = {
|
|
|
1010
1267
|
device?: DeviceInfo;
|
|
1011
1268
|
connectId?: string;
|
|
1012
1269
|
type?: string;
|
|
1013
|
-
};
|
|
1270
|
+
} & UiRequestOperationAttribution;
|
|
1014
1271
|
} | {
|
|
1015
1272
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
1016
1273
|
payload: {
|
|
1017
1274
|
device: DeviceInfo;
|
|
1018
|
-
};
|
|
1275
|
+
} & UiRequestOperationAttribution;
|
|
1019
1276
|
} | {
|
|
1020
1277
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1021
1278
|
payload: {
|
|
1022
1279
|
device: DeviceInfo;
|
|
1023
|
-
};
|
|
1280
|
+
} & UiRequestOperationAttribution;
|
|
1024
1281
|
} | {
|
|
1025
1282
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1026
1283
|
payload: {
|
|
1027
1284
|
device: DeviceInfo;
|
|
1028
1285
|
code?: string;
|
|
1029
|
-
};
|
|
1286
|
+
} & UiRequestOperationAttribution;
|
|
1030
1287
|
} | {
|
|
1031
1288
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1032
1289
|
payload: {
|
|
1033
1290
|
device: DeviceInfo;
|
|
1034
1291
|
data: QrDisplayData;
|
|
1035
|
-
};
|
|
1292
|
+
} & UiRequestOperationAttribution;
|
|
1036
1293
|
} | {
|
|
1037
1294
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1038
1295
|
payload: {
|
|
1039
1296
|
device: DeviceInfo;
|
|
1040
|
-
};
|
|
1297
|
+
} & UiRequestOperationAttribution;
|
|
1041
1298
|
} | {
|
|
1042
1299
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
1043
1300
|
payload: {
|
|
1044
1301
|
transportType: TransportType;
|
|
1045
1302
|
connectId?: string;
|
|
1046
1303
|
deviceId?: string;
|
|
1047
|
-
};
|
|
1304
|
+
} & UiRequestOperationAttribution;
|
|
1048
1305
|
} | {
|
|
1049
1306
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1050
|
-
payload:
|
|
1051
|
-
|
|
1052
|
-
|
|
1307
|
+
payload: DeviceSelectionRequest;
|
|
1308
|
+
} | {
|
|
1309
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1310
|
+
payload: SaveDeviceBindingRequest;
|
|
1311
|
+
} | {
|
|
1312
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1313
|
+
payload: DeviceBindingStatus;
|
|
1053
1314
|
} | {
|
|
1054
1315
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
1055
1316
|
payload: {
|
|
@@ -1069,13 +1330,13 @@ type UiRequestEvent = {
|
|
|
1069
1330
|
* isn't recognized.
|
|
1070
1331
|
*/
|
|
1071
1332
|
message: string;
|
|
1072
|
-
};
|
|
1333
|
+
} & UiRequestOperationAttribution;
|
|
1073
1334
|
} | {
|
|
1074
1335
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1075
1336
|
payload: {
|
|
1076
1337
|
vendor: string;
|
|
1077
1338
|
appName: string;
|
|
1078
|
-
};
|
|
1339
|
+
} & UiRequestOperationAttribution;
|
|
1079
1340
|
} | {
|
|
1080
1341
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
1081
1342
|
payload: {
|
|
@@ -1083,10 +1344,10 @@ type UiRequestEvent = {
|
|
|
1083
1344
|
availableMethods: number[];
|
|
1084
1345
|
selectedMethod: number;
|
|
1085
1346
|
nfcData?: string;
|
|
1086
|
-
};
|
|
1347
|
+
} & UiRequestOperationAttribution;
|
|
1087
1348
|
} | {
|
|
1088
1349
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1089
|
-
payload:
|
|
1350
|
+
payload: UiRequestOperationAttribution;
|
|
1090
1351
|
};
|
|
1091
1352
|
type SdkEvent = {
|
|
1092
1353
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1109,6 +1370,12 @@ type SdkEvent = {
|
|
|
1109
1370
|
payload: {
|
|
1110
1371
|
connectId: string;
|
|
1111
1372
|
};
|
|
1373
|
+
} | {
|
|
1374
|
+
type: typeof SDK.OPERATION_ENDED;
|
|
1375
|
+
payload: {
|
|
1376
|
+
operationId: string;
|
|
1377
|
+
reason: OperationEndReason;
|
|
1378
|
+
};
|
|
1112
1379
|
};
|
|
1113
1380
|
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent | HardwareUiEvent;
|
|
1114
1381
|
type DeviceEventListener = (event: HardwareEvent) => void;
|
|
@@ -1119,6 +1386,14 @@ type DeviceEventListener = (event: HardwareEvent) => void;
|
|
|
1119
1386
|
* and the value is the narrowed event object the listener will receive.
|
|
1120
1387
|
*/
|
|
1121
1388
|
interface HardwareEventMap {
|
|
1389
|
+
[UI_REQUEST.DEVICE_BINDING_STATUS]: {
|
|
1390
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1391
|
+
payload: DeviceBindingStatus;
|
|
1392
|
+
};
|
|
1393
|
+
[UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING]: {
|
|
1394
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1395
|
+
payload: SaveDeviceBindingRequest;
|
|
1396
|
+
};
|
|
1122
1397
|
'ui-event': HardwareUiEvent;
|
|
1123
1398
|
[DEVICE.CONNECT]: {
|
|
1124
1399
|
type: typeof DEVICE.CONNECT;
|
|
@@ -1151,6 +1426,8 @@ interface HardwareEventMap {
|
|
|
1151
1426
|
connectId: string;
|
|
1152
1427
|
deviceId?: string;
|
|
1153
1428
|
credentials: Record<string, unknown>[];
|
|
1429
|
+
/** Credentials the device rejected; a list kept for several devices drops these. */
|
|
1430
|
+
removed?: Record<string, unknown>[];
|
|
1154
1431
|
};
|
|
1155
1432
|
};
|
|
1156
1433
|
[UI_REQUEST.REQUEST_PIN]: {
|
|
@@ -1159,7 +1436,7 @@ interface HardwareEventMap {
|
|
|
1159
1436
|
device?: DeviceInfo;
|
|
1160
1437
|
connectId?: string;
|
|
1161
1438
|
type?: string;
|
|
1162
|
-
};
|
|
1439
|
+
} & UiRequestOperationAttribution;
|
|
1163
1440
|
};
|
|
1164
1441
|
[UI_REQUEST.REQUEST_PASSPHRASE]: {
|
|
1165
1442
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
@@ -1168,33 +1445,33 @@ interface HardwareEventMap {
|
|
|
1168
1445
|
connectId?: string;
|
|
1169
1446
|
passphraseState?: string;
|
|
1170
1447
|
useEmptyPassphrase?: boolean;
|
|
1171
|
-
};
|
|
1448
|
+
} & UiRequestOperationAttribution;
|
|
1172
1449
|
};
|
|
1173
1450
|
[UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
|
|
1174
1451
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1175
1452
|
payload: {
|
|
1176
1453
|
device: DeviceInfo;
|
|
1177
|
-
};
|
|
1454
|
+
} & UiRequestOperationAttribution;
|
|
1178
1455
|
};
|
|
1179
1456
|
[UI_REQUEST.REQUEST_BUTTON]: {
|
|
1180
1457
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1181
1458
|
payload: {
|
|
1182
1459
|
device: DeviceInfo;
|
|
1183
1460
|
code?: string;
|
|
1184
|
-
};
|
|
1461
|
+
} & UiRequestOperationAttribution;
|
|
1185
1462
|
};
|
|
1186
1463
|
[UI_REQUEST.REQUEST_QR_DISPLAY]: {
|
|
1187
1464
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1188
1465
|
payload: {
|
|
1189
1466
|
device: DeviceInfo;
|
|
1190
1467
|
data: QrDisplayData;
|
|
1191
|
-
};
|
|
1468
|
+
} & UiRequestOperationAttribution;
|
|
1192
1469
|
};
|
|
1193
1470
|
[UI_REQUEST.REQUEST_QR_SCAN]: {
|
|
1194
1471
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1195
1472
|
payload: {
|
|
1196
1473
|
device: DeviceInfo;
|
|
1197
|
-
};
|
|
1474
|
+
} & UiRequestOperationAttribution;
|
|
1198
1475
|
};
|
|
1199
1476
|
[UI_REQUEST.REQUEST_DEVICE_PERMISSION]: {
|
|
1200
1477
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
@@ -1202,13 +1479,11 @@ interface HardwareEventMap {
|
|
|
1202
1479
|
transportType: TransportType;
|
|
1203
1480
|
connectId?: string;
|
|
1204
1481
|
deviceId?: string;
|
|
1205
|
-
};
|
|
1482
|
+
} & UiRequestOperationAttribution;
|
|
1206
1483
|
};
|
|
1207
1484
|
[UI_REQUEST.REQUEST_SELECT_DEVICE]: {
|
|
1208
1485
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1209
|
-
payload:
|
|
1210
|
-
devices: DeviceInfo[];
|
|
1211
|
-
};
|
|
1486
|
+
payload: DeviceSelectionRequest;
|
|
1212
1487
|
};
|
|
1213
1488
|
[UI_REQUEST.REQUEST_DEVICE_CONNECT]: {
|
|
1214
1489
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
@@ -1216,7 +1491,7 @@ interface HardwareEventMap {
|
|
|
1216
1491
|
vendor: string;
|
|
1217
1492
|
reason: string;
|
|
1218
1493
|
message: string;
|
|
1219
|
-
};
|
|
1494
|
+
} & UiRequestOperationAttribution;
|
|
1220
1495
|
};
|
|
1221
1496
|
[UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM]: {
|
|
1222
1497
|
type: typeof UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM;
|
|
@@ -1224,14 +1499,14 @@ interface HardwareEventMap {
|
|
|
1224
1499
|
vendor: string;
|
|
1225
1500
|
path: string;
|
|
1226
1501
|
accountIndex: number;
|
|
1227
|
-
};
|
|
1502
|
+
} & UiRequestOperationAttribution;
|
|
1228
1503
|
};
|
|
1229
1504
|
[UI_REQUEST.REQUEST_INSTALL_APP]: {
|
|
1230
1505
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1231
1506
|
payload: {
|
|
1232
1507
|
vendor: string;
|
|
1233
1508
|
appName: string;
|
|
1234
|
-
};
|
|
1509
|
+
} & UiRequestOperationAttribution;
|
|
1235
1510
|
};
|
|
1236
1511
|
[UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
|
|
1237
1512
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
@@ -1240,11 +1515,11 @@ interface HardwareEventMap {
|
|
|
1240
1515
|
availableMethods: number[];
|
|
1241
1516
|
selectedMethod: number;
|
|
1242
1517
|
nfcData?: string;
|
|
1243
|
-
};
|
|
1518
|
+
} & UiRequestOperationAttribution;
|
|
1244
1519
|
};
|
|
1245
1520
|
[UI_REQUEST.CLOSE_UI_WINDOW]: {
|
|
1246
1521
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1247
|
-
payload:
|
|
1522
|
+
payload: UiRequestOperationAttribution;
|
|
1248
1523
|
};
|
|
1249
1524
|
[SDK.DEVICE_INTERACTION]: {
|
|
1250
1525
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1271,16 +1546,23 @@ interface HardwareEventMap {
|
|
|
1271
1546
|
connectId: string;
|
|
1272
1547
|
};
|
|
1273
1548
|
};
|
|
1549
|
+
[SDK.OPERATION_ENDED]: {
|
|
1550
|
+
type: typeof SDK.OPERATION_ENDED;
|
|
1551
|
+
payload: {
|
|
1552
|
+
operationId: string;
|
|
1553
|
+
reason: OperationEndReason;
|
|
1554
|
+
};
|
|
1555
|
+
};
|
|
1274
1556
|
}
|
|
1275
1557
|
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>>>;
|
|
1558
|
+
getFeatures?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1559
|
+
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1560
|
+
setBrightness?(connectId: string, params?: TrezorBrightnessParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1561
|
+
changePin?(connectId: string, params?: TrezorChangePinParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1562
|
+
wipeDevice?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1281
1563
|
authenticateDevice?(connectId: string, params: {
|
|
1282
1564
|
challenge: string;
|
|
1283
|
-
}): Promise<Response<Record<string, unknown>>>;
|
|
1565
|
+
}, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1284
1566
|
}
|
|
1285
1567
|
interface IWalletStateMethods {
|
|
1286
1568
|
/**
|
|
@@ -1307,20 +1589,35 @@ interface IWalletStateMethods {
|
|
|
1307
1589
|
* Optional: vendors without host-managed passphrase sessions (Ledger) omit
|
|
1308
1590
|
* it. Implemented by `TrezorAdapter`.
|
|
1309
1591
|
*/
|
|
1310
|
-
getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
|
|
1592
|
+
getPassphraseState?(connectId: string, passphraseState?: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<string | null>>;
|
|
1311
1593
|
}
|
|
1594
|
+
/**
|
|
1595
|
+
* `stops-waiting`: an on-device confirmation stays up until answered or timed out.
|
|
1596
|
+
* `interrupts-device`: the command on the wire is withdrawn. No vendor reports it, so hosts
|
|
1597
|
+
* should say "stopped waiting, answer on the device", not "cancelled".
|
|
1598
|
+
*/
|
|
1599
|
+
type CancelCapability = 'interrupts-device' | 'stops-waiting';
|
|
1312
1600
|
interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
|
|
1313
1601
|
readonly vendor: string;
|
|
1314
1602
|
readonly activeTransport: TransportType | null;
|
|
1603
|
+
/** What `cancel()` reaches on this vendor. Declared, never inferred. */
|
|
1604
|
+
readonly cancelCapability: CancelCapability;
|
|
1315
1605
|
init(config: TConfig): Promise<void>;
|
|
1316
1606
|
dispose(): Promise<void>;
|
|
1317
1607
|
getAvailableTransports(): TransportType[];
|
|
1318
1608
|
switchTransport(type: TransportType): Promise<void>;
|
|
1319
1609
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
1320
|
-
|
|
1321
|
-
|
|
1610
|
+
/** Discover selectable hardware entries without claiming identified devices or wallets. */
|
|
1611
|
+
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
1612
|
+
/** Connect or logically bind a selected search result and return a runtime-only operation id. */
|
|
1613
|
+
connectDevice(searchTargetId: string): Promise<Response<string>>;
|
|
1614
|
+
/** Device Manager rebind: verify the existing identity before replacing its BLE locator. */
|
|
1615
|
+
bindBleDevice?(params: BindBleDeviceParams): Promise<Response<string>>;
|
|
1616
|
+
/** Resolve and pin operation routing; the caller verifies wallet identity before business calls. */
|
|
1617
|
+
acquireOperation?(connectId: string, context: IHardwareConnectionContext): Promise<Response<string>>;
|
|
1618
|
+
/** Release a caller-owned operation. Disconnect events end matching operations automatically. */
|
|
1619
|
+
releaseOperation(operationId: string): Promise<void>;
|
|
1322
1620
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
1323
|
-
getSupportedChains(): ChainCapability[];
|
|
1324
1621
|
/** Abort the in-flight call. Omit connectId to cancel whatever is active. */
|
|
1325
1622
|
cancel(connectId?: string): void;
|
|
1326
1623
|
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
@@ -1357,6 +1654,11 @@ interface SearchDevicesOptions {
|
|
|
1357
1654
|
* was discovered first.
|
|
1358
1655
|
*/
|
|
1359
1656
|
waitForAllTransports?: boolean;
|
|
1657
|
+
/**
|
|
1658
|
+
* Restrict discovery to one transport. A virtual target (Keystone QR) must not start any wallet
|
|
1659
|
+
* interaction during discovery; `connectDevice()` resolves it.
|
|
1660
|
+
*/
|
|
1661
|
+
transportType?: ConnectionType;
|
|
1360
1662
|
}
|
|
1361
1663
|
|
|
1362
1664
|
interface EvmGetAddressParams extends PassphraseStateAware {
|
|
@@ -1370,6 +1672,8 @@ interface EvmAddress {
|
|
|
1370
1672
|
path: string;
|
|
1371
1673
|
/** Device-reported secp256k1 public key; populated when the transport exposes it. */
|
|
1372
1674
|
publicKey?: string;
|
|
1675
|
+
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
1676
|
+
accountKey?: ExportedAccountKey;
|
|
1373
1677
|
}
|
|
1374
1678
|
interface EvmSignTxBaseParams extends PassphraseStateAware {
|
|
1375
1679
|
path: string;
|
|
@@ -1480,6 +1784,11 @@ interface EvmSignTypedDataFull extends PassphraseStateAware {
|
|
|
1480
1784
|
primaryType: string;
|
|
1481
1785
|
message: Record<string, unknown>;
|
|
1482
1786
|
};
|
|
1787
|
+
/**
|
|
1788
|
+
* The dApp's original EIP-712 JSON, byte for byte. Serializing vendors (Keystone) must prefer it:
|
|
1789
|
+
* re-stringifying `data` rewrites integers wider than 2^53 and exponent forms.
|
|
1790
|
+
*/
|
|
1791
|
+
dataJson?: string;
|
|
1483
1792
|
metamaskV4Compat?: boolean;
|
|
1484
1793
|
showMessageHash?: boolean;
|
|
1485
1794
|
/**
|
|
@@ -1518,6 +1827,33 @@ interface IEvmMethods {
|
|
|
1518
1827
|
evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
|
|
1519
1828
|
}
|
|
1520
1829
|
|
|
1830
|
+
/** Which `GET_VK` encoding the Ledger Zcash app should return. */
|
|
1831
|
+
type ZcashFullViewingKeyMode = 'ufvk' | 'orchardFvk';
|
|
1832
|
+
interface ZcashGetFullViewingKeyParams extends PassphraseStateAware {
|
|
1833
|
+
/** BIP44 account path `m/44'/133'/a'`; a deeper transparent path is accepted, only `a'` is used. */
|
|
1834
|
+
path: string;
|
|
1835
|
+
/** Default `ufvk`. */
|
|
1836
|
+
mode?: ZcashFullViewingKeyMode;
|
|
1837
|
+
}
|
|
1838
|
+
interface ZcashFullViewingKey {
|
|
1839
|
+
path: string;
|
|
1840
|
+
mode: ZcashFullViewingKeyMode;
|
|
1841
|
+
/** ZIP-316 bech32m UFVK string (mode `ufvk`). */
|
|
1842
|
+
ufvk?: string;
|
|
1843
|
+
/** 96-byte raw Orchard FVK as hex (mode `orchardFvk`). */
|
|
1844
|
+
orchardFvk?: string;
|
|
1845
|
+
}
|
|
1846
|
+
interface ZcashGetShieldedAddressParams extends PassphraseStateAware {
|
|
1847
|
+
/** Full 5-level transparent path `m/44'/133'/a'/0/i`; the Orchard path is derived from it. */
|
|
1848
|
+
path: string;
|
|
1849
|
+
showOnDevice?: boolean;
|
|
1850
|
+
}
|
|
1851
|
+
interface ZcashShieldedAddress {
|
|
1852
|
+
/** Unified address with a single Orchard receiver. */
|
|
1853
|
+
address: string;
|
|
1854
|
+
path: string;
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1521
1857
|
/**
|
|
1522
1858
|
* Low-level device descriptor from Transport layer.
|
|
1523
1859
|
* Represents a physical device detected by USB/BLE scanning.
|
|
@@ -1563,14 +1899,13 @@ interface DeviceDisconnectEvent {
|
|
|
1563
1899
|
type DeviceChangeEvent = DeviceConnectEvent | DeviceDisconnectEvent;
|
|
1564
1900
|
|
|
1565
1901
|
/**
|
|
1566
|
-
*
|
|
1567
|
-
*
|
|
1568
|
-
*
|
|
1569
|
-
*
|
|
1570
|
-
*
|
|
1571
|
-
*
|
|
1572
|
-
*
|
|
1573
|
-
* synchronously, without racing against in-flight enqueues.
|
|
1902
|
+
* Serializes every device call and gives callers one handle to cancel them. Ordering is already
|
|
1903
|
+
* guaranteed by awaiting callers, so what this adds is an AbortController per job, a busy check
|
|
1904
|
+
* that rejects double-submits, and generation tracking so a job queued before a teardown doesn't
|
|
1905
|
+
* start after it; these races exist even for a sequential caller because cleanup is async.
|
|
1906
|
+
*
|
|
1907
|
+
* Interrupt-or-ask policy belongs to the caller; `getActiveJob()` is synchronous so a UI handler
|
|
1908
|
+
* can look, decide, and submit in one turn without racing an in-flight enqueue.
|
|
1574
1909
|
*/
|
|
1575
1910
|
interface JobOptions {
|
|
1576
1911
|
label?: string;
|
|
@@ -1582,10 +1917,15 @@ interface ActiveJobInfo {
|
|
|
1582
1917
|
label?: string;
|
|
1583
1918
|
startedAt: number;
|
|
1584
1919
|
}
|
|
1920
|
+
interface CancelScopeHandle {
|
|
1921
|
+
signal: AbortSignal;
|
|
1922
|
+
release: () => void;
|
|
1923
|
+
}
|
|
1585
1924
|
declare class DeviceJobQueue {
|
|
1586
1925
|
private _tail;
|
|
1587
1926
|
private _active;
|
|
1588
1927
|
private readonly _jobs;
|
|
1928
|
+
private readonly _cancelScopes;
|
|
1589
1929
|
/** Incremented on clear() so queued-but-not-yet-running jobs detect invalidation. */
|
|
1590
1930
|
private _generation;
|
|
1591
1931
|
private readonly _generationCancelReasons;
|
|
@@ -1594,21 +1934,64 @@ declare class DeviceJobQueue {
|
|
|
1594
1934
|
* `deviceId` is a label only — used by inspection / cancellation routing.
|
|
1595
1935
|
*/
|
|
1596
1936
|
enqueue<T>(deviceId: string, job: (signal: AbortSignal) => Promise<T>, options?: JobOptions): Promise<T>;
|
|
1597
|
-
/**
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1937
|
+
/**
|
|
1938
|
+
* Holds a cancel across the gaps between a bundle's per-item jobs, when the queue is empty.
|
|
1939
|
+
* Callers must `release()` when the bundle ends.
|
|
1940
|
+
*/
|
|
1941
|
+
createCancelScope(deviceId: string): CancelScopeHandle;
|
|
1942
|
+
/**
|
|
1943
|
+
* Cancels the running job only; `reason` becomes signal.reason. Adapters use
|
|
1944
|
+
* `cancelActiveAndPending`; this stays for a connector layer that stops only what is on the wire.
|
|
1945
|
+
*/
|
|
1946
|
+
cancelActive(deviceId?: string, reason?: Error): boolean;
|
|
1947
|
+
/**
|
|
1948
|
+
* Cancels the active job and unstarted queued jobs; returns whether anything was reached. Only
|
|
1949
|
+
* `undefined` means everything: an empty key matches nothing instead of tearing the queue down.
|
|
1950
|
+
*/
|
|
1604
1951
|
cancelActiveAndPending(deviceId?: string, reason?: Error): boolean;
|
|
1605
1952
|
/** Get info about the currently active job, or null if idle. */
|
|
1606
1953
|
getActiveJob(deviceId?: string): ActiveJobInfo | null;
|
|
1607
|
-
/** True if any job is currently running. */
|
|
1608
|
-
isBusy(): boolean;
|
|
1609
1954
|
clear(reason?: Error): void;
|
|
1610
1955
|
}
|
|
1611
1956
|
|
|
1957
|
+
declare const HARDWARE_RUNTIME_ID_PREFIX = "hwk:runtime";
|
|
1958
|
+
/**
|
|
1959
|
+
* `search-target`: one device in one discovery snapshot, dead on the next search of that kind.
|
|
1960
|
+
* `link`: one open transport. `operation`: one business operation.
|
|
1961
|
+
*/
|
|
1962
|
+
type HardwareRuntimeIdKind = 'operation' | 'search-target' | 'link';
|
|
1963
|
+
type HardwareRuntimeId = {
|
|
1964
|
+
kind: HardwareRuntimeIdKind;
|
|
1965
|
+
vendor: VendorType;
|
|
1966
|
+
};
|
|
1967
|
+
/** Runtime ids are opaque and must never be persisted as device identity. */
|
|
1968
|
+
declare function createHardwareOperationId(vendor: VendorType): string;
|
|
1969
|
+
/** Search targets are valid only for the adapter's current discovery snapshot. */
|
|
1970
|
+
declare function createHardwareSearchTargetId(vendor: VendorType): string;
|
|
1971
|
+
declare function createHardwareLinkId(vendor: VendorType): string;
|
|
1972
|
+
declare function hasHardwareRuntimeIdPrefix(value: unknown): value is string;
|
|
1973
|
+
declare function parseHardwareRuntimeId(value: unknown): HardwareRuntimeId | undefined;
|
|
1974
|
+
declare function isHardwareOperationId(value: unknown): value is string;
|
|
1975
|
+
|
|
1976
|
+
interface HardwareOperationTarget {
|
|
1977
|
+
/** Effective target accepted by existing adapter/connector call paths. */
|
|
1978
|
+
targetId: string | undefined;
|
|
1979
|
+
/** Present when this operation is pinned to a live operation. */
|
|
1980
|
+
operationId: string | undefined;
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Normalizes the transitional positional operation id and the canonical
|
|
1984
|
+
* common-params field. All vendors must reject conflicting bindings.
|
|
1985
|
+
*/
|
|
1986
|
+
declare function resolveHardwareOperationTarget(positionalTargetId: string | null | undefined, commonOperationId: string | null | undefined, expectedVendor?: VendorType): Response<HardwareOperationTarget>;
|
|
1987
|
+
/** Narrow the connection-context fields of untyped call params. */
|
|
1988
|
+
declare function pickConnectionContext(params: {
|
|
1989
|
+
knownConnections?: unknown;
|
|
1990
|
+
extra?: unknown;
|
|
1991
|
+
allowDeviceSelection?: unknown;
|
|
1992
|
+
supportedTransports?: unknown;
|
|
1993
|
+
}): IHardwareConnectionContext;
|
|
1994
|
+
|
|
1612
1995
|
/**
|
|
1613
1996
|
* Minimal typed event emitter using Map<string, Set<listener>>.
|
|
1614
1997
|
* Each adapter uses this for device events (connect, disconnect, pin, etc.).
|
|
@@ -1635,6 +2018,104 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
|
|
|
1635
2018
|
listenerCount(event: string): number;
|
|
1636
2019
|
}
|
|
1637
2020
|
|
|
2021
|
+
/** Serializable BLE transport data shared by Electron main and renderer runtimes. */
|
|
2022
|
+
interface ElectronBleDeviceInfo {
|
|
2023
|
+
id: string;
|
|
2024
|
+
name?: string;
|
|
2025
|
+
rssi?: number;
|
|
2026
|
+
advertisedServiceUuids?: string[];
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* IPC-safe peripheral match: advertises one of `serviceUuids`, or its local name matches every
|
|
2030
|
+
* `namePatterns` entry (case-insensitive regex sources). The desktop noble-ble host treats this
|
|
2031
|
+
* as a hint only: its vendor allowlist decides, `serviceUuids` can only narrow it, and
|
|
2032
|
+
* `namePatterns` are never compiled.
|
|
2033
|
+
*/
|
|
2034
|
+
interface ElectronBleMatch {
|
|
2035
|
+
serviceUuids?: string[];
|
|
2036
|
+
namePatterns?: string[];
|
|
2037
|
+
}
|
|
2038
|
+
interface ElectronBleScanOptions {
|
|
2039
|
+
/** Opaque partition key: results and connected devices never mix across it. */
|
|
2040
|
+
vendor?: string;
|
|
2041
|
+
match?: ElectronBleMatch;
|
|
2042
|
+
/** @deprecated Superseded by `match.serviceUuids`. */
|
|
2043
|
+
serviceUuids?: string[];
|
|
2044
|
+
durationMs?: number;
|
|
2045
|
+
}
|
|
2046
|
+
/** GATT profile plus the write framing this vendor's firmware expects. */
|
|
2047
|
+
interface ElectronBleConnectOptions {
|
|
2048
|
+
vendor: string;
|
|
2049
|
+
serviceUuid: string;
|
|
2050
|
+
writeUuid: string;
|
|
2051
|
+
notifyUuid: string;
|
|
2052
|
+
/**
|
|
2053
|
+
* `padded`: fixed `chunkSize` packets, last zero-filled (Trezor firmware drops short packets).
|
|
2054
|
+
* `raw`: the buffer as given, for self-length-framed protocols (Ledger).
|
|
2055
|
+
*/
|
|
2056
|
+
write?: {
|
|
2057
|
+
mode: 'padded' | 'raw';
|
|
2058
|
+
chunkSize?: number;
|
|
2059
|
+
chunkDelayMs?: number;
|
|
2060
|
+
maxLength?: number;
|
|
2061
|
+
};
|
|
2062
|
+
}
|
|
2063
|
+
/** Native code handles GATT only; framing, identity checks and wallet calls stay in the SDK. */
|
|
2064
|
+
interface ElectronBleApi {
|
|
2065
|
+
scan(options?: ElectronBleScanOptions): Promise<ElectronBleDeviceInfo[]>;
|
|
2066
|
+
stopScan(vendor?: string): Promise<void>;
|
|
2067
|
+
connect(id: string, options?: ElectronBleConnectOptions): Promise<{
|
|
2068
|
+
id: string;
|
|
2069
|
+
name?: string;
|
|
2070
|
+
}>;
|
|
2071
|
+
disconnect(id: string): Promise<void>;
|
|
2072
|
+
subscribe(id: string): Promise<void>;
|
|
2073
|
+
unsubscribe(id: string): Promise<void>;
|
|
2074
|
+
write(id: string, hexData: string): Promise<void>;
|
|
2075
|
+
checkAvailability(): Promise<{
|
|
2076
|
+
available: boolean;
|
|
2077
|
+
state: string;
|
|
2078
|
+
initialized: boolean;
|
|
2079
|
+
}>;
|
|
2080
|
+
getDevice(id: string): Promise<ElectronBleDeviceInfo | null>;
|
|
2081
|
+
onNotification(handler: (id: string, hexData: string) => void): () => void;
|
|
2082
|
+
onDeviceDisconnected(handler: (id: string) => void): () => void;
|
|
2083
|
+
/** Abandon an in-flight connect in the main process. Optional for hosts that cannot cancel. */
|
|
2084
|
+
cancelPairing?(options?: {
|
|
2085
|
+
vendor: string;
|
|
2086
|
+
id?: string;
|
|
2087
|
+
}): Promise<void>;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
declare function emitDeviceBindingStatus(emitter: TypedEventEmitter<HardwareEventMap>, selectionRequestId: string, status: DeviceBindingStatus['status']): void;
|
|
2091
|
+
/**
|
|
2092
|
+
* A host refusal is reported, never thrown: the device is already connected, so a lost binding
|
|
2093
|
+
* is worth a warning and a retry, not failing the user's work.
|
|
2094
|
+
*/
|
|
2095
|
+
type SaveDeviceBindingOutcome = {
|
|
2096
|
+
saved: true;
|
|
2097
|
+
} | {
|
|
2098
|
+
saved: false;
|
|
2099
|
+
reason: SaveDeviceBindingDeclineReason;
|
|
2100
|
+
};
|
|
2101
|
+
/** Persist a binding through the host. Only a user abort throws. */
|
|
2102
|
+
declare function requestSaveDeviceBinding(emitter: TypedEventEmitter<HardwareEventMap>, registry: UiRequestRegistry, binding: Omit<SaveDeviceBindingRequest, 'requestId'>, signal?: AbortSignal): Promise<SaveDeviceBindingOutcome>;
|
|
2103
|
+
|
|
2104
|
+
/** Discovery and selection share one owner; never connect until the last scan has drained. */
|
|
2105
|
+
declare function requestBleDeviceSelection({ emitter, registry, request, scan, signal, allowUsbFallback, pollIntervalMs, }: {
|
|
2106
|
+
emitter: TypedEventEmitter<HardwareEventMap>;
|
|
2107
|
+
registry: UiRequestRegistry;
|
|
2108
|
+
request: Omit<DeviceSelectionRequest, 'requestId' | 'scanning'>;
|
|
2109
|
+
scan: () => Promise<DeviceInfo[]>;
|
|
2110
|
+
signal: AbortSignal;
|
|
2111
|
+
/** The adapter must verify a returned USB candidate before dispatching any business call. */
|
|
2112
|
+
allowUsbFallback?: boolean;
|
|
2113
|
+
pollIntervalMs?: number;
|
|
2114
|
+
}): Promise<{
|
|
2115
|
+
device: DeviceInfo;
|
|
2116
|
+
requestId: string;
|
|
2117
|
+
}>;
|
|
2118
|
+
|
|
1638
2119
|
/**
|
|
1639
2120
|
* Compare two semver strings (e.g. "2.1.0" vs "2.3.1").
|
|
1640
2121
|
* Returns -1 if a < b, 0 if equal, 1 if a > b.
|
|
@@ -1655,7 +2136,57 @@ declare function hexToBytes(hex: string): Uint8Array;
|
|
|
1655
2136
|
/** Convert a Uint8Array to a hex string (no 0x prefix). */
|
|
1656
2137
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
1657
2138
|
|
|
1658
|
-
|
|
2139
|
+
/**
|
|
2140
|
+
* Walks CBOR from an untrusted source (a scanned QR code, a device reply) before a third-party
|
|
2141
|
+
* decoder sees it. Those decoders read past the end as zero and trust declared lengths, so one
|
|
2142
|
+
* indefinite-length header or a huge declared count exhausts memory. This walk accepts only
|
|
2143
|
+
* definite lengths that fit in the bytes actually present, bounded nesting, and no trailing bytes.
|
|
2144
|
+
*/
|
|
2145
|
+
declare function assertBoundedCbor(input: Uint8Array, maxBytes?: number): void;
|
|
2146
|
+
/** Hex from an untrusted source, checked as such and then as bounded CBOR. */
|
|
2147
|
+
declare function boundedCborFromHex(hex: string, maxBytes?: number): Buffer;
|
|
2148
|
+
|
|
2149
|
+
interface PrepareSolanaOffchainMessageV1Params {
|
|
2150
|
+
message: Uint8Array;
|
|
2151
|
+
requiredSigners: readonly string[];
|
|
2152
|
+
}
|
|
2153
|
+
interface PreparedSolanaOffchainMessageV1 {
|
|
2154
|
+
messageText: string;
|
|
2155
|
+
requiredSigners: string[];
|
|
2156
|
+
serializedMessage: Uint8Array;
|
|
2157
|
+
}
|
|
2158
|
+
declare function prepareSolanaOffchainMessageV1({ message, requiredSigners, }: PrepareSolanaOffchainMessageV1Params): PreparedSolanaOffchainMessageV1;
|
|
2159
|
+
|
|
2160
|
+
type LogSummaryContext = {
|
|
2161
|
+
/** Method name from the options, or '' when none was given. */
|
|
2162
|
+
method: string;
|
|
2163
|
+
role: 'params' | 'result';
|
|
2164
|
+
};
|
|
2165
|
+
/**
|
|
2166
|
+
* Returns extra space-separated hints for a payload field (e.g. PSBT input/output counts), or
|
|
2167
|
+
* undefined to add nothing. `key` is normalized: lower-case with `_` and `-` removed. Hints are
|
|
2168
|
+
* appended verbatim, so they must not contain payload contents. A throwing describer is ignored.
|
|
2169
|
+
*/
|
|
2170
|
+
type LogPayloadDescriber = (key: string, value: string | Uint8Array, context: LogSummaryContext) => string | undefined;
|
|
2171
|
+
type LogSummaryOptions = {
|
|
2172
|
+
/** Public or connector method name; enables chain-specific hints (EVM tx type). */
|
|
2173
|
+
method?: string;
|
|
2174
|
+
/** In results, transaction fields hold signed transactions rather than requests. */
|
|
2175
|
+
role?: 'params' | 'result';
|
|
2176
|
+
/** Chain-specific payload hints that need a decoder adapter-core does not ship. */
|
|
2177
|
+
describePayload?: LogPayloadDescriber;
|
|
2178
|
+
};
|
|
2179
|
+
/**
|
|
2180
|
+
* JSON-safe, log-safe summary of `value`. Never throws.
|
|
2181
|
+
*
|
|
2182
|
+
* Paths, chain ids, flags and error fields stay readable; payloads become
|
|
2183
|
+
* `<hex|str|json len=N sha256=16hex [hints]>`, addresses `first6…last4`, xpubs `xpub… len=N`,
|
|
2184
|
+
* public keys and chain codes `… len=N`, signatures `<signature len=N>` and secrets
|
|
2185
|
+
* `<redacted len=N>`.
|
|
2186
|
+
*/
|
|
2187
|
+
declare function summarizeForLog(value: unknown, options?: LogSummaryOptions): unknown;
|
|
2188
|
+
|
|
2189
|
+
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger' | 'keystone';
|
|
1659
2190
|
type HardwareDeviceIdentityInput = {
|
|
1660
2191
|
name?: string | null;
|
|
1661
2192
|
localName?: string | null;
|
|
@@ -1718,8 +2249,19 @@ type RunAllNetworkGetAddressOptions = {
|
|
|
1718
2249
|
buildTopLevelFailure?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => Response<AllNetworkAddressResponse[]>;
|
|
1719
2250
|
};
|
|
1720
2251
|
declare function runAllNetworkGetAddress({ connectId, deviceId, params, getMethodChain, normalizeItem, buildUnsupportedNetworkResponse, callItem, attachIdentity, shouldAbortBundle, buildTopLevelFailure, }: RunAllNetworkGetAddressOptions): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
2252
|
+
/** An SDK-dialog cancel or on-device reject ends the bundle; the user already answered "no". */
|
|
2253
|
+
declare function isUserRefusal(code: HardwareErrorCode | number | undefined): boolean;
|
|
2254
|
+
/**
|
|
2255
|
+
* The device or wallet could not be shown to be the one asked for: another wallet, a locked
|
|
2256
|
+
* device, a wrong PIN or passphrase. No later item may derive on it, and a PIN is not retried.
|
|
2257
|
+
*/
|
|
2258
|
+
declare function isWalletSafetyFailure(code: HardwareErrorCode | number | undefined): boolean;
|
|
2259
|
+
/** The bundle's session is gone, so the remaining items have nothing to run against. */
|
|
2260
|
+
declare function isConnectionLost(code: HardwareErrorCode | number | undefined): boolean;
|
|
2261
|
+
/** UserAborted is a top-level abort code, so this ends the bundle. */
|
|
2262
|
+
declare function buildAllNetworkCancelledFailure<T>(signal: AbortSignal): Response<T>;
|
|
1721
2263
|
declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams): AllNetworkAddressResponse;
|
|
1722
2264
|
|
|
1723
2265
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
1724
2266
|
|
|
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 };
|
|
2267
|
+
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, type LogPayloadDescriber, type LogSummaryContext, type LogSummaryOptions, 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, summarizeForLog, toPhysicalDeviceSearchTarget };
|