/** * @module @arcis/node/sveltekit * * SvelteKit adapter for Arcis. Returns a `Handle` factory you can drop into * `src/hooks.server.ts`. * * **Scope:** rate-limit + bot detection + security headers. For * XSS/SQL/SSTI/etc. body-payload blocking, call `sanitizeObject` from * `@arcis/node/sanitizers` inside your route handler. v1 keeps the * middleware surface narrow. * * ```ts * import { arcisHandle } from '@arcis/node/sveltekit'; * export const handle = arcisHandle({ rateLimit: { max: 100 }, bot: true }); * ``` * * Or compose with other handles via SvelteKit's own `sequence` helper: * * ```ts * import { sequence } from '@sveltejs/kit/hooks'; * import { arcisHandle } from '@arcis/node/sveltekit'; * export const handle = sequence(arcisHandle(), authHandle, loggingHandle); * ``` * * SvelteKit uses Web Fetch `Request`/`Response` objects, not Express * `req`/`res`, so this adapter implements the Arcis pipeline natively against * the Fetch API rather than wrapping `arcis()`. There is no runtime dependency * on `@sveltejs/kit` — its types are imported only for compile-time checks. */ import type { HeaderOptions, RateLimitOptions } from '../core/types'; import { type BotProtectionOptions } from './bot-detection'; interface SvelteKitCookies { get(name: string): string | undefined; set(name: string, value: string, opts: { path: string; [k: string]: unknown; }): void; delete(name: string, opts: { path: string; }): void; } export interface SvelteKitRequestEvent { request: Request; url: URL; cookies: SvelteKitCookies; getClientAddress(): string; } export type SvelteKitResolve = (event: SvelteKitRequestEvent, opts?: unknown) => Promise | Response; export type SvelteKitHandle = (input: { event: SvelteKitRequestEvent; resolve: SvelteKitResolve; }) => Promise; export interface ArcisHandleOptions { /** 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 SvelteKit `Handle` that applies Arcis protections in this order on * each request: rate limit (returns 429 if exceeded), bot detection (returns * 403 if the bot is in the deny list), then runs downstream `resolve(event)`, * then mutates the resulting `Response`'s headers with security defaults. */ export declare function arcisHandle(options?: ArcisHandleOptions): SvelteKitHandle; export default arcisHandle; //# sourceMappingURL=sveltekit.d.ts.map