UNPKG

1.71 kBTypeScriptView Raw
1declare module 'telegram-mtproto' {
2 type DC = {
3 id: number
4 host: string
5 port: number
6 }
7 type ServerConfig = {
8 dev?: boolean
9 webogram?: boolean
10 dcList?: Array<DC>
11 }
12 type PublicKey = {
13 modulus: string
14 exponent: string
15 }
16 type AppConfig = {
17 debug?: boolean
18 publicKeys?: Array<PublicKey>
19 storage?: AsyncStorage
20 }
21 type ApiConfig = {
22 invokeWithLayer?: number
23 layer ?: number
24 initConnection ?: number
25 api_id ?: number
26 device_model ?: string
27 system_version ?: string
28 app_version ?: string
29 lang_code ?: string
30 }
31 type Config = {
32 server?: ServerConfig
33 api?: ApiConfig
34 app?: AppConfig
35 schema?: object
36 mtSchema?: object
37 }
38 type UpdatesManager = any
39
40 interface ApiManagerInstance {
41 readonly storage: AsyncStorage
42 readonly updates: UpdatesManager
43 <T>(method: string, params?: object, options?: object): Promise<T>
44 setUserAuth<T>(dc: number, userAuth: T): void
45 on(event: string|Array<string>, handler: Function)
46 }
47 interface ApiManager {
48 new ({ server, api, app, schema, mtSchema }?: Config): ApiManagerInstance
49 }
50 export const ApiManager: ApiManager
51 class ApiManagerClass {
52 public readonly storage: AsyncStorage
53 public setUserAuth<T>(dc: number, userAuth: T): void
54 public on(event: string|Array<string>, handler: Function)
55 }
56 export interface AsyncStorage {
57 get(key: string): Promise<any>
58 set(key: string, val: any): Promise<any>
59 remove(...keys: Array<string>): Promise<any>
60 clear(): Promise<{}>
61 }
62
63 function MTProto({ server, api, app, schema, mtSchema }: Config): ApiManagerInstance
64 export default MTProto
65}
66
\No newline at end of file