/** * @module @arcis/node/hono * * Hono adapter for Arcis. Hono runs on Web Fetch primitives (Request / * Response / Headers) so the same Edge-native pipeline that powers the * SvelteKit / Astro / Nuxt / Next.js / Bun adapters drives this one. * That means it works in any runtime Hono targets: Cloudflare Workers, * Deno Deploy, Bun, AWS Lambda, Node, and so on. * * **Scope:** rate-limit + bot detection + security headers. The * Web Fetch shape means consuming the body stream in this adapter * would defeat the downstream handler. For XSS/SQL/SSTI/etc. body * payload blocking, call `sanitizeObject(await c.req.json())` from * `@arcis/node/sanitizers` inside your route handler. * * Quick start: * * ```ts * import { Hono } from 'hono'; * import { arcisHono } from '@arcis/node/hono'; * * const app = new Hono(); * app.use('*', arcisHono({ rateLimit: { max: 100 }, bot: true })); * app.get('/', (c) => c.text('hello')); * ``` * * No runtime dependency on `hono` — its types are imported only at * compile time. The adapter ships in every Arcis install regardless of * whether the consumer uses Hono. * * For users running Hono on top of Bun, the dedicated `@arcis/node/bun` * adapter ships with a tighter Bun integration; this adapter is for * everyone else (Workers, Deno, Lambda, plain Node + Hono). */ import type { HeaderOptions, RateLimitOptions } from '../core/types'; import { type BotProtectionOptions } from './bot-detection'; interface HonoContextLike { req: { raw: Request; }; res: Response; env?: Record; } export type HonoMiddleware = (c: HonoContextLike, next: () => Promise) => Promise; export interface ArcisHonoOptions { /** Security headers configuration. Default: enabled. Pass `false` to disable. */ headers?: boolean | HeaderOptions; /** Rate limiter configuration. Default: 100 req/60s in-memory. Pass `false` to disable. */ rateLimit?: boolean | RateLimitOptions; /** * Bot protection. Default: disabled (opt-in to avoid surprising behavior on * legitimate crawlers). Pass `true` for sensible defaults or an options * object for full control. */ bot?: boolean | BotProtectionOptions; } /** * Build a Hono middleware handler that applies Arcis protections in * this order: rate limit (returns 429 if exceeded), bot detection * (returns 403 if the bot is in the deny list), runs `next()`, then * mutates the resulting `c.res` headers with security defaults. * * Hono's `c.res` is a regular `Response` whose `headers` are mutable * mid-request, so the security-header pass is in-place — no * Response-rebuild needed. */ export declare function arcisHono(options?: ArcisHonoOptions): HonoMiddleware; export default arcisHono; //# sourceMappingURL=hono.d.ts.map