/** * Key derivation, value encryption, and token helpers for the OAuth proxy. * Web Crypto only, so the proxy runs on Node, Deno, Bun, and Workers. * * @internal */ /** @internal Keys derived from one configured secret. */ export interface ProxyKey { /** Stable, non-secret identifier written next to each ciphertext. */ readonly kid: string; /** AES-256-GCM key for stored values. */ readonly storage: CryptoKey; /** HMAC secret for signed cookies (hono/cookie takes bytes). */ readonly cookie: Uint8Array; } /** @internal The current key first, then previous keys that only decrypt. */ export interface ProxyKeyring { /** Key for new ciphertexts and new cookies. */ readonly current: ProxyKey; /** Every key, current first, for decryption and cookie checks. */ readonly all: readonly ProxyKey[]; } /** @internal Validates the configured secret(s) without deriving keys. */ export declare function normalizeSecrets(secret: unknown): string[]; /** @internal Derives the keyring from the secrets, current secret first. */ export declare function deriveKeyring(secrets: readonly string[]): Promise; /** @internal Creates a keyring from fresh random bytes, for local development. */ export declare function randomKeyring(): Promise; /** * @internal Encrypts a value with the current key. The storage key is the * authenticated data, so a ciphertext copied to another key fails to decrypt. */ export declare function encryptValue(keyring: ProxyKeyring, storageKey: string, plaintext: string): Promise; /** * @internal Decrypts a value written by any key in the keyring. Returns * `undefined` for an unknown key, a tampered value, or a value moved from * another storage key. */ export declare function decryptValue(keyring: ProxyKeyring, storageKey: string, envelope: string): Promise; /** @internal Random URL-safe token with `bytes` bytes of entropy. */ export declare function randomToken(bytes?: number): string; /** @internal SHA-256 of a UTF-8 string, base64url without padding. */ export declare function sha256(value: string): Promise; /** @internal RFC 7636 S256 code challenge for a verifier. */ export declare function pkceChallenge(verifier: string): Promise; /** @internal Compares two strings in time that depends only on their length. */ export declare function timingSafeEqual(a: string, b: string): boolean; /** @internal Base64url encoding without padding. */ export declare function base64UrlEncode(bytes: Uint8Array): string;