openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
113 lines • 4.73 kB
TypeScript
import { n as PinnedDispatcherPolicy, o as SsrFPolicy, t as LookupFn } from "./ssrf-CkjpArdF.js";
import { Dispatcher } from "undici";
//#region src/infra/net/pinned-dispatcher-pool.d.ts
type PinnedDispatcherLease = {
dispatcher: Dispatcher;
reused: boolean;
release: () => Promise<void>;
};
type PinnedDispatcherPoolOptions = {
maxEntries: number;
idleTtlMs: number;
};
/**
* Bounded cache of reusable DNS-pinned dispatchers.
*
* Callers must perform fresh DNS and SSRF validation before every acquisition
* and include the resulting origin, address set, and connection policy in the key.
*/
declare class PinnedDispatcherPool {
private readonly entries;
private readonly ownedEntries;
private readonly maxEntries;
private readonly idleTtlMs;
private closed;
constructor(options: PinnedDispatcherPoolOptions);
acquire(params: {
key: string;
groupKey: string;
createDispatcher: () => Dispatcher;
}): PinnedDispatcherLease | undefined;
closeAll(): Promise<void>;
private createLease;
private retireEntry;
private startClose;
}
//#endregion
//#region src/infra/net/runtime-fetch.d.ts
type DispatcherAwareRequestInit = RequestInit & {
dispatcher?: Dispatcher;
};
/** Uses the undici runtime fetch so callers can pass dispatcher-aware options. */
declare function fetchWithRuntimeDispatcher(input: RequestInfo | URL, init?: DispatcherAwareRequestInit): Promise<Response>;
//#endregion
//#region src/infra/net/fetch-guard.d.ts
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
declare const GUARDED_FETCH_MODE: {
readonly STRICT: "strict";
readonly TRUSTED_ENV_PROXY: "trusted_env_proxy";
readonly TRUSTED_EXPLICIT_PROXY: "trusted_explicit_proxy";
};
type GuardedFetchMode = (typeof GUARDED_FETCH_MODE)[keyof typeof GUARDED_FETCH_MODE];
type GuardedFetchOptions = {
url: string;
fetchImpl?: FetchLike;
/** Final synchronous check after transport preparation and before each request or redirect. */
beforeRequest?: () => void | undefined;
init?: RequestInit;
capture?: false | {
flowId?: string;
meta?: Record<string, unknown>;
sensitiveRequestHeaderNames?: readonly string[];
};
maxRedirects?: number;
/**
* Allow replaying unsafe request methods and bodies across cross-origin redirects.
* Sensitive cross-origin headers (for example Authorization/Cookie) are still stripped.
* Defaults to false.
*/
allowCrossOriginUnsafeRedirectReplay?: boolean;
timeoutMs?: number;
signal?: AbortSignal;
requireHttps?: boolean;
policy?: SsrFPolicy;
lookupFn?: LookupFn;
dispatcherPolicy?: PinnedDispatcherPolicy;
/** Resolve a synchronous per-hop override so redirects can change proxy or direct routing. */
resolveDispatcherPolicy?: (url: URL) => PinnedDispatcherPolicy | undefined;
retainAuthorizationRedirectHostnameAllowlist?: string[];
mode?: GuardedFetchMode;
pinDns?: boolean;
/** @deprecated use `mode: "trusted_env_proxy"` for trusted/operator-controlled URLs. */
proxy?: "env";
/**
* @deprecated use `mode: "trusted_env_proxy"` instead.
*/
dangerouslyAllowEnvProxyWithoutPinnedDns?: boolean;
auditContext?: string;
/** Internal opt-in for reusing freshly revalidated, direct pinned dispatchers. */
dispatcherPool?: PinnedDispatcherPool;
};
type GuardedFetchResult = {
response: Response;
finalUrl: string;
release: () => Promise<void>;
refreshTimeout?: () => void;
dispatcherReused?: boolean;
};
declare class GuardedFetchRedirectError extends Error {
readonly status: number;
readonly maxRedirects: number;
constructor(params: {
status: number;
maxRedirects: number;
});
}
type GuardedFetchPresetOptions = Omit<GuardedFetchOptions, "mode" | "proxy" | "dangerouslyAllowEnvProxyWithoutPinnedDns">;
declare function withStrictGuardedFetchMode(params: GuardedFetchPresetOptions): GuardedFetchOptions;
declare function withTrustedEnvProxyGuardedFetchMode(params: GuardedFetchPresetOptions): GuardedFetchOptions;
declare function withTrustedExplicitProxyGuardedFetchMode(params: GuardedFetchPresetOptions): GuardedFetchOptions;
declare function retainSafeHeadersForCrossOriginRedirectHeaders(headers?: HeadersInit): Record<string, string> | undefined;
declare function fetchWithSsrFGuard(params: GuardedFetchOptions): Promise<GuardedFetchResult>;
//#endregion
export { GuardedFetchResult as a, withStrictGuardedFetchMode as c, fetchWithRuntimeDispatcher as d, GuardedFetchRedirectError as i, withTrustedEnvProxyGuardedFetchMode as l, GuardedFetchMode as n, fetchWithSsrFGuard as o, GuardedFetchOptions as r, retainSafeHeadersForCrossOriginRedirectHeaders as s, GUARDED_FETCH_MODE as t, withTrustedExplicitProxyGuardedFetchMode as u };