@majikah/majik-key 0.1.9 → 0.1.10
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.
|
@@ -10,6 +10,7 @@ import { arrayToBase64 } from "../utils";
|
|
|
10
10
|
import { argon2id as nobleArgon2id } from "@noble/hashes/argon2.js";
|
|
11
11
|
import { ARGON2_PARAMS } from "./constants";
|
|
12
12
|
import { ml_kem768 } from "@noble/post-quantum/ml-kem.js";
|
|
13
|
+
import { argon2id as hashWasmArgon2id } from "hash-wasm";
|
|
13
14
|
export const IV_LENGTH = 12;
|
|
14
15
|
export function generateRandomBytes(len) {
|
|
15
16
|
const b = new Uint8Array(len);
|
|
@@ -60,10 +61,12 @@ export function aesGcmDecrypt(keyBytes, iv, ciphertext) {
|
|
|
60
61
|
*/
|
|
61
62
|
let _wasmAvailable = null;
|
|
62
63
|
async function _probeWasm() {
|
|
64
|
+
// Never run WASM probe on server — KDF only runs client-side
|
|
65
|
+
if (typeof window === "undefined")
|
|
66
|
+
return false;
|
|
63
67
|
try {
|
|
64
|
-
const { argon2id } = await import("hash-wasm");
|
|
65
68
|
// Cheap smoke-test: tiny params, just proves the WASM module loads & runs
|
|
66
|
-
await
|
|
69
|
+
await hashWasmArgon2id({
|
|
67
70
|
password: new Uint8Array(4),
|
|
68
71
|
salt: new Uint8Array(8),
|
|
69
72
|
memorySize: 8,
|
|
@@ -79,14 +82,13 @@ async function _probeWasm() {
|
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
async function _argon2idWasm(input, salt, params) {
|
|
82
|
-
|
|
83
|
-
return argon2id({
|
|
85
|
+
return hashWasmArgon2id({
|
|
84
86
|
password: input,
|
|
85
87
|
salt,
|
|
86
|
-
memorySize: params.m,
|
|
87
|
-
iterations: params.t,
|
|
88
|
-
parallelism: params.p,
|
|
89
|
-
hashLength: params.dkLen,
|
|
88
|
+
memorySize: params.m,
|
|
89
|
+
iterations: params.t,
|
|
90
|
+
parallelism: params.p,
|
|
91
|
+
hashLength: params.dkLen,
|
|
90
92
|
outputType: "binary",
|
|
91
93
|
});
|
|
92
94
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@majikah/majik-key",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "A post-quantum ready seed phrase account library for the Majikah ecosystem. Manages deterministic X25519 and ML-KEM-768 identities with Argon2id protection and seamless legacy account migration.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.10",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Zelijah",
|
|
8
8
|
"main": "./dist/index.js",
|