@majikah/majik-key 0.2.0 → 0.2.1

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.
@@ -51,7 +51,8 @@ export function aesGcmEncrypt(keyBytes, iv, plaintext) {
51
51
  export function aesGcmDecrypt(keyBytes, iv, ciphertext) {
52
52
  const aes = new AES(keyBytes);
53
53
  const gcm = new GCM(aes);
54
- return gcm.open(iv, ciphertext);
54
+ const result = gcm.open(iv, ciphertext);
55
+ return result ? result.slice() : null;
55
56
  }
56
57
  // ─── WASM-first Argon2id with @noble/hashes fallback ─────────────────────────
57
58
  /**
@@ -132,7 +133,8 @@ async function _argon2id(input, salt, params) {
132
133
  */
133
134
  export async function deriveKeyFromPassphraseArgon2(passphrase, salt) {
134
135
  const pw = new TextEncoder().encode(passphrase);
135
- return _argon2id(pw, salt, ARGON2_PARAMS.PASSPHRASE);
136
+ const result = await _argon2id(pw, salt, ARGON2_PARAMS.PASSPHRASE);
137
+ return result.slice(); // ← force a copy out of WASM memory
136
138
  }
137
139
  /**
138
140
  * Derive a 32-byte AES key from a BIP-39 mnemonic using Argon2id.
@@ -144,7 +146,8 @@ export async function deriveKeyFromPassphraseArgon2(passphrase, salt) {
144
146
  */
145
147
  export async function deriveKeyFromMnemonicArgon2(mnemonic, salt) {
146
148
  const m = new TextEncoder().encode(mnemonic);
147
- return _argon2id(m, salt, ARGON2_PARAMS.MNEMONIC);
149
+ const result = await _argon2id(m, salt, ARGON2_PARAMS.MNEMONIC);
150
+ return result.slice(); // ← force a copy out of WASM memory
148
151
  }
149
152
  // ─── KDF v1: PBKDF2-SHA256 (legacy — do not use for new operations) ───────────
150
153
  /**
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.2.0",
5
+ "version": "0.2.1",
6
6
  "license": "Apache-2.0",
7
7
  "author": "Zelijah",
8
8
  "main": "./dist/index.js",