@sidhujag/sysweb3-keyring 2.1.6 → 2.1.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/cjs/hardware-transaction-authority.js +15 -11
  3. package/cjs/hardware-transaction-authority.js.map +1 -1
  4. package/cjs/hardware-wallet-manager.js +74 -119
  5. package/cjs/hardware-wallet-manager.js.map +1 -1
  6. package/cjs/hardware-wallet-types.js +16 -0
  7. package/cjs/hardware-wallet-types.js.map +1 -0
  8. package/cjs/host-keyring.js +32 -0
  9. package/cjs/host-keyring.js.map +1 -0
  10. package/cjs/index.js +1 -0
  11. package/cjs/index.js.map +1 -1
  12. package/cjs/keyring-core.js +96 -61
  13. package/cjs/keyring-core.js.map +1 -1
  14. package/cjs/keyring-manager.js +15 -16
  15. package/cjs/keyring-manager.js.map +1 -1
  16. package/cjs/ledger/host-types.js.map +1 -1
  17. package/cjs/ledger/index.js +24 -4
  18. package/cjs/ledger/index.js.map +1 -1
  19. package/cjs/ledger-hardware.js +15 -0
  20. package/cjs/ledger-hardware.js.map +1 -0
  21. package/cjs/software.js +6 -25
  22. package/cjs/software.js.map +1 -1
  23. package/cjs/transactions/ethereum.js +321 -269
  24. package/cjs/transactions/ethereum.js.map +1 -1
  25. package/cjs/transactions/evm-envelope.js +186 -0
  26. package/cjs/transactions/evm-envelope.js.map +1 -0
  27. package/cjs/transactions/evm-submission.js +32 -4
  28. package/cjs/transactions/evm-submission.js.map +1 -1
  29. package/cjs/transactions/ledger-signing.js +44 -0
  30. package/cjs/transactions/ledger-signing.js.map +1 -0
  31. package/cjs/transactions/prepared-evm.js +44 -124
  32. package/cjs/transactions/prepared-evm.js.map +1 -1
  33. package/cjs/trezor/connect.js +238 -243
  34. package/cjs/trezor/connect.js.map +1 -1
  35. package/cjs/trezor/host-types.js +19 -0
  36. package/cjs/trezor/host-types.js.map +1 -0
  37. package/cjs/trezor/index.js +75 -23
  38. package/cjs/trezor/index.js.map +1 -1
  39. package/cjs/trezor/webextension-host.js +118 -0
  40. package/cjs/trezor/webextension-host.js.map +1 -0
  41. package/cjs/trezor-hardware.js +16 -0
  42. package/cjs/trezor-hardware.js.map +1 -0
  43. package/cjs/types.js.map +1 -1
  44. package/esm/hardware-transaction-authority.js +14 -11
  45. package/esm/hardware-transaction-authority.js.map +1 -1
  46. package/esm/hardware-wallet-manager.js +20 -32
  47. package/esm/hardware-wallet-manager.js.map +1 -1
  48. package/esm/hardware-wallet-types.js +13 -0
  49. package/esm/hardware-wallet-types.js.map +1 -0
  50. package/esm/keyring-core.js +98 -63
  51. package/esm/keyring-core.js.map +1 -1
  52. package/esm/ledger/dmk-host.js +2 -0
  53. package/esm/ledger/dmk-host.js.map +1 -1
  54. package/esm/ledger/dmk-session.js +73 -8
  55. package/esm/ledger/dmk-session.js.map +1 -1
  56. package/esm/ledger/host-types.js.map +1 -1
  57. package/esm/ledger/index.js +22 -2
  58. package/esm/ledger/index.js.map +1 -1
  59. package/esm/transactions/ethereum.js +322 -270
  60. package/esm/transactions/ethereum.js.map +1 -1
  61. package/esm/transactions/evm-envelope.js +179 -0
  62. package/esm/transactions/evm-envelope.js.map +1 -0
  63. package/esm/transactions/evm-submission.js +32 -4
  64. package/esm/transactions/evm-submission.js.map +1 -1
  65. package/esm/transactions/ledger-signing.js +41 -0
  66. package/esm/transactions/ledger-signing.js.map +1 -0
  67. package/esm/transactions/prepared-evm.js +43 -124
  68. package/esm/transactions/prepared-evm.js.map +1 -1
  69. package/esm/trezor/connect.js +236 -209
  70. package/esm/trezor/connect.js.map +1 -1
  71. package/esm/trezor/host-types.js +16 -0
  72. package/esm/trezor/host-types.js.map +1 -0
  73. package/esm/trezor/index.js +74 -22
  74. package/esm/trezor/index.js.map +1 -1
  75. package/esm/types.js.map +1 -1
  76. package/package.json +61 -1
  77. package/types/hardware-transaction-authority.d.ts +1 -0
  78. package/types/hardware-wallet-manager.d.ts +6 -22
  79. package/types/hardware-wallet-types.d.ts +21 -0
  80. package/types/host-keyring.d.ts +16 -0
  81. package/types/index.d.ts +1 -0
  82. package/types/keyring-core.d.ts +12 -4
  83. package/types/keyring-manager.d.ts +5 -3
  84. package/types/ledger/dmk-host.d.ts +2 -0
  85. package/types/ledger/dmk-session.d.ts +9 -0
  86. package/types/ledger/host-types.d.ts +2 -0
  87. package/types/ledger/index.d.ts +3 -1
  88. package/types/ledger-hardware.d.ts +5 -0
  89. package/types/software.d.ts +4 -17
  90. package/types/transactions/ethereum.d.ts +11 -1
  91. package/types/transactions/evm-envelope.d.ts +64 -0
  92. package/types/transactions/evm-submission.d.ts +7 -2
  93. package/types/transactions/ledger-signing.d.ts +13 -0
  94. package/types/transactions/prepared-evm.d.ts +14 -23
  95. package/types/trezor/connect.d.ts +11 -9
  96. package/types/trezor/host-types.d.ts +25 -0
  97. package/types/trezor/index.d.ts +7 -7
  98. package/types/trezor/webextension-host.d.ts +7 -0
  99. package/types/trezor-hardware.d.ts +6 -0
  100. package/types/types.d.ts +17 -5
