@sidhujag/sysweb3-keyring 2.1.9 → 2.1.11

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 (45) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +8 -5
  3. package/cjs/hardware-signing-data.js +85 -0
  4. package/cjs/hardware-signing-data.js.map +1 -0
  5. package/cjs/hardware-wallet-manager.js +36 -13
  6. package/cjs/hardware-wallet-manager.js.map +1 -1
  7. package/cjs/ledger/index.js +41 -51
  8. package/cjs/ledger/index.js.map +1 -1
  9. package/cjs/transactions/ethereum.js +92 -70
  10. package/cjs/transactions/ethereum.js.map +1 -1
  11. package/cjs/transactions/prepared-evm.js.map +1 -1
  12. package/cjs/trezor/connect.js +155 -50
  13. package/cjs/trezor/connect.js.map +1 -1
  14. package/cjs/trezor/index.js +159 -138
  15. package/cjs/trezor/index.js.map +1 -1
  16. package/cjs/types.js.map +1 -1
  17. package/esm/hardware-signing-data.js +82 -0
  18. package/esm/hardware-signing-data.js.map +1 -0
  19. package/esm/hardware-wallet-manager.js +36 -13
  20. package/esm/hardware-wallet-manager.js.map +1 -1
  21. package/esm/ledger/dmk-evm.js +13 -48
  22. package/esm/ledger/dmk-evm.js.map +1 -1
  23. package/esm/ledger/dmk-utxo.js +9 -6
  24. package/esm/ledger/dmk-utxo.js.map +1 -1
  25. package/esm/ledger/index.js +41 -51
  26. package/esm/ledger/index.js.map +1 -1
  27. package/esm/transactions/ethereum.js +92 -70
  28. package/esm/transactions/ethereum.js.map +1 -1
  29. package/esm/transactions/prepared-evm.js.map +1 -1
  30. package/esm/trezor/connect.js +155 -50
  31. package/esm/trezor/connect.js.map +1 -1
  32. package/esm/trezor/index.js +160 -139
  33. package/esm/trezor/index.js.map +1 -1
  34. package/esm/types.js.map +1 -1
  35. package/package.json +1 -1
  36. package/types/hardware-signing-data.d.ts +2 -0
  37. package/types/hardware-wallet-manager.d.ts +3 -1
  38. package/types/ledger/host-types.d.ts +3 -3
  39. package/types/ledger/index.d.ts +2 -1
  40. package/types/ledger/types.d.ts +4 -4
  41. package/types/transactions/ethereum.d.ts +4 -2
  42. package/types/transactions/prepared-evm.d.ts +1 -0
  43. package/types/trezor/connect.d.ts +10 -1
  44. package/types/trezor/index.d.ts +21 -11
  45. package/types/types.d.ts +2 -2
@@ -37,16 +37,16 @@ export interface IEvmMethods {
37
37
  s: string;
38
38
  v: string;
39
39
  }>;
40
- signPersonalMessage: ({ message, accountIndex, }: {
40
+ signPersonalMessage: (request: {
41
41
  accountIndex: number;
42
42
  message: string;
43
43
  expectedAddress: string;
44
- }) => Promise<string>;
45
- signTypedData: ({ version, data, accountIndex, }: {
44
+ }, authority: HardwareTransactionAuthority) => Promise<string>;
45
+ signTypedData: (request: {
46
46
  accountIndex: number;
47
47
  data: any;
48
48
  expectedAddress: string;
49
49
  version: SignTypedDataVersion;
50
- }) => Promise<string>;
50
+ }, authority: HardwareTransactionAuthority) => Promise<string>;
51
51
  }
52
52
  export {};
@@ -6,6 +6,7 @@ import { CustomJsonRpcProvider } from '../providers';
6
6
  import { IResponseFromSendErcSignedTransaction, ISendSignedErc20TransactionProps, ISendSignedErc721TransactionProps, ISendSignedErc1155TransactionProps, IReviewedEvmTokenApproval, IEthereumTransactions, IEvmCancellationOptions, IEvmReplacementOptions, EvmFormattedSendArguments, SimpleTransactionRequest, KeyringAccountType, accountType, IGasParams } from '../types';
7
7
  import { type PreparedEvmTransaction } from './evm-envelope';
8
8
  import { type CaptureEvmSubmission } from './evm-submission';
