/** * The `Password` class provides methods for securely hashing, comparing, and * checking the strength of passwords. It integrates with `bcrypt` for hashing * and comparison and also checks for weak or compromised passwords using * both strength rules and the Pwned Passwords API. */ export declare class Password { private value; /** * Static factory method to create a `Password` instance. * * @param value - The plain text password. * @returns A new `Password` instance. */ static from(value: string): Password; /** * Private constructor for the `Password` class. * * @param value - The plain text password. */ private constructor(); /** * Hashes the password using `bcrypt` with a customizable salt rounds factor. * * @param salt - The number of salt rounds to use. Defaults to 10. * @returns A promise that resolves to the hashed password. */ hash(salt?: number): Promise; /** * Compares the plain text password with a hashed password using `bcrypt`. * * @param hashed - The hashed password to compare against. * @returns A promise that resolves to `true` if the passwords match, otherwise `false`. */ compare(hashed: string): Promise; /** * Checks if the password is weak. A password is considered weak if it does * not meet the following criteria: * - Minimum length of 8 characters (configured with a constant). * - Contains at least one lowercase letter. * - Contains at least one uppercase letter. * - Contains at least one number. * - Contains at least one special character. * - Not found in the Pwned Passwords database. * * @throws {WeakPasswordError} If the password is considered weak. * @returns A promise that resolves if the password is strong, otherwise throws an error. */ isStrong(): Promise; /** * Private method to check if the password has been compromised using the * Pwned Passwords API. * * @returns A promise that resolves to `true` if the password has been found * in a data breach, otherwise `false`. */ private isPwned; toJSON(): string; } /** * The `WeakPasswordError` is thrown when a password fails the strength * requirements or is found in a known data breach. */ export declare class WeakPasswordError extends Error { name: string; }