@onekeyfe/hwk-adapter-core 1.2.2-alpha.8 → 1.2.3-alpha.1
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-3M3GMF64.mjs +68 -0
- package/dist/chunk-3M3GMF64.mjs.map +1 -0
- package/dist/{chunk-67BP77GT.mjs → chunk-72KOSYTH.mjs} +145 -56
- package/dist/chunk-72KOSYTH.mjs.map +1 -0
- package/dist/chunk-7SFFS2NL.js +68 -0
- package/dist/chunk-7SFFS2NL.js.map +1 -0
- package/dist/{chunk-SK7ZF33J.js → chunk-IZEVYMJK.js} +145 -56
- package/dist/chunk-IZEVYMJK.js.map +1 -0
- package/dist/{chunk-U63HTLGJ.mjs → chunk-KCIK56B5.mjs} +31 -2
- package/dist/chunk-KCIK56B5.mjs.map +1 -0
- package/dist/{chunk-BAGEFFFY.js → chunk-RRCFH7X6.js} +32 -3
- package/dist/chunk-RRCFH7X6.js.map +1 -0
- package/dist/errors-ChA_YEZY.d.mts +296 -0
- package/dist/errors-ChA_YEZY.d.ts +296 -0
- package/dist/errors.d.mts +1 -205
- package/dist/errors.d.ts +1 -205
- package/dist/errors.js +8 -2
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +9 -3
- package/dist/index.d.mts +530 -57
- package/dist/index.d.ts +530 -57
- package/dist/index.js +600 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +591 -49
- package/dist/index.mjs.map +1 -1
- package/dist/{ui-events-Cb7haAeE.d.ts → ui-events-BXI9BBpx.d.mts} +19 -3
- package/dist/{ui-events-Cb7haAeE.d.mts → ui-events-BXI9BBpx.d.ts} +19 -3
- package/dist/ui-events.d.mts +1 -1
- package/dist/ui-events.d.ts +1 -1
- package/dist/ui-events.js +3 -2
- package/dist/ui-events.js.map +1 -1
- package/dist/ui-events.mjs +2 -1
- package/package.json +2 -2
- package/dist/chunk-67BP77GT.mjs.map +0 -1
- package/dist/chunk-BAGEFFFY.js.map +0 -1
- package/dist/chunk-SK7ZF33J.js.map +0 -1
- package/dist/chunk-U63HTLGJ.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HardwareErrorCode } from './errors.mjs';
|
|
2
|
-
export { HwkError, IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage } from './errors.mjs';
|
|
3
|
-
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-
|
|
4
|
-
export { D as DevicePermissionDeniedReason,
|
|
1
|
+
import { H as HardwareErrorCode, a as HwkErrorOrigin, b as HwkRecoveryHint } from './errors-ChA_YEZY.mjs';
|
|
2
|
+
export { c as HwkError, d as HwkRecoveryScope, I as IHwkErrorPayload, e as IOperationMayHaveCompletedParams, O as ORPHAN_ELIGIBLE_ERROR_CODES, f as createHwkError, g as defaultOriginForCode, h as defaultRecoveryForCode, i as enrichErrorMessage, j as isHwkRecoveryHint, o as operationMayHaveCompletedParams } from './errors-ChA_YEZY.mjs';
|
|
3
|
+
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData, b as UiRequestRegistry } from './ui-events-BXI9BBpx.mjs';
|
|
4
|
+
export { D as DevicePermissionDeniedReason, c as DevicePermissionResponse, d as QrResponseData, e as UI_EVENT, f as UI_REQUEST_CANCELLED_TAG, g as UI_REQUEST_DEFAULT_TIMEOUT_MS, h as UI_REQUEST_PREEMPTED_TAG, i as UI_REQUEST_TIMEOUT_TAG, j as UI_RESPONSE } from './ui-events-BXI9BBpx.mjs';
|
|
5
5
|
|
|
6
6
|
interface Success<T> {
|
|
7
7
|
success: true;
|
|
@@ -12,16 +12,57 @@ interface Failure {
|
|
|
12
12
|
payload: {
|
|
13
13
|
error: string;
|
|
14
14
|
code: HardwareErrorCode;
|
|
15
|
+
/** See HwkErrorOrigin — who the failure came from. Optional so an
|
|
16
|
+
* unclassified failure degrades to code-based handling, never a guess. */
|
|
17
|
+
origin?: HwkErrorOrigin;
|
|
18
|
+
/** Connection-lifecycle recovery semantics. Optional for wire compatibility
|
|
19
|
+
* with SDK versions that predate this field. SDK failure helpers populate it. */
|
|
20
|
+
recovery?: HwkRecoveryHint;
|
|
15
21
|
params?: Record<string, unknown>;
|
|
16
22
|
};
|
|
17
23
|
}
|
|
18
24
|
type Response<T> = Success<T> | Failure;
|
|
19
25
|
declare function success<T>(payload: T): Success<T>;
|
|
20
|
-
declare function failure(code: HardwareErrorCode, error: string, params?: Record<string, unknown
|
|
26
|
+
declare function failure(code: HardwareErrorCode, error: string, params?: Record<string, unknown>, origin?: HwkErrorOrigin, recovery?: HwkRecoveryHint): Failure;
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Fixed derivation paths used to generate chain fingerprints.
|
|
30
|
+
* Uses standard index 0 — Ledger firmware shows device confirmation for
|
|
31
|
+
* non-standard paths (e.g., index=100), which would interrupt wallet creation.
|
|
32
|
+
* The address is hashed into a 16-char fingerprint, not exposed directly.
|
|
33
|
+
* - EVM: cointype 60 (Ledger ETH App only supports 60)
|
|
34
|
+
* - BTC: cointype 1 (testnet)
|
|
35
|
+
* - SOL: cointype 501, standard 3-level hardened
|
|
36
|
+
*/
|
|
37
|
+
declare const CHAIN_FINGERPRINT_PATHS: Record<ChainForFingerprint, string>;
|
|
38
|
+
type ChainForFingerprint = 'evm' | 'btc' | 'sol' | 'tron' | 'zcash';
|
|
39
|
+
/**
|
|
40
|
+
* Parses the complete BIP32 master fingerprint wire value: 4 bytes encoded
|
|
41
|
+
* as exactly 8 hexadecimal characters. This is protocol metadata, not a
|
|
42
|
+
* collision-resistant wallet identity.
|
|
43
|
+
*/
|
|
44
|
+
declare function parseBip32MasterFingerprint(value: unknown): string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* 16-char SHA-256 fingerprint for device-identity verification.
|
|
47
|
+
* Callers must canonicalize input (e.g. EVM address → lowercase) —
|
|
48
|
+
* encoding variations otherwise cause false DeviceMismatch.
|
|
49
|
+
*/
|
|
50
|
+
declare function deriveDeviceFingerprint(value: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Stable 256-bit wallet identity derived from canonical public wallet
|
|
53
|
+
* material. The domain separator prevents the same input from being confused
|
|
54
|
+
* with hashes used by other SDK features.
|
|
55
|
+
*
|
|
56
|
+
* Callers must provide one fixed, vendor-defined identity source. Do not hash
|
|
57
|
+
* a variable subset of exported accounts: the same wallet would then receive
|
|
58
|
+
* different ids depending on which accounts happened to be returned.
|
|
59
|
+
*/
|
|
60
|
+
declare function deriveWalletId(canonicalPublicMaterial: string): string;
|
|
61
|
+
|
|
62
|
+
type VendorType = 'trezor' | 'ledger' | 'keystone';
|
|
63
|
+
/** 'qr' is a virtual channel: UR payloads travel via app-rendered/scanned QR codes. */
|
|
64
|
+
type ConnectionType = 'usb' | 'ble' | 'qr';
|
|
65
|
+
type TransportType = 'usb' | 'ble' | 'hid' | 'bridge' | 'qr';
|
|
25
66
|
/**
|
|
26
67
|
* Device capabilities — describes what a specific device/connection
|
|
27
68
|
* combination can or cannot do. Varies by vendor, model, and connection type.
|
|
@@ -73,6 +114,56 @@ interface DeviceTarget {
|
|
|
73
114
|
connectId: string;
|
|
74
115
|
deviceId: string;
|
|
75
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* How long a discovery handle remains safe to use for a new connection.
|
|
119
|
+
* This is deliberately separate from post-connect device identity.
|
|
120
|
+
*/
|
|
121
|
+
type SearchTargetReusePolicy = 'current-discovery' | 'reconnectable' | 'rediscover';
|
|
122
|
+
declare function resolveSearchTargetReusePolicy(device: Pick<DeviceInfo, 'connectionType' | 'capabilities'>): SearchTargetReusePolicy;
|
|
123
|
+
/**
|
|
124
|
+
* A selectable result from hardware discovery. It may represent a physical
|
|
125
|
+
* transport endpoint or an interactive entry such as Keystone QR; it is not a
|
|
126
|
+
* physical-device or wallet identity.
|
|
127
|
+
*/
|
|
128
|
+
interface DeviceSearchTarget {
|
|
129
|
+
/** Opaque handle scoped to the adapter's current discovery state. */
|
|
130
|
+
searchTargetId: string;
|
|
131
|
+
/**
|
|
132
|
+
* Whether the handle itself may be retried. This says nothing about the
|
|
133
|
+
* identity learned after connect and must not be inferred from a stored
|
|
134
|
+
* connectId.
|
|
135
|
+
*/
|
|
136
|
+
searchTargetReusePolicy?: SearchTargetReusePolicy;
|
|
137
|
+
vendor: VendorType;
|
|
138
|
+
connectionType: ConnectionType;
|
|
139
|
+
kind: 'physical' | 'interactive';
|
|
140
|
+
label?: string;
|
|
141
|
+
model?: string;
|
|
142
|
+
modelName?: string;
|
|
143
|
+
serialNumber?: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated Use DeviceSearchTarget. Kept for consumers of the pre-release
|
|
147
|
+
* connection-target API.
|
|
148
|
+
*/
|
|
149
|
+
type ConnectionTarget = Omit<DeviceSearchTarget, 'searchTargetId'> & {
|
|
150
|
+
targetId: string;
|
|
151
|
+
searchTargetId?: string;
|
|
152
|
+
};
|
|
153
|
+
type WalletIdentity = {
|
|
154
|
+
vendor: 'ledger';
|
|
155
|
+
type: 'chainFingerprint';
|
|
156
|
+
chain: ChainForFingerprint;
|
|
157
|
+
value: string;
|
|
158
|
+
} | {
|
|
159
|
+
vendor: 'trezor';
|
|
160
|
+
type: 'deviceId';
|
|
161
|
+
value: string;
|
|
162
|
+
} | {
|
|
163
|
+
vendor: 'keystone';
|
|
164
|
+
type: 'walletId';
|
|
165
|
+
value: string;
|
|
166
|
+
};
|
|
76
167
|
|
|
77
168
|
/**
|
|
78
169
|
* Mixin for chain-operation params that can be pinned to a specific passphrase
|
|
@@ -133,6 +224,15 @@ interface ConnectorSession {
|
|
|
133
224
|
sessionId: string;
|
|
134
225
|
deviceInfo: DeviceInfo;
|
|
135
226
|
}
|
|
227
|
+
type ConnectorConnectTarget = {
|
|
228
|
+
type: 'default';
|
|
229
|
+
} | {
|
|
230
|
+
type: 'search-target';
|
|
231
|
+
searchTargetId: string;
|
|
232
|
+
} | {
|
|
233
|
+
type: 'expected-device-identity';
|
|
234
|
+
deviceIdentity: string;
|
|
235
|
+
};
|
|
136
236
|
/**
|
|
137
237
|
* Vendor-agnostic bag of extra error fields. Known keys are documented for
|
|
138
238
|
* discoverability; the index signature keeps it open so any connector can
|
|
@@ -253,12 +353,16 @@ interface ConnectorEventMap {
|
|
|
253
353
|
'ui-event': ConnectorUiEvent;
|
|
254
354
|
}
|
|
255
355
|
interface ConnectorSearchDevicesOptions {
|
|
356
|
+
/** Select a child transport without waking/scanning the others. */
|
|
357
|
+
transportType?: ConnectionType;
|
|
256
358
|
/**
|
|
257
359
|
* Wait for every child transport in a fused connector. Default discovery can
|
|
258
360
|
* return shortly after USB appears so BLE does not slow down USB flows;
|
|
259
361
|
* binding pickers can opt in when they need BLE candidates too.
|
|
260
362
|
*/
|
|
261
363
|
waitForAll?: boolean;
|
|
364
|
+
/** Availability probes must not invalidate user-selectable discovery targets. */
|
|
365
|
+
purpose?: 'selection' | 'availability';
|
|
262
366
|
}
|
|
263
367
|
interface ConnectorConfig {
|
|
264
368
|
/**
|
|
@@ -273,8 +377,17 @@ interface ConnectorConfig {
|
|
|
273
377
|
interface IConnector {
|
|
274
378
|
/** Physical connection type this connector uses. Fixed at construction. */
|
|
275
379
|
readonly connectionType: ConnectionType;
|
|
380
|
+
readonly availableTransports?: readonly ConnectionType[];
|
|
276
381
|
searchDevices(options?: ConnectorSearchDevicesOptions): Promise<ConnectorDevice[]>;
|
|
277
|
-
connect(deviceId?: string
|
|
382
|
+
connect(deviceId?: string, options?: {
|
|
383
|
+
transportType: ConnectionType;
|
|
384
|
+
}): Promise<ConnectorSession>;
|
|
385
|
+
/**
|
|
386
|
+
* Structured form for connectors where a discovery handle and a stable
|
|
387
|
+
* device identity are different concepts. The string form remains for
|
|
388
|
+
* bridge and legacy compatibility.
|
|
389
|
+
*/
|
|
390
|
+
connectTarget?(target: ConnectorConnectTarget): Promise<ConnectorSession>;
|
|
278
391
|
disconnect(sessionId: string): Promise<void>;
|
|
279
392
|
call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
|
|
280
393
|
cancel(sessionId: string): Promise<void>;
|
|
@@ -299,6 +412,9 @@ interface IHardwareBridge {
|
|
|
299
412
|
connect(params: {
|
|
300
413
|
vendor: VendorType;
|
|
301
414
|
deviceId?: string;
|
|
415
|
+
options?: {
|
|
416
|
+
transportType: ConnectionType;
|
|
417
|
+
};
|
|
302
418
|
}): Promise<ConnectorSession>;
|
|
303
419
|
disconnect(params: {
|
|
304
420
|
vendor: VendorType;
|
|
@@ -383,6 +499,10 @@ declare const DEVICE: {
|
|
|
383
499
|
readonly DISCONNECT: "device-disconnect";
|
|
384
500
|
readonly CHANGED: "device-changed";
|
|
385
501
|
readonly FEATURES: "features";
|
|
502
|
+
/** Trezor transport binding, emitted only after matching the expected firmware device_id. */
|
|
503
|
+
readonly TREZOR_CONNECTION_VERIFIED: "device-trezor-connection-verified";
|
|
504
|
+
/** Ledger BLE address repair, emitted only after matching the stored chain fingerprint. */
|
|
505
|
+
readonly LEDGER_CONNECTION_VERIFIED: "device-ledger-connection-verified";
|
|
386
506
|
/**
|
|
387
507
|
* Trezor-only. Emitted after a successful THP handshake that minted or
|
|
388
508
|
* refreshed pairing credentials. The host should persist `credentials`
|
|
@@ -581,11 +701,21 @@ interface SolSignedTx {
|
|
|
581
701
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
582
702
|
signature: string;
|
|
583
703
|
}
|
|
584
|
-
interface
|
|
704
|
+
interface SolSignMessageBaseParams extends PassphraseStateAware {
|
|
585
705
|
path: string;
|
|
586
706
|
/** Message bytes as hex string (no 0x prefix) */
|
|
587
707
|
message: string;
|
|
588
708
|
}
|
|
709
|
+
interface SolOffchainMessageV1Params {
|
|
710
|
+
/** Finalized Solana off-chain message format. */
|
|
711
|
+
messageVersion: 1;
|
|
712
|
+
/** Complete signer set as 32-byte hex public keys. */
|
|
713
|
+
requiredSigners: string[];
|
|
714
|
+
}
|
|
715
|
+
type SolSignMsgParams = SolSignMessageBaseParams & ({
|
|
716
|
+
messageVersion?: undefined;
|
|
717
|
+
requiredSigners?: undefined;
|
|
718
|
+
} | SolOffchainMessageV1Params);
|
|
589
719
|
interface SolSignature {
|
|
590
720
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
591
721
|
signature: string;
|
|
@@ -712,6 +842,12 @@ interface TronSignMsgParams extends PassphraseStateAware {
|
|
|
712
842
|
path: string;
|
|
713
843
|
/** Message hex (no 0x prefix) */
|
|
714
844
|
messageHex: string;
|
|
845
|
+
/**
|
|
846
|
+
* TRON message scheme: 'V1' = legacy signMessage (prefix + 32-byte hash),
|
|
847
|
+
* 'V2' = TIP-191 signMessageV2 (prefix + byte length + message). Adapters
|
|
848
|
+
* that only implement one scheme reject the other with MethodNotSupported.
|
|
849
|
+
*/
|
|
850
|
+
messageType?: 'V1' | 'V2';
|
|
715
851
|
}
|
|
716
852
|
interface TronSignature {
|
|
717
853
|
/** 65-byte hex-encoded signature (no 0x prefix) */
|
|
@@ -723,100 +859,160 @@ interface ITronMethods {
|
|
|
723
859
|
tronSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignMsgParams>>): Promise<Response<TronSignature>>;
|
|
724
860
|
}
|
|
725
861
|
|
|
726
|
-
/**
|
|
727
|
-
* Fixed derivation paths used to generate chain fingerprints.
|
|
728
|
-
* Uses standard index 0 — Ledger firmware shows device confirmation for
|
|
729
|
-
* non-standard paths (e.g., index=100), which would interrupt wallet creation.
|
|
730
|
-
* The address is hashed into a 16-char fingerprint, not exposed directly.
|
|
731
|
-
* - EVM: cointype 60 (Ledger ETH App only supports 60)
|
|
732
|
-
* - BTC: cointype 1 (testnet)
|
|
733
|
-
* - SOL: cointype 501, standard 3-level hardened
|
|
734
|
-
*/
|
|
735
|
-
declare const CHAIN_FINGERPRINT_PATHS: Record<ChainForFingerprint, string>;
|
|
736
|
-
type ChainForFingerprint = 'evm' | 'btc' | 'sol' | 'tron';
|
|
737
|
-
/**
|
|
738
|
-
* 16-char SHA-256 fingerprint for device-identity verification.
|
|
739
|
-
* Callers must canonicalize input (e.g. EVM address → lowercase) —
|
|
740
|
-
* encoding variations otherwise cause false DeviceMismatch.
|
|
741
|
-
*/
|
|
742
|
-
declare function deriveDeviceFingerprint(value: string): string;
|
|
743
|
-
|
|
744
862
|
/** Events generated by SDK internal detection (not from hardware directly). */
|
|
745
863
|
declare const SDK: {
|
|
746
864
|
readonly DEVICE_STUCK: "device-stuck";
|
|
747
865
|
readonly DEVICE_UNRESPONSIVE: "device-unresponsive";
|
|
748
866
|
readonly DEVICE_RECOVERED: "device-recovered";
|
|
749
867
|
readonly DEVICE_INTERACTION: "device-interaction";
|
|
868
|
+
readonly INTERACTION_ENDED: "interaction-ended";
|
|
750
869
|
};
|
|
751
870
|
|
|
871
|
+
declare const INTERACTION_DEFAULT_TTL_MS = 600000;
|
|
872
|
+
type InteractionEndReason = 'explicit' | 'disconnect' | 'timeout' | 'runtime-reset';
|
|
873
|
+
type HardwareInteraction = {
|
|
874
|
+
interactionId: string;
|
|
875
|
+
searchTargetId: string;
|
|
876
|
+
connectId: string;
|
|
877
|
+
device: DeviceInfo;
|
|
878
|
+
connectionKeys: string[];
|
|
879
|
+
createdAt: number;
|
|
880
|
+
lastActiveAt: number;
|
|
881
|
+
};
|
|
882
|
+
type InteractionRegistryOptions = {
|
|
883
|
+
vendor: VendorType;
|
|
884
|
+
ttlMs?: number;
|
|
885
|
+
onEnded?: (interaction: HardwareInteraction, reason: InteractionEndReason) => void;
|
|
886
|
+
};
|
|
887
|
+
/** Runtime-only association between a public interaction id and one live target. */
|
|
888
|
+
declare class InteractionRegistry {
|
|
889
|
+
private readonly _vendor;
|
|
890
|
+
private readonly _ttlMs;
|
|
891
|
+
private readonly _onEnded?;
|
|
892
|
+
private readonly _active;
|
|
893
|
+
private readonly _ended;
|
|
894
|
+
constructor(options: InteractionRegistryOptions);
|
|
895
|
+
create(params: {
|
|
896
|
+
searchTargetId: string;
|
|
897
|
+
connectId: string;
|
|
898
|
+
device: DeviceInfo;
|
|
899
|
+
connectionKeys?: string[];
|
|
900
|
+
}): HardwareInteraction;
|
|
901
|
+
resolve(interactionId: string): HardwareInteraction;
|
|
902
|
+
/** Keep an interaction alive while one device job is actively using it. */
|
|
903
|
+
retain(interactionId: string): () => void;
|
|
904
|
+
/** Return active or tombstoned binding data without refreshing its TTL. */
|
|
905
|
+
find(interactionId: string): HardwareInteraction | undefined;
|
|
906
|
+
findActiveByConnectionKey(connectionKey: string): HardwareInteraction | undefined;
|
|
907
|
+
/** Replace the live transport binding after the same target was reconnected. */
|
|
908
|
+
rebind(interactionId: string, params: {
|
|
909
|
+
connectId: string;
|
|
910
|
+
device: DeviceInfo;
|
|
911
|
+
connectionKeys?: string[];
|
|
912
|
+
}): HardwareInteraction;
|
|
913
|
+
end(interactionId: string, reason: InteractionEndReason): HardwareInteraction | undefined;
|
|
914
|
+
endByConnectionKey(connectionKey: string, reason: InteractionEndReason, exceptInteractionId?: string): void;
|
|
915
|
+
endAll(reason: InteractionEndReason, exceptInteractionId?: string): void;
|
|
916
|
+
private _createTimer;
|
|
917
|
+
private _rememberEnded;
|
|
918
|
+
}
|
|
919
|
+
|
|
752
920
|
type HardwareMethodMetadata = {
|
|
753
921
|
chain: ChainForFingerprint;
|
|
754
922
|
allNetwork: boolean;
|
|
923
|
+
/** Whether repeating the method after an ambiguous transport failure is safe. */
|
|
924
|
+
replayAfterTransportFailure: 'safe' | 'unsafe';
|
|
755
925
|
};
|
|
756
926
|
declare const HARDWARE_METHOD_CATALOG: {
|
|
757
927
|
readonly evmGetAddress: {
|
|
758
928
|
readonly chain: "evm";
|
|
759
929
|
readonly allNetwork: true;
|
|
930
|
+
readonly replayAfterTransportFailure: "safe";
|
|
760
931
|
};
|
|
761
932
|
readonly evmSignTransaction: {
|
|
762
933
|
readonly chain: "evm";
|
|
763
934
|
readonly allNetwork: false;
|
|
935
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
764
936
|
};
|
|
765
937
|
readonly evmSignMessage: {
|
|
766
938
|
readonly chain: "evm";
|
|
767
939
|
readonly allNetwork: false;
|
|
940
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
768
941
|
};
|
|
769
942
|
readonly evmSignTypedData: {
|
|
770
943
|
readonly chain: "evm";
|
|
771
944
|
readonly allNetwork: false;
|
|
945
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
772
946
|
};
|
|
773
947
|
readonly btcGetAddress: {
|
|
774
948
|
readonly chain: "btc";
|
|
775
949
|
readonly allNetwork: true;
|
|
950
|
+
readonly replayAfterTransportFailure: "safe";
|
|
776
951
|
};
|
|
777
952
|
readonly btcGetPublicKey: {
|
|
778
953
|
readonly chain: "btc";
|
|
779
954
|
readonly allNetwork: true;
|
|
955
|
+
readonly replayAfterTransportFailure: "safe";
|
|
780
956
|
};
|
|
781
957
|
readonly btcSignTransaction: {
|
|
782
958
|
readonly chain: "btc";
|
|
783
959
|
readonly allNetwork: false;
|
|
960
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
784
961
|
};
|
|
785
962
|
readonly btcSignPsbt: {
|
|
786
963
|
readonly chain: "btc";
|
|
787
964
|
readonly allNetwork: false;
|
|
965
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
788
966
|
};
|
|
789
967
|
readonly btcSignMessage: {
|
|
790
968
|
readonly chain: "btc";
|
|
791
969
|
readonly allNetwork: false;
|
|
970
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
792
971
|
};
|
|
793
972
|
readonly btcGetMasterFingerprint: {
|
|
794
973
|
readonly chain: "btc";
|
|
795
974
|
readonly allNetwork: false;
|
|
975
|
+
readonly replayAfterTransportFailure: "safe";
|
|
796
976
|
};
|
|
797
977
|
readonly solGetAddress: {
|
|
798
978
|
readonly chain: "sol";
|
|
799
979
|
readonly allNetwork: true;
|
|
980
|
+
readonly replayAfterTransportFailure: "safe";
|
|
800
981
|
};
|
|
801
982
|
readonly solSignTransaction: {
|
|
802
983
|
readonly chain: "sol";
|
|
803
984
|
readonly allNetwork: false;
|
|
985
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
804
986
|
};
|
|
805
987
|
readonly solSignMessage: {
|
|
806
988
|
readonly chain: "sol";
|
|
807
989
|
readonly allNetwork: false;
|
|
990
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
808
991
|
};
|
|
809
992
|
readonly tronGetAddress: {
|
|
810
993
|
readonly chain: "tron";
|
|
811
994
|
readonly allNetwork: true;
|
|
995
|
+
readonly replayAfterTransportFailure: "safe";
|
|
812
996
|
};
|
|
813
997
|
readonly tronSignTransaction: {
|
|
814
998
|
readonly chain: "tron";
|
|
815
999
|
readonly allNetwork: false;
|
|
1000
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
816
1001
|
};
|
|
817
1002
|
readonly tronSignMessage: {
|
|
818
1003
|
readonly chain: "tron";
|
|
819
1004
|
readonly allNetwork: false;
|
|
1005
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
1006
|
+
};
|
|
1007
|
+
readonly zcashGetFullViewingKey: {
|
|
1008
|
+
readonly chain: "zcash";
|
|
1009
|
+
readonly allNetwork: false;
|
|
1010
|
+
readonly replayAfterTransportFailure: "safe";
|
|
1011
|
+
};
|
|
1012
|
+
readonly zcashGetShieldedAddress: {
|
|
1013
|
+
readonly chain: "zcash";
|
|
1014
|
+
readonly allNetwork: false;
|
|
1015
|
+
readonly replayAfterTransportFailure: "safe";
|
|
820
1016
|
};
|
|
821
1017
|
};
|
|
822
1018
|
type HardwareMethodName = keyof typeof HARDWARE_METHOD_CATALOG;
|
|
@@ -825,6 +1021,11 @@ type AllNetworkMethodName = {
|
|
|
825
1021
|
}[HardwareMethodName];
|
|
826
1022
|
declare const ALL_NETWORK_METHOD_NAMES: AllNetworkMethodName[];
|
|
827
1023
|
declare function getHardwareMethodMetadata(method: string): HardwareMethodMetadata | undefined;
|
|
1024
|
+
/**
|
|
1025
|
+
* Conservative replay gate used only after a call may have reached hardware.
|
|
1026
|
+
* Unknown methods and device mutations are unsafe by default.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function canReplayHardwareMethodAfterTransportFailure(method: string): boolean;
|
|
828
1029
|
declare function isAllNetworkMethodName(method: string): method is AllNetworkMethodName;
|
|
829
1030
|
declare function getAllNetworkMethodChain(method: AllNetworkMethodName): ChainForFingerprint;
|
|
830
1031
|
|
|
@@ -843,7 +1044,7 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
|
|
|
843
1044
|
progress: number;
|
|
844
1045
|
};
|
|
845
1046
|
};
|
|
846
|
-
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron';
|
|
1047
|
+
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron' | 'zcash';
|
|
847
1048
|
type TrezorDisplayRotation = 'North' | 'East' | 'South' | 'West';
|
|
848
1049
|
type TrezorSafetyCheckLevel = 'Strict' | 'PromptAlways' | 'PromptTemporarily';
|
|
849
1050
|
type TrezorDeviceSettingsParams = {
|
|
@@ -920,13 +1121,67 @@ type DeviceAuthenticityResult = {
|
|
|
920
1121
|
* that aren't specific to one chain. Vendor-specific options can be added
|
|
921
1122
|
* as typed sub-fields here when a vendor actually needs them.
|
|
922
1123
|
*/
|
|
923
|
-
|
|
1124
|
+
/** Persisted connection hints, never proof of device or wallet identity. */
|
|
1125
|
+
type KnownDeviceConnection = {
|
|
1126
|
+
transport: 'usb' | 'ble';
|
|
1127
|
+
connectId: string;
|
|
1128
|
+
} | {
|
|
1129
|
+
transport: 'qr';
|
|
1130
|
+
};
|
|
1131
|
+
/** Opaque host lookup identifiers. Never forward these to firmware or logs. */
|
|
1132
|
+
type HardwareCallExtra = Readonly<Record<string, string>>;
|
|
1133
|
+
interface IHardwareConnectionContext {
|
|
1134
|
+
knownConnections?: readonly KnownDeviceConnection[];
|
|
1135
|
+
extra?: HardwareCallExtra;
|
|
1136
|
+
/** False makes discovery fail instead of asking the user to select a new endpoint. */
|
|
1137
|
+
allowDeviceSelection?: boolean;
|
|
1138
|
+
}
|
|
1139
|
+
type DeviceSelectionContext = {
|
|
1140
|
+
kind: 'select-device';
|
|
1141
|
+
transport: 'usb';
|
|
1142
|
+
reason: 'multiple-candidates';
|
|
1143
|
+
} | {
|
|
1144
|
+
kind: 'bind-connection';
|
|
1145
|
+
transport: 'ble';
|
|
1146
|
+
reason: 'missing-binding' | 'known-connection-unavailable';
|
|
1147
|
+
};
|
|
1148
|
+
interface DeviceSelectionRequest {
|
|
1149
|
+
devices: DeviceInfo[];
|
|
1150
|
+
requestId: string;
|
|
1151
|
+
context: DeviceSelectionContext;
|
|
1152
|
+
extra?: HardwareCallExtra;
|
|
1153
|
+
/** Repeated snapshots with this requestId update one SDK-owned binding scan. */
|
|
1154
|
+
scanning?: boolean;
|
|
1155
|
+
bindingSessionId?: string;
|
|
1156
|
+
/** A candidate rejected by SDK identity verification in this binding session. */
|
|
1157
|
+
rejectedConnectId?: string;
|
|
1158
|
+
}
|
|
1159
|
+
/** The SDK has verified this endpoint; the host must persist it before acknowledging. */
|
|
1160
|
+
interface SaveDeviceBindingRequest {
|
|
1161
|
+
requestId: string;
|
|
1162
|
+
selectionRequestId: string;
|
|
1163
|
+
connection: {
|
|
1164
|
+
transport: 'ble';
|
|
1165
|
+
connectId: string;
|
|
1166
|
+
};
|
|
1167
|
+
identity: Extract<WalletIdentity, {
|
|
1168
|
+
vendor: 'ledger' | 'trezor';
|
|
1169
|
+
}>;
|
|
1170
|
+
extra?: HardwareCallExtra;
|
|
1171
|
+
}
|
|
1172
|
+
interface DeviceBindingStatus {
|
|
1173
|
+
selectionRequestId: string;
|
|
1174
|
+
status: 'verifying' | 'saved' | 'failed' | 'cancelled';
|
|
1175
|
+
}
|
|
1176
|
+
interface ICommonCallParams extends IHardwareConnectionContext {
|
|
924
1177
|
/**
|
|
925
1178
|
* When the required device app is missing, prompt the user (UI request)
|
|
926
1179
|
* to install it, stream install progress, then retry the operation once.
|
|
927
1180
|
* Off by default — preserves the plain "app not installed" failure.
|
|
928
1181
|
*/
|
|
929
1182
|
autoInstallApp?: boolean;
|
|
1183
|
+
/** Runtime-only id returned by connectDevice(). When present, discovery and fallback are disabled. */
|
|
1184
|
+
interactionId?: string;
|
|
930
1185
|
}
|
|
931
1186
|
type NullableCallArg<T> = T | null | undefined;
|
|
932
1187
|
interface IPassphraseCallParams {
|
|
@@ -935,6 +1190,15 @@ interface IPassphraseCallParams {
|
|
|
935
1190
|
}
|
|
936
1191
|
type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
|
|
937
1192
|
type IHardwareCallParams<T> = T & IHardwareCommonCallParams;
|
|
1193
|
+
/**
|
|
1194
|
+
* Runtime-only context for device-manager operations. The expected identity
|
|
1195
|
+
* lets an adapter fail closed before a read or mutation is replayed after a
|
|
1196
|
+
* reconnect. It must never be forwarded to vendor firmware.
|
|
1197
|
+
*/
|
|
1198
|
+
interface IDeviceManagerOperationContext extends IHardwareConnectionContext {
|
|
1199
|
+
interactionId?: string;
|
|
1200
|
+
expectedDeviceIdentity?: WalletIdentity;
|
|
1201
|
+
}
|
|
938
1202
|
interface AllNetworkAddressParams {
|
|
939
1203
|
network: string;
|
|
940
1204
|
path: string;
|
|
@@ -945,16 +1209,7 @@ interface AllNetworkAddressParams {
|
|
|
945
1209
|
interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
|
|
946
1210
|
bundle: AllNetworkAddressParams[];
|
|
947
1211
|
}
|
|
948
|
-
type AllNetworkDeviceIdentity =
|
|
949
|
-
vendor: 'ledger';
|
|
950
|
-
type: 'chainFingerprint';
|
|
951
|
-
chain: ChainForFingerprint;
|
|
952
|
-
value: string;
|
|
953
|
-
} | {
|
|
954
|
-
vendor: 'trezor';
|
|
955
|
-
type: 'deviceId';
|
|
956
|
-
value: string;
|
|
957
|
-
};
|
|
1212
|
+
type AllNetworkDeviceIdentity = WalletIdentity;
|
|
958
1213
|
type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
959
1214
|
error?: string;
|
|
960
1215
|
code?: HardwareErrorCode | number;
|
|
@@ -962,6 +1217,7 @@ type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
|
962
1217
|
connectId?: string;
|
|
963
1218
|
deviceId?: string;
|
|
964
1219
|
deviceIdentity?: AllNetworkDeviceIdentity;
|
|
1220
|
+
rootFingerprint?: number;
|
|
965
1221
|
chainFingerprint?: string;
|
|
966
1222
|
chainFingerprintChain?: ChainForFingerprint;
|
|
967
1223
|
params?: Record<string, unknown>;
|
|
@@ -986,6 +1242,25 @@ type DeviceEvent = {
|
|
|
986
1242
|
} | {
|
|
987
1243
|
type: typeof DEVICE.CHANGED;
|
|
988
1244
|
payload: DeviceInfo;
|
|
1245
|
+
} | {
|
|
1246
|
+
type: typeof DEVICE.LEDGER_CONNECTION_VERIFIED;
|
|
1247
|
+
payload: {
|
|
1248
|
+
previousConnectId: string;
|
|
1249
|
+
connectId: string;
|
|
1250
|
+
chain: ChainForFingerprint;
|
|
1251
|
+
fingerprint: string;
|
|
1252
|
+
extra?: HardwareCallExtra;
|
|
1253
|
+
selectionRequestId?: string;
|
|
1254
|
+
};
|
|
1255
|
+
} | {
|
|
1256
|
+
type: typeof DEVICE.TREZOR_CONNECTION_VERIFIED;
|
|
1257
|
+
payload: {
|
|
1258
|
+
deviceId: string;
|
|
1259
|
+
connectId: string;
|
|
1260
|
+
connectionType: TransportType;
|
|
1261
|
+
extra?: HardwareCallExtra;
|
|
1262
|
+
selectionRequestId?: string;
|
|
1263
|
+
};
|
|
989
1264
|
} | {
|
|
990
1265
|
type: typeof DEVICE.FEATURES;
|
|
991
1266
|
device: DeviceInfo & {
|
|
@@ -1047,9 +1322,13 @@ type UiRequestEvent = {
|
|
|
1047
1322
|
};
|
|
1048
1323
|
} | {
|
|
1049
1324
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1050
|
-
payload:
|
|
1051
|
-
|
|
1052
|
-
|
|
1325
|
+
payload: DeviceSelectionRequest;
|
|
1326
|
+
} | {
|
|
1327
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1328
|
+
payload: SaveDeviceBindingRequest;
|
|
1329
|
+
} | {
|
|
1330
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1331
|
+
payload: DeviceBindingStatus;
|
|
1053
1332
|
} | {
|
|
1054
1333
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
1055
1334
|
payload: {
|
|
@@ -1109,6 +1388,12 @@ type SdkEvent = {
|
|
|
1109
1388
|
payload: {
|
|
1110
1389
|
connectId: string;
|
|
1111
1390
|
};
|
|
1391
|
+
} | {
|
|
1392
|
+
type: typeof SDK.INTERACTION_ENDED;
|
|
1393
|
+
payload: {
|
|
1394
|
+
interactionId: string;
|
|
1395
|
+
reason: InteractionEndReason;
|
|
1396
|
+
};
|
|
1112
1397
|
};
|
|
1113
1398
|
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent | HardwareUiEvent;
|
|
1114
1399
|
type DeviceEventListener = (event: HardwareEvent) => void;
|
|
@@ -1119,6 +1404,14 @@ type DeviceEventListener = (event: HardwareEvent) => void;
|
|
|
1119
1404
|
* and the value is the narrowed event object the listener will receive.
|
|
1120
1405
|
*/
|
|
1121
1406
|
interface HardwareEventMap {
|
|
1407
|
+
[UI_REQUEST.DEVICE_BINDING_STATUS]: {
|
|
1408
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1409
|
+
payload: DeviceBindingStatus;
|
|
1410
|
+
};
|
|
1411
|
+
[UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING]: {
|
|
1412
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1413
|
+
payload: SaveDeviceBindingRequest;
|
|
1414
|
+
};
|
|
1122
1415
|
'ui-event': HardwareUiEvent;
|
|
1123
1416
|
[DEVICE.CONNECT]: {
|
|
1124
1417
|
type: typeof DEVICE.CONNECT;
|
|
@@ -1134,6 +1427,27 @@ interface HardwareEventMap {
|
|
|
1134
1427
|
type: typeof DEVICE.CHANGED;
|
|
1135
1428
|
payload: DeviceInfo;
|
|
1136
1429
|
};
|
|
1430
|
+
[DEVICE.LEDGER_CONNECTION_VERIFIED]: {
|
|
1431
|
+
type: typeof DEVICE.LEDGER_CONNECTION_VERIFIED;
|
|
1432
|
+
payload: {
|
|
1433
|
+
previousConnectId: string;
|
|
1434
|
+
connectId: string;
|
|
1435
|
+
chain: ChainForFingerprint;
|
|
1436
|
+
fingerprint: string;
|
|
1437
|
+
extra?: HardwareCallExtra;
|
|
1438
|
+
selectionRequestId?: string;
|
|
1439
|
+
};
|
|
1440
|
+
};
|
|
1441
|
+
[DEVICE.TREZOR_CONNECTION_VERIFIED]: {
|
|
1442
|
+
type: typeof DEVICE.TREZOR_CONNECTION_VERIFIED;
|
|
1443
|
+
payload: {
|
|
1444
|
+
deviceId: string;
|
|
1445
|
+
connectId: string;
|
|
1446
|
+
connectionType: TransportType;
|
|
1447
|
+
extra?: HardwareCallExtra;
|
|
1448
|
+
selectionRequestId?: string;
|
|
1449
|
+
};
|
|
1450
|
+
};
|
|
1137
1451
|
[DEVICE.FEATURES]: {
|
|
1138
1452
|
type: typeof DEVICE.FEATURES;
|
|
1139
1453
|
device: DeviceInfo & {
|
|
@@ -1206,9 +1520,7 @@ interface HardwareEventMap {
|
|
|
1206
1520
|
};
|
|
1207
1521
|
[UI_REQUEST.REQUEST_SELECT_DEVICE]: {
|
|
1208
1522
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1209
|
-
payload:
|
|
1210
|
-
devices: DeviceInfo[];
|
|
1211
|
-
};
|
|
1523
|
+
payload: DeviceSelectionRequest;
|
|
1212
1524
|
};
|
|
1213
1525
|
[UI_REQUEST.REQUEST_DEVICE_CONNECT]: {
|
|
1214
1526
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
@@ -1271,16 +1583,23 @@ interface HardwareEventMap {
|
|
|
1271
1583
|
connectId: string;
|
|
1272
1584
|
};
|
|
1273
1585
|
};
|
|
1586
|
+
[SDK.INTERACTION_ENDED]: {
|
|
1587
|
+
type: typeof SDK.INTERACTION_ENDED;
|
|
1588
|
+
payload: {
|
|
1589
|
+
interactionId: string;
|
|
1590
|
+
reason: InteractionEndReason;
|
|
1591
|
+
};
|
|
1592
|
+
};
|
|
1274
1593
|
}
|
|
1275
1594
|
interface IDeviceManagerMethods {
|
|
1276
|
-
getFeatures?(connectId: string): Promise<Response<Record<string, unknown>>>;
|
|
1277
|
-
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams): Promise<Response<Record<string, unknown>>>;
|
|
1278
|
-
setBrightness?(connectId: string, params?: TrezorBrightnessParams): Promise<Response<Record<string, unknown>>>;
|
|
1279
|
-
changePin?(connectId: string, params?: TrezorChangePinParams): Promise<Response<Record<string, unknown>>>;
|
|
1280
|
-
wipeDevice?(connectId: string): Promise<Response<Record<string, unknown>>>;
|
|
1595
|
+
getFeatures?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1596
|
+
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1597
|
+
setBrightness?(connectId: string, params?: TrezorBrightnessParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1598
|
+
changePin?(connectId: string, params?: TrezorChangePinParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1599
|
+
wipeDevice?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1281
1600
|
authenticateDevice?(connectId: string, params: {
|
|
1282
1601
|
challenge: string;
|
|
1283
|
-
}): Promise<Response<Record<string, unknown>>>;
|
|
1602
|
+
}, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1284
1603
|
}
|
|
1285
1604
|
interface IWalletStateMethods {
|
|
1286
1605
|
/**
|
|
@@ -1307,7 +1626,7 @@ interface IWalletStateMethods {
|
|
|
1307
1626
|
* Optional: vendors without host-managed passphrase sessions (Ledger) omit
|
|
1308
1627
|
* it. Implemented by `TrezorAdapter`.
|
|
1309
1628
|
*/
|
|
1310
|
-
getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
|
|
1629
|
+
getPassphraseState?(connectId: string, passphraseState?: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<string | null>>;
|
|
1311
1630
|
}
|
|
1312
1631
|
interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
|
|
1313
1632
|
readonly vendor: string;
|
|
@@ -1317,8 +1636,16 @@ interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, I
|
|
|
1317
1636
|
getAvailableTransports(): TransportType[];
|
|
1318
1637
|
switchTransport(type: TransportType): Promise<void>;
|
|
1319
1638
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
1320
|
-
|
|
1321
|
-
|
|
1639
|
+
/** Discover selectable hardware entries without claiming identified devices or wallets. */
|
|
1640
|
+
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
1641
|
+
/** @deprecated Use searchDeviceTargets(). */
|
|
1642
|
+
listConnectionTargets(options?: SearchDevicesOptions): Promise<ConnectionTarget[]>;
|
|
1643
|
+
/** Connect or logically bind a selected search result and return a runtime-only interaction id. */
|
|
1644
|
+
connectDevice(searchTargetId: string): Promise<Response<string>>;
|
|
1645
|
+
/** Resolve operation-first routing/selection and pin it. The caller must verify wallet identity before business calls. */
|
|
1646
|
+
acquireInteraction?(connectId: string, context: IHardwareConnectionContext): Promise<Response<string>>;
|
|
1647
|
+
/** Release an interaction owned by the caller. Disconnect events end matching interactions automatically. */
|
|
1648
|
+
releaseInteraction(interactionId: string): Promise<void>;
|
|
1322
1649
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
1323
1650
|
getSupportedChains(): ChainCapability[];
|
|
1324
1651
|
/** Abort the in-flight call. Omit connectId to cancel whatever is active. */
|
|
@@ -1357,6 +1684,14 @@ interface SearchDevicesOptions {
|
|
|
1357
1684
|
* was discovered first.
|
|
1358
1685
|
*/
|
|
1359
1686
|
waitForAllTransports?: boolean;
|
|
1687
|
+
/**
|
|
1688
|
+
* Restrict discovery to one transport. A non-enumerable channel may return
|
|
1689
|
+
* a virtual connection target (for example Keystone QR), but discovery must
|
|
1690
|
+
* not start a wallet protocol or account-export interaction. The target is
|
|
1691
|
+
* resolved by the following `connectDevice()` call. Omit to scan everything
|
|
1692
|
+
* available.
|
|
1693
|
+
*/
|
|
1694
|
+
transportType?: ConnectionType;
|
|
1360
1695
|
}
|
|
1361
1696
|
|
|
1362
1697
|
interface EvmGetAddressParams extends PassphraseStateAware {
|
|
@@ -1518,6 +1853,33 @@ interface IEvmMethods {
|
|
|
1518
1853
|
evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
|
|
1519
1854
|
}
|
|
1520
1855
|
|
|
1856
|
+
/** Which `GET_VK` encoding the Ledger Zcash app should return. */
|
|
1857
|
+
type ZcashFullViewingKeyMode = 'ufvk' | 'orchardFvk';
|
|
1858
|
+
interface ZcashGetFullViewingKeyParams extends PassphraseStateAware {
|
|
1859
|
+
/** BIP44 account path `m/44'/133'/a'` (any deeper transparent path is accepted; only the account level is used). */
|
|
1860
|
+
path: string;
|
|
1861
|
+
/** Default `ufvk`. */
|
|
1862
|
+
mode?: ZcashFullViewingKeyMode;
|
|
1863
|
+
}
|
|
1864
|
+
interface ZcashFullViewingKey {
|
|
1865
|
+
path: string;
|
|
1866
|
+
mode: ZcashFullViewingKeyMode;
|
|
1867
|
+
/** ZIP-316 bech32m UFVK string (mode `ufvk`). */
|
|
1868
|
+
ufvk?: string;
|
|
1869
|
+
/** 96-byte raw Orchard FVK as hex (mode `orchardFvk`). */
|
|
1870
|
+
orchardFvk?: string;
|
|
1871
|
+
}
|
|
1872
|
+
interface ZcashGetShieldedAddressParams extends PassphraseStateAware {
|
|
1873
|
+
/** Full 5-level transparent path `m/44'/133'/a'/0/i`; the Orchard path is derived from it. */
|
|
1874
|
+
path: string;
|
|
1875
|
+
showOnDevice?: boolean;
|
|
1876
|
+
}
|
|
1877
|
+
interface ZcashShieldedAddress {
|
|
1878
|
+
/** Unified address with a single Orchard receiver. */
|
|
1879
|
+
address: string;
|
|
1880
|
+
path: string;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1521
1883
|
/**
|
|
1522
1884
|
* Low-level device descriptor from Transport layer.
|
|
1523
1885
|
* Represents a physical device detected by USB/BLE scanning.
|
|
@@ -1609,6 +1971,50 @@ declare class DeviceJobQueue {
|
|
|
1609
1971
|
clear(reason?: Error): void;
|
|
1610
1972
|
}
|
|
1611
1973
|
|
|
1974
|
+
declare const HARDWARE_RUNTIME_ID_PREFIX = "hwk:runtime:v1";
|
|
1975
|
+
type HardwareRuntimeId = {
|
|
1976
|
+
kind: 'interaction';
|
|
1977
|
+
vendor: VendorType;
|
|
1978
|
+
nonce: string;
|
|
1979
|
+
} | {
|
|
1980
|
+
kind: 'search-target';
|
|
1981
|
+
vendor: VendorType;
|
|
1982
|
+
connectionType: ConnectionType;
|
|
1983
|
+
nonce: string;
|
|
1984
|
+
} | {
|
|
1985
|
+
kind: 'connector-session';
|
|
1986
|
+
vendor: VendorType;
|
|
1987
|
+
connectionType: ConnectionType;
|
|
1988
|
+
nonce: string;
|
|
1989
|
+
};
|
|
1990
|
+
/** Runtime ids are opaque and must never be persisted as device identity. */
|
|
1991
|
+
declare function createHardwareInteractionId(vendor: VendorType): string;
|
|
1992
|
+
/** Search targets are valid only for the adapter's current discovery snapshot. */
|
|
1993
|
+
declare function createHardwareSearchTargetId(params: {
|
|
1994
|
+
vendor: VendorType;
|
|
1995
|
+
connectionType: ConnectionType;
|
|
1996
|
+
}): string;
|
|
1997
|
+
declare function createHardwareConnectorSessionId(params: {
|
|
1998
|
+
vendor: VendorType;
|
|
1999
|
+
connectionType: ConnectionType;
|
|
2000
|
+
}): string;
|
|
2001
|
+
declare function hasHardwareRuntimeIdPrefix(value: unknown): value is string;
|
|
2002
|
+
declare function parseHardwareRuntimeId(value: unknown): HardwareRuntimeId | undefined;
|
|
2003
|
+
declare function isHardwareInteractionId(value: unknown): value is string;
|
|
2004
|
+
declare function isHardwareSearchTargetId(value: unknown): value is string;
|
|
2005
|
+
|
|
2006
|
+
interface HardwareOperationTarget {
|
|
2007
|
+
/** Effective target accepted by existing adapter/connector call paths. */
|
|
2008
|
+
targetId: string | undefined;
|
|
2009
|
+
/** Present when this operation is pinned to a live interaction. */
|
|
2010
|
+
interactionId: string | undefined;
|
|
2011
|
+
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Normalizes the transitional positional interaction id and the canonical
|
|
2014
|
+
* common-params field. All vendors must reject conflicting bindings.
|
|
2015
|
+
*/
|
|
2016
|
+
declare function resolveHardwareOperationTarget(positionalTargetId: string | null | undefined, commonInteractionId: string | null | undefined, expectedVendor?: VendorType): Response<HardwareOperationTarget>;
|
|
2017
|
+
|
|
1612
2018
|
/**
|
|
1613
2019
|
* Minimal typed event emitter using Map<string, Set<listener>>.
|
|
1614
2020
|
* Each adapter uses this for device events (connect, disconnect, pin, etc.).
|
|
@@ -1635,6 +2041,62 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
|
|
|
1635
2041
|
listenerCount(event: string): number;
|
|
1636
2042
|
}
|
|
1637
2043
|
|
|
2044
|
+
/** Serializable BLE transport data shared by Electron main and renderer runtimes. */
|
|
2045
|
+
interface ElectronBleDeviceInfo {
|
|
2046
|
+
id: string;
|
|
2047
|
+
name?: string;
|
|
2048
|
+
rssi?: number;
|
|
2049
|
+
advertisedServiceUuids?: string[];
|
|
2050
|
+
}
|
|
2051
|
+
interface ElectronBleScanOptions {
|
|
2052
|
+
vendor?: 'trezor' | 'ledger';
|
|
2053
|
+
serviceUuids?: string[];
|
|
2054
|
+
durationMs?: number;
|
|
2055
|
+
}
|
|
2056
|
+
interface ElectronBleConnectOptions {
|
|
2057
|
+
vendor: 'ledger';
|
|
2058
|
+
serviceUuid: string;
|
|
2059
|
+
writeUuid: string;
|
|
2060
|
+
notifyUuid: string;
|
|
2061
|
+
}
|
|
2062
|
+
/** Native code handles GATT only; framing, identity checks and wallet operations stay in the SDK. */
|
|
2063
|
+
interface ElectronBleApi {
|
|
2064
|
+
scan(options?: ElectronBleScanOptions): Promise<ElectronBleDeviceInfo[]>;
|
|
2065
|
+
stopScan(): Promise<void>;
|
|
2066
|
+
connect(id: string, options?: ElectronBleConnectOptions): Promise<{
|
|
2067
|
+
id: string;
|
|
2068
|
+
name?: string;
|
|
2069
|
+
}>;
|
|
2070
|
+
disconnect(id: string): Promise<void>;
|
|
2071
|
+
subscribe(id: string): Promise<void>;
|
|
2072
|
+
unsubscribe(id: string): Promise<void>;
|
|
2073
|
+
write(id: string, hexData: string): Promise<void>;
|
|
2074
|
+
checkAvailability(): Promise<{
|
|
2075
|
+
available: boolean;
|
|
2076
|
+
state: string;
|
|
2077
|
+
initialized: boolean;
|
|
2078
|
+
}>;
|
|
2079
|
+
getDevice(id: string): Promise<ElectronBleDeviceInfo | null>;
|
|
2080
|
+
onNotification(handler: (id: string, hexData: string) => void): () => void;
|
|
2081
|
+
onDeviceDisconnected(handler: (id: string) => void): () => void;
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
/** Legacy hosts keep their notification path until they subscribe to the acknowledged contract. */
|
|
2085
|
+
declare function requestSaveDeviceBinding(emitter: TypedEventEmitter<HardwareEventMap>, registry: UiRequestRegistry, binding: Omit<SaveDeviceBindingRequest, 'requestId'>, signal?: AbortSignal): Promise<boolean>;
|
|
2086
|
+
|
|
2087
|
+
/** Discovery and selection share one owner; never connect until the last scan has drained. */
|
|
2088
|
+
declare function requestBleDeviceSelection({ emitter, registry, request, scan, signal, pollIntervalMs, }: {
|
|
2089
|
+
emitter: TypedEventEmitter<HardwareEventMap>;
|
|
2090
|
+
registry: UiRequestRegistry;
|
|
2091
|
+
request: Omit<DeviceSelectionRequest, 'requestId' | 'scanning'>;
|
|
2092
|
+
scan: () => Promise<DeviceInfo[]>;
|
|
2093
|
+
signal: AbortSignal;
|
|
2094
|
+
pollIntervalMs?: number;
|
|
2095
|
+
}): Promise<{
|
|
2096
|
+
device: DeviceInfo;
|
|
2097
|
+
requestId: string;
|
|
2098
|
+
}>;
|
|
2099
|
+
|
|
1638
2100
|
/**
|
|
1639
2101
|
* Compare two semver strings (e.g. "2.1.0" vs "2.3.1").
|
|
1640
2102
|
* Returns -1 if a < b, 0 if equal, 1 if a > b.
|
|
@@ -1655,7 +2117,18 @@ declare function hexToBytes(hex: string): Uint8Array;
|
|
|
1655
2117
|
/** Convert a Uint8Array to a hex string (no 0x prefix). */
|
|
1656
2118
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
1657
2119
|
|
|
1658
|
-
|
|
2120
|
+
interface PrepareSolanaOffchainMessageV1Params {
|
|
2121
|
+
message: Uint8Array;
|
|
2122
|
+
requiredSigners: readonly string[];
|
|
2123
|
+
}
|
|
2124
|
+
interface PreparedSolanaOffchainMessageV1 {
|
|
2125
|
+
messageText: string;
|
|
2126
|
+
requiredSigners: string[];
|
|
2127
|
+
serializedMessage: Uint8Array;
|
|
2128
|
+
}
|
|
2129
|
+
declare function prepareSolanaOffchainMessageV1({ message, requiredSigners, }: PrepareSolanaOffchainMessageV1Params): PreparedSolanaOffchainMessageV1;
|
|
2130
|
+
|
|
2131
|
+
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger' | 'keystone';
|
|
1659
2132
|
type HardwareDeviceIdentityInput = {
|
|
1660
2133
|
name?: string | null;
|
|
1661
2134
|
localName?: string | null;
|
|
@@ -1722,4 +2195,4 @@ declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams):
|
|
|
1722
2195
|
|
|
1723
2196
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
1724
2197
|
|
|
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 };
|
|
2198
|
+
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkDeviceIdentity, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type 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 ConnectionTarget, type ConnectionType, type ConnectorCallResult, type ConnectorConfig, type ConnectorConnectTarget, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSearchDevicesOptions, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_CONNECT_RETRY_DELAY_MS, DEVICE_EVENT, type DetectableHardwareVendor, type DeviceAuthenticityParams, type DeviceAuthenticityResult, type DeviceBindingStatus, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DeviceSearchTarget, type DeviceSelectionContext, type DeviceSelectionRequest, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type ElectronBleApi, type ElectronBleConnectOptions, type ElectronBleDeviceInfo, type ElectronBleScanOptions, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxLedgerParams, type EvmSignTxParams, type EvmSignTxTrezorParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, HARDWARE_RUNTIME_ID_PREFIX, type HardwareCallExtra, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareInteraction, type HardwareMethodMetadata, type HardwareMethodName, type HardwareOperationTarget, type HardwareRuntimeId, type HardwareUiEvent, HwkErrorOrigin, HwkRecoveryHint, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IDeviceManagerOperationContext, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareConnectionContext, type IHardwareWallet, INTERACTION_DEFAULT_TTL_MS, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type InteractionEndReason, InteractionRegistry, type JobOptions, type KnownDeviceConnection, type NullableCallArg, type PassphraseResponse, type PassphraseStateAware, type PrepareSolanaOffchainMessageV1Params, type PreparedSolanaOffchainMessageV1, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, type SaveDeviceBindingRequest, type SdkEvent, type SearchDevicesOptions, type SearchTargetReusePolicy, type SolAddress, type SolGetAddressParams, type SolOffchainMessageV1Params, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiRequestRegistry, UiResponseEvent, type VendorType, type WalletIdentity, type ZcashFullViewingKey, type ZcashFullViewingKeyMode, type ZcashGetFullViewingKeyParams, type ZcashGetShieldedAddressParams, type ZcashShieldedAddress, batchCall, buildUnsupportedMethodResponse, bytesToHex, canReplayHardwareMethodAfterTransportFailure, compareSemver, createBridgedConnector, createCombinedConnector, createHardwareConnectorSessionId, createHardwareInteractionId, createHardwareSearchTargetId, deriveDeviceFingerprint, deriveWalletId, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hasHardwareRuntimeIdPrefix, hexToBytes, isAllNetworkMethodName, isHardwareInteractionId, isHardwareSearchTargetId, isKnownNonTargetHardwareVendor, padHex64, parseBip32MasterFingerprint, parseHardwareRuntimeId, prepareSolanaOffchainMessageV1, rehydrateConnectorError, requestBleDeviceSelection, requestSaveDeviceBinding, resolveHardwareOperationTarget, resolveSearchTargetReusePolicy, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };
|