9
+ import { type HardwareTransactionAuthority } from '../hardware-transaction-authority';
9
10
  import { type EvmDigestSignOptions, type PreparedSoftwareEvmSigningRequest, type PreparedEvmSigningOptions } from './prepared-evm';
10
11
  import type { LedgerKeyring } from '../ledger';
11
12
  import type { TrezorKeyring } from '../trezor';
@@ -52,7 +53,8 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
52
53
  private submitSignedHardwareTransaction;
53
54
  get web3Provider(): CustomJsonRpcProvider;
54
55
  private ensureProvidersInitialized;
55
- signTypedData: (addr: string, typedData: TypedDataV1 | TypedMessage<any>, version: SignTypedDataVersion) => Promise<string>;
56
+ private captureMessageSigning;
57
+ signTypedData: (addr: string, typedData: TypedDataV1 | TypedMessage<any>, version: SignTypedDataVersion, authority: HardwareTransactionAuthority) => Promise<string>;
56
58
  verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string | undefined>;
57
59
  verifyTypedSignature: (data: TypedDataV1 | TypedMessage<any>, signature: string, version: SignTypedDataVersion) => string;
58
60
  signPreparedEvmTransaction(input: PreparedSoftwareEvmSigningRequest, options: PreparedEvmSigningOptions): Readonly<{
@@ -63,7 +65,7 @@ export declare class EthereumTransactions<TLedger extends EthereumLedgerSigner |
63
65
  transaction: PreparedEvmTransaction;
64
66
  }>;
65
67
  ethSign: (params: string[], input: EvmDigestSignOptions) => Promise<string>;
66
- signPersonalMessage: (params: string[]) => Promise<string>;
68
+ signPersonalMessage: (params: string[], authority: HardwareTransactionAuthority) => Promise<string>;
67
69
  parsePersonalMessage: (hexMsg: string) => string;
68
70
  verifyPersonalMessage: (message: string, sign: string) => string;
69
71
  getEncryptedPubKey: () => string;
@@ -6,6 +6,7 @@ export type EvmSigningIdentity = Readonly<{
6
6
  }>;
7
7
  export declare function snapshotEvmSigningIdentity(input: unknown): EvmSigningIdentity;