@@ -1,15 +1,17 @@
1
1
  import { HardwareWalletManager } from './hardware-wallet-manager';
2
- import { KeyringCore } from './keyring-core';
2
+ import { HostKeyring } from './host-keyring';
3
3
  import { LedgerKeyring } from './ledger';
4
4
  import { TrezorKeyring } from './trezor';
5
5
  import type { KeyringHost, KeyringOptions } from './keyring-host';
6
6
  import type { LedgerHost } from './ledger/host-types';
7
7
  import type { CaptureEvmSubmission } from './transactions/evm-submission';
8
+ import type { TrezorHost } from './trezor/host-types';
8
9
  import type { IKeyringManager } from './types';
9
10
  export type { ISysAccount } from './keyring-core';
10
- export type { DeviceUnlockControls, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, } from './keyring-core';
11
+ export type { DeviceUnlockControls, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, PreparedSessionTransfer, } from './keyring-core';
11
12
  export type KeyringManagerOptions = Omit<KeyringOptions, 'captureEvmSubmission'> & {
12
13
  captureEvmSubmission: CaptureEvmSubmission;
14
+ trezorHost: TrezorHost;
13
15
  } & ({
14
16
  ledgerHost: LedgerHost;
15
17
  hardwareManager?: never;
@@ -18,7 +20,7 @@ export type KeyringManagerOptions = Omit<KeyringOptions, 'captureEvmSubmission'>
18
20
  hardwareManager: HardwareWalletManager;
19
21
  });
20
22
  /** Browser keyring with an explicit wallet authority and hardware adapter. */
