/** * Hono middleware for authenticating requests via Service API Keys. * * This middleware is integrated into `createAuthMiddleware()` and * activates only when the bearer token starts with `rk_`. It: * * 1. Hashes the token with SHA-256 * 2. Looks up the hash in the `rebase.api_keys` table * 3. Validates the key is not revoked and not expired * 4. Sets `c.set("user", ...)` and `c.set("apiKey", ...)` for downstream use * 5. Scopes the DataDriver via `withAuth()` using the API key's service identity * * @module */ import type { Context } from "hono"; import type { DataDriver } from "@rebasepro/types"; import type { HonoEnv } from "../../api/types"; import type { ApiKeyStore } from "./api-key-store"; /** * Check whether a token looks like a Rebase API key. */ export declare function isApiKeyToken(token: string): boolean; /** * Options for the API key authentication handler. */ export interface ApiKeyAuthOptions { store: ApiKeyStore; driver: DataDriver; } /** * Validate an API key token and populate the Hono context. * * Returns `true` if the key is valid and context has been populated, * or returns an error Response if the key is invalid. * * This is NOT a standalone middleware — it's called from within * `createAuthMiddleware()` when a `rk_` prefixed token is detected. */ export declare function validateApiKey(c: Context, token: string, options: ApiKeyAuthOptions): Promise;