/** * HTTP handler for atrib well-known endpoints (§5.3.5, §5.3.6). * * Serves two routes: * GET /.well-known/atrib-policy.json , policy document (§5.3.6) * GET /.well-known/atrib-proof/{hash}, cached inclusion proof (§5.3.5) * * Two API surfaces: * 1. createAtribHttpHandler(), returns a web-standard Request => Response * handler for Hono, Deno, Bun, Cloudflare Workers, and similar runtimes. * 2. handleAtribRequest(), returns a plain { status, headers, body } object * for Express, Fastify, or any custom HTTP framework. */ import type { AtribServer } from './middleware.js'; /** Framework-agnostic response shape for handleAtribRequest(). */ export interface AtribHttpResult { status: number; headers: Record; body: string; } /** * Resolve an atrib well-known request to a plain response object. * * Returns null if the pathname does not match any atrib endpoint, * allowing the caller to fall through to their own routing. * * @param server - The AtribServer instance returned by atrib(). * @param method - HTTP method (e.g. "GET"). * @param pathname - URL pathname (e.g. "/.well-known/atrib-policy.json"). */ export declare function handleAtribRequest(server: AtribServer, method: string, pathname: string): AtribHttpResult | null; /** * Create a web-standard HTTP handler for atrib well-known endpoints. * * Returns a function that accepts a Request and returns a Response for * matched routes, or null for unmatched routes. * * Works natively with Hono, Deno.serve, Bun.serve, Cloudflare Workers, * and any runtime that uses the Fetch API Request/Response types. * * Usage with Hono: * ```ts * const handler = createAtribHttpHandler(atribServer) * app.all('/.well-known/*', (c) => { * const response = handler(c.req.raw) * return response ?? c.notFound() * }) * ``` * * Usage with Express (via a small adapter): * ```ts * const handler = createAtribHttpHandler(atribServer) * app.use((req, res, next) => { * const response = handler(new Request(`http://localhost${req.url}`, { method: req.method })) * if (!response) return next() * res.status(response.status) * response.headers.forEach((v, k) => res.setHeader(k, v)) * response.text().then((body) => res.send(body)) * }) * ``` */ export declare function createAtribHttpHandler(server: AtribServer): (request: Request) => Response | null; //# sourceMappingURL=http.d.ts.map