/** * API key service. Provides the public lifecycle operations for hashed, * scoped, optionally-expiring API tokens. * * All persistence flows through the abstract {@link DataStore} from * `@molecule/api-database` — no raw SQL is issued from this module. * * @module */ import type { ApiKey, CreateApiKeyInput, CreateApiKeyResult } from './types.js'; /** * Create a new API key. Generates a fresh plaintext token, hashes it * with SHA-256, persists the row, and returns BOTH the persisted record * and the plaintext. * * The plaintext is returned exactly once — callers MUST surface it * immediately to the user (or store it in their own vault). It cannot * be recovered after this call returns. * * @param input - Creation parameters. * @returns The persisted {@link ApiKey} plus its plaintext token. */ export declare const createApiKey: (input: CreateApiKeyInput) => Promise; /** * Rotate an existing API key. Revokes the old row and creates a fresh * key (new plaintext, new hash, new masked) that inherits the original * key's `user_id`, `name`, `scopes`, and `expires_at`. * * The freshly generated plaintext is returned exactly once. * * @param id - ID of the existing key to rotate. * @returns The new {@link ApiKey} plus its plaintext token. */ export declare const rotateApiKey: (id: string) => Promise; /** * Revoke an API key. Sets `revoked_at` to the current time. Subsequent * calls to {@link verifyApiKey} with the matching plaintext will return * `null`. * * @param id - ID of the key to revoke. */ export declare const revokeApiKey: (id: string) => Promise; /** * Verify a plaintext API key. Hashes the input, looks up the row by * hash, then constant-time-compares the stored hash against the * recomputed hash before performing any short-circuit return. * * Returns `null` if the key is not found, has been revoked, or is * past its expiration. * * @param plaintext - The plaintext token to verify. * @returns The matching {@link ApiKey}, or `null` if no valid match exists. */ export declare const verifyApiKey: (plaintext: string) => Promise; /** * Record that an API key was just used to authenticate. Sets * `last_used_at` to the current time. * * @param id - ID of the key that was used. */ export declare const recordApiKeyUse: (id: string) => Promise; //# sourceMappingURL=service.d.ts.map