21
- export declare class KeyringManager extends KeyringCore<LedgerKeyring, TrezorKeyring> implements IKeyringManager {
23
+ export declare class KeyringManager extends HostKeyring<LedgerKeyring, TrezorKeyring> implements IKeyringManager {
22
24
  constructor(host: KeyringHost, options: KeyringManagerOptions);
23
25
  static createInitialized(host: KeyringHost, seed: string, password: string, vaultStateGetter: () => any, options: KeyringManagerOptions): Promise<KeyringManager>;
24
26
  }
@@ -1,5 +1,7 @@
1
1
  import { type LedgerEvmConfig, type LedgerHost } from './host-types';
2
2
  export interface LedgerDmkHost extends LedgerHost {
3
+ /** Observe connection changes; read getStatus() in the callback. */
4
+ subscribeStatus(listener: () => void): () => void;
3
5
  /** Start before enumerating. The returned capability is single use. */
4
6
  beginDeviceSelection(signal?: AbortSignal): (candidate: object) => Promise<void>;
5
7
  }
@@ -37,16 +37,22 @@ export declare class LedgerDmkSession {
37
37
  private activeCancel;
38
38
  private activeAbort;
39
39
  private closing;
40
+ private closingResult;
41
+ private readonly closeObservers;
40
42
  private stateSubscription;
41
43
  private connectionAttempt;
42
44
  private connectionAbort;
43
45
  private deviceSelection;
44
46
  private readonly invalidationListeners;
47
+ private readonly statusListeners;
48
+ private reportedConnected;
45
49
  constructor(dmk: DeviceManagementKit, requireDeviceSelection?: boolean);
46
50
  private get readyConnection();
47
51
  getStatus(): {
48
52
  connected: boolean;
49
53
  };
54
+ subscribeStatus(listener: () => void): () => void;
55
+ private publishStatus;
50
56
  onInvalidated(listener: () => void): () => void;
51
57
  private invalidate;
52
58
  /** The platform passes one candidate from its own current DMK picker. */
@@ -61,6 +67,9 @@ export declare class LedgerDmkSession {
61
67
  private connectDevice;
62
68
  /** Cancel revokes the result and closes I/O; it cannot undo on-device approval. */
63
69
  disconnect(): Promise<void>;
70
+ private closeSession;
71
+ /** Join late vendor admission and its cleanup after immediate revocation. */
72
+ retire(): Promise<() => void>;
64
73
  runExclusive<Output>(operation: (session: LedgerDmkOperation) => Promise<Output>, options?: LedgerOperationOptions): Promise<Output>;
65
74
  runAction<Output>(createAction: (session: LedgerDmkOperation) => Action<Output>, options?: LedgerOperationOptions): Promise<Output>;
66
75
  private awaitAction;
@@ -120,6 +120,8 @@ export interface LedgerHost {
120
120
  useGrantedDevices?: boolean;
121
121
  }, options?: LedgerOperationOptions): Promise<void>;
122
122
  disconnect(): Promise<void>;
123
+ /** Complete cleanup and return a guard invalidated by any subsequent reopen. */
124
+ retire(): Promise<() => void>;
123
125
  getStatus(): {
124
126
  connected: boolean;
125
127
  };
@@ -1,4 +1,4 @@
1
- import { ConnectionStatus, HardwareWalletType } from '../hardware-wallet-manager';
1
+ import { ConnectionStatus, HardwareWalletType } from '../hardware-wallet-types';
2
2
  import type { HardwareWalletManager } from '../hardware-wallet-manager';
3
3
  import type { LedgerHost, LedgerUtxoHost } from './host-types';
4
4
  import type { IEvmMethods, IUTXOMethods } from './types';
@@ -22,4 +22,6 @@ export declare class LedgerKeyring {
22
22
  status: ConnectionStatus;
23
23
  };
24
24
  destroy(): Promise<void>;
25
+ /** Complete teardown and prove that no shared-host operation has reopened it. */
26
+ retire(): Promise<() => void>;
25
27
  }
@@ -0,0 +1,5 @@
1
+ import { LedgerKeyring } from './ledger';
2
+ import type { KeyringHardware } from './keyring-core';
3
+ import type { LedgerHost } from './ledger/host-types';
4
+ /** Use the same Ledger account and transaction adapters on every host. */
5
+ export declare function createLedgerHardware(host: LedgerHost): KeyringHardware<LedgerKeyring, undefined>;
@@ -1,22 +1,8 @@
1
1
  /** Software-only entry: explicit host storage, no browser/device initialization. */
2
- import { KeyringCore } from './keyring-core';
2
+ import { HostKeyring } from './host-keyring';
3
3
  import type { KeyringHost, KeyringOptions } from './keyring-host';
4
- import type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest } from './software-hd-account';
5
- import type { PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction } from './transactions/prepared-evm';
6
- export declare class SoftwareKeyring extends KeyringCore<undefined, undefined> {
4
+ export declare class SoftwareKeyring extends HostKeyring<undefined, undefined> {
7
5
  constructor(host: KeyringHost, options: KeyringOptions);
8
- /**
9
- * Derive a fixed-path Ethereum HD runtime account without network or storage
10
- * writes. The returned password-encrypted xprv is internal runtime state,
11
- * never a public account/catalogue DTO. The host owns index allocation.
12
- */
13
- deriveEvmHdRuntimeAccount(request: EvmHdRuntimeAccountRequest, options: EvmHdRuntimeAccountOptions): Promise<EncryptedEvmHdRuntimeAccount>;
14
- /**
15
- * Sign exactly the prepared envelope without RPC, fee/nonce discovery or
16
- * broadcasting. The host must journal the result before submitting it.
17
- * A later lock cannot revoke already returned signed bytes.
18
- */
19
- signPreparedEvmTransaction(request: PreparedSoftwareEvmSigningRequest, options: PreparedEvmSigningOptions): SignedPreparedEvmTransaction;
20
6
  static createInitialized(host: KeyringHost, seed: string, password: string, vaultStateGetter: () => any, options: KeyringOptions): Promise<SoftwareKeyring>;
21
7
  }
22
8
  export { createKeyringHost } from './keyring-host';
@@ -26,7 +12,8 @@ export { INetworkType } from '@sidhujag/sysweb3-network';
26
12
  export type { INetwork } from '@sidhujag/sysweb3-network';
27
13
  export type { DeviceUnlockControls, DeviceUnlockCredential, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, } from './keyring-core';
28
14
  export type { EvmRetainedCancellationOrigin, IKeyringAccountState, SyscoinOwnedReadOptions, SyscoinOwnedSubmissionOptions, SyscoinSubmissionDescriptor, } from './types';
29
- export type { PreparedEvmTransaction, PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction, } from './transactions/prepared-evm';
15
+ export type { EvmAccessList, PreparedEvmTransaction, } from './transactions/evm-envelope';
16
+ export type { PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction, } from './transactions/prepared-evm';
30
17
  export type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest, } from './software-hd-account';
