import { hash, verify } from "@node-rs/argon2"; const OPTS = { algorithm: 2 /* Argon2id */, memoryCost: 65536, timeCost: 3, parallelism: 1, outputLen: 32 }; export const hashPassword = (pw: string) => hash(pw, OPTS); export const verifyPassword = (h: string, pw: string) => verify(h, pw).catch(() => false); export function passwordPolicy(pw: string): string | null { if (pw.length < 14) return "Password must be at least 14 characters."; if (/^\d+$/.test(pw)) return "Password cannot be only digits."; if (!/[a-z]/.test(pw) || !/[A-Z]/.test(pw) || !/[0-9]/.test(pw)) return "Use upper-case and lower-case letters and a digit."; return null; }