import * as http from 'http';
import type { JSONSerializable } from '../utils/json.js';
import type { Logger } from '../log/index.js';
import type { CertificateChainConfig, ResolvedCertificateChainRequirement } from '../utils/certificate-network.js';
export declare const AssertHTTPErrorData: (input: unknown) => {
    error: string;
    statusCode?: number;
    contentType?: string;
};
type RouteHandlerMethod<BodyDataType = JSONSerializable | undefined> = (urlParams: Map<string, string>, postData: BodyDataType, requestHeaders: http.IncomingHttpHeaders, requestUrl: URL) => Promise<{
    output: string | Buffer;
    statusCode?: number;
    contentType?: string;
    headers?: {
        [headerName: string]: string;
    };
}>;
type RouteHandlerWithConfig = {
    bodyType: 'raw';
    maxBodySize?: number;
    handler: RouteHandlerMethod<Buffer>;
} | {
    bodyType: 'parsed';
    maxBodySize?: number;
    handler: RouteHandlerMethod;
} | {
    bodyType: 'none';
    handler: RouteHandlerMethod<undefined>;
};
type RouteHandler = RouteHandlerMethod | RouteHandlerWithConfig;
export type Routes = {
    [route: string]: RouteHandler;
};
export type RoutesWithConfigs = {
    [route: string]: RouteHandlerWithConfig;
};
export interface KeetaAnchorHTTPServerConfig {
    /**
     * Identifier for the server instance -- if one is not given
     * a random one will be generated.
     */
    id?: string;
    /**
     * The port for the HTTP server to listen on (default is an ephemeral port).
     */
    port?: number;
    /**
     * Enable debug logging
     */
    logger?: Logger | undefined;
    /**
     * The URL for the server. By default, this will be generated based on
     * the port and will use "localhost" as the hostname, but it can be
     * overridden by setting this to a string, URL, or function that
     * generates the URL
     */
    url?: undefined | string | URL | ((object: KeetaNetAnchorHTTPServer) => string) | {
        hostname?: string;
        port?: number;
        protocol?: string;
    };
    /**
     * Optional on-chain cert-chain gate. When set, authenticated callers
     * MUST have a published cert chaining to one of `trustedIssuers`.
     */
    requireCertificateChain?: CertificateChainConfig | undefined;
}
export declare abstract class KeetaNetAnchorHTTPServer<ConfigType extends KeetaAnchorHTTPServerConfig = KeetaAnchorHTTPServerConfig> implements Required<KeetaAnchorHTTPServerConfig> {
    #private;
    readonly port: NonNullable<KeetaAnchorHTTPServerConfig['port']>;
    readonly logger: NonNullable<KeetaAnchorHTTPServerConfig['logger']>;
    readonly id: NonNullable<KeetaAnchorHTTPServerConfig['id']>;
    /**
     * Resolved cert-chain requirement, or `undefined` when disabled.
     * @see {@link requireCertificateChain}.
     */
    protected readonly resolvedCertificateChainRequirement: ResolvedCertificateChainRequirement | undefined;
    constructor(config: ConfigType);
    protected abstract initRoutes(config: ConfigType): Promise<Routes>;
    /**
     * Public view of the cert-chain config, or `undefined` when disabled.
     */
    get requireCertificateChain(): CertificateChainConfig | undefined;
    /**
     * Trusted-issuer DNs metadata. Is `undefined` when the gate is not configured.
     */
    protected acceptedIssuerDNs(): {
        name: string;
        value: string;
    }[][] | undefined;
    private static routeMatch;
    private static routeFind;
    private static addCORS;
    private main;
    /**
     * Start the HTTP server and wait for it to be fully initialized.
     */
    start(): Promise<void>;
    /**
     * Wait for the server to terminate. This will only resolve once the
     * server has been stopped.
     */
    wait(): Promise<void>;
    /**
     * Stop the HTTP server and wait for it to be fully terminated.
     */
    stop(): Promise<void>;
    /**
     * Get the URL of the server, which can be used to make requests to
     * it.  This will use "localhost" as the hostname and the port that
     * the server is listening on by default but can be overridden by
     * setting a custom URL.
     */
    get url(): string;
    set url(value: undefined | string | URL | ((object: this) => string));
    [Symbol.asyncDispose](): Promise<void>;
}
export {};
//# sourceMappingURL=index.d.ts.map