@onekeyfe/hwk-adapter-core 1.2.8-alpha.13 → 1.2.8-alpha.14
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-YIQFVAFZ.js → chunk-BAGEFFFY.js} +13 -45
- package/dist/chunk-BAGEFFFY.js.map +1 -0
- package/dist/{chunk-T5HIQPNG.js → chunk-SZZF623R.js} +55 -155
- package/dist/chunk-SZZF623R.js.map +1 -0
- package/dist/{chunk-3D45OEC2.mjs → chunk-U63HTLGJ.mjs} +12 -44
- package/dist/chunk-U63HTLGJ.mjs.map +1 -0
- package/dist/{chunk-KTRQZ5AJ.mjs → chunk-YA4BWFTZ.mjs} +55 -155
- package/dist/chunk-YA4BWFTZ.mjs.map +1 -0
- package/dist/errors.d.mts +207 -1
- package/dist/errors.d.ts +207 -1
- package/dist/errors.js +2 -8
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +3 -9
- package/dist/index.d.mts +104 -610
- package/dist/index.d.ts +104 -610
- package/dist/index.js +86 -754
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -746
- package/dist/index.mjs.map +1 -1
- package/dist/{ui-events-29Va0fPc.d.ts → ui-events-Cb7haAeE.d.mts} +3 -57
- package/dist/{ui-events-29Va0fPc.d.mts → ui-events-Cb7haAeE.d.ts} +3 -57
- package/dist/ui-events.d.mts +1 -1
- package/dist/ui-events.d.ts +1 -1
- package/dist/ui-events.js +2 -3
- package/dist/ui-events.js.map +1 -1
- package/dist/ui-events.mjs +1 -2
- package/package.json +2 -2
- package/dist/chunk-3D45OEC2.mjs.map +0 -1
- package/dist/chunk-DB4JOPZO.mjs +0 -74
- package/dist/chunk-DB4JOPZO.mjs.map +0 -1
- package/dist/chunk-KTRQZ5AJ.mjs.map +0 -1
- package/dist/chunk-T5HIQPNG.js.map +0 -1
- package/dist/chunk-YIQFVAFZ.js.map +0 -1
- package/dist/chunk-YLCHSNXO.js +0 -74
- package/dist/chunk-YLCHSNXO.js.map +0 -1
- package/dist/errors-BgJ4kzRx.d.mts +0 -276
- package/dist/errors-BgJ4kzRx.d.ts +0 -276
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { U as UiResponseEvent,
|
|
4
|
-
export { D as DevicePermissionDeniedReason,
|
|
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-Cb7haAeE.mjs';
|
|
4
|
+
export { D as DevicePermissionDeniedReason, b as DevicePermissionResponse, c as QrResponseData, d as UI_EVENT, e as UI_REQUEST_CANCELLED_TAG, f as UI_REQUEST_DEFAULT_TIMEOUT_MS, g as UI_REQUEST_PREEMPTED_TAG, h as UI_REQUEST_TIMEOUT_TAG, i as UI_RESPONSE, j as UiRequestRegistry } from './ui-events-Cb7haAeE.mjs';
|
|
5
5
|
|
|
6
6
|
interface Success<T> {
|
|
7
7
|
success: true;
|
|
@@ -12,51 +12,16 @@ 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;
|
|
21
15
|
params?: Record<string, unknown>;
|
|
22
16
|
};
|
|
23
17
|
}
|
|
24
18
|
type Response<T> = Success<T> | Failure;
|
|
25
19
|
declare function success<T>(payload: T): Success<T>;
|
|
26
|
-
declare function failure(code: HardwareErrorCode, error: string, params?: Record<string, unknown
|
|
20
|
+
declare function failure(code: HardwareErrorCode, error: string, params?: Record<string, unknown>): Failure;
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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';
|
|
22
|
+
type VendorType = 'trezor' | 'ledger';
|
|
23
|
+
type ConnectionType = 'usb' | 'ble';
|
|
24
|
+
type TransportType = 'usb' | 'ble' | 'hid' | 'bridge';
|
|
60
25
|
/**
|
|
61
26
|
* Device capabilities — describes what a specific device/connection
|
|
62
27
|
* combination can or cannot do. Varies by vendor, model, and connection type.
|
|
@@ -66,8 +31,12 @@ type TransportType = 'usb' | 'ble' | 'hid' | 'bridge' | 'qr';
|
|
|
66
31
|
*/
|
|
67
32
|
interface DeviceCapabilities {
|
|
68
33
|
/**
|
|
69
|
-
* Whether
|
|
70
|
-
*
|
|
34
|
+
* Whether connectId/deviceId persist across sessions.
|
|
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.
|
|
71
40
|
*/
|
|
72
41
|
persistentDeviceIdentity: boolean;
|
|
73
42
|
}
|
|
@@ -104,46 +73,6 @@ interface DeviceTarget {
|
|
|
104
73
|
connectId: string;
|
|
105
74
|
deviceId: string;
|
|
106
75
|
}
|
|
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
|
-
};
|
|
147
76
|
|
|
148
77
|
/**
|
|
149
78
|
* Mixin for chain-operation params that can be pinned to a specific passphrase
|
|
@@ -204,15 +133,6 @@ interface ConnectorSession {
|
|
|
204
133
|
sessionId: string;
|
|
205
134
|
deviceInfo: DeviceInfo;
|
|
206
135
|
}
|
|
207
|
-
type ConnectorConnectTarget = {
|
|
208
|
-
type: 'default';
|
|
209
|
-
} | {
|
|
210
|
-
type: 'search-target';
|
|
211
|
-
searchTargetId: string;
|
|
212
|
-
} | {
|
|
213
|
-
type: 'expected-device-identity';
|
|
214
|
-
deviceIdentity: string;
|
|
215
|
-
};
|
|
216
136
|
/**
|
|
217
137
|
* Vendor-agnostic bag of extra error fields. Known keys are documented for
|
|
218
138
|
* discoverability; the index signature keeps it open so any connector can
|
|
@@ -325,8 +245,6 @@ interface ConnectorEventMap {
|
|
|
325
245
|
connectId: string;
|
|
326
246
|
deviceId?: string;
|
|
327
247
|
credentials: Record<string, unknown>[];
|
|
328
|
-
/** Credentials the device rejected; a list kept for several devices drops these. */
|
|
329
|
-
removed?: Record<string, unknown>[];
|
|
330
248
|
};
|
|
331
249
|
'ui-request': {
|
|
332
250
|
type: string;
|
|
@@ -335,16 +253,12 @@ interface ConnectorEventMap {
|
|
|
335
253
|
'ui-event': ConnectorUiEvent;
|
|
336
254
|
}
|
|
337
255
|
interface ConnectorSearchDevicesOptions {
|
|
338
|
-
/** Select a child transport without waking/scanning the others. */
|
|
339
|
-
transportType?: ConnectionType;
|
|
340
256
|
/**
|
|
341
257
|
* Wait for every child transport in a fused connector. Default discovery can
|
|
342
258
|
* return shortly after USB appears so BLE does not slow down USB flows;
|
|
343
259
|
* binding pickers can opt in when they need BLE candidates too.
|
|
344
260
|
*/
|
|
345
261
|
waitForAll?: boolean;
|
|
346
|
-
/** Availability probes must not invalidate user-selectable discovery targets. */
|
|
347
|
-
purpose?: 'selection' | 'availability';
|
|
348
262
|
}
|
|
349
263
|
interface ConnectorConfig {
|
|
350
264
|
/**
|
|
@@ -359,16 +273,8 @@ interface ConnectorConfig {
|
|
|
359
273
|
interface IConnector {
|
|
360
274
|
/** Physical connection type this connector uses. Fixed at construction. */
|
|
361
275
|
readonly connectionType: ConnectionType;
|
|
362
|
-
readonly availableTransports?: readonly ConnectionType[];
|
|
363
276
|
searchDevices(options?: ConnectorSearchDevicesOptions): Promise<ConnectorDevice[]>;
|
|
364
|
-
connect(deviceId?: string
|
|
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>;
|
|
277
|
+
connect(deviceId?: string): Promise<ConnectorSession>;
|
|
372
278
|
disconnect(sessionId: string): Promise<void>;
|
|
373
279
|
call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
|
|
374
280
|
cancel(sessionId: string): Promise<void>;
|
|
@@ -393,9 +299,6 @@ interface IHardwareBridge {
|
|
|
393
299
|
connect(params: {
|
|
394
300
|
vendor: VendorType;
|
|
395
301
|
deviceId?: string;
|
|
396
|
-
options?: {
|
|
397
|
-
transportType: ConnectionType;
|
|
398
|
-
};
|
|
399
302
|
}): Promise<ConnectorSession>;
|
|
400
303
|
disconnect(params: {
|
|
401
304
|
vendor: VendorType;
|
|
@@ -504,8 +407,6 @@ interface BtcGetAddressParams extends PassphraseStateAware {
|
|
|
504
407
|
interface BtcAddress {
|
|
505
408
|
address: string;
|
|
506
409
|
path: string;
|
|
507
|
-
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
508
|
-
accountKey?: ExportedAccountKey;
|
|
509
410
|
}
|
|
510
411
|
interface BtcGetPublicKeyParams extends PassphraseStateAware {
|
|
511
412
|
path: string;
|
|
@@ -520,8 +421,6 @@ interface BtcPublicKey {
|
|
|
520
421
|
chainCode: string;
|
|
521
422
|
path: string;
|
|
522
423
|
depth: number;
|
|
523
|
-
/** Set by air-gapped wallets (Keystone): the exported key, for pinning by the host. */
|
|
524
|
-
accountKey?: ExportedAccountKey;
|
|
525
424
|
}
|
|
526
425
|
interface BtcSignTxParams extends PassphraseStateAware {
|
|
527
426
|
psbt?: string;
|
|
@@ -662,8 +561,6 @@ interface SolAddress {
|
|
|
662
561
|
/** Base58-encoded Solana address — this is also the Ed25519 public key. */
|
|
663
562
|
address: string;
|
|
664
563
|
path: string;
|
|
665
|
-
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
666
|
-
accountKey?: ExportedAccountKey;
|
|
667
564
|
}
|
|
668
565
|
interface SolSignTxParams extends PassphraseStateAware {
|
|
669
566
|
path: string;
|
|
@@ -684,21 +581,11 @@ interface SolSignedTx {
|
|
|
684
581
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
685
582
|
signature: string;
|
|
686
583
|
}
|
|
687
|
-
interface
|
|
584
|
+
interface SolSignMsgParams extends PassphraseStateAware {
|
|
688
585
|
path: string;
|
|
689
586
|
/** Message bytes as hex string (no 0x prefix) */
|
|
690
587
|
message: string;
|
|
691
588
|
}
|
|
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);
|
|
702
589
|
interface SolSignature {
|
|
703
590
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
704
591
|
signature: string;
|
|
@@ -717,8 +604,6 @@ interface TronAddress {
|
|
|
717
604
|
/** Base58check-encoded TRON address (starts with 'T') */
|
|
718
605
|
address: string;
|
|
719
606
|
path: string;
|
|
720
|
-
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
721
|
-
accountKey?: ExportedAccountKey;
|
|
722
607
|
}
|
|
723
608
|
/** TRON network resource, used by freeze/unfreeze contracts. */
|
|
724
609
|
type TronResource = 'BANDWIDTH' | 'ENERGY';
|
|
@@ -827,12 +712,6 @@ interface TronSignMsgParams extends PassphraseStateAware {
|
|
|
827
712
|
path: string;
|
|
828
713
|
/** Message hex (no 0x prefix) */
|
|
829
714
|
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';
|
|
836
715
|
}
|
|
837
716
|
interface TronSignature {
|
|
838
717
|
/** 65-byte hex-encoded signature (no 0x prefix) */
|
|
@@ -844,167 +723,100 @@ interface ITronMethods {
|
|
|
844
723
|
tronSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignMsgParams>>): Promise<Response<TronSignature>>;
|
|
845
724
|
}
|
|
846
725
|
|
|
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
|
+
|
|
847
744
|
/** Events generated by SDK internal detection (not from hardware directly). */
|
|
848
745
|
declare const SDK: {
|
|
849
746
|
readonly DEVICE_STUCK: "device-stuck";
|
|
850
747
|
readonly DEVICE_UNRESPONSIVE: "device-unresponsive";
|
|
851
748
|
readonly DEVICE_RECOVERED: "device-recovered";
|
|
852
749
|
readonly DEVICE_INTERACTION: "device-interaction";
|
|
853
|
-
readonly OPERATION_ENDED: "operation-ended";
|
|
854
750
|
};
|
|
855
751
|
|
|
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
|
-
|
|
912
752
|
type HardwareMethodMetadata = {
|
|
913
753
|
chain: ChainForFingerprint;
|
|
914
754
|
allNetwork: boolean;
|
|
915
|
-
/** Whether repeating the method after an ambiguous transport failure is safe. */
|
|
916
|
-
replayAfterTransportFailure: 'safe' | 'unsafe';
|
|
917
755
|
};
|
|
918
756
|
declare const HARDWARE_METHOD_CATALOG: {
|
|
919
757
|
readonly evmGetAddress: {
|
|
920
758
|
readonly chain: "evm";
|
|
921
759
|
readonly allNetwork: true;
|
|
922
|
-
readonly replayAfterTransportFailure: "safe";
|
|
923
760
|
};
|
|
924
761
|
readonly evmSignTransaction: {
|
|
925
762
|
readonly chain: "evm";
|
|
926
763
|
readonly allNetwork: false;
|
|
927
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
928
764
|
};
|
|
929
765
|
readonly evmSignMessage: {
|
|
930
766
|
readonly chain: "evm";
|
|
931
767
|
readonly allNetwork: false;
|
|
932
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
933
768
|
};
|
|
934
769
|
readonly evmSignTypedData: {
|
|
935
770
|
readonly chain: "evm";
|
|
936
771
|
readonly allNetwork: false;
|
|
937
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
938
772
|
};
|
|
939
773
|
readonly btcGetAddress: {
|
|
940
774
|
readonly chain: "btc";
|
|
941
775
|
readonly allNetwork: true;
|
|
942
|
-
readonly replayAfterTransportFailure: "safe";
|
|
943
776
|
};
|
|
944
777
|
readonly btcGetPublicKey: {
|
|
945
778
|
readonly chain: "btc";
|
|
946
779
|
readonly allNetwork: true;
|
|
947
|
-
readonly replayAfterTransportFailure: "safe";
|
|
948
780
|
};
|
|
949
781
|
readonly btcSignTransaction: {
|
|
950
782
|
readonly chain: "btc";
|
|
951
783
|
readonly allNetwork: false;
|
|
952
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
953
784
|
};
|
|
954
785
|
readonly btcSignPsbt: {
|
|
955
786
|
readonly chain: "btc";
|
|
956
787
|
readonly allNetwork: false;
|
|
957
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
958
788
|
};
|
|
959
789
|
readonly btcSignMessage: {
|
|
960
790
|
readonly chain: "btc";
|
|
961
791
|
readonly allNetwork: false;
|
|
962
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
963
792
|
};
|
|
964
793
|
readonly btcGetMasterFingerprint: {
|
|
965
794
|
readonly chain: "btc";
|
|
966
795
|
readonly allNetwork: false;
|
|
967
|
-
readonly replayAfterTransportFailure: "safe";
|
|
968
796
|
};
|
|
969
797
|
readonly solGetAddress: {
|
|
970
798
|
readonly chain: "sol";
|
|
971
799
|
readonly allNetwork: true;
|
|
972
|
-
readonly replayAfterTransportFailure: "safe";
|
|
973
800
|
};
|
|
974
801
|
readonly solSignTransaction: {
|
|
975
802
|
readonly chain: "sol";
|
|
976
803
|
readonly allNetwork: false;
|
|
977
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
978
804
|
};
|
|
979
805
|
readonly solSignMessage: {
|
|
980
806
|
readonly chain: "sol";
|
|
981
807
|
readonly allNetwork: false;
|
|
982
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
983
808
|
};
|
|
984
809
|
readonly tronGetAddress: {
|
|
985
810
|
readonly chain: "tron";
|
|
986
811
|
readonly allNetwork: true;
|
|
987
|
-
readonly replayAfterTransportFailure: "safe";
|
|
988
812
|
};
|
|
989
813
|
readonly tronSignTransaction: {
|
|
990
814
|
readonly chain: "tron";
|
|
991
815
|
readonly allNetwork: false;
|
|
992
|
-
readonly replayAfterTransportFailure: "unsafe";
|
|
993
816
|
};
|
|
994
817
|
readonly tronSignMessage: {
|
|
995
818
|
readonly chain: "tron";
|
|
996
819
|
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";
|
|
1008
820
|
};
|
|
1009
821
|
};
|
|
1010
822
|
type HardwareMethodName = keyof typeof HARDWARE_METHOD_CATALOG;
|
|
@@ -1013,11 +825,6 @@ type AllNetworkMethodName = {
|
|
|
1013
825
|
}[HardwareMethodName];
|
|
1014
826
|
declare const ALL_NETWORK_METHOD_NAMES: AllNetworkMethodName[];
|
|
1015
827
|
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;
|
|
1021
828
|
declare function isAllNetworkMethodName(method: string): method is AllNetworkMethodName;
|
|
1022
829
|
declare function getAllNetworkMethodChain(method: AllNetworkMethodName): ChainForFingerprint;
|
|
1023
830
|
|
|
@@ -1036,7 +843,7 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
|
|
|
1036
843
|
progress: number;
|
|
1037
844
|
};
|
|
1038
845
|
};
|
|
1039
|
-
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron'
|
|
846
|
+
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron';
|
|
1040
847
|
type TrezorDisplayRotation = 'North' | 'East' | 'South' | 'West';
|
|
1041
848
|
type TrezorSafetyCheckLevel = 'Strict' | 'PromptAlways' | 'PromptTemporarily';
|
|
1042
849
|
type TrezorDeviceSettingsParams = {
|
|
@@ -1107,77 +914,19 @@ type DeviceAuthenticityResult = {
|
|
|
1107
914
|
};
|
|
1108
915
|
};
|
|
1109
916
|
};
|
|
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
|
-
}
|
|
1166
917
|
/**
|
|
1167
918
|
* Cross-chain / cross-vendor options passed alongside any chain method's
|
|
1168
919
|
* own params (the optional last argument). Holds operation-level switches
|
|
1169
920
|
* that aren't specific to one chain. Vendor-specific options can be added
|
|
1170
921
|
* as typed sub-fields here when a vendor actually needs them.
|
|
1171
922
|
*/
|
|
1172
|
-
interface ICommonCallParams
|
|
923
|
+
interface ICommonCallParams {
|
|
1173
924
|
/**
|
|
1174
925
|
* When the required device app is missing, prompt the user (UI request)
|
|
1175
926
|
* to install it, stream install progress, then retry the operation once.
|
|
1176
927
|
* Off by default — preserves the plain "app not installed" failure.
|
|
1177
928
|
*/
|
|
1178
929
|
autoInstallApp?: boolean;
|
|
1179
|
-
/** Runtime-only id from connectDevice(); when present, discovery and fallback are disabled. */
|
|
1180
|
-
operationId?: string;
|
|
1181
930
|
}
|
|
1182
931
|
type NullableCallArg<T> = T | null | undefined;
|
|
1183
932
|
interface IPassphraseCallParams {
|
|
@@ -1186,14 +935,6 @@ interface IPassphraseCallParams {
|
|
|
1186
935
|
}
|
|
1187
936
|
type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
|
|
1188
937
|
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
|
-
}
|
|
1197
938
|
interface AllNetworkAddressParams {
|
|
1198
939
|
network: string;
|
|
1199
940
|
path: string;
|
|
@@ -1204,7 +945,16 @@ interface AllNetworkAddressParams {
|
|
|
1204
945
|
interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
|
|
1205
946
|
bundle: AllNetworkAddressParams[];
|
|
1206
947
|
}
|
|
1207
|
-
type AllNetworkDeviceIdentity =
|
|
948
|
+
type AllNetworkDeviceIdentity = {
|
|
949
|
+
vendor: 'ledger';
|
|
950
|
+
type: 'chainFingerprint';
|
|
951
|
+
chain: ChainForFingerprint;
|
|
952
|
+
value: string;
|
|
953
|
+
} | {
|
|
954
|
+
vendor: 'trezor';
|
|
955
|
+
type: 'deviceId';
|
|
956
|
+
value: string;
|
|
957
|
+
};
|
|
1208
958
|
type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
1209
959
|
error?: string;
|
|
1210
960
|
code?: HardwareErrorCode | number;
|
|
@@ -1212,7 +962,6 @@ type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
|
1212
962
|
connectId?: string;
|
|
1213
963
|
deviceId?: string;
|
|
1214
964
|
deviceIdentity?: AllNetworkDeviceIdentity;
|
|
1215
|
-
rootFingerprint?: number;
|
|
1216
965
|
chainFingerprint?: string;
|
|
1217
966
|
chainFingerprintChain?: ChainForFingerprint;
|
|
1218
967
|
params?: Record<string, unknown>;
|
|
@@ -1253,7 +1002,6 @@ type DeviceEvent = {
|
|
|
1253
1002
|
connectId: string;
|
|
1254
1003
|
deviceId?: string;
|
|
1255
1004
|
credentials: Record<string, unknown>[];
|
|
1256
|
-
removed?: Record<string, unknown>[];
|
|
1257
1005
|
};
|
|
1258
1006
|
};
|
|
1259
1007
|
type UiRequestEvent = {
|
|
@@ -1262,50 +1010,46 @@ type UiRequestEvent = {
|
|
|
1262
1010
|
device?: DeviceInfo;
|
|
1263
1011
|
connectId?: string;
|
|
1264
1012
|
type?: string;
|
|
1265
|
-
}
|
|
1013
|
+
};
|
|
1266
1014
|
} | {
|
|
1267
1015
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
1268
1016
|
payload: {
|
|
1269
1017
|
device: DeviceInfo;
|
|
1270
|
-
}
|
|
1018
|
+
};
|
|
1271
1019
|
} | {
|
|
1272
1020
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1273
1021
|
payload: {
|
|
1274
1022
|
device: DeviceInfo;
|
|
1275
|
-
}
|
|
1023
|
+
};
|
|
1276
1024
|
} | {
|
|
1277
1025
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1278
1026
|
payload: {
|
|
1279
1027
|
device: DeviceInfo;
|
|
1280
1028
|
code?: string;
|
|
1281
|
-
}
|
|
1029
|
+
};
|
|
1282
1030
|
} | {
|
|
1283
1031
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1284
1032
|
payload: {
|
|
1285
1033
|
device: DeviceInfo;
|
|
1286
1034
|
data: QrDisplayData;
|
|
1287
|
-
}
|
|
1035
|
+
};
|
|
1288
1036
|
} | {
|
|
1289
1037
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1290
1038
|
payload: {
|
|
1291
1039
|
device: DeviceInfo;
|
|
1292
|
-
}
|
|
1040
|
+
};
|
|
1293
1041
|
} | {
|
|
1294
1042
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
1295
1043
|
payload: {
|
|
1296
1044
|
transportType: TransportType;
|
|
1297
1045
|
connectId?: string;
|
|
1298
1046
|
deviceId?: string;
|
|
1299
|
-
}
|
|
1047
|
+
};
|
|
1300
1048
|
} | {
|
|
1301
1049
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1302
|
-
payload:
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
payload: SaveDeviceBindingRequest;
|
|
1306
|
-
} | {
|
|
1307
|
-
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1308
|
-
payload: DeviceBindingStatus;
|
|
1050
|
+
payload: {
|
|
1051
|
+
devices: DeviceInfo[];
|
|
1052
|
+
};
|
|
1309
1053
|
} | {
|
|
1310
1054
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
1311
1055
|
payload: {
|
|
@@ -1325,13 +1069,13 @@ type UiRequestEvent = {
|
|
|
1325
1069
|
* isn't recognized.
|
|
1326
1070
|
*/
|
|
1327
1071
|
message: string;
|
|
1328
|
-
}
|
|
1072
|
+
};
|
|
1329
1073
|
} | {
|
|
1330
1074
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1331
1075
|
payload: {
|
|
1332
1076
|
vendor: string;
|
|
1333
1077
|
appName: string;
|
|
1334
|
-
}
|
|
1078
|
+
};
|
|
1335
1079
|
} | {
|
|
1336
1080
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
1337
1081
|
payload: {
|
|
@@ -1339,10 +1083,10 @@ type UiRequestEvent = {
|
|
|
1339
1083
|
availableMethods: number[];
|
|
1340
1084
|
selectedMethod: number;
|
|
1341
1085
|
nfcData?: string;
|
|
1342
|
-
}
|
|
1086
|
+
};
|
|
1343
1087
|
} | {
|
|
1344
1088
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1345
|
-
payload:
|
|
1089
|
+
payload: Record<string, never>;
|
|
1346
1090
|
};
|
|
1347
1091
|
type SdkEvent = {
|
|
1348
1092
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1365,12 +1109,6 @@ type SdkEvent = {
|
|
|
1365
1109
|
payload: {
|
|
1366
1110
|
connectId: string;
|
|
1367
1111
|
};
|
|
1368
|
-
} | {
|
|
1369
|
-
type: typeof SDK.OPERATION_ENDED;
|
|
1370
|
-
payload: {
|
|
1371
|
-
operationId: string;
|
|
1372
|
-
reason: OperationEndReason;
|
|
1373
|
-
};
|
|
1374
1112
|
};
|
|
1375
1113
|
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent | HardwareUiEvent;
|
|
1376
1114
|
type DeviceEventListener = (event: HardwareEvent) => void;
|
|
@@ -1381,14 +1119,6 @@ type DeviceEventListener = (event: HardwareEvent) => void;
|
|
|
1381
1119
|
* and the value is the narrowed event object the listener will receive.
|
|
1382
1120
|
*/
|
|
1383
1121
|
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
|
-
};
|
|
1392
1122
|
'ui-event': HardwareUiEvent;
|
|
1393
1123
|
[DEVICE.CONNECT]: {
|
|
1394
1124
|
type: typeof DEVICE.CONNECT;
|
|
@@ -1421,8 +1151,6 @@ interface HardwareEventMap {
|
|
|
1421
1151
|
connectId: string;
|
|
1422
1152
|
deviceId?: string;
|
|
1423
1153
|
credentials: Record<string, unknown>[];
|
|
1424
|
-
/** Credentials the device rejected; a list kept for several devices drops these. */
|
|
1425
|
-
removed?: Record<string, unknown>[];
|
|
1426
1154
|
};
|
|
1427
1155
|
};
|
|
1428
1156
|
[UI_REQUEST.REQUEST_PIN]: {
|
|
@@ -1431,7 +1159,7 @@ interface HardwareEventMap {
|
|
|
1431
1159
|
device?: DeviceInfo;
|
|
1432
1160
|
connectId?: string;
|
|
1433
1161
|
type?: string;
|
|
1434
|
-
}
|
|
1162
|
+
};
|
|
1435
1163
|
};
|
|
1436
1164
|
[UI_REQUEST.REQUEST_PASSPHRASE]: {
|
|
1437
1165
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
@@ -1440,33 +1168,33 @@ interface HardwareEventMap {
|
|
|
1440
1168
|
connectId?: string;
|
|
1441
1169
|
passphraseState?: string;
|
|
1442
1170
|
useEmptyPassphrase?: boolean;
|
|
1443
|
-
}
|
|
1171
|
+
};
|
|
1444
1172
|
};
|
|
1445
1173
|
[UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
|
|
1446
1174
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1447
1175
|
payload: {
|
|
1448
1176
|
device: DeviceInfo;
|
|
1449
|
-
}
|
|
1177
|
+
};
|
|
1450
1178
|
};
|
|
1451
1179
|
[UI_REQUEST.REQUEST_BUTTON]: {
|
|
1452
1180
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1453
1181
|
payload: {
|
|
1454
1182
|
device: DeviceInfo;
|
|
1455
1183
|
code?: string;
|
|
1456
|
-
}
|
|
1184
|
+
};
|
|
1457
1185
|
};
|
|
1458
1186
|
[UI_REQUEST.REQUEST_QR_DISPLAY]: {
|
|
1459
1187
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1460
1188
|
payload: {
|
|
1461
1189
|
device: DeviceInfo;
|
|
1462
1190
|
data: QrDisplayData;
|
|
1463
|
-
}
|
|
1191
|
+
};
|
|
1464
1192
|
};
|
|
1465
1193
|
[UI_REQUEST.REQUEST_QR_SCAN]: {
|
|
1466
1194
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1467
1195
|
payload: {
|
|
1468
1196
|
device: DeviceInfo;
|
|
1469
|
-
}
|
|
1197
|
+
};
|
|
1470
1198
|
};
|
|
1471
1199
|
[UI_REQUEST.REQUEST_DEVICE_PERMISSION]: {
|
|
1472
1200
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
@@ -1474,11 +1202,13 @@ interface HardwareEventMap {
|
|
|
1474
1202
|
transportType: TransportType;
|
|
1475
1203
|
connectId?: string;
|
|
1476
1204
|
deviceId?: string;
|
|
1477
|
-
}
|
|
1205
|
+
};
|
|
1478
1206
|
};
|
|
1479
1207
|
[UI_REQUEST.REQUEST_SELECT_DEVICE]: {
|
|
1480
1208
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1481
|
-
payload:
|
|
1209
|
+
payload: {
|
|
1210
|
+
devices: DeviceInfo[];
|
|
1211
|
+
};
|
|
1482
1212
|
};
|
|
1483
1213
|
[UI_REQUEST.REQUEST_DEVICE_CONNECT]: {
|
|
1484
1214
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
@@ -1486,7 +1216,7 @@ interface HardwareEventMap {
|
|
|
1486
1216
|
vendor: string;
|
|
1487
1217
|
reason: string;
|
|
1488
1218
|
message: string;
|
|
1489
|
-
}
|
|
1219
|
+
};
|
|
1490
1220
|
};
|
|
1491
1221
|
[UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM]: {
|
|
1492
1222
|
type: typeof UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM;
|
|
@@ -1494,14 +1224,14 @@ interface HardwareEventMap {
|
|
|
1494
1224
|
vendor: string;
|
|
1495
1225
|
path: string;
|
|
1496
1226
|
accountIndex: number;
|
|
1497
|
-
}
|
|
1227
|
+
};
|
|
1498
1228
|
};
|
|
1499
1229
|
[UI_REQUEST.REQUEST_INSTALL_APP]: {
|
|
1500
1230
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1501
1231
|
payload: {
|
|
1502
1232
|
vendor: string;
|
|
1503
1233
|
appName: string;
|
|
1504
|
-
}
|
|
1234
|
+
};
|
|
1505
1235
|
};
|
|
1506
1236
|
[UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
|
|
1507
1237
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
@@ -1510,11 +1240,11 @@ interface HardwareEventMap {
|
|
|
1510
1240
|
availableMethods: number[];
|
|
1511
1241
|
selectedMethod: number;
|
|
1512
1242
|
nfcData?: string;
|
|
1513
|
-
}
|
|
1243
|
+
};
|
|
1514
1244
|
};
|
|
1515
1245
|
[UI_REQUEST.CLOSE_UI_WINDOW]: {
|
|
1516
1246
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1517
|
-
payload:
|
|
1247
|
+
payload: Record<string, never>;
|
|
1518
1248
|
};
|
|
1519
1249
|
[SDK.DEVICE_INTERACTION]: {
|
|
1520
1250
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1541,23 +1271,16 @@ interface HardwareEventMap {
|
|
|
1541
1271
|
connectId: string;
|
|
1542
1272
|
};
|
|
1543
1273
|
};
|
|
1544
|
-
[SDK.OPERATION_ENDED]: {
|
|
1545
|
-
type: typeof SDK.OPERATION_ENDED;
|
|
1546
|
-
payload: {
|
|
1547
|
-
operationId: string;
|
|
1548
|
-
reason: OperationEndReason;
|
|
1549
|
-
};
|
|
1550
|
-
};
|
|
1551
1274
|
}
|
|
1552
1275
|
interface IDeviceManagerMethods {
|
|
1553
|
-
getFeatures?(connectId: string
|
|
1554
|
-
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams
|
|
1555
|
-
setBrightness?(connectId: string, params?: TrezorBrightnessParams
|
|
1556
|
-
changePin?(connectId: string, params?: TrezorChangePinParams
|
|
1557
|
-
wipeDevice?(connectId: string
|
|
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
1281
|
authenticateDevice?(connectId: string, params: {
|
|
1559
1282
|
challenge: string;
|
|
1560
|
-
}
|
|
1283
|
+
}): Promise<Response<Record<string, unknown>>>;
|
|
1561
1284
|
}
|
|
1562
1285
|
interface IWalletStateMethods {
|
|
1563
1286
|
/**
|
|
@@ -1584,35 +1307,20 @@ interface IWalletStateMethods {
|
|
|
1584
1307
|
* Optional: vendors without host-managed passphrase sessions (Ledger) omit
|
|
1585
1308
|
* it. Implemented by `TrezorAdapter`.
|
|
1586
1309
|
*/
|
|
1587
|
-
getPassphraseState?(connectId: string, passphraseState?: string
|
|
1310
|
+
getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
|
|
1588
1311
|
}
|
|
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';
|
|
1595
1312
|
interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
|
|
1596
1313
|
readonly vendor: string;
|
|
1597
1314
|
readonly activeTransport: TransportType | null;
|
|
1598
|
-
/** What `cancel()` reaches on this vendor. Declared, never inferred. */
|
|
1599
|
-
readonly cancelCapability: CancelCapability;
|
|
1600
1315
|
init(config: TConfig): Promise<void>;
|
|
1601
1316
|
dispose(): Promise<void>;
|
|
1602
1317
|
getAvailableTransports(): TransportType[];
|
|
1603
1318
|
switchTransport(type: TransportType): Promise<void>;
|
|
1604
1319
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
1605
|
-
|
|
1606
|
-
|
|
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>;
|
|
1320
|
+
connectDevice(connectId: string): Promise<Response<string>>;
|
|
1321
|
+
disconnectDevice(connectId: string): Promise<void>;
|
|
1615
1322
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
1323
|
+
getSupportedChains(): ChainCapability[];
|
|
1616
1324
|
/** Abort the in-flight call. Omit connectId to cancel whatever is active. */
|
|
1617
1325
|
cancel(connectId?: string): void;
|
|
1618
1326
|
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
@@ -1649,11 +1357,6 @@ interface SearchDevicesOptions {
|
|
|
1649
1357
|
* was discovered first.
|
|
1650
1358
|
*/
|
|
1651
1359
|
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;
|
|
1657
1360
|
}
|
|
1658
1361
|
|
|
1659
1362
|
interface EvmGetAddressParams extends PassphraseStateAware {
|
|
@@ -1667,8 +1370,6 @@ interface EvmAddress {
|
|
|
1667
1370
|
path: string;
|
|
1668
1371
|
/** Device-reported secp256k1 public key; populated when the transport exposes it. */
|
|
1669
1372
|
publicKey?: string;
|
|
1670
|
-
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
1671
|
-
accountKey?: ExportedAccountKey;
|
|
1672
1373
|
}
|
|
1673
1374
|
interface EvmSignTxBaseParams extends PassphraseStateAware {
|
|
1674
1375
|
path: string;
|
|
@@ -1779,11 +1480,6 @@ interface EvmSignTypedDataFull extends PassphraseStateAware {
|
|
|
1779
1480
|
primaryType: string;
|
|
1780
1481
|
message: Record<string, unknown>;
|
|
1781
1482
|
};
|
|
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;
|
|
1787
1483
|
metamaskV4Compat?: boolean;
|
|
1788
1484
|
showMessageHash?: boolean;
|
|
1789
1485
|
/**
|
|
@@ -1822,33 +1518,6 @@ interface IEvmMethods {
|
|
|
1822
1518
|
evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
|
|
1823
1519
|
}
|
|
1824
1520
|
|
|
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
|
-
|
|
1852
1521
|
/**
|
|
1853
1522
|
* Low-level device descriptor from Transport layer.
|
|
1854
1523
|
* Represents a physical device detected by USB/BLE scanning.
|
|
@@ -1894,13 +1563,14 @@ interface DeviceDisconnectEvent {
|
|
|
1894
1563
|
type DeviceChangeEvent = DeviceConnectEvent | DeviceDisconnectEvent;
|
|
1895
1564
|
|
|
1896
1565
|
/**
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1566
|
+
* Pure FIFO job queue. Every enqueue chains onto the tail; jobs run one at
|
|
1567
|
+
* a time across all devices. The queue is intentionally passive — it does
|
|
1568
|
+
* NOT decide whether to interrupt or ask the user. Those are application-
|
|
1569
|
+
* layer concerns owned by the caller (e.g. a UI button handler that wants
|
|
1570
|
+
* to ask "device is busy, interrupt current?" before submitting). The
|
|
1571
|
+
* queue exposes inspection (`getActiveJob`) and explicit cancellation
|
|
1572
|
+
* (`cancelActive` / `cancelAll`) so callers can implement those policies
|
|
1573
|
+
* synchronously, without racing against in-flight enqueues.
|
|
1904
1574
|
*/
|
|
1905
1575
|
interface JobOptions {
|
|
1906
1576
|
label?: string;
|
|
@@ -1912,15 +1582,10 @@ interface ActiveJobInfo {
|
|
|
1912
1582
|
label?: string;
|
|
1913
1583
|
startedAt: number;
|
|
1914
1584
|
}
|
|
1915
|
-
interface CancelScopeHandle {
|
|
1916
|
-
signal: AbortSignal;
|
|
1917
|
-
release: () => void;
|
|
1918
|
-
}
|
|
1919
1585
|
declare class DeviceJobQueue {
|
|
1920
1586
|
private _tail;
|
|
1921
1587
|
private _active;
|
|
1922
1588
|
private readonly _jobs;
|
|
1923
|
-
private readonly _cancelScopes;
|
|
1924
1589
|
/** Incremented on clear() so queued-but-not-yet-running jobs detect invalidation. */
|
|
1925
1590
|
private _generation;
|
|
1926
1591
|
private readonly _generationCancelReasons;
|
|
@@ -1929,64 +1594,21 @@ declare class DeviceJobQueue {
|
|
|
1929
1594
|
* `deviceId` is a label only — used by inspection / cancellation routing.
|
|
1930
1595
|
*/
|
|
1931
1596
|
enqueue<T>(deviceId: string, job: (signal: AbortSignal) => Promise<T>, options?: JobOptions): Promise<T>;
|
|
1932
|
-
/**
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
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
|
-
*/
|
|
1597
|
+
/** Cancel the active job. If `deviceId` is given, only cancels when it matches. */
|
|
1598
|
+
cancelActive(deviceId?: string): boolean;
|
|
1599
|
+
/** Force cancel the active job. `reason` becomes signal.reason. */
|
|
1600
|
+
forceCancelActive(deviceId?: string, reason?: Error): boolean;
|
|
1601
|
+
/** Cancel the active job (alias for callers that previously needed multi-device cancel). */
|
|
1602
|
+
cancelAllActive(reason?: Error): void;
|
|
1603
|
+
/** Cancel the active job and invalidate queued jobs that have not started. */
|
|
1946
1604
|
cancelActiveAndPending(deviceId?: string, reason?: Error): boolean;
|
|
1947
1605
|
/** Get info about the currently active job, or null if idle. */
|
|
1948
1606
|
getActiveJob(deviceId?: string): ActiveJobInfo | null;
|
|
1607
|
+
/** True if any job is currently running. */
|
|
1608
|
+
isBusy(): boolean;
|
|
1949
1609
|
clear(reason?: Error): void;
|
|
1950
1610
|
}
|
|
1951
1611
|
|
|
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
|
-
|
|
1990
1612
|
/**
|
|
1991
1613
|
* Minimal typed event emitter using Map<string, Set<listener>>.
|
|
1992
1614
|
* Each adapter uses this for device events (connect, disconnect, pin, etc.).
|
|
@@ -2013,102 +1635,6 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
|
|
|
2013
1635
|
listenerCount(event: string): number;
|
|
2014
1636
|
}
|
|
2015
1637
|
|
|
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
|
-
|
|
2112
1638
|
/**
|
|
2113
1639
|
* Compare two semver strings (e.g. "2.1.0" vs "2.3.1").
|
|
2114
1640
|
* Returns -1 if a < b, 0 if equal, 1 if a > b.
|
|
@@ -2129,28 +1655,7 @@ declare function hexToBytes(hex: string): Uint8Array;
|
|
|
2129
1655
|
/** Convert a Uint8Array to a hex string (no 0x prefix). */
|
|
2130
1656
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
2131
1657
|
|
|
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';
|
|
1658
|
+
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger';
|
|
2154
1659
|
type HardwareDeviceIdentityInput = {
|
|
2155
1660
|
name?: string | null;
|
|
2156
1661
|
localName?: string | null;
|
|
@@ -2213,19 +1718,8 @@ type RunAllNetworkGetAddressOptions = {
|
|
|
2213
1718
|
buildTopLevelFailure?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => Response<AllNetworkAddressResponse[]>;
|
|
2214
1719
|
};
|
|
2215
1720
|
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>;
|
|
2227
1721
|
declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams): AllNetworkAddressResponse;
|
|
2228
1722
|
|
|
2229
1723
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
2230
1724
|
|
|
2231
|
-
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type
|
|
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 };
|