Files
pwa/backend/src/modules/auth/password.ts
T
ar.badieiandCursor 370ac15471 Ship Novya PWA with backend for deployable production use.
Fix production TypeScript builds and add DEPLOY.md so the app can be hosted from this repo.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 21:01:52 +03:30

25 lines
584 B
TypeScript

import { hash, verify, Algorithm } from '@node-rs/argon2';
const ARGON2_OPTIONS = {
algorithm: Algorithm.Argon2id,
memoryCost: 19_456,
timeCost: 2,
parallelism: 1,
};
export async function hashPassword(password: string): Promise<string> {
return hash(password, ARGON2_OPTIONS);
}
export async function verifyPassword(password: string, passwordHash: string): Promise<boolean> {
try {
return await verify(passwordHash, password);
} catch {
return false;
}
}
export function isArgon2idHash(value: string): boolean {
return value.startsWith('$argon2id$');
}