@onekeyfe/hwk-adapter-core 1.2.8-alpha.120 → 1.2.8-alpha.121

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/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as HardwareErrorCode, a as HwkErrorOrigin, b as HwkRecoveryHint } from './errors-BgJ4kzRx.mjs';
2
- export { c as HwkError, d as HwkRecoveryScope, I as IHwkErrorPayload, e as IOperationMayHaveCompletedParams, O as ORPHAN_ELIGIBLE_ERROR_CODES, f as createHwkError, g as defaultOriginForCode, h as defaultRecoveryForCode, i as enrichErrorMessage, j as isHwkRecoveryHint, o as operationMayHaveCompletedParams } from './errors-BgJ4kzRx.mjs';
3
- import { U as UiResponseEvent, E as ExportedAccountKey, a as UiRequestOperationAttribution, b as UI_REQUEST, Q as QrDisplayData, c as UiRequestRegistry, S as SaveDeviceBindingDeclineReason } from './ui-events-C61GTilK.mjs';
4
- export { D as DevicePermissionDeniedReason, d as DevicePermissionResponse, e as QrResponseData, f as UI_EVENT, g as UI_REQUEST_CANCELLED_TAG, h as UI_REQUEST_DEFAULT_TIMEOUT_MS, i as UI_REQUEST_PREEMPTED_TAG, j as UI_REQUEST_TIMEOUT_TAG, k as UI_RESPONSE } from './ui-events-C61GTilK.mjs';
1
+ import { H as HardwareErrorCode, a as HwkErrorOrigin, b as HwkRecoveryHint } from './errors-DednD9bG.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-DednD9bG.mjs';
3
+ import { U as UiResponseEvent, E as ExportedAccountKey, a as UiRequestOperationAttribution, b as UI_REQUEST, Q as QrDisplayData, c as UiRequestRegistry, S as SaveDeviceBindingDeclineReason } from './ui-events-D_lCGgCk.mjs';
4
+ export { D as DevicePermissionDeniedReason, d as DevicePermissionResponse, e as QrResponseData, f as UI_EVENT, g as UI_REQUEST_CANCELLED_TAG, h as UI_REQUEST_DEFAULT_TIMEOUT_MS, i as UI_REQUEST_PREEMPTED_TAG, j as UI_REQUEST_TIMEOUT_TAG, k as UI_RESPONSE } from './ui-events-D_lCGgCk.mjs';
5
5
 
