declare module 'api-mtproto' { type DC = { id: number host: string port: number } type ServerConfig = { dev?: boolean webogram?: boolean dcList?: Array } type PublicKey = { modulus: string exponent: string } type AppConfig = { debug?: boolean publicKeys?: Array storage?: AsyncStorage } type ApiConfig = { invokeWithLayer?: number layer ?: number initConnection ?: number api_id ?: number device_model ?: string system_version ?: string app_version ?: string lang_code ?: string } type Config = { server?: ServerConfig api?: ApiConfig app?: AppConfig schema?: Object mtSchema?: Object } export interface ApiManagerInstance { readonly storage: AsyncStorage readonly updates: any (method: string): Promise (method: string, params: Object): Promise (method: string, params: Object, options: Object): Promise setUserAuth(dc: number, userAuth: T): void on(event: string|string[], handler: Function): void } interface IApiManager { new (): ApiManagerInstance new ({ server, api, app, schema, mtSchema }: Config): ApiManagerInstance } export const ApiManager: IApiManager class ApiManagerClass { readonly storage: AsyncStorage setUserAuth(dc: number, userAuth: T): void on(event: string|string[], handler: Function): void } export interface AsyncStorage { get(key: string): Promise set(key: string, val: any): Promise remove(...keys: string[]): Promise clear(): Promise<{}> } function MTProto({ server, api, app, schema, mtSchema }: Config): ApiManagerInstance export default MTProto }