// src/utils/authUtils.ts import zxcvbn from 'zxcvbn'; /** * Validates the strength of a password using zxcvbn. * @param password The password to validate. * @returns An object with `isValid` and a feedback message. */ export function validatePasswordStrength(password: string): { isValid: boolean; feedback: string; } { const result = zxcvbn(password); // Score: 0-4. We require at least 3. if (result.score < 3) { const suggestions = result.feedback.suggestions.join(' '); return { isValid: false, feedback: `Password is too weak. ${suggestions}` }; } return { isValid: true, feedback: '' }; }