Setu-TS
    Preparing search index...

    Class PasswordHasher

    Password hasher using PBKDF2-SHA256 via Web Crypto.

    const hasher = new PasswordHasher(runtime); // 600,000 iterations
    if (await hasher.verify(user.passwordHash, password)) {
    if (hasher.needsRehash(user.passwordHash)) {
    await users.update(user.id, { passwordHash: await hasher.hash(password) });
    }
    }
    Index
    • Reports whether a stored hash was made with fewer iterations than this hasher is configured for, so the application re-hashes it after the next successful PasswordHasher.verify — the only moment the plaintext is available.

      A hash at or above the configured count reports false, so lowering the configuration never downgrades a stored credential.

      Parameters

      • stored: string

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

      Returns boolean

      true when the hash should be replaced

      On every input verify refuses

      0.10.0

    • 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

      Returns Promise<boolean>

      true if the secret matches, false otherwise

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