UNPKG

passwise

Version:

A customizable React password strength checker library

61 lines (59 loc) 1.77 kB
type PasswordStrength = 0 | 1 | 2 | 3 | 4; type PasswordStrengthLabel = "Very Weak" | "Weak" | "Fair" | "Good" | "Strong"; type ThemeType = "light" | "dark"; interface PasswordPolicy { minLength?: number; mustContain?: { lowercase?: boolean; uppercase?: boolean; number?: boolean; symbol?: boolean; }; maxLength?: number; } interface PasswordValidationResult { valid: boolean; message?: string; } interface PasswordStrengthResult { score: PasswordStrength; label: PasswordStrengthLabel; feedback: { suggestions: string[]; warning: string | null; }; passwordLength: number; validations: PasswordValidationResult[]; meetsPolicy: boolean; } interface StrengthBarProps { strength: PasswordStrength; theme?: ThemeType; className?: string; showLabels?: boolean; barOnly?: boolean; } interface ValidationSuggestionsProps { validations: PasswordValidationResult[]; suggestions: string[]; warning: string | null; className?: string; theme?: ThemeType; } interface PasswordStrengthMeterProps { password: string; theme?: ThemeType; className?: string; showLabels?: boolean; showBar?: boolean; showSuggestions?: boolean; scoreWords?: [string, string, string, string, string]; policy?: PasswordPolicy; barOnly?: boolean; onChange?: (result: PasswordStrengthResult) => void; } interface UsePasswordStrengthOptions { password: string; policy?: PasswordPolicy; } export { PasswordPolicy, PasswordStrength, PasswordStrengthLabel, PasswordStrengthMeterProps, PasswordStrengthResult, PasswordValidationResult, StrengthBarProps, ThemeType, UsePasswordStrengthOptions, ValidationSuggestionsProps };