import bcrypt from "bcryptjs"; const ADMIN_ROUNDS = 12; const PIN_ROUNDS = 12; export async function hashPassword(password: string): Promise { if (!password || password.length < 8) { throw new Error("Password must be at least 8 characters"); } return bcrypt.hash(password, ADMIN_ROUNDS); } export async function verifyPassword(password: string, hash: string): Promise { return bcrypt.compare(password, hash); } export function isValidPin(pin: string): boolean { return /^\d{4}$/.test(pin); } export async function hashPin(pin: string): Promise { if (!isValidPin(pin)) throw new Error("PIN must be exactly 4 digits"); return bcrypt.hash(pin, PIN_ROUNDS); } export async function verifyPin(pin: string, hash: string): Promise { if (!isValidPin(pin)) return false; return bcrypt.compare(pin, hash); }