method PasswordHasher.prototype.verify
PasswordHasher.prototype.verify(
stored: string,
secret: string
): Promise<boolean>

Verify a secret against a stored hash.

A wrong secret returns false; a stored value that is not a well-formed pbkdf2$… string throws MalformedPasswordHashError, because that shape of failure is a programming error (most often reversed arguments) rather than a failed login.

Parameters

stored: string

The stored hash string in pbkdf2$<iterations>$<salt>$<hash> format

secret: string

The password to verify

Return Type

Promise<boolean>

true if the secret matches, false otherwise

Throws

MalformedPasswordHashError

If stored is not a well-formed pbkdf2$… string

Usage

import { PasswordHasher } from "auth-plugin/src/index.ts";