imapflow 1.0.162 → 1.0.163

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.163](https://github.com/postalsys/imapflow/compare/v1.0.162...v1.0.163) (2024-07-06)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **parser:** parse subfolders with square brackets ([0d0e8a6](https://github.com/postalsys/imapflow/commit/0d0e8a6ea379adf11594684d49a1ce5031339939))
9
+ * **socket:** Use destroy() instead of destroySoon() ([830c2d1](https://github.com/postalsys/imapflow/commit/830c2d18f3d27eb12dc6babe4edd37fed5f65490))
10
+
3
11
  ## [1.0.162](https://github.com/postalsys/imapflow/compare/v1.0.161...v1.0.162) (2024-05-07)
4
12
 
5
13
 
@@ -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
- let error = new Error(`Unexpected section start char [ at position ${this.pos + i} [E14]`);
359
- error.code = 'ParserError14';
360
- error.parserContext = { input: this.str, pos: this.pos + i, chr };
361
- throw error;
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
- if (typeof this.socket.destroySoon === 'function') {
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
- if (typeof this.writeSocket.destroySoon === 'function') {
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
- if (typeof this.socket.destroySoon === 'function') {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.162",
3
+ "version": "1.0.163",
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.5",
32
- "@babel/eslint-plugin": "7.24.5",
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.5",
35
- "@types/node": "20.12.8",
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.1.0",
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.13",
56
- "pino": "9.0.0",
55
+ "nodemailer": "6.9.14",
56
+ "pino": "9.2.0",
57
57
  "socks": "2.8.3"
58
58
  }
59
59
  }
@@ -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
+ });