31
18
  export { captureEvmSubmission, submitSignedEvmTransaction, evmSubmissionFailure, } from './transactions/evm-submission';
32
19
  export type { CaptureEvmSubmission, EvmSubmissionContext, EvmSubmissionLifecycle, EvmSignedSubmission, EvmSubmissionBoundary, } from './transactions/evm-submission';
@@ -4,7 +4,9 @@ import { BigNumber, TransactionResponse } from '../ethers-v6';
4
4
  import { type EvmFeeReader } from '../evm-fees';
5
5
  import { CustomJsonRpcProvider } from '../providers';
6
6
  import { IResponseFromSendErcSignedTransaction, ISendSignedErc20TransactionProps, ISendSignedErc721TransactionProps, ISendSignedErc1155TransactionProps, IReviewedEvmTokenApproval, IEthereumTransactions, IEvmCancellationOptions, IEvmReplacementOptions, EvmFormattedSendArguments, SimpleTransactionRequest, KeyringAccountType, accountType, IGasParams } from '../types';
7
+ import { type PreparedEvmTransaction } from './evm-envelope';
7
8
  import { type CaptureEvmSubmission } from './evm-submission';
9
+ import { type EvmDigestSignOptions, type PreparedSoftwareEvmSigningRequest, type PreparedEvmSigningOptions } from './prepared-evm';
8
10
  import type { LedgerKeyring } from '../ledger';
9
11
  import type { TrezorKeyring } from '../trezor';
10
12
  /** Minimal trusted device capabilities used by EVM transaction routing. */
@@ -43,6 +45,7 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
43
45
  private requireTrezorSigner;
44
46
  private assertHardwareSignerAvailable;
45
47
  private captureSessionGuard;
48
+ private captureEvmAccountContext;
46
49
  private captureEvmSigningContext;
47
50
  private captureSubmission;
48
51
  private authorizeHardwareTransaction;
@@ -52,7 +55,14 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
52
55
  signTypedData: (addr: string, typedData: TypedDataV1 | TypedMessage<any>, version: SignTypedDataVersion) => Promise<string>;
53
56
  verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string | undefined>;
54
57
  verifyTypedSignature: (data: TypedDataV1 | TypedMessage<any>, signature: string, version: SignTypedDataVersion) => string;
55
- ethSign: (params: string[]) => Promise<string>;
58
+ signPreparedEvmTransaction(input: PreparedSoftwareEvmSigningRequest, options: PreparedEvmSigningOptions): Readonly<{
59
+ rawTransaction: string;
60
+ hash: string;
61
+ unsignedHash: string;
62
+ from: string;
63
+ transaction: PreparedEvmTransaction;
64
+ }>;
65
+ ethSign: (params: string[], input: EvmDigestSignOptions) => Promise<string>;
56
66
  signPersonalMessage: (params: string[]) => Promise<string>;
57
67
  parsePersonalMessage: (hexMsg: string) => string;
58
68
  verifyPersonalMessage: (message: string, sign: string) => string;
