/** * Internal helpers for hashing, masking, and constant-time comparison * of API keys. * * @module */ /** Default token prefix when one isn't supplied. */ export declare const DEFAULT_PREFIX = "sk_"; /** Number of random bytes that back each plaintext token (256 bits). */ export declare const PLAINTEXT_BYTES = 32; /** Number of trailing plaintext characters to surface in the masked display. */ export declare const MASKED_TAIL_LENGTH = 4; /** * Generate a cryptographically random plaintext API token. * * The returned string has the form ``, where * `` is {@link PLAINTEXT_BYTES} random bytes encoded * url-safely. Callers must treat the result as a secret — it is the * only chance to surface the plaintext to a user. * * @param prefix - Optional token prefix (e.g. `'sk_live_'`). Defaults to {@link DEFAULT_PREFIX}. * @returns The newly generated plaintext token. */ export declare const generatePlaintextToken: (prefix?: string) => string; /** * SHA-256-hash a plaintext token. Deterministic for a given input. * * @param plaintext - The plaintext token to hash. * @returns Hex-encoded SHA-256 digest. */ export declare const hashPlaintextToken: (plaintext: string) => string; /** * Build a UI-safe display string of the form `…`. * * The middle of the token is replaced with an ellipsis; only the * configured prefix and last {@link MASKED_TAIL_LENGTH} characters * are kept. * * @param plaintext - The plaintext token. * @param prefix - Optional prefix override. When omitted, the function infers it * from the leading `_` segment of `plaintext`, falling back * to {@link DEFAULT_PREFIX}. * @returns The masked display string. */ export declare const maskPlaintextToken: (plaintext: string, prefix?: string) => string; /** * Constant-time compare of two strings of arbitrary length. * * Uses {@link timingSafeEqual} — when the lengths differ, falsifies * after a same-shape compare so the runtime does not leak length * information to an attacker. * * @param a - First string. * @param b - Second string. * @returns True iff `a` and `b` are byte-identical. */ export declare const constantTimeEqual: (a: string, b: string) => boolean; //# sourceMappingURL=utilities.d.ts.map