@onekeyfe/hwk-adapter-core 1.2.3-alpha.6 → 1.2.3-alpha.8
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-SZZF623R.js → chunk-CQM2P5IG.js} +155 -55
- package/dist/chunk-CQM2P5IG.js.map +1 -0
- package/dist/chunk-DB4JOPZO.mjs +74 -0
- package/dist/chunk-DB4JOPZO.mjs.map +1 -0
- package/dist/{chunk-U63HTLGJ.mjs → chunk-EQYPRCWU.mjs} +48 -12
- package/dist/chunk-EQYPRCWU.mjs.map +1 -0
- package/dist/{chunk-YA4BWFTZ.mjs → chunk-IOFMG7YO.mjs} +155 -55
- package/dist/chunk-IOFMG7YO.mjs.map +1 -0
- package/dist/{chunk-BAGEFFFY.js → chunk-WUIWRX56.js} +49 -13
- package/dist/chunk-WUIWRX56.js.map +1 -0
- package/dist/chunk-YLCHSNXO.js +74 -0
- package/dist/chunk-YLCHSNXO.js.map +1 -0
- package/dist/errors-Cm8XpjmX.d.mts +321 -0
- package/dist/errors-Cm8XpjmX.d.ts +321 -0
- package/dist/errors.d.mts +1 -207
- package/dist/errors.d.ts +1 -207
- package/dist/errors.js +8 -2
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +9 -3
- package/dist/index.d.mts +635 -98
- package/dist/index.d.ts +635 -98
- package/dist/index.js +680 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +671 -73
- package/dist/index.mjs.map +1 -1
- package/dist/{ui-events-Cb7haAeE.d.mts → ui-events-BGUpXxvP.d.mts} +44 -3
- package/dist/{ui-events-Cb7haAeE.d.ts → ui-events-BGUpXxvP.d.ts} +44 -3
- package/dist/ui-events.d.mts +1 -1
- package/dist/ui-events.d.ts +1 -1
- package/dist/ui-events.js +3 -2
- package/dist/ui-events.js.map +1 -1
- package/dist/ui-events.mjs +2 -1
- package/package.json +2 -2
- package/dist/chunk-BAGEFFFY.js.map +0 -1
- package/dist/chunk-SZZF623R.js.map +0 -1
- package/dist/chunk-U63HTLGJ.mjs.map +0 -1
- package/dist/chunk-YA4BWFTZ.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HardwareErrorCode } from './errors.js';
|
|
2
|
-
export { HwkError, IHwkErrorPayload, ORPHAN_ELIGIBLE_ERROR_CODES, createHwkError, enrichErrorMessage } from './errors.js';
|
|
3
|
-
import { U as UiResponseEvent, a as UI_REQUEST, Q as QrDisplayData } from './ui-events-
|
|
4
|
-
export { D as DevicePermissionDeniedReason,
|
|
1
|
+
import { H as HardwareErrorCode, a as HwkErrorOrigin, b as HwkRecoveryHint } from './errors-Cm8XpjmX.js';
|
|
2
|
+
export { c as HwkError, d as HwkRecoveryScope, I as IHwkErrorPayload, e as IOperationMayHaveCompletedParams, O as ORPHAN_ELIGIBLE_ERROR_CODES, f as createHwkError, g as defaultOriginForCode, h as defaultRecoveryForCode, i as enrichErrorMessage, j as isHwkRecoveryHint, o as operationMayHaveCompletedParams } from './errors-Cm8XpjmX.js';
|
|
3
|
+
import { U as UiResponseEvent, a as UiRequestOperationAttribution, b as UI_REQUEST, Q as QrDisplayData, c as UiRequestRegistry, S as SaveDeviceBindingDeclineReason } from './ui-events-BGUpXxvP.js';
|
|
4
|
+
export { D as DevicePermissionDeniedReason, d as DevicePermissionResponse, e as QrResponseData, f as UI_EVENT, g as UI_REQUEST_CANCELLED_TAG, h as UI_REQUEST_DEFAULT_TIMEOUT_MS, i as UI_REQUEST_PREEMPTED_TAG, j as UI_REQUEST_TIMEOUT_TAG, k as UI_RESPONSE } from './ui-events-BGUpXxvP.js';
|
|
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;
|
|
@@ -581,11 +697,21 @@ interface SolSignedTx {
|
|
|
581
697
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
582
698
|
signature: string;
|
|
583
699
|
}
|
|
584
|
-
interface
|
|
700
|
+
interface SolSignMessageBaseParams extends PassphraseStateAware {
|
|
585
701
|
path: string;
|
|
586
702
|
/** Message bytes as hex string (no 0x prefix) */
|
|
587
703
|
message: string;
|
|
588
704
|
}
|
|
705
|
+
interface SolOffchainMessageV1Params {
|
|
706
|
+
/** Finalized Solana off-chain message format. */
|
|
707
|
+
messageVersion: 1;
|
|
708
|
+
/** Complete signer set as 32-byte hex public keys. */
|
|
709
|
+
requiredSigners: string[];
|
|
710
|
+
}
|
|
711
|
+
type SolSignMsgParams = SolSignMessageBaseParams & ({
|
|
712
|
+
messageVersion?: undefined;
|
|
713
|
+
requiredSigners?: undefined;
|
|
714
|
+
} | SolOffchainMessageV1Params);
|
|
589
715
|
interface SolSignature {
|
|
590
716
|
/** Hex-encoded Ed25519 signature (no 0x prefix) */
|
|
591
717
|
signature: string;
|
|
@@ -712,6 +838,12 @@ interface TronSignMsgParams extends PassphraseStateAware {
|
|
|
712
838
|
path: string;
|
|
713
839
|
/** Message hex (no 0x prefix) */
|
|
714
840
|
messageHex: string;
|
|
841
|
+
/**
|
|
842
|
+
* TRON message scheme: 'V1' = legacy signMessage (prefix + 32-byte hash),
|
|
843
|
+
* 'V2' = TIP-191 signMessageV2 (prefix + byte length + message). Adapters
|
|
844
|
+
* that only implement one scheme reject the other with MethodNotSupported.
|
|
845
|
+
*/
|
|
846
|
+
messageType?: 'V1' | 'V2';
|
|
715
847
|
}
|
|
716
848
|
interface TronSignature {
|
|
717
849
|
/** 65-byte hex-encoded signature (no 0x prefix) */
|
|
@@ -723,100 +855,168 @@ interface ITronMethods {
|
|
|
723
855
|
tronSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<TronSignMsgParams>>): Promise<Response<TronSignature>>;
|
|
724
856
|
}
|
|
725
857
|
|
|
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
858
|
/** Events generated by SDK internal detection (not from hardware directly). */
|
|
745
859
|
declare const SDK: {
|
|
746
860
|
readonly DEVICE_STUCK: "device-stuck";
|
|
747
861
|
readonly DEVICE_UNRESPONSIVE: "device-unresponsive";
|
|
748
862
|
readonly DEVICE_RECOVERED: "device-recovered";
|
|
749
863
|
readonly DEVICE_INTERACTION: "device-interaction";
|
|
864
|
+
readonly OPERATION_ENDED: "operation-ended";
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
declare const OPERATION_DEFAULT_TTL_MS = 600000;
|
|
868
|
+
type OperationEndReason = 'explicit' | 'disconnect' | 'timeout' | 'runtime-reset';
|
|
869
|
+
type HardwareOperation = {
|
|
870
|
+
operationId: string;
|
|
871
|
+
connectId: string;
|
|
872
|
+
device: DeviceInfo;
|
|
873
|
+
/**
|
|
874
|
+
* The channel this operation actually runs on. Required on `create` and
|
|
875
|
+
* `rebind` so it comes from whichever adapter picked the channel, rather
|
|
876
|
+
* than being read back off `device`, whose snapshot a combined connector
|
|
877
|
+
* fills with a nominal value.
|
|
878
|
+
*/
|
|
879
|
+
connectionType: ConnectionType;
|
|
880
|
+
connectionKeys: string[];
|
|
881
|
+
createdAt: number;
|
|
882
|
+
lastActiveAt: number;
|
|
883
|
+
};
|
|
884
|
+
type OperationRegistryOptions = {
|
|
885
|
+
vendor: VendorType;
|
|
886
|
+
ttlMs?: number;
|
|
887
|
+
onEnded?: (operation: HardwareOperation, reason: OperationEndReason) => void;
|
|
750
888
|
};
|
|
889
|
+
/** Runtime-only association between a public operation id and one live target. */
|
|
890
|
+
declare class OperationRegistry {
|
|
891
|
+
private readonly _vendor;
|
|
892
|
+
private readonly _ttlMs;
|
|
893
|
+
private readonly _onEnded?;
|
|
894
|
+
private readonly _active;
|
|
895
|
+
private readonly _ended;
|
|
896
|
+
constructor(options: OperationRegistryOptions);
|
|
897
|
+
create(params: {
|
|
898
|
+
searchTargetId: string;
|
|
899
|
+
connectId: string;
|
|
900
|
+
device: DeviceInfo;
|
|
901
|
+
connectionType: ConnectionType;
|
|
902
|
+
connectionKeys?: string[];
|
|
903
|
+
}): HardwareOperation;
|
|
904
|
+
resolve(operationId: string): HardwareOperation;
|
|
905
|
+
/** Keep an operation alive while one device job is actively using it. */
|
|
906
|
+
retain(operationId: string): () => void;
|
|
907
|
+
/** Return active or tombstoned binding data without refreshing its TTL. */
|
|
908
|
+
find(operationId: string): HardwareOperation | undefined;
|
|
909
|
+
findActiveByConnectionKey(connectionKey: string): HardwareOperation | undefined;
|
|
910
|
+
/** Replace the live transport binding after the same target was reconnected. */
|
|
911
|
+
rebind(operationId: string, params: {
|
|
912
|
+
connectId: string;
|
|
913
|
+
device: DeviceInfo;
|
|
914
|
+
connectionType: ConnectionType;
|
|
915
|
+
connectionKeys?: string[];
|
|
916
|
+
}): HardwareOperation;
|
|
917
|
+
end(operationId: string, reason: OperationEndReason): HardwareOperation | undefined;
|
|
918
|
+
endByConnectionKey(connectionKey: string, reason: OperationEndReason, exceptOperationId?: string): void;
|
|
919
|
+
endAll(reason: OperationEndReason, exceptOperationId?: string): void;
|
|
920
|
+
private _createTimer;
|
|
921
|
+
private _rememberEnded;
|
|
922
|
+
}
|
|
751
923
|
|
|
752
924
|
type HardwareMethodMetadata = {
|
|
753
925
|
chain: ChainForFingerprint;
|
|
754
926
|
allNetwork: boolean;
|
|
927
|
+
/** Whether repeating the method after an ambiguous transport failure is safe. */
|
|
928
|
+
replayAfterTransportFailure: 'safe' | 'unsafe';
|
|
755
929
|
};
|
|
756
930
|
declare const HARDWARE_METHOD_CATALOG: {
|
|
757
931
|
readonly evmGetAddress: {
|
|
758
932
|
readonly chain: "evm";
|
|
759
933
|
readonly allNetwork: true;
|
|
934
|
+
readonly replayAfterTransportFailure: "safe";
|
|
760
935
|
};
|
|
761
936
|
readonly evmSignTransaction: {
|
|
762
937
|
readonly chain: "evm";
|
|
763
938
|
readonly allNetwork: false;
|
|
939
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
764
940
|
};
|
|
765
941
|
readonly evmSignMessage: {
|
|
766
942
|
readonly chain: "evm";
|
|
767
943
|
readonly allNetwork: false;
|
|
944
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
768
945
|
};
|
|
769
946
|
readonly evmSignTypedData: {
|
|
770
947
|
readonly chain: "evm";
|
|
771
948
|
readonly allNetwork: false;
|
|
949
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
772
950
|
};
|
|
773
951
|
readonly btcGetAddress: {
|
|
774
952
|
readonly chain: "btc";
|
|
775
953
|
readonly allNetwork: true;
|
|
954
|
+
readonly replayAfterTransportFailure: "safe";
|
|
776
955
|
};
|
|
777
956
|
readonly btcGetPublicKey: {
|
|
778
957
|
readonly chain: "btc";
|
|
779
958
|
readonly allNetwork: true;
|
|
959
|
+
readonly replayAfterTransportFailure: "safe";
|
|
780
960
|
};
|
|
781
961
|
readonly btcSignTransaction: {
|
|
782
962
|
readonly chain: "btc";
|
|
783
963
|
readonly allNetwork: false;
|
|
964
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
784
965
|
};
|
|
785
966
|
readonly btcSignPsbt: {
|
|
786
967
|
readonly chain: "btc";
|
|
787
968
|
readonly allNetwork: false;
|
|
969
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
788
970
|
};
|
|
789
971
|
readonly btcSignMessage: {
|
|
790
972
|
readonly chain: "btc";
|
|
791
973
|
readonly allNetwork: false;
|
|
974
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
792
975
|
};
|
|
793
976
|
readonly btcGetMasterFingerprint: {
|
|
794
977
|
readonly chain: "btc";
|
|
795
978
|
readonly allNetwork: false;
|
|
979
|
+
readonly replayAfterTransportFailure: "safe";
|
|
796
980
|
};
|
|
797
981
|
readonly solGetAddress: {
|
|
798
982
|
readonly chain: "sol";
|
|
799
983
|
readonly allNetwork: true;
|
|
984
|
+
readonly replayAfterTransportFailure: "safe";
|
|
800
985
|
};
|
|
801
986
|
readonly solSignTransaction: {
|
|
802
987
|
readonly chain: "sol";
|
|
803
988
|
readonly allNetwork: false;
|
|
989
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
804
990
|
};
|
|
805
991
|
readonly solSignMessage: {
|
|
806
992
|
readonly chain: "sol";
|
|
807
993
|
readonly allNetwork: false;
|
|
994
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
808
995
|
};
|
|
809
996
|
readonly tronGetAddress: {
|
|
810
997
|
readonly chain: "tron";
|
|
811
998
|
readonly allNetwork: true;
|
|
999
|
+
readonly replayAfterTransportFailure: "safe";
|
|
812
1000
|
};
|
|
813
1001
|
readonly tronSignTransaction: {
|
|
814
1002
|
readonly chain: "tron";
|
|
815
1003
|
readonly allNetwork: false;
|
|
1004
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
816
1005
|
};
|
|
817
1006
|
readonly tronSignMessage: {
|
|
818
1007
|
readonly chain: "tron";
|
|
819
1008
|
readonly allNetwork: false;
|
|
1009
|
+
readonly replayAfterTransportFailure: "unsafe";
|
|
1010
|
+
};
|
|
1011
|
+
readonly zcashGetFullViewingKey: {
|
|
1012
|
+
readonly chain: "zcash";
|
|
1013
|
+
readonly allNetwork: false;
|
|
1014
|
+
readonly replayAfterTransportFailure: "safe";
|
|
1015
|
+
};
|
|
1016
|
+
readonly zcashGetShieldedAddress: {
|
|
1017
|
+
readonly chain: "zcash";
|
|
1018
|
+
readonly allNetwork: false;
|
|
1019
|
+
readonly replayAfterTransportFailure: "safe";
|
|
820
1020
|
};
|
|
821
1021
|
};
|
|
822
1022
|
type HardwareMethodName = keyof typeof HARDWARE_METHOD_CATALOG;
|
|
@@ -825,6 +1025,11 @@ type AllNetworkMethodName = {
|
|
|
825
1025
|
}[HardwareMethodName];
|
|
826
1026
|
declare const ALL_NETWORK_METHOD_NAMES: AllNetworkMethodName[];
|
|
827
1027
|
declare function getHardwareMethodMetadata(method: string): HardwareMethodMetadata | undefined;
|
|
1028
|
+
/**
|
|
1029
|
+
* Conservative replay gate used only after a call may have reached hardware.
|
|
1030
|
+
* Unknown methods and device mutations are unsafe by default.
|
|
1031
|
+
*/
|
|
1032
|
+
declare function canReplayHardwareMethodAfterTransportFailure(method: string): boolean;
|
|
828
1033
|
declare function isAllNetworkMethodName(method: string): method is AllNetworkMethodName;
|
|
829
1034
|
declare function getAllNetworkMethodChain(method: AllNetworkMethodName): ChainForFingerprint;
|
|
830
1035
|
|
|
@@ -843,7 +1048,7 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
|
|
|
843
1048
|
progress: number;
|
|
844
1049
|
};
|
|
845
1050
|
};
|
|
846
|
-
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron';
|
|
1051
|
+
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron' | 'zcash';
|
|
847
1052
|
type TrezorDisplayRotation = 'North' | 'East' | 'South' | 'West';
|
|
848
1053
|
type TrezorSafetyCheckLevel = 'Strict' | 'PromptAlways' | 'PromptTemporarily';
|
|
849
1054
|
type TrezorDeviceSettingsParams = {
|
|
@@ -920,13 +1125,68 @@ type DeviceAuthenticityResult = {
|
|
|
920
1125
|
* that aren't specific to one chain. Vendor-specific options can be added
|
|
921
1126
|
* as typed sub-fields here when a vendor actually needs them.
|
|
922
1127
|
*/
|
|
923
|
-
|
|
1128
|
+
/** Persisted connection hints, never proof of device or wallet identity. */
|
|
1129
|
+
type KnownDeviceConnection = {
|
|
1130
|
+
transport: 'usb' | 'ble';
|
|
1131
|
+
connectId: string;
|
|
1132
|
+
} | {
|
|
1133
|
+
transport: 'qr';
|
|
1134
|
+
};
|
|
1135
|
+
/** Opaque host lookup identifiers. Never forward these to firmware or logs. */
|
|
1136
|
+
type HardwareCallExtra = Readonly<Record<string, string>>;
|
|
1137
|
+
interface IHardwareConnectionContext {
|
|
1138
|
+
knownConnections?: readonly KnownDeviceConnection[];
|
|
1139
|
+
extra?: HardwareCallExtra;
|
|
1140
|
+
/** False makes discovery fail instead of asking the user to select a new endpoint. */
|
|
1141
|
+
allowDeviceSelection?: boolean;
|
|
1142
|
+
}
|
|
1143
|
+
type DeviceSelectionContext = {
|
|
1144
|
+
kind: 'select-device';
|
|
1145
|
+
transport: 'usb';
|
|
1146
|
+
reason: 'multiple-candidates';
|
|
1147
|
+
} | {
|
|
1148
|
+
kind: 'bind-connection';
|
|
1149
|
+
transport: 'ble';
|
|
1150
|
+
reason: 'missing-binding' | 'known-connection-unavailable' | 'manual-rebind';
|
|
1151
|
+
};
|
|
1152
|
+
interface DeviceSelectionRequest extends UiRequestOperationAttribution {
|
|
1153
|
+
devices: DeviceInfo[];
|
|
1154
|
+
requestId: string;
|
|
1155
|
+
context: DeviceSelectionContext;
|
|
1156
|
+
extra?: HardwareCallExtra;
|
|
1157
|
+
/** Repeated snapshots with this requestId update one SDK-owned binding scan. */
|
|
1158
|
+
scanning?: boolean;
|
|
1159
|
+
bindingSessionId?: string;
|
|
1160
|
+
/** A candidate rejected by SDK identity verification in this binding session. */
|
|
1161
|
+
rejectedConnectId?: string;
|
|
1162
|
+
}
|
|
1163
|
+
/** The SDK has verified this endpoint; the host must persist it before acknowledging. */
|
|
1164
|
+
interface SaveDeviceBindingRequest extends UiRequestOperationAttribution {
|
|
1165
|
+
requestId: string;
|
|
1166
|
+
selectionRequestId: string;
|
|
1167
|
+
connection: {
|
|
1168
|
+
transport: 'ble';
|
|
1169
|
+
connectId: string;
|
|
1170
|
+
};
|
|
1171
|
+
identity: Extract<WalletIdentity, {
|
|
1172
|
+
vendor: 'ledger' | 'trezor';
|
|
1173
|
+
}>;
|
|
1174
|
+
extra?: HardwareCallExtra;
|
|
1175
|
+
}
|
|
1176
|
+
type BindBleDeviceParams = Pick<SaveDeviceBindingRequest, 'identity' | 'extra'>;
|
|
1177
|
+
interface DeviceBindingStatus {
|
|
1178
|
+
selectionRequestId: string;
|
|
1179
|
+
status: 'verifying' | 'saved' | 'failed' | 'cancelled';
|
|
1180
|
+
}
|
|
1181
|
+
interface ICommonCallParams extends IHardwareConnectionContext {
|
|
924
1182
|
/**
|
|
925
1183
|
* When the required device app is missing, prompt the user (UI request)
|
|
926
1184
|
* to install it, stream install progress, then retry the operation once.
|
|
927
1185
|
* Off by default — preserves the plain "app not installed" failure.
|
|
928
1186
|
*/
|
|
929
1187
|
autoInstallApp?: boolean;
|
|
1188
|
+
/** Runtime-only id returned by connectDevice(). When present, discovery and fallback are disabled. */
|
|
1189
|
+
operationId?: string;
|
|
930
1190
|
}
|
|
931
1191
|
type NullableCallArg<T> = T | null | undefined;
|
|
932
1192
|
interface IPassphraseCallParams {
|
|
@@ -935,6 +1195,15 @@ interface IPassphraseCallParams {
|
|
|
935
1195
|
}
|
|
936
1196
|
type IHardwareCommonCallParams = ICommonCallParams & IPassphraseCallParams;
|
|
937
1197
|
type IHardwareCallParams<T> = T & IHardwareCommonCallParams;
|
|
1198
|
+
/**
|
|
1199
|
+
* Runtime-only context for device-manager operations. The expected identity
|
|
1200
|
+
* lets an adapter fail closed before a read or mutation is replayed after a
|
|
1201
|
+
* reconnect. It must never be forwarded to vendor firmware.
|
|
1202
|
+
*/
|
|
1203
|
+
interface IDeviceManagerOperationContext extends IHardwareConnectionContext {
|
|
1204
|
+
operationId?: string;
|
|
1205
|
+
expectedDeviceIdentity?: WalletIdentity;
|
|
1206
|
+
}
|
|
938
1207
|
interface AllNetworkAddressParams {
|
|
939
1208
|
network: string;
|
|
940
1209
|
path: string;
|
|
@@ -945,16 +1214,7 @@ interface AllNetworkAddressParams {
|
|
|
945
1214
|
interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
|
|
946
1215
|
bundle: AllNetworkAddressParams[];
|
|
947
1216
|
}
|
|
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
|
-
};
|
|
1217
|
+
type AllNetworkDeviceIdentity = WalletIdentity;
|
|
958
1218
|
type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
959
1219
|
error?: string;
|
|
960
1220
|
code?: HardwareErrorCode | number;
|
|
@@ -962,6 +1222,7 @@ type AllNetworkAddressResponsePayload = Record<string, unknown> & {
|
|
|
962
1222
|
connectId?: string;
|
|
963
1223
|
deviceId?: string;
|
|
964
1224
|
deviceIdentity?: AllNetworkDeviceIdentity;
|
|
1225
|
+
rootFingerprint?: number;
|
|
965
1226
|
chainFingerprint?: string;
|
|
966
1227
|
chainFingerprintChain?: ChainForFingerprint;
|
|
967
1228
|
params?: Record<string, unknown>;
|
|
@@ -1010,46 +1271,50 @@ type UiRequestEvent = {
|
|
|
1010
1271
|
device?: DeviceInfo;
|
|
1011
1272
|
connectId?: string;
|
|
1012
1273
|
type?: string;
|
|
1013
|
-
};
|
|
1274
|
+
} & UiRequestOperationAttribution;
|
|
1014
1275
|
} | {
|
|
1015
1276
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
1016
1277
|
payload: {
|
|
1017
1278
|
device: DeviceInfo;
|
|
1018
|
-
};
|
|
1279
|
+
} & UiRequestOperationAttribution;
|
|
1019
1280
|
} | {
|
|
1020
1281
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1021
1282
|
payload: {
|
|
1022
1283
|
device: DeviceInfo;
|
|
1023
|
-
};
|
|
1284
|
+
} & UiRequestOperationAttribution;
|
|
1024
1285
|
} | {
|
|
1025
1286
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1026
1287
|
payload: {
|
|
1027
1288
|
device: DeviceInfo;
|
|
1028
1289
|
code?: string;
|
|
1029
|
-
};
|
|
1290
|
+
} & UiRequestOperationAttribution;
|
|
1030
1291
|
} | {
|
|
1031
1292
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1032
1293
|
payload: {
|
|
1033
1294
|
device: DeviceInfo;
|
|
1034
1295
|
data: QrDisplayData;
|
|
1035
|
-
};
|
|
1296
|
+
} & UiRequestOperationAttribution;
|
|
1036
1297
|
} | {
|
|
1037
1298
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1038
1299
|
payload: {
|
|
1039
1300
|
device: DeviceInfo;
|
|
1040
|
-
};
|
|
1301
|
+
} & UiRequestOperationAttribution;
|
|
1041
1302
|
} | {
|
|
1042
1303
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
1043
1304
|
payload: {
|
|
1044
1305
|
transportType: TransportType;
|
|
1045
1306
|
connectId?: string;
|
|
1046
1307
|
deviceId?: string;
|
|
1047
|
-
};
|
|
1308
|
+
} & UiRequestOperationAttribution;
|
|
1048
1309
|
} | {
|
|
1049
1310
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1050
|
-
payload:
|
|
1051
|
-
|
|
1052
|
-
|
|
1311
|
+
payload: DeviceSelectionRequest;
|
|
1312
|
+
} | {
|
|
1313
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1314
|
+
payload: SaveDeviceBindingRequest;
|
|
1315
|
+
} | {
|
|
1316
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1317
|
+
payload: DeviceBindingStatus;
|
|
1053
1318
|
} | {
|
|
1054
1319
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
1055
1320
|
payload: {
|
|
@@ -1069,13 +1334,13 @@ type UiRequestEvent = {
|
|
|
1069
1334
|
* isn't recognized.
|
|
1070
1335
|
*/
|
|
1071
1336
|
message: string;
|
|
1072
|
-
};
|
|
1337
|
+
} & UiRequestOperationAttribution;
|
|
1073
1338
|
} | {
|
|
1074
1339
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1075
1340
|
payload: {
|
|
1076
1341
|
vendor: string;
|
|
1077
1342
|
appName: string;
|
|
1078
|
-
};
|
|
1343
|
+
} & UiRequestOperationAttribution;
|
|
1079
1344
|
} | {
|
|
1080
1345
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
1081
1346
|
payload: {
|
|
@@ -1083,10 +1348,10 @@ type UiRequestEvent = {
|
|
|
1083
1348
|
availableMethods: number[];
|
|
1084
1349
|
selectedMethod: number;
|
|
1085
1350
|
nfcData?: string;
|
|
1086
|
-
};
|
|
1351
|
+
} & UiRequestOperationAttribution;
|
|
1087
1352
|
} | {
|
|
1088
1353
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1089
|
-
payload:
|
|
1354
|
+
payload: UiRequestOperationAttribution;
|
|
1090
1355
|
};
|
|
1091
1356
|
type SdkEvent = {
|
|
1092
1357
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1109,6 +1374,12 @@ type SdkEvent = {
|
|
|
1109
1374
|
payload: {
|
|
1110
1375
|
connectId: string;
|
|
1111
1376
|
};
|
|
1377
|
+
} | {
|
|
1378
|
+
type: typeof SDK.OPERATION_ENDED;
|
|
1379
|
+
payload: {
|
|
1380
|
+
operationId: string;
|
|
1381
|
+
reason: OperationEndReason;
|
|
1382
|
+
};
|
|
1112
1383
|
};
|
|
1113
1384
|
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent | HardwareUiEvent;
|
|
1114
1385
|
type DeviceEventListener = (event: HardwareEvent) => void;
|
|
@@ -1119,6 +1390,14 @@ type DeviceEventListener = (event: HardwareEvent) => void;
|
|
|
1119
1390
|
* and the value is the narrowed event object the listener will receive.
|
|
1120
1391
|
*/
|
|
1121
1392
|
interface HardwareEventMap {
|
|
1393
|
+
[UI_REQUEST.DEVICE_BINDING_STATUS]: {
|
|
1394
|
+
type: typeof UI_REQUEST.DEVICE_BINDING_STATUS;
|
|
1395
|
+
payload: DeviceBindingStatus;
|
|
1396
|
+
};
|
|
1397
|
+
[UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING]: {
|
|
1398
|
+
type: typeof UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
|
|
1399
|
+
payload: SaveDeviceBindingRequest;
|
|
1400
|
+
};
|
|
1122
1401
|
'ui-event': HardwareUiEvent;
|
|
1123
1402
|
[DEVICE.CONNECT]: {
|
|
1124
1403
|
type: typeof DEVICE.CONNECT;
|
|
@@ -1159,7 +1438,7 @@ interface HardwareEventMap {
|
|
|
1159
1438
|
device?: DeviceInfo;
|
|
1160
1439
|
connectId?: string;
|
|
1161
1440
|
type?: string;
|
|
1162
|
-
};
|
|
1441
|
+
} & UiRequestOperationAttribution;
|
|
1163
1442
|
};
|
|
1164
1443
|
[UI_REQUEST.REQUEST_PASSPHRASE]: {
|
|
1165
1444
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE;
|
|
@@ -1168,33 +1447,33 @@ interface HardwareEventMap {
|
|
|
1168
1447
|
connectId?: string;
|
|
1169
1448
|
passphraseState?: string;
|
|
1170
1449
|
useEmptyPassphrase?: boolean;
|
|
1171
|
-
};
|
|
1450
|
+
} & UiRequestOperationAttribution;
|
|
1172
1451
|
};
|
|
1173
1452
|
[UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE]: {
|
|
1174
1453
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
1175
1454
|
payload: {
|
|
1176
1455
|
device: DeviceInfo;
|
|
1177
|
-
};
|
|
1456
|
+
} & UiRequestOperationAttribution;
|
|
1178
1457
|
};
|
|
1179
1458
|
[UI_REQUEST.REQUEST_BUTTON]: {
|
|
1180
1459
|
type: typeof UI_REQUEST.REQUEST_BUTTON;
|
|
1181
1460
|
payload: {
|
|
1182
1461
|
device: DeviceInfo;
|
|
1183
1462
|
code?: string;
|
|
1184
|
-
};
|
|
1463
|
+
} & UiRequestOperationAttribution;
|
|
1185
1464
|
};
|
|
1186
1465
|
[UI_REQUEST.REQUEST_QR_DISPLAY]: {
|
|
1187
1466
|
type: typeof UI_REQUEST.REQUEST_QR_DISPLAY;
|
|
1188
1467
|
payload: {
|
|
1189
1468
|
device: DeviceInfo;
|
|
1190
1469
|
data: QrDisplayData;
|
|
1191
|
-
};
|
|
1470
|
+
} & UiRequestOperationAttribution;
|
|
1192
1471
|
};
|
|
1193
1472
|
[UI_REQUEST.REQUEST_QR_SCAN]: {
|
|
1194
1473
|
type: typeof UI_REQUEST.REQUEST_QR_SCAN;
|
|
1195
1474
|
payload: {
|
|
1196
1475
|
device: DeviceInfo;
|
|
1197
|
-
};
|
|
1476
|
+
} & UiRequestOperationAttribution;
|
|
1198
1477
|
};
|
|
1199
1478
|
[UI_REQUEST.REQUEST_DEVICE_PERMISSION]: {
|
|
1200
1479
|
type: typeof UI_REQUEST.REQUEST_DEVICE_PERMISSION;
|
|
@@ -1202,13 +1481,11 @@ interface HardwareEventMap {
|
|
|
1202
1481
|
transportType: TransportType;
|
|
1203
1482
|
connectId?: string;
|
|
1204
1483
|
deviceId?: string;
|
|
1205
|
-
};
|
|
1484
|
+
} & UiRequestOperationAttribution;
|
|
1206
1485
|
};
|
|
1207
1486
|
[UI_REQUEST.REQUEST_SELECT_DEVICE]: {
|
|
1208
1487
|
type: typeof UI_REQUEST.REQUEST_SELECT_DEVICE;
|
|
1209
|
-
payload:
|
|
1210
|
-
devices: DeviceInfo[];
|
|
1211
|
-
};
|
|
1488
|
+
payload: DeviceSelectionRequest;
|
|
1212
1489
|
};
|
|
1213
1490
|
[UI_REQUEST.REQUEST_DEVICE_CONNECT]: {
|
|
1214
1491
|
type: typeof UI_REQUEST.REQUEST_DEVICE_CONNECT;
|
|
@@ -1216,7 +1493,7 @@ interface HardwareEventMap {
|
|
|
1216
1493
|
vendor: string;
|
|
1217
1494
|
reason: string;
|
|
1218
1495
|
message: string;
|
|
1219
|
-
};
|
|
1496
|
+
} & UiRequestOperationAttribution;
|
|
1220
1497
|
};
|
|
1221
1498
|
[UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM]: {
|
|
1222
1499
|
type: typeof UI_REQUEST.REQUEST_BTC_HIGH_INDEX_CONFIRM;
|
|
@@ -1224,14 +1501,14 @@ interface HardwareEventMap {
|
|
|
1224
1501
|
vendor: string;
|
|
1225
1502
|
path: string;
|
|
1226
1503
|
accountIndex: number;
|
|
1227
|
-
};
|
|
1504
|
+
} & UiRequestOperationAttribution;
|
|
1228
1505
|
};
|
|
1229
1506
|
[UI_REQUEST.REQUEST_INSTALL_APP]: {
|
|
1230
1507
|
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
1231
1508
|
payload: {
|
|
1232
1509
|
vendor: string;
|
|
1233
1510
|
appName: string;
|
|
1234
|
-
};
|
|
1511
|
+
} & UiRequestOperationAttribution;
|
|
1235
1512
|
};
|
|
1236
1513
|
[UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
|
|
1237
1514
|
type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
|
|
@@ -1240,11 +1517,11 @@ interface HardwareEventMap {
|
|
|
1240
1517
|
availableMethods: number[];
|
|
1241
1518
|
selectedMethod: number;
|
|
1242
1519
|
nfcData?: string;
|
|
1243
|
-
};
|
|
1520
|
+
} & UiRequestOperationAttribution;
|
|
1244
1521
|
};
|
|
1245
1522
|
[UI_REQUEST.CLOSE_UI_WINDOW]: {
|
|
1246
1523
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
1247
|
-
payload:
|
|
1524
|
+
payload: UiRequestOperationAttribution;
|
|
1248
1525
|
};
|
|
1249
1526
|
[SDK.DEVICE_INTERACTION]: {
|
|
1250
1527
|
type: typeof SDK.DEVICE_INTERACTION;
|
|
@@ -1271,16 +1548,23 @@ interface HardwareEventMap {
|
|
|
1271
1548
|
connectId: string;
|
|
1272
1549
|
};
|
|
1273
1550
|
};
|
|
1551
|
+
[SDK.OPERATION_ENDED]: {
|
|
1552
|
+
type: typeof SDK.OPERATION_ENDED;
|
|
1553
|
+
payload: {
|
|
1554
|
+
operationId: string;
|
|
1555
|
+
reason: OperationEndReason;
|
|
1556
|
+
};
|
|
1557
|
+
};
|
|
1274
1558
|
}
|
|
1275
1559
|
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>>>;
|
|
1560
|
+
getFeatures?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1561
|
+
deviceSettings?(connectId: string, params: TrezorDeviceSettingsParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1562
|
+
setBrightness?(connectId: string, params?: TrezorBrightnessParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1563
|
+
changePin?(connectId: string, params?: TrezorChangePinParams, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1564
|
+
wipeDevice?(connectId: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1281
1565
|
authenticateDevice?(connectId: string, params: {
|
|
1282
1566
|
challenge: string;
|
|
1283
|
-
}): Promise<Response<Record<string, unknown>>>;
|
|
1567
|
+
}, operationContext?: IDeviceManagerOperationContext): Promise<Response<Record<string, unknown>>>;
|
|
1284
1568
|
}
|
|
1285
1569
|
interface IWalletStateMethods {
|
|
1286
1570
|
/**
|
|
@@ -1307,20 +1591,45 @@ interface IWalletStateMethods {
|
|
|
1307
1591
|
* Optional: vendors without host-managed passphrase sessions (Ledger) omit
|
|
1308
1592
|
* it. Implemented by `TrezorAdapter`.
|
|
1309
1593
|
*/
|
|
1310
|
-
getPassphraseState?(connectId: string, passphraseState?: string): Promise<Response<string | null>>;
|
|
1594
|
+
getPassphraseState?(connectId: string, passphraseState?: string, operationContext?: IDeviceManagerOperationContext): Promise<Response<string | null>>;
|
|
1311
1595
|
}
|
|
1596
|
+
/**
|
|
1597
|
+
* What a `cancel()` actually reaches on this vendor.
|
|
1598
|
+
*
|
|
1599
|
+
* - `stops-waiting`: the caller stops waiting and the adapter drops the
|
|
1600
|
+
* response, but a confirmation screen already on the device stays up until
|
|
1601
|
+
* the user answers it or the device times out.
|
|
1602
|
+
* - `interrupts-device`: the command on the wire is genuinely withdrawn.
|
|
1603
|
+
*
|
|
1604
|
+
* No vendor here reports `interrupts-device`: none of the three can retract a
|
|
1605
|
+
* prompt the device is already showing. The distinction exists so a host can
|
|
1606
|
+
* say "we stopped waiting, answer or reject on the device" instead of claiming
|
|
1607
|
+
* the operation was cancelled.
|
|
1608
|
+
*/
|
|
1609
|
+
type CancelCapability = 'interrupts-device' | 'stops-waiting';
|
|
1312
1610
|
interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, ISolMethods, ITronMethods, IDeviceManagerMethods, IWalletStateMethods {
|
|
1313
1611
|
readonly vendor: string;
|
|
1314
1612
|
readonly activeTransport: TransportType | null;
|
|
1613
|
+
/** What `cancel()` reaches on this vendor. Declared, never inferred. */
|
|
1614
|
+
readonly cancelCapability: CancelCapability;
|
|
1315
1615
|
init(config: TConfig): Promise<void>;
|
|
1316
1616
|
dispose(): Promise<void>;
|
|
1317
1617
|
getAvailableTransports(): TransportType[];
|
|
1318
1618
|
switchTransport(type: TransportType): Promise<void>;
|
|
1319
1619
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
1320
|
-
|
|
1321
|
-
|
|
1620
|
+
/** Discover selectable hardware entries without claiming identified devices or wallets. */
|
|
1621
|
+
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
1622
|
+
/** @deprecated Use searchDeviceTargets(). */
|
|
1623
|
+
listConnectionTargets(options?: SearchDevicesOptions): Promise<ConnectionTarget[]>;
|
|
1624
|
+
/** Connect or logically bind a selected search result and return a runtime-only operation id. */
|
|
1625
|
+
connectDevice(searchTargetId: string): Promise<Response<string>>;
|
|
1626
|
+
/** Explicit Device Manager binding: verify the existing identity before replacing its BLE locator. */
|
|
1627
|
+
bindBleDevice?(params: BindBleDeviceParams): Promise<Response<string>>;
|
|
1628
|
+
/** Resolve operation-first routing/selection and pin it. The caller must verify wallet identity before business calls. */
|
|
1629
|
+
acquireOperation?(connectId: string, context: IHardwareConnectionContext): Promise<Response<string>>;
|
|
1630
|
+
/** Release an operation owned by the caller. Disconnect events end matching operations automatically. */
|
|
1631
|
+
releaseOperation(operationId: string): Promise<void>;
|
|
1322
1632
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
1323
|
-
getSupportedChains(): ChainCapability[];
|
|
1324
1633
|
/** Abort the in-flight call. Omit connectId to cancel whatever is active. */
|
|
1325
1634
|
cancel(connectId?: string): void;
|
|
1326
1635
|
allNetworkGetAddress(connectId: string, deviceId: string, params: AllNetworkGetAddressParams): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
@@ -1357,6 +1666,14 @@ interface SearchDevicesOptions {
|
|
|
1357
1666
|
* was discovered first.
|
|
1358
1667
|
*/
|
|
1359
1668
|
waitForAllTransports?: boolean;
|
|
1669
|
+
/**
|
|
1670
|
+
* Restrict discovery to one transport. A non-enumerable channel may return
|
|
1671
|
+
* a virtual connection target (for example Keystone QR), but discovery must
|
|
1672
|
+
* not start a wallet protocol or account-export interaction. The target is
|
|
1673
|
+
* resolved by the following `connectDevice()` call. Omit to scan everything
|
|
1674
|
+
* available.
|
|
1675
|
+
*/
|
|
1676
|
+
transportType?: ConnectionType;
|
|
1360
1677
|
}
|
|
1361
1678
|
|
|
1362
1679
|
interface EvmGetAddressParams extends PassphraseStateAware {
|
|
@@ -1480,6 +1797,14 @@ interface EvmSignTypedDataFull extends PassphraseStateAware {
|
|
|
1480
1797
|
primaryType: string;
|
|
1481
1798
|
message: Record<string, unknown>;
|
|
1482
1799
|
};
|
|
1800
|
+
/**
|
|
1801
|
+
* The dApp's original EIP-712 JSON, byte for byte. Vendors that hand the
|
|
1802
|
+
* device a serialized payload (Keystone) must prefer this over
|
|
1803
|
+
* re-stringifying `data`: a JSON round trip rewrites integer literals wider
|
|
1804
|
+
* than 2^53 and exponent forms, so the device would display and sign
|
|
1805
|
+
* something the dApp never sent.
|
|
1806
|
+
*/
|
|
1807
|
+
dataJson?: string;
|
|
1483
1808
|
metamaskV4Compat?: boolean;
|
|
1484
1809
|
showMessageHash?: boolean;
|
|
1485
1810
|
/**
|
|
@@ -1518,6 +1843,33 @@ interface IEvmMethods {
|
|
|
1518
1843
|
evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
|
|
1519
1844
|
}
|
|
1520
1845
|
|
|
1846
|
+
/** Which `GET_VK` encoding the Ledger Zcash app should return. */
|
|
1847
|
+
type ZcashFullViewingKeyMode = 'ufvk' | 'orchardFvk';
|
|
1848
|
+
interface ZcashGetFullViewingKeyParams extends PassphraseStateAware {
|
|
1849
|
+
/** BIP44 account path `m/44'/133'/a'` (any deeper transparent path is accepted; only the account level is used). */
|
|
1850
|
+
path: string;
|
|
1851
|
+
/** Default `ufvk`. */
|
|
1852
|
+
mode?: ZcashFullViewingKeyMode;
|
|
1853
|
+
}
|
|
1854
|
+
interface ZcashFullViewingKey {
|
|
1855
|
+
path: string;
|
|
1856
|
+
mode: ZcashFullViewingKeyMode;
|
|
1857
|
+
/** ZIP-316 bech32m UFVK string (mode `ufvk`). */
|
|
1858
|
+
ufvk?: string;
|
|
1859
|
+
/** 96-byte raw Orchard FVK as hex (mode `orchardFvk`). */
|
|
1860
|
+
orchardFvk?: string;
|
|
1861
|
+
}
|
|
1862
|
+
interface ZcashGetShieldedAddressParams extends PassphraseStateAware {
|
|
1863
|
+
/** Full 5-level transparent path `m/44'/133'/a'/0/i`; the Orchard path is derived from it. */
|
|
1864
|
+
path: string;
|
|
1865
|
+
showOnDevice?: boolean;
|
|
1866
|
+
}
|
|
1867
|
+
interface ZcashShieldedAddress {
|
|
1868
|
+
/** Unified address with a single Orchard receiver. */
|
|
1869
|
+
address: string;
|
|
1870
|
+
path: string;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1521
1873
|
/**
|
|
1522
1874
|
* Low-level device descriptor from Transport layer.
|
|
1523
1875
|
* Represents a physical device detected by USB/BLE scanning.
|
|
@@ -1563,14 +1915,18 @@ interface DeviceDisconnectEvent {
|
|
|
1563
1915
|
type DeviceChangeEvent = DeviceConnectEvent | DeviceDisconnectEvent;
|
|
1564
1916
|
|
|
1565
1917
|
/**
|
|
1566
|
-
*
|
|
1567
|
-
*
|
|
1568
|
-
*
|
|
1569
|
-
*
|
|
1570
|
-
*
|
|
1571
|
-
*
|
|
1572
|
-
*
|
|
1573
|
-
*
|
|
1918
|
+
* Serializes every device call and gives callers one handle to cancel them.
|
|
1919
|
+
*
|
|
1920
|
+
* Ordering is the lesser half of the job: calls already await each other, and
|
|
1921
|
+
* nothing in the app issues two device operations at once. What this buys is
|
|
1922
|
+
* the rest — an AbortController per job so a cancel has something to pull, a
|
|
1923
|
+
* busy check so a double-submit is refused rather than queued, and generation
|
|
1924
|
+
* tracking so a job that was queued before a teardown does not start after it.
|
|
1925
|
+
* Those races exist in a perfectly sequential caller, because cleanup is async.
|
|
1926
|
+
*
|
|
1927
|
+
* The queue never decides whether to interrupt or ask the user; the caller owns
|
|
1928
|
+
* that. `getActiveJob()` reads synchronously so a UI handler can look, decide,
|
|
1929
|
+
* and submit in one turn without racing an in-flight enqueue.
|
|
1574
1930
|
*/
|
|
1575
1931
|
interface JobOptions {
|
|
1576
1932
|
label?: string;
|
|
@@ -1582,10 +1938,15 @@ interface ActiveJobInfo {
|
|
|
1582
1938
|
label?: string;
|
|
1583
1939
|
startedAt: number;
|
|
1584
1940
|
}
|
|
1941
|
+
interface CancelScopeHandle {
|
|
1942
|
+
signal: AbortSignal;
|
|
1943
|
+
release: () => void;
|
|
1944
|
+
}
|
|
1585
1945
|
declare class DeviceJobQueue {
|
|
1586
1946
|
private _tail;
|
|
1587
1947
|
private _active;
|
|
1588
1948
|
private readonly _jobs;
|
|
1949
|
+
private readonly _cancelScopes;
|
|
1589
1950
|
/** Incremented on clear() so queued-but-not-yet-running jobs detect invalidation. */
|
|
1590
1951
|
private _generation;
|
|
1591
1952
|
private readonly _generationCancelReasons;
|
|
@@ -1594,21 +1955,77 @@ declare class DeviceJobQueue {
|
|
|
1594
1955
|
* `deviceId` is a label only — used by inspection / cancellation routing.
|
|
1595
1956
|
*/
|
|
1596
1957
|
enqueue<T>(deviceId: string, job: (signal: AbortSignal) => Promise<T>, options?: JobOptions): Promise<T>;
|
|
1597
|
-
/**
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1958
|
+
/**
|
|
1959
|
+
* Open a cancellation scope that outlives the individual jobs under it.
|
|
1960
|
+
*
|
|
1961
|
+
* A bundle (all-network) does not enqueue itself — it enqueues one job per
|
|
1962
|
+
* item. Between two items the queue is empty, so a cancel landing in that
|
|
1963
|
+
* gap finds nothing to abort and the next item goes to the device anyway.
|
|
1964
|
+
* The scope holds the cancel across those gaps; the bundle checks its
|
|
1965
|
+
* signal before each item. Callers must `release()` when the bundle ends.
|
|
1966
|
+
*/
|
|
1967
|
+
createCancelScope(deviceId: string): CancelScopeHandle;
|
|
1968
|
+
/**
|
|
1969
|
+
* Cancel the running job. `reason` becomes signal.reason.
|
|
1970
|
+
*
|
|
1971
|
+
* No caller today: every adapter cancel wants the queued work invalidated
|
|
1972
|
+
* too and uses `cancelActiveAndPending`. Kept for a connector layer that
|
|
1973
|
+
* needs to stop only what is on the wire and leave the queue behind it.
|
|
1974
|
+
*/
|
|
1975
|
+
cancelActive(deviceId?: string, reason?: Error): boolean;
|
|
1976
|
+
/**
|
|
1977
|
+
* Cancel the active job and invalidate queued jobs that have not started.
|
|
1978
|
+
*
|
|
1979
|
+
* Only `undefined` means "everything". An empty string is a queue key that
|
|
1980
|
+
* derived to nothing, so it matches nothing and reports `false` rather than
|
|
1981
|
+
* silently tearing the whole queue down.
|
|
1982
|
+
*
|
|
1983
|
+
* Returns what the cancel actually reached, not whether it was accepted.
|
|
1984
|
+
*/
|
|
1604
1985
|
cancelActiveAndPending(deviceId?: string, reason?: Error): boolean;
|
|
1605
1986
|
/** Get info about the currently active job, or null if idle. */
|
|
1606
1987
|
getActiveJob(deviceId?: string): ActiveJobInfo | null;
|
|
1607
|
-
/** True if any job is currently running. */
|
|
1608
|
-
isBusy(): boolean;
|
|
1609
1988
|
clear(reason?: Error): void;
|
|
1610
1989
|
}
|
|
1611
1990
|
|
|
1991
|
+
declare const HARDWARE_RUNTIME_ID_PREFIX = "hwk:runtime";
|
|
1992
|
+
/**
|
|
1993
|
+
* Scopes a runtime id can name. Each is a different lifetime, and none of them
|
|
1994
|
+
* nests cleanly inside another:
|
|
1995
|
+
*
|
|
1996
|
+
* - `search-target` — one device in one discovery snapshot. Dies on the next
|
|
1997
|
+
* search of the same kind, so a stale pick is refused rather than silently
|
|
1998
|
+
* resolved against a different unit.
|
|
1999
|
+
* - `link` — one open transport. Outlives the snapshot that produced it.
|
|
2000
|
+
* - `operation` — one business operation. Outlives the link: `rebind()` swaps
|
|
2001
|
+
* the transport underneath while the id stays the same.
|
|
2002
|
+
*/
|
|
2003
|
+
type HardwareRuntimeIdKind = 'operation' | 'search-target' | 'link';
|
|
2004
|
+
type HardwareRuntimeId = {
|
|
2005
|
+
kind: HardwareRuntimeIdKind;
|
|
2006
|
+
vendor: VendorType;
|
|
2007
|
+
};
|
|
2008
|
+
/** Runtime ids are opaque and must never be persisted as device identity. */
|
|
2009
|
+
declare function createHardwareOperationId(vendor: VendorType): string;
|
|
2010
|
+
/** Search targets are valid only for the adapter's current discovery snapshot. */
|
|
2011
|
+
declare function createHardwareSearchTargetId(vendor: VendorType): string;
|
|
2012
|
+
declare function createHardwareLinkId(vendor: VendorType): string;
|
|
2013
|
+
declare function hasHardwareRuntimeIdPrefix(value: unknown): value is string;
|
|
2014
|
+
declare function parseHardwareRuntimeId(value: unknown): HardwareRuntimeId | undefined;
|
|
2015
|
+
declare function isHardwareOperationId(value: unknown): value is string;
|
|
2016
|
+
|
|
2017
|
+
interface HardwareOperationTarget {
|
|
2018
|
+
/** Effective target accepted by existing adapter/connector call paths. */
|
|
2019
|
+
targetId: string | undefined;
|
|
2020
|
+
/** Present when this operation is pinned to a live operation. */
|
|
2021
|
+
operationId: string | undefined;
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* Normalizes the transitional positional operation id and the canonical
|
|
2025
|
+
* common-params field. All vendors must reject conflicting bindings.
|
|
2026
|
+
*/
|
|
2027
|
+
declare function resolveHardwareOperationTarget(positionalTargetId: string | null | undefined, commonOperationId: string | null | undefined, expectedVendor?: VendorType): Response<HardwareOperationTarget>;
|
|
2028
|
+
|
|
1612
2029
|
/**
|
|
1613
2030
|
* Minimal typed event emitter using Map<string, Set<listener>>.
|
|
1614
2031
|
* Each adapter uses this for device events (connect, disconnect, pin, etc.).
|
|
@@ -1635,6 +2052,104 @@ declare class TypedEventEmitter<TMap extends Record<string, any> = Record<string
|
|
|
1635
2052
|
listenerCount(event: string): number;
|
|
1636
2053
|
}
|
|
1637
2054
|
|
|
2055
|
+
/** Serializable BLE transport data shared by Electron main and renderer runtimes. */
|
|
2056
|
+
interface ElectronBleDeviceInfo {
|
|
2057
|
+
id: string;
|
|
2058
|
+
name?: string;
|
|
2059
|
+
rssi?: number;
|
|
2060
|
+
advertisedServiceUuids?: string[];
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* How the main process recognizes one vendor's peripherals. Everything here
|
|
2064
|
+
* crosses IPC, so it is data rather than predicates: the handler owns no
|
|
2065
|
+
* vendor knowledge of its own. A peripheral matches when it advertises one of
|
|
2066
|
+
* `serviceUuids`, or when its local name matches every entry in
|
|
2067
|
+
* `namePatterns` (each is a case-insensitive regular expression source, so a
|
|
2068
|
+
* single entry can carry alternations).
|
|
2069
|
+
*/
|
|
2070
|
+
interface ElectronBleMatch {
|
|
2071
|
+
serviceUuids?: string[];
|
|
2072
|
+
namePatterns?: string[];
|
|
2073
|
+
}
|
|
2074
|
+
interface ElectronBleScanOptions {
|
|
2075
|
+
/** Opaque partition key: results and connected devices never mix across it. */
|
|
2076
|
+
vendor?: string;
|
|
2077
|
+
match?: ElectronBleMatch;
|
|
2078
|
+
/** @deprecated Superseded by `match.serviceUuids`. */
|
|
2079
|
+
serviceUuids?: string[];
|
|
2080
|
+
durationMs?: number;
|
|
2081
|
+
}
|
|
2082
|
+
/** GATT profile plus the write framing this vendor's firmware expects. */
|
|
2083
|
+
interface ElectronBleConnectOptions {
|
|
2084
|
+
vendor: string;
|
|
2085
|
+
serviceUuid: string;
|
|
2086
|
+
writeUuid: string;
|
|
2087
|
+
notifyUuid: string;
|
|
2088
|
+
/**
|
|
2089
|
+
* `padded` splits into fixed `chunkSize` packets, zero-filling the last one
|
|
2090
|
+
* — Trezor firmware silently drops a short packet. `raw` writes the buffer
|
|
2091
|
+
* as given, for framing that carries its own length (Ledger).
|
|
2092
|
+
*/
|
|
2093
|
+
write?: {
|
|
2094
|
+
mode: 'padded' | 'raw';
|
|
2095
|
+
chunkSize?: number;
|
|
2096
|
+
chunkDelayMs?: number;
|
|
2097
|
+
maxLength?: number;
|
|
2098
|
+
};
|
|
2099
|
+
}
|
|
2100
|
+
/** Native code handles GATT only; framing, identity checks and wallet operations stay in the SDK. */
|
|
2101
|
+
interface ElectronBleApi {
|
|
2102
|
+
scan(options?: ElectronBleScanOptions): Promise<ElectronBleDeviceInfo[]>;
|
|
2103
|
+
stopScan(): Promise<void>;
|
|
2104
|
+
connect(id: string, options?: ElectronBleConnectOptions): Promise<{
|
|
2105
|
+
id: string;
|
|
2106
|
+
name?: string;
|
|
2107
|
+
}>;
|
|
2108
|
+
disconnect(id: string): Promise<void>;
|
|
2109
|
+
subscribe(id: string): Promise<void>;
|
|
2110
|
+
unsubscribe(id: string): Promise<void>;
|
|
2111
|
+
write(id: string, hexData: string): Promise<void>;
|
|
2112
|
+
checkAvailability(): Promise<{
|
|
2113
|
+
available: boolean;
|
|
2114
|
+
state: string;
|
|
2115
|
+
initialized: boolean;
|
|
2116
|
+
}>;
|
|
2117
|
+
getDevice(id: string): Promise<ElectronBleDeviceInfo | null>;
|
|
2118
|
+
onNotification(handler: (id: string, hexData: string) => void): () => void;
|
|
2119
|
+
onDeviceDisconnected(handler: (id: string) => void): () => void;
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
/**
|
|
2123
|
+
* The outcome of asking the host to persist a verified binding. A refusal is
|
|
2124
|
+
* reported, never thrown: by this point the SDK has already verified that the
|
|
2125
|
+
* connected wallet is the one the operation expects, so anything the host says
|
|
2126
|
+
* back is about the host's own records. Losing the binding is worth a warning
|
|
2127
|
+
* and a retry next time; it is not a reason to fail work the user asked for.
|
|
2128
|
+
*/
|
|
2129
|
+
type SaveDeviceBindingOutcome = {
|
|
2130
|
+
saved: true;
|
|
2131
|
+
} | {
|
|
2132
|
+
saved: false;
|
|
2133
|
+
reason: SaveDeviceBindingDeclineReason;
|
|
2134
|
+
};
|
|
2135
|
+
/** Persist a verified binding through the host. Only a user abort throws. */
|
|
2136
|
+
declare function requestSaveDeviceBinding(emitter: TypedEventEmitter<HardwareEventMap>, registry: UiRequestRegistry, binding: Omit<SaveDeviceBindingRequest, 'requestId'>, signal?: AbortSignal): Promise<SaveDeviceBindingOutcome>;
|
|
2137
|
+
|
|
2138
|
+
/** Discovery and selection share one owner; never connect until the last scan has drained. */
|
|
2139
|
+
declare function requestBleDeviceSelection({ emitter, registry, request, scan, signal, allowUsbFallback, pollIntervalMs, }: {
|
|
2140
|
+
emitter: TypedEventEmitter<HardwareEventMap>;
|
|
2141
|
+
registry: UiRequestRegistry;
|
|
2142
|
+
request: Omit<DeviceSelectionRequest, 'requestId' | 'scanning'>;
|
|
2143
|
+
scan: () => Promise<DeviceInfo[]>;
|
|
2144
|
+
signal: AbortSignal;
|
|
2145
|
+
/** The adapter must verify a returned USB candidate before dispatching any business call. */
|
|
2146
|
+
allowUsbFallback?: boolean;
|
|
2147
|
+
pollIntervalMs?: number;
|
|
2148
|
+
}): Promise<{
|
|
2149
|
+
device: DeviceInfo;
|
|
2150
|
+
requestId: string;
|
|
2151
|
+
}>;
|
|
2152
|
+
|
|
1638
2153
|
/**
|
|
1639
2154
|
* Compare two semver strings (e.g. "2.1.0" vs "2.3.1").
|
|
1640
2155
|
* Returns -1 if a < b, 0 if equal, 1 if a > b.
|
|
@@ -1655,7 +2170,18 @@ declare function hexToBytes(hex: string): Uint8Array;
|
|
|
1655
2170
|
/** Convert a Uint8Array to a hex string (no 0x prefix). */
|
|
1656
2171
|
declare function bytesToHex(bytes: Uint8Array): string;
|
|
1657
2172
|
|
|
1658
|
-
|
|
2173
|
+
interface PrepareSolanaOffchainMessageV1Params {
|
|
2174
|
+
message: Uint8Array;
|
|
2175
|
+
requiredSigners: readonly string[];
|
|
2176
|
+
}
|
|
2177
|
+
interface PreparedSolanaOffchainMessageV1 {
|
|
2178
|
+
messageText: string;
|
|
2179
|
+
requiredSigners: string[];
|
|
2180
|
+
serializedMessage: Uint8Array;
|
|
2181
|
+
}
|
|
2182
|
+
declare function prepareSolanaOffchainMessageV1({ message, requiredSigners, }: PrepareSolanaOffchainMessageV1Params): PreparedSolanaOffchainMessageV1;
|
|
2183
|
+
|
|
2184
|
+
type DetectableHardwareVendor = 'onekey' | 'trezor' | 'ledger' | 'keystone';
|
|
1659
2185
|
type HardwareDeviceIdentityInput = {
|
|
1660
2186
|
name?: string | null;
|
|
1661
2187
|
localName?: string | null;
|
|
@@ -1718,8 +2244,19 @@ type RunAllNetworkGetAddressOptions = {
|
|
|
1718
2244
|
buildTopLevelFailure?: (response: AllNetworkAddressResponse, context: AllNetworkResponseContext) => Response<AllNetworkAddressResponse[]>;
|
|
1719
2245
|
};
|
|
1720
2246
|
declare function runAllNetworkGetAddress({ connectId, deviceId, params, getMethodChain, normalizeItem, buildUnsupportedNetworkResponse, callItem, attachIdentity, shouldAbortBundle, buildTopLevelFailure, }: RunAllNetworkGetAddressOptions): Promise<Response<AllNetworkAddressResponse[]>>;
|
|
2247
|
+
/**
|
|
2248
|
+
* User said "no": an SDK-dialog cancel and an on-device reject both end the
|
|
2249
|
+
* bundle. Asking the device for the next chain after a refusal is a prompt the
|
|
2250
|
+
* user already answered.
|
|
2251
|
+
*/
|
|
2252
|
+
declare function isUserRefusal(code: HardwareErrorCode | number | undefined): boolean;
|
|
2253
|
+
/**
|
|
2254
|
+
* The session the bundle runs on is gone, so the remaining items have nothing
|
|
2255
|
+
* to run against.
|
|
2256
|
+
*/
|
|
2257
|
+
declare function isConnectionLost(code: HardwareErrorCode | number | undefined): boolean;
|
|
1721
2258
|
declare function buildUnsupportedMethodResponse(item: AllNetworkAddressParams): AllNetworkAddressResponse;
|
|
1722
2259
|
|
|
1723
2260
|
declare const DEVICE_CONNECT_RETRY_DELAY_MS = 1000;
|
|
1724
2261
|
|
|
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 };
|
|
2262
|
+
export { ALL_NETWORK_METHOD_NAMES, type ActiveJobInfo, type AllNetworkAddressParams, type AllNetworkAddressResponse, type AllNetworkAddressResponsePayload, type AllNetworkAttachIdentityContext, type AllNetworkCallItemContext, type AllNetworkDeviceIdentity, type AllNetworkGetAddressParams, type AllNetworkMethodName, type AllNetworkResponseContext, type BindBleDeviceParams, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPaymentRequest, type BtcPaymentRequestMemo, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type CancelCapability, type CancelScopeHandle, type ChainCapability, type ChainForFingerprint, type 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 ElectronBleMatch, type ElectronBleScanOptions, type EvmAddress, type EvmEthereumDefinitions, type EvmGetAddressParams, type EvmPaymentRequest, type EvmPaymentRequestMemo, type EvmSignMsgParams, type EvmSignTxLedgerParams, type EvmSignTxParams, type EvmSignTxTrezorParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HARDWARE_METHOD_CATALOG, HARDWARE_RUNTIME_ID_PREFIX, type HardwareCallExtra, type HardwareDeviceIdentityInput, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareMethodMetadata, type HardwareMethodName, type HardwareOperation, type HardwareOperationTarget, type HardwareRuntimeId, type HardwareRuntimeIdKind, type HardwareUiEvent, HwkErrorOrigin, HwkRecoveryHint, type IBtcMethods, type ICommonCallParams, type IConnector, type IDeviceManagerMethods, type IDeviceManagerOperationContext, type IEvmMethods, type IHardwareBridge, type IHardwareCallParams, type IHardwareCommonCallParams, type IHardwareConnectionContext, type IHardwareWallet, type IPassphraseCallParams, type ISolMethods, type ITronMethods, type IWalletStateMethods, type JobOptions, type KnownDeviceConnection, type NullableCallArg, OPERATION_DEFAULT_TTL_MS, type OperationEndReason, OperationRegistry, type PassphraseResponse, type PassphraseStateAware, type PrepareSolanaOffchainMessageV1Params, type PreparedSolanaOffchainMessageV1, QrDisplayData, type Response, type RunAllNetworkGetAddressOptions, SDK, SaveDeviceBindingDeclineReason, type SaveDeviceBindingRequest, type SdkEvent, type SearchDevicesOptions, type SearchTargetReusePolicy, type SolAddress, type SolGetAddressParams, type SolOffchainMessageV1Params, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TrezorBrightnessParams, type TrezorChangePinParams, type TrezorDeviceSettingsParams, type TrezorDisplayRotation, type TrezorSafetyCheckLevel, type TronAddress, type TronContract, type TronFreezeBalanceV2Contract, type TronGetAddressParams, type TronResource, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, type TronTransferContract, type TronTriggerSmartContract, type TronUnfreezeBalanceV2Contract, type TronVote, type TronVoteWitnessContract, type TronWithdrawExpireUnfreezeContract, TypedEventEmitter, UI_REQUEST, type UiRequestEvent, UiRequestOperationAttribution, UiRequestRegistry, UiResponseEvent, type VendorType, type WalletIdentity, type ZcashFullViewingKey, type ZcashFullViewingKeyMode, type ZcashGetFullViewingKeyParams, type ZcashGetShieldedAddressParams, type ZcashShieldedAddress, batchCall, buildUnsupportedMethodResponse, bytesToHex, canReplayHardwareMethodAfterTransportFailure, compareSemver, createBridgedConnector, createCombinedConnector, createHardwareLinkId, createHardwareOperationId, createHardwareSearchTargetId, deriveDeviceFingerprint, deriveWalletId, detectHardwareVendorFromDescriptor, ensure0x, failure, getAllNetworkMethodChain, getHardwareMethodMetadata, hasHardwareRuntimeIdPrefix, hexToBytes, isAllNetworkMethodName, isConnectionLost, isHardwareOperationId, isKnownNonTargetHardwareVendor, isUserRefusal, padHex64, parseBip32MasterFingerprint, parseHardwareRuntimeId, prepareSolanaOffchainMessageV1, rehydrateConnectorError, requestBleDeviceSelection, requestSaveDeviceBinding, resolveHardwareOperationTarget, resolveSearchTargetReusePolicy, runAllNetworkGetAddress, serializeConnectorError, stripHex, success };
|