File tree Expand file tree Collapse file tree
new-deepnotes/packages/e2ee/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ import { argon2id } from "@noble/hashes/argon2.js";
22
33import { wrapSymmetricKey } from "./symmetric-key.js" ;
44
5+ /** Fast Argon2 params in test environments; production hardness unchanged. */
6+ const isTestEnv =
7+ typeof process !== "undefined" && process . env ?. VITEST === "true" ;
8+
59/** Legacy nanoid alphabet (must match `@stdlib/misc` / client). */
610const alphabet =
711 "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict" ;
@@ -54,8 +58,8 @@ export function deriveGroupPasswordValues(
5458 const salt = nanoidToBytes ( groupId ) ;
5559
5660 const derivedKey = argon2id ( new TextEncoder ( ) . encode ( password ) , salt , {
57- t : 8 , // iterations
58- m : 32 * 1024 , // memory in KB (32MB)
61+ t : isTestEnv ? 1 : 8 , // iterations
62+ m : isTestEnv ? 64 * 1024 : 32 * 1024 , // memory in KB
5963 p : 1 , // parallelism
6064 dkLen : 32 + 64 , // output length
6165 } ) ;
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ import { argon2id } from "@noble/hashes/argon2.js";
22
33import { wrapSymmetricKey } from "./symmetric-key.js" ;
44
5+ /** Fast Argon2 params in test environments; production hardness unchanged. */
6+ const isTestEnv =
7+ typeof process !== "undefined" && process . env ?. VITEST === "true" ;
8+
59const SALT_SIZE = 16 ;
610
711function getRandomBytes ( length : number ) : Uint8Array {
@@ -24,8 +28,8 @@ export function derivePasswordValues(input: {
2428 input . salt ??= getRandomBytes ( SALT_SIZE ) ;
2529
2630 const derivedKey = argon2id ( input . password , input . salt , {
27- t : 2 , // iterations
28- m : 32 * 1024 , // memory in KB (32MB)
31+ t : isTestEnv ? 1 : 2 , // iterations
32+ m : isTestEnv ? 64 * 1024 : 32 * 1024 , // memory in KB
2933 p : 1 , // parallelism
3034 dkLen : 32 + 64 , // output length
3135 } ) ;
You can’t perform that action at this time.
0 commit comments