import { Hash } from './hash.ts'; import type { HashDriverContract, ManagerDriverFactory } from './types.ts'; /** * HashManager implements the manager/builder pattern to create a use multiple * hashing algorithm without self managing hash instance. * * ```ts * const manager = new HashManager({ * default: 'argon', * list: { * argon: () => new ArgonDriver(), * bcrypt: () => new BcryptDriver(), * } * }) * ``` */ export declare class HashManager> implements HashDriverContract { #private; /** * Configuration object containing default hasher and list of available hashers */ config: { default?: keyof KnownHashers; list: KnownHashers; }; constructor(config: { default?: keyof KnownHashers; list: KnownHashers; }); /** * Use one of the registered hashers to hash values. * * ```ts * manager.use() // returns default hasher * manager.use('argon') * ``` * * @param hasher - The name of the hasher to use, defaults to the configured default * @return Hash instance for the specified hasher */ use(hasher?: Hasher): Hash; /** * Enable fake hash drivers to disable actual hashing for testing */ fake(): { [Symbol.dispose]: () => void; }; /** * Restore normal hashing behavior by disabling fake mode */ restore(): void; /** * Check if the value is a valid hash. This method just checks * for the formatting of the hash * * @param value - The value to check * @return True if the value is a valid hash format */ isValidHash(value: string): boolean; /** * Hash plain text value using the default hasher * * @param value - The plain text value to hash * @return Promise resolving to the hashed value */ make(value: string): Promise; /** * Verify the plain text value against an existing hash * * @param hashedValue - The hashed value to verify against * @param plainValue - The plain text value to verify * @return Promise resolving to true if verification succeeds */ verify(hashedValue: string, plainValue: string): Promise; /** * Find if the hash value needs a rehash or not. * * @param hashedValue - The hashed value to check * @return True if the hash needs to be rehashed */ needsReHash(hashedValue: string): boolean; /** * Assert the plain value passes the hash verification * * @param hashedValue - The hashed value to verify against * @param plainValue - The plain text value to verify * @return Promise that resolves if verification passes, throws if it fails */ assertEquals(hashedValue: string, plainValue: string): Promise; /** * Assert the plain value fails the hash verification * * @param hashedValue - The hashed value to verify against * @param plainValue - The plain text value to verify * @return Promise that resolves if verification fails, throws if it passes */ assertNotEquals(hashedValue: string, plainValue: string): Promise; }