Repository Public
1/** Password strength hints for setup and password change. Only the first two are enforced. */2export function passwordChecks(password: string, username: string): { label: string; ok: boolean; required: boolean }[] {3 const classes = [/[a-z]/, /[A-Z]/, /\d/, /[^A-Za-z0-9]/].filter((r) => r.test(password)).length;4 return [5 { label: 'At least 12 characters', ok: password.length >= 12, required: true },6 { label: 'Does not contain the username', ok: password.length > 0 && (username.length < 3 || !password.toLowerCase().includes(username.toLowerCase())), required: true },7 { label: '16 characters or more (recommended: a passphrase)', ok: password.length >= 16, required: false },8 { label: 'Mixes three kinds of characters (recommended)', ok: classes >= 3, required: false },9 ];10}1112