/** * Fenced `/firecrawl/api` route for the Firecrawl settings page. The DSH * settings RPC domain only serves an allowlist of product-owned namespaces, * so a third-party plugin cannot read or write its own namespace through * `ctx.settingsScope`. This route reaches the settings seam in-process from * the plugin's own webserver route, gated by the same browser-trust fence as * the /api gateway (Host-header loopback or a configured trusted host; no * cross-site browser markers). * @module @elves-ai/dsh-web-search-firecrawl/settings-routes */ import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http'; import type { Context } from '@deepseek-ai/cordis'; import { type SettingsPathOp } from '@deepseek-ai/dsh-settings'; /** Structural webServer face (mirror of `@deepseek-ai/dsh-host-webserver`). */ export interface FirecrawlWebServer { register(route: { kind: 'exact'; path: string; handler: (req: IncomingMessage, res: ServerResponse) => void | Promise; }): () => void; } /** Structural webRuntime face (the bind-derived trusted host list). */ export interface FirecrawlWebRuntime { trustedHosts: readonly string[]; } /** One redacted secret slot as returned by `settings.describe({ redactSecrets: true })`. */ export interface FirecrawlSettingsSecretView { path: string[]; set: boolean; } /** Redacted settings view served to the Firecrawl settings page. */ export interface FirecrawlSettingsView { value: unknown; revision: number; base?: unknown; user?: unknown; applies: 'live' | 'restart'; secrets: FirecrawlSettingsSecretView[]; writable: boolean; } /** One path-addressed settings edit accepted by `settings.mutate`. */ export type FirecrawlSettingsOp = SettingsPathOp; /** Wire failure envelope of the Firecrawl settings route. */ export interface FirecrawlSettingsRouteErrorBody { code: 'bad-request' | 'method-error' | 'not-found' | 'forbidden' | 'settings-rejected' | 'settings-conflict' | 'internal'; message: string; } /** Route-level error with an HTTP status and a stable machine code. */ export declare class FirecrawlSettingsRouteError extends Error { readonly code: FirecrawlSettingsRouteErrorBody['code']; readonly status: number; constructor(code: FirecrawlSettingsRouteErrorBody['code'], message: string, status?: number); } /** * Register `/firecrawl/api` while `webServer` and `webRuntime` are mounted. * The optional-inject shape keeps the search provider usable in deployments * without a web server (the settings page simply cannot reach its route). */ export declare function registerFirecrawlSettingsRoutes(ctx: Context): void; /** Whether a normalized URL hostname names the local loopback authority. */ export declare function isLoopbackHostname(hostname: string): boolean; /** True when the browser request comes from the DSH host itself. */ export declare function isTrustedApiRequest(headers: IncomingHttpHeaders, trustedHosts: readonly string[]): boolean;