forked from emailjs/emailjs-imap-client
/
index.d.ts
133 lines (122 loc) · 3.43 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
export const LOG_LEVEL_NONE = 1000
export const LOG_LEVEL_ERROR = 40
export const LOG_LEVEL_WARN = 30
export const LOG_LEVEL_INFO = 20
export const LOG_LEVEL_DEBUG = 10
export const LOG_LEVEL_ALL = 0
export const TIMEOUT_CONNECTION = 90 * 1000 // Milliseconds to wait for the IMAP greeting from the server
export const TIMEOUT_NOOP = 60 * 1000 // Milliseconds between NOOP commands while idling
export const TIMEOUT_IDLE = 60 * 1000 // Milliseconds until IDLE command is cancelled
export const STATE_CONNECTING = 1
export const STATE_NOT_AUTHENTICATED = 2
export const STATE_AUTHENTICATED = 3
export const STATE_SELECTED = 4
export const STATE_LOGOUT = 5
export const DEFAULT_CLIENT_ID = {
name: 'emailjs-imap-client',
}
export interface AuthObject {
user?: string
pass?: string
xoauth2?: string
}
export interface ClientOptions {
id?: { name: string }
enableCompression?: boolean
auth?: AuthObject
requireTLS?: boolean
ignoreTLS?: boolean
logLevel?: number
}
export interface MailboxInfo {
readOnly: boolean
exists: number
flags: string[]
permanentFlags: string[]
uidValidity: number
uidNext: number
highestModseq: string
noModseq: boolean
}
export interface MessageInfo {
'#': number
uid: number
modseq: string
flags: string[]
xGmLabels: string[]
envelope: any
bodystructure: any
}
export interface Mailbox {
name: string
delimiter: string
path: string
children: Mailbox[]
flags: string[]
listed: boolean
subscribed: boolean
specialUse: string
specialUseFlag: string
}
export default class Client {
constructor(host?: string, port?: number, options?: ClientOptions)
oncert: (cert: any) => void
onupdate: (path: string, type: string, data: any) => void
onselectmailbox: (path: string, info: MailboxInfo) => void
onclosemailbox: (path: string) => void
connect(): Promise<void>
openConnection(): Promise<string[]>
logout(): Promise<void>
close(err?: Error): Promise<void>
updateId(id?: any): Promise<void>
selectMailbox(path: string, options?: any): Promise<MailboxInfo>
subscribeMailbox(path: string): Promise<void>
unsubscribeMailbox(path: string): Promise<void>
listNamespaces(): Promise<any>
listMailboxes(): Promise<Mailbox>
createMailbox(path: string): Promise<void>
deleteMailbox(path: string): Promise<void>
listMessages(
path: string,
sequence: string,
items?: any[],
options?: any
): Promise<MessageInfo[]>
search(path: string, query: any, options?: any): Promise<number[]>
setFlags(
path: string,
sequence: string,
flags: any,
options?: any
): Promise<MessageInfo[]>
store(
path: string,
sequence: string,
action: string,
flags: any[],
options?: any
): Promise<MessageInfo[]>
upload(destination: string, message: string, options?: any): Promise<string>
deleteMessages(path: string, sequence: string, options?: any): Promise<void>
copyMessages(
path: string,
sequence: string,
destination: string,
options?: any
): Promise<any>
moveMessages(
path: string,
sequence: string,
destination: string,
options?: any
): Promise<void>
compressConnection(): Promise<void>
login(auth: AuthObject): Promise<void>
exec(request: any, acceptUntagged?: any[], options?: any): Promise<any>
enterIdle(): void
breakIdle(): void
upgradeConnection(): Promise<void>
updateCapability(forced?: boolean): Promise<void>
hasCapability(capa?: string): boolean
getOkGreeting(): string
}