6
6
  interface Success<T> {
7
7
  success: true;
@@ -53,116 +53,6 @@ declare function parseWalletMasterFingerprint(value: unknown): string | undefine
53
53
  */
54
54
  declare function deriveDeviceFingerprint(value: string): string;
55
55
 
56
- type VendorType = 'trezor' | 'ledger' | 'keystone';
57
- /** 'qr' is a virtual channel: UR payloads travel via app-rendered/scanned QR codes. */
58
- type ConnectionType = 'usb' | 'ble' | 'qr';
59
- type TransportType = 'usb' | 'ble' | 'hid' | 'bridge' | 'qr';
60
- /**
61
- * Device capabilities — describes what a specific device/connection
62
- * combination can or cannot do. Varies by vendor, model, and connection type.
63
- *
64
- * This enables business logic to check capabilities instead of hard-coding
65
- * vendor-specific conditions (e.g., `if (vendor === 'ledger')`).
66
- */
67
- interface DeviceCapabilities {
68
- /**
69
- * Whether the discovery handle can be reused to reconnect; `false` requires rediscovery. Says
70
- * nothing about identity (Trezor BLE is false yet its device_id is stable); verify it separately.
71
- */
72
- persistentDeviceIdentity: boolean;
73
- }
74
- interface DeviceInfo {
75
- vendor: VendorType;
76
- /** Machine model id (e.g. "nanoX"). */
77
- model: string;
78
- /** Human-readable model name (e.g. "Ledger Nano X"). */
79
- modelName?: string;
80
- firmwareVersion: string;
81
- deviceId: string;
82
- connectId: string;
83
- label?: string;
84
- connectionType: ConnectionType;
85
- battery?: number;
86
- /** BLE signal strength (BLE only). */
87
- rssi?: number | null;
88
- /** BLE connectable flag (BLE only). */
89
- isConnectable?: boolean | null;
90
- /** USB serial number (USB only). */
91
- serialNumber?: string;
92
- /** Device capabilities — varies by vendor, model, and connection type */
93
- capabilities?: DeviceCapabilities;
94
- /**
95
- * Vendor-specific raw payload from the post-handshake `Features` (Trezor)
96
- * or device-info call. Populated by the connector with `{ transport,
97
- * descriptor, features }` so the app layer can read fields we haven't
98
- * promoted to the typed surface yet. Treat as informational — promote
99
- * any consumed field above.
100
- */
101
- raw?: Record<string, unknown>;
102
- }
103
- interface DeviceTarget {
104
- connectId: string;
105
- deviceId: string;
106
- }
107
- /**
108
- * How long a discovery handle remains safe to use for a new connection.
109
- * This is deliberately separate from post-connect device identity.
110
- */
111
- type SearchTargetReusePolicy = 'current-discovery' | 'reconnectable' | 'rediscover';
112
- declare function resolveSearchTargetReusePolicy(device: Pick<DeviceInfo, 'connectionType' | 'capabilities'>): SearchTargetReusePolicy;
113
- /** Search target for a physical device whose connectId is the discovery handle. */
114
- declare function toPhysicalDeviceSearchTarget(vendor: VendorType, device: DeviceInfo): DeviceSearchTarget;
115
- /**
116
- * A selectable result from hardware discovery. It may represent a physical
117
- * transport endpoint or an interactive entry such as Keystone QR; it is not a
118
- * physical-device or wallet identity.
119
- */
120
- interface DeviceSearchTarget {
121
- /** Opaque handle scoped to the adapter's current discovery state. */
122
- searchTargetId: string;
123
- /** Whether the handle itself may be retried; never inferred from a stored connectId. */
124
- searchTargetReusePolicy?: SearchTargetReusePolicy;
125
- vendor: VendorType;
126
- connectionType: ConnectionType;
127
- kind: 'physical' | 'interactive';
128
- label?: string;
129
- model?: string;
130
- modelName?: string;
131
- serialNumber?: string;
132
- }
133
- type WalletIdentity = {
134
- vendor: 'ledger';
135
- type: 'chainFingerprint';
136
- chain: ChainForFingerprint;
137
- value: string;
138
- } | {
139
- vendor: 'trezor';
140
- type: 'deviceId';
141
- value: string;
142
- } | {
143
- vendor: 'keystone';
144
- type: 'walletId';
145
- value: string;
146
- };
147
-
148
- /**
149
- * Mixin for chain-operation params that can be pinned to a specific passphrase
150
- * wallet.
151
- *
152
- * Trezor-only. `passphraseState` is the wallet identity returned by
153
- * `getPassphraseState`: today this is the compressed public key derived at
154
- * `m/44'/0'/0'`, not the 4-byte master fingerprint. When present, the adapter
155
- * creates a fresh wallet session (THP application session, or v1 device
156
- * session) and verifies the derived state before issuing the call, so the
157
- * address/signature comes from the intended passphrase wallet.
158
- *
159
- * Ledger has no equivalent and ignores the field — it never reaches the
160
- * protobuf layer (the adapter strips it before forwarding to the connector).
161
- */
162
- interface PassphraseStateAware {
163
- passphraseState?: string;
164
- }
165
-
166
56
  /**
167
57
  * Minimal device info returned during discovery (searchDevices).
168
58
  * At scan time, full DeviceInfo fields like firmwareVersion are not yet available.
@@ -277,6 +167,8 @@ declare enum EConnectorInteraction {
277
167
  AppInstallProgress = "app-install-progress"
278
168
  }
279
169
  type ConnectorUiEvent = {
170
+ operationId?: string;
171
+ } & ({
280
172
  type: EConnectorInteraction.Searching;
281
173
  payload: {
282
174
  sessionId: string;
@@ -285,6 +177,7 @@ type ConnectorUiEvent = {
285
177
  type: EConnectorInteraction.ConfirmOpenApp;
286
178
  payload: {
287
179
  sessionId: string;
180
+ appName?: string;
288
181
  };
289
182
  } | {
290
183
  type: EConnectorInteraction.UnlockDevice;
@@ -308,7 +201,7 @@ type ConnectorUiEvent = {
308
201
  appName: string;
309
202
  progress: number;
310
203
  };
311
- };
204
+ });
312
205
  interface ConnectorEventMap {
313
206
  'device-connect': {
314
207
  device: ConnectorDevice;
@@ -493,6 +386,190 @@ declare const DEVICE: {
493
386
  readonly TREZOR_THP_CREDENTIALS_CHANGED: "device-trezor-thp-credentials-changed";
494
387
  };
495
388
 
389
+ /**
390
+ * Mixin for chain-operation params that can be pinned to a specific passphrase
391
+ * wallet.
392
+ *
393
+ * Trezor-only. `passphraseState` is the wallet identity returned by
394
+ * `getPassphraseState`: today this is the compressed public key derived at
395
+ * `m/44'/0'/0'`, not the 4-byte master fingerprint. When present, the adapter
396
+ * creates a fresh wallet session (THP application session, or v1 device
397
+ * session) and verifies the derived state before issuing the call, so the
398
+ * address/signature comes from the intended passphrase wallet.
399
+ *
400
+ * Ledger has no equivalent and ignores the field — it never reaches the
401
+ * protobuf layer (the adapter strips it before forwarding to the connector).
402
+ */
403
+ interface PassphraseStateAware {
404
+ passphraseState?: string;
405
+ }
406
+
407
+ interface EvmGetAddressParams extends PassphraseStateAware {
408
+ path: string;
409
+ showOnDevice?: boolean;
410
+ chainId?: number;
411
+ ethereumDefinitions?: EvmEthereumDefinitions;
412
+ }
413
+ interface EvmAddress {
414
+ address: string;
415
+ path: string;
416
+ /** Device-reported secp256k1 public key; populated when the transport exposes it. */
417
+ publicKey?: string;
418
+ /** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
419
+ accountKey?: ExportedAccountKey;
420
+ }
421
+ interface EvmSignTxBaseParams extends PassphraseStateAware {
422
+ path: string;
423
+ chainId?: number;
424
+ }
425
+ /** Ledger shape: the whole RLP-serialized tx (0x-prefixed or plain hex); structured fields forbidden. */
426
+ interface EvmSignTxLedgerParams extends EvmSignTxBaseParams {
427
+ serializedTx: string;
428
+ to?: never;
429
+ value?: never;
430
+ nonce?: never;
431
+ gasLimit?: never;
432
+ gasPrice?: never;
433
+ txType?: never;
434
+ maxFeePerGas?: never;
435
+ maxPriorityFeePerGas?: never;
436
+ accessList?: never;
437
+ data?: never;
438
+ paymentRequest?: never;
439
+ ethereumDefinitions?: never;
440
+ }
441
+ /** Trezor shape: structured EthereumSignTx protobuf fields; serializedTx forbidden. */
442
+ interface EvmSignTxTrezorParams extends EvmSignTxBaseParams {
443
+ serializedTx?: never;
444
+ /** Contract address or recipient. Optional for contract deployment transactions. */
445
+ to?: string;
446
+ value?: string;
447
+ nonce?: string;
448
+ gasLimit?: string;
449
+ gasPrice?: string;
450
+ txType?: number;
451
+ maxFeePerGas?: string;
452
+ maxPriorityFeePerGas?: string;
453
+ accessList?: Array<{
454
+ address: string;
455
+ storageKeys: string[];
456
+ }>;
457
+ data?: string;
458
+ paymentRequest?: EvmPaymentRequest;
459
+ ethereumDefinitions?: EvmEthereumDefinitions;
460
+ }
461
+ /** Mutually exclusive vendor shapes; each adapter narrows to its own. */
462
+ type EvmSignTxParams = EvmSignTxLedgerParams | EvmSignTxTrezorParams;
463
+ interface EvmEthereumDefinitions {
464
+ /** Trezor Ethereum network definition bytes as a hex string. */
465
+ encodedNetwork?: string;
466
+ /** Trezor Ethereum token definition bytes as a hex string. */
467
+ encodedToken?: string;
468
+ }
469
+ interface EvmPaymentRequestMemo {
470
+ textMemo?: {
471
+ text: string;
472
+ };
473
+ textDetailsMemo?: {
474
+ title: string;
475
+ text: string;
476
+ };
477
+ refundMemo?: {
478
+ address: string;
479
+ addressN?: number[];
480
+ mac: string;
481
+ };
482
+ coinPurchaseMemo?: {
483
+ coinType: number;
484
+ amount: string;
485
+ address: string;
486
+ addressN?: number[];
487
+ mac: string;
488
+ };
489
+ }
490
+ interface EvmPaymentRequest {
491
+ nonce?: string;
492
+ recipientName: string;
493
+ memos?: EvmPaymentRequestMemo[];
494
+ /** Decimal string in subunits; SDK encodes it as SLIP-24 uint256 LE hex. */
495
+ amount?: string;
496
+ signature: string;
497
+ }
498
+ interface EvmSignedTx {
499
+ /** Recovery id as `0x`-prefixed hex string. */
500
+ v: string;
501
+ /** ECDSA `r` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
502
+ r: string;
503
+ /** ECDSA `s` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
504
+ s: string;
505
+ serializedTx?: string;
506
+ }
507
+ interface EvmSignMsgParams extends PassphraseStateAware {
508
+ path: string;
509
+ message: string;
510
+ chainId?: number;
511
+ hex?: boolean;
512
+ ethereumDefinitions?: EvmEthereumDefinitions;
513
+ }
514
+ type EvmSignTypedDataParams = EvmSignTypedDataFull | EvmSignTypedDataHash;
515
+ interface EvmSignTypedDataFull extends PassphraseStateAware {
516
+ path: string;
517
+ chainId?: number;
518
+ /** Defaults to `'full'` when omitted. */
519
+ mode?: 'full';
520
+ ethereumDefinitions?: EvmEthereumDefinitions;
521
+ data: {
522
+ domain: EIP712Domain;
523
+ types: Record<string, Array<{
524
+ name: string;
525
+ type: string;
526
+ }>>;
527
+ primaryType: string;
528
+ message: Record<string, unknown>;
529
+ };
530
+ /**
531
+ * The dApp's original EIP-712 JSON, byte for byte. Serializing vendors (Keystone) must prefer it:
532
+ * re-stringifying `data` rewrites integers wider than 2^53 and exponent forms.
533
+ */
534
+ dataJson?: string;
535
+ metamaskV4Compat?: boolean;
536
+ showMessageHash?: boolean;
537
+ /**
538
+ * Optional host-computed hashes. Core Trezor models still use full typed-data
539
+ * signing for display, while Trezor One can fall back to typed-hash signing
540
+ * when firmware cannot compute the hashes itself.
541
+ */
542
+ domainSeparatorHash?: string;
543
+ messageHash?: string;
544
+ }
545
+ interface EvmSignTypedDataHash extends PassphraseStateAware {
546
+ path: string;
547
+ chainId?: number;
548
+ mode: 'hash';
549
+ domainSeparatorHash: string;
550
+ messageHash: string;
551
+ ethereumDefinitions?: EvmEthereumDefinitions;
552
+ }
553
+ interface EIP712Domain {
554
+ name?: string;
555
+ version?: string;
556
+ chainId?: number;
557
+ verifyingContract?: string;
558
+ salt?: string;
559
+ [key: string]: unknown;
560
+ }
561
+ interface EvmSignature {
562
+ /** `0x`-prefixed hex string (r + s + v). */
563
+ signature: string;
564
+ address?: string;
565
+ }
566
+ interface IEvmMethods {
567
+ evmGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmGetAddressParams>>): Promise<Response<EvmAddress>>;
568
+ evmSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTxParams>>): Promise<Response<EvmSignedTx>>;
569
+ evmSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignMsgParams>>): Promise<Response<EvmSignature>>;
570
+ evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
571
+ }
572
+
496
573
  interface BtcGetAddressParams extends PassphraseStateAware {
497
574
  path: string;
498
575
  coin?: string;
@@ -898,7 +975,7 @@ declare class OperationRegistry {
898
975
  /** Return active or tombstoned binding data without refreshing its TTL. */
899
976
  find(operationId: string): HardwareOperation | undefined;
900
977
  findActiveByConnectionKey(connectionKey: string): HardwareOperation | undefined;
901
- /** Map a job queue key (an operation id or a connection key) to its live operation id. */
978
+ /** Only an explicitly supplied operation job key owns the call's UI requests. */
902
979
  findOperationIdByJobKey(jobKey: string | undefined): string | undefined;
903
980
  /**
904
981
  * End an operation on the caller's explicit release. Throws for an unknown id; returns undefined
@@ -1034,6 +1111,7 @@ type HardwareUiEvent = Exclude<ConnectorUiEvent, {
1034
1111
  type: EConnectorInteraction.AppInstallProgress;
1035
1112
  }> | {
1036
1113
  type: EConnectorInteraction.AppInstallProgress;
1114
+ operationId?: string;
1037
1115
  payload: {
1038
1116
  connectId: string;
1039
1117
  appName: string;
@@ -1216,6 +1294,8 @@ interface AllNetworkGetAddressParams extends IHardwareCommonCallParams {
1216
1294
  }
1217
1295
  type AllNetworkDeviceIdentity = WalletIdentity;
1218
1296
  type AllNetworkAddressResponsePayload = Record<string, unknown> & {
1297
+ /** This account came from the user's explicit device-export scan. */
1298
+ accountExport?: boolean;
1219
1299
  error?: string;
1220
1300
  code?: HardwareErrorCode | number;
1221
1301
  errorCode?: string | number;
@@ -1342,6 +1422,12 @@ type UiRequestEvent = {
1342
1422
  vendor: string;
1343
1423
  appName: string;
1344
1424
  } & UiRequestOperationAttribution;
1425
+ } | {
1426
+ type: typeof UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM;
1427
+ payload: {
1428
+ vendor: string;
1429
+ requestId: string;
1430
+ } & UiRequestOperationAttribution;
1345
1431
  } | {
1346
1432
  type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
1347
1433
  payload: {
@@ -1513,6 +1599,13 @@ interface HardwareEventMap {
1513
1599
  appName: string;
1514
1600
  } & UiRequestOperationAttribution;
1515
1601
  };
1602
+ [UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM]: {
1603
+ type: typeof UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM;
1604
+ payload: {
1605
+ vendor: string;
1606
+ requestId: string;
1607
+ } & UiRequestOperationAttribution;
1608
+ };
1516
1609
  [UI_REQUEST.REQUEST_TREZOR_THP_PAIRING]: {
1517
1610
  type: typeof UI_REQUEST.REQUEST_TREZOR_THP_PAIRING;
1518
1611
  payload: {
@@ -1666,171 +1759,99 @@ interface SearchDevicesOptions {
1666
1759
  transportType?: ConnectionType;
1667
1760
  }
1668
1761
 
1669
- interface EvmGetAddressParams extends PassphraseStateAware {
1670
- path: string;
1671
- showOnDevice?: boolean;
1672
- chainId?: number;
1673
- ethereumDefinitions?: EvmEthereumDefinitions;
1674
- }
1675
- interface EvmAddress {
1676
- address: string;
1677
- path: string;
1678
- /** Device-reported secp256k1 public key; populated when the transport exposes it. */
1679
- publicKey?: string;
1680
- /** Set by air-gapped wallets (Keystone): the exported key this address derives from. */
1681
- accountKey?: ExportedAccountKey;
1682
- }
1683
- interface EvmSignTxBaseParams extends PassphraseStateAware {
1684
- path: string;
1685
- chainId?: number;
1686
- }
1687
- /** Ledger shape: the whole RLP-serialized tx (0x-prefixed or plain hex); structured fields forbidden. */
1688
- interface EvmSignTxLedgerParams extends EvmSignTxBaseParams {
1689
- serializedTx: string;
1690
- to?: never;
1691
- value?: never;
1692
- nonce?: never;
1693
- gasLimit?: never;
1694
- gasPrice?: never;
1695
- txType?: never;
1696
- maxFeePerGas?: never;
1697
- maxPriorityFeePerGas?: never;
1698
- accessList?: never;
1699
- data?: never;
1700
- paymentRequest?: never;
1701
- ethereumDefinitions?: never;
1702
- }
1703
- /** Trezor shape: structured EthereumSignTx protobuf fields; serializedTx forbidden. */
1704
- interface EvmSignTxTrezorParams extends EvmSignTxBaseParams {
1705
- serializedTx?: never;
1706
- /** Contract address or recipient. Optional for contract deployment transactions. */
1707
- to?: string;
1708
- value?: string;
1709
- nonce?: string;
1710
- gasLimit?: string;
1711
- gasPrice?: string;
1712
- txType?: number;
1713
- maxFeePerGas?: string;
1714
- maxPriorityFeePerGas?: string;
1715
- accessList?: Array<{
1716
- address: string;
1717
- storageKeys: string[];
1718
- }>;
1719
- data?: string;
1720
- paymentRequest?: EvmPaymentRequest;
1721
- ethereumDefinitions?: EvmEthereumDefinitions;
1722
- }
1723
- /** Mutually exclusive vendor shapes; each adapter narrows to its own. */
1724
- type EvmSignTxParams = EvmSignTxLedgerParams | EvmSignTxTrezorParams;
1725
- interface EvmEthereumDefinitions {
1726
- /** Trezor Ethereum network definition bytes as a hex string. */
1727
- encodedNetwork?: string;
1728
- /** Trezor Ethereum token definition bytes as a hex string. */
1729
- encodedToken?: string;
1730
- }
1731
- interface EvmPaymentRequestMemo {
1732
- textMemo?: {
1733
- text: string;
1734
- };
1735
- textDetailsMemo?: {
1736
- title: string;
1737
- text: string;
1738
- };
1739
- refundMemo?: {
1740
- address: string;
1741
- addressN?: number[];
1742
- mac: string;
1743
- };
1744
- coinPurchaseMemo?: {
1745
- coinType: number;
1746
- amount: string;
1747
- address: string;
1748
- addressN?: number[];
1749
- mac: string;
1750
- };
1751
- }
1752
- interface EvmPaymentRequest {
1753
- nonce?: string;
1754
- recipientName: string;
1755
- memos?: EvmPaymentRequestMemo[];
1756
- /** Decimal string in subunits; SDK encodes it as SLIP-24 uint256 LE hex. */
1757
- amount?: string;
1758
- signature: string;
1759
- }
1760
- interface EvmSignedTx {
1761
- /** Recovery id as `0x`-prefixed hex string. */
1762
- v: string;
1763
- /** ECDSA `r` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
1764
- r: string;
1765
- /** ECDSA `s` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
1766
- s: string;
1767
- serializedTx?: string;
1768
- }
1769
- interface EvmSignMsgParams extends PassphraseStateAware {
1770
- path: string;
1771
- message: string;
1772
- chainId?: number;
1773
- hex?: boolean;
1774
- ethereumDefinitions?: EvmEthereumDefinitions;
1775
- }
1776
- type EvmSignTypedDataParams = EvmSignTypedDataFull | EvmSignTypedDataHash;
1777
- interface EvmSignTypedDataFull extends PassphraseStateAware {
1778
- path: string;
1779
- chainId?: number;
1780
- /** Defaults to `'full'` when omitted. */
1781
- mode?: 'full';
1782
- ethereumDefinitions?: EvmEthereumDefinitions;
1783
- data: {
1784
- domain: EIP712Domain;
1785
- types: Record<string, Array<{
1786
- name: string;
1787
- type: string;
1788
- }>>;
1789
- primaryType: string;
1790
- message: Record<string, unknown>;
1791
- };
1762
+ type VendorType = 'trezor' | 'ledger' | 'keystone';
1763
+ /** 'qr' is a virtual channel: UR payloads travel via app-rendered/scanned QR codes. */
1764
+ type ConnectionType = 'usb' | 'ble' | 'qr';
1765
+ type TransportType = 'usb' | 'ble' | 'hid' | 'bridge' | 'qr';
1766
+ /**
1767
+ * Device capabilities — describes what a specific device/connection
1768
+ * combination can or cannot do. Varies by vendor, model, and connection type.
1769
+ *
1770
+ * This enables business logic to check capabilities instead of hard-coding
1771
+ * vendor-specific conditions (e.g., `if (vendor === 'ledger')`).
1772
+ */
1773
+ interface DeviceCapabilities {
1774
+ /** Chains usable through this adapter on the connected firmware; absent means not advertised. */
1775
+ supportedChains?: ChainCapability[];
1792
1776
  /**
1793
- * The dApp's original EIP-712 JSON, byte for byte. Serializing vendors (Keystone) must prefer it:
1794
- * re-stringifying `data` rewrites integers wider than 2^53 and exponent forms.
1777
+ * Whether the discovery handle can be reused to reconnect; `false` requires rediscovery. Says
1778
+ * nothing about identity (Trezor BLE is false yet its device_id is stable); verify it separately.
1795
1779
  */
1796
- dataJson?: string;
1797
- metamaskV4Compat?: boolean;
1798
- showMessageHash?: boolean;
1780
+ persistentDeviceIdentity: boolean;
1781
+ }
1782
+ interface DeviceInfo {
1783
+ vendor: VendorType;
1784
+ /** Machine model id (e.g. "nanoX"). */
1785
+ model: string;
1786
+ /** Human-readable model name (e.g. "Ledger Nano X"). */
1787
+ modelName?: string;
1788
+ firmwareVersion: string;
1789
+ deviceId: string;
1790
+ connectId: string;
1791
+ label?: string;
1792
+ connectionType: ConnectionType;
1793
+ battery?: number;
1794
+ /** BLE signal strength (BLE only). */
1795
+ rssi?: number | null;
1796
+ /** BLE connectable flag (BLE only). */
1797
+ isConnectable?: boolean | null;
1798
+ /** USB serial number (USB only). */
1799
+ serialNumber?: string;
1800
+ /** Device capabilities — varies by vendor, model, and connection type */
1801
+ capabilities?: DeviceCapabilities;
1799
1802
  /**
1800
- * Optional host-computed hashes. Core Trezor models still use full typed-data
1801
- * signing for display, while Trezor One can fall back to typed-hash signing
1802
- * when firmware cannot compute the hashes itself.
1803
+ * Vendor-specific raw payload from the post-handshake `Features` (Trezor)
1804
+ * or device-info call. Populated by the connector with `{ transport,
1805
+ * descriptor, features }` so the app layer can read fields we haven't
1806
+ * promoted to the typed surface yet. Treat as informational — promote
1807
+ * any consumed field above.
1803
1808
  */
1804
- domainSeparatorHash?: string;
1805
- messageHash?: string;
1806
- }
1807
- interface EvmSignTypedDataHash extends PassphraseStateAware {
1808
- path: string;
1809
- chainId?: number;
1810
- mode: 'hash';
1811
- domainSeparatorHash: string;
1812
- messageHash: string;
1813
- ethereumDefinitions?: EvmEthereumDefinitions;
1814
- }
1815
- interface EIP712Domain {
1816
- name?: string;
1817
- version?: string;
1818
- chainId?: number;
1819
- verifyingContract?: string;
1820
- salt?: string;
1821
- [key: string]: unknown;
1809
+ raw?: Record<string, unknown>;
1822
1810
  }
1823
- interface EvmSignature {
1824
- /** `0x`-prefixed hex string (r + s + v). */
1825
- signature: string;
1826
- address?: string;
1811
+ interface DeviceTarget {
1812
+ connectId: string;
1813
+ deviceId: string;
1827
1814
  }
1828
- interface IEvmMethods {
1829
- evmGetAddress(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmGetAddressParams>>): Promise<Response<EvmAddress>>;
1830
- evmSignTransaction(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTxParams>>): Promise<Response<EvmSignedTx>>;
1831
- evmSignMessage(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignMsgParams>>): Promise<Response<EvmSignature>>;
1832
- evmSignTypedData(connectId?: NullableCallArg<string>, deviceId?: NullableCallArg<string>, params?: NullableCallArg<IHardwareCallParams<EvmSignTypedDataParams>>): Promise<Response<EvmSignature>>;
1815
+ /**
1816
+ * How long a discovery handle remains safe to use for a new connection.
1817
+ * This is deliberately separate from post-connect device identity.
1818
+ */
1819
+ type SearchTargetReusePolicy = 'current-discovery' | 'reconnectable' | 'rediscover';
1820
+ declare function resolveSearchTargetReusePolicy(device: Pick<DeviceInfo, 'connectionType' | 'capabilities'>): SearchTargetReusePolicy;
1821
+ /** Search target for a physical device whose connectId is the discovery handle. */
1822
+ declare function toPhysicalDeviceSearchTarget(vendor: VendorType, device: DeviceInfo): DeviceSearchTarget;
1823
+ /**
1824
+ * A selectable result from hardware discovery. It may represent a physical
1825
+ * transport endpoint or an interactive entry such as Keystone QR; it is not a
1826
+ * physical-device or wallet identity.
1827
+ */
1828
+ interface DeviceSearchTarget {
1829
+ /** Opaque handle scoped to the adapter's current discovery state. */
1830
+ searchTargetId: string;
1831
+ /** Whether the handle itself may be retried; never inferred from a stored connectId. */
1832
+ searchTargetReusePolicy?: SearchTargetReusePolicy;
1833
+ vendor: VendorType;
1834
+ connectionType: ConnectionType;
1835
+ kind: 'physical' | 'interactive';
1836
+ label?: string;
1837
+ model?: string;
1838
+ modelName?: string;
1839
+ serialNumber?: string;
1833
1840
  }
1841
+ type WalletIdentity = {
1842
+ vendor: 'ledger';
1843
+ type: 'chainFingerprint';
1844
+ chain: ChainForFingerprint;
1845
+ value: string;
1846
+ } | {
1847
+ vendor: 'trezor';
1848
+ type: 'deviceId';
1849
+ value: string;
1850
+ } | {
1851
+ vendor: 'keystone';
1852
+ type: 'walletId';
1853
+ value: string;
1854
+ };
1834
1855
 
1835
1856
  /** Which `GET_VK` encoding the Ledger Zcash app should return. */
1836
1857
  type ZcashFullViewingKeyMode = 'ufvk' | 'orchardFvk';