auth-vir
Version:
Auth made easy and secure via JWT cookies, CSRF tokens, and password hashing helpers.
43 lines (42 loc) • 1.45 kB
TypeScript
import { type PartialWithUndefined } from '@augment-vir/common';
import { type IArgon2Options } from 'hash-wasm';
/**
* Default value for {@link HashPasswordOptions}.
*
* @category Internal
*/
export declare const defaultHashOptions: HashPasswordOptions;
/**
* Options for {@link hashPassword}.
*
* @category Internal
*/
export type HashPasswordOptions = PartialWithUndefined<Omit<IArgon2Options, 'outputType' | 'salt' | 'password' | 'secret'>>;
/**
* Hashes a password using the Argon2id algorithm so passwords don't need to be stored in plain
* text. The output of this function is safe to store in a database for future credential
* comparisons.
*
* @category Auth : Host
* @returns The hashed password.
* @see https://en.wikipedia.org/wiki/Argon2
*/
export declare function hashPassword(password: string, options?: HashPasswordOptions): Promise<string>;
/**
* A utility that provides more accurate string byte size than doing `string.length`.
*
* @category Internal
*/
export declare function getByteLength(input: string): number;
/**
* Checks if the given password is a match by comparing it to the previously computed and stored
* hash.
*
* @category Auth : Host
*/
export declare function doesPasswordMatchHash({ password, hash, }: {
/** The password entered by the user in their login attempt. */
password: string;
/** The stored password hash for that user. */
hash: string;
}): Promise<boolean>;