/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ /** * PHC (Password Hashing Competition) string format encode / decode for argon2id. * * Format: * $argon2id$v=$m=,t=,p=$$ * * Where `saltB64` and `hashB64` use the PHC "B64" alphabet — standard base64 * without trailing `=` padding. Matches the wire format produced by * `@node-rs/argon2` and `argon2-cffi`, so existing password column rows keep * verifying after the cutover. * * Implemented against the Web-standard `btoa` / `atob` (available in Node ≥ 16, * browsers, Workers, Deno, Bun) so this module has no Node-specific surface. */ export type Argon2idPhc = { /** Always `'argon2id'` for this codebase. */ algorithm: 'argon2id'; /** Argon2 version number — `0x13` (decimal 19) since RFC 9106. */ version: number; /** Memory cost in KiB. */ memoryCost: number; /** Iterations. */ timeCost: number; /** Parallelism (lanes). */ parallelism: number; /** Raw salt bytes. */ salt: Uint8Array; /** Raw derived-key bytes. */ hash: Uint8Array; }; export declare function encodeArgon2idPhc(phc: Argon2idPhc): string; export declare function decodeArgon2idPhc(s: string): Argon2idPhc; /** * Constant-time byte comparison. Returns `true` only if both arrays have the * same length and every byte matches. Intended for hash verification. */ export declare function timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;