imapflow 1.0.131 → 1.0.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/close.js +1 -0
- package/lib/commands/idle.js +11 -1
- package/lib/commands/select.js +2 -0
- package/lib/imap-flow.js +3 -0
- package/lib/tools.js +9 -1
- package/lib/types.d.ts +2 -0
- package/package.json +1 -1
package/lib/commands/close.js
CHANGED
package/lib/commands/idle.js
CHANGED
|
@@ -150,7 +150,17 @@ module.exports = async (connection, maxIdleTime) => {
|
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
let idleCheck = async () => {
|
|
153
|
-
let response
|
|
153
|
+
let response;
|
|
154
|
+
switch (connection.missingIdleCommand) {
|
|
155
|
+
case 'SELECT':
|
|
156
|
+
connection.log.debug({ src: 'c', msg: `Running SELECT to detect changes in folder` });
|
|
157
|
+
response = await connection.exec('SELECT', connection.mailbox.path, connection.mailboxOptions);
|
|
158
|
+
break;
|
|
159
|
+
case 'NOOP':
|
|
160
|
+
default:
|
|
161
|
+
response = await connection.exec('NOOP', false, { comment: 'IDLE not supported' });
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
154
164
|
response.next();
|
|
155
165
|
};
|
|
156
166
|
|
package/lib/commands/select.js
CHANGED
|
@@ -183,6 +183,7 @@ module.exports = async (connection, path, options) => {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
connection.mailbox = map;
|
|
186
|
+
connection.mailboxOptions = options;
|
|
186
187
|
connection.state = connection.states.SELECTED;
|
|
187
188
|
|
|
188
189
|
if (!currentMailbox || currentMailbox.path !== path) {
|
|
@@ -204,6 +205,7 @@ module.exports = async (connection, path, options) => {
|
|
|
204
205
|
let currentMailbox = connection.mailbox;
|
|
205
206
|
|
|
206
207
|
connection.mailbox = false;
|
|
208
|
+
connection.mailboxOptions = false;
|
|
207
209
|
connection.state = connection.states.AUTHENTICATED;
|
|
208
210
|
|
|
209
211
|
if (currentMailbox) {
|
package/lib/imap-flow.js
CHANGED
|
@@ -130,6 +130,7 @@ class ImapFlow extends EventEmitter {
|
|
|
130
130
|
* @param {String} [options.proxy] Optional proxy URL. Supports HTTP CONNECT (`http://`, `https://`) and SOCKS (`socks://`, `socks4://`, `socks5://`) proxies
|
|
131
131
|
* @param {Boolean} [options.qresync=false] If true, then enables QRESYNC support. EXPUNGE notifications will include `uid` property instead of `seq`
|
|
132
132
|
* @param {Number} [options.maxIdleTime] If set, then breaks and restarts IDLE every maxIdleTime ms
|
|
133
|
+
* @param {String} [options.missingIdleCommand="NOOP"] Which command to use if server does not support IDLE
|
|
133
134
|
* @param {Boolean} [options.disableBinary=false] If true, then ignores the BINARY extension when making FETCH and APPEND calls
|
|
134
135
|
* @param {Boolean} [options.disableAutoEnable] Do not enable supported extensions by default
|
|
135
136
|
* @param {Number} [options.connectionTimeout=90000] how many milliseconds to wait for the connection to establish (default is 90 seconds)
|
|
@@ -247,6 +248,7 @@ class ImapFlow extends EventEmitter {
|
|
|
247
248
|
* @type {MailboxObject|Boolean}
|
|
248
249
|
*/
|
|
249
250
|
this.mailbox = false;
|
|
251
|
+
this.mailboxOptions = false;
|
|
250
252
|
|
|
251
253
|
/**
|
|
252
254
|
* Is current mailbox idling (`true`) or not (`false`)
|
|
@@ -275,6 +277,7 @@ class ImapFlow extends EventEmitter {
|
|
|
275
277
|
this.idRequested = false;
|
|
276
278
|
|
|
277
279
|
this.maxIdleTime = this.options.maxIdleTime || false;
|
|
280
|
+
this.missingIdleCommand = (this.options.missingIdleCommand || '').toString().toUpperCase().trim() || 'NOOP';
|
|
278
281
|
|
|
279
282
|
this.disableBinary = !!this.options.disableBinary;
|
|
280
283
|
|
package/lib/tools.js
CHANGED
|
@@ -354,6 +354,14 @@ module.exports = {
|
|
|
354
354
|
return map;
|
|
355
355
|
},
|
|
356
356
|
|
|
357
|
+
processName(name) {
|
|
358
|
+
name = (name || '').toString();
|
|
359
|
+
if (name.length > 2 && name.at(0) === '"' && name.at(-1) === '"') {
|
|
360
|
+
name = name.replace(/^"|"$/g, '');
|
|
361
|
+
}
|
|
362
|
+
return name;
|
|
363
|
+
},
|
|
364
|
+
|
|
357
365
|
parseEnvelope(entry) {
|
|
358
366
|
let getStrValue = obj => {
|
|
359
367
|
if (!obj) {
|
|
@@ -370,7 +378,7 @@ module.exports = {
|
|
|
370
378
|
|
|
371
379
|
let processAddresses = function (list) {
|
|
372
380
|
return [].concat(list || []).map(addr => ({
|
|
373
|
-
name: libmime.decodeWords(getStrValue(addr[0])
|
|
381
|
+
name: module.exports.processName(libmime.decodeWords(getStrValue(addr[0]))),
|
|
374
382
|
address: (getStrValue(addr[2]) || '') + '@' + (getStrValue(addr[3]) || '')
|
|
375
383
|
}));
|
|
376
384
|
},
|
package/lib/types.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare module "imapflow" {
|
|
|
29
29
|
* @param [options.proxy] - Optional proxy URL. Supports HTTP CONNECT (`http://`, `https://`) and SOCKS (`socks://`, `socks4://`, `socks5://`) proxies
|
|
30
30
|
* @param [options.qresync = false] - If true, then enables QRESYNC support. EXPUNGE notifications will include `uid` property instead of `seq`
|
|
31
31
|
* @param [options.maxIdleTime] - If set, then breaks and restarts IDLE every maxIdleTime ms
|
|
32
|
+
* @param [options.missingIdleCommand = "NOOP"] - Which command to use if server does not support IDLE
|
|
32
33
|
* @param [options.disableBinary = false] - If true, then ignores the BINARY extension when making FETCH and APPEND calls
|
|
33
34
|
* @param [options.disableAutoEnable] - Do not enable supported extensions by default
|
|
34
35
|
* @param [options.connectionTimeout = 90000] - how many milliseconds to wait for the connection to establish (default is 90 seconds)
|
|
@@ -61,6 +62,7 @@ declare module "imapflow" {
|
|
|
61
62
|
proxy?: string;
|
|
62
63
|
qresync?: boolean;
|
|
63
64
|
maxIdleTime?: number;
|
|
65
|
+
missingIdleCommand?: string;
|
|
64
66
|
disableBinary?: boolean;
|
|
65
67
|
disableAutoEnable?: boolean;
|
|
66
68
|
connectionTimeout?: number;
|