@@ -0,0 +1,64 @@
1
+ export type EvmAccessList = readonly Readonly<{
2
+ address: string;
3
+ storageKeys: readonly string[];
4
+ }>[];
5
+ /**
6
+ * Fully specified type-0/type-2 transaction. Quantities are canonical decimal
7
+ * integer strings, nonce is at most MAX_SAFE_INTEGER, and gasLimit is uint64.
8
+ * The sender is a nonzero hex address. A null destination creates a contract.
9
+ * Data is even-length 0x hex, at most 512 KiB. Type 2 requires an access list.
10
+ */
11
+ export type PreparedEvmTransaction = Readonly<{
12
+ from: string;
13
+ to: string | null;
14
+ chainId: string;
15
+ nonce: string;
16
+ value: string;
17
+ gasLimit: string;
18
+ data: string;
19
+ } & ({
20
+ type: 0;
21
+ gasPrice: string;
22
+ } | {
23
+ type: 2;
24
+ maxFeePerGas: string;
25
+ maxPriorityFeePerGas: string;
26
+ accessList: EvmAccessList;
27
+ })>;
28
+ /** Snapshot values without invoking accessors or accepting hidden fields. */
29
+ /** @internal Strict own-data snapshot shared with prepared request binding. */
30
+ export declare function readEvmOwnData(value: unknown, keys: readonly string[]): Record<string, unknown>;
31
+ /** Copy bounded own data while preserving the signed order and duplicates. */
32
+ export declare function snapshotEvmAccessList(value: unknown): EvmAccessList;
33
+ export declare function snapshotPreparedEvmTransaction(input: unknown): PreparedEvmTransaction;
34
+ /** @internal The same validated fields feed unsigned serialization and signing. */
35
+ export declare function prepareUnsignedEvmEnvelope(input: PreparedEvmTransaction): {
36
+ transaction: PreparedEvmTransaction;
37
+ unsigned: {
38
+ gasPrice: bigint;
39
+ type: 0 | 2;
40
+ to: string | null;
41
+ chainId: bigint;
42
+ nonce: number;
43
+ value: bigint;
44
+ gasLimit: bigint;
45
+ data: string;
46
+ } | {
47
+ maxFeePerGas: bigint;
48
+ maxPriorityFeePerGas: bigint;
49
+ accessList: {
50
+ address: string;
51
+ storageKeys: string[];
52
+ }[];
53
+ type: 0 | 2;
54
+ to: string | null;
55
+ chainId: bigint;
56
+ nonce: number;
57
+ value: bigint;
58
+ gasLimit: bigint;
59
+ data: string;
60
+ };
61
+ expectedUnsigned: string;
62
+ };
63
+ /** Validate and serialize the exact envelope used by prepared signing. */
64
+ export declare function serializePreparedEvmTransaction(transaction: PreparedEvmTransaction): string;
@@ -15,6 +15,11 @@ export type EvmSubmissionContext = Readonly<{
15
15
  operation: 'send' | 'cancel' | 'speed-up' | 'erc20' | 'erc721' | 'erc1155';
16
16
  originalHash?: string;
17
17
  origin?: EvmRetainedCancellationOrigin;
18
+ /** Transient identity of the live host fee review, bound to these signed bytes. */
19
+ review?: Readonly<{
20
+ id: string;
21
+ unsignedHash: string;
22
+ }>;
18
23
  walletNonce?: EvmWalletNonce;
19
24
  }>;
20
25
  /** Signed wire bytes only; never a key, password or mutable transaction request. */
@@ -54,11 +59,11 @@ export type EvmSubmissionBoundary = Readonly<{
54
59
  export declare function captureEvmSubmission(input: EvmSubmissionContext, assertCurrent: () => void, capture: CaptureEvmSubmission): EvmSubmissionBoundary;
55
60
  /** Refuse any new signature or dispatch without a captured durable port. */
56
61
  export declare function assertDurableEvmSubmission(boundary: EvmSubmissionBoundary): void;
57
- /** Only local stage evidence can label an error as a possibly dispatched send. */
62
+ /** Return owned stage evidence only; unrecognized errors carry no classification. */
58
63
  export declare function evmSubmissionFailure(error: unknown): Readonly<{
59
64
  transactionNotBroadcast: boolean;
60
65
  signedTransactionHash?: string;
61
- }>;
66
+ }> | undefined;
62
67
  /** Preserve local evidence when an existing public API wraps its Error object. */
63
68
  export declare function copyEvmSubmissionFailure(source: unknown, target: Error): void;
64
69
  /** Compare signed wire bytes with the complete envelope captured before signing. */
