import { OutboundPolicy, ResolvedOutboundPolicy } from "./outbound-policy.type.mjs"; //#region ../ai/src/security/outbound-policy.d.ts /** * Fill an {@link OutboundPolicy} with strict defaults: https-only, * private-IP deny on, 10s timeout, 5 MiB cap, global `fetch`. Idempotent * — resolving an already-resolved policy yields the same shape. */ declare function resolveOutboundPolicy(policy?: OutboundPolicy): ResolvedOutboundPolicy; /** * Validate a URL against the policy BEFORE any network call: scheme * allowlist, host allowlist, and (when enabled) a DNS resolution that * rejects private / loopback / link-local / metadata addresses — the SSRF * guard. Returns the parsed `URL` on success; throws * {@link OutboundPolicyError} otherwise. */ declare function assertUrlAllowed(rawUrl: string, policy: ResolvedOutboundPolicy): Promise; /** * Policy-guarded `fetch`: validates the URL ({@link assertUrlAllowed}), * then performs the request with the policy's timeout and (optional) * caller signal merged. Returns the raw `Response` — read its body via * {@link readTextCapped} to enforce `maxBytes`. Throws * {@link OutboundPolicyError} on a policy violation or timeout. * * Redirects are NEVER delegated to the platform: every hop is issued * with `redirect: "manual"` and its `Location` is re-run through * {@link assertUrlAllowed} before being followed (capped at * `maxRedirects`), so a 3xx from an allowed host cannot smuggle the * request to a private / metadata / off-allowlist target. Credential * headers are stripped when a hop crosses an origin boundary. Pass * `init.redirect: "manual"` to receive the raw 3xx, or `"error"` to * reject on any redirect. */ declare function guardedFetch(rawUrl: string, policyInput: OutboundPolicy, init?: RequestInit): Promise; /** * Read a response body as UTF-8 text with a hard byte cap. A declared * `content-length` over the cap fails fast; otherwise the stream is read * chunk-by-chunk and aborted the moment the running total exceeds * `maxBytes`. Throws {@link OutboundPolicyError} on overflow. */ declare function readTextCapped(response: Response, maxBytes: number): Promise; /** * Convenience: {@link guardedFetch} + {@link readTextCapped}. Returns the * response status alongside the (capped) body text so callers can shape * their own not-OK error. The body is only read when the response is OK. */ declare function fetchTextWithPolicy(rawUrl: string, policyInput: OutboundPolicy, init?: RequestInit): Promise<{ ok: boolean; status: number; statusText: string; text: string; }>; //#endregion export { assertUrlAllowed, fetchTextWithPolicy, guardedFetch, readTextCapped, resolveOutboundPolicy }; //# sourceMappingURL=outbound-policy.d.mts.map