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
| Parameter | Type | Description |
|---|---|---|
password | string | The 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
| Parameter | Type | Description |
|---|---|---|
storedHash | string | The stored hash to check. |
Returns
boolean
verify()
verify(password, storedHash): Promise<boolean>
Verifies a plaintext password against a stored hash.
Parameters
| Parameter | Type | Description |
|---|---|---|
password | string | The plaintext password to verify. |
storedHash | string | The stored hash to compare against. |
Returns
Promise<boolean>