-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
67 lines (65 loc) · 1.71 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
declare module 'telegram-mtproto' {
type DC = {
id: number
host: string
port: number
}
type ServerConfig = {
dev?: boolean
webogram?: boolean
dcList?: Array<DC>
}
type PublicKey = {
modulus: string
exponent: string
}
type AppConfig = {
debug?: boolean
publicKeys?: Array<PublicKey>
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
}
interface ApiManagerInstance {
readonly storage: AsyncStorage
readonly updates: any
<T>(method: string): Promise<T>
<T>(method: string, params: Object): Promise<T>
<T>(method: string, params: Object, options: Object): Promise<T>
setUserAuth<T>(dc: number, userAuth: T): void
on(event: string|string[], handler: Function)
}
interface IApiManager {
new (): ApiManagerInstance
new ({ server, api, app, schema, mtSchema }: Config): ApiManagerInstance
}
export const ApiManager: IApiManager
class ApiManagerClass {
readonly storage: AsyncStorage
setUserAuth<T>(dc: number, userAuth: T): void
on(event: string|string[], handler: Function)
}
export interface AsyncStorage {
get(key: string): Promise<any>
set(key: string, val: any): Promise<any>
remove(...keys: string[]): Promise<any>
clear(): Promise<{}>
}
function MTProto({ server, api, app, schema, mtSchema }: Config): ApiManagerInstance
export default MTProto
}