imapflow 1.0.190 → 1.0.192
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 +17 -0
- package/lib/handler/imap-stream.js +15 -1
- package/lib/imap-flow.js +35 -2
- package/lib/search-compiler.js +6 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.192](https://github.com/postalsys/imapflow/compare/v1.0.191...v1.0.192) (2025-07-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* destroy _inflate and _deflate streams if set ([eab274b](https://github.com/postalsys/imapflow/commit/eab274b15b2ea2ee93aa027fd874249b1860167e))
|
|
9
|
+
* do not allow too large IMAP literals ([680a44d](https://github.com/postalsys/imapflow/commit/680a44d6550d51fc00602c49d6c5a377046c3504))
|
|
10
|
+
* Improved socket handler listener setup/cleanup ([0b72714](https://github.com/postalsys/imapflow/commit/0b727140866d220ff1df07d7245c60aa72e3be4a))
|
|
11
|
+
* remove unneeded timer ([1867606](https://github.com/postalsys/imapflow/commit/1867606aaf5ea37935c460aca1b615ab2a2b6534))
|
|
12
|
+
|
|
13
|
+
## [1.0.191](https://github.com/postalsys/imapflow/compare/v1.0.190...v1.0.191) (2025-07-10)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **search:** Use the next day when searching BEFORE/SENTBEFORE to include current day in the range as well ([9e6d749](https://github.com/postalsys/imapflow/commit/9e6d749ac781c6240b3113f2ec8d329ad831d740))
|
|
19
|
+
|
|
3
20
|
## [1.0.190](https://github.com/postalsys/imapflow/compare/v1.0.189...v1.0.190) (2025-07-10)
|
|
4
21
|
|
|
5
22
|
|
|
@@ -13,6 +13,9 @@ const NUM_9 = 0x39;
|
|
|
13
13
|
const CURLY_OPEN = 0x7b;
|
|
14
14
|
const CURLY_CLOSE = 0x7d;
|
|
15
15
|
|
|
16
|
+
// Maximum allowed literal size: 1GB (1073741824 bytes)
|
|
17
|
+
const MAX_LITERAL_SIZE = 1024 * 1024 * 1024;
|
|
18
|
+
|
|
16
19
|
class ImapStream extends Transform {
|
|
17
20
|
constructor(options) {
|
|
18
21
|
super({
|
|
@@ -80,8 +83,19 @@ class ImapStream extends Transform {
|
|
|
80
83
|
continue;
|
|
81
84
|
}
|
|
82
85
|
if (c === CURLY_OPEN && numBytes.length) {
|
|
86
|
+
const literalSize = Number(Buffer.from(numBytes).toString());
|
|
87
|
+
|
|
88
|
+
if (literalSize > MAX_LITERAL_SIZE) {
|
|
89
|
+
const err = new Error(`Literal size ${literalSize} exceeds maximum allowed size of ${MAX_LITERAL_SIZE} bytes`);
|
|
90
|
+
err.code = 'LiteralTooLarge';
|
|
91
|
+
err.literalSize = literalSize;
|
|
92
|
+
err.maxSize = MAX_LITERAL_SIZE;
|
|
93
|
+
this.emit('error', err);
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
83
97
|
this.state = LITERAL;
|
|
84
|
-
this.literalWaiting =
|
|
98
|
+
this.literalWaiting = literalSize;
|
|
85
99
|
return true;
|
|
86
100
|
}
|
|
87
101
|
return false;
|
package/lib/imap-flow.js
CHANGED
|
@@ -754,6 +754,9 @@ class ImapFlow extends EventEmitter {
|
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
setSocketHandlers() {
|
|
757
|
+
// Clear any existing handlers first to prevent duplicates
|
|
758
|
+
this.clearSocketHandlers();
|
|
759
|
+
|
|
757
760
|
this._socketError =
|
|
758
761
|
this._socketError ||
|
|
759
762
|
(err => {
|
|
@@ -806,14 +809,22 @@ class ImapFlow extends EventEmitter {
|
|
|
806
809
|
this.socket.on('tlsClientError', this._socketError);
|
|
807
810
|
this.socket.on('timeout', this._socketTimeout);
|
|
808
811
|
|
|
809
|
-
this.writeSocket.
|
|
812
|
+
if (this.writeSocket && this.writeSocket !== this.socket) {
|
|
813
|
+
this.writeSocket.on('error', this._socketError);
|
|
814
|
+
}
|
|
810
815
|
}
|
|
811
816
|
|
|
812
817
|
clearSocketHandlers() {
|
|
818
|
+
if (!this.socket) {
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
|
|
813
822
|
if (this._socketError) {
|
|
814
823
|
this.socket.removeListener('error', this._socketError);
|
|
815
824
|
this.socket.removeListener('tlsClientError', this._socketError);
|
|
816
|
-
this.writeSocket.
|
|
825
|
+
if (this.writeSocket && this.writeSocket !== this.socket) {
|
|
826
|
+
this.writeSocket.removeListener('error', this._socketError);
|
|
827
|
+
}
|
|
817
828
|
}
|
|
818
829
|
if (this._socketTimeout) {
|
|
819
830
|
this.socket.removeListener('timeout', this._socketTimeout);
|
|
@@ -1614,6 +1625,7 @@ class ImapFlow extends EventEmitter {
|
|
|
1614
1625
|
clearTimeout(this.idleStartTimer);
|
|
1615
1626
|
clearTimeout(this.upgradeTimeout);
|
|
1616
1627
|
clearTimeout(this.connectTimeout);
|
|
1628
|
+
clearTimeout(this.greetingTimeout);
|
|
1617
1629
|
|
|
1618
1630
|
this.usable = false;
|
|
1619
1631
|
this.idling = false;
|
|
@@ -1673,6 +1685,27 @@ class ImapFlow extends EventEmitter {
|
|
|
1673
1685
|
}
|
|
1674
1686
|
}
|
|
1675
1687
|
|
|
1688
|
+
// cleanup compression streams if they exist
|
|
1689
|
+
if (this._inflate) {
|
|
1690
|
+
try {
|
|
1691
|
+
this._inflate.unpipe();
|
|
1692
|
+
this._inflate.destroy();
|
|
1693
|
+
this._inflate = null;
|
|
1694
|
+
} catch (err) {
|
|
1695
|
+
this.log.error({ err, info: 'Failed to destroy inflate stream', cid: this.id });
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
if (this._deflate) {
|
|
1700
|
+
try {
|
|
1701
|
+
this._deflate.unpipe();
|
|
1702
|
+
this._deflate.destroy();
|
|
1703
|
+
this._deflate = null;
|
|
1704
|
+
} catch (err) {
|
|
1705
|
+
this.log.error({ err, info: 'Failed to destroy deflate stream', cid: this.id });
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1676
1709
|
if (this.socket && !this.socket.destroyed && this.writeSocket !== this.socket) {
|
|
1677
1710
|
try {
|
|
1678
1711
|
this.socket.destroy();
|
package/lib/search-compiler.js
CHANGED
|
@@ -66,6 +66,12 @@ let setOpt = (attributes, term, value, type) => {
|
|
|
66
66
|
* @param {*} value - Date value to format
|
|
67
67
|
*/
|
|
68
68
|
let processDateField = (attributes, term, value) => {
|
|
69
|
+
if (['BEFORE', 'SENTBEFORE'].includes(term.toUpperCase()) && isDate(value) && value.toISOString().substring(11) !== '00:00:00.000Z') {
|
|
70
|
+
// Set to next day to include current day as well, othwerise BEFORE+AFTER
|
|
71
|
+
// searches for the same day but different time values do not match anything
|
|
72
|
+
value = new Date(value.getTime() + 24 * 3600 * 1000);
|
|
73
|
+
}
|
|
74
|
+
|
|
69
75
|
let date = formatDate(value);
|
|
70
76
|
if (!date) {
|
|
71
77
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imapflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.192",
|
|
4
4
|
"description": "IMAP Client for Node",
|
|
5
5
|
"main": "lib/imap-flow.js",
|
|
6
6
|
"types": "lib/imap-flow.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@babel/eslint-plugin": "7.27.1",
|
|
33
33
|
"@babel/plugin-syntax-class-properties": "7.12.13",
|
|
34
34
|
"@babel/preset-env": "7.28.0",
|
|
35
|
-
"@types/node": "24.0
|
|
35
|
+
"@types/node": "24.1.0",
|
|
36
36
|
"eslint": "8.57.0",
|
|
37
37
|
"eslint-config-nodemailer": "1.2.0",
|
|
38
38
|
"eslint-config-prettier": "9.1.0",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"grunt-cli": "1.5.0",
|
|
41
41
|
"grunt-contrib-nodeunit": "5.0.0",
|
|
42
42
|
"grunt-eslint": "24.3.0",
|
|
43
|
-
"imapflow-jsdoc-template": "3.4.0-imapflow.
|
|
44
|
-
"jsdoc": "
|
|
43
|
+
"imapflow-jsdoc-template": "3.4.0-imapflow.3",
|
|
44
|
+
"jsdoc": "4.0.4",
|
|
45
45
|
"st": "3.0.2",
|
|
46
46
|
"typescript": "5.8.3"
|
|
47
47
|
},
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"libbase64": "1.3.0",
|
|
52
52
|
"libmime": "5.3.7",
|
|
53
53
|
"libqp": "2.1.1",
|
|
54
|
-
"mailsplit": "5.4.
|
|
54
|
+
"mailsplit": "5.4.6",
|
|
55
55
|
"nodemailer": "7.0.5",
|
|
56
56
|
"pino": "9.7.0",
|
|
57
|
-
"socks": "2.8.
|
|
57
|
+
"socks": "2.8.6"
|
|
58
58
|
}
|
|
59
59
|
}
|