8
8
  export type EvmDigestSignOptions = Readonly<{
9
+ signal: AbortSignal;
9
10
  selectedAccount: EvmSigningIdentity;
10
11
  targetAccount: EvmSigningIdentity;
11
12
  assertCurrent(): void;
@@ -2,7 +2,8 @@ import type { HardwareTransactionAuthority } from '../hardware-transaction-autho
2
2
  import type { TrezorCalls, TrezorHost, TrezorMethod } from './host-types';
3
3
  type Client = TrezorCalls;
4
4
  type TransactionMethod = 'ethereumSignTransaction' | 'signTransaction';
5
- type ForwardedMethod = Exclude<TrezorMethod, TransactionMethod>;
5
+ type SigningMethod = TransactionMethod | 'signMessage' | 'ethereumSignMessage' | 'ethereumSignTypedData';
6
+ type ForwardedMethod = Exclude<TrezorMethod, SigningMethod>;
6
7
  type Compatible<T> = T extends {
7
8
  success: false;
8
9
  } ? T & {
@@ -29,7 +30,15 @@ export type ConnectionEvent = {
29
30
  type: 'model';
30
31
  model: string;
31
32
  };
33
+ export type TrezorSigningSession = {
34
+ [Name in SigningMethod]: CompatibleCall<Client[Name]>;
35
+ } & {
36
+ init(): Promise<void>;
37
+ dispose(): Promise<void>;
38
+ getFeatures: CompatibleCall<Client['getFeatures']>;
39
+ };
32
40
  export type TrezorConnection = Calls & {
41
+ withOwnedSigning<Result>(authority: HardwareTransactionAuthority, operation: (session: TrezorSigningSession) => Promise<Result>): Promise<Result>;
33
42
  ethereumSignTransactionOwned: (request: Parameters<Client['ethereumSignTransaction']>[0], authority: HardwareTransactionAuthority) => ReturnType<CompatibleCall<Client['ethereumSignTransaction']>>;
34
43
  signTransactionOwned: (request: Parameters<Client['signTransaction']>[0], authority: HardwareTransactionAuthority) => ReturnType<CompatibleCall<Client['signTransaction']>>;
35
44
  init: () => Promise<void>;
@@ -1,8 +1,9 @@
1
- import { TypedMessage, SignTypedDataVersion, TypedDataV1 } from '@metamask/eth-sig-util';
1
+ import { SignTypedDataVersion } from '@metamask/eth-sig-util';
2
2
  import { Psbt } from 'bitcoinjs-lib';
3
3
  import { Buffer } from 'buffer';
4
4
  import type { HardwareTransactionAuthority } from '../hardware-transaction-authority';
5
5
  import type { TrezorConnection } from './connect';
6
+ import type { LedgerTypedData } from '../ledger/host-types';
6
7
  import type { AccountInfo, EthereumTransaction, EthereumTransactionEIP1559 } from '@trezor/connect-webextension';
7
8
  export interface TrezorControllerState {
8
9
  hdPath: string;
@@ -28,6 +29,7 @@ export declare class TrezorKeyring {
28
29
  * Initialize Trezor script.
29
30
  */
30
31
  init(assertCurrent?: () => void): Promise<boolean>;
32
+ private initSigning;
31
33
  /**
32
34
  * Execute operation with automatic retry
33
35
  */
@@ -144,26 +146,34 @@ export declare class TrezorKeyring {
144
146
  * @param index - index of account for path derivation
145
147
  * @returns signature object
146
148
  */
147
- signMessage({ index, message, coin, slip44, address, }: {
149
+ signMessage(request: {
148
150
  address: string;
149
151
  coin: string;
150
- index?: number;
151
- message?: string;
152
+ index: number;
153
+ message: string;
152
154
  slip44: number;
153
- }): Promise<unknown>;
154
- private _signUtxoPersonalMessage;
155
- private _signEthPersonalMessage;
156
- private _sanitizeData;
155
+ }, authority: HardwareTransactionAuthority): Promise<(import("@trezor/type-utils").Err<import("@trezor/connect-common/lib/constants/errors").SerializedError> & {
156
+ payload: {
157
+ error: string;
158
+ code?: string;
159
+ };
160
+ }) | import("@trezor/connect-webextension").OkWithDevice<{
161
+ address: string;
162
+ signature: string;
163
+ }> | {
164
+ signature: string;
165
+ success: boolean;
166
+ }>;
157
167
  private _transformTypedData;
158
168
  /**
159
169
  * EIP-712 Sign Typed Data
160
170
  */
161
- signTypedData({ version, address, data, index, }: {
171
+ signTypedData(request: {
162
172
  address: string;
163
- data: TypedMessage<any> | TypedDataV1;
173
+ data: LedgerTypedData;
164
174
  index: number;
165
175
  version: SignTypedDataVersion;
166
- }): Promise<string>;
176
+ }, authority: HardwareTransactionAuthority): Promise<string>;
167
177
  /**
168
178
  * Verify UTXO address by displaying it on the Trezor device
169
179
  * @param accountIndex - The account index
package/types/types.d.ts CHANGED
@@ -135,7 +135,7 @@ export interface IEthereumTransactions {
135
135
  getGasLimit: (toAddress: string) => Promise<number>;
136
136
  getGasOracle?: () => Promise<any>;
137
137
  getRecommendedNonce: (address: string) => Promise<number>;
138
- signTypedData: (addr: string, typedData: TypedDataV1 | TypedMessage<any>, version: SignTypedDataVersion) => Promise<string>;
138
+ signTypedData: (addr: string, typedData: TypedDataV1 | TypedMessage<any>, version: SignTypedDataVersion, authority: import('./hardware-transaction-authority').HardwareTransactionAuthority) => Promise<string>;
139
139
  importAccount: (mnemonicOrPrivKey: string) => EvmLocalAccount;
140
140
  parsePersonalMessage: (hexMsg: string) => string;
141
141
  sendFormattedTransaction: (...args: EvmFormattedSendArguments) => Promise<TransactionResponse>;
@@ -152,7 +152,7 @@ export interface IEthereumTransactions {
152
152
  transaction?: TransactionResponse;
153
153
  error?: boolean;
154
154
  }>;
155
- signPersonalMessage: (params: string[]) => Promise<string>;
155
+ signPersonalMessage: (params: string[], authority: import('./hardware-transaction-authority').HardwareTransactionAuthority) => Promise<string>;
156
156
  verifyTypedSignature: (data: TypedDataV1 | TypedMessage<any>, signature: string, version: SignTypedDataVersion) => string;
157
157
  verifyUtxoAddress: (accountIndex: number, currency: string, slip44: number) => Promise<string | undefined>;
158
158
  setWeb3Provider: (network: INetwork) => void;