imapflow 1.0.146 → 1.0.148
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 +14 -0
- package/jsdoc.json +1 -1
- package/lib/commands/idle.js +0 -2
- package/lib/commands/logout.js +3 -0
- package/lib/imap-flow.js +20 -11
- package/lib/types.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.148](https://github.com/postalsys/imapflow/compare/v1.0.147...v1.0.148) (2024-01-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **logout:** Fixed race condition for logout and TCP close. Fixes [#161](https://github.com/postalsys/imapflow/issues/161) ([39a7333](https://github.com/postalsys/imapflow/commit/39a7333a39499e4876abb29149f7c72f2f99a63d))
|
|
9
|
+
|
|
10
|
+
## [1.0.147](https://github.com/postalsys/imapflow/compare/v1.0.146...v1.0.147) (2023-10-26)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **idle:** removed unneeded variable ([da59d9a](https://github.com/postalsys/imapflow/commit/da59d9a960dd0992b22335902808a315b1cb6ded))
|
|
16
|
+
|
|
3
17
|
## [1.0.146](https://github.com/postalsys/imapflow/compare/v1.0.145...v1.0.146) (2023-10-26)
|
|
4
18
|
|
|
5
19
|
|
package/jsdoc.json
CHANGED
package/lib/commands/idle.js
CHANGED
package/lib/commands/logout.js
CHANGED
|
@@ -18,6 +18,9 @@ module.exports = async connection => {
|
|
|
18
18
|
response = await connection.exec('LOGOUT');
|
|
19
19
|
return true;
|
|
20
20
|
} catch (err) {
|
|
21
|
+
if (err.code === 'NoConnection') {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
21
24
|
connection.log.warn({ err, cid: connection.id });
|
|
22
25
|
return false;
|
|
23
26
|
} finally {
|
package/lib/imap-flow.js
CHANGED
|
@@ -371,7 +371,9 @@ class ImapFlow extends EventEmitter {
|
|
|
371
371
|
let request = this.requestTagMap.get(data.tag);
|
|
372
372
|
if (request) {
|
|
373
373
|
this.requestTagMap.delete(request.tag);
|
|
374
|
-
|
|
374
|
+
const error = new Error('Connection not available');
|
|
375
|
+
error.code = 'NoConnection';
|
|
376
|
+
request.reject(error);
|
|
375
377
|
}
|
|
376
378
|
}
|
|
377
379
|
return;
|
|
@@ -595,6 +597,7 @@ class ImapFlow extends EventEmitter {
|
|
|
595
597
|
|
|
596
598
|
default: {
|
|
597
599
|
let err = new Error('Invalid server response');
|
|
600
|
+
err.code = 'InvalidResponse';
|
|
598
601
|
err.response = parsed;
|
|
599
602
|
request.reject(err);
|
|
600
603
|
break;
|
|
@@ -1393,7 +1396,7 @@ class ImapFlow extends EventEmitter {
|
|
|
1393
1396
|
* await client.logout();
|
|
1394
1397
|
*/
|
|
1395
1398
|
async logout() {
|
|
1396
|
-
await this.run('LOGOUT');
|
|
1399
|
+
return await this.run('LOGOUT');
|
|
1397
1400
|
}
|
|
1398
1401
|
|
|
1399
1402
|
/**
|
|
@@ -1432,9 +1435,11 @@ class ImapFlow extends EventEmitter {
|
|
|
1432
1435
|
// reject command that is currently processed
|
|
1433
1436
|
if (this.currentRequest && this.requestTagMap.has(this.currentRequest.tag)) {
|
|
1434
1437
|
let request = this.requestTagMap.get(this.currentRequest.tag);
|
|
1435
|
-
if (request) {
|
|
1438
|
+
if (request && ['LOGOUT'].includes(request.command)) {
|
|
1436
1439
|
this.requestTagMap.delete(request.tag);
|
|
1437
|
-
|
|
1440
|
+
const error = new Error('Connection not available');
|
|
1441
|
+
error.code = 'NoConnection';
|
|
1442
|
+
request.reject(error);
|
|
1438
1443
|
}
|
|
1439
1444
|
this.currentRequest = false;
|
|
1440
1445
|
}
|
|
@@ -1446,7 +1451,9 @@ class ImapFlow extends EventEmitter {
|
|
|
1446
1451
|
let request = this.requestTagMap.get(req.tag);
|
|
1447
1452
|
if (request) {
|
|
1448
1453
|
this.requestTagMap.delete(request.tag);
|
|
1449
|
-
|
|
1454
|
+
const error = new Error('Connection not available');
|
|
1455
|
+
error.code = 'NoConnection';
|
|
1456
|
+
request.reject(error);
|
|
1450
1457
|
}
|
|
1451
1458
|
}
|
|
1452
1459
|
}
|
|
@@ -2602,7 +2609,7 @@ class ImapFlow extends EventEmitter {
|
|
|
2602
2609
|
* @example
|
|
2603
2610
|
* let mailbox = await client.mailboxOpen('INBOX');
|
|
2604
2611
|
* // download body parts '2', and '3' from all messages in the selected mailbox
|
|
2605
|
-
* let response = await client.downloadMany('*', ['2', '3]);
|
|
2612
|
+
* let response = await client.downloadMany('*', ['2', '3']);
|
|
2606
2613
|
* process.stdout.write(response[2].content)
|
|
2607
2614
|
* process.stdout.write(response[3].content)
|
|
2608
2615
|
*/
|
|
@@ -2728,8 +2735,9 @@ class ImapFlow extends EventEmitter {
|
|
|
2728
2735
|
}
|
|
2729
2736
|
|
|
2730
2737
|
if (this.socket.destroyed) {
|
|
2731
|
-
|
|
2732
|
-
|
|
2738
|
+
const error = new Error('Connection not available');
|
|
2739
|
+
error.code = 'NoConnection';
|
|
2740
|
+
throw error;
|
|
2733
2741
|
}
|
|
2734
2742
|
|
|
2735
2743
|
clearTimeout(this.idleStartTimer);
|
|
@@ -2771,10 +2779,11 @@ class ImapFlow extends EventEmitter {
|
|
|
2771
2779
|
const { resolve, reject, path, options, lockId } = this.locks.shift();
|
|
2772
2780
|
|
|
2773
2781
|
if (!this.usable || this.socket.destroyed) {
|
|
2774
|
-
// reject all
|
|
2775
|
-
let err = new Error('Connection not available');
|
|
2776
2782
|
this.log.trace({ msg: 'Failed to acquire mailbox lock', path, lockId });
|
|
2777
|
-
reject
|
|
2783
|
+
// reject all
|
|
2784
|
+
let error = new Error('Connection not available');
|
|
2785
|
+
error.code = 'NoConnection';
|
|
2786
|
+
reject(error);
|
|
2778
2787
|
return await this.processLocks(true);
|
|
2779
2788
|
}
|
|
2780
2789
|
|
package/lib/types.d.ts
CHANGED
|
@@ -502,7 +502,7 @@ declare module "imapflow" {
|
|
|
502
502
|
* @example
|
|
503
503
|
* let mailbox = await client.mailboxOpen('INBOX');
|
|
504
504
|
* // download body parts '2', and '3' from all messages in the selected mailbox
|
|
505
|
-
* let response = await client.downloadMany('*', ['2', '3]);
|
|
505
|
+
* let response = await client.downloadMany('*', ['2', '3']);
|
|
506
506
|
* process.stdout.write(response[2].content)
|
|
507
507
|
* process.stdout.write(response[3].content)
|
|
508
508
|
* @param range - UID or sequence number for the message to fetch
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imapflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.148",
|
|
4
4
|
"description": "IMAP Client for Node",
|
|
5
5
|
"main": "./lib/imap-flow.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
"@babel/eslint-plugin": "7.22.10",
|
|
33
33
|
"@babel/plugin-syntax-class-properties": "7.12.13",
|
|
34
34
|
"@babel/preset-env": "7.23.2",
|
|
35
|
-
"@types/node": "20.8.
|
|
36
|
-
"braintree-jsdoc-template": "3.3.0",
|
|
35
|
+
"@types/node": "20.8.10",
|
|
37
36
|
"eslint": "8.52.0",
|
|
38
37
|
"eslint-config-nodemailer": "1.2.0",
|
|
39
38
|
"eslint-config-prettier": "9.0.0",
|
|
@@ -41,6 +40,7 @@
|
|
|
41
40
|
"grunt-cli": "1.4.3",
|
|
42
41
|
"grunt-contrib-nodeunit": "5.0.0",
|
|
43
42
|
"grunt-eslint": "24.3.0",
|
|
43
|
+
"imapflow-jsdoc-template": "3.4.0-imapflow.1",
|
|
44
44
|
"jsdoc": "3.6.11",
|
|
45
45
|
"st": "3.0.0",
|
|
46
46
|
"tsd-jsdoc": "2.5.0"
|