@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otoplo/wallet-common",
3
- "version": "0.1.3",
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 { pbkdf2Async } from "@noble/hashes/pbkdf2.js";
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
- async function deriveKey(password: string, salt: Uint8Array): Promise<Uint8Array> {
17
- return pbkdf2Async(sha256, password, salt, { c: 600_000, dkLen: 32 });
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 | boolean> {
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);