@metamask-previews/keyring-utils 2.0.0-776292e → 2.0.0-d9aa015

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.
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=keyring.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring.cjs","sourceRoot":"","sources":["../src/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { TypedTransaction, TxData } from '@ethereumjs/tx';\nimport type { Eip1024EncryptedData, Hex, Json } from '@metamask/utils';\n\n/**\n * A Keyring class.\n *\n * This type is used to validate the constructor signature and the `type`\n * static property on Keyring classes. See the {@link Keyring} type for more\n * information.\n */\nexport type KeyringClass = {\n /**\n * The Keyring constructor. Takes a single parameter, an \"options\" object.\n * See the documentation for the specific keyring for more information about\n * what these options are.\n *\n * @param options - The constructor options. Differs between keyring\n * implementations.\n */\n new (options?: Record<string, unknown>): Keyring;\n\n /**\n * The name of this type of keyring. This must uniquely identify the\n * keyring type.\n */\n type: string;\n};\n\n/**\n * A keyring is something that can sign messages. Keyrings are used to add new\n * signing strategies; each strategy is a new keyring.\n *\n * Each keyring manages a collection of key pairs, which we call \"accounts\".\n * Each account is referred to by its \"address\", which is a unique identifier\n * derived from the public key. The address is always a \"0x\"-prefixed\n * hexidecimal string.\n *\n * The keyring might store the private key for each account as well, but it's\n * not guaranteed. Some keyrings delegate signing, so they don't need the\n * private key directly. The keyring (and in particular the keyring state)\n * should be treated with care though, just in case it does contain sensitive\n * material such as a private key.\n */\nexport type Keyring = {\n /**\n * The name of this type of keyring. This must match the `type` property of\n * the keyring class.\n */\n type: string;\n\n /**\n * Get the addresses for all accounts in this keyring.\n *\n * @returns A list of the account addresses for this keyring\n */\n getAccounts(): Promise<Hex[]>;\n\n /**\n * Add an account to the keyring.\n *\n * @param number - The number of accounts to add. Usually defaults to 1.\n * @returns A list of the newly added account addresses.\n */\n addAccounts(number: number): Promise<Hex[]>;\n\n /**\n * Serialize the keyring state as a JSON-serializable object.\n *\n * @returns A JSON-serializable representation of the keyring state.\n */\n serialize(): Promise<Json>;\n\n /**\n * Deserialize the given keyring state, overwriting any existing state with\n * the serialized state provided.\n *\n * @param state - A JSON-serializable representation of the keyring state.\n */\n deserialize(state: Json): Promise<void>;\n\n /**\n * Method to include asynchronous configuration.\n */\n init?(): Promise<void>;\n\n /**\n * Remove an account from the keyring.\n *\n * @param address - The address of the account to remove.\n */\n removeAccount?(address: Hex): void;\n\n /**\n * Export the private key for one of the keyring accounts.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter is used to allow exporting a\n * private key that is derived from the given account, rather than exporting\n * that account's private key directly.\n *\n * @param address - The address of the account to export.\n * @param options - Export options; differs between keyrings.\n * @returns The non-prefixed, hex-encoded private key that was requested.\n */\n exportAccount?(\n address: Hex,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Get the \"app key\" address for the given account and origin. An app key is\n * an application-specific key pair. See {@link https://eips.ethereum.org/EIPS/eip-1775|EIP-1775}\n * for more information. The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin|origin}\n * is used as the unique identifier for the application, and it's used as\n * part of the key derivation process.\n *\n * @param address - The address of the account the app key is derived from.\n * @param origin - The origin of the application.\n * @returns The address of the app key for the given account and origin.\n */\n getAppKeyAddress?(address: Hex, origin: string): Promise<Hex>;\n\n /**\n * Sign a transaction. This is equivalent to the `eth_signTransaction`\n * Ethereum JSON-RPC method. See the Ethereum JSON-RPC API documentation for\n * more details.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param transaction - The transaction to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed transaction.\n */\n signTransaction?(\n address: Hex,\n transaction: TypedTransaction,\n options?: Record<string, unknown>,\n ): Promise<TxData>;\n\n /**\n * Sign a message. This is equivalent to an older version of the the\n * `eth_sign` Ethereum JSON-RPC method. The message is signed using ECDSA,\n * using the curve secp256k1 the Keccak-256 hash function.\n *\n * For more information about this method and why we still support it, see\n * the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param message - The message to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signMessage?(\n address: Hex,\n message: string,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign an EIP-7702 authorization. This is a signing method for authorizing a\n * specific contract on a specific chain.\n *\n * @param address - The address of the account to use for signing.\n * @param authorization - An array containing the chain ID, contract address,\n * and nonce.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed authorization as a hex string.\n */\n signEip7702Authorization?(\n address: Hex,\n authorization: [chainId: number, contractAddress: Hex, nonce: number],\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC\n * method, which is exposed by MetaMask as the method `personal_sign`. See\n * the Ethereum JSON-RPC API documentation for more details.\n *\n * For more information about this method and why we call it `personal_sign`,\n * see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param message - The message to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signPersonalMessage?(\n address: Hex,\n message: Hex,\n options?: { version?: string } & Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign a message. This is equivalent to the `eth_signTypedData` Ethereum\n * JSON-RPC method. See {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md|EIP-712}\n * for more details.\n *\n * The \"version\" option dictates which version of `eth_signTypedData` is\n * used. The latest version reflects the specification most closely, whereas\n * earlier versions reflect earlier drafts of the specification that are\n * still supported for backwards-compatibility reasons. For more information\n * about why we support multiple versions, see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept additional options as well. See the documentation for\n * the specific keyring for more information about what these options are.\n * For some keyrings, the options parameter can even change which key is used\n * for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param typedData - The data to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signTypedData?(\n address: Hex,\n typedData: Record<string, unknown>,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Get a public key to use for encryption. This is equivalent to the\n * ` eth_getEncryptionPublicKey` JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-getencryptionpublickey|MetaMask Docs}\n * for more information.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used (e.g. encrypting with app keys).\n *\n * @param account - The address of the account you want the encryption key for.\n * @param options - Options; differs between keyrings.\n */\n getEncryptionPublicKey?(\n account: Hex,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Decrypt an encrypted message. This is equivalent to the ` eth_decrypt`\n * JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-decrypt|MetaMask Docs}\n * for more information.\n *\n * @param account - The address of the account you want to use to decrypt\n * the message.\n * @param encryptedData - The encrypted data that you want to decrypt.\n * @returns The decrypted data.\n */\n decryptMessage?(\n account: Hex,\n encryptedData: Eip1024EncryptedData,\n ): Promise<string>;\n\n /**\n * Generates the properties for the keyring based on the given\n * BIP39-compliant mnemonic.\n *\n * @returns A promise resolving when the keyring has generated the properties.\n */\n generateRandomMnemonic?(): Promise<void>;\n\n /**\n * Destroy the keyring.\n */\n destroy?(): Promise<void>;\n};\n"]}
@@ -0,0 +1,235 @@
1
+ import type { TypedTransaction, TxData } from "@ethereumjs/tx";
2
+ import type { Eip1024EncryptedData, Hex, Json } from "@metamask/utils";
3
+ /**
4
+ * A Keyring class.
5
+ *
6
+ * This type is used to validate the constructor signature and the `type`
7
+ * static property on Keyring classes. See the {@link Keyring} type for more
8
+ * information.
9
+ */
10
+ export type KeyringClass = {
11
+ /**
12
+ * The Keyring constructor. Takes a single parameter, an "options" object.
13
+ * See the documentation for the specific keyring for more information about
14
+ * what these options are.
15
+ *
16
+ * @param options - The constructor options. Differs between keyring
17
+ * implementations.
18
+ */
19
+ new (options?: Record<string, unknown>): Keyring;
20
+ /**
21
+ * The name of this type of keyring. This must uniquely identify the
22
+ * keyring type.
23
+ */
24
+ type: string;
25
+ };
26
+ /**
27
+ * A keyring is something that can sign messages. Keyrings are used to add new
28
+ * signing strategies; each strategy is a new keyring.
29
+ *
30
+ * Each keyring manages a collection of key pairs, which we call "accounts".
31
+ * Each account is referred to by its "address", which is a unique identifier
32
+ * derived from the public key. The address is always a "0x"-prefixed
33
+ * hexidecimal string.
34
+ *
35
+ * The keyring might store the private key for each account as well, but it's
36
+ * not guaranteed. Some keyrings delegate signing, so they don't need the
37
+ * private key directly. The keyring (and in particular the keyring state)
38
+ * should be treated with care though, just in case it does contain sensitive
39
+ * material such as a private key.
40
+ */
41
+ export type Keyring = {
42
+ /**
43
+ * The name of this type of keyring. This must match the `type` property of
44
+ * the keyring class.
45
+ */
46
+ type: string;
47
+ /**
48
+ * Get the addresses for all accounts in this keyring.
49
+ *
50
+ * @returns A list of the account addresses for this keyring
51
+ */
52
+ getAccounts(): Promise<Hex[]>;
53
+ /**
54
+ * Add an account to the keyring.
55
+ *
56
+ * @param number - The number of accounts to add. Usually defaults to 1.
57
+ * @returns A list of the newly added account addresses.
58
+ */
59
+ addAccounts(number: number): Promise<Hex[]>;
60
+ /**
61
+ * Serialize the keyring state as a JSON-serializable object.
62
+ *
63
+ * @returns A JSON-serializable representation of the keyring state.
64
+ */
65
+ serialize(): Promise<Json>;
66
+ /**
67
+ * Deserialize the given keyring state, overwriting any existing state with
68
+ * the serialized state provided.
69
+ *
70
+ * @param state - A JSON-serializable representation of the keyring state.
71
+ */
72
+ deserialize(state: Json): Promise<void>;
73
+ /**
74
+ * Method to include asynchronous configuration.
75
+ */
76
+ init?(): Promise<void>;
77
+ /**
78
+ * Remove an account from the keyring.
79
+ *
80
+ * @param address - The address of the account to remove.
81
+ */
82
+ removeAccount?(address: Hex): void;
83
+ /**
84
+ * Export the private key for one of the keyring accounts.
85
+ *
86
+ * Some keyrings accept an "options" parameter as well. See the documentation
87
+ * for the specific keyring for more information about what these options
88
+ * are. For some keyrings, the options parameter is used to allow exporting a
89
+ * private key that is derived from the given account, rather than exporting
90
+ * that account's private key directly.
91
+ *
92
+ * @param address - The address of the account to export.
93
+ * @param options - Export options; differs between keyrings.
94
+ * @returns The non-prefixed, hex-encoded private key that was requested.
95
+ */
96
+ exportAccount?(address: Hex, options?: Record<string, unknown>): Promise<string>;
97
+ /**
98
+ * Get the "app key" address for the given account and origin. An app key is
99
+ * an application-specific key pair. See {@link https://eips.ethereum.org/EIPS/eip-1775|EIP-1775}
100
+ * for more information. The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin|origin}
101
+ * is used as the unique identifier for the application, and it's used as
102
+ * part of the key derivation process.
103
+ *
104
+ * @param address - The address of the account the app key is derived from.
105
+ * @param origin - The origin of the application.
106
+ * @returns The address of the app key for the given account and origin.
107
+ */
108
+ getAppKeyAddress?(address: Hex, origin: string): Promise<Hex>;
109
+ /**
110
+ * Sign a transaction. This is equivalent to the `eth_signTransaction`
111
+ * Ethereum JSON-RPC method. See the Ethereum JSON-RPC API documentation for
112
+ * more details.
113
+ *
114
+ * Some keyrings accept an "options" parameter as well. See the documentation
115
+ * for the specific keyring for more information about what these options
116
+ * are. For some keyrings, the options parameter can even change which key is
117
+ * used for signing (e.g. signing with app keys).
118
+ *
119
+ * @param address - The address of the account to use for signing.
120
+ * @param transaction - The transaction to sign.
121
+ * @param options - Signing options; differs between keyrings.
122
+ * @returns The signed transaction.
123
+ */
124
+ signTransaction?(address: Hex, transaction: TypedTransaction, options?: Record<string, unknown>): Promise<TxData>;
125
+ /**
126
+ * Sign a message. This is equivalent to an older version of the the
127
+ * `eth_sign` Ethereum JSON-RPC method. The message is signed using ECDSA,
128
+ * using the curve secp256k1 the Keccak-256 hash function.
129
+ *
130
+ * For more information about this method and why we still support it, see
131
+ * the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
132
+ *
133
+ * Some keyrings accept an "options" parameter as well. See the documentation
134
+ * for the specific keyring for more information about what these options
135
+ * are. For some keyrings, the options parameter can even change which key is
136
+ * used for signing (e.g. signing with app keys).
137
+ *
138
+ * @param address - The address of the account to use for signing.
139
+ * @param message - The message to sign.
140
+ * @param options - Signing options; differs between keyrings.
141
+ * @returns The signed message.
142
+ */
143
+ signMessage?(address: Hex, message: string, options?: Record<string, unknown>): Promise<string>;
144
+ /**
145
+ * Sign an EIP-7702 authorization. This is a signing method for authorizing a
146
+ * specific contract on a specific chain.
147
+ *
148
+ * @param address - The address of the account to use for signing.
149
+ * @param authorization - An array containing the chain ID, contract address,
150
+ * and nonce.
151
+ * @param options - Signing options; differs between keyrings.
152
+ * @returns The signed authorization as a hex string.
153
+ */
154
+ signEip7702Authorization?(address: Hex, authorization: [chainId: number, contractAddress: Hex, nonce: number], options?: Record<string, unknown>): Promise<string>;
155
+ /**
156
+ * Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC
157
+ * method, which is exposed by MetaMask as the method `personal_sign`. See
158
+ * the Ethereum JSON-RPC API documentation for more details.
159
+ *
160
+ * For more information about this method and why we call it `personal_sign`,
161
+ * see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
162
+ *
163
+ * Some keyrings accept an "options" parameter as well. See the documentation
164
+ * for the specific keyring for more information about what these options
165
+ * are. For some keyrings, the options parameter can even change which key is
166
+ * used for signing (e.g. signing with app keys).
167
+ *
168
+ * @param address - The address of the account to use for signing.
169
+ * @param message - The message to sign.
170
+ * @param options - Signing options; differs between keyrings.
171
+ * @returns The signed message.
172
+ */
173
+ signPersonalMessage?(address: Hex, message: Hex, options?: {
174
+ version?: string;
175
+ } & Record<string, unknown>): Promise<string>;
176
+ /**
177
+ * Sign a message. This is equivalent to the `eth_signTypedData` Ethereum
178
+ * JSON-RPC method. See {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md|EIP-712}
179
+ * for more details.
180
+ *
181
+ * The "version" option dictates which version of `eth_signTypedData` is
182
+ * used. The latest version reflects the specification most closely, whereas
183
+ * earlier versions reflect earlier drafts of the specification that are
184
+ * still supported for backwards-compatibility reasons. For more information
185
+ * about why we support multiple versions, see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
186
+ *
187
+ * Some keyrings accept additional options as well. See the documentation for
188
+ * the specific keyring for more information about what these options are.
189
+ * For some keyrings, the options parameter can even change which key is used
190
+ * for signing (e.g. signing with app keys).
191
+ *
192
+ * @param address - The address of the account to use for signing.
193
+ * @param typedData - The data to sign.
194
+ * @param options - Signing options; differs between keyrings.
195
+ * @returns The signed message.
196
+ */
197
+ signTypedData?(address: Hex, typedData: Record<string, unknown>, options?: Record<string, unknown>): Promise<string>;
198
+ /**
199
+ * Get a public key to use for encryption. This is equivalent to the
200
+ * ` eth_getEncryptionPublicKey` JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-getencryptionpublickey|MetaMask Docs}
201
+ * for more information.
202
+ *
203
+ * Some keyrings accept an "options" parameter as well. See the documentation
204
+ * for the specific keyring for more information about what these options
205
+ * are. For some keyrings, the options parameter can even change which key is
206
+ * used (e.g. encrypting with app keys).
207
+ *
208
+ * @param account - The address of the account you want the encryption key for.
209
+ * @param options - Options; differs between keyrings.
210
+ */
211
+ getEncryptionPublicKey?(account: Hex, options?: Record<string, unknown>): Promise<string>;
212
+ /**
213
+ * Decrypt an encrypted message. This is equivalent to the ` eth_decrypt`
214
+ * JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-decrypt|MetaMask Docs}
215
+ * for more information.
216
+ *
217
+ * @param account - The address of the account you want to use to decrypt
218
+ * the message.
219
+ * @param encryptedData - The encrypted data that you want to decrypt.
220
+ * @returns The decrypted data.
221
+ */
222
+ decryptMessage?(account: Hex, encryptedData: Eip1024EncryptedData): Promise<string>;
223
+ /**
224
+ * Generates the properties for the keyring based on the given
225
+ * BIP39-compliant mnemonic.
226
+ *
227
+ * @returns A promise resolving when the keyring has generated the properties.
228
+ */
229
+ generateRandomMnemonic?(): Promise<void>;
230
+ /**
231
+ * Destroy the keyring.
232
+ */
233
+ destroy?(): Promise<void>;
234
+ };
235
+ //# sourceMappingURL=keyring.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring.d.cts","sourceRoot":"","sources":["../src/keyring.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,235 @@
1
+ import type { TypedTransaction, TxData } from "@ethereumjs/tx";
2
+ import type { Eip1024EncryptedData, Hex, Json } from "@metamask/utils";
3
+ /**
4
+ * A Keyring class.
5
+ *
6
+ * This type is used to validate the constructor signature and the `type`
7
+ * static property on Keyring classes. See the {@link Keyring} type for more
8
+ * information.
9
+ */
10
+ export type KeyringClass = {
11
+ /**
12
+ * The Keyring constructor. Takes a single parameter, an "options" object.
13
+ * See the documentation for the specific keyring for more information about
14
+ * what these options are.
15
+ *
16
+ * @param options - The constructor options. Differs between keyring
17
+ * implementations.
18
+ */
19
+ new (options?: Record<string, unknown>): Keyring;
20
+ /**
21
+ * The name of this type of keyring. This must uniquely identify the
22
+ * keyring type.
23
+ */
24
+ type: string;
25
+ };
26
+ /**
27
+ * A keyring is something that can sign messages. Keyrings are used to add new
28
+ * signing strategies; each strategy is a new keyring.
29
+ *
30
+ * Each keyring manages a collection of key pairs, which we call "accounts".
31
+ * Each account is referred to by its "address", which is a unique identifier
32
+ * derived from the public key. The address is always a "0x"-prefixed
33
+ * hexidecimal string.
34
+ *
35
+ * The keyring might store the private key for each account as well, but it's
36
+ * not guaranteed. Some keyrings delegate signing, so they don't need the
37
+ * private key directly. The keyring (and in particular the keyring state)
38
+ * should be treated with care though, just in case it does contain sensitive
39
+ * material such as a private key.
40
+ */
41
+ export type Keyring = {
42
+ /**
43
+ * The name of this type of keyring. This must match the `type` property of
44
+ * the keyring class.
45
+ */
46
+ type: string;
47
+ /**
48
+ * Get the addresses for all accounts in this keyring.
49
+ *
50
+ * @returns A list of the account addresses for this keyring
51
+ */
52
+ getAccounts(): Promise<Hex[]>;
53
+ /**
54
+ * Add an account to the keyring.
55
+ *
56
+ * @param number - The number of accounts to add. Usually defaults to 1.
57
+ * @returns A list of the newly added account addresses.
58
+ */
59
+ addAccounts(number: number): Promise<Hex[]>;
60
+ /**
61
+ * Serialize the keyring state as a JSON-serializable object.
62
+ *
63
+ * @returns A JSON-serializable representation of the keyring state.
64
+ */
65
+ serialize(): Promise<Json>;
66
+ /**
67
+ * Deserialize the given keyring state, overwriting any existing state with
68
+ * the serialized state provided.
69
+ *
70
+ * @param state - A JSON-serializable representation of the keyring state.
71
+ */
72
+ deserialize(state: Json): Promise<void>;
73
+ /**
74
+ * Method to include asynchronous configuration.
75
+ */
76
+ init?(): Promise<void>;
77
+ /**
78
+ * Remove an account from the keyring.
79
+ *
80
+ * @param address - The address of the account to remove.
81
+ */
82
+ removeAccount?(address: Hex): void;
83
+ /**
84
+ * Export the private key for one of the keyring accounts.
85
+ *
86
+ * Some keyrings accept an "options" parameter as well. See the documentation
87
+ * for the specific keyring for more information about what these options
88
+ * are. For some keyrings, the options parameter is used to allow exporting a
89
+ * private key that is derived from the given account, rather than exporting
90
+ * that account's private key directly.
91
+ *
92
+ * @param address - The address of the account to export.
93
+ * @param options - Export options; differs between keyrings.
94
+ * @returns The non-prefixed, hex-encoded private key that was requested.
95
+ */
96
+ exportAccount?(address: Hex, options?: Record<string, unknown>): Promise<string>;
97
+ /**
98
+ * Get the "app key" address for the given account and origin. An app key is
99
+ * an application-specific key pair. See {@link https://eips.ethereum.org/EIPS/eip-1775|EIP-1775}
100
+ * for more information. The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin|origin}
101
+ * is used as the unique identifier for the application, and it's used as
102
+ * part of the key derivation process.
103
+ *
104
+ * @param address - The address of the account the app key is derived from.
105
+ * @param origin - The origin of the application.
106
+ * @returns The address of the app key for the given account and origin.
107
+ */
108
+ getAppKeyAddress?(address: Hex, origin: string): Promise<Hex>;
109
+ /**
110
+ * Sign a transaction. This is equivalent to the `eth_signTransaction`
111
+ * Ethereum JSON-RPC method. See the Ethereum JSON-RPC API documentation for
112
+ * more details.
113
+ *
114
+ * Some keyrings accept an "options" parameter as well. See the documentation
115
+ * for the specific keyring for more information about what these options
116
+ * are. For some keyrings, the options parameter can even change which key is
117
+ * used for signing (e.g. signing with app keys).
118
+ *
119
+ * @param address - The address of the account to use for signing.
120
+ * @param transaction - The transaction to sign.
121
+ * @param options - Signing options; differs between keyrings.
122
+ * @returns The signed transaction.
123
+ */
124
+ signTransaction?(address: Hex, transaction: TypedTransaction, options?: Record<string, unknown>): Promise<TxData>;
125
+ /**
126
+ * Sign a message. This is equivalent to an older version of the the
127
+ * `eth_sign` Ethereum JSON-RPC method. The message is signed using ECDSA,
128
+ * using the curve secp256k1 the Keccak-256 hash function.
129
+ *
130
+ * For more information about this method and why we still support it, see
131
+ * the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
132
+ *
133
+ * Some keyrings accept an "options" parameter as well. See the documentation
134
+ * for the specific keyring for more information about what these options
135
+ * are. For some keyrings, the options parameter can even change which key is
136
+ * used for signing (e.g. signing with app keys).
137
+ *
138
+ * @param address - The address of the account to use for signing.
139
+ * @param message - The message to sign.
140
+ * @param options - Signing options; differs between keyrings.
141
+ * @returns The signed message.
142
+ */
143
+ signMessage?(address: Hex, message: string, options?: Record<string, unknown>): Promise<string>;
144
+ /**
145
+ * Sign an EIP-7702 authorization. This is a signing method for authorizing a
146
+ * specific contract on a specific chain.
147
+ *
148
+ * @param address - The address of the account to use for signing.
149
+ * @param authorization - An array containing the chain ID, contract address,
150
+ * and nonce.
151
+ * @param options - Signing options; differs between keyrings.
152
+ * @returns The signed authorization as a hex string.
153
+ */
154
+ signEip7702Authorization?(address: Hex, authorization: [chainId: number, contractAddress: Hex, nonce: number], options?: Record<string, unknown>): Promise<string>;
155
+ /**
156
+ * Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC
157
+ * method, which is exposed by MetaMask as the method `personal_sign`. See
158
+ * the Ethereum JSON-RPC API documentation for more details.
159
+ *
160
+ * For more information about this method and why we call it `personal_sign`,
161
+ * see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
162
+ *
163
+ * Some keyrings accept an "options" parameter as well. See the documentation
164
+ * for the specific keyring for more information about what these options
165
+ * are. For some keyrings, the options parameter can even change which key is
166
+ * used for signing (e.g. signing with app keys).
167
+ *
168
+ * @param address - The address of the account to use for signing.
169
+ * @param message - The message to sign.
170
+ * @param options - Signing options; differs between keyrings.
171
+ * @returns The signed message.
172
+ */
173
+ signPersonalMessage?(address: Hex, message: Hex, options?: {
174
+ version?: string;
175
+ } & Record<string, unknown>): Promise<string>;
176
+ /**
177
+ * Sign a message. This is equivalent to the `eth_signTypedData` Ethereum
178
+ * JSON-RPC method. See {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md|EIP-712}
179
+ * for more details.
180
+ *
181
+ * The "version" option dictates which version of `eth_signTypedData` is
182
+ * used. The latest version reflects the specification most closely, whereas
183
+ * earlier versions reflect earlier drafts of the specification that are
184
+ * still supported for backwards-compatibility reasons. For more information
185
+ * about why we support multiple versions, see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.
186
+ *
187
+ * Some keyrings accept additional options as well. See the documentation for
188
+ * the specific keyring for more information about what these options are.
189
+ * For some keyrings, the options parameter can even change which key is used
190
+ * for signing (e.g. signing with app keys).
191
+ *
192
+ * @param address - The address of the account to use for signing.
193
+ * @param typedData - The data to sign.
194
+ * @param options - Signing options; differs between keyrings.
195
+ * @returns The signed message.
196
+ */
197
+ signTypedData?(address: Hex, typedData: Record<string, unknown>, options?: Record<string, unknown>): Promise<string>;
198
+ /**
199
+ * Get a public key to use for encryption. This is equivalent to the
200
+ * ` eth_getEncryptionPublicKey` JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-getencryptionpublickey|MetaMask Docs}
201
+ * for more information.
202
+ *
203
+ * Some keyrings accept an "options" parameter as well. See the documentation
204
+ * for the specific keyring for more information about what these options
205
+ * are. For some keyrings, the options parameter can even change which key is
206
+ * used (e.g. encrypting with app keys).
207
+ *
208
+ * @param account - The address of the account you want the encryption key for.
209
+ * @param options - Options; differs between keyrings.
210
+ */
211
+ getEncryptionPublicKey?(account: Hex, options?: Record<string, unknown>): Promise<string>;
212
+ /**
213
+ * Decrypt an encrypted message. This is equivalent to the ` eth_decrypt`
214
+ * JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-decrypt|MetaMask Docs}
215
+ * for more information.
216
+ *
217
+ * @param account - The address of the account you want to use to decrypt
218
+ * the message.
219
+ * @param encryptedData - The encrypted data that you want to decrypt.
220
+ * @returns The decrypted data.
221
+ */
222
+ decryptMessage?(account: Hex, encryptedData: Eip1024EncryptedData): Promise<string>;
223
+ /**
224
+ * Generates the properties for the keyring based on the given
225
+ * BIP39-compliant mnemonic.
226
+ *
227
+ * @returns A promise resolving when the keyring has generated the properties.
228
+ */
229
+ generateRandomMnemonic?(): Promise<void>;
230
+ /**
231
+ * Destroy the keyring.
232
+ */
233
+ destroy?(): Promise<void>;
234
+ };
235
+ //# sourceMappingURL=keyring.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring.d.mts","sourceRoot":"","sources":["../src/keyring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,uBAAuB;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,GAAG,EAAE,IAAI,EAAE,wBAAwB;AAEvE;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;;;OAOG;IACH,KAAK,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAEjD;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE9B;;;;;OAKG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAE5C;;;;OAIG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3B;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC;;OAEG;IACH,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;;OAIG;IACH,aAAa,CAAC,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IAEnC;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,CACZ,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9D;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,CACd,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,CACV,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;;;;;OASG;IACH,wBAAwB,CAAC,CACvB,OAAO,EAAE,GAAG,EACZ,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,EACrE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;;;;;;;;;;;;;OAiBG;IACH,mBAAmB,CAAC,CAClB,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvD,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,aAAa,CAAC,CACZ,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;;;;;;;;OAYG;IACH,sBAAsB,CAAC,CACrB,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;;;;;OASG;IACH,cAAc,CAAC,CACb,OAAO,EAAE,GAAG,EACZ,aAAa,EAAE,oBAAoB,GAClC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;;OAKG;IACH,sBAAsB,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzC;;OAEG;IACH,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=keyring.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyring.mjs","sourceRoot":"","sources":["../src/keyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { TypedTransaction, TxData } from '@ethereumjs/tx';\nimport type { Eip1024EncryptedData, Hex, Json } from '@metamask/utils';\n\n/**\n * A Keyring class.\n *\n * This type is used to validate the constructor signature and the `type`\n * static property on Keyring classes. See the {@link Keyring} type for more\n * information.\n */\nexport type KeyringClass = {\n /**\n * The Keyring constructor. Takes a single parameter, an \"options\" object.\n * See the documentation for the specific keyring for more information about\n * what these options are.\n *\n * @param options - The constructor options. Differs between keyring\n * implementations.\n */\n new (options?: Record<string, unknown>): Keyring;\n\n /**\n * The name of this type of keyring. This must uniquely identify the\n * keyring type.\n */\n type: string;\n};\n\n/**\n * A keyring is something that can sign messages. Keyrings are used to add new\n * signing strategies; each strategy is a new keyring.\n *\n * Each keyring manages a collection of key pairs, which we call \"accounts\".\n * Each account is referred to by its \"address\", which is a unique identifier\n * derived from the public key. The address is always a \"0x\"-prefixed\n * hexidecimal string.\n *\n * The keyring might store the private key for each account as well, but it's\n * not guaranteed. Some keyrings delegate signing, so they don't need the\n * private key directly. The keyring (and in particular the keyring state)\n * should be treated with care though, just in case it does contain sensitive\n * material such as a private key.\n */\nexport type Keyring = {\n /**\n * The name of this type of keyring. This must match the `type` property of\n * the keyring class.\n */\n type: string;\n\n /**\n * Get the addresses for all accounts in this keyring.\n *\n * @returns A list of the account addresses for this keyring\n */\n getAccounts(): Promise<Hex[]>;\n\n /**\n * Add an account to the keyring.\n *\n * @param number - The number of accounts to add. Usually defaults to 1.\n * @returns A list of the newly added account addresses.\n */\n addAccounts(number: number): Promise<Hex[]>;\n\n /**\n * Serialize the keyring state as a JSON-serializable object.\n *\n * @returns A JSON-serializable representation of the keyring state.\n */\n serialize(): Promise<Json>;\n\n /**\n * Deserialize the given keyring state, overwriting any existing state with\n * the serialized state provided.\n *\n * @param state - A JSON-serializable representation of the keyring state.\n */\n deserialize(state: Json): Promise<void>;\n\n /**\n * Method to include asynchronous configuration.\n */\n init?(): Promise<void>;\n\n /**\n * Remove an account from the keyring.\n *\n * @param address - The address of the account to remove.\n */\n removeAccount?(address: Hex): void;\n\n /**\n * Export the private key for one of the keyring accounts.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter is used to allow exporting a\n * private key that is derived from the given account, rather than exporting\n * that account's private key directly.\n *\n * @param address - The address of the account to export.\n * @param options - Export options; differs between keyrings.\n * @returns The non-prefixed, hex-encoded private key that was requested.\n */\n exportAccount?(\n address: Hex,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Get the \"app key\" address for the given account and origin. An app key is\n * an application-specific key pair. See {@link https://eips.ethereum.org/EIPS/eip-1775|EIP-1775}\n * for more information. The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin|origin}\n * is used as the unique identifier for the application, and it's used as\n * part of the key derivation process.\n *\n * @param address - The address of the account the app key is derived from.\n * @param origin - The origin of the application.\n * @returns The address of the app key for the given account and origin.\n */\n getAppKeyAddress?(address: Hex, origin: string): Promise<Hex>;\n\n /**\n * Sign a transaction. This is equivalent to the `eth_signTransaction`\n * Ethereum JSON-RPC method. See the Ethereum JSON-RPC API documentation for\n * more details.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param transaction - The transaction to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed transaction.\n */\n signTransaction?(\n address: Hex,\n transaction: TypedTransaction,\n options?: Record<string, unknown>,\n ): Promise<TxData>;\n\n /**\n * Sign a message. This is equivalent to an older version of the the\n * `eth_sign` Ethereum JSON-RPC method. The message is signed using ECDSA,\n * using the curve secp256k1 the Keccak-256 hash function.\n *\n * For more information about this method and why we still support it, see\n * the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param message - The message to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signMessage?(\n address: Hex,\n message: string,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign an EIP-7702 authorization. This is a signing method for authorizing a\n * specific contract on a specific chain.\n *\n * @param address - The address of the account to use for signing.\n * @param authorization - An array containing the chain ID, contract address,\n * and nonce.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed authorization as a hex string.\n */\n signEip7702Authorization?(\n address: Hex,\n authorization: [chainId: number, contractAddress: Hex, nonce: number],\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign a message. This is equivalent to the `eth_sign` Ethereum JSON-RPC\n * method, which is exposed by MetaMask as the method `personal_sign`. See\n * the Ethereum JSON-RPC API documentation for more details.\n *\n * For more information about this method and why we call it `personal_sign`,\n * see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param message - The message to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signPersonalMessage?(\n address: Hex,\n message: Hex,\n options?: { version?: string } & Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Sign a message. This is equivalent to the `eth_signTypedData` Ethereum\n * JSON-RPC method. See {@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md|EIP-712}\n * for more details.\n *\n * The \"version\" option dictates which version of `eth_signTypedData` is\n * used. The latest version reflects the specification most closely, whereas\n * earlier versions reflect earlier drafts of the specification that are\n * still supported for backwards-compatibility reasons. For more information\n * about why we support multiple versions, see the {@link https://docs.metamask.io/guide/signing-data.html|MetaMask Docs}.\n *\n * Some keyrings accept additional options as well. See the documentation for\n * the specific keyring for more information about what these options are.\n * For some keyrings, the options parameter can even change which key is used\n * for signing (e.g. signing with app keys).\n *\n * @param address - The address of the account to use for signing.\n * @param typedData - The data to sign.\n * @param options - Signing options; differs between keyrings.\n * @returns The signed message.\n */\n signTypedData?(\n address: Hex,\n typedData: Record<string, unknown>,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Get a public key to use for encryption. This is equivalent to the\n * ` eth_getEncryptionPublicKey` JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-getencryptionpublickey|MetaMask Docs}\n * for more information.\n *\n * Some keyrings accept an \"options\" parameter as well. See the documentation\n * for the specific keyring for more information about what these options\n * are. For some keyrings, the options parameter can even change which key is\n * used (e.g. encrypting with app keys).\n *\n * @param account - The address of the account you want the encryption key for.\n * @param options - Options; differs between keyrings.\n */\n getEncryptionPublicKey?(\n account: Hex,\n options?: Record<string, unknown>,\n ): Promise<string>;\n\n /**\n * Decrypt an encrypted message. This is equivalent to the ` eth_decrypt`\n * JSON-RPC method. See the {@link https://docs.metamask.io/guide/rpc-api.html#eth-decrypt|MetaMask Docs}\n * for more information.\n *\n * @param account - The address of the account you want to use to decrypt\n * the message.\n * @param encryptedData - The encrypted data that you want to decrypt.\n * @returns The decrypted data.\n */\n decryptMessage?(\n account: Hex,\n encryptedData: Eip1024EncryptedData,\n ): Promise<string>;\n\n /**\n * Generates the properties for the keyring based on the given\n * BIP39-compliant mnemonic.\n *\n * @returns A promise resolving when the keyring has generated the properties.\n */\n generateRandomMnemonic?(): Promise<void>;\n\n /**\n * Destroy the keyring.\n */\n destroy?(): Promise<void>;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/keyring-utils",
3
- "version": "2.0.0-776292e",
3
+ "version": "2.0.0-d9aa015",
4
4
  "description": "MetaMask Keyring utils",
5
5
  "keywords": [
6
6
  "metamask",
@@ -45,6 +45,7 @@
45
45
  "test:watch": "jest --watch"
46
46
  },
47
47
  "dependencies": {
48
+ "@ethereumjs/tx": "^4.2.0",
48
49
  "@metamask/superstruct": "^3.1.0",
49
50
  "@metamask/utils": "^11.1.0",
50
51
  "bitcoin-address-validation": "^2.2.3"