imapflow 1.0.162 → 1.0.164
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 +15 -0
- package/lib/handler/token-parser.js +10 -4
- package/lib/imap-flow.js +38 -19
- package/lib/types.d.ts +29 -4
- package/package.json +8 -8
- package/test/imap-parser-test.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.164](https://github.com/postalsys/imapflow/compare/v1.0.163...v1.0.164) (2024-07-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **api:** Add fetchAll method ([#207](https://github.com/postalsys/imapflow/issues/207)) ([bc09998](https://github.com/postalsys/imapflow/commit/bc09998270006ea6ff8430b3461619dd9b3e91c8))
|
|
9
|
+
|
|
10
|
+
## [1.0.163](https://github.com/postalsys/imapflow/compare/v1.0.162...v1.0.163) (2024-07-06)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **parser:** parse subfolders with square brackets ([0d0e8a6](https://github.com/postalsys/imapflow/commit/0d0e8a6ea379adf11594684d49a1ce5031339939))
|
|
16
|
+
* **socket:** Use destroy() instead of destroySoon() ([830c2d1](https://github.com/postalsys/imapflow/commit/830c2d18f3d27eb12dc6babe4edd37fed5f65490))
|
|
17
|
+
|
|
3
18
|
## [1.0.162](https://github.com/postalsys/imapflow/compare/v1.0.161...v1.0.162) (2024-05-07)
|
|
4
19
|
|
|
5
20
|
|
|
@@ -355,10 +355,16 @@ class TokenParser {
|
|
|
355
355
|
if (chr === '[') {
|
|
356
356
|
// allowed only for selected elements
|
|
357
357
|
if (['BODY', 'BODY.PEEK', 'BINARY', 'BINARY.PEEK'].indexOf(this.currentNode.value.toUpperCase()) < 0) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
358
|
+
if (/[./]/.test(this.currentNode.value)) {
|
|
359
|
+
// could be a path
|
|
360
|
+
this.currentNode.value += chr;
|
|
361
|
+
break;
|
|
362
|
+
} else {
|
|
363
|
+
let error = new Error(`Unexpected section start char [ at position ${this.pos + i} [E14]`);
|
|
364
|
+
error.code = 'ParserError14';
|
|
365
|
+
error.parserContext = { input: this.str, pos: this.pos + i, chr };
|
|
366
|
+
throw error;
|
|
367
|
+
}
|
|
362
368
|
}
|
|
363
369
|
this.currentNode.endPos = this.pos + i;
|
|
364
370
|
this.currentNode = this.createNode(this.currentNode.parentNode, this.pos + i);
|
package/lib/imap-flow.js
CHANGED
|
@@ -768,11 +768,7 @@ class ImapFlow extends EventEmitter {
|
|
|
768
768
|
this.writeSocket.destroySoon = () => {
|
|
769
769
|
try {
|
|
770
770
|
if (this.socket) {
|
|
771
|
-
|
|
772
|
-
this.socket.destroySoon();
|
|
773
|
-
} else {
|
|
774
|
-
this.socket.destroy();
|
|
775
|
-
}
|
|
771
|
+
this.socket.destroy();
|
|
776
772
|
}
|
|
777
773
|
this.writeSocket.end();
|
|
778
774
|
} catch (err) {
|
|
@@ -1484,11 +1480,7 @@ class ImapFlow extends EventEmitter {
|
|
|
1484
1480
|
|
|
1485
1481
|
if (this.writeSocket && !this.writeSocket.destroyed) {
|
|
1486
1482
|
try {
|
|
1487
|
-
|
|
1488
|
-
this.writeSocket.destroySoon();
|
|
1489
|
-
} else {
|
|
1490
|
-
this.writeSocket.destroy();
|
|
1491
|
-
}
|
|
1483
|
+
this.writeSocket.destroy();
|
|
1492
1484
|
} catch (err) {
|
|
1493
1485
|
this.log.error({ err, cid: this.id });
|
|
1494
1486
|
}
|
|
@@ -1496,11 +1488,7 @@ class ImapFlow extends EventEmitter {
|
|
|
1496
1488
|
|
|
1497
1489
|
if (this.socket && !this.socket.destroyed && this.writeSocket !== this.socket) {
|
|
1498
1490
|
try {
|
|
1499
|
-
|
|
1500
|
-
this.socket.destroySoon();
|
|
1501
|
-
} else {
|
|
1502
|
-
this.socket.destroy();
|
|
1503
|
-
}
|
|
1491
|
+
this.socket.destroy();
|
|
1504
1492
|
} catch (err) {
|
|
1505
1493
|
this.log.error({ err, cid: this.id });
|
|
1506
1494
|
}
|
|
@@ -2022,7 +2010,7 @@ class ImapFlow extends EventEmitter {
|
|
|
2022
2010
|
}
|
|
2023
2011
|
|
|
2024
2012
|
/**
|
|
2025
|
-
* Delete messages from currently opened mailbox. Method does not indicate info about deleted messages,
|
|
2013
|
+
* Delete messages from the currently opened mailbox. Method does not indicate info about deleted messages,
|
|
2026
2014
|
* instead you should be using {@link ImapFlow#expunge} event for this
|
|
2027
2015
|
*
|
|
2028
2016
|
* @param {SequenceString | Number[] | SearchObject} range Range to filter the messages
|
|
@@ -2133,7 +2121,7 @@ class ImapFlow extends EventEmitter {
|
|
|
2133
2121
|
}
|
|
2134
2122
|
|
|
2135
2123
|
/**
|
|
2136
|
-
* Search messages from currently opened mailbox
|
|
2124
|
+
* Search messages from the currently opened mailbox
|
|
2137
2125
|
*
|
|
2138
2126
|
* @param {SearchObject} query Query to filter the messages
|
|
2139
2127
|
* @param {Object} [options]
|
|
@@ -2252,7 +2240,7 @@ class ImapFlow extends EventEmitter {
|
|
|
2252
2240
|
*/
|
|
2253
2241
|
|
|
2254
2242
|
/**
|
|
2255
|
-
* Fetch messages from currently opened mailbox
|
|
2243
|
+
* Fetch messages from the currently opened mailbox
|
|
2256
2244
|
*
|
|
2257
2245
|
* @param {SequenceString | Number[] | SearchObject} range Range of messages to fetch
|
|
2258
2246
|
* @param {FetchQueryObject} query Fetch query
|
|
@@ -2365,7 +2353,38 @@ class ImapFlow extends EventEmitter {
|
|
|
2365
2353
|
}
|
|
2366
2354
|
|
|
2367
2355
|
/**
|
|
2368
|
-
* Fetch
|
|
2356
|
+
* Fetch messages from the currently opened mailbox.
|
|
2357
|
+
*
|
|
2358
|
+
* This method will fetch all messages before resolving the promise, unlike .fetch(), which
|
|
2359
|
+
* is an async generator. Do not use large ranges like 1:*, as this might exhaust all available
|
|
2360
|
+
* memory if the mailbox contains a large number of emails.
|
|
2361
|
+
* @param {SequenceString | Number[] | SearchObject} range Range of messages to fetch
|
|
2362
|
+
* @param {FetchQueryObject} query Fetch query
|
|
2363
|
+
* @param {Object} [options]
|
|
2364
|
+
* @param {Boolean} [options.uid] If `true` then uses UID numbers instead of sequence numbers for `range`
|
|
2365
|
+
* @param {BigInt} [options.changedSince] If set then only messages with a higher modseq value are returned. Ignored if server does not support `CONDSTORE` extension.
|
|
2366
|
+
* @param {Boolean} [options.binary=false] If `true` then requests a binary response if the server supports this
|
|
2367
|
+
* @returns {Promise<FetchMessageObject[]>} Array of Message data object
|
|
2368
|
+
*
|
|
2369
|
+
* @example
|
|
2370
|
+
* let mailbox = await client.mailboxOpen('INBOX');
|
|
2371
|
+
* // fetch UID for all messages in a mailbox
|
|
2372
|
+
* const messages = await client.fetchAll('1:*', {uid: true});
|
|
2373
|
+
* for (let msg of messages){
|
|
2374
|
+
* console.log(msg.uid);
|
|
2375
|
+
* }
|
|
2376
|
+
*/
|
|
2377
|
+
async fetchAll(range, query, options) {
|
|
2378
|
+
const results = [];
|
|
2379
|
+
const generator = this.fetch(range, query, options);
|
|
2380
|
+
for await (const message of generator) {
|
|
2381
|
+
results.push(message);
|
|
2382
|
+
}
|
|
2383
|
+
return results;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
/**
|
|
2387
|
+
* Fetch a single message from the currently opened mailbox
|
|
2369
2388
|
*
|
|
2370
2389
|
* @param {SequenceString} seq Single UID or sequence number of the message to fetch for
|
|
2371
2390
|
* @param {FetchQueryObject} query Fetch query
|
package/lib/types.d.ts
CHANGED
|
@@ -355,7 +355,7 @@ declare module "imapflow" {
|
|
|
355
355
|
unchangedSince?: bigint;
|
|
356
356
|
}): Promise<Boolean>;
|
|
357
357
|
/**
|
|
358
|
-
* Delete messages from currently opened mailbox. Method does not indicate info about deleted messages,
|
|
358
|
+
* Delete messages from the currently opened mailbox. Method does not indicate info about deleted messages,
|
|
359
359
|
* instead you should be using {@link ImapFlow#expunge} event for this
|
|
360
360
|
* @example
|
|
361
361
|
* let mailbox = await client.mailboxOpen('INBOX');
|
|
@@ -410,7 +410,7 @@ declare module "imapflow" {
|
|
|
410
410
|
uid?: boolean;
|
|
411
411
|
}): Promise<CopyResponseObject>;
|
|
412
412
|
/**
|
|
413
|
-
* Search messages from currently opened mailbox
|
|
413
|
+
* Search messages from the currently opened mailbox
|
|
414
414
|
* @example
|
|
415
415
|
* let mailbox = await client.mailboxOpen('INBOX');
|
|
416
416
|
* // find all unseen messages
|
|
@@ -431,7 +431,7 @@ declare module "imapflow" {
|
|
|
431
431
|
uid?: boolean;
|
|
432
432
|
}): Promise<Number[]>;
|
|
433
433
|
/**
|
|
434
|
-
* Fetch messages from currently opened mailbox
|
|
434
|
+
* Fetch messages from the currently opened mailbox
|
|
435
435
|
* @example
|
|
436
436
|
* let mailbox = await client.mailboxOpen('INBOX');
|
|
437
437
|
* // fetch UID for all messages in a mailbox
|
|
@@ -452,7 +452,32 @@ declare module "imapflow" {
|
|
|
452
452
|
binary?: boolean;
|
|
453
453
|
}): void;
|
|
454
454
|
/**
|
|
455
|
-
* Fetch
|
|
455
|
+
* Fetch messages from the currently opened mailbox.
|
|
456
|
+
*
|
|
457
|
+
* This method will fetch all messages before resolving the promise, unlike .fetch(), which
|
|
458
|
+
* is an async generator. Do not use large ranges like 1:*, as this might exhaust all available
|
|
459
|
+
* memory if the mailbox contains a large number of emails.
|
|
460
|
+
* @example
|
|
461
|
+
* let mailbox = await client.mailboxOpen('INBOX');
|
|
462
|
+
* // fetch UID for all messages in a mailbox
|
|
463
|
+
* const messages = await client.fetchAll('1:*', {uid: true});
|
|
464
|
+
* for (let msg of messages){
|
|
465
|
+
* console.log(msg.uid);
|
|
466
|
+
* }
|
|
467
|
+
* @param range - Range of messages to fetch
|
|
468
|
+
* @param query - Fetch query
|
|
469
|
+
* @param [options.uid] - If `true` then uses UID numbers instead of sequence numbers for `range`
|
|
470
|
+
* @param [options.changedSince] - If set then only messages with a higher modseq value are returned. Ignored if server does not support `CONDSTORE` extension.
|
|
471
|
+
* @param [options.binary = false] - If `true` then requests a binary response if the server supports this
|
|
472
|
+
* @returns Array of Message data object
|
|
473
|
+
*/
|
|
474
|
+
fetchAll(range: SequenceString | Number[] | SearchObject, query: FetchQueryObject, options?: {
|
|
475
|
+
uid?: boolean;
|
|
476
|
+
changedSince?: bigint;
|
|
477
|
+
binary?: boolean;
|
|
478
|
+
}): Promise<FetchMessageObject[]>;
|
|
479
|
+
/**
|
|
480
|
+
* Fetch a single message from the currently opened mailbox
|
|
456
481
|
* @example
|
|
457
482
|
* let mailbox = await client.mailboxOpen('INBOX');
|
|
458
483
|
* // fetch UID for the last email in the selected mailbox
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imapflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.164",
|
|
4
4
|
"description": "IMAP Client for Node",
|
|
5
5
|
"main": "./lib/imap-flow.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://imapflow.com/",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@babel/eslint-parser": "7.24.
|
|
32
|
-
"@babel/eslint-plugin": "7.24.
|
|
31
|
+
"@babel/eslint-parser": "7.24.7",
|
|
32
|
+
"@babel/eslint-plugin": "7.24.7",
|
|
33
33
|
"@babel/plugin-syntax-class-properties": "7.12.13",
|
|
34
|
-
"@babel/preset-env": "7.24.
|
|
35
|
-
"@types/node": "20.
|
|
34
|
+
"@babel/preset-env": "7.24.7",
|
|
35
|
+
"@types/node": "20.14.10",
|
|
36
36
|
"eslint": "8.57.0",
|
|
37
37
|
"eslint-config-nodemailer": "1.2.0",
|
|
38
38
|
"eslint-config-prettier": "9.1.0",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"tsd-jsdoc": "2.5.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"encoding-japanese": "2.
|
|
49
|
+
"encoding-japanese": "2.2.0",
|
|
50
50
|
"iconv-lite": "0.6.3",
|
|
51
51
|
"libbase64": "1.3.0",
|
|
52
52
|
"libmime": "5.3.5",
|
|
53
53
|
"libqp": "2.1.0",
|
|
54
54
|
"mailsplit": "5.4.0",
|
|
55
|
-
"nodemailer": "6.9.
|
|
56
|
-
"pino": "9.
|
|
55
|
+
"nodemailer": "6.9.14",
|
|
56
|
+
"pino": "9.2.0",
|
|
57
57
|
"socks": "2.8.3"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/test/imap-parser-test.js
CHANGED
|
@@ -992,3 +992,13 @@ module.exports['IMAP Parser, BAD with throttling'] = test =>
|
|
|
992
992
|
test.equal(parsed.command, 'BAD');
|
|
993
993
|
test.deepEqual(parsed.attributes, [{ type: 'TEXT', value: 'Request is throttled. Suggested Backoff Time: 92415 milliseconds' }]);
|
|
994
994
|
});
|
|
995
|
+
|
|
996
|
+
module.exports['IMAP Parser, subfolder square bracket'] = test =>
|
|
997
|
+
asyncWrapper(test, async test => {
|
|
998
|
+
let parsed = await parser('* LIST (\\UnMarked) "." INBOX.[Airmail].Snooze');
|
|
999
|
+
test.deepEqual(parsed.attributes, [
|
|
1000
|
+
[{ type: 'ATOM', value: '\\UnMarked' }],
|
|
1001
|
+
{ type: 'STRING', value: '.' },
|
|
1002
|
+
{ type: 'ATOM', value: 'INBOX.[Airmail].Snooze' }
|
|
1003
|
+
]);
|
|
1004
|
+
});
|