@talismn/keyring 0.0.0-pr1827-20250314021218 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -8,5 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
**@talismn/keyring** is a basic keyring implementation used by the Talisman wallet.
|
|
10
10
|
|
|
11
|
+
This keyring is not ecosystem specific. As such, it does not provide any signing functionality, and is only used to store accounts and mnemonics.
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
11
15
|
> ⚠️ This package relies on the browser's native crypto API for encryption and decryption. It is designed for use in modern browsers—Talisman wallet runs on Chromium v102+ and Firefox v109+ at the time of writing.
|
|
12
16
|
> Using this library in environments with weaker crypto API implementations, particularly for random number generation, may introduce security risks.
|
|
@@ -27,6 +27,15 @@ export declare class Keyring {
|
|
|
27
27
|
updateAccount(address: string, { name, isPortfolio, genesisHash }: UpdateAccountOptions): Account;
|
|
28
28
|
removeAccount(address: string): void;
|
|
29
29
|
addAccountExternal(options: AddAccountExternalOptions): Account;
|
|
30
|
+
/**
|
|
31
|
+
* Needs to be called before deriving an account from a mnemonic.
|
|
32
|
+
*
|
|
33
|
+
* This will ensure that it is present (or add it if possible) in the keyring before actually creating the account.
|
|
34
|
+
*
|
|
35
|
+
* @param options
|
|
36
|
+
* @param password
|
|
37
|
+
* @returns the id of the mnemonic
|
|
38
|
+
*/
|
|
30
39
|
private ensureMnemonic;
|
|
31
40
|
addAccountDerive(options: AddAccountDeriveOptions, password: string): Promise<Account>;
|
|
32
41
|
addAccountKeypair({ curve, name, secretKey }: AddAccountKeypairOptions, password: string): Promise<Account>;
|
|
@@ -258,7 +258,7 @@ class Keyring {
|
|
|
258
258
|
account.name = name;
|
|
259
259
|
}
|
|
260
260
|
if (account.type === "watch-only" && isPortfolio !== undefined) {
|
|
261
|
-
if (typeof isPortfolio !== "boolean") throw new Error("
|
|
261
|
+
if (typeof isPortfolio !== "boolean") throw new Error("isPortfolio must be a boolean");
|
|
262
262
|
account.isPortfolio = isPortfolio;
|
|
263
263
|
}
|
|
264
264
|
// allow updating genesisHash only for contacts
|
|
@@ -286,6 +286,16 @@ class Keyring {
|
|
|
286
286
|
this.#data.accounts.push(account);
|
|
287
287
|
return accountFromStorage(account);
|
|
288
288
|
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Needs to be called before deriving an account from a mnemonic.
|
|
292
|
+
*
|
|
293
|
+
* This will ensure that it is present (or add it if possible) in the keyring before actually creating the account.
|
|
294
|
+
*
|
|
295
|
+
* @param options
|
|
296
|
+
* @param password
|
|
297
|
+
* @returns the id of the mnemonic
|
|
298
|
+
*/
|
|
289
299
|
async ensureMnemonic(options, password) {
|
|
290
300
|
await this.checkPassword(password);
|
|
291
301
|
switch (options.type) {
|
|
@@ -258,7 +258,7 @@ class Keyring {
|
|
|
258
258
|
account.name = name;
|
|
259
259
|
}
|
|
260
260
|
if (account.type === "watch-only" && isPortfolio !== undefined) {
|
|
261
|
-
if (typeof isPortfolio !== "boolean") throw new Error("
|
|
261
|
+
if (typeof isPortfolio !== "boolean") throw new Error("isPortfolio must be a boolean");
|
|
262
262
|
account.isPortfolio = isPortfolio;
|
|
263
263
|
}
|
|
264
264
|
// allow updating genesisHash only for contacts
|
|
@@ -286,6 +286,16 @@ class Keyring {
|
|
|
286
286
|
this.#data.accounts.push(account);
|
|
287
287
|
return accountFromStorage(account);
|
|
288
288
|
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Needs to be called before deriving an account from a mnemonic.
|
|
292
|
+
*
|
|
293
|
+
* This will ensure that it is present (or add it if possible) in the keyring before actually creating the account.
|
|
294
|
+
*
|
|
295
|
+
* @param options
|
|
296
|
+
* @param password
|
|
297
|
+
* @returns the id of the mnemonic
|
|
298
|
+
*/
|
|
289
299
|
async ensureMnemonic(options, password) {
|
|
290
300
|
await this.checkPassword(password);
|
|
291
301
|
switch (options.type) {
|
|
@@ -256,7 +256,7 @@ class Keyring {
|
|
|
256
256
|
account.name = name;
|
|
257
257
|
}
|
|
258
258
|
if (account.type === "watch-only" && isPortfolio !== undefined) {
|
|
259
|
-
if (typeof isPortfolio !== "boolean") throw new Error("
|
|
259
|
+
if (typeof isPortfolio !== "boolean") throw new Error("isPortfolio must be a boolean");
|
|
260
260
|
account.isPortfolio = isPortfolio;
|
|
261
261
|
}
|
|
262
262
|
// allow updating genesisHash only for contacts
|
|
@@ -284,6 +284,16 @@ class Keyring {
|
|
|
284
284
|
this.#data.accounts.push(account);
|
|
285
285
|
return accountFromStorage(account);
|
|
286
286
|
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Needs to be called before deriving an account from a mnemonic.
|
|
290
|
+
*
|
|
291
|
+
* This will ensure that it is present (or add it if possible) in the keyring before actually creating the account.
|
|
292
|
+
*
|
|
293
|
+
* @param options
|
|
294
|
+
* @param password
|
|
295
|
+
* @returns the id of the mnemonic
|
|
296
|
+
*/
|
|
287
297
|
async ensureMnemonic(options, password) {
|
|
288
298
|
await this.checkPassword(password);
|
|
289
299
|
switch (options.type) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talismn/keyring",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"author": "Talisman",
|
|
5
5
|
"homepage": "https://talisman.xyz",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">=18"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@talismn/crypto": "0.
|
|
25
|
+
"@talismn/crypto": "0.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/jest": "^29.5.14",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"jest-fixed-jsdom": "^0.0.9",
|
|
32
32
|
"ts-jest": "^29.2.5",
|
|
33
33
|
"typescript": "^5.6.3",
|
|
34
|
-
"@talismn/
|
|
35
|
-
"@talismn/
|
|
34
|
+
"@talismn/tsconfig": "0.0.2",
|
|
35
|
+
"@talismn/eslint-config": "0.0.3"
|
|
36
36
|
},
|
|
37
37
|
"preconstruct": {
|
|
38
38
|
"entrypoints": [
|