class MalformedPasswordHashError
extends Error
Since 0.3.0

Thrown by PasswordHasher.verify when the stored value is not a well-formed pbkdf2$<iterations>$<salt>$<hash> string.

This usually means the arguments were passed in reverse order — a plaintext password in the stored position makes every correct verification fail, so it is reported loudly here instead of indistinguishably as false.

Examples

Example 1

try {
  const ok = await hasher.verify(stored, password);
} catch (error) {
  if (error instanceof MalformedPasswordHashError) {
    // The stored credential is corrupt, or verify's arguments are swapped
  }
}

Properties

readonly
name: string

Discriminant for consumers that cannot use instanceof across realms.

Usage

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