/// <reference types="express" />
import { Discovery } from './discovery';
import * as Realm from "realm";
import { Logger } from './shared/Logger';
import { FindRealmResponse } from './shared/FindRealmResponse';
import { StatsStorage, StatsSink } from "./stats";
import { TokenValidator } from './shared';
import { IService } from "./Service";
import { RequestHandler } from "express";
import { RealmDefinition } from "./RealmFactory";
import { AuthClient } from './service-clients/AuthClient';
import { PermissionsClient } from './service-clients/PermissionsClient';
import { RealmDirectoryClient } from './service-clients/RealmDirectoryClient';
import { HealthClient } from './service-clients/HealthClient';
export declare class ServerValidationError extends Error {
}
export declare class ServerStartError extends Error {
}
export interface ServerConfig {
    dataPath: string;
    privateKeyPath?: string;
    publicKeyPath?: string;
    featureToken?: string;
    autoKeyGen?: boolean;
    autoKeyGenBits?: number;
    writeAdminTokenToJson?: boolean;
    logger?: Logger;
    logLevel?: string;
    address?: string;
    port?: number | string;
    disableTokenRevocation?: boolean;
    discovery?: Discovery;
    https?: boolean;
    httpsKeyPath?: string;
    httpsCertChainPath?: string;
    httpsPort?: number;
    httpsAddress?: string;
    middlewares?: RequestHandler | RequestHandler[];
    statsSink?: StatsSink;
    statsStorage?: StatsStorage;
    jsonBodyLimit?: number | string;
    authorizationHeaderName?: string;
}
export declare class Server {
    private serverConfig;
    private realmFactory;
    authClient: AuthClient;
    permissionsClient: PermissionsClient;
    realmDirectoryClient: RealmDirectoryClient;
    healthClient: HealthClient;
    privateKey: string;
    publicKey: string;
    adminToken: string;
    services: IService[];
    tokenValidator: TokenValidator;
    readonly version: string;
    private _started;
    private numberOfOpenFiles;
    readonly started: boolean;
    readonly dataPath: string;
    readonly discovery: Discovery;
    readonly logger: Logger;
    readonly publicKeyPath: string;
    readonly privateKeyPath: string;
    private expressApp;
    private httpServer;
    private httpAccessLogger;
    private httpsServer;
    private statsSink;
    private statsStorage;
    private httpBytesSentCounter;
    private httpBytesReceivedCounter;
    start(config: ServerConfig): Promise<void>;
    readonly address: string;
    readonly secureAddress: string;
    shutdown(): Promise<void>;
    addServices(...services: IService[]): this;
    addService(service: IService | string, config?: object): this;
    removeService(service: IService | string): this;
    getService(name: string): IService & any;
    private upgradeHandler(req, socket, head);
    private connectionHandler(socket);
    private injectLogger();
    private addServiceEndpoints(service);
    private startServices();
    private startService(service);
    private authenticationMiddleware(req, res, next);
    private processException(error);
    private errorHandler(error, req, res, next);
    private validateStartConfig(config);
    private periodicLoggingOfOpenFiles();
    openRealm(pathOrDefinition: string | RealmDefinition, schema?: Realm.ObjectSchema[]): Promise<Realm>;
    applyPermissions(condition: Realm.Sync.PermissionCondition, realmPath: string, accessLevel: Realm.Sync.AccessLevel): Promise<{
        affectedUsers: number;
    }>;
    ensureRealmExists(realmPath: string, ownerId?: string): Promise<FindRealmResponse>;
}
