Skip to main content

Interface: PasswordHasher

Interface for password hashing implementations. Allows swapping the default Argon2id hasher with custom logic (e.g. bcrypt, scrypt).

Methods

hash()

hash(password): Promise<string>

Hashes a plaintext password.

Parameters

ParameterTypeDescription
passwordstringThe plaintext password to hash.

Returns

Promise<string>


needsRehash()

needsRehash(storedHash): boolean

Checks if a stored hash needs to be rehashed (e.g. due to parameter upgrades).

Parameters

ParameterTypeDescription
storedHashstringThe stored hash to check.

Returns

boolean


verify()

verify(password, storedHash): Promise<boolean>

Verifies a plaintext password against a stored hash.

Parameters

ParameterTypeDescription
passwordstringThe plaintext password to verify.
storedHashstringThe stored hash to compare against.

Returns

Promise<boolean>