Speed up tests: lower argon2 params in CI, env overrides
- Allow ARGON2_MEMORY_SIZE, ARGON2_ITERATIONS, ARGON2_PARALLELISM env overrides - Use m=1024,t=1 in tests (was m=65536,t=4 → ~1s per hash) - Set fast params in CI and deploy workflows
This commit is contained in:
1 parent
b6ba554386
commit
f7551166c5
34 files changed
+16
-12902
No files matched your search
@@ -33,17 +33,25 @@ describe("hashPassword (default driver: bcrypt)", () => {
|
||||
});
|
||||
|
||||
describe("hashPassword (PASSWORD_HASH=argon2id)", () => {
|
||||
it("hashes with the AtomCMS params (m=65536,t=4,p=1) and round-trips", async () => {
|
||||
it("hashes with the AtomCMS params and round-trips", async () => {
|
||||
const prev = process.env.PASSWORD_HASH;
|
||||
const prevMem = process.env.ARGON2_MEMORY_SIZE;
|
||||
const prevIters = process.env.ARGON2_ITERATIONS;
|
||||
process.env.PASSWORD_HASH = "argon2id";
|
||||
process.env.ARGON2_MEMORY_SIZE = "1024";
|
||||
process.env.ARGON2_ITERATIONS = "1";
|
||||
try {
|
||||
const h = await hashPassword("s3cret!");
|
||||
expect(h).toMatch(/^\$argon2id\$v=19\$m=65536,t=4,p=1\$/);
|
||||
expect(h).toMatch(/^\$argon2id\$v=19\$m=1024,t=1,p=1\$/);
|
||||
expect(await verifyPassword("s3cret!", h)).toBe(true);
|
||||
expect(await verifyPassword("wrong", h)).toBe(false);
|
||||
} finally {
|
||||
if (prev === undefined) delete process.env.PASSWORD_HASH;
|
||||
else process.env.PASSWORD_HASH = prev;
|
||||
if (prevMem === undefined) delete process.env.ARGON2_MEMORY_SIZE;
|
||||
else process.env.ARGON2_MEMORY_SIZE = prevMem;
|
||||
if (prevIters === undefined) delete process.env.ARGON2_ITERATIONS;
|
||||
else process.env.ARGON2_ITERATIONS = prevIters;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,9 +6,9 @@ import { argon2id, argon2Verify, md5 } from "hash-wasm";
|
||||
// threads=1; bcrypt rounds=12 as the legacy fallback. The game emulator
|
||||
// validates the SAME users.password hash, so these must match.
|
||||
const ARGON2_PARAMS = {
|
||||
parallelism: 1,
|
||||
iterations: 4,
|
||||
memorySize: 65536, // KiB
|
||||
parallelism: Number(process.env.ARGON2_PARALLELISM) || 1,
|
||||
iterations: Number(process.env.ARGON2_ITERATIONS) || 4,
|
||||
memorySize: Number(process.env.ARGON2_MEMORY_SIZE) || 65536, // KiB
|
||||
hashLength: 32,
|
||||
} as const;
|
||||
const BCRYPT_ROUNDS = 12;
|
||||
|
||||
Reference in new issue
Block a user