/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type { AddressInfo } from "net";
import { Http2Server, Http2ServerRequest } from "node:http2";
import { Http2ServerResponse } from "node:http2";
import type { Server as SecureServer } from "https";
import type { RequestHandler } from "express";
import type { ServerOptions as SocketIoServerOptions } from "socket.io";
import { Server } from "http";
import { Server as GrpcServer } from "@grpc/grpc-js";
import { ConnectRouter } from "@connectrpc/connect";
import { FastifyBaseLogger, FastifyInstance, FastifyTypeProviderDefault } from "fastify";
import express from "express";
import { Server as SocketIoServer } from "socket.io";
import { ServiceType } from "@bufbuild/protobuf";
import { ICrpcSvcRegistration } from "@hyperledger/cactus-core-api";
import { PluginRegistry } from "@hyperledger/cactus-core";
import { ICactusApiServerOptions } from "./config/config-service";
import { PrometheusExporter } from "./prometheus-exporter/prometheus-exporter";
export interface IApiServerConstructorOptions {
    readonly pluginManagerOptions?: {
        pluginsPath: string;
    };
    readonly pluginRegistry?: PluginRegistry;
    readonly httpServerApi?: Server | SecureServer;
    readonly wsServerApi?: SocketIoServer;
    readonly grpcServer?: GrpcServer;
    readonly crpcServer?: FastifyInstance<Http2Server, Http2ServerRequest, Http2ServerResponse, FastifyBaseLogger, FastifyTypeProviderDefault>;
    readonly wsOptions?: SocketIoServerOptions;
    readonly httpServerCockpit?: Server | SecureServer;
    readonly config: ICactusApiServerOptions;
    readonly prometheusExporter?: PrometheusExporter;
    readonly enableShutdownHook?: boolean;
}
export declare class ApiServer {
    readonly options: IApiServerConstructorOptions;
    static readonly CLASS_NAME = "ApiServer";
    static readonly E_POST_CRASH_SHUTDOWN = "API server failed to shut itself down, will ignore this because we were already crashing anyway...";
    static readonly E_NON_EXEMPT_UNPROTECTED_ENDPOINTS: string;
    private readonly log;
    private pluginRegistry;
    private readonly httpServerApi;
    private readonly httpServerCockpit?;
    private readonly wsApi;
    private readonly grpcServer;
    private readonly crpcServer;
    private readonly expressApi;
    private readonly expressCockpit;
    private readonly pluginsPath;
    private readonly enableShutdownHook;
    prometheusExporter: PrometheusExporter;
    boundGrpcHostPort: string;
    get className(): string;
    constructor(options: IApiServerConstructorOptions);
    getPrometheusExporter(): PrometheusExporter;
    getPrometheusExporterMetrics(): Promise<string>;
    getPluginImportsCount(): number;
    start(): Promise<{
        readonly addressInfoCockpit?: AddressInfo;
        readonly addressInfoApi: AddressInfo;
        readonly addressInfoGrpc: AddressInfo;
        readonly addressInfoCrpc: AddressInfo;
    }>;
    /**
     * Verifies that the currently running NodeJS process is at least of a certain
     * NodeJS version as specified by the configuration.
     *
     * @throws {Error} if the version contraint is not satisfied by the runtime.
     */
    checkNodeVersion(currentVersion?: string): void;
    getHttpServerApi(): Server | SecureServer;
    getHttpServerCockpit(): Server | SecureServer | undefined;
    getOrInitPluginRegistry(): Promise<PluginRegistry>;
    initPluginRegistry(req?: {
        readonly pluginRegistry: PluginRegistry;
    }): Promise<PluginRegistry>;
    private instantiatePlugin;
    private installPluginPackage;
    shutdown(): Promise<void>;
    startCockpitFileServer(): Promise<AddressInfo>;
    /**
     * Installs the own endpoints of the API server such as the ones providing
     * healthcheck and monitoring information.
     * @param app
     */
    getOrCreateWebServices(app: express.Express): Promise<void>;
    createCrpcExpressMiddlewareHandler(): Promise<{
        readonly svcCount: number;
        readonly crpcMiddlewareHandler: express.RequestHandler;
    }>;
    createCrpcRoutesHandler(): Promise<{
        readonly svcCount: number;
        readonly crpcRoutesHandler: (router: ConnectRouter) => void;
    }>;
    startCrpcServer(): Promise<{
        readonly addressInfoCrpc: AddressInfo;
        readonly crpcUrl: string;
    }>;
    startGrpcServer(): Promise<AddressInfo>;
    createCrpcServicesOfPlugins(): Promise<ICrpcSvcRegistration<ServiceType>[]>;
    startApiServer(): Promise<AddressInfo>;
    private checkNonExemptUnprotectedEps;
    createCorsMiddleware(allowedDomains: string[]): RequestHandler;
    /**
     * `JSON.stringify` replacer function to handle BigInt.
     * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json
     */
    private stringifyBigIntReplacer;
}
