import { type ResolveWorkerHost, type WorkerEgressFetch, type WorkerEgressPinnedFetch, type WorkerEgressRedirect } from "../sandbox/worker-egress-guard.js"; export declare const HOST_INTERNAL_EGRESS_OVERRIDE_ENV = "VERYFRONT_HOST_ALLOW_INTERNAL_EGRESS"; export declare const HOST_ALLOWED_INTERNAL_PROVIDER_ORIGINS_ENV = "VERYFRONT_HOST_ALLOWED_INTERNAL_PROVIDER_ORIGINS"; type BoundedFileReader = (path: string, byteLimit: number) => Promise; export declare class OutboundRequestBlockedError extends Error { name: string; } export interface GuardedOutboundFetchOptions { /** Additional operator-owned URL policy, applied to every redirect hop. */ authorizeUrl?: (url: URL) => void | Promise; /** Observe each redirect after its guarded destination request succeeds. */ onRedirect?: (redirect: WorkerEgressRedirect) => void | Promise; } /** Host-owned transport primitives used after outbound policy validation. */ export interface OutboundFetchTransport { fetch: WorkerEgressFetch; pinnedFetch?: WorkerEgressPinnedFetch; /** * Address resolver the egress guard pins against, defaulting to real DNS. * * The guard resolves the destination host before it reaches `fetch` or * `pinnedFetch`, so a transport that never opens a socket still triggers a * live lookup unless it supplies this too. Production leaves it unset and * keeps `defaultResolveHost`. */ resolveHost?: ResolveWorkerHost; } /** Explicit host transport boundary used by runtime composition and tests. */ export interface OutboundFetchBoundary { guardedFetch(input: RequestInfo | URL, init?: RequestInit, options?: GuardedOutboundFetchOptions): Promise; createOriginBoundFetch(baseUrl: string): typeof fetch; } /** @internal Exported for boundary tests. */ export declare function loadTrustedCaCertificates(filePath: string, defaultRoots: readonly string[], readFileWithinLimit: BoundedFileReader): Promise; /** * Create an outbound boundary from explicit host-owned transport primitives. * * @internal Runtime composition and deterministic tests use this seam. The * default exports below never source their production transport from it. */ export declare function createOutboundFetchBoundary(transport: OutboundFetchTransport): OutboundFetchBoundary; /** * Point the host transport at `transport` until the returned function is called. * * For suites that install a stub in `beforeEach` and tear it down in * `afterEach`, where there is no single callback to scope. Prefer * `__runWithOutboundFetchTransportForTests` when there is one -- it cannot be * left installed by an early return. */ /** * Route outbound requests through the captured host `fetch` without address * pinning, for the duration of a test process. * * Deno's pinned path uses its SOCKS client, which holds a connection open past * the end of a test and trips the resource sanitiser. Tests that genuinely * reach the network want the plain transport; production never does. Installed * once from `src/testing/preload.ts`, where it is visible, rather than inferred * from an environment variable inside this module. * * This is not a stub: it is the real host `fetch`, captured before tenant code * could replace it, so it cannot silently honour an ambient * `globalThis.fetch` assignment the way the old `DENO_TESTING` branch did. */ export declare function __installUnpinnedHostTransportForTests(): () => void; export declare function __installOutboundFetchTransportForTests(transport: OutboundFetchTransport): () => void; export declare function __runWithOutboundFetchTransportForTests(transport: OutboundFetchTransport, fn: () => Promise): Promise; /** * Fetch an HTTP resource through the host egress ceiling. * * Internal destinations are denied by default. Only the host process can * enable the explicit override; project environment overlays cannot change * `getHostEnv()`. */ export declare function guardedOutboundFetch(input: RequestInfo | URL, init?: RequestInit, options?: GuardedOutboundFetchOptions): Promise; /** * Fetch a caller-validated HTTP loopback development endpoint. * * This is deliberately not a flag on `guardedOutboundFetch`: generic callers * cannot self-authorize internal egress by adding an untyped option. The helper * admits only exact HTTP loopback URLs and applies the same restriction to * every redirect hop before it enables the host egress override. * * @internal Application-auth development loopback support only. */ export declare function guardedExactHttpLoopbackOutboundFetch(input: RequestInfo | URL, init?: RequestInit, options?: GuardedOutboundFetchOptions): Promise; /** * Create a credential-safe provider transport bound to one configured origin. * Redirects are rejected rather than followed so provider-specific credential * headers (for example `x-api-key`) can never cross an origin boundary. */ export declare function createOriginBoundOutboundFetch(baseUrl: string): typeof fetch; export {}; //# sourceMappingURL=outbound-fetch.d.ts.map