UNPKG

security-toolkit

Version:

A library for implementing multiples security measures in a nodejs application

30 lines (29 loc) 1.17 kB
export interface RegexValidators { countLetters: (password: string) => number; countUpperCase: (password: string) => number; countSymbols: (password: string) => number; countNumbers: (password: string) => number; countConsecutiveCharacters: (password: string) => number; checkCommonPasswords: (password: string) => boolean; } export type PasswordComplexityValidation = { minChars: number; maxChars: number; minLetters?: number; minUpperCase?: number; minSymbols?: number; minNumbers?: number; maxConsecutiveChars?: number; avoidCommonPasswords?: boolean; }; export interface PasswordComplexityInputProps { password: string; validation?: PasswordComplexityValidation; } export interface PasswordComplexityReturnsProps { isValid: boolean; strength?: "weak" | "medium" | "strong"; message: string; } export declare function calculateStrength(validation: PasswordComplexityValidation, messages: string[], password: string): "weak" | "medium" | "strong"; export declare function validatePassword(input: PasswordComplexityInputProps, regexValidators?: RegexValidators): PasswordComplexityReturnsProps;