/** * CLI-internal helper. Preserves the v0.13.0 @peac/disc behavior contract * (tolerant two-pass parse + SSRF-aware remote fetch) using public * @peac/policy-kit and @peac/net-node primitives, plus PUBLIC @peac/kernel * constants where the fields exist. * * NOT exported from @peac/cli's public surface. Used by: * - packages/cli/src/commands/discover.ts * - packages/cli/src/lib/conformance/validators.ts (validateDiscoveryInput) * * External consumers needing the same compatibility behavior should copy * this pattern; a packaged public helper may land in a later release if * external demand surfaces. */ import { type PolicyDocument } from '@peac/policy-kit'; export declare const DISCOVER_TIMEOUT_MS = 5000; export declare const DISCOVER_MAX_BYTES: 262144; export declare const PEAC_TXT_PATH: "/.well-known/peac.txt"; /** @internal - tests only; resets the one-shot legacy-warning flag. */ export declare function __resetLegacyWarningForTests(): void; export interface CompatParseResult { valid: boolean; data?: PolicyDocument; errors?: string[]; warnings?: string[]; } /** * Tolerant two-pass parser preserving v0.13.0 @peac/disc.parse semantics. * * Pass 1: hand the raw text to parsePolicyDocument unmodified. Legacy-looking * substrings inside YAML comments / block scalars / rule text remain intact. * * Pass 2 (only if Pass 1 throws AND legacy `verify:` / `public_keys:` / * `jwks:` lines are present at top level): strip those lines and retry. * Detected legacy lines surface as warnings + a once-per-process structured * DeprecationWarning with code PEAC_LEGACY_PEAC_TXT_KEY_FIELD. * * Returns a structured ParseResult; never throws on policy validation / * load failure (those become `errors`). Throws only on programming errors. */ export declare function parsePolicyDocumentCompat(text: string): CompatParseResult; export interface FetchPolicyDocumentSuccess { ok: true; text: string; warnings?: string[]; } export interface FetchPolicyDocumentFailure { ok: false; error: string; code?: string; } export type FetchPolicyDocumentResult = FetchPolicyDocumentSuccess | FetchPolicyDocumentFailure; export interface FetchPolicyDocumentOptions { /** Override the v0.13.0-equivalent 5_000 ms total timeout. */ timeoutMs?: number; /** Override the v0.13.0-equivalent 256 KiB body cap. */ maxBytes?: number; /** Override the User-Agent header. Defaults to `peac-cli`. */ userAgent?: string; } /** * Fetch a peac.txt policy document via SSRF-aware HTTP with a body cap and * timeout. Returns the raw response text on success. Caller is responsible * for parsing via `parsePolicyDocumentCompat`. Always closes the underlying * raw response in a `finally` block (no socket leak). */ export declare function fetchPolicyDocumentText(origin: string, options?: FetchPolicyDocumentOptions): Promise; //# sourceMappingURL=policy-document-discovery.d.ts.map