import { DocumentScope, ServerScope } from 'nano';
import { Config, PersonalDBSettings, PersonalDBType } from '../types/config';
import { CouchDbAuthDoc, IdentifiedObj, SessionCleanupType, SlUserDoc } from '../types/typings';
import { CouchAdapter } from './couchdb';
export declare class DBAuth {
    private config;
    private userDB;
    private couchServer;
    adapter: CouchAdapter;
    constructor(config: Partial<Config>, userDB: DocumentScope<SlUserDoc>, couchServer: ServerScope, couchAuthDB?: DocumentScope<CouchDbAuthDoc>);
    storeKey(username: string, user_uid: string, key: string, password: string, expires: number, roles: string[], provider: string): Promise<CouchDbAuthDoc>;
    /**
     * Step 1) During deauthorization: Removes the keys of format
     * org.couchdb.user:TOKEN from the `_users` - database, if they are present.
     * If this step fails, the user hasn't been deauthorized!
     */
    removeKeys(keys: any): Promise<false | import("nano").DocumentBulkResponse[]>;
    retrieveKey(key: string): Promise<CouchDbAuthDoc>;
    extendKey(key: string, newExpiration: number): Promise<import("nano").DocumentInsertResponse>;
    /** generates a random token and password */
    getApiKey(): {
        key: string;
        password: string;
    };
    /**
     * Removes the affected from the `_users` db and from the `_security` of the
     * user's personal DBs, returning the modified `sl-users` doc
     *
     *  - 'all' -> logs out all sessions
     *  - 'other' -> logout all sessions except for 'currentSession'
     *  - 'expired' -> only logs out expired sessions
     */
    logoutUserSessions(userDoc: SlUserDoc, op: SessionCleanupType, currentSession?: string): Promise<SlUserDoc>;
    authorizeKeys(db: DocumentScope<any>, keys: Record<string, any> | Array<string> | string): Promise<any>;
    /** removes the keys from the security doc of the db */
    deauthorizeKeys(db: DocumentScope<any>, keys: string[] | string): Promise<any>;
    authorizeUserSessions(personalDBs: any, sessionKeys: string[] | string): Promise<any[]>;
    addUserDB(userDoc: SlUserDoc, dbName: string, designDocs?: any[], type?: string, adminRoles?: string[], memberRoles?: string[], partitioned?: boolean): Promise<string>;
    /**
     * Checks from the superlogin-userDB which keys are expired and removes them
     * from:
     * 1. the CouchDB authentication-DB (`_users`)
     * 2. the security-doc of the user's personal DB
     * 3. the user's doc in the superlogin-DB
     *
     * @returns an array of removed keys
     * @throws This method can fail due to Connection/ CouchDB-Problems.
     */
    removeExpiredKeys(): Promise<string[]>;
    /** deauthenticates the keys from the user's personal DB */
    deauthorizeUser(userDoc: SlUserDoc, keys: any): Promise<boolean> | Promise<any[]>;
    getDesignDoc(docName: string): any;
    getDBConfig(dbName: string, type?: PersonalDBType): PersonalDBSettings & IdentifiedObj;
    createDB(dbName: string, partitioned?: boolean): Promise<boolean>;
    removeDB(dbName: string): Promise<import("nano").OkResponse>;
}