@@ -0,0 +1,13 @@
1
+ import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
2
+ import type { IEvmMethods } from '../ledger/types';
3
+ /** Sign the reviewed bytes through the shared Ledger adapter without changing fees or nonce. */
4
+ export declare function signLedgerEvmTransaction(signer: {
5
+ evm: Pick<IEvmMethods, 'signEVMTransaction'>;
6
+ }, request: Readonly<{
7
+ accountIndex: number;
8
+ expectedAddress: string;
9
+ unsignedTransaction: string;
10
+ }>, authority: HardwareTransactionAuthority): Promise<Readonly<{
11
+ rawTransaction: string;
12
+ hash: string;
13
+ }>>;
@@ -1,26 +1,17 @@
1
- /**
2
- * Fully specified type-0/type-2 transaction. Quantities are canonical decimal
3
- * integer strings, nonce is at most MAX_SAFE_INTEGER, and gasLimit is uint64.
4
- * Addresses must be nonzero hex addresses; valid casing is normalized. Data is
5
- * even-length 0x hex, at most 16 KiB. Contract creation/access lists are omitted.
6
- */
7
- export type PreparedEvmTransaction = Readonly<{
8
- from: string;
9
- to: string;
10
- chainId: string;
11
- nonce: string;
12
- value: string;
13
- gasLimit: string;
14
- data: string;
15
- } & ({
16
- type: 0;
17
- gasPrice: string;
18
- } | {
19
- type: 2;
20
- maxFeePerGas: string;
21
- maxPriorityFeePerGas: string;
22
- })>;
1
+ import type { PreparedEvmTransaction } from './evm-envelope';
2
+ export type EvmSigningIdentity = Readonly<{
3
+ id: number;
4
+ type: 'HDAccount' | 'Imported' | 'Ledger' | 'Trezor' | 'SmartAccount';
5
+ expectedAddress: string;
6
+ }>;
7
+ export declare function snapshotEvmSigningIdentity(input: unknown): EvmSigningIdentity;
8
+ export type EvmDigestSignOptions = Readonly<{
9
+ selectedAccount: EvmSigningIdentity;
10
+ targetAccount: EvmSigningIdentity;
11
+ assertCurrent(): void;
12
+ }>;
23
13
  export type PreparedSoftwareEvmSigningRequest = Readonly<{
14
+ selectedAccount: EvmSigningIdentity;
24
15
  account: Readonly<{
25
16
  id: number;
26
17
  type: 'HDAccount' | 'Imported';
@@ -50,7 +41,7 @@ export type SignedPreparedEvmTransaction = Readonly<{
50
41
  export declare function snapshotPreparedEvmRequest(input: unknown): PreparedSoftwareEvmSigningRequest;
51
42
  export declare function preparedEvmGuard(input: unknown): () => void;
52
43
  /** Internal, network-free signing. The key never becomes part of the result. */
53
- export declare function signPreparedEvmEnvelope(transaction: PreparedEvmTransaction, privateKey: string): Readonly<{
44
+ export declare function signPreparedEvmEnvelope(input: PreparedEvmTransaction, privateKey: string): Readonly<{
54
45
  signed: SignedPreparedEvmTransaction;
55
46
  expectedUnsigned: string;
56
47
  }>;
@@ -1,8 +1,8 @@
1
1
  import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
2
- import type { ConnectDynamicSettings, TrezorConnectPublicAPI } from '@trezor/connect-webextension';
3
- type Client = TrezorConnectPublicAPI<ConnectDynamicSettings>;
4
- declare const methods: readonly ["getFeatures", "getAccountInfo", "ethereumGetAddress", "ethereumGetPublicKey", "getPublicKey", "getAddress", "signMessage", "ethereumSignMessage", "ethereumSignTypedData", "verifyMessage", "ethereumVerifyMessage"];
5
- type ForwardedMethod = (typeof methods)[number];
2
+ import type { TrezorCalls, TrezorHost, TrezorMethod } from './host-types';
3
+ type Client = TrezorCalls;
4
+ type TransactionMethod = 'ethereumSignTransaction' | 'signTransaction';
5
+ type ForwardedMethod = Exclude<TrezorMethod, TransactionMethod>;
6
6
  type Compatible<T> = T extends {
7
7
  success: false;
8
8
  } ? T & {
@@ -23,23 +23,25 @@ type CompatibleCall<FunctionType> = FunctionType extends {
23
23
  type Calls = {
24
24
  [Name in ForwardedMethod]: CompatibleCall<Client[Name]>;
25
25
  };
26
- type ConnectionEvent = {
26
+ export type ConnectionEvent = {
27
27
  type: 'disconnected';
28
28
  } | {
29
29
  type: 'model';
30
30
  model: string;
31
31
  };
32
- export declare const subscribeTrezorEvents: (listener: (event: ConnectionEvent) => void) => (() => void);
33
- declare const TrezorConnect: Calls & {
32
+ export type TrezorConnection = Calls & {
34
33
  ethereumSignTransactionOwned: (request: Parameters<Client['ethereumSignTransaction']>[0], authority: HardwareTransactionAuthority) => ReturnType<CompatibleCall<Client['ethereumSignTransaction']>>;
35
34
  signTransactionOwned: (request: Parameters<Client['signTransaction']>[0], authority: HardwareTransactionAuthority) => ReturnType<CompatibleCall<Client['signTransaction']>>;
36
- init: Client['init'];
35
+ init: () => Promise<void>;
37
36
  dispose: () => Promise<void>;
37
+ retire: () => Promise<() => void>;
38
+ subscribe(listener: (event: ConnectionEvent) => void): () => void;
38
39
  };
40
+ export declare function createTrezorConnection(host: TrezorHost): TrezorConnection;
39
41
  export declare const trezorResponseError: (response: {
40
42
  payload?: {
41
43
  error?: string;
42
44
  code?: string;
43
45
  };
44
46
  }, prefix?: string) => Error;
45
- export default TrezorConnect;
47
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { ConnectDynamicSettings, TrezorConnectPublicAPI } from '@trezor/connect-webextension';
2
+ export declare const TREZOR_METHODS: readonly ["getFeatures", "getAccountInfo", "ethereumGetAddress", "ethereumGetPublicKey", "getPublicKey", "getAddress", "signMessage", "ethereumSignMessage", "ethereumSignTypedData", "verifyMessage", "ethereumVerifyMessage", "ethereumSignTransaction", "signTransaction"];
3
+ export type TrezorMethod = (typeof TREZOR_METHODS)[number];
4
+ export type TrezorCalls = Pick<TrezorConnectPublicAPI<ConnectDynamicSettings>, TrezorMethod>;
5
+ type GuardedCall<Call> = Call extends {
6
+ (...args: infer A): infer R;
7
+ (...args: infer B): infer S;
8
+ (...args: infer C): infer T;
9
+ } ? {
10
+ (assertCurrent: () => void, ...args: A): R;
11
+ (assertCurrent: () => void, ...args: B): S;
12
+ (assertCurrent: () => void, ...args: C): T;
13
+ } : never;
14
+ /** Recheck after asynchronous preparation and immediately before device I/O. */
15
+ export type TrezorHostCalls = {
16
+ [Method in TrezorMethod]: GuardedCall<TrezorCalls[Method]>;
17
+ };
18
+ /** One explicitly owned client. This contract imports no platform runtime. */
19
+ export type TrezorHost = TrezorHostCalls & {
20
+ /** Check after asynchronous preparation and immediately before prompting. */
21
+ init(assertCurrent: () => void): Promise<void>;
22
+ /** Retire this host's client according to its platform cleanup requirements. */
23
+ dispose(pendingCalls: readonly Promise<unknown>[]): Promise<void>;
24
+ };
25
+ export {};
@@ -2,17 +2,14 @@ import { TypedMessage, SignTypedDataVersion, TypedDataV1 } from '@metamask/eth-s
2
2
  import { Psbt } from 'bitcoinjs-lib';
3
3
  import { Buffer } from 'buffer';
4
4
  import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
5
+ import type { TrezorConnection } from './connect';
5
6
  import type { AccountInfo, EthereumTransaction, EthereumTransactionEIP1559 } from '@trezor/connect-webextension';
6
7
  export interface TrezorControllerState {
7
8
  hdPath: string;
8
9
  paths: Record<string, number>;
9
10
  }
10
- declare global {
11
- interface Window {
12
- TrezorConnect: any;
13
- }
14
- }
15
11
  export declare class TrezorKeyring {
12
+ private readonly connection;
16
13
  hdPath: string;
17
14
  publicKey: Buffer;
18
15
  chainCode: Buffer;
@@ -21,10 +18,11 @@ export declare class TrezorKeyring {
21
18
  private hardwareWalletManager;
22
19
  private initialized;
23
20
  private lifecycleGeneration;
21
+ private retirementEpoch;
24
22
  private unsubscribeTrezor?;
25
23
  private readonly onTrezorConnected;
26
24
  private readonly onTrezorDisconnected;
27
- constructor();
25
+ constructor(connection: TrezorConnection);
28
26
  private observeTrezor;
29
27
  /**
30
28
  * Initialize Trezor script.
@@ -177,9 +175,11 @@ export declare class TrezorKeyring {
177
175
  /**
178
176
  * Check Trezor status
179
177
  */
180
- getStatus(): import("../hardware-wallet-manager").HardwareWalletStatus | undefined;
178
+ getStatus(): import("../hardware-wallet-types").HardwareWalletStatus | undefined;
181
179
  /**
182
180
  * Clean up resources
183
181
  */
184
182
  destroy(): Promise<void>;
183
+ /** Wait for the old device call and transport ownership to be fully retired. */
184
+ retire(): Promise<() => void>;
185
185
  }
@@ -0,0 +1,7 @@
1
+ import type { TrezorHost } from './host-types';
2
+ import type { ConnectDynamicSettings, TrezorConnectPublicAPI } from '@trezor/connect-webextension';
3
+ type Client = TrezorConnectPublicAPI<ConnectDynamicSettings>;
4
+ export type TrezorWebExtensionSettings = Parameters<Client['init']>[0];
5
+ /** Explicit browser composition. The shared signer never loads this module. */
6
+ export declare function createTrezorWebExtensionHost(settings: TrezorWebExtensionSettings): TrezorHost;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import { TrezorKeyring } from './trezor';
2
+ import type { KeyringHardware } from './keyring-core';
3
+ import type { TrezorHost } from './trezor/host-types';
4
+ /** Use the same Trezor account and transaction adapters on every host. */
5
+ export declare function createTrezorHardware(host: TrezorHost): KeyringHardware<undefined, TrezorKeyring>;
6
+ export type { TrezorHost } from './trezor/host-types';
package/types/types.d.ts CHANGED
@@ -7,8 +7,8 @@ import { LedgerKeyring } from './ledger';
7
7
  import { IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams } from './private-records';
8
8
  import { SyscoinHDSigner } from './signers';
9
9
  import { TrezorKeyring } from './trezor';
10
- import type { KeyringCore } from './keyring-core';
11
- import type { PreparedEvmTransaction } from './transactions/prepared-evm';
10
+ import type { KeyringCore, PreparedSessionTransfer } from './keyring-core';
11
+ import type { PreparedEvmTransaction } from './transactions/evm-envelope';
12
12
  import type { OwnedUtxoRpcVerification } from '@sidhujag/sysweb3-network';
13
13
  export type AccessListish = Array<{
14
14
  address: string;
@@ -43,12 +43,22 @@ export type EvmWalletNonce = Readonly<{
43
43
  source: 'automatic' | 'manual';
44
44
  }>;
45
45
  export interface IEvmSendOptions {
46
+ selectedAccount: import('./transactions/prepared-evm').EvmSigningIdentity;
47
+ targetAccount: import('./transactions/prepared-evm').EvmSigningIdentity;
46
48
  /** Synchronous host admission, rechecked immediately before signing and broadcast. */
47
49
  assertCurrent: () => void;
48
- mode: 'reviewed-native' | 'specialized';
50
+ mode: 'reviewed-native' | 'reviewed-generic' | 'specialized';
49
51
  walletNonce?: EvmWalletNonce;
50
52
  }
51
53
  export type EvmFormattedSendArguments = [
54
+ approvedTransaction: PreparedEvmTransaction,
55
+ isLegacy: boolean | undefined,
56
+ options: IEvmSendOptions & {
57
+ mode: 'reviewed-generic';
58
+ reviewId: string;
59
+ walletNonce: EvmWalletNonce;
60
+ }
61
+ ] | [
52
62
  approvedTransaction: PreparedEvmTransaction,
53
63
  isLegacy: boolean | undefined,
54
64
  options: IEvmSendOptions & {
@@ -115,7 +125,8 @@ export interface IEthereumTransactions {
115
125
  transaction?: TransactionResponse;
116
126
  }>;
117
127
  decryptMessage: (msgParams: string[]) => string;
118
- ethSign: (params: string[]) => Promise<string>;
128
+ ethSign: (params: string[], options: import('./transactions/prepared-evm').EvmDigestSignOptions) => Promise<string>;
129
+ signPreparedEvmTransaction: (request: import('./transactions/prepared-evm').PreparedSoftwareEvmSigningRequest, options: import('./transactions/prepared-evm').PreparedEvmSigningOptions) => import('./transactions/prepared-evm').SignedPreparedEvmTransaction;
119
130
  getBalance: (address: string) => Promise<number>;
120
131
  getEncryptedPubKey: () => string;
121
132
  getErc20TokensByAddress?: (address: string, isSupported: boolean, apiUrl: string) => Promise<any[]>;
@@ -233,6 +244,7 @@ export interface IKeyringManager {
233
244
  needsAccountCreation?: boolean;
234
245
  }>;
235
246
  isUnlocked: () => boolean;
247
+ captureUnlockedSessionGuard: () => () => void;
236
248
  logout: () => void;
237
249
  ledgerSigner: LedgerKeyring;
238
250
  trezorSigner: TrezorKeyring;
@@ -283,7 +295,7 @@ export interface IKeyringManager {
283
295
  initializeWalletSecurely: (seedPhrase: string, password: string, prvPassword?: string) => Promise<IKeyringAccountState>;
284
296
  initializeSession: (seedPhrase: string, password: string) => Promise<void>;
285
297
  createFirstAccount: (label?: string) => Promise<IKeyringAccountState>;
286
- transferSessionTo: (targetKeyring: KeyringCore) => void;
298
+ prepareSessionTransfer: (targetKeyring: KeyringCore, assertCurrent: () => void) => Promise<PreparedSessionTransfer>;
287
299
  lockWallet: () => Promise<void>;
288
300
  setVaultStateGetter: (getter: () => any) => void;
289
301
  }