@swapkit/wallet-keystore 1.8.0 → 1.8.2

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,14 +1,14 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@scure/bip39": "1.5.4",
4
- "@swapkit/helpers": "2.7.4",
5
- "@swapkit/toolbox-cosmos": "1.11.6",
6
- "@swapkit/toolbox-evm": "1.10.4",
7
- "@swapkit/toolbox-radix": "1.3.4",
8
- "@swapkit/toolbox-ripple": "1.0.7",
9
- "@swapkit/toolbox-solana": "1.6.4",
10
- "@swapkit/toolbox-substrate": "1.4.4",
11
- "@swapkit/toolbox-utxo": "1.4.4",
4
+ "@swapkit/helpers": "2.7.5",
5
+ "@swapkit/toolbox-cosmos": "1.11.8",
6
+ "@swapkit/toolbox-evm": "1.10.5",
7
+ "@swapkit/toolbox-radix": "1.3.5",
8
+ "@swapkit/toolbox-ripple": "1.0.8",
9
+ "@swapkit/toolbox-solana": "1.6.5",
10
+ "@swapkit/toolbox-substrate": "1.4.5",
11
+ "@swapkit/toolbox-utxo": "1.4.5",
12
12
  "blakejs": "1.2.1",
13
13
  "micro-key-producer": "0.7.5"
14
14
  },
@@ -35,5 +35,5 @@
35
35
  },
36
36
  "type": "module",
37
37
  "types": "./src/index.ts",
38
- "version": "1.8.0"
38
+ "version": "1.8.2"
39
39
  }
package/src/helpers.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as crypto from "node:crypto";
1
+ import { createCipheriv, createDecipheriv, pbkdf2, randomBytes } from "node:crypto";
2
2
  import { generateMnemonic, validateMnemonic } from "@scure/bip39";
3
3
  import { wordlist } from "@scure/bip39/wordlists/english";
4
4
  import blakejs from "blakejs";
@@ -50,7 +50,7 @@ const pbkdf2Async = (
50
50
  digest: string,
51
51
  ) =>
52
52
  new Promise<Buffer>((resolve, reject) => {
53
- crypto.pbkdf2(passphrase, salt, iterations, keylen, digest, (error, drived) => {
53
+ pbkdf2(passphrase, salt, iterations, keylen, digest, (error, drived) => {
54
54
  if (error) {
55
55
  reject(error);
56
56
  } else {
@@ -60,8 +60,8 @@ const pbkdf2Async = (
60
60
  });
61
61
 
62
62
  export const encryptToKeyStore = async (phrase: string, password: string) => {
63
- const salt = crypto.randomBytes(32);
64
- const iv = crypto.randomBytes(16);
63
+ const salt = randomBytes(32);
64
+ const iv = randomBytes(16);
65
65
  const kdfParams = { c: 262144, prf: "hmac-sha256", dklen: 32, salt: salt.toString("hex") };
66
66
  const cipher = "aes-128-ctr";
67
67
 
@@ -72,7 +72,7 @@ export const encryptToKeyStore = async (phrase: string, password: string) => {
72
72
  kdfParams.dklen,
73
73
  "sha256",
74
74
  );
75
- const cipherIV = crypto.createCipheriv(cipher, derivedKey.subarray(0, 16), iv);
75
+ const cipherIV = createCipheriv(cipher, derivedKey.subarray(0, 16), iv);
76
76
  const ciphertext = Buffer.concat([
77
77
  cipherIV.update(Buffer.from(phrase, "utf8")),
78
78
  cipherIV.final(),
@@ -116,7 +116,7 @@ export const decryptFromKeystore = async (keystore: Keystore, password: string)
116
116
  const mac = blake256(Buffer.concat([derivedKey.subarray(16, 32), ciphertext]));
117
117
 
118
118
  if (mac !== keystore.crypto.mac) throw new Error("Invalid password");
119
- const decipher = crypto.createDecipheriv(
119
+ const decipher = createDecipheriv(
120
120
  keystore.crypto.cipher,
121
121
  derivedKey.subarray(0, 16),
122
122
  Buffer.from(keystore.crypto.cipherparams.iv, "hex"),