/** * Shared outbound-request hygiene for the two fixed, operator-configured origins * this plugin talks to: the DeepSeek balance endpoint and the optional holiday * calendar source. * * Neither URL comes from model output, so the web-fetch SSRF policy (which exists * because its URLs are model-chosen) does not apply here. What does apply is the * house rule for credential-bearing or third-party requests: validate the * configured URL once, never follow redirects, and cap the response body. * * @module dsh-balance/net */ /** Options for {@link parseSafeUrl}. */ export interface SafeUrlOptions { /** Whether a loopback `http://` URL is acceptable (local endpoints only). */ readonly allowLoopbackHttp?: boolean; /** Whether a query string or fragment is acceptable. */ readonly allowQuery?: boolean; } /** Whether a URL's host is a loopback address literal. */ export declare function isLoopbackHost(hostname: string): boolean; /** * Validate one configured URL. * * @param raw - the configured URL. * @param options - acceptance policy. * @returns the parsed URL. * @throws when it carries credentials, is not `https` (loopback `http` aside), or * carries a query/fragment the caller did not allow. */ export declare function parseSafeUrl(raw: string, options?: SafeUrlOptions): URL; /** * Validate a configured **origin**, rejecting any path/query/fragment. * @param raw - the configured origin, e.g. `https://api.deepseek.com`. * @param options - acceptance policy. * @returns the parsed origin. * @throws when the URL carries anything beyond a scheme, host and port. */ export declare function parseSafeOrigin(raw: string, options?: SafeUrlOptions): string; /** * Read a response body, refusing to buffer more than `maxBytes`. * * Reads the stream incrementally so an oversized or endless body is abandoned * rather than accumulated; a declared `content-length` above the cap short-circuits * before any body is read. * * @param response - the response. * @param maxBytes - the accepted size. * @returns the body text. * @throws when the body exceeds the cap or the stream cannot be read. */ export declare function readCappedBody(response: Response, maxBytes: number): Promise; /** * Parse a JSON body without letting a syntax error escape as an opaque failure. * @param text - the raw body. * @returns the parsed value, or undefined when it is not JSON. */ export declare function parseJson(text: string): unknown;