imapflow 1.0.97 → 1.0.100
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/CHANGELOG.md +12 -0
- package/lib/commands/append.js +24 -0
- package/lib/commands/list.js +7 -1
- package/lib/commands/status.js +10 -0
- package/lib/imap-flow.js +12 -0
- package/lib/tools.js +20 -7
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
- 1.0.100 - 2022-06-17
|
|
4
|
+
|
|
5
|
+
- Emit new message notification if appending to currently opened folder
|
|
6
|
+
|
|
7
|
+
- 1.0.99 - 2022-06-05
|
|
8
|
+
|
|
9
|
+
- Check if folder exists on failed status command
|
|
10
|
+
|
|
11
|
+
- 1.0.98 - 2022-05-30
|
|
12
|
+
|
|
13
|
+
- Fixed an issue with envelope parsing where literal values were returned as Buffers
|
|
14
|
+
|
|
3
15
|
- 1.0.97 - 2022-05-29
|
|
4
16
|
|
|
5
17
|
- Allow single quotes in atoms
|
package/lib/commands/append.js
CHANGED
|
@@ -62,6 +62,18 @@ module.exports = async (connection, destination, content, flags, idate) => {
|
|
|
62
62
|
? {
|
|
63
63
|
EXISTS: async untagged => {
|
|
64
64
|
map.seq = Number(untagged.command);
|
|
65
|
+
|
|
66
|
+
if (expectExists) {
|
|
67
|
+
let prevCount = connection.mailbox.exists;
|
|
68
|
+
if (map.seq !== prevCount) {
|
|
69
|
+
connection.mailbox.exists = map.seq;
|
|
70
|
+
connection.emit('exists', {
|
|
71
|
+
path: connection.mailbox.path,
|
|
72
|
+
count: map.seq,
|
|
73
|
+
prevCount
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
65
77
|
}
|
|
66
78
|
}
|
|
67
79
|
: false
|
|
@@ -95,6 +107,18 @@ module.exports = async (connection, destination, content, flags, idate) => {
|
|
|
95
107
|
untagged: {
|
|
96
108
|
EXISTS: async untagged => {
|
|
97
109
|
map.seq = Number(untagged.command);
|
|
110
|
+
|
|
111
|
+
if (expectExists) {
|
|
112
|
+
let prevCount = connection.mailbox.exists;
|
|
113
|
+
if (map.seq !== prevCount) {
|
|
114
|
+
connection.mailbox.exists = map.seq;
|
|
115
|
+
connection.emit('exists', {
|
|
116
|
+
path: connection.mailbox.path,
|
|
117
|
+
count: map.seq,
|
|
118
|
+
prevCount
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
98
122
|
}
|
|
99
123
|
},
|
|
100
124
|
comment: 'Sequence not found from APPEND output'
|
package/lib/commands/list.js
CHANGED
|
@@ -4,7 +4,9 @@ const { decodePath, encodePath, normalizePath } = require('../tools.js');
|
|
|
4
4
|
const { specialUse } = require('../special-use');
|
|
5
5
|
|
|
6
6
|
// Lists mailboxes from server
|
|
7
|
-
module.exports = async (connection, reference, mailbox) => {
|
|
7
|
+
module.exports = async (connection, reference, mailbox, options) => {
|
|
8
|
+
options = options || {};
|
|
9
|
+
|
|
8
10
|
let listCommand = connection.capabilities.has('XLIST') && !connection.capabilities.has('SPECIAL-USE') ? 'XLIST' : 'LIST';
|
|
9
11
|
|
|
10
12
|
let response;
|
|
@@ -64,6 +66,10 @@ module.exports = async (connection, reference, mailbox) => {
|
|
|
64
66
|
let normalizedReference = normalizePath(connection, reference || '');
|
|
65
67
|
await runList(normalizedReference, normalizePath(connection, mailbox || '', true));
|
|
66
68
|
|
|
69
|
+
if (options.listOnly) {
|
|
70
|
+
return entries;
|
|
71
|
+
}
|
|
72
|
+
|
|
67
73
|
if (normalizedReference && !entries.find(entry => entry.specialUse === '\\Inbox')) {
|
|
68
74
|
// INBOX was most probably not included in the listing if namespace was used
|
|
69
75
|
await runList('', 'INBOX');
|
package/lib/commands/status.js
CHANGED
|
@@ -126,6 +126,16 @@ module.exports = async (connection, path, query) => {
|
|
|
126
126
|
response.next();
|
|
127
127
|
return map;
|
|
128
128
|
} catch (err) {
|
|
129
|
+
if (err.responseStatus === 'NO') {
|
|
130
|
+
let folders = await connection.run('LIST', '', path, { listOnly: true });
|
|
131
|
+
if (folders && !folders.length) {
|
|
132
|
+
let error = new Error(`Mailbox doesn't exist: ${path}`);
|
|
133
|
+
error.code = 'NotFound';
|
|
134
|
+
error.response = err;
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
129
139
|
connection.log.warn({ err, cid: connection.id });
|
|
130
140
|
return false;
|
|
131
141
|
}
|
package/lib/imap-flow.js
CHANGED
|
@@ -2501,6 +2501,17 @@ class ImapFlow extends EventEmitter {
|
|
|
2501
2501
|
this.currentLockId = lockId;
|
|
2502
2502
|
return resolve({ path, release });
|
|
2503
2503
|
} catch (err) {
|
|
2504
|
+
if (err.responseStatus === 'NO') {
|
|
2505
|
+
try {
|
|
2506
|
+
let folders = await this.run('LIST', '', path, { listOnly: true });
|
|
2507
|
+
if (!folders || !folders.length) {
|
|
2508
|
+
err.mailboxMissing = true;
|
|
2509
|
+
}
|
|
2510
|
+
} catch (E) {
|
|
2511
|
+
this.log.trace({ msg: 'Failed to verify failed mailbox', path, err: E });
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2504
2515
|
this.log.trace({ msg: 'Failed to acquire mailbox lock', path, lockId });
|
|
2505
2516
|
reject(err);
|
|
2506
2517
|
await this.processLocks(true);
|
|
@@ -2531,6 +2542,7 @@ class ImapFlow extends EventEmitter {
|
|
|
2531
2542
|
*/
|
|
2532
2543
|
async getMailboxLock(path, options) {
|
|
2533
2544
|
options = options || {};
|
|
2545
|
+
|
|
2534
2546
|
path = normalizePath(this, path);
|
|
2535
2547
|
|
|
2536
2548
|
let lockId = ++this.lockCounter;
|
package/lib/tools.js
CHANGED
|
@@ -350,25 +350,38 @@ module.exports = {
|
|
|
350
350
|
},
|
|
351
351
|
|
|
352
352
|
parseEnvelope(entry) {
|
|
353
|
+
let getStrValue = obj => {
|
|
354
|
+
if (!obj) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
if (typeof obj.value === 'string') {
|
|
358
|
+
return obj.value;
|
|
359
|
+
}
|
|
360
|
+
if (Buffer.isBuffer(obj.value)) {
|
|
361
|
+
return obj.value.toString();
|
|
362
|
+
}
|
|
363
|
+
return obj.value;
|
|
364
|
+
};
|
|
365
|
+
|
|
353
366
|
let processAddresses = function (list) {
|
|
354
367
|
return [].concat(list || []).map(addr => ({
|
|
355
|
-
name: libmime.decodeWords((addr[0]
|
|
356
|
-
address: ((addr[2]
|
|
368
|
+
name: libmime.decodeWords(getStrValue(addr[0]) || ''),
|
|
369
|
+
address: (getStrValue(addr[2]) || '') + '@' + (getStrValue(addr[3]) || '')
|
|
357
370
|
}));
|
|
358
371
|
},
|
|
359
372
|
envelope = {};
|
|
360
373
|
|
|
361
374
|
if (entry[0] && entry[0].value) {
|
|
362
|
-
let date = new Date(entry[0]
|
|
375
|
+
let date = new Date(getStrValue(entry[0]));
|
|
363
376
|
if (date.toString() === 'Invalid Date') {
|
|
364
|
-
envelope.date = entry[0]
|
|
377
|
+
envelope.date = getStrValue(entry[0]);
|
|
365
378
|
} else {
|
|
366
379
|
envelope.date = date;
|
|
367
380
|
}
|
|
368
381
|
}
|
|
369
382
|
|
|
370
383
|
if (entry[1] && entry[1].value) {
|
|
371
|
-
envelope.subject = libmime.decodeWords(entry[1]
|
|
384
|
+
envelope.subject = libmime.decodeWords(getStrValue(entry[1]));
|
|
372
385
|
}
|
|
373
386
|
|
|
374
387
|
if (entry[2] && entry[2].length) {
|
|
@@ -396,11 +409,11 @@ module.exports = {
|
|
|
396
409
|
}
|
|
397
410
|
|
|
398
411
|
if (entry[8] && entry[8].value) {
|
|
399
|
-
envelope.inReplyTo = entry[8].
|
|
412
|
+
envelope.inReplyTo = (getStrValue(entry[8]) || '').toString().trim();
|
|
400
413
|
}
|
|
401
414
|
|
|
402
415
|
if (entry[9] && entry[9].value) {
|
|
403
|
-
envelope.messageId = entry[9].
|
|
416
|
+
envelope.messageId = (getStrValue(entry[9]) || '').toString().trim();
|
|
404
417
|
}
|
|
405
418
|
|
|
406
419
|
return envelope;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imapflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.100",
|
|
4
4
|
"description": "IMAP Client for Node",
|
|
5
5
|
"main": "./lib/imap-flow.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://imapflow.com/",
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@babel/eslint-parser": "7.
|
|
30
|
+
"@babel/eslint-parser": "7.18.2",
|
|
31
31
|
"@babel/eslint-plugin": "7.17.7",
|
|
32
32
|
"@babel/plugin-syntax-class-properties": "7.12.13",
|
|
33
|
-
"@babel/preset-env": "7.
|
|
34
|
-
"@types/node": "
|
|
33
|
+
"@babel/preset-env": "7.18.2",
|
|
34
|
+
"@types/node": "18.0.0",
|
|
35
35
|
"braintree-jsdoc-template": "3.3.0",
|
|
36
|
-
"eslint": "8.
|
|
36
|
+
"eslint": "8.18.0",
|
|
37
37
|
"eslint-config-nodemailer": "1.2.0",
|
|
38
38
|
"eslint-config-prettier": "8.5.0",
|
|
39
39
|
"grunt": "1.5.3",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"libqp": "1.1.0",
|
|
53
53
|
"mailsplit": "5.3.2",
|
|
54
54
|
"nodemailer": "6.7.5",
|
|
55
|
-
"pino": "
|
|
55
|
+
"pino": "8.0.0",
|
|
56
56
|
"socks": "2.6.2"
|
|
57
57
|
}
|
|
58
58
|
}
|