@onekeyfe/hwk-adapter-core 1.2.8-alpha.50 → 1.2.8-alpha.51
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-AYS7A7Z3.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-G5EU7VRW.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 -642
- package/dist/index.d.ts +104 -642
- package/dist/index.js +86 -1095
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -1087
- package/dist/index.mjs.map +1 -1
- package/dist/{ui-events-C61GTilK.d.ts → ui-events-Cb7haAeE.d.mts} +3 -67
- package/dist/{ui-events-C61GTilK.d.mts → ui-events-Cb7haAeE.d.ts} +3 -67
- 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-AYS7A7Z3.js.map +0 -1
- package/dist/chunk-DB4JOPZO.mjs +0 -74
- package/dist/chunk-DB4JOPZO.mjs.map +0 -1
- package/dist/chunk-G5EU7VRW.mjs.map +0 -1
- package/dist/chunk-KTRQZ5AJ.mjs.map +0 -1
- package/dist/chunk-T5HIQPNG.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,78 +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
|
-
/** Echo this in the `RECEIVE_SELECT_DEVICE` answer; an answer without it is ignored. */
|
|
1139
|
-
requestId: string;
|
|
1140
|
-
context: DeviceSelectionContext;
|
|
1141
|
-
extra?: HardwareCallExtra;
|
|
1142
|
-
/** Repeated snapshots with this requestId update one SDK-owned binding scan. */
|
|
1143
|
-
scanning?: boolean;
|
|
1144
|
-
bindingSessionId?: string;
|
|
1145
|
-
/** A candidate rejected by SDK identity verification in this binding session. */
|
|
1146
|
-
rejectedConnectId?: string;
|
|
1147
|
-
}
|
|
1148
|
-
/** The host must persist this endpoint before acknowledging. */
|
|
1149
|
-
interface SaveDeviceBindingRequest extends UiRequestOperationAttribution {
|
|
1150
|
-
requestId: string;
|
|
1151
|
-
selectionRequestId: string;
|
|
1152
|
-
connection: {
|
|
1153
|
-
transport: 'ble';
|
|
1154
|
-
connectId: string;
|
|
1155
|
-
};
|
|
1156
|
-
/** Omitted when the vendor binds the selected BLE endpoint without checking its wallet (Ledger). */
|
|
1157
|
-
identity?: Extract<WalletIdentity, {
|
|
1158
|
-
vendor: 'ledger' | 'trezor';
|
|
1159
|
-
}>;
|
|
1160
|
-
extra?: HardwareCallExtra;
|
|
1161
|
-
}
|
|
1162
|
-
type BindBleDeviceParams = Pick<SaveDeviceBindingRequest, 'identity' | 'extra'>;
|
|
1163
|
-
interface DeviceBindingStatus {
|
|
1164
|
-
selectionRequestId: string;
|
|
1165
|
-
status: 'verifying' | 'saved' | 'failed' | 'cancelled';
|
|
1166
|
-
}
|
|
1167
917
|
/**
|
|
1168
918
|
* Cross-chain / cross-vendor options passed alongside any chain method's
|
|
1169
919
|
* own params (the optional last argument). Holds operation-level switches
|
|
1170
920
|
* that aren't specific to one chain. Vendor-specific options can be added
|
|
1171
921
|
* as typed sub-fields here when a vendor actually needs them.
|
|
1172
922
|
*/
|
|
1173
|
-
interface ICommonCallParams
|
|
923
|
+
interface ICommonCallParams {
|
|
1174
924
|
/**
|
|
1175
925
|
* When the required device app is missing, prompt the user (UI request)
|
|
1176
926
|
* to install it, stream install progress, then retry the operation once.
|
|
1177
927
|
* Off by default — preserves the plain "app not installed" failure.
|
|
1178
928
|
*/
|
|
1179
929
|
autoInstallApp?: boolean;
|
|
1180
|
-
/** Runtime-only id from connectDevice(); when present, discovery and fallback are disabled. */
|
|
1181
|
-
operationId?: string;
|
|
1182
930
|
}
|
|
1183
931
|
type NullableCallArg<T> = T | null | undefined;
|
|
1184
932
|
interface IPassphraseCallParams {
|
|
@@ -1187,14 +935,6 @@ interface IPassphraseCallParams {
|
|
|
1187
935
|
}
|
|
1188
936
|
type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
|
|
1189
937
|
type IHardwareCallParams<T> = T & IHardwareCommonCallParams;
|
|
1190
|
-
/**
|
|
1191
|
-
* Runtime-only device-manager context, never forwarded to firmware. The expected identity lets an
|
|
1192
|
-
* adapter fail closed before replaying a read or mutation after a reconnect.
|
|
1193
|
-
*/
|
|
1194
|
-
interface IDeviceManagerOperationContext extends IHardwareConnectionContext {
|
|
1195
|
-
operationId?: string;
|
|
1196
|
-
expectedDeviceIdentity?: WalletIdentity;
|
|
1197
|
-
}
|
|
1198
938
|
interface AllNetworkAddressParams {
|
|
1199
939
|
network: string;
|
|
1200
940
|
path: string;
|
|
@@ -1205,7 +945,16 @@ interface AllNetworkAddressParams {
|
|
|
1205
945
|
interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
|
|
1206
946
|
bundle: AllNetworkAddressParams[];
|
|
1207
947
|
}
|
|
1208
|
-
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
|
+
};
|
|
1209
958
|
type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
1210
959
|
error?: string;
|
|
1211
960
|
code?: HardwareErrorCode | number;
|
|
@@ -1213,7 +962,6 @@ type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
|
1213
962
|
connectId?: string;
|
|
1214
963
|
deviceId?: string;
|
|
1215
964
|
deviceIdentity?: AllNetworkDeviceIdentity;
|
|
1216
|
-
rootFingerprint?: number;
|
|
1217
965
|
chainFingerprint?: string;
|
|
1218
966
|
chainFingerprintChain?: ChainForFingerprint;
|
|
1219
967
|
params?: Record<string, unknown>;
|
|
@@ -1254,7 +1002,6 @@ type DeviceEvent = {
|
|
|
1254
1002
|
connectId: string;
|
|
1255
1003
|
deviceId?: string;
|
|
1256
1004
|
credentials: Record<string, unknown>[];
|
|
1257
|
-
removed?: Record<string, unknown>[];
|
|
1258
1005
|
};
|
|
1259
1006
|
};
|
|
1260
1007
|
type UiRequestEvent = {
|
|
@@ -1263,50 +1010,46 @@ type UiRequestEvent = {
|
|
|
1263
1010
|
device?: DeviceInfo;
|
|
1264
1011
|
connectId?: string;
|
|
1265
1012
|
type?: string;
|
|
1266
|
-
}
|
|
1013
|
+
};
|
|
1267
1014
|
} | {
|
|
1268
1015
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
1269
1016
|
payload: {
|
|
1270
1017
|
device: DeviceInfo;
|
|
1271
|
-
}
|
|
1018
|
+
};
|
|
1272
1019
|
} | {
|
|
1273
1020
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1274
1021
|
payload: {
|
|
1275
1022
|
device: DeviceInfo;
|
|
1276
|
-
}
|
|
1023
|
+
};
|
|
1277
1024
|
} | {
|
|
1278
1025
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1279
1026
|
payload: {
|
|
1280
1027
|
device: DeviceInfo;
|
|
1281
1028
|
code?: string;
|
|
1282
|
-
}
|
|
1029
|
+
};
|
|
1283
1030
|
} | {
|
|
1284
1031
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1285
1032
|
payload: {
|
|
1286
1033
|
device: DeviceInfo;
|
|
1287
1034
|
data: QrDisplayData;
|
|
1288
|
-
}
|
|
1035
|
+
};
|
|
1289
1036
|
} | {
|
|
1290
1037
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1291
1038
|
payload: {
|
|
1292
1039
|
device: DeviceInfo;
|
|
1293
|
-
}
|
|
1040
|
+
};
|
|
1294
1041
|
} | {
|
|
1295
1042
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
1296
1043
|
payload: {
|
|
1297
1044
|
transportType: TransportType;
|
|
1298
1045
|
connectId?: string;
|
|
1299
1046
|
deviceId?: string;
|
|
1300
|
-
}
|
|
1047
|
+
};
|
|
1301
1048
|
} | {
|
|
1302
1049
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1303
|
-
payload:
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
payload: SaveDeviceBindingRequest;
|
|
1307
|
-
} | {
|
|
1308
|
-
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1309
|
-
payload: DeviceBindingStatus;
|
|
1050
|
+
payload: {
|
|
1051
|
+
devices: DeviceInfo[];
|
|
1052
|
+
};
|
|
1310
1053
|
} | {
|
|
1311
1054
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
1312
1055
|
payload: {
|
|
@@ -1326,13 +1069,13 @@ type UiRequestEvent = {
|
|
|
1326
1069
|
* isn't recognized.
|
|
1327
1070
|
*/
|
|
1328
1071
|
message: string;
|
|
1329
|
-
}
|
|
1072
|
+
};
|
|
1330
1073
|
} | {
|
|
1331
1074
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1332
1075
|
payload: {
|
|
1333
1076
|
vendor: string;
|
|
1334
1077
|
appName: string;
|
|
1335
|
-
}
|
|
1078
|
+
};
|
|
1336
1079
|
} | {
|
|
1337
1080
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
1338
1081
|
payload: {
|
|
@@ -1340,10 +1083,10 @@ type UiRequestEvent = {
|
|
|
1340
1083
|
availableMethods: number[];
|
|
1341
1084
|
selectedMethod: number;
|
|
1342
1085
|
nfcData?: string;
|
|
1343
|
-
}
|
|
1086
|
+
};
|
|
1344
1087
|
} | {
|
|
1345
1088
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1346
|
-
payload:
|
|
1089
|
+
payload: Record<string, never>;
|
|
1347
1090
|
};
|
|
1348
1091
|
type SdkEvent = {
|
|
1349
1092
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1366,12 +1109,6 @@ type SdkEvent = {
|
|
|
1366
1109
|
payload: {
|
|
1367
1110
|
connectId: string;
|
|
1368
1111
|
};
|
|
1369
|
-
} | {
|
|
1370
|
-
type: typeof SDK.OPERATION_ENDED;
|
|
1371
|
-
payload: {
|
|
1372
|
-
operationId: string;
|
|
1373
|
-
reason: OperationEndReason;
|
|
1374
|
-
};
|
|
1375
1112
|
};
|
|
1376
1113
|
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent | HardwareUiEvent;
|
|
1377
1114
|
type DeviceEventListener = (event: HardwareEvent) => void;
|
|
@@ -1382,14 +1119,6 @@ type DeviceEventListener = (event: HardwareEvent) => void;
|
|
|
1382
1119
|
* and the value is the narrowed event object the listener will receive.
|
|
1383
1120
|
*/
|
|
1384
1121
|
interface HardwareEventMap {
|
|
1385
|
-
[UI_REQUEST.DEVICE_BINDING_STATUS]: {
|
|
1386
|
-
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1387
|
-
payload: DeviceBindingStatus;
|
|
1388
|
-
};
|
|
1389
|
-
[UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING]: {
|
|
1390
|
-
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1391
|
-
payload: SaveDeviceBindingRequest;
|
|
1392
|
-
};
|
|
1393
1122
|
'ui-event': HardwareUiEvent;
|
|
1394
1123
|
[DEVICE.CONNECT]: {
|
|
1395
1124
|
type: typeof DEVICE.CONNECT;
|
|
@@ -1422,8 +1151,6 @@ interface HardwareEventMap {
|
|
|
1422
1151
|
connectId: string;
|
|
1423
1152
|
deviceId?: string;
|
|
1424
1153
|
credentials: Record<string, unknown>[];
|
|
1425
|
-
/** Credentials the device rejected; a list kept for several devices drops these. */
|
|
1426
|
-
removed?: Record<string, unknown>[];
|
|
1427
1154
|
};
|
|
1428
1155
|
};
|
|
1429
1156
|
[UI_REQUEST.REQUEST_PIN]: {
|
|
@@ -1432,7 +1159,7 @@ interface HardwareEventMap {
|
|
|
1432
1159
|
device?: DeviceInfo;
|
|
1433
1160
|
connectId?: string;
|
|
1434
1161
|
type?: string;
|
|
1435
|
-
}
|
|
1162
|
+
};
|
|
1436
1163
|
};
|
|
1437
1164
|
[UI_REQUEST.REQUEST_PASSPHRASE]: {
|
|
1438
1165
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
@@ -1441,33 +1168,33 @@ interface HardwareEventMap {
|
|
|
1441
1168
|
connectId?: string;
|
|
1442
1169
|
passphraseState?: string;
|
|
1443
1170
|
useEmptyPassphrase?: boolean;
|
|
1444
|
-
}
|
|
1171
|
+
};
|
|
1445
1172
|
};
|
|
1446
1173
|
[UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
|
|
1447
1174
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1448
1175
|
payload: {
|
|
1449
1176
|
device: DeviceInfo;
|
|
1450
|
-
}
|
|
1177
|
+
};
|
|
1451
1178
|
};
|
|
1452
1179
|
[UI_REQUEST.REQUEST_BUTTON]: {
|
|
1453
1180
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1454
1181
|
payload: {
|
|
1455
1182
|
device: DeviceInfo;
|
|
1456
1183
|
code?: string;
|
|
1457
|
-
}
|
|
1184
|
+
};
|
|
1458
1185
|
};
|
|
1459
1186
|
[UI_REQUEST.REQUEST_QR_DISPLAY]: {
|
|
1460
1187
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1461
1188
|
payload: {
|
|
1462
1189
|
device: DeviceInfo;
|
|
1463
1190
|
data: QrDisplayData;
|
|
1464
|
-
}
|
|
1191
|
+
};
|
|
1465
1192
|
};
|
|
1466
1193
|
[UI_REQUEST.REQUEST_QR_SCAN]: {
|
|
1467
1194
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1468
1195
|
payload: {
|
|
1469
1196
|
device: DeviceInfo;
|
|
1470
|
-
}
|
|
1197
|
+
};
|
|
1471
1198
|
};
|
|
1472
1199
|
[UI_REQUEST.REQUEST_DEVICE_PERMISSION]: {
|
|
1473
1200
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
@@ -1475,11 +1202,13 @@ interface HardwareEventMap {
|
|
|
1475
1202
|
transportType: TransportType;
|
|
1476
1203
|
connectId?: string;
|
|
1477
1204
|
deviceId?: string;
|
|
1478
|
-
}
|
|
1205
|
+
};
|
|
1479
1206
|
};
|
|
1480
1207
|
[UI_REQUEST.REQUEST_SELECT_DEVICE]: {
|
|
1481
1208
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1482
|
-
payload:
|
|
1209
|
+
payload: {
|
|
1210
|
+
devices: DeviceInfo[];
|
|
1211
|
+
};
|
|
1483
1212
|
};
|
|
1484
1213
|
[UI_REQUEST.REQUEST_DEVICE_CONNECT]: {
|
|
1485
1214
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
@@ -1487,7 +1216,7 @@ interface HardwareEventMap {
|
|
|
1487
1216
|
vendor: string;
|
|
1488
1217
|
reason: string;
|
|
1489
1218
|
message: string;
|
|
1490
|
-
}
|
|
1219
|
+
};
|
|
1491
1220
|
};
|
|
1492
1221
|
[UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM]: {
|
|
1493
1222
|
type: typeof UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM;
|
|
@@ -1495,14 +1224,14 @@ interface HardwareEventMap {
|
|
|
1495
1224
|
vendor: string;
|
|
1496
1225
|
path: string;
|
|
1497
1226
|
accountIndex: number;
|
|
1498
|
-
}
|
|
1227
|
+
};
|
|
1499
1228
|
};
|
|
1500
1229
|
[UI_REQUEST.REQUEST_INSTALL_APP]: {
|
|
1501
1230
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1502
1231
|
payload: {
|
|
1503
1232
|
vendor: string;
|
|
1504
1233
|
appName: string;
|
|
1505
|
-
}
|
|
1234
|
+
};
|
|
1506
1235
|
};
|
|
1507
1236
|
[UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
|
|
1508
1237
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
@@ -1511,11 +1240,11 @@ interface HardwareEventMap {
|
|
|
1511
1240
|
availableMethods: number[];
|
|
1512
1241
|
selectedMethod: number;
|
|
1513
1242
|
nfcData?: string;
|
|
1514
|
-
}
|
|
1243
|
+
};
|
|
1515
1244
|
};
|
|
1516
1245
|
[UI_REQUEST.CLOSE_UI_WINDOW]: {
|
|
1517
1246
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1518
|
-
payload:
|
|
1247
|
+
payload: Record<string, never>;
|
|
1519
1248
|
};
|
|
1520
1249
|
[SDK.DEVICE_INTERACTION]: {
|
|
1521
1250
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1542,23 +1271,16 @@ interface HardwareEventMap {
|
|
|
1542
1271
|
connectId: string;
|
|
1543
1272
|
};
|
|
1544
1273
|
};
|
|
1545
|
-
[SDK.OPERATION_ENDED]: {
|
|
1546
|
-
type: typeof SDK.OPERATION_ENDED;
|
|
1547
|
-
payload: {
|
|
1548
|
-
operationId: string;
|
|
1549
|
-
reason: OperationEndReason;
|
|
1550
|
-
};
|
|
1551
|
-
};
|
|
1552
1274
|
}
|
|
1553
1275
|
interface IDeviceManagerMethods {
|
|
1554
|
-
getFeatures?(connectId: string
|
|
1555
|
-
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams
|
|
1556
|
-
setBrightness?(connectId: string, params?: TrezorBrightnessParams
|
|
1557
|
-
changePin?(connectId: string, params?: TrezorChangePinParams
|
|
1558
|
-
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>>>;
|
|
1559
1281
|
authenticateDevice?(connectId: string, params: {
|
|
1560
1282
|
challenge: string;
|
|
1561
|
-
}
|
|
1283
|
+
}): Promise<Response<Record<string, unknown>>>;
|
|
1562
1284
|
}
|
|
1563
1285
|
interface IWalletStateMethods {
|
|
1564
1286
|
/**
|
|
@@ -1585,35 +1307,20 @@ interface IWalletStateMethods {
|
|
|
1585
1307
|
* Optional: vendors without host-managed passphrase sessions (Ledger) omit
|
|
1586
1308
|
* it. Implemented by `TrezorAdapter`.
|
|
1587
1309
|
*/
|
|
1588
|
-
getPassphraseState?(connectId: string, passphraseState?: string
|
|
1310
|
+
getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
|
|
1589
1311
|
}
|
|
1590
|
-
/**
|
|
1591
|
-
* `stops-waiting`: an on-device confirmation stays up until answered or timed out.
|
|
1592
|
-
* `interrupts-device`: the command on the wire is withdrawn. No vendor reports it, so hosts
|
|
1593
|
-
* should say "stopped waiting, answer on the device", not "cancelled".
|
|
1594
|
-
*/
|
|
1595
|
-
type CancelCapability = 'interrupts-device' | 'stops-waiting';
|
|
1596
1312
|
interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
|
|
1597
1313
|
readonly vendor: string;
|
|
1598
1314
|
readonly activeTransport: TransportType | null;
|
|
1599
|
-
/** What `cancel()` reaches on this vendor. Declared, never inferred. */
|
|
1600
|
-
readonly cancelCapability: CancelCapability;
|
|
1601
1315
|
init(config: TConfig): Promise<void>;
|
|
1602
1316
|
dispose(): Promise<void>;
|
|
1603
1317
|
getAvailableTransports(): TransportType[];
|
|
1604
1318
|
switchTransport(type: TransportType): Promise<void>;
|
|
1605
1319
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
/** Connect or logically bind a selected search result and return a runtime-only operation id. */
|
|
1609
|
-
connectDevice(searchTargetId: string): Promise<Response<string>>;
|
|
1610
|
-
/** Device Manager rebind: verify the existing identity before replacing its BLE locator. */
|
|
1611
|
-
bindBleDevice?(params: BindBleDeviceParams): Promise<Response<string>>;
|
|
1612
|
-
/** Resolve and pin operation routing; the caller verifies wallet identity before business calls. */
|
|
1613
|
-
acquireOperation?(connectId: string, context: IHardwareConnectionContext): Promise<Response<string>>;
|
|
1614
|
-
/** Release a caller-owned operation. Disconnect events end matching operations automatically. */
|
|
1615
|
-
releaseOperation(operationId: string): Promise<void>;
|
|
1320
|
+
connectDevice(connectId: string): Promise<Response<string>>;
|
|
1321
|
+
disconnectDevice(connectId: string): Promise<void>;
|
|
1616
1322
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
1323
|
+
getSupportedChains(): ChainCapability[];
|
|
1617
1324
|
/** Abort the in-flight call. Omit connectId to cancel whatever is active. */
|
|
1618
1325
|
cancel(connectId?: string): void;
|
|
1619
1326
|
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
@@ -1650,11 +1357,6 @@ interface SearchDevicesOptions {
|
|
|
1650
1357
|
* was discovered first.
|
|
1651
1358
|
*/
|
|
1652
1359
|
waitForAllTransports?: boolean;
|
|
1653
|
-
/**
|
|
1654
|
-
* Restrict discovery to one transport. A virtual target (Keystone QR) must not start any wallet
|
|
1655
|
-
* interaction during discovery; `connectDevice()` resolves it.
|
|
1656
|
-
*/
|
|
1657
|
-
transportType?: ConnectionType;
|
|
1658
1360
|
}
|
|
1659
1361
|
|
|
1660
1362
|
interface EvmGetAddressParams extends PassphraseStateAware {
|
|
@@ -1668,8 +1370,6 @@ interface EvmAddress {
|
|
|
1668
1370
|
path: string;
|
|
1669
1371
|
/** Device-reported secp256k1 public key; populated when the transport exposes it. */
|
|
1670
1372
|
publicKey?: string;
|
|
1671
|
-
/** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
|
|
1672
|
-
accountKey?: ExportedAccountKey;
|
|
1673
1373
|
}
|
|
1674
1374
|
interface EvmSignTxBaseParams extends PassphraseStateAware {
|
|
1675
1375
|
path: string;
|
|
@@ -1780,11 +1480,6 @@ interface EvmSignTypedDataFull extends PassphraseStateAware {
|
|
|
1780
1480
|
primaryType: string;
|
|
1781
1481
|
message: Record<string, unknown>;
|
|
1782
1482
|
};
|
|
1783
|
-
/**
|
|
1784
|
-
* The dApp's original EIP-712 JSON, byte for byte. Serializing vendors (Keystone) must prefer it:
|
|
1785
|
-
* re-stringifying `data` rewrites integers wider than 2^53 and exponent forms.
|
|
1786
|
-
*/
|
|
1787
|
-
dataJson?: string;
|
|
1788
1483
|
metamaskV4Compat?: boolean;
|
|
1789
1484
|
showMessageHash?: boolean;
|
|
1790
1485
|
/**
|
|
@@ -1823,33 +1518,6 @@ interface IEvmMethods {
|
|
|
1823
1518
|
evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
|
|
1824
1519
|
}
|
|
1825
1520
|
|
|
1826
|
-
/** Which `GET_VK` encoding the Ledger Zcash app should return. */
|
|
1827
|
-
type ZcashFullViewingKeyMode = 'ufvk' | 'orchardFvk';
|
|
1828
|
-
interface ZcashGetFullViewingKeyParams extends PassphraseStateAware {
|
|
1829
|
-
/** BIP44 account path `m/44'/133'/a'`; a deeper transparent path is accepted, only `a'` is used. */
|
|
1830
|
-
path: string;
|
|
1831
|
-
/** Default `ufvk`. */
|
|
1832
|
-
mode?: ZcashFullViewingKeyMode;
|
|
1833
|
-
}
|
|
1834
|
-
interface ZcashFullViewingKey {
|
|
1835
|
-
path: string;
|
|
1836
|
-
mode: ZcashFullViewingKeyMode;
|
|
1837
|
-
/** ZIP-316 bech32m UFVK string (mode `ufvk`). */
|
|
1838
|
-
ufvk?: string;
|
|
1839
|
-
/** 96-byte raw Orchard FVK as hex (mode `orchardFvk`). */
|
|
1840
|
-
orchardFvk?: string;
|
|
1841
|
-
}
|
|
1842
|
-
interface ZcashGetShieldedAddressParams extends PassphraseStateAware {
|
|
1843
|
-
/** Full 5-level transparent path `m/44'/133'/a'/0/i`; the Orchard path is derived from it. */
|
|
1844
|
-
path: string;
|
|
1845
|
-
showOnDevice?: boolean;
|
|
1846
|
-
}
|
|
1847
|
-
interface ZcashShieldedAddress {
|
|
1848
|
-
/** Unified address with a single Orchard receiver. */
|
|
1849
|
-
address: string;
|
|
1850
|
-
path: string;
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1853
1521
|
/**
|
|
1854
1522
|
* Low-level device descriptor from Transport layer.
|
|
1855
1523
|
* Represents a physical device detected by USB/BLE scanning.
|
|
@@ -1895,13 +1563,14 @@ interface DeviceDisconnectEvent {
|
|
|
1895
1563
|
type DeviceChangeEvent = DeviceConnectEvent | DeviceDisconnectEvent;
|
|
1896
1564
|
|
|
1897
1565
|
/**
|
|
1898
|
-
*
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
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.
|
|
1905
1574
|
*/
|
|
1906
1575
|
interface JobOptions {
|
|
1907
1576
|
label?: string;
|
|
@@ -1913,15 +1582,10 @@ interface ActiveJobInfo {
|
|
|
1913
1582
|
label?: string;
|
|
1914
1583
|
startedAt: number;
|
|
1915
1584
|
}
|
|
1916
|
-
interface CancelScopeHandle {
|
|
1917
|
-
signal: AbortSignal;
|
|
1918
|
-
release: () => void;
|
|
1919
|
-
}
|
|
1920
1585
|
declare class DeviceJobQueue {
|
|
1921
1586
|
private _tail;
|
|
1922
1587
|
private _active;
|
|
1923
1588
|
private readonly _jobs;
|
|
1924
|
-
private readonly _cancelScopes;
|
|
1925
1589
|
/** Incremented on clear() so queued-but-not-yet-running jobs detect invalidation. */
|
|
1926
1590
|
private _generation;
|
|
1927
1591
|
private readonly _generationCancelReasons;
|
|
@@ -1930,64 +1594,21 @@ declare class DeviceJobQueue {
|
|
|
1930
1594
|
* `deviceId` is a label only — used by inspection / cancellation routing.
|
|
1931
1595
|
*/
|
|
1932
1596
|
enqueue<T>(deviceId: string, job: (signal: AbortSignal) => Promise<T>, options?: JobOptions): Promise<T>;
|
|
1933
|
-
/**
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
* `cancelActiveAndPending`; this stays for a connector layer that stops only what is on the wire.
|
|
1941
|
-
*/
|
|
1942
|
-
cancelActive(deviceId?: string, reason?: Error): boolean;
|
|
1943
|
-
/**
|
|
1944
|
-
* Cancels the active job and unstarted queued jobs; returns whether anything was reached. Only
|
|
1945
|
-
* `undefined` means everything: an empty key matches nothing instead of tearing the queue down.
|
|
1946
|
-
*/
|
|
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. */
|
|
1947
1604
|
cancelActiveAndPending(deviceId?: string, reason?: Error): boolean;
|
|
1948
1605
|
/** Get info about the currently active job, or null if idle. */
|
|
1949
1606
|
getActiveJob(deviceId?: string): ActiveJobInfo | null;
|
|
1607
|
+
/** True if any job is currently running. */
|
|
1608
|
+
isBusy(): boolean;
|
|
1950
1609
|
clear(reason?: Error): void;
|
|
1951
1610
|
}
|
|
1952
1611
|
|
|
1953
|
-
declare const HARDWARE_RUNTIME_ID_PREFIX = "hwk:runtime";
|
|
1954
|
-
/**
|
|
1955
|
-
* `search-target`: one device in one discovery snapshot, dead on the next search of that kind.
|
|
1956
|
-
* `link`: one open transport. `operation`: one business operation.
|
|
1957
|
-
*/
|
|
1958
|
-
type HardwareRuntimeIdKind = 'operation' | 'search-target' | 'link';
|
|
1959
|
-
type HardwareRuntimeId = {
|
|
1960
|
-
kind: HardwareRuntimeIdKind;
|
|
1961
|
-
vendor: VendorType;
|
|
1962
|
-
};
|
|
1963
|
-
/** Runtime ids are opaque and must never be persisted as device identity. */
|
|
1964
|
-
declare function createHardwareOperationId(vendor: VendorType): string;
|
|
1965
|
-
/** Search targets are valid only for the adapter's current discovery snapshot. */
|
|
1966
|
-
declare function createHardwareSearchTargetId(vendor: VendorType): string;
|
|
1967
|
-
declare function createHardwareLinkId(vendor: VendorType): string;
|
|
1968
|
-
declare function hasHardwareRuntimeIdPrefix(value: unknown): value is string;
|
|
1969
|
-
declare function parseHardwareRuntimeId(value: unknown): HardwareRuntimeId | undefined;
|
|
1970
|
-
declare function isHardwareOperationId(value: unknown): value is string;
|
|
1971
|
-
|
|
1972
|
-
interface HardwareOperationTarget {
|
|
1973
|
-
/** Effective target accepted by existing adapter/connector call paths. */
|
|
1974
|
-
targetId: string | undefined;
|
|
1975
|
-
/** Present when this operation is pinned to a live operation. */
|
|
1976
|
-
operationId: string | undefined;
|
|
1977
|
-
}
|
|
1978
|
-
/**
|
|
1979
|
-
* Normalizes the transitional positional operation id and the canonical
|
|
1980
|
-
* common-params field. All vendors must reject conflicting bindings.
|
|
1981
|
-
*/
|
|
1982
|
-
declare function resolveHardwareOperationTarget(positionalTargetId: string | null | undefined, commonOperationId: string | null | undefined, expectedVendor?: VendorType): Response<HardwareOperationTarget>;
|
|
1983
|
-
/** Narrow the connection-context fields of untyped call params. */
|
|
1984
|
-
declare function pickConnectionContext(params: {
|
|
1985
|
-
knownConnections?: unknown;
|
|
1986
|
-
extra?: unknown;
|
|
1987
|
-
allowDeviceSelection?: unknown;
|
|
1988
|
-
supportedTransports?: unknown;
|
|
1989
|
-
}): IHardwareConnectionContext;
|
|
1990
|
-
|
|
1991
1612
|
/**
|
|
1992
1613
|
* Minimal typed event emitter using Map<string, Set<listener>>.
|
|
1993
1614
|
* Each adapter uses this for device events (connect, disconnect, pin, etc.).
|
|
@@ -2014,104 +1635,6 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
|
|
|
2014
1635
|
listenerCount(event: string): number;
|
|
2015
1636
|
}
|
|
2016
1637
|
|
|
2017
|
-
/** Serializable BLE transport data shared by Electron main and renderer runtimes. */
|
|
2018
|
-
interface ElectronBleDeviceInfo {
|
|
2019
|
-
id: string;
|
|
2020
|
-
name?: string;
|
|
2021
|
-
rssi?: number;
|
|
2022
|
-
advertisedServiceUuids?: string[];
|
|
2023
|
-
}
|
|
2024
|
-
/**
|
|
2025
|
-
* IPC-safe peripheral match: advertises one of `serviceUuids`, or its local name matches every
|
|
2026
|
-
* `namePatterns` entry (case-insensitive regex sources). The desktop noble-ble host treats this
|
|
2027
|
-
* as a hint only: its vendor allowlist decides, `serviceUuids` can only narrow it, and
|
|
2028
|
-
* `namePatterns` are never compiled.
|
|
2029
|
-
*/
|
|
2030
|
-
interface ElectronBleMatch {
|
|
2031
|
-
serviceUuids?: string[];
|
|
2032
|
-
namePatterns?: string[];
|
|
2033
|
-
}
|
|
2034
|
-
interface ElectronBleScanOptions {
|
|
2035
|
-
/** Opaque partition key: results and connected devices never mix across it. */
|
|
2036
|
-
vendor?: string;
|
|
2037
|
-
match?: ElectronBleMatch;
|
|
2038
|
-
/** @deprecated Superseded by `match.serviceUuids`. */
|
|
2039
|
-
serviceUuids?: string[];
|
|
2040
|
-
durationMs?: number;
|
|
2041
|
-
}
|
|
2042
|
-
/** GATT profile plus the write framing this vendor's firmware expects. */
|
|
2043
|
-
interface ElectronBleConnectOptions {
|
|
2044
|
-
vendor: string;
|
|
2045
|
-
serviceUuid: string;
|
|
2046
|
-
writeUuid: string;
|
|
2047
|
-
notifyUuid: string;
|
|
2048
|
-
/**
|
|
2049
|
-
* `padded`: fixed `chunkSize` packets, last zero-filled (Trezor firmware drops short packets).
|
|
2050
|
-
* `raw`: the buffer as given, for self-length-framed protocols (Ledger).
|
|
2051
|
-
*/
|
|
2052
|
-
write?: {
|
|
2053
|
-
mode: 'padded' | 'raw';
|
|
2054
|
-
chunkSize?: number;
|
|
2055
|
-
chunkDelayMs?: number;
|
|
2056
|
-
maxLength?: number;
|
|
2057
|
-
};
|
|
2058
|
-
}
|
|
2059
|
-
/** Native code handles GATT only; framing, identity checks and wallet calls stay in the SDK. */
|
|
2060
|
-
interface ElectronBleApi {
|
|
2061
|
-
scan(options?: ElectronBleScanOptions): Promise<ElectronBleDeviceInfo[]>;
|
|
2062
|
-
stopScan(vendor?: string): Promise<void>;
|
|
2063
|
-
connect(id: string, options?: ElectronBleConnectOptions): Promise<{
|
|
2064
|
-
id: string;
|
|
2065
|
-
name?: string;
|
|
2066
|
-
}>;
|
|
2067
|
-
disconnect(id: string): Promise<void>;
|
|
2068
|
-
subscribe(id: string): Promise<void>;
|
|
2069
|
-
unsubscribe(id: string): Promise<void>;
|
|
2070
|
-
write(id: string, hexData: string): Promise<void>;
|
|
2071
|
-
checkAvailability(): Promise<{
|
|
2072
|
-
available: boolean;
|
|
2073
|
-
state: string;
|
|
2074
|
-
initialized: boolean;
|
|
2075
|
-
}>;
|
|
2076
|
-
getDevice(id: string): Promise<ElectronBleDeviceInfo | null>;
|
|
2077
|
-
onNotification(handler: (id: string, hexData: string) => void): () => void;
|
|
2078
|
-
onDeviceDisconnected(handler: (id: string) => void): () => void;
|
|
2079
|
-
/** Abandon an in-flight connect in the main process. Optional for hosts that cannot cancel. */
|
|
2080
|
-
cancelPairing?(options?: {
|
|
2081
|
-
vendor: string;
|
|
2082
|
-
id?: string;
|
|
2083
|
-
}): Promise<void>;
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
|
-
declare function emitDeviceBindingStatus(emitter: TypedEventEmitter<HardwareEventMap>, selectionRequestId: string, status: DeviceBindingStatus['status']): void;
|
|
2087
|
-
/**
|
|
2088
|
-
* A host refusal is reported, never thrown: the device is already connected, so a lost binding
|
|
2089
|
-
* is worth a warning and a retry, not failing the user's work.
|
|
2090
|
-
*/
|
|
2091
|
-
type SaveDeviceBindingOutcome = {
|
|
2092
|
-
saved: true;
|
|
2093
|
-
} | {
|
|
2094
|
-
saved: false;
|
|
2095
|
-
reason: SaveDeviceBindingDeclineReason;
|
|
2096
|
-
};
|
|
2097
|
-
/** Persist a binding through the host. Only a user abort throws. */
|
|
2098
|
-
declare function requestSaveDeviceBinding(emitter: TypedEventEmitter<HardwareEventMap>, registry: UiRequestRegistry, binding: Omit<SaveDeviceBindingRequest, 'requestId'>, signal?: AbortSignal): Promise<SaveDeviceBindingOutcome>;
|
|
2099
|
-
|
|
2100
|
-
/** Discovery and selection share one owner; never connect until the last scan has drained. */
|
|
2101
|
-
declare function requestBleDeviceSelection({ emitter, registry, request, scan, signal, allowUsbFallback, pollIntervalMs, }: {
|
|
2102
|
-
emitter: TypedEventEmitter<HardwareEventMap>;
|
|
2103
|
-
registry: UiRequestRegistry;
|
|
2104
|
-
request: Omit<DeviceSelectionRequest, 'requestId' | 'scanning'>;
|
|
2105
|
-
scan: () => Promise<DeviceInfo[]>;
|
|
2106
|
-
signal: AbortSignal;
|
|
2107
|
-
/** The adapter must verify a returned USB candidate before dispatching any business call. */
|
|
2108
|
-
allowUsbFallback?: boolean;
|
|
2109
|
-
pollIntervalMs?: number;
|
|
2110
|
-
}): Promise<{
|
|
2111
|
-
device: DeviceInfo;
|
|
2112
|
-
requestId: string;
|
|
2113
|
-
}>;
|
|
2114
|
-
|
|
2115
1638
|
/**
|
|
2116
1639
|
* Compare two semver strings (e.g. "2.1.0" vs "2.3.1").
|
|
2117
1640
|
* Returns -1 if a < b, 0 if equal, 1 if a > b.
|
|
@@ -2132,57 +1655,7 @@ declare function hexToBytes(hex: string): Uint8Array;
|
|
|
2132
1655
|
/** Convert a Uint8Array to a hex string (no 0x prefix). */
|
|
2133
1656
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
2134
1657
|
|
|
2135
|
-
|
|
2136
|
-
* Walks CBOR from an untrusted source (a scanned QR code, a device reply) before a third-party
|
|
2137
|
-
* decoder sees it. Those decoders read past the end as zero and trust declared lengths, so one
|
|
2138
|
-
* indefinite-length header or a huge declared count exhausts memory. This walk accepts only
|
|
2139
|
-
* definite lengths that fit in the bytes actually present, bounded nesting, and no trailing bytes.
|
|
2140
|
-
*/
|
|
2141
|
-
declare function assertBoundedCbor(input: Uint8Array, maxBytes?: number): void;
|
|
2142
|
-
/** Hex from an untrusted source, checked as such and then as bounded CBOR. */
|
|
2143
|
-
declare function boundedCborFromHex(hex: string, maxBytes?: number): Buffer;
|
|
2144
|
-
|
|
2145
|
-
interface PrepareSolanaOffchainMessageV1Params {
|
|
2146
|
-
message: Uint8Array;
|
|
2147
|
-
requiredSigners: readonly string[];
|
|
2148
|
-
}
|
|
2149
|
-
interface PreparedSolanaOffchainMessageV1 {
|
|
2150
|
-
messageText: string;
|
|
2151
|
-
requiredSigners: string[];
|
|
2152
|
-
serializedMessage: Uint8Array;
|
|
2153
|
-
}
|
|
2154
|
-
declare function prepareSolanaOffchainMessageV1({ message, requiredSigners, }: PrepareSolanaOffchainMessageV1Params): PreparedSolanaOffchainMessageV1;
|
|
2155
|
-
|
|
2156
|
-
type LogSummaryContext = {
|
|
2157
|
-
/** Method name from the options, or '' when none was given. */
|
|
2158
|
-
method: string;
|
|
2159
|
-
role: 'params' | 'result';
|
|
2160
|
-
};
|
|
2161
|
-
/**
|
|
2162
|
-
* Returns extra space-separated hints for a payload field (e.g. PSBT input/output counts), or
|
|
2163
|
-
* undefined to add nothing. `key` is normalized: lower-case with `_` and `-` removed. Hints are
|
|
2164
|
-
* appended verbatim, so they must not contain payload contents. A throwing describer is ignored.
|
|
2165
|
-
*/
|
|
2166
|
-
type LogPayloadDescriber = (key: string, value: string | Uint8Array, context: LogSummaryContext) => string | undefined;
|
|
2167
|
-
type LogSummaryOptions = {
|
|
2168
|
-
/** Public or connector method name; enables chain-specific hints (EVM tx type). */
|
|
2169
|
-
method?: string;
|
|
2170
|
-
/** In results, transaction fields hold signed transactions rather than requests. */
|
|
2171
|
-
role?: 'params' | 'result';
|
|
2172
|
-
/** Chain-specific payload hints that need a decoder adapter-core does not ship. */
|
|
2173
|
-
describePayload?: LogPayloadDescriber;
|
|
2174
|
-
};
|
|
2175
|
-
/**
|
|
2176
|
-
* JSON-safe, log-safe summary of `value`. Never throws.
|
|
2177
|
-
*
|
|
2178
|
-
* Paths, chain ids, flags and error fields stay readable; payloads become
|
|
2179
|
-
* `<hex|str|json len=N sha256=16hex [hints]>`, addresses `first6…last4`, xpubs `xpub… len=N`,
|
|
2180
|
-
* public keys and chain codes `… len=N`, signatures `<signature len=N>` and secrets
|
|
2181
|
-
* `<redacted len=N>`.
|
|
2182
|
-
*/
|
|
2183
|
-
declare function summarizeForLog(value: unknown, options?: LogSummaryOptions): unknown;
|
|
2184
|
-
|
|
2185
|
-
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger' | 'keystone';
|
|
1658
|
+
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger';
|
|
2186
1659
|
type HardwareDeviceIdentityInput = {
|
|
2187
1660
|
name?: string | null;
|
|
2188
1661
|
localName?: string | null;
|
|
@@ -2245,19 +1718,8 @@ type RunAllNetworkGetAddressOptions = {
|
|
|
2245
1718
|
buildTopLevelFailure?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => Response<AllNetworkAddressResponse[]>;
|
|
2246
1719
|
};
|
|
2247
1720
|
declare function runAllNetworkGetAddress({ connectId, deviceId, params, getMethodChain, normalizeItem, buildUnsupportedNetworkResponse, callItem, attachIdentity, shouldAbortBundle, buildTopLevelFailure, }: RunAllNetworkGetAddressOptions): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
2248
|
-
/** An SDK-dialog cancel or on-device reject ends the bundle; the user already answered "no". */
|
|
2249
|
-
declare function isUserRefusal(code: HardwareErrorCode | number | undefined): boolean;
|
|
2250
|
-
/**
|
|
2251
|
-
* The device or wallet could not be shown to be the one asked for: another wallet, a locked
|
|
2252
|
-
* device, a wrong PIN or passphrase. No later item may derive on it, and a PIN is not retried.
|
|
2253
|
-
*/
|
|
2254
|
-
declare function isWalletSafetyFailure(code: HardwareErrorCode | number | undefined): boolean;
|
|
2255
|
-
/** The bundle's session is gone, so the remaining items have nothing to run against. */
|
|
2256
|
-
declare function isConnectionLost(code: HardwareErrorCode | number | undefined): boolean;
|
|
2257
|
-
/** UserAborted is a top-level abort code, so this ends the bundle. */
|
|
2258
|
-
declare function buildAllNetworkCancelledFailure<T>(signal: AbortSignal): Response<T>;
|
|
2259
1721
|
declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams): AllNetworkAddressResponse;
|
|
2260
1722
|
|
|
2261
1723
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
2262
1724
|
|
|
2263
|
-
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 };
|