@otoplo/wallet-common 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +140 -141
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/utils/seed.ts +4 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@otoplo/wallet-common",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Shared common library for internal use in Otoplo wallet",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "vgrunner",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "https://gitlab.com/nexa/otoplo/otoplo-wallet-common"
|
|
31
|
+
"url": "git+https://gitlab.com/nexa/otoplo/otoplo-wallet-common.git"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@noble/ciphers": "^2.1.1",
|
package/src/utils/seed.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { gcm } from "@noble/ciphers/aes.js";
|
|
2
|
-
import {
|
|
3
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
|
+
import { argon2idAsync } from "@noble/hashes/argon2.js";
|
|
4
3
|
import { generateMnemonic, validateMnemonic } from "@scure/bip39";
|
|
5
4
|
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
6
5
|
import { BufferUtils } from "libnexa-ts";
|
|
@@ -13,8 +12,8 @@ export function isMnemonicValid(mnemonic: string): boolean {
|
|
|
13
12
|
return validateMnemonic(mnemonic, wordlist);
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
return
|
|
15
|
+
function deriveKey(password: string, salt: Uint8Array): Promise<Uint8Array> {
|
|
16
|
+
return argon2idAsync(password, salt, { t: 2, m: 19456, p: 1, dkLen: 32 });
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
export async function encryptMnemonic(phrase: string, password: string): Promise<string> {
|
|
@@ -42,7 +41,7 @@ async function decryptMnemonic(encSeed: string, password: string): Promise<strin
|
|
|
42
41
|
return BufferUtils.bufferToUtf8(data);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
export async function validateAndDecryptMnemonic(encSeed: string, password: string): Promise<string |
|
|
44
|
+
export async function validateAndDecryptMnemonic(encSeed: string, password: string): Promise<string | false> {
|
|
46
45
|
try {
|
|
47
46
|
if (encSeed) {
|
|
48
47
|
const decMn = await decryptMnemonic(encSeed, password);
|