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, userDB: DocumentScope, couchServer: ServerScope, couchAuthDB?: DocumentScope); storeKey(username: string, user_uid: string, key: string, password: string, expires: number, roles: string[], provider: string): Promise; /** * 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; retrieveKey(key: string): Promise; extendKey(key: string, newExpiration: number): Promise; /** 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; authorizeKeys(db: DocumentScope, keys: Record | Array | string): Promise; /** removes the keys from the security doc of the db */ deauthorizeKeys(db: DocumentScope, keys: string[] | string): Promise; authorizeUserSessions(personalDBs: any, sessionKeys: string[] | string): Promise; addUserDB(userDoc: SlUserDoc, dbName: string, designDocs?: any[], type?: string, adminRoles?: string[], memberRoles?: string[], partitioned?: boolean): Promise; /** * 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; /** deauthenticates the keys from the user's personal DB */ deauthorizeUser(userDoc: SlUserDoc, keys: any): Promise | Promise; getDesignDoc(docName: string): any; getDBConfig(dbName: string, type?: PersonalDBType): PersonalDBSettings & IdentifiedObj; createDB(dbName: string, partitioned?: boolean): Promise; removeDB(dbName: string